glider-rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fingerprintjs-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Valentin Vasilyev, Dmitry Karpunin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # Glider - angularjs UI slider
2
+
3
+ Glider - angularjs slider with no dependencies. Dead simple - 74 LOC.
4
+
5
+ ## Demo
6
+
7
+ Demo is available here: http://evrone.github.io/glider
8
+
9
+ ## Installation
10
+
11
+ ### Bower
12
+
13
+ `bower install glider`
14
+
15
+ UPD: bower install is currently unavailable, due to project moving to a new location
16
+
17
+ ### Ruby-on-Rails
18
+
19
+ Add this to your Gemfile
20
+
21
+ `
22
+ gem 'glider-rails'
23
+ `
24
+ and
25
+
26
+ `bundle install`
27
+
28
+ After that you can add the file to sprockets:
29
+
30
+ ` //= require glider `
31
+
32
+ ## Usage
33
+
34
+ Add module as a dependency:
35
+
36
+ ```javascript
37
+ angular.module('myApp', ['glider']);
38
+ ```
39
+
40
+ And then in HTML:
41
+
42
+ ```html
43
+ <slider min="21" max="130" value="age"></slider>
44
+ ```
45
+
46
+ ## CoffeeScript to JavaScript compilation
47
+
48
+ To convert the `src/glider.coffee` to javascript, use coffeescript compiler.
49
+ Install it with:
50
+
51
+ ```
52
+ npm -g install coffee-script'
53
+ ```
54
+
55
+ Then compile the file with:
56
+
57
+ ```
58
+ coffee -c -o . src/glider.coffee
59
+ ```
60
+
61
+ This will compile the src/glider.coffee to glider.js
62
+
63
+ ## Minification
64
+
65
+ To minify the file I recommend using [uglifyjs][uglifyjs]
66
+ If you don't have it installed, install it with:
67
+
68
+ ```
69
+ npm -g install uglify-js
70
+ ```
71
+
72
+ Then run the minification with:
73
+
74
+ ```
75
+ uglifyjs glider.js > glider.min.js -mc
76
+ ```
77
+
78
+ `-mc` tells uglifier to (m)angle and (c)ompress the input code.
79
+
80
+ If you don't have node.js installed on your machine, you can create a minified version of the library with
81
+ online services, such as [Google Closure compiler][closure]
82
+
83
+ ### Authors
84
+
85
+ * Valve - Valentin Vasilyev
86
+ * KODerFunk - Dmitry Karpunin
87
+
88
+ Inspired by a plunkr snippet
89
+
90
+ ### Licence
91
+
92
+ This code is [MIT][mit] licenced:
93
+
94
+ Copyright (c) 2013 Valentin Vasilyev, Dmitry Karpunin
95
+
96
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
97
+
98
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
99
+
100
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,96 @@
1
+ /*
2
+ glider 0.0.2 - Angularjs slider
3
+ https://github.com/Valve/glider
4
+ Copyright (c) 2013 Valentin Vasilyev, Dmitry Karpunin
5
+ Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
6
+ */
7
+
8
+
9
+ (function() {
10
+ var app,
11
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
12
+
13
+ app = angular.module("glider", []);
14
+
15
+ app.directive("slider", [
16
+ "$document", function($document) {
17
+ var moveHandle;
18
+ moveHandle = function(elem, posX) {
19
+ angular.element(elem[0].getElementsByClassName('handle')[0]).css("left", "" + posX + "%");
20
+ return angular.element(elem[0].getElementsByClassName('range')[0]).css("width", "" + posX + "%");
21
+ };
22
+ return {
23
+ template: "<span class=\"g-slider horizontal\">\n <span class=\"slider\">\n <span class=\"range\"></span>\n <span class=\"handle\" ng-mousedown=\"mouseDown($event)\"></span>\n </span>\n <span class=\"side dec\">\n <span class=\"button\" ng-click=\"step(-1)\">-</span>\n <span class=\"bound-value\">{{min()}}</span>\n </span>\n <span class=\"side inc\">\n <span class=\"button\" ng-click=\"step(+1)\">+</span>\n <span class=\"bound-value\">{{max()}}</span>\n </span>\n</span>",
24
+ replace: true,
25
+ restrict: "E",
26
+ scope: {
27
+ value: "=",
28
+ min: '&',
29
+ max: '&'
30
+ },
31
+ link: function(scope, element, attrs) {
32
+ var dragging, startPointX, step, xPosition;
33
+ dragging = false;
34
+ startPointX = 0;
35
+ xPosition = 0;
36
+ step = attrs.step != null ? parseInt(attrs.step, 10) : 1;
37
+ if (scope.value == null) {
38
+ scope.value = scope.min();
39
+ }
40
+ scope.$watch("value", function() {
41
+ if (dragging) {
42
+ return;
43
+ }
44
+ xPosition = (scope.value - scope.min()) / (scope.max() - scope.min()) * 100;
45
+ if (xPosition < 0) {
46
+ xPosition = 0;
47
+ } else {
48
+ if (xPosition > 100) {
49
+ xPosition = 100;
50
+ }
51
+ }
52
+ return moveHandle(element, xPosition);
53
+ });
54
+ scope.step = function(step_value) {
55
+ var inc, _i, _ref, _ref1, _ref2, _results;
56
+ inc = step_value * step;
57
+ if (_ref = scope.value + inc, __indexOf.call((function() {
58
+ _results = [];
59
+ for (var _i = _ref1 = scope.min(), _ref2 = scope.max(); _ref1 <= _ref2 ? _i <= _ref2 : _i >= _ref2; _ref1 <= _ref2 ? _i++ : _i--){ _results.push(_i); }
60
+ return _results;
61
+ }).apply(this), _ref) >= 0) {
62
+ return scope.value += inc;
63
+ }
64
+ };
65
+ return scope.mouseDown = function($event) {
66
+ dragging = true;
67
+ startPointX = $event.pageX;
68
+ $document.on("mousemove", function($event) {
69
+ var moveDelta;
70
+ if (!dragging) {
71
+ return;
72
+ }
73
+ moveDelta = $event.pageX - startPointX;
74
+ xPosition = xPosition + ((moveDelta / element[0].offsetWidth) * 100);
75
+ if (xPosition < 0) {
76
+ xPosition = 0;
77
+ } else if (xPosition > 100) {
78
+ xPosition = 100;
79
+ } else {
80
+ startPointX = $event.pageX;
81
+ }
82
+ scope.value = Math.round((((scope.max() - scope.min()) * (xPosition / 100)) + scope.min()) / step) * step;
83
+ scope.$apply();
84
+ return moveHandle(element, xPosition);
85
+ });
86
+ return $document.on('mouseup', function() {
87
+ dragging = false;
88
+ return $document.off("mousemove");
89
+ });
90
+ };
91
+ }
92
+ };
93
+ }
94
+ ]);
95
+
96
+ }).call(this);
@@ -0,0 +1 @@
1
+ !function(){var n,a=[].indexOf||function(n){for(var a=0,e=this.length;e>a;a++)if(a in this&&this[a]===n)return a;return-1};n=angular.module("glider",[]),n.directive("slider",["$document",function(n){var e;return e=function(n,a){return angular.element(n[0].getElementsByClassName("handle")[0]).css("left",""+a+"%"),angular.element(n[0].getElementsByClassName("range")[0]).css("width",""+a+"%")},{template:'<span class="g-slider horizontal">\n <span class="slider">\n <span class="range"></span>\n <span class="handle" ng-mousedown="mouseDown($event)"></span>\n </span>\n <span class="side dec">\n <span class="button" ng-click="step(-1)">-</span>\n <span class="bound-value">{{min()}}</span>\n </span>\n <span class="side inc">\n <span class="button" ng-click="step(+1)">+</span>\n <span class="bound-value">{{max()}}</span>\n </span>\n</span>',replace:!0,restrict:"E",scope:{value:"=",min:"&",max:"&"},link:function(s,t,l){var u,r,i,o;return u=!1,r=0,o=0,i=null!=l.step?parseInt(l.step,10):1,null==s.value&&(s.value=s.min()),s.$watch("value",function(){return u?void 0:(o=100*((s.value-s.min())/(s.max()-s.min())),0>o?o=0:o>100&&(o=100),e(t,o))}),s.step=function(n){var e,t,l,u;return e=n*i,t=s.value+e,a.call(function(){u=[];for(var n=l=s.min(),a=s.max();a>=l?a>=n:n>=a;a>=l?n++:n--)u.push(n);return u}.apply(this),t)>=0?s.value+=e:void 0},s.mouseDown=function(a){return u=!0,r=a.pageX,n.on("mousemove",function(n){var a;if(u)return a=n.pageX-r,o+=100*(a/t[0].offsetWidth),0>o?o=0:o>100?o=100:r=n.pageX,s.value=Math.round(((s.max()-s.min())*(o/100)+s.min())/i)*i,s.$apply(),e(t,o)}),n.on("mouseup",function(){return u=!1,n.off("mousemove")})}}}}])}.call(this);
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "glider-rails"
7
+ gem.version = "0.0.2"
8
+ gem.authors = ["Valentin Vasilyev", "Dmitry Karpunin"]
9
+ gem.email = ["iamvalentin@gmail.com"]
10
+ gem.description = "Glider, angularjs UI slider for rails asset pipeline"
11
+ gem.summary = "Glider - angularjs UI slider library, packaged for Ruby-on-Rails asset pipeline"
12
+ gem.homepage = "http://evrone.github.com/glider-rails"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.require_paths = ["lib"]
16
+ end
@@ -0,0 +1,4 @@
1
+ module Glider
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: glider-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Valentin Vasilyev
9
+ - Dmitry Karpunin
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-09-09 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Glider, angularjs UI slider for rails asset pipeline
16
+ email:
17
+ - iamvalentin@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - app/assets/javascripts/glider.js
28
+ - app/assets/javascripts/glider.min.js
29
+ - glider-rails.gemspec
30
+ - lib/glider-rails.rb
31
+ homepage: http://evrone.github.com/glider-rails
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.23
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Glider - angularjs UI slider library, packaged for Ruby-on-Rails asset pipeline
55
+ test_files: []