-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.selectall.min.js
3 lines (3 loc) · 1.22 KB
/
jquery.selectall.min.js
1
2
3
(function(a){checkedItems=[];checkedAll=!1;var e=function(b,c){this.element=a(b);this.settings=a.extend({allSelector:""},c||{});a(this.element).on("click",a.proxy(this.click,this));if(""!=this.settings.allSelector)a(this.settings.allSelector).on("click",a.proxy(this.allClick,this));this.append=function(a){-1==this.search(a)&&checkedItems.push(a);return checkedItems};this.search=function(a){return checkedItems.indexOf(String(a))};this.removeID=function(a){a=this.search(String(a));-1!=a&&checkedItems.splice(a,
1);return checkedItems};this.removeIndex=function(a){checkedItems.splice(a,1);return checkedItems};this.getList=function(){return checkedItems}};e.prototype={click:function(){var b=a(this.element).val(),c=this.search(b);a(this.element).prop("checked")?this.append(b):this.removeIndex(c);a(this.element).trigger("change",this.element)},allClick:function(){var b=a(this.settings.allSelector).prop("checked"),c=a(this.element).val(),d=this.search(c);b?(-1==d&&this.append(c),a(this.element).prop("checked",
!0)):(this.removeIndex(d),a(this.element).prop("checked",!1));a(this.element).trigger("change",this.element)}};a.fn.selectall=function(b){return this.each(function(){var c=a(this),d=new e(this,b);c.data("selectall",d)})}})(jQuery);