From a5dc23622f892ae944a2e44b4399f023bfa6b864 Mon Sep 17 00:00:00 2001 From: Tony Wang Date: Mon, 7 Dec 2015 21:32:03 +0800 Subject: [PATCH] update version number --- bower.json | 2 +- dist/angular-bootstrap-toggle.js | 13 +++++++++---- dist/angular-bootstrap-toggle.min.js | 2 +- src/angular-bootstrap-toggle.js | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 05dfa02..08f765c 100755 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "angular-bootstrap-toggle", "description": "AngularJS version of Bootstrap Toggle", - "version": "0.1.1", + "version": "0.1.2", "keywords": [ "angular", "toggle", diff --git a/dist/angular-bootstrap-toggle.js b/dist/angular-bootstrap-toggle.js index c808ba5..20ef38f 100644 --- a/dist/angular-bootstrap-toggle.js +++ b/dist/angular-bootstrap-toggle.js @@ -161,10 +161,15 @@ require: ['toggle', 'ngModel'], controller: 'ToggleController', controllerAs: 'toggle', - link: function (scope, element, attrs, ctrls) { - var toggleCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - toggleCtrl.element = element; - toggleCtrl.init(ngModelCtrl); + compile: function (element, attrs, transclude) { + return { + pre: function (scope, element, attrs, ctrls) { + var toggleCtrl = ctrls[0], ngModelCtrl = ctrls[1]; + toggleCtrl.element = element; + toggleCtrl.init(ngModelCtrl); + }, + post: function () {} + } } }; } diff --git a/dist/angular-bootstrap-toggle.min.js b/dist/angular-bootstrap-toggle.min.js index 4b647b6..f3a01a0 100644 --- a/dist/angular-bootstrap-toggle.min.js +++ b/dist/angular-bootstrap-toggle.min.js @@ -1 +1 @@ -!function(){"use strict";angular.module("ui.toggle",[]).value("$toggleSuppressError",!1).constant("toggleConfig",{on:"On",off:"Off",size:"",onstyle:"btn-primary",offstyle:"btn-default",style:""}).controller("ToggleController",["$scope","$attrs","$interpolate","$log","toggleConfig","$toggleSuppressError",function(e,t,n,l,o){var s=this,a={$setViewValue:angular.noop};angular.forEach(["on","off","size","onstyle","offstyle","style"],function(l,a){s[l]=angular.isDefined(t[l])?6>a?n(t[l])(e.$parent):e.$parent.$eval(t[l]):o[l]}),this.init=function(n){a=n,s.computeStyle(),a.$render=function(){s.toggle()},a.$viewChangeListeners.push(function(){e.$eval(t.ngChange)})},this.computeStyle=function(){var t=s.element.find("label");angular.element(t[0]).html(s.on),angular.element(t[1]).html(s.off);var n=s.element.find("span"),l=s.width||Math.max(t[0].offsetWidth,t[1].offsetWidth)+n[0].offsetWidth/2,o=s.height||Math.max(t[0].offsetHeight,t[1].offsetHeight),a=s.element.find("div"),i=a[0].offsetWidth,r=a[1].offsetHeight;e.wrapperStyle={},e.wrapperStyle.width=l>i?l+"px":i+"px",e.wrapperStyle.height=o>r&&"btn-xs"!==s.size&&"btn-sm"!==s.size?o+"px":r+"px",e.onClass=[s.onstyle,s.size,"toggle-on"],e.offClass=[s.offstyle,s.size,"toggle-off"],e.handleClass=[s.size,"toggle-handle"]},this.toggle=function(){this.isOn=angular.isDefined(a.$viewValue)?a.$viewValue:!1,e.wrapperClass=this.isOn?[s.onstyle,s.size,s.style]:[s.offstyle,"off ",s.size,s.style]},e.onSwitch=function(){a.$setViewValue(!a.$viewValue),a.$render()},angular.forEach(["ngModel"],function(n){var l=e.$parent.$watch(t[n],function(){a.$render()});e.$parent.$on("$destroy",function(){l()})}),angular.forEach(["on","off","size","onstyle","offstyle","style"],function(e){t.$observe(e,function(t){s[e]!==t&&(s[e]=t,s.computeStyle())})})}]).directive("toggle",function(){return{restrict:"E",transclude:!0,template:'
',scope:{bindModel:"=ngModel"},require:["toggle","ngModel"],controller:"ToggleController",controllerAs:"toggle",link:function(e,t,n,l){var o=l[0],s=l[1];o.element=t,o.init(s)}}})}(); \ No newline at end of file +!function(){"use strict";angular.module("ui.toggle",[]).value("$toggleSuppressError",!1).constant("toggleConfig",{on:"On",off:"Off",size:"",onstyle:"btn-primary",offstyle:"btn-default",style:""}).controller("ToggleController",["$scope","$attrs","$interpolate","$log","toggleConfig","$toggleSuppressError",function(e,t,n,l,o){var s=this,a={$setViewValue:angular.noop};angular.forEach(["on","off","size","onstyle","offstyle","style"],function(l,a){s[l]=angular.isDefined(t[l])?6>a?n(t[l])(e.$parent):e.$parent.$eval(t[l]):o[l]}),this.init=function(n){a=n,s.computeStyle(),a.$render=function(){s.toggle()},a.$viewChangeListeners.push(function(){e.$eval(t.ngChange)})},this.computeStyle=function(){var t=s.element.find("label");angular.element(t[0]).html(s.on),angular.element(t[1]).html(s.off);var n=s.element.find("span"),l=s.width||Math.max(t[0].offsetWidth,t[1].offsetWidth)+n[0].offsetWidth/2,o=s.height||Math.max(t[0].offsetHeight,t[1].offsetHeight),a=s.element.find("div"),i=a[0].offsetWidth,r=a[1].offsetHeight;e.wrapperStyle={},e.wrapperStyle.width=l>i?l+"px":i+"px",e.wrapperStyle.height=o>r&&"btn-xs"!==s.size&&"btn-sm"!==s.size?o+"px":r+"px",e.onClass=[s.onstyle,s.size,"toggle-on"],e.offClass=[s.offstyle,s.size,"toggle-off"],e.handleClass=[s.size,"toggle-handle"]},this.toggle=function(){this.isOn=angular.isDefined(a.$viewValue)?a.$viewValue:!1,e.wrapperClass=this.isOn?[s.onstyle,s.size,s.style]:[s.offstyle,"off ",s.size,s.style]},e.onSwitch=function(){a.$setViewValue(!a.$viewValue),a.$render()},angular.forEach(["ngModel"],function(n){var l=e.$parent.$watch(t[n],function(){a.$render()});e.$parent.$on("$destroy",function(){l()})}),angular.forEach(["on","off","size","onstyle","offstyle","style"],function(e){t.$observe(e,function(t){s[e]!==t&&(s[e]=t,s.computeStyle())})})}]).directive("toggle",function(){return{restrict:"E",transclude:!0,template:'
',scope:{bindModel:"=ngModel"},require:["toggle","ngModel"],controller:"ToggleController",controllerAs:"toggle",compile:function(){return{pre:function(e,t,n,l){var o=l[0],s=l[1];o.element=t,o.init(s)},post:function(){}}}}})}(); \ No newline at end of file diff --git a/src/angular-bootstrap-toggle.js b/src/angular-bootstrap-toggle.js index c808ba5..609d532 100644 --- a/src/angular-bootstrap-toggle.js +++ b/src/angular-bootstrap-toggle.js @@ -56,9 +56,11 @@ // Configuration attributes angular.forEach(['on', 'off', 'size', 'onstyle', 'offstyle', 'style'], function (key, index) { + //$log.info(key + ':' + $attrs[key]); self[key] = angular.isDefined($attrs[key]) ? (index < 6 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : toggleConfig[key]; + //$log.info(key + ':' + self[key]); }); this.init = function (ngModelCtrl_) {