Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
resources.tools_javascript_jquery-picklist.min.js Maven / Gradle / Ivy
(function(c){c.widget("awnry.pickList",{widgetEventPrefix:"pickList_",options:{mainClass:"pickList",listContainerClass:"pickList_listContainer",sourceListContainerClass:"pickList_sourceListContainer",controlsContainerClass:"pickList_controlsContainer",targetListContainerClass:"pickList_targetListContainer",listClass:"pickList_list",sourceListClass:"pickList_sourceList",targetListClass:"pickList_targetList",clearClass:"pickList_clear",listItemClass:"pickList_listItem",richListItemClass:"pickList_richListItem",
selectedListItemClass:"pickList_selectedListItem",addAllClass:"pickList_addAll",addClass:"pickList_add",removeAllClass:"pickList_removeAll",removeClass:"pickList_remove",addAllLabel:">>",addLabel:">",removeAllLabel:"<<",removeLabel:"<",listLabelClass:"pickList_listLabel",sourceListLabel:"Available",sourceListLabelClass:"pickList_sourceListLabel",targetListLabel:"Selected",targetListLabelClass:"pickList_targetListLabel",sortItems:!0,sortAttribute:"label",listItemValueAttribute:"data-value",
items:[]},_create:function(){this._buildPickList();this._refresh()},_buildPickList:function(){this._trigger("beforeBuild");this.pickList=c("
").hide().addClass(this.options.mainClass).insertAfter(this.element).append(this._buildSourceList()).append(this._buildControls()).append(this._buildTargetList()).append(c("
").addClass(this.options.clearClass));this._populateLists();this.element.hide();this.pickList.show();this._trigger("afterBuild")},_buildSourceList:function(){var a=c("
").addClass(this.options.listContainerClass).addClass(this.options.sourceListContainerClass).css({"-moz-user-select":"none",
"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none"}).each(function(){this.onselectstart=function(){return!1}}),b=c("
").text(this.options.sourceListLabel).addClass(this.options.listLabelClass).addClass(this.options.sourceListLabelClass);this.sourceList=c("").addClass(this.options.listClass).addClass(this.options.sourceListClass).delegate("li","click",{pickList:this},this._changeHandler);a.append(b).append(this.sourceList);this.sourceList.delegate(".pickList_listItem",
"dblclick",{pickList:this},function(a){a=a.data.pickList;a._addItems(a.sourceList.children(".ui-selected"))});return a},_buildTargetList:function(){var a=c("
").addClass(this.options.listContainerClass).addClass(this.options.targetListContainerClass).css({"-moz-user-select":"none","-webkit-user-select":"none","user-select":"none","-ms-user-select":"none"}).each(function(){this.onselectstart=function(){return!1}}),b=c("
").text(this.options.targetListLabel).addClass(this.options.listLabelClass).addClass(this.options.targetListLabelClass);
this.targetList=c("").addClass(this.options.listClass).addClass(this.options.targetListClass).delegate("li","click",{pickList:this},this._changeHandler);a.append(b).append(this.targetList);this.targetList.delegate(".pickList_listItem","dblclick",{pickList:this},function(a){a=a.data.pickList;a._removeItems(a.targetList.children(".ui-selected"))});return a},_buildControls:function(){this.controls=c("
").addClass(this.options.controlsContainerClass);this.addAllButton=c(" ").click({pickList:this},
this._addAllHandler).html(this.options.addAllLabel).addClass(this.options.addAllClass);this.addButton=c(" ").click({pickList:this},this._addHandler).html(this.options.addLabel).addClass(this.options.addClass);this.removeButton=c(" ").click({pickList:this},this._removeHandler).html(this.options.removeLabel).addClass(this.options.removeClass);this.removeAllButton=c(" ").click({pickList:this},this._removeAllHandler).html(this.options.removeAllLabel).addClass(this.options.removeAllClass);
this.controls.append(this.addAllButton).append(this.addButton).append(this.removeButton).append(this.removeAllButton);return this.controls},_populateLists:function(){var a=this;a._trigger("beforePopulate");var b=[],c=[],e=a.element.children();e.not(":selected").each(function(){b.push(a._createDoppelganger(this))});e.filter(":selected").each(function(){c.push(a._createDoppelganger(this))});a.sourceList.append(b.join("\n"));a.targetList.append(c.join("\n"));a.insertItems(a.options.items);a._trigger("afterPopulate")},
_addItems:function(a){var b=this;b._trigger("beforeAdd");b.targetList.append(b._removeSelections(a));var d=[];a.each(function(){d.push(b._getItemValue(this))});b.element.children().filter(function(){return-1!=c.inArray(this.value,d)}).attr("selected","selected");b._refresh();b._trigger("afterAdd",null,{items:a});b._trigger("onChange",null,{type:"add",items:a})},_removeItems:function(a){var b=this;b._trigger("beforeRemove");b.sourceList.append(b._removeSelections(a));var d=[];a.each(function(){d.push(b._getItemValue(this))});
b.element.children().filter(function(){return-1!=c.inArray(this.value,d)}).removeAttr("selected");b._refresh();b._trigger("afterRemove",null,{items:a});b._trigger("onChange",null,{type:"remove",items:a})},_addAllHandler:function(a){a=a.data.pickList;a._trigger("beforeAddAll");var b=a.sourceList.children();a.targetList.append(a._removeSelections(b));a.element.children().not(":selected").attr("selected","selected");a._refresh();a._trigger("afterAddAll",null,{items:b});a._trigger("onChange",null,{type:"addAll",
items:b})},_addHandler:function(a){a=a.data.pickList;a._addItems(a.sourceList.children(".ui-selected"))},_removeHandler:function(a){a=a.data.pickList;a._removeItems(a.targetList.children(".ui-selected"))},_removeAllHandler:function(a){a=a.data.pickList;a._trigger("beforeRemoveAll");var b=a.targetList.children();a.sourceList.append(a._removeSelections(b));a.element.children().filter(":selected").removeAttr("selected");a._refresh();a._trigger("afterRemoveAll",null,{items:b});a._trigger("onChange",null,
{type:"removeAll",items:b})},_refresh:function(){this._trigger("beforeRefresh");this._refreshControls();this.options.sortItems&&(this._sortItems(this.sourceList,this.options),this._sortItems(this.targetList,this.options));this._trigger("afterRefresh")},_refreshControls:function(){this._trigger("beforeRefreshControls");this.sourceList.children().length?this.addAllButton.removeAttr("disabled"):this.addAllButton.attr("disabled","disabled");this.targetList.children().length?this.removeAllButton.removeAttr("disabled"):
this.removeAllButton.attr("disabled","disabled");this.sourceList.children(".ui-selected").length?this.addButton.removeAttr("disabled"):this.addButton.attr("disabled","disabled");this.targetList.children(".ui-selected").length?this.removeButton.removeAttr("disabled"):this.removeButton.attr("disabled","disabled");this._trigger("afterRefreshControls")},_sortItems:function(a,b){var d=[];a.children().each(function(){d.push(c(this))});d.sort(function(a,c){return a.attr(b.sortAttribute)>c.attr(b.sortAttribute)?
1:a.attr(b.sortAttribute)==c.attr(b.sortAttribute)?0:-1});a.empty();for(var e=0;e"+a.label+""},_createListItem:function(a){if(void 0!=a.element){var b=a.element.clone().wrap("").parent().html();a.element.hide();return"
"+b+" "}return"
"+a.label+
" "},_createDoppelganger:function(a){return"
"+c(a).text()+" "},_getItemValue:function(a){return c(a).attr(this.options.listItemValueAttribute)}})})(jQuery);