diff --git a/jquery.selectlist.dev.js b/jquery.selectlist.dev.js index d3731c8..0bc80ac 100755 --- a/jquery.selectlist.dev.js +++ b/jquery.selectlist.dev.js @@ -15,40 +15,40 @@ $.selectList = function (select, options) { /* Variables starting with $ are jQuery objects */ - var + var /* Single select element (drop-down list) */ $selectSingle, - + /* List of selected options */ $list, - + /* List items */ $item, $newItem, - + /* Option element */ $option, - + /* * Keyboard event to use (keydown for MSIE and Safari, keypress for * other browsers) */ keyEvent, - + /* Has the plugin been initialized? */ ready, - + /* * The index of the first option element (equal to 1 if there is a hint, * otherwise 0) */ first = 0, - + /* Flags for keeping track of events */ change, click, keypress, enter; /** * Make list item visible. - * + * * @param $item * A jQuery object representing the list item * @param callback @@ -69,7 +69,7 @@ $.selectList = function (select, options) { /** * Make list item hidden. - * + * * @param $item * A jQuery object representing the list item * @param callback @@ -90,7 +90,7 @@ $.selectList = function (select, options) { /** * Compare two list items by text data or with an user-defined function. - * + * * @param item1 * A DOM object representing the first list item to compare * @param item2 @@ -116,7 +116,7 @@ $.selectList = function (select, options) { /** * Add a new item to the list of selected items. - * + * * @param value * Value of the new item or a DOM object representing a HTML * option element @@ -138,7 +138,7 @@ $.selectList = function (select, options) { */ if ($option[0].index < first) return; - + /* Extract value and text */ value = $option.val(); text = $option.text(); @@ -148,7 +148,7 @@ $.selectList = function (select, options) { * Find the option with the given value (and possibly text) in the * select element. */ - $option = $selectSingle.find("option[value=\"" + + $option = $selectSingle.find("option[value=\"" + value.replace("'", "\\\"") + "\"]"); if ($option.length) @@ -159,10 +159,10 @@ $.selectList = function (select, options) { else $option = null; } - + if (text === undefined) text = $option ? $option.text() : value; - + /* If duplicates are not allowed, disable the option */ if ($option && !options.duplicates) $option.attr('disabled', 'disabled') @@ -171,7 +171,7 @@ $.selectList = function (select, options) { * our own flag as a workaround. */ .data('disabled', 1); - + /* * Create the new list item based on the template, and make it hidden. * The $('').text(text).html() part is a trick to convert special @@ -196,7 +196,7 @@ $.selectList = function (select, options) { if (options.clickRemove) remove($(this)); }); - + /* * If there is a hint (first == 1), set it back as the selected option * in the select element. @@ -207,9 +207,9 @@ $.selectList = function (select, options) { /* Callback function that will be called after the item is added */ var callback = function () { if (callHandler !== false) - options.onAdd(select, value, text); + options.onAdd(select, value, text); }; - + if (options.sort && ($item = $list.children().eq(0)).length) { /* * If the list is supposed to be automatically sorted, look for the @@ -218,27 +218,27 @@ $.selectList = function (select, options) { */ while ($item.length && cmp($newItem[0], $item[0])) $item = $item.next(); - + show($item.length ? $newItem.insertBefore($item) : $newItem.appendTo($list), callback); } else /* Otherwise, append the new element at the end of the list. */ show($newItem.appendTo($list), callback); - + $(select).empty(); - + $list.children().each(function () { $(select).append($("