glider-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  ###
2
- glider 0.1.0 - AngularJS slider
2
+ glider 0.1.1 - AngularJS slider
3
3
  https://github.com/evrone/glider
4
4
  Copyright (c) 2013 Valentin Vasilyev, Dmitry Karpunin
5
5
  Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
@@ -18,14 +18,14 @@
18
18
  'use strict';
19
19
  app = angular.module("glider", [])
20
20
 
21
- app.directive "slider", ["$document", ($document) ->
21
+ app.directive 'slider', ['$document', ($document) ->
22
22
 
23
23
  getSubElement = (sliderElement, className) ->
24
24
  sliderElement[0].getElementsByClassName(className)[0]
25
25
 
26
26
  moveHandle = (elem, posX) ->
27
- angular.element(getSubElement(elem, "handle")).css("left", "#{posX}%")
28
- angular.element(getSubElement(elem, "range")).css("width", "#{posX}%")
27
+ angular.element(getSubElement(elem, 'handle')).css('left', "#{posX}%")
28
+ angular.element(getSubElement(elem, 'range')).css('width', "#{posX}%")
29
29
 
30
30
  template: """
31
31
  <span class="g-slider horizontal">
@@ -68,7 +68,12 @@ app.directive "slider", ["$document", ($document) ->
68
68
  value: parseInt(trim(i), 10)
69
69
  offset: offset(min, max, i)
70
70
 
71
- sliderElement = getSubElement(element, "slider")
71
+ createSnapValues = (increments)->
72
+ if attrs.increments?
73
+ ([scope.min(), scope.max()].concat(i.value for i in increments)).sort((a,b) -> a - b)
74
+
75
+
76
+ sliderElement = getSubElement(element, 'slider')
72
77
  dragging = false
73
78
  xPosition = 0
74
79
  step = if attrs.step? then parseInt(attrs.step, 10) else 1
@@ -77,10 +82,7 @@ app.directive "slider", ["$document", ($document) ->
77
82
  scope.value = scope.min() unless scope.value?
78
83
 
79
84
  scope.increments = parseIncrements(attrs.increments)
80
- if attrs.increments?
81
- scope.snapValues = ([scope.min(), scope.max()].concat(i.value for i in scope.increments))
82
- .sort((a,b) -> a - b)
83
-
85
+ scope.snapValues = createSnapValues(scope.increments)
84
86
 
85
87
  refreshHandle = ->
86
88
  range = scope.max() - scope.min()
@@ -91,19 +93,19 @@ app.directive "slider", ["$document", ($document) ->
91
93
  xPosition = Math.min(Math.max(0, xPosition), 100)
92
94
  moveHandle element, xPosition
93
95
 
94
- scope.$watch "min()", (minValue) ->
96
+ scope.$watch 'min()', (minValue) ->
95
97
  if scope.value < minValue
96
98
  scope.value = minValue
97
99
  else
98
100
  refreshHandle()
99
101
 
100
- scope.$watch "max()", (maxValue) ->
102
+ scope.$watch 'max()', (maxValue) ->
101
103
  if scope.value > maxValue
102
104
  scope.value = maxValue
103
105
  else
104
106
  refreshHandle()
105
107
 
106
- scope.$watch "value", (newVal, oldVal)->
108
+ scope.$watch 'value', (newVal, oldVal)->
107
109
  return if dragging
108
110
  if scope.min() <= newVal <= scope.max()
109
111
  refreshHandle()
@@ -151,9 +153,8 @@ app.directive "slider", ["$document", ($document) ->
151
153
  scope.value = closest
152
154
  scope.$apply()
153
155
 
154
- $document.on "mousemove", ($event) ->
156
+ $document.on 'mousemove', ($event) ->
155
157
  return unless dragging
156
- # Calculate value handle position
157
158
  moveDelta = $event.pageX - startPointX
158
159
  xPosition += moveDelta / sliderElement.offsetWidth * 100
159
160
  if xPosition < 0
@@ -165,11 +166,11 @@ app.directive "slider", ["$document", ($document) ->
165
166
  updateValue() unless deferUpdate
166
167
  moveHandle element, xPosition
167
168
 
168
- $document.on "mouseup", ->
169
+ $document.on 'mouseup', ->
169
170
  dragging = false
170
171
  updateValue() if deferUpdate
171
172
  snap() if scope.increments
172
- $document.off "mousemove"
173
+ $document.off 'mousemove'
173
174
  ]
174
175
  app.filter 'intersperse', ->
175
176
  (input) ->
@@ -1,6 +1,6 @@
1
1
  // Generated by CoffeeScript 1.6.3
2
2
  /*
3
- glider 0.1.0 - AngularJS slider
3
+ glider 0.1.1 - AngularJS slider
4
4
  https://github.com/evrone/glider
5
5
  Copyright (c) 2013 Valentin Vasilyev, Dmitry Karpunin
6
6
  Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
@@ -24,15 +24,15 @@
24
24
 
25
25
  app = angular.module("glider", []);
26
26
 
27
- app.directive("slider", [
28
- "$document", function($document) {
27
+ app.directive('slider', [
28
+ '$document', function($document) {
29
29
  var getSubElement, moveHandle;
30
30
  getSubElement = function(sliderElement, className) {
31
31
  return sliderElement[0].getElementsByClassName(className)[0];
32
32
  };
33
33
  moveHandle = function(elem, posX) {
34
- angular.element(getSubElement(elem, "handle")).css("left", "" + posX + "%");
35
- return angular.element(getSubElement(elem, "range")).css("width", "" + posX + "%");
34
+ angular.element(getSubElement(elem, 'handle')).css('left', "" + posX + "%");
35
+ return angular.element(getSubElement(elem, 'range')).css('width', "" + posX + "%");
36
36
  };
37
37
  return {
38
38
  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() | intersperse}}</span>\n </span>\n <span class=\"side inc\">\n <span class=\"button\" ng-click=\"step(+1)\">+</span>\n <span class=\"bound-value\">{{max() | intersperse}}</span>\n </span>\n <span class=\"increments\">\n <span ng-repeat=\"i in increments\" class=\"i\" style=\"left: {{i.offset}}%\">\n {{ i.value | intersperse }}\n </span>\n </span>\n</span>",
@@ -44,7 +44,7 @@
44
44
  max: "&"
45
45
  },
46
46
  link: function(scope, element, attrs) {
47
- var deferUpdate, dragging, i, parseIncrements, refreshHandle, sliderElement, step, xPosition;
47
+ var createSnapValues, deferUpdate, dragging, parseIncrements, refreshHandle, sliderElement, step, xPosition;
48
48
  parseIncrements = function() {
49
49
  var i, increments, max, min, offset, trim;
50
50
  trim = function(input) {
@@ -77,7 +77,23 @@
77
77
  })();
78
78
  }
79
79
  };
80
- sliderElement = getSubElement(element, "slider");
80
+ createSnapValues = function(increments) {
81
+ var i;
82
+ if (attrs.increments != null) {
83
+ return ([scope.min(), scope.max()].concat((function() {
84
+ var _i, _len, _results;
85
+ _results = [];
86
+ for (_i = 0, _len = increments.length; _i < _len; _i++) {
87
+ i = increments[_i];
88
+ _results.push(i.value);
89
+ }
90
+ return _results;
91
+ })())).sort(function(a, b) {
92
+ return a - b;
93
+ });
94
+ }
95
+ };
96
+ sliderElement = getSubElement(element, 'slider');
81
97
  dragging = false;
82
98
  xPosition = 0;
83
99
  step = attrs.step != null ? parseInt(attrs.step, 10) : 1;
@@ -86,20 +102,7 @@
86
102
  scope.value = scope.min();
87
103
  }
88
104
  scope.increments = parseIncrements(attrs.increments);
89
- if (attrs.increments != null) {
90
- scope.snapValues = ([scope.min(), scope.max()].concat((function() {
91
- var _i, _len, _ref, _results;
92
- _ref = scope.increments;
93
- _results = [];
94
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
95
- i = _ref[_i];
96
- _results.push(i.value);
97
- }
98
- return _results;
99
- })())).sort(function(a, b) {
100
- return a - b;
101
- });
102
- }
105
+ scope.snapValues = createSnapValues(scope.increments);
103
106
  refreshHandle = function() {
104
107
  var range;
105
108
  range = scope.max() - scope.min();
@@ -111,21 +114,21 @@
111
114
  }
112
115
  return moveHandle(element, xPosition);
113
116
  };
114
- scope.$watch("min()", function(minValue) {
117
+ scope.$watch('min()', function(minValue) {
115
118
  if (scope.value < minValue) {
116
119
  return scope.value = minValue;
117
120
  } else {
118
121
  return refreshHandle();
119
122
  }
120
123
  });
121
- scope.$watch("max()", function(maxValue) {
124
+ scope.$watch('max()', function(maxValue) {
122
125
  if (scope.value > maxValue) {
123
126
  return scope.value = maxValue;
124
127
  } else {
125
128
  return refreshHandle();
126
129
  }
127
130
  });
128
- scope.$watch("value", function(newVal, oldVal) {
131
+ scope.$watch('value', function(newVal, oldVal) {
129
132
  if (dragging) {
130
133
  return;
131
134
  }
@@ -190,7 +193,7 @@
190
193
  return scope.$apply();
191
194
  };
192
195
  snap = function() {
193
- var closest, diff, l, min;
196
+ var closest, diff, i, l, min;
194
197
  i = 0;
195
198
  l = scope.snapValues.length;
196
199
  while (i < l) {
@@ -207,7 +210,7 @@
207
210
  scope.value = closest;
208
211
  return scope.$apply();
209
212
  };
210
- $document.on("mousemove", function($event) {
213
+ $document.on('mousemove', function($event) {
211
214
  var moveDelta;
212
215
  if (!dragging) {
213
216
  return;
@@ -226,7 +229,7 @@
226
229
  }
227
230
  return moveHandle(element, xPosition);
228
231
  });
229
- return $document.on("mouseup", function() {
232
+ return $document.on('mouseup', function() {
230
233
  dragging = false;
231
234
  if (deferUpdate) {
232
235
  updateValue();
@@ -234,7 +237,7 @@
234
237
  if (scope.increments) {
235
238
  snap();
236
239
  }
237
- return $document.off("mousemove");
240
+ return $document.off('mousemove');
238
241
  });
239
242
  };
240
243
  }
@@ -1 +1 @@
1
- !function(){"use strict";var n;n=angular.module("glider",[]),n.directive("slider",["$document",function(n){var e,a;return e=function(n,e){return n[0].getElementsByClassName(e)[0]},a=function(n,a){return angular.element(e(n,"handle")).css("left",""+a+"%"),angular.element(e(n,"range")).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() | slice}}</span>\n </span>\n <span class="side inc">\n <span class="button" ng-click="step(+1)">+</span>\n <span class="bound-value">{{max() | slice}}</span>\n </span>\n</span>',replace:!0,restrict:"E",scope:{value:"=",min:"&",max:"&"},link:function(s,t,u){var r,l,i,c,o,p;return c=e(t,"slider"),l=!1,p=0,o=null!=u.step?parseInt(u.step,10):1,r=null!=u.deferUpdate,null==s.value&&(s.value=s.min()),i=function(){var n;return n=s.max()-s.min(),0===n?p=0:(p=100*((s.value-s.min())/n),p=Math.min(Math.max(0,p),100)),a(t,p)},s.$watch("min()",function(n){return s.value<n?s.value=n:i()}),s.$watch("max()",function(n){return s.value>n?s.value=n:i()}),s.$watch("value",function(){return l?void 0:i()}),s.step=function(n){var e;return e=s.value+n*o,s.min()<=e&&e<=s.max()?s.value=e:void 0},s.mouseDown=function(e){var u,i;return l=!0,u=e.pageX,i=function(){return s.value=Math.round(((s.max()-s.min())*(p/100)+s.min())/o)*o,s.$apply()},n.on("mousemove",function(n){var e;if(l)return e=n.pageX-u,p+=100*(e/c.offsetWidth),0>p?p=0:p>100?p=100:u=n.pageX,r||i(),a(t,p)}),n.on("mouseup",function(){return l=!1,r&&i(),n.off("mousemove")})}}}}]),n.filter("slice",function(){return function(n){var e,a,s,t;if(null!=n)return n=n.toString(),e=function(n){return n.split("").reverse().join("")},a=e(n),s=a.replace(/(.{3})/g,"$1 "),t=e(s),t.trim()}})}.call(this);
1
+ !function(){"use strict";var n;n=angular.module("glider",[]),n.directive("slider",["$document",function(n){var e,a;return e=function(n,e){return n[0].getElementsByClassName(e)[0]},a=function(n,a){return angular.element(e(n,"handle")).css("left",""+a+"%"),angular.element(e(n,"range")).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() | intersperse}}</span>\n </span>\n <span class="side inc">\n <span class="button" ng-click="step(+1)">+</span>\n <span class="bound-value">{{max() | intersperse}}</span>\n </span>\n <span class="increments">\n <span ng-repeat="i in increments" class="i" style="left: {{i.offset}}%">\n {{ i.value | intersperse }}\n </span>\n </span>\n</span>',replace:!0,restrict:"E",scope:{value:"=",min:"&",max:"&"},link:function(t,r,s){var u,i,l,c,o,p,f,m;return c=function(){var n,e,a,r,u,i;return i=function(n){return n?n.replace(/^\s+|\s+$/g,""):n},u=function(n,e,a){return 100*(a/Math.abs(e-n))},s.increments?(r=t.min(),a=t.max(),e=s.increments.split(","),e=function(){var t,s,l,c;for(c=[],t=0,s=e.length;s>t;t++)n=e[t],r<(l=parseInt(n))&&a>l&&c.push({value:parseInt(i(n),10),offset:u(r,a,n)});return c}()):void 0},u=function(n){var e;return null!=s.increments?[t.min(),t.max()].concat(function(){var a,t,r;for(r=[],a=0,t=n.length;t>a;a++)e=n[a],r.push(e.value);return r}()).sort(function(n,e){return n-e}):void 0},p=e(r,"slider"),l=!1,m=0,f=null!=s.step?parseInt(s.step,10):1,i=null!=s.deferUpdate,null==t.value&&(t.value=t.min()),t.increments=c(s.increments),t.snapValues=u(t.increments),o=function(){var n;return n=t.max()-t.min(),0===n?m=0:(m=100*((t.value-t.min())/n),m=Math.min(Math.max(0,m),100)),a(r,m)},t.$watch("min()",function(n){return t.value<n?t.value=n:o()}),t.$watch("max()",function(n){return t.value>n?t.value=n:o()}),t.$watch("value",function(n,e){return l?void 0:t.min()<=n&&n<=t.max()?o():n=e}),t.step=function(n){var e,a;return a=function(n){var e;return e=t.value+n*f,t.min()<=e&&e<=t.max()?t.value=e:void 0},e=function(n){var e,a;return e=n>0?function(){var n,e,r,s;for(r=t.snapValues,s=[],n=0,e=r.length;e>n;n++)a=r[n],a>t.value&&s.push(a);return s}()[0]:function(){var n,e,r,s;for(r=t.snapValues,s=[],n=0,e=r.length;e>n;n++)a=r[n],a<t.value&&s.push(a);return s}().sort(function(n,e){return e-n})[0],null!=e?t.value=e:void 0},null!=s.increments?e(n):a(n)},t.mouseDown=function(e){var s,u,c;return l=!0,u=e.pageX,c=function(){return t.value=Math.round(((t.max()-t.min())*(m/100)+t.min())/f)*f,t.$apply()},s=function(){var n,e,a,r,s;for(a=0,r=t.snapValues.length;r>a;)e=Math.abs(t.snapValues[a]-t.value),("undefined"==typeof s||null===s)&&(s=e),s>=e&&(n=t.snapValues[a],s=e),a++;return t.value=n,t.$apply()},n.on("mousemove",function(n){var e;if(l)return e=n.pageX-u,m+=100*(e/p.offsetWidth),0>m?m=0:m>100?m=100:u=n.pageX,i||c(),a(r,m)}),n.on("mouseup",function(){return l=!1,i&&c(),t.increments&&s(),n.off("mousemove")})}}}}]),n.filter("intersperse",function(){return function(n){var e,a,t,r;if(null!=n)return n=n.toString(),e=function(n){return n.split("").reverse().join("")},a=e(n),t=a.replace(/(.{3})/g,"$1 "),r=e(t),r.trim()}})}.call(this);
data/glider-rails.gemspec CHANGED
@@ -4,12 +4,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "glider-rails"
7
- gem.version = "0.1.0"
8
- gem.authors = ["Valentin Vasilyev", "Dmitry Karpunin"]
7
+ gem.version = "0.1.1"
8
+ gem.authors = ["Valentin Valve Vasilyev", "Dmitry KODer Karpunin"]
9
9
  gem.email = ["iamvalentin@gmail.com", "koderfunk@gmail.com"]
10
10
  gem.description = "Glider, AngularJS UI slider for rails asset pipeline"
11
11
  gem.summary = "Glider — AngularJS UI slider library, packaged for Ruby-on-Rails asset pipeline"
12
12
  gem.homepage = "http://evrone.github.com/glider-rails"
13
+ gem.license = "MIT"
13
14
 
14
15
  gem.files = `git ls-files`.split($/)
15
16
  gem.require_paths = ["lib"]
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glider-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Valentin Vasilyev
9
- - Dmitry Karpunin
8
+ - Valentin Valve Vasilyev
9
+ - Dmitry KODer Karpunin
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-10-03 00:00:00.000000000 Z
13
+ date: 2013-10-04 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Glider, AngularJS UI slider for rails asset pipeline
16
16
  email:
@@ -31,7 +31,8 @@ files:
31
31
  - glider-rails.gemspec
32
32
  - lib/glider-rails.rb
33
33
  homepage: http://evrone.github.com/glider-rails
34
- licenses: []
34
+ licenses:
35
+ - MIT
35
36
  post_install_message:
36
37
  rdoc_options: []
37
38
  require_paths: