forked from xpepermint/angular-ui-switch
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathangular-ui-switch.min.js
More file actions
1 lines (1 loc) · 1.25 KB
/
angular-ui-switch.min.js
File metadata and controls
1 lines (1 loc) · 1.25 KB
1
angular.module("uiSwitch",[]).directive("switch",function(){return{restrict:"AE",replace:!0,transclude:!0,template:function(e,n){var l="",a="";return n.ngOnClick&&(a+="; "+n.ngOnClick),n.ngChange&&(a+="; "+n.ngChange+"()"),l+="<span",l+=' class="switch'+(n["class"]?" "+n["class"]:"")+'"',l+=n.ngModel?' ng-click="'+n.disabled+" ? "+n.ngModel+" : "+n.ngModel+"=!"+n.ngModel+(n.ngChange?"; "+n.ngChange+'()"':'"'):"",l+=' ng-class="{ checked:'+n.ngModel+", disabled:"+n.disabled+' }"',n.onValue&&n.offValue?(l+=n.ngModel?' ng-click="'+n.disabled+" ? "+n.ngModel+" : "+n.ngModel+"=("+n.ngModel+"=== '"+(n.onValue||!0)+"' ? '"+(n.offValue||!1)+"':'"+(n.onValue||!0)+"')"+a+'"':"",l+=' ng-class="{ checked:'+n.ngModel+"==='"+(n.onValue||!0)+"'?true:false, disabled:"+n.disabled+' }"'):(l+=n.ngModel?' ng-click="'+n.disabled+" ? "+n.ngModel+" : "+n.ngModel+"=!"+n.ngModel+a+'"':"",l+=' ng-class="{ checked:'+n.ngModel+", disabled:"+n.disabled+' }"'),l+=">",l+="<small></small>",l+='<input type="checkbox"',l+=n.id?' id="'+n.id+'"':"",l+=n.name?' name="'+n.name+'"':"",l+=n.ngModel?' ng-model="'+n.ngModel+'"':"",l+=' style="display:none" />',l+='<span class="switch-text">',l+=n.on?'<span class="on">'+n.on+"</span>":"",l+=n.off?'<span class="off">'+n.off+"</span>":" ",l+="</span>"}}});