Mercurial > web-octave
annotate js/foundation/foundation.slider.js @ 0:7abe02bf29ec
initial commit
author | Alex Krolick <whokilledtheelectricmonk@gmail.com> |
---|---|
date | Sat, 07 Nov 2015 18:04:42 -0800 |
parents | |
children |
rev | line source |
---|---|
0
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
1 ;(function ($, window, document, undefined) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
2 'use strict'; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
3 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
4 Foundation.libs.slider = { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
5 name : 'slider', |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
6 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
7 version : '5.5.3', |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
8 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
9 settings : { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
10 start : 0, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
11 end : 100, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
12 step : 1, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
13 precision : 2, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
14 initial : null, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
15 display_selector : '', |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
16 vertical : false, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
17 trigger_input_change : false, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
18 on_change : function () {} |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
19 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
20 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
21 cache : {}, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
22 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
23 init : function (scope, method, options) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
24 Foundation.inherit(this, 'throttle'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
25 this.bindings(method, options); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
26 this.reflow(); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
27 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
28 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
29 events : function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
30 var self = this; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
31 $(this.scope) |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
32 .off('.slider') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
33 .on('mousedown.fndtn.slider touchstart.fndtn.slider pointerdown.fndtn.slider', |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
34 '[' + self.attr_name() + ']:not(.disabled, [disabled]) .range-slider-handle', function (e) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
35 if (!self.cache.active) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
36 e.preventDefault(); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
37 self.set_active_slider($(e.target)); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
38 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
39 }) |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
40 .on('mousemove.fndtn.slider touchmove.fndtn.slider pointermove.fndtn.slider', function (e) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
41 if (!!self.cache.active) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
42 e.preventDefault(); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
43 if ($.data(self.cache.active[0], 'settings').vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
44 var scroll_offset = 0; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
45 if (!e.pageY) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
46 scroll_offset = window.scrollY; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
47 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
48 self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
49 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
50 self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x')); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
51 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
52 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
53 }) |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
54 .on('mouseup.fndtn.slider touchend.fndtn.slider pointerup.fndtn.slider', function (e) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
55 if(!self.cache.active) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
56 // if the user has just clicked into the slider without starting to drag the handle |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
57 var slider = $(e.target).attr('role') === 'slider' ? $(e.target) : $(e.target).closest('.range-slider').find("[role='slider']"); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
58 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
59 if (slider.length && (!slider.parent().hasClass('disabled') && !slider.parent().attr('disabled'))) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
60 self.set_active_slider(slider); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
61 if ($.data(self.cache.active[0], 'settings').vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
62 var scroll_offset = 0; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
63 if (!e.pageY) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
64 scroll_offset = window.scrollY; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
65 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
66 self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
67 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
68 self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x')); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
69 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
70 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
71 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
72 self.remove_active_slider(); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
73 }) |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
74 .on('change.fndtn.slider', function (e) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
75 self.settings.on_change(); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
76 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
77 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
78 self.S(window) |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
79 .on('resize.fndtn.slider', self.throttle(function (e) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
80 self.reflow(); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
81 }, 300)); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
82 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
83 // update slider value as users change input value |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
84 this.S('[' + this.attr_name() + ']').each(function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
85 var slider = $(this), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
86 handle = slider.children('.range-slider-handle')[0], |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
87 settings = self.initialize_settings(handle); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
88 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
89 if (settings.display_selector != '') { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
90 $(settings.display_selector).each(function(){ |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
91 if ($(this).attr('value')) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
92 $(this).off('change').on('change', function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
93 slider.foundation("slider", "set_value", $(this).val()); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
94 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
95 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
96 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
97 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
98 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
99 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
100 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
101 get_cursor_position : function (e, xy) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
102 var pageXY = 'page' + xy.toUpperCase(), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
103 clientXY = 'client' + xy.toUpperCase(), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
104 position; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
105 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
106 if (typeof e[pageXY] !== 'undefined') { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
107 position = e[pageXY]; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
108 } else if (typeof e.originalEvent[clientXY] !== 'undefined') { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
109 position = e.originalEvent[clientXY]; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
110 } else if (e.originalEvent.touches && e.originalEvent.touches[0] && typeof e.originalEvent.touches[0][clientXY] !== 'undefined') { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
111 position = e.originalEvent.touches[0][clientXY]; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
112 } else if (e.currentPoint && typeof e.currentPoint[xy] !== 'undefined') { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
113 position = e.currentPoint[xy]; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
114 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
115 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
116 return position; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
117 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
118 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
119 set_active_slider : function ($handle) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
120 this.cache.active = $handle; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
121 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
122 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
123 remove_active_slider : function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
124 this.cache.active = null; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
125 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
126 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
127 calculate_position : function ($handle, cursor_x) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
128 var self = this, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
129 settings = $.data($handle[0], 'settings'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
130 handle_l = $.data($handle[0], 'handle_l'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
131 handle_o = $.data($handle[0], 'handle_o'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
132 bar_l = $.data($handle[0], 'bar_l'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
133 bar_o = $.data($handle[0], 'bar_o'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
134 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
135 requestAnimationFrame(function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
136 var pct; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
137 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
138 if (Foundation.rtl && !settings.vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
139 pct = self.limit_to(((bar_o + bar_l - cursor_x) / bar_l), 0, 1); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
140 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
141 pct = self.limit_to(((cursor_x - bar_o) / bar_l), 0, 1); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
142 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
143 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
144 pct = settings.vertical ? 1 - pct : pct; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
145 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
146 var norm = self.normalized_value(pct, settings.start, settings.end, settings.step, settings.precision); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
147 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
148 self.set_ui($handle, norm); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
149 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
150 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
151 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
152 set_ui : function ($handle, value) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
153 var settings = $.data($handle[0], 'settings'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
154 handle_l = $.data($handle[0], 'handle_l'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
155 bar_l = $.data($handle[0], 'bar_l'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
156 norm_pct = this.normalized_percentage(value, settings.start, settings.end), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
157 handle_offset = norm_pct * (bar_l - handle_l) - 1, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
158 progress_bar_length = norm_pct * 100, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
159 $handle_parent = $handle.parent(), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
160 $hidden_inputs = $handle.parent().children('input[type=hidden]'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
161 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
162 if (Foundation.rtl && !settings.vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
163 handle_offset = -handle_offset; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
164 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
165 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
166 handle_offset = settings.vertical ? -handle_offset + bar_l - handle_l + 1 : handle_offset; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
167 this.set_translate($handle, handle_offset, settings.vertical); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
168 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
169 if (settings.vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
170 $handle.siblings('.range-slider-active-segment').css('height', progress_bar_length + '%'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
171 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
172 $handle.siblings('.range-slider-active-segment').css('width', progress_bar_length + '%'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
173 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
174 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
175 $handle_parent.attr(this.attr_name(), value).trigger('change.fndtn.slider'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
176 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
177 $hidden_inputs.val(value); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
178 if (settings.trigger_input_change) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
179 $hidden_inputs.trigger('change.fndtn.slider'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
180 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
181 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
182 if (!$handle[0].hasAttribute('aria-valuemin')) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
183 $handle.attr({ |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
184 'aria-valuemin' : settings.start, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
185 'aria-valuemax' : settings.end |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
186 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
187 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
188 $handle.attr('aria-valuenow', value); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
189 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
190 if (settings.display_selector != '') { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
191 $(settings.display_selector).each(function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
192 if (this.hasAttribute('value')) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
193 $(this).val(value); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
194 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
195 $(this).text(value); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
196 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
197 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
198 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
199 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
200 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
201 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
202 normalized_percentage : function (val, start, end) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
203 return Math.min(1, (val - start) / (end - start)); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
204 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
205 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
206 normalized_value : function (val, start, end, step, precision) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
207 var range = end - start, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
208 point = val * range, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
209 mod = (point - (point % step)) / step, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
210 rem = point % step, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
211 round = ( rem >= step * 0.5 ? step : 0); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
212 return ((mod * step + round) + start).toFixed(precision); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
213 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
214 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
215 set_translate : function (ele, offset, vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
216 if (vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
217 $(ele) |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
218 .css('-webkit-transform', 'translateY(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
219 .css('-moz-transform', 'translateY(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
220 .css('-ms-transform', 'translateY(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
221 .css('-o-transform', 'translateY(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
222 .css('transform', 'translateY(' + offset + 'px)'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
223 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
224 $(ele) |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
225 .css('-webkit-transform', 'translateX(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
226 .css('-moz-transform', 'translateX(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
227 .css('-ms-transform', 'translateX(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
228 .css('-o-transform', 'translateX(' + offset + 'px)') |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
229 .css('transform', 'translateX(' + offset + 'px)'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
230 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
231 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
232 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
233 limit_to : function (val, min, max) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
234 return Math.min(Math.max(val, min), max); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
235 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
236 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
237 initialize_settings : function (handle) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
238 var settings = $.extend({}, this.settings, this.data_options($(handle).parent())), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
239 decimal_places_match_result; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
240 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
241 if (settings.precision === null) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
242 decimal_places_match_result = ('' + settings.step).match(/\.([\d]*)/); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
243 settings.precision = decimal_places_match_result && decimal_places_match_result[1] ? decimal_places_match_result[1].length : 0; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
244 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
245 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
246 if (settings.vertical) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
247 $.data(handle, 'bar_o', $(handle).parent().offset().top); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
248 $.data(handle, 'bar_l', $(handle).parent().outerHeight()); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
249 $.data(handle, 'handle_o', $(handle).offset().top); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
250 $.data(handle, 'handle_l', $(handle).outerHeight()); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
251 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
252 $.data(handle, 'bar_o', $(handle).parent().offset().left); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
253 $.data(handle, 'bar_l', $(handle).parent().outerWidth()); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
254 $.data(handle, 'handle_o', $(handle).offset().left); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
255 $.data(handle, 'handle_l', $(handle).outerWidth()); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
256 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
257 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
258 $.data(handle, 'bar', $(handle).parent()); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
259 return $.data(handle, 'settings', settings); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
260 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
261 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
262 set_initial_position : function ($ele) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
263 var settings = $.data($ele.children('.range-slider-handle')[0], 'settings'), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
264 initial = ((typeof settings.initial == 'number' && !isNaN(settings.initial)) ? settings.initial : Math.floor((settings.end - settings.start) * 0.5 / settings.step) * settings.step + settings.start), |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
265 $handle = $ele.children('.range-slider-handle'); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
266 this.set_ui($handle, initial); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
267 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
268 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
269 set_value : function (value) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
270 var self = this; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
271 $('[' + self.attr_name() + ']', this.scope).each(function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
272 $(this).attr(self.attr_name(), value); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
273 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
274 if (!!$(this.scope).attr(self.attr_name())) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
275 $(this.scope).attr(self.attr_name(), value); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
276 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
277 self.reflow(); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
278 }, |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
279 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
280 reflow : function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
281 var self = this; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
282 self.S('[' + this.attr_name() + ']').each(function () { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
283 var handle = $(this).children('.range-slider-handle')[0], |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
284 val = $(this).attr(self.attr_name()); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
285 self.initialize_settings(handle); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
286 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
287 if (val) { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
288 self.set_ui($(handle), parseFloat(val)); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
289 } else { |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
290 self.set_initial_position($(this)); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
291 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
292 }); |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
293 } |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
294 }; |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
295 |
7abe02bf29ec
initial commit
Alex Krolick <whokilledtheelectricmonk@gmail.com>
parents:
diff
changeset
|
296 }(jQuery, window, window.document)); |