Created
June 21, 2013 10:24
-
-
Save fritzvd/5830321 to your computer and use it in GitHub Desktop.
Angular JS jQuery UI Slider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<jq-schlider ng-enabled="state.master" at="time.at" max="time.max_timestep"></jq-schlider> | |
<script> | |
angular | |
.module('Components', []) | |
.directive('jqSchlider', function () { | |
return { | |
restrict: 'E', | |
replace: true, | |
template: '<div id="schlider"></div>', | |
scope: { | |
'ngEnabled': '=', | |
'max': '=', | |
'at': '=' | |
}, | |
link: function (scope, element, attrs) { | |
element.slider({ | |
stop : function(event, ui) {} | |
}); | |
element.on('slidestop', function(event, ui){ | |
scope.$apply(function(){ | |
scope.$parent.time.at = ui.value; | |
}); | |
}); | |
scope.$watch('max', function (value) { | |
element.slider('option', 'max', value); | |
}); | |
scope.$watch('at', function (value) { | |
element.slider('option', 'value', value); | |
}); | |
scope.$watch('ngEnabled', function (value) { | |
element.attr('enabled', value); | |
if (value) { | |
element.slider('enable'); | |
} | |
else { | |
element.slider('disable'); | |
} | |
}); | |
} | |
}; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment