Skip to content

Commit

Permalink
Updated switchery dependency to ~0.8.1 + more stable implementation o…
Browse files Browse the repository at this point in the history
…f disabled attribute
  • Loading branch information
Mathieu Amiot committed Nov 9, 2015
1 parent 4d7ec71 commit 99e4a89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bower.json
@@ -1,6 +1,6 @@
{
"name": "ng-switchery",
"version": "1.0.0-alpha7",
"version": "1.0.0-alpha8",
"main": "src/ng-switchery.js",
"license": "MIT",
"ignore": [
Expand All @@ -10,7 +10,7 @@
"examples"
],
"dependencies": {
"switchery": "~0.6.2"
"switchery": "~0.8.1"
},
"devDependencies": {
"angular": "~1.2.19"
Expand Down
15 changes: 6 additions & 9 deletions src/ng-switchery.js
Expand Up @@ -15,7 +15,7 @@ angular.module('NgSwitchery', [])
* @param scope
* @param elem
* @param attrs
* @param ngModel
* @param ngModel
*/
function linkSwitchery(scope, elem, attrs, ngModel) {
if(!ngModel) return false;
Expand All @@ -25,15 +25,12 @@ angular.module('NgSwitchery', [])
}
catch (e) {}
var switcher;
var previousDisabledValue;
// Watch for attribute changes to recreate the switch if the 'disabled' attribute changes

attrs.$observe('disabled', function(value) {
if (value == undefined || value == previousDisabledValue) {
return;
} else {
previousDisabledValue = value;
}
initializeSwitch();
if (value)
switcher.disable();
else
switcher.enable();
});

function initializeSwitch() {
Expand Down

0 comments on commit 99e4a89

Please sign in to comment.