Created
September 18, 2012 12:51
-
-
Save vedovelli/3742925 to your computer and use it in GitHub Desktop.
Super Simple Slider plugin directive
This file contains 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
rialabs.directive('riaSsslider', function(){ | |
return { | |
restrict: 'A', | |
link: function link ($scope, $element, $attrs){ | |
var el = jQuery($element), | |
ng = $scope; | |
el.children().each(function(index, item){ | |
ng.panes_length.push($(item).data('label') || ""); | |
}); | |
ng.$watch('position', function(newValue){ | |
el.ssslider('navigate',newValue); | |
}); | |
ng.$watch('prev', function(newValue){ | |
if(newValue != undefined){ | |
el.ssslider('prev'); | |
} | |
}); | |
ng.$watch('next', function(newValue){ | |
if(newValue != undefined){ | |
el.ssslider('next'); | |
} | |
}); | |
el.ssslider(ng.config || {}); | |
} | |
}; | |
}) | |
.controller('CtrlSlider', function($scope){ | |
var ng = $scope; | |
ng.navigate = function(pos){ | |
ng.position = pos; | |
}; | |
ng.change_prev = function(){ | |
ng.prev = !ng.prev || false; | |
}; | |
ng.change_next = function(){ | |
ng.next = !ng.next || false; | |
}; | |
var init = function(){ | |
ng.position = 0; | |
ng.panes_length = []; | |
ng.config = { | |
orientation:'from_right' | |
}; | |
}(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment