From f1aa2a25e43c0b0c9d5101ea260dd3585c6d7690 Mon Sep 17 00:00:00 2001 From: wodka Date: Tue, 18 Oct 2016 17:41:10 +0200 Subject: [PATCH] add first version --- .gitignore | 1 + README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ bower.json | 27 +++++++++++++++++++++++++++ src/radioSlider.js | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 bower.json create mode 100644 src/radioSlider.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a84f29 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +angular-radios-to-slider +=========== +[![Bower version](https://badge.fury.io/bo/angular-radios-to-slider.svg)](http://badge.fury.io/bo/angular-radios-to-slider) + +angular module for https://github.com/rubentd/radios-to-slider + +### Installation + +``` +bower install angular-radios-to-slider --save +``` + +### Usage + +add "radio.slider" to your modules and start using the directive. + +### Example + +```html + + + + + + + +``` + diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..6900263 --- /dev/null +++ b/bower.json @@ -0,0 +1,27 @@ +{ + "name": "angular-radios-to-slider", + "homepage": "https://github.com/wodka/angular-radios-to-slider", + "authors": [ + "Michael Schramm " + ], + "dependencies": { + "angular": ">=1.4.0", + "radios-to-slider": "#master" + }, + "description": "angular module for rubentd/radios-to-slider", + "main": "src/radioSlider.js", + "keywords": [ + "radio", + "slider", + "angular", + "jquery" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/src/radioSlider.js b/src/radioSlider.js new file mode 100644 index 0000000..37c704d --- /dev/null +++ b/src/radioSlider.js @@ -0,0 +1,37 @@ +(function (angular) { + angular.module('radio.slider', []) + .directive('radioSlider', radioSlider) + ; + + radioSlider.$inject = ['$timeout']; + function radioSlider ($timeout) { + var idx = 0; + + return { + restrict: 'E', + scope: { + ngModel: '=', + name: '=?', + values: '=' + }, + template: '
'+ + ''+ + ''+ + '
', + link: function (scope, element) { + if (!scope.name) { + scope.name = 'radio_slider_'+(idx++); + } + + $timeout(function () { + element.find('div').first().radiosToSlider({ + onSelect: function (radio) { + scope.ngModel = radio.val(); + scope.$apply(); + } + }); + }, 150); + } + }; + } +}(angular));