X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2Fjquery%2Fjquery.crmasmselect.js;h=9b1dc314ff78b08639cb314f2c3d673c6a0b4796;hb=e52e75227248e4251661d10f9600bd26be49494c;hp=49b93e123987cf9c3c313c73c3958113d23429ec;hpb=192e8d1a947814993aa699e47ac1669ac17b1045;p=civicrm-core.git diff --git a/js/jquery/jquery.crmasmselect.js b/js/jquery/jquery.crmasmselect.js index 49b93e1239..9b1dc314ff 100644 --- a/js/jquery/jquery.crmasmselect.js +++ b/js/jquery/jquery.crmasmselect.js @@ -71,13 +71,13 @@ .attr('id', options.listClass + index); $container = $("
") - .addClass(options.containerClass) - .attr('id', options.containerClass + index); + .addClass(options.containerClass) + .attr('id', options.containerClass + index); buildSelect(); $select.change(selectChangeEvent) - .click(selectClickEvent); + .click(selectClickEvent); $original.change(originalChangeEvent) .wrap($container).before($select).before($ol); @@ -102,31 +102,31 @@ $(this).children("li").each(function(n) { - $option = $('#' + $(this).attr('rel')); + $option = $('#' + $(this).attr('rel')); if($(this).is(".ui-sortable-helper")) { - updatedOptionId = $option.attr('id'); + updatedOptionId = $option.attr('id'); return; } - $original.append($option); - }); + $original.append($option); + }); - if(updatedOptionId) triggerOriginalChange(updatedOptionId, 'sort'); + if(updatedOptionId) triggerOriginalChange(updatedOptionId, 'sort'); } - }).addClass(options.listSortableClass); + }).addClass(options.listSortableClass); } function selectChangeEvent(e) { - + // an item has been selected on the regular select we created // check to make sure it's not an IE screwup, and add it to the list if($.browser.msie && $.browser.version < 7 && !ieClick) return; - var id = $(this).children("option:selected").slice(0,1).attr('rel'); - addListItem(id); - ieClick = false; + var id = $(this).children("option:selected").slice(0,1).attr('rel'); + addListItem(id); + ieClick = false; triggerOriginalChange(id, 'add'); // for use by user-defined callbacks } @@ -136,7 +136,7 @@ // making sure a click preceded the change() event reduces the chance // if unintended items being added. there may be a better solution? - ieClick = true; + ieClick = true; } function originalChangeEvent(e) { @@ -145,8 +145,8 @@ // on the original // used only by buildSelect() - if(disabled == undefined) var disabled = false; + if(disabled == undefined) disabled = false; - var $O = $('#' + optionId); + var $O = $('#' + optionId); var $option = $("") .val($O.val()) .attr('rel', optionId) .addClass(optionClasses); - if(disabled) disableSelectOption($option); + if(disabled) disableSelectOption($option); - $select.append($option); + $select.append($option); } function selectFirstItem() { @@ -244,7 +244,7 @@ // add a new item to the html list - var $O = $('#' + optionId); + var $O = $('#' + optionId); if(!$O) return; // this is the first item, selectLabel @@ -252,14 +252,14 @@ .attr("href", "#") .addClass(options.removeClass) .prepend(options.removeLabel) - .click(function() { - dropListItem($(this).parent('li').attr('rel')); - return false; - }); + .click(function() { + dropListItem($(this).parent('li').attr('rel')); + return false; + }); var $itemLabel = $("") .addClass(options.listItemLabelClass) - .html($O.html()); + .html($O.html()); var $item = $("
  • ") .attr('rel', optionId) @@ -275,32 +275,32 @@ } if(options.addItemTarget == 'top' && !buildingSelect) { - $ol.prepend($item); - if(options.sortable) $original.prepend($O); + $ol.prepend($item); + if(options.sortable) $original.prepend($O); } else { - $ol.append($item); - if(options.sortable) $original.append($O); + $ol.append($item); + if(options.sortable) $original.append($O); } - addListItemShow($item); + addListItemShow($item); disableSelectOption($("[rel=" + optionId + "]", $select)); if(!buildingSelect) { - setHighlight($item, options.highlightAddedLabel); + setHighlight($item, options.highlightAddedLabel); selectFirstItem(); - if(options.sortable) $ol.sortable("refresh"); + if(options.sortable) $ol.sortable("refresh"); } - + if(options.respectParents) { - + if($O.hasClass('child')) { parentName = $O.attr('class').split('parent-')[1]; parentName = parentName.split(' ')[0]; parentId = $('.option-'+parentName).attr('rel'); addListItem(parentId); - }; - }; + } + } } function addListItemShow($item) { @@ -312,15 +312,15 @@ $item.animate({ opacity: "show", height: "show" - }, 100, "swing", function() { + }, 100, "swing", function() { $item.animate({ height: "+=2px" }, 50, "swing", function() { $item.animate({ height: "-=2px" - }, 25, "swing"); - }); - }); + }, 25, "swing"); + }); + }); } else { $item.show(); } @@ -330,19 +330,19 @@ // remove an item from the html list - if(highlightItem == undefined) var highlightItem = true; - var $O = $('#' + optionId); + if(highlightItem == undefined) highlightItem = true; + var $O = $('#' + optionId); $O.prop('selected', false); $item = $ol.children("li[rel=" + optionId + "]"); - dropListItemHide($item); + dropListItemHide($item); enableSelectOption($("[rel=" + optionId + "]", options.removeWhenAdded ? $selectRemoved : $select)); - if(highlightItem) setHighlight($item, options.highlightRemovedLabel); + if(highlightItem) setHighlight($item, options.highlightRemovedLabel); + + triggerOriginalChange(optionId, 'drop'); - triggerOriginalChange(optionId, 'drop'); - } function dropListItemHide($item) { @@ -363,13 +363,13 @@ }, 50, "swing", function() { $prevItem.animate({ height: "+=2px" - }, 100, "swing"); - }); - $item.remove(); - }); - + }, 100, "swing"); + }); + $item.remove(); + }); + } else { - $item.remove(); + $item.remove(); } } @@ -379,7 +379,7 @@ // directly after the