diff options
author | isteven <isteven@server.fake> | 2014-05-07 14:19:36 +0800 |
---|---|---|
committer | isteven <isteven@server.fake> | 2014-05-07 14:19:36 +0800 |
commit | c638175e941247a8920050274d1d82ffd9a2ff29 (patch) | |
tree | b74256a2e68c96b8ccdc43d6062de5c3515c2e29 /angular-multi-select.min.js | |
parent | d045bb2e47e40a8dfe1b53b11b842fbcbdd4ac2a (diff) | |
download | angular-multi-select-c638175e941247a8920050274d1d82ffd9a2ff29.zip angular-multi-select-c638175e941247a8920050274d1d82ffd9a2ff29.tar.gz angular-multi-select-c638175e941247a8920050274d1d82ffd9a2ff29.tar.bz2 |
added minified version
Diffstat (limited to 'angular-multi-select.min.js')
-rw-r--r-- | angular-multi-select.min.js | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/angular-multi-select.min.js b/angular-multi-select.min.js index aeda51d..3a5974e 100644 --- a/angular-multi-select.min.js +++ b/angular-multi-select.min.js @@ -1,8 +1 @@ -angular.B("multi-select",["ng"]).v("multiSelect",["$sce",function(f){return{C:"AE",replace:!0,scope:{a:"=",n:"=",u:"@",h:"@",p:"@",b:"@",i:"@",orientation:"@",f:"@",m:"=",e:"@"},F:'<span class="multiSelect inlineBlock"><button type="button" class="multiSelect button multiSelectButton" ng-click="toggleCheckboxes( $event ); refreshSelectedItems();" ng-bind-html="varButtonLabel"></button><div class="multiSelect checkboxLayer hide"><div class="multiSelect line"><span ng-if="!isDisabled">Select: </span><button type="button" ng-click="select( \'all\' )" class="multiSelect helperButton" ng-if="!isDisabled && selectionMode.toUpperCase() != \'SINGLE\'">All</button> <button type="button" ng-click="select( \'none\' )" class="multiSelect helperButton" ng-if="!isDisabled && selectionMode.toUpperCase() != \'SINGLE\'">None</button> <button type="button" ng-click="select( \'reset\' )" class="multiSelect helperButton" ng-if="!isDisabled">Reset</button></div><div class="multiSelect line">Filter: <input class="multiSelect" type="text" ng-model="labelFilter" /> <button type="button" class="multiSelect helperButton" ng-click="labelFilter=\'\'">Clear</button></div><div ng-repeat="item in inputModel | filter:labelFilter" ng-class="orientation" class="multiSelect multiSelectItem"><div class="multiSelect acol"><div class="multiSelect" ng-show="item[ tickProperty ]">✔</div></div><div class="multiSelect acol"><label class="multiSelect" ng-class="{checkboxSelected:item[ tickProperty ]}"><input class="multiSelect checkbox" type="checkbox" ng-disabled="itemIsDisabled( item )" ng-checked="item[ tickProperty ]" ng-click="syncItems( item, $event )" /><span class="multiSelect" ng-class="{disabled:itemIsDisabled( item )}" ng-bind-html="writeLabel( item, \'itemLabel\' )"></span></label> </div></div></div></span>', -link:function(a,h,e){a.d=[];a.j=[];a.c="";a.D=function(c,b){index=a.a.indexOf(c);a.a[index][a.b]=!a.a[index][a.b];if(e.h&&"SINGLE"===a.h.toUpperCase()){a.a[index][a.b]=!0;for(i=0;i<a.a.length;i++)i!==index&&(a.a[i][a.b]=!1);a.r(b)}a.g()};a.g=function(){a.c="";a.d=[];ctr=0;angular.forEach(a.a,function(b){"undefined"!==typeof b&&(!0!==b[a.b]&&"true"!==b[a.b]||a.d.push(b))});"undefined"!==typeof e.n&&(a.n=angular.k(a.d));if(0===a.d.length)a.c="None selected";else{var c=a.d.length;"undefined"!==typeof a.f&& -""!==a.f&&"0"!==a.f&&(c=a.f);a.q=a.d.length>c?!0:!1;angular.forEach(a.d,function(b){"undefined"!==typeof b&&(ctr<c&&(a.c+=(0<a.c.length?", ":"")+a.t(b)),ctr++)});!0===a.q&&(a.c+=", ... (Total: "+a.d.length+")")}a.c=f.s(a.c+'<span class="multiSelect caret"></span>')};a.w=function(c){return!0===c[a.i]?!0:!0===a.m?!0:!1};a.t=function(c){var b="";angular.forEach(a.buttonLabel.split(" "),function(a){"undefined"!==typeof a&&angular.forEach(c,function(c,e){e==a&&(b+=" "+c)})});return f.s(b)};a.r=function(c){c.target&& -("BUTTON"!==c.target.tagName.toUpperCase()&&0>c.target.className.indexOf("multiSelectButton")?e.h&&"SINGLE"===a.h.toUpperCase()?"INPUT"===c.target.tagName.toUpperCase()&&(c=a.l(c.target,"div","checkboxLayer"),c=c.previousSibling):c=a.l(c.target,"button","multiSelectButton"):c=c.target);a.A="";var b=-1,d=document.querySelectorAll(".checkboxLayer"),g=document.querySelectorAll(".multiSelectButton");for(i=0;i<g.length;i++)if(c===g[i]){b=i;break}if(-1<b){for(i=0;i<d.length;i++)i!=b&&(d[i].className="multiSelect checkboxLayer hide"); -"multiSelect checkboxLayer hide"==d[b].className?d[b].className="multiSelect checkboxLayer show":"multiSelect checkboxLayer show"==d[b].className&&(d[b].className="multiSelect checkboxLayer hide")}};a.l=function(a,b,d){for(;a.parentNode;)if(a=a.parentNode,"undefined"!==typeof a.tagName&&a.tagName.toUpperCase()===b.toUpperCase()&&-1<a.className.indexOf(d))return a;return null};a.select=function(c){switch(c.toUpperCase()){case "ALL":angular.forEach(a.a,function(b){"undefined"!==typeof b&&!0!==b[a.i]&& -(b[a.b]=!0)});break;case "NONE":angular.forEach(a.a,function(b){"undefined"!==typeof b&&!0!==b[a.i]&&(b[a.b]=!1)});break;case "RESET":a.a=angular.k(a.j)}a.g()};validate=function(){"inputModel"in e||console.log("Multi-select error: input-model is not defined! (ID: "+a.e+")");"buttonLabel"in e||console.log("Multi-select error: button-label is not defined! (ID: "+a.e+")");"itemLabel"in e||console.log("Multi-select error: item-label is not defined! (ID: "+a.e+")");"tickProperty"in e||console.log("Multi-select error: tick-property is not defined! (ID: "+ -a.e+")")};validateProperties=function(c,b){var d=!1;angular.forEach(c,function(a){if("undefined"!==typeof a){var c=!0;angular.forEach(b,function(b){"undefined"===typeof b||!c||a in b||(d=!0,c=!1,missingLabel=a)})}});!0===d&&console.log('Multi-select error: property "'+missingLabel+'" is not available in the input model. (Name: '+a.e+")")};validate();a.g();a.o("inputModel",function(){"undefined"!==a.a&&(validateProperties(a.p.split(" "),a.a),validateProperties(Array(a.b),a.a));a.j=angular.k(a.a);a.g()}); -a.o("isDisabled",function(c){a.m=c});angular.element(document);Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var d=this.length;b<d;){if(this[b]===a)return b;++b}return-1})}}}]); +angular.module("multi-select",["ng"]).directive("multiSelect",["$sce",function(a){return{restrict:"AE",replace:true,scope:{inputModel:"=",outputModel:"=",buttonLabel:"@",selectionMode:"@",itemLabel:"@",tickProperty:"@",disableProperty:"@",orientation:"@",maxLabels:"@",isDisabled:"=",directiveId:"@"},template:'<span class="multiSelect inlineBlock"><button type="button" class="multiSelect button multiSelectButton" ng-click="toggleCheckboxes( $event ); refreshSelectedItems();" ng-bind-html="varButtonLabel"></button><div class="multiSelect checkboxLayer hide"><div class="multiSelect line"><span ng-if="!isDisabled">Select: </span><button type="button" ng-click="select( \'all\' )" class="multiSelect helperButton" ng-if="!isDisabled && selectionMode.toUpperCase() != \'SINGLE\'">All</button> <button type="button" ng-click="select( \'none\' )" class="multiSelect helperButton" ng-if="!isDisabled && selectionMode.toUpperCase() != \'SINGLE\'">None</button> <button type="button" ng-click="select( \'reset\' )" class="multiSelect helperButton" ng-if="!isDisabled">Reset</button></div><div class="multiSelect line">Filter: <input class="multiSelect" type="text" ng-model="labelFilter" /> <button type="button" class="multiSelect helperButton" ng-click="labelFilter=\'\'">Clear</button></div><div ng-repeat="item in inputModel | filter:labelFilter" ng-class="orientation" class="multiSelect multiSelectItem"><div class="multiSelect acol"><div class="multiSelect" ng-show="item[ tickProperty ]">✔</div></div><div class="multiSelect acol"><label class="multiSelect" ng-class="{checkboxSelected:item[ tickProperty ]}"><input class="multiSelect checkbox" type="checkbox" ng-disabled="itemIsDisabled( item )" ng-checked="item[ tickProperty ]" ng-click="syncItems( item, $event )" /><span class="multiSelect" ng-class="{disabled:itemIsDisabled( item )}" ng-bind-html="writeLabel( item, \'itemLabel\' )"></span></label> </div></div></div></span>',link:function(b,d,c){b.selectedItems=[];b.backUp=[];b.varButtonLabel="";b.syncItems=function(f,g){index=b.inputModel.indexOf(f);b.inputModel[index][b.tickProperty]=!b.inputModel[index][b.tickProperty];if(c.selectionMode&&b.selectionMode.toUpperCase()==="SINGLE"){b.inputModel[index][b.tickProperty]=true;for(i=0;i<b.inputModel.length;i++){if(i!==index){b.inputModel[i][b.tickProperty]=false}}b.toggleCheckboxes(g)}b.refreshSelectedItems()};b.refreshSelectedItems=function(){b.varButtonLabel="";b.selectedItems=[];ctr=0;angular.forEach(b.inputModel,function(g,f){if(typeof g!=="undefined"){if(g[b.tickProperty]===true||g[b.tickProperty]==="true"){b.selectedItems.push(g)}}});if(typeof c.outputModel!=="undefined"){b.outputModel=angular.copy(b.selectedItems)}if(b.selectedItems.length===0){b.varButtonLabel="None selected"}else{var e=b.selectedItems.length;if(typeof b.maxLabels!=="undefined"&&b.maxLabels!==""&&b.maxLabels!=="0"){e=b.maxLabels}if(b.selectedItems.length>e){b.more=true}else{b.more=false}angular.forEach(b.selectedItems,function(g,f){if(typeof g!=="undefined"){if(ctr<e){b.varButtonLabel+=(b.varButtonLabel.length>0?", ":"")+b.writeLabel(g,"buttonLabel")}ctr++}});if(b.more===true){b.varButtonLabel+=", ... (Total: "+b.selectedItems.length+")"}}b.varButtonLabel=a.trustAsHtml(b.varButtonLabel+'<span class="multiSelect caret"></span>')};b.itemIsDisabled=function(e){if(e[b.disableProperty]===true){return true}else{if(b.isDisabled===true){return true}else{return false}}};b.writeLabel=function(h,g){var f="";var e=b[g].split(" ");angular.forEach(e,function(j,k){if(typeof j!=="undefined"){angular.forEach(h,function(l,m){if(m==j){f+=" "+l}})}});return a.trustAsHtml(f)};b.toggleCheckboxes=function(j){if(j.target){if(j.target.tagName.toUpperCase()!=="BUTTON"&&j.target.className.indexOf("multiSelectButton")<0){if(c.selectionMode&&b.selectionMode.toUpperCase()==="SINGLE"){if(j.target.tagName.toUpperCase()==="INPUT"){j=b.findUpTag(j.target,"div","checkboxLayer");j=j.previousSibling}}else{j=b.findUpTag(j.target,"button","multiSelectButton")}}else{j=j.target}}b.labelFilter="";var g=-1;var h=document.querySelectorAll(".checkboxLayer");var f=document.querySelectorAll(".multiSelectButton");for(i=0;i<f.length;i++){if(j===f[i]){g=i;break}}if(g>-1){for(i=0;i<h.length;i++){if(i!=g){h[i].className="multiSelect checkboxLayer hide"}}if(h[g].className=="multiSelect checkboxLayer hide"){h[g].className="multiSelect checkboxLayer show"}else{if(h[g].className=="multiSelect checkboxLayer show"){h[g].className="multiSelect checkboxLayer hide"}}}};b.findUpTag=function(g,e,f){while(g.parentNode){g=g.parentNode;if(typeof g.tagName!=="undefined"){if(g.tagName.toUpperCase()===e.toUpperCase()&&g.className.indexOf(f)>-1){return g}}}return null};b.select=function(f){var e=[];switch(f.toUpperCase()){case"ALL":angular.forEach(b.inputModel,function(h,g){if(typeof h!=="undefined"&&h[b.disableProperty]!==true){h[b.tickProperty]=true}});break;case"NONE":angular.forEach(b.inputModel,function(h,g){if(typeof h!=="undefined"&&h[b.disableProperty]!==true){h[b.tickProperty]=false}});break;case"RESET":b.inputModel=angular.copy(b.backUp);break;default:}b.refreshSelectedItems()};validate=function(){if(!("inputModel" in c)){console.log("Multi-select error: input-model is not defined! (ID: "+b.directiveId+")")}if(!("buttonLabel" in c)){console.log("Multi-select error: button-label is not defined! (ID: "+b.directiveId+")")}if(!("itemLabel" in c)){console.log("Multi-select error: item-label is not defined! (ID: "+b.directiveId+")")}if(!("tickProperty" in c)){console.log("Multi-select error: tick-property is not defined! (ID: "+b.directiveId+")")}};validateProperties=function(f,h){var g=false;var e="";angular.forEach(f,function(j,k){if(typeof j!=="undefined"){var l=true;angular.forEach(h,function(m,n){if(typeof m!=="undefined"&&l){if(!(j in m)){g=true;l=false;missingLabel=j}}})}});if(g===true){console.log('Multi-select error: property "'+missingLabel+'" is not available in the input model. (Name: '+b.directiveId+")")}};validate();b.refreshSelectedItems();b.$watch("inputModel",function(e,f){if(b.inputModel!=="undefined"){validateProperties(b.itemLabel.split(" "),b.inputModel);validateProperties(new Array(b.tickProperty),b.inputModel)}b.backUp=angular.copy(b.inputModel);b.refreshSelectedItems()});b.$watch("isDisabled",function(e){b.isDisabled=e});angular.element(document).bind("click",function(g){var f=document.querySelectorAll(".checkboxLayer");if(g.target.className.indexOf("multiSelect")===-1){for(i=0;i<f.length;i++){f[i].className="multiSelect checkboxLayer hide"}g.stopPropagation()}});if(!Array.prototype.indexOf){Array.prototype.indexOf=function(g,f){f=f||0;var e=this.length;while(f<e){if(this[f]===g){return f}++f}return -1}}}}}]); |