rangesliderjs-rails 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.md +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/rangesliderjs/rails/version.rb +5 -0
- data/lib/rangesliderjs/rails.rb +8 -0
- data/rangesliderjs-rails.gemspec +24 -0
- data/vendor/assets/javascripts/rangeslider.js +483 -0
- data/vendor/assets/stylesheets/rangeslider.css +111 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 391f8cf7a352ad36aa054a39f6828246fc65e2a9
|
4
|
+
data.tar.gz: b40ff927b68dd03a7abfc7c58f188488c179c253
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b453f40b8a053db28692218b3f59f71e1beb2e0320b27b3c730a253d951f91a037c870edcd0246b88b5cad1528064ee1ae8ec54f5622dce76cd36e7e214a6bfb
|
7
|
+
data.tar.gz: 6524909408559151d794f727c3425d85849f28fb0abe0bbdee74879110cc5831b98997b5d751d9136246d88eddb8fd363a91b870ac4e19750ba7a82bd1721b2c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 André Ruffert, http://andreruffert.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Rangesliderjs-Rails
|
2
|
+
|
3
|
+
This gem bundles [rangeslider.js](https://github.com/andreruffert/rangeslider.js)
|
4
|
+
for the Rails asset pipeline.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'rangesliderjs_rails'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install rangesliderjs_rails
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
In your application.js, include the following:
|
25
|
+
|
26
|
+
```javascript
|
27
|
+
//= require rangeslider
|
28
|
+
```
|
29
|
+
|
30
|
+
In your application.css, include the following:
|
31
|
+
|
32
|
+
```css
|
33
|
+
*= require rangeslider
|
34
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rangesliderjs/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rangesliderjs-rails"
|
8
|
+
spec.version = Rangesliderjs::Rails::VERSION
|
9
|
+
spec.authors = ["Ilja Krijger"]
|
10
|
+
spec.email = ["ilja@quittheprogram.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{rangeslider.js packaged for the rails assets pipeline.}
|
13
|
+
spec.description = %q{Simple, small and fast JavaScript/jQuery polyfill for the HTML5 <input type="range"> slider element.}
|
14
|
+
spec.homepage = "https://github.com/ilja/rangesliderjs-rails."
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
@@ -0,0 +1,483 @@
|
|
1
|
+
/*! rangeslider.js - v2.0.5 | (c) 2015 @andreruffert | MIT license | https://github.com/andreruffert/rangeslider.js */
|
2
|
+
(function(factory) {
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
if (typeof define === 'function' && define.amd) {
|
6
|
+
// AMD. Register as an anonymous module.
|
7
|
+
define(['jquery'], factory);
|
8
|
+
} else if (typeof exports === 'object') {
|
9
|
+
// CommonJS
|
10
|
+
module.exports = factory(require('jquery'));
|
11
|
+
} else {
|
12
|
+
// Browser globals
|
13
|
+
factory(jQuery);
|
14
|
+
}
|
15
|
+
}(function($) {
|
16
|
+
'use strict';
|
17
|
+
|
18
|
+
// Polyfill Number.isNaN(value)
|
19
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN
|
20
|
+
Number.isNaN = Number.isNaN || function(value) {
|
21
|
+
return typeof value === 'number' && value !== value;
|
22
|
+
};
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Range feature detection
|
26
|
+
* @return {Boolean}
|
27
|
+
*/
|
28
|
+
function supportsRange() {
|
29
|
+
var input = document.createElement('input');
|
30
|
+
input.setAttribute('type', 'range');
|
31
|
+
return input.type !== 'text';
|
32
|
+
}
|
33
|
+
|
34
|
+
var pluginName = 'rangeslider',
|
35
|
+
pluginIdentifier = 0,
|
36
|
+
hasInputRangeSupport = supportsRange(),
|
37
|
+
defaults = {
|
38
|
+
polyfill: true,
|
39
|
+
orientation: 'horizontal',
|
40
|
+
rangeClass: 'rangeslider',
|
41
|
+
disabledClass: 'rangeslider--disabled',
|
42
|
+
horizontalClass: 'rangeslider--horizontal',
|
43
|
+
verticalClass: 'rangeslider--vertical',
|
44
|
+
fillClass: 'rangeslider__fill',
|
45
|
+
handleClass: 'rangeslider__handle',
|
46
|
+
startEvent: ['mousedown', 'touchstart', 'pointerdown'],
|
47
|
+
moveEvent: ['mousemove', 'touchmove', 'pointermove'],
|
48
|
+
endEvent: ['mouseup', 'touchend', 'pointerup']
|
49
|
+
},
|
50
|
+
constants = {
|
51
|
+
orientation: {
|
52
|
+
horizontal: {
|
53
|
+
dimension: 'width',
|
54
|
+
direction: 'left',
|
55
|
+
directionStyle: 'left',
|
56
|
+
coordinate: 'x'
|
57
|
+
},
|
58
|
+
vertical: {
|
59
|
+
dimension: 'height',
|
60
|
+
direction: 'top',
|
61
|
+
directionStyle: 'bottom',
|
62
|
+
coordinate: 'y'
|
63
|
+
}
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Delays a function for the given number of milliseconds, and then calls
|
69
|
+
* it with the arguments supplied.
|
70
|
+
*
|
71
|
+
* @param {Function} fn [description]
|
72
|
+
* @param {Number} wait [description]
|
73
|
+
* @return {Function}
|
74
|
+
*/
|
75
|
+
function delay(fn, wait) {
|
76
|
+
var args = Array.prototype.slice.call(arguments, 2);
|
77
|
+
return setTimeout(function(){ return fn.apply(null, args); }, wait);
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Returns a debounced function that will make sure the given
|
82
|
+
* function is not triggered too much.
|
83
|
+
*
|
84
|
+
* @param {Function} fn Function to debounce.
|
85
|
+
* @param {Number} debounceDuration OPTIONAL. The amount of time in milliseconds for which we will debounce the function. (defaults to 100ms)
|
86
|
+
* @return {Function}
|
87
|
+
*/
|
88
|
+
function debounce(fn, debounceDuration) {
|
89
|
+
debounceDuration = debounceDuration || 100;
|
90
|
+
return function() {
|
91
|
+
if (!fn.debouncing) {
|
92
|
+
var args = Array.prototype.slice.apply(arguments);
|
93
|
+
fn.lastReturnVal = fn.apply(window, args);
|
94
|
+
fn.debouncing = true;
|
95
|
+
}
|
96
|
+
clearTimeout(fn.debounceTimeout);
|
97
|
+
fn.debounceTimeout = setTimeout(function(){
|
98
|
+
fn.debouncing = false;
|
99
|
+
}, debounceDuration);
|
100
|
+
return fn.lastReturnVal;
|
101
|
+
};
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Check if a `element` is visible in the DOM
|
106
|
+
*
|
107
|
+
* @param {Element} element
|
108
|
+
* @return {Boolean}
|
109
|
+
*/
|
110
|
+
function isHidden(element) {
|
111
|
+
return (
|
112
|
+
element && (
|
113
|
+
element.offsetWidth === 0 ||
|
114
|
+
element.offsetHeight === 0 ||
|
115
|
+
// Also Consider native `<details>` elements.
|
116
|
+
element.open === false
|
117
|
+
)
|
118
|
+
);
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Get hidden parentNodes of an `element`
|
123
|
+
*
|
124
|
+
* @param {Element} element
|
125
|
+
* @return {[type]}
|
126
|
+
*/
|
127
|
+
function getHiddenParentNodes(element) {
|
128
|
+
var parents = [],
|
129
|
+
node = element.parentNode;
|
130
|
+
|
131
|
+
while (isHidden(node)) {
|
132
|
+
parents.push(node);
|
133
|
+
node = node.parentNode;
|
134
|
+
}
|
135
|
+
return parents;
|
136
|
+
}
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Returns dimensions for an element even if it is not visible in the DOM.
|
140
|
+
*
|
141
|
+
* @param {Element} element
|
142
|
+
* @param {String} key (e.g. offsetWidth …)
|
143
|
+
* @return {Number}
|
144
|
+
*/
|
145
|
+
function getDimension(element, key) {
|
146
|
+
var hiddenParentNodes = getHiddenParentNodes(element),
|
147
|
+
hiddenParentNodesLength = hiddenParentNodes.length,
|
148
|
+
inlineStyle = [],
|
149
|
+
dimension = element[key];
|
150
|
+
|
151
|
+
// Used for native `<details>` elements
|
152
|
+
function toggleOpenProperty(element) {
|
153
|
+
if (typeof element.open !== 'undefined') {
|
154
|
+
element.open = (element.open) ? false : true;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
if (hiddenParentNodesLength) {
|
159
|
+
for (var i = 0; i < hiddenParentNodesLength; i++) {
|
160
|
+
|
161
|
+
// Cache style attribute to restore it later.
|
162
|
+
inlineStyle[i] = hiddenParentNodes[i].style.cssText;
|
163
|
+
|
164
|
+
// visually hide
|
165
|
+
if (hiddenParentNodes[i].style.setProperty) {
|
166
|
+
hiddenParentNodes[i].style.setProperty('display', 'block', 'important');
|
167
|
+
} else {
|
168
|
+
hiddenParentNodes[i].style.cssText += ';display: block !important';
|
169
|
+
}
|
170
|
+
hiddenParentNodes[i].style.height = '0';
|
171
|
+
hiddenParentNodes[i].style.overflow = 'hidden';
|
172
|
+
hiddenParentNodes[i].style.visibility = 'hidden';
|
173
|
+
toggleOpenProperty(hiddenParentNodes[i]);
|
174
|
+
}
|
175
|
+
|
176
|
+
// Update dimension
|
177
|
+
dimension = element[key];
|
178
|
+
|
179
|
+
for (var j = 0; j < hiddenParentNodesLength; j++) {
|
180
|
+
|
181
|
+
// Restore the style attribute
|
182
|
+
hiddenParentNodes[j].style.cssText = inlineStyle[j];
|
183
|
+
toggleOpenProperty(hiddenParentNodes[j]);
|
184
|
+
}
|
185
|
+
}
|
186
|
+
return dimension;
|
187
|
+
}
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Returns the parsed float or the default if it failed.
|
191
|
+
*
|
192
|
+
* @param {String} str
|
193
|
+
* @param {Number} defaultValue
|
194
|
+
* @return {Number}
|
195
|
+
*/
|
196
|
+
function tryParseFloat(str, defaultValue) {
|
197
|
+
var value = parseFloat(str);
|
198
|
+
return Number.isNaN(value) ? defaultValue : value;
|
199
|
+
}
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Capitalize the first letter of string
|
203
|
+
*
|
204
|
+
* @param {String} str
|
205
|
+
* @return {String}
|
206
|
+
*/
|
207
|
+
function ucfirst(str) {
|
208
|
+
return str.charAt(0).toUpperCase() + str.substr(1);
|
209
|
+
}
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Plugin
|
213
|
+
* @param {String} element
|
214
|
+
* @param {Object} options
|
215
|
+
*/
|
216
|
+
function Plugin(element, options) {
|
217
|
+
this.$window = $(window);
|
218
|
+
this.$document = $(document);
|
219
|
+
this.$element = $(element);
|
220
|
+
this.options = $.extend( {}, defaults, options );
|
221
|
+
this.polyfill = this.options.polyfill;
|
222
|
+
this.orientation = this.$element[0].getAttribute('data-orientation') || this.options.orientation;
|
223
|
+
this.onInit = this.options.onInit;
|
224
|
+
this.onSlide = this.options.onSlide;
|
225
|
+
this.onSlideEnd = this.options.onSlideEnd;
|
226
|
+
this.DIMENSION = constants.orientation[this.orientation].dimension;
|
227
|
+
this.DIRECTION = constants.orientation[this.orientation].direction;
|
228
|
+
this.DIRECTION_STYLE = constants.orientation[this.orientation].directionStyle;
|
229
|
+
this.COORDINATE = constants.orientation[this.orientation].coordinate;
|
230
|
+
|
231
|
+
// Plugin should only be used as a polyfill
|
232
|
+
if (this.polyfill) {
|
233
|
+
// Input range support?
|
234
|
+
if (hasInputRangeSupport) { return false; }
|
235
|
+
}
|
236
|
+
|
237
|
+
this.identifier = 'js-' + pluginName + '-' +(pluginIdentifier++);
|
238
|
+
this.startEvent = this.options.startEvent.join('.' + this.identifier + ' ') + '.' + this.identifier;
|
239
|
+
this.moveEvent = this.options.moveEvent.join('.' + this.identifier + ' ') + '.' + this.identifier;
|
240
|
+
this.endEvent = this.options.endEvent.join('.' + this.identifier + ' ') + '.' + this.identifier;
|
241
|
+
this.toFixed = (this.step + '').replace('.', '').length - 1;
|
242
|
+
this.$fill = $('<div class="' + this.options.fillClass + '" />');
|
243
|
+
this.$handle = $('<div class="' + this.options.handleClass + '" />');
|
244
|
+
this.$range = $('<div class="' + this.options.rangeClass + ' ' + this.options[this.orientation + 'Class'] + '" id="' + this.identifier + '" />').insertAfter(this.$element).prepend(this.$fill, this.$handle);
|
245
|
+
|
246
|
+
// visually hide the input
|
247
|
+
this.$element.css({
|
248
|
+
'position': 'absolute',
|
249
|
+
'width': '1px',
|
250
|
+
'height': '1px',
|
251
|
+
'overflow': 'hidden',
|
252
|
+
'opacity': '0'
|
253
|
+
});
|
254
|
+
|
255
|
+
// Store context
|
256
|
+
this.handleDown = $.proxy(this.handleDown, this);
|
257
|
+
this.handleMove = $.proxy(this.handleMove, this);
|
258
|
+
this.handleEnd = $.proxy(this.handleEnd, this);
|
259
|
+
|
260
|
+
this.init();
|
261
|
+
|
262
|
+
// Attach Events
|
263
|
+
var _this = this;
|
264
|
+
this.$window.on('resize.' + this.identifier, debounce(function() {
|
265
|
+
// Simulate resizeEnd event.
|
266
|
+
delay(function() { _this.update(); }, 300);
|
267
|
+
}, 20));
|
268
|
+
|
269
|
+
this.$document.on(this.startEvent, '#' + this.identifier + ':not(.' + this.options.disabledClass + ')', this.handleDown);
|
270
|
+
|
271
|
+
// Listen to programmatic value changes
|
272
|
+
this.$element.on('change.' + this.identifier, function(e, data) {
|
273
|
+
if (data && data.origin === _this.identifier) {
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
|
277
|
+
var value = e.target.value,
|
278
|
+
pos = _this.getPositionFromValue(value);
|
279
|
+
_this.setPosition(pos);
|
280
|
+
});
|
281
|
+
}
|
282
|
+
|
283
|
+
Plugin.prototype.init = function() {
|
284
|
+
this.update(true, false);
|
285
|
+
|
286
|
+
if (this.onInit && typeof this.onInit === 'function') {
|
287
|
+
this.onInit();
|
288
|
+
}
|
289
|
+
};
|
290
|
+
|
291
|
+
Plugin.prototype.update = function(updateAttributes, triggerSlide) {
|
292
|
+
updateAttributes = updateAttributes || false;
|
293
|
+
|
294
|
+
if (updateAttributes) {
|
295
|
+
this.min = tryParseFloat(this.$element[0].getAttribute('min'), 0);
|
296
|
+
this.max = tryParseFloat(this.$element[0].getAttribute('max'), 100);
|
297
|
+
this.value = tryParseFloat(this.$element[0].value, Math.round(this.min + (this.max-this.min)/2));
|
298
|
+
this.step = tryParseFloat(this.$element[0].getAttribute('step'), 1);
|
299
|
+
}
|
300
|
+
|
301
|
+
this.handleDimension = getDimension(this.$handle[0], 'offset' + ucfirst(this.DIMENSION));
|
302
|
+
this.rangeDimension = getDimension(this.$range[0], 'offset' + ucfirst(this.DIMENSION));
|
303
|
+
this.maxHandlePos = this.rangeDimension - this.handleDimension;
|
304
|
+
this.grabPos = this.handleDimension / 2;
|
305
|
+
this.position = this.getPositionFromValue(this.value);
|
306
|
+
|
307
|
+
// Consider disabled state
|
308
|
+
if (this.$element[0].disabled) {
|
309
|
+
this.$range.addClass(this.options.disabledClass);
|
310
|
+
} else {
|
311
|
+
this.$range.removeClass(this.options.disabledClass);
|
312
|
+
}
|
313
|
+
|
314
|
+
this.setPosition(this.position, triggerSlide);
|
315
|
+
};
|
316
|
+
|
317
|
+
Plugin.prototype.handleDown = function(e) {
|
318
|
+
this.$document.on(this.moveEvent, this.handleMove);
|
319
|
+
this.$document.on(this.endEvent, this.handleEnd);
|
320
|
+
|
321
|
+
// If we click on the handle don't set the new position
|
322
|
+
if ((' ' + e.target.className + ' ').replace(/[\n\t]/g, ' ').indexOf(this.options.handleClass) > -1) {
|
323
|
+
return;
|
324
|
+
}
|
325
|
+
|
326
|
+
var pos = this.getRelativePosition(e),
|
327
|
+
rangePos = this.$range[0].getBoundingClientRect()[this.DIRECTION],
|
328
|
+
handlePos = this.getPositionFromNode(this.$handle[0]) - rangePos,
|
329
|
+
setPos = (this.orientation === 'vertical') ? (this.maxHandlePos - (pos - this.grabPos)) : (pos - this.grabPos);
|
330
|
+
|
331
|
+
this.setPosition(setPos);
|
332
|
+
|
333
|
+
if (pos >= handlePos && pos < handlePos + this.handleDimension) {
|
334
|
+
this.grabPos = pos - handlePos;
|
335
|
+
}
|
336
|
+
};
|
337
|
+
|
338
|
+
Plugin.prototype.handleMove = function(e) {
|
339
|
+
e.preventDefault();
|
340
|
+
var pos = this.getRelativePosition(e);
|
341
|
+
var setPos = (this.orientation === 'vertical') ? (this.maxHandlePos - (pos - this.grabPos)) : (pos - this.grabPos);
|
342
|
+
this.setPosition(setPos);
|
343
|
+
};
|
344
|
+
|
345
|
+
Plugin.prototype.handleEnd = function(e) {
|
346
|
+
e.preventDefault();
|
347
|
+
this.$document.off(this.moveEvent, this.handleMove);
|
348
|
+
this.$document.off(this.endEvent, this.handleEnd);
|
349
|
+
|
350
|
+
// Ok we're done fire the change event
|
351
|
+
this.$element.trigger('change', { origin: this.identifier });
|
352
|
+
|
353
|
+
if (this.onSlideEnd && typeof this.onSlideEnd === 'function') {
|
354
|
+
this.onSlideEnd(this.position, this.value);
|
355
|
+
}
|
356
|
+
};
|
357
|
+
|
358
|
+
Plugin.prototype.cap = function(pos, min, max) {
|
359
|
+
if (pos < min) { return min; }
|
360
|
+
if (pos > max) { return max; }
|
361
|
+
return pos;
|
362
|
+
};
|
363
|
+
|
364
|
+
Plugin.prototype.setPosition = function(pos, triggerSlide) {
|
365
|
+
var value, newPos;
|
366
|
+
|
367
|
+
if (triggerSlide === undefined) {
|
368
|
+
triggerSlide = true;
|
369
|
+
}
|
370
|
+
|
371
|
+
// Snapping steps
|
372
|
+
value = this.getValueFromPosition(this.cap(pos, 0, this.maxHandlePos));
|
373
|
+
newPos = this.getPositionFromValue(value);
|
374
|
+
|
375
|
+
// Update ui
|
376
|
+
this.$fill[0].style[this.DIMENSION] = (newPos + this.grabPos) + 'px';
|
377
|
+
this.$handle[0].style[this.DIRECTION_STYLE] = newPos + 'px';
|
378
|
+
this.setValue(value);
|
379
|
+
|
380
|
+
// Update globals
|
381
|
+
this.position = newPos;
|
382
|
+
this.value = value;
|
383
|
+
|
384
|
+
if (triggerSlide && this.onSlide && typeof this.onSlide === 'function') {
|
385
|
+
this.onSlide(newPos, value);
|
386
|
+
}
|
387
|
+
};
|
388
|
+
|
389
|
+
// Returns element position relative to the parent
|
390
|
+
Plugin.prototype.getPositionFromNode = function(node) {
|
391
|
+
var i = 0;
|
392
|
+
while (node !== null) {
|
393
|
+
i += node.offsetLeft;
|
394
|
+
node = node.offsetParent;
|
395
|
+
}
|
396
|
+
return i;
|
397
|
+
};
|
398
|
+
|
399
|
+
Plugin.prototype.getRelativePosition = function(e) {
|
400
|
+
// Get the offset DIRECTION relative to the viewport
|
401
|
+
var ucCoordinate = ucfirst(this.COORDINATE),
|
402
|
+
rangePos = this.$range[0].getBoundingClientRect()[this.DIRECTION],
|
403
|
+
pageCoordinate = 0;
|
404
|
+
|
405
|
+
if (typeof e['page' + ucCoordinate] !== 'undefined') {
|
406
|
+
pageCoordinate = e['client' + ucCoordinate];
|
407
|
+
}
|
408
|
+
else if (typeof e.originalEvent['client' + ucCoordinate] !== 'undefined') {
|
409
|
+
pageCoordinate = e.originalEvent['client' + ucCoordinate];
|
410
|
+
}
|
411
|
+
else if (e.originalEvent.touches && e.originalEvent.touches[0] && typeof e.originalEvent.touches[0]['client' + ucCoordinate] !== 'undefined') {
|
412
|
+
pageCoordinate = e.originalEvent.touches[0]['client' + ucCoordinate];
|
413
|
+
}
|
414
|
+
else if(e.currentPoint && typeof e.currentPoint[this.COORDINATE] !== 'undefined') {
|
415
|
+
pageCoordinate = e.currentPoint[this.COORDINATE];
|
416
|
+
}
|
417
|
+
|
418
|
+
return pageCoordinate - rangePos;
|
419
|
+
};
|
420
|
+
|
421
|
+
Plugin.prototype.getPositionFromValue = function(value) {
|
422
|
+
var percentage, pos;
|
423
|
+
percentage = (value - this.min)/(this.max - this.min);
|
424
|
+
pos = (!Number.isNaN(percentage)) ? percentage * this.maxHandlePos : 0;
|
425
|
+
return pos;
|
426
|
+
};
|
427
|
+
|
428
|
+
Plugin.prototype.getValueFromPosition = function(pos) {
|
429
|
+
var percentage, value;
|
430
|
+
percentage = ((pos) / (this.maxHandlePos || 1));
|
431
|
+
value = this.step * Math.round(percentage * (this.max - this.min) / this.step) + this.min;
|
432
|
+
return Number((value).toFixed(this.toFixed));
|
433
|
+
};
|
434
|
+
|
435
|
+
Plugin.prototype.setValue = function(value) {
|
436
|
+
if (value === this.value && this.$element[0].value !== '') {
|
437
|
+
return;
|
438
|
+
}
|
439
|
+
|
440
|
+
// Set the new value and fire the `input` event
|
441
|
+
this.$element
|
442
|
+
.val(value)
|
443
|
+
.trigger('input', { origin: this.identifier });
|
444
|
+
};
|
445
|
+
|
446
|
+
Plugin.prototype.destroy = function() {
|
447
|
+
this.$document.off('.' + this.identifier);
|
448
|
+
this.$window.off('.' + this.identifier);
|
449
|
+
|
450
|
+
this.$element
|
451
|
+
.off('.' + this.identifier)
|
452
|
+
.removeAttr('style')
|
453
|
+
.removeData('plugin_' + pluginName);
|
454
|
+
|
455
|
+
// Remove the generated markup
|
456
|
+
if (this.$range && this.$range.length) {
|
457
|
+
this.$range[0].parentNode.removeChild(this.$range[0]);
|
458
|
+
}
|
459
|
+
};
|
460
|
+
|
461
|
+
// A really lightweight plugin wrapper around the constructor,
|
462
|
+
// preventing against multiple instantiations
|
463
|
+
$.fn[pluginName] = function(options) {
|
464
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
465
|
+
|
466
|
+
return this.each(function() {
|
467
|
+
var $this = $(this),
|
468
|
+
data = $this.data('plugin_' + pluginName);
|
469
|
+
|
470
|
+
// Create a new instance.
|
471
|
+
if (!data) {
|
472
|
+
$this.data('plugin_' + pluginName, (data = new Plugin(this, options)));
|
473
|
+
}
|
474
|
+
|
475
|
+
// Make it possible to access methods from public.
|
476
|
+
// e.g `$element.rangeslider('method');`
|
477
|
+
if (typeof options === 'string') {
|
478
|
+
data[options].apply(data, args);
|
479
|
+
}
|
480
|
+
});
|
481
|
+
};
|
482
|
+
|
483
|
+
}));
|
@@ -0,0 +1,111 @@
|
|
1
|
+
.rangeslider,
|
2
|
+
.rangeslider__fill {
|
3
|
+
display: block;
|
4
|
+
-moz-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.3);
|
5
|
+
-webkit-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.3);
|
6
|
+
box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.3);
|
7
|
+
-moz-border-radius: 10px;
|
8
|
+
-webkit-border-radius: 10px;
|
9
|
+
border-radius: 10px;
|
10
|
+
}
|
11
|
+
|
12
|
+
.rangeslider {
|
13
|
+
background: #e6e6e6;
|
14
|
+
position: relative;
|
15
|
+
}
|
16
|
+
|
17
|
+
.rangeslider--horizontal {
|
18
|
+
height: 20px;
|
19
|
+
width: 100%;
|
20
|
+
}
|
21
|
+
|
22
|
+
.rangeslider--vertical {
|
23
|
+
width: 20px;
|
24
|
+
min-height: 150px;
|
25
|
+
max-height: 100%;
|
26
|
+
}
|
27
|
+
|
28
|
+
.rangeslider--disabled {
|
29
|
+
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
|
30
|
+
opacity: 0.4;
|
31
|
+
}
|
32
|
+
|
33
|
+
.rangeslider__fill {
|
34
|
+
background: #00ff00;
|
35
|
+
position: absolute;
|
36
|
+
}
|
37
|
+
.rangeslider--horizontal .rangeslider__fill {
|
38
|
+
top: 0;
|
39
|
+
height: 100%;
|
40
|
+
}
|
41
|
+
.rangeslider--vertical .rangeslider__fill {
|
42
|
+
bottom: 0;
|
43
|
+
width: 100%;
|
44
|
+
}
|
45
|
+
|
46
|
+
.rangeslider__handle {
|
47
|
+
background: white;
|
48
|
+
border: 1px solid #ccc;
|
49
|
+
cursor: pointer;
|
50
|
+
display: inline-block;
|
51
|
+
width: 40px;
|
52
|
+
height: 40px;
|
53
|
+
position: absolute;
|
54
|
+
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDAwMDAiIHN0b3Atb3BhY2l0eT0iMC4xIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
|
55
|
+
background-size: 100%;
|
56
|
+
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(0, 0, 0, 0.1)));
|
57
|
+
background-image: -moz-linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1));
|
58
|
+
background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1));
|
59
|
+
background-image: linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1));
|
60
|
+
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
61
|
+
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
62
|
+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
63
|
+
-moz-border-radius: 50%;
|
64
|
+
-webkit-border-radius: 50%;
|
65
|
+
border-radius: 50%;
|
66
|
+
}
|
67
|
+
.rangeslider__handle:after {
|
68
|
+
content: "";
|
69
|
+
display: block;
|
70
|
+
width: 18px;
|
71
|
+
height: 18px;
|
72
|
+
margin: auto;
|
73
|
+
position: absolute;
|
74
|
+
top: 0;
|
75
|
+
right: 0;
|
76
|
+
bottom: 0;
|
77
|
+
left: 0;
|
78
|
+
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjEzIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIiBzdG9wLW9wYWNpdHk9IjAuMCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
|
79
|
+
background-size: 100%;
|
80
|
+
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0.13)), color-stop(100%, rgba(255, 255, 255, 0)));
|
81
|
+
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0.13), rgba(255, 255, 255, 0));
|
82
|
+
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0.13), rgba(255, 255, 255, 0));
|
83
|
+
background-image: linear-gradient(rgba(0, 0, 0, 0.13), rgba(255, 255, 255, 0));
|
84
|
+
-moz-border-radius: 50%;
|
85
|
+
-webkit-border-radius: 50%;
|
86
|
+
border-radius: 50%;
|
87
|
+
}
|
88
|
+
.rangeslider__handle:active {
|
89
|
+
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjEiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDAwMDAiIHN0b3Atb3BhY2l0eT0iMC4xMiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
|
90
|
+
background-size: 100%;
|
91
|
+
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0.1)), color-stop(100%, rgba(0, 0, 0, 0.12)));
|
92
|
+
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.12));
|
93
|
+
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.12));
|
94
|
+
background-image: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.12));
|
95
|
+
}
|
96
|
+
.rangeslider--horizontal .rangeslider__handle {
|
97
|
+
top: -10px;
|
98
|
+
touch-action: pan-y;
|
99
|
+
-ms-touch-action: pan-y;
|
100
|
+
}
|
101
|
+
.rangeslider--vertical .rangeslider__handle {
|
102
|
+
left: -10px;
|
103
|
+
touch-action: pan-x;
|
104
|
+
-ms-touch-action: pan-x;
|
105
|
+
}
|
106
|
+
|
107
|
+
input[type="range"]:focus + .rangeslider .rangeslider__handle {
|
108
|
+
-moz-box-shadow: 0 0 8px rgba(255, 0, 255, 0.9);
|
109
|
+
-webkit-box-shadow: 0 0 8px rgba(255, 0, 255, 0.9);
|
110
|
+
box-shadow: 0 0 8px rgba(255, 0, 255, 0.9);
|
111
|
+
}
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rangesliderjs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilja Krijger
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Simple, small and fast JavaScript/jQuery polyfill for the HTML5 <input
|
42
|
+
type="range"> slider element.
|
43
|
+
email:
|
44
|
+
- ilja@quittheprogram.org
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.md
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/rangesliderjs/rails.rb
|
55
|
+
- lib/rangesliderjs/rails/version.rb
|
56
|
+
- rangesliderjs-rails.gemspec
|
57
|
+
- vendor/assets/javascripts/rangeslider.js
|
58
|
+
- vendor/assets/stylesheets/rangeslider.css
|
59
|
+
homepage: https://github.com/ilja/rangesliderjs-rails.
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.2.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: rangeslider.js packaged for the rails assets pipeline.
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|