rails-active-ui 0.3.0 → 0.3.2

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.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/app/javascript/ui/controllers/turbo_modal_controller.js +36 -0
  3. data/config/importmap.rb +1 -0
  4. data/formantic-ui/components/accordion.css +369 -0
  5. data/formantic-ui/components/accordion.js +595 -0
  6. data/formantic-ui/components/accordion.min.css +9 -0
  7. data/formantic-ui/components/accordion.min.js +11 -0
  8. data/formantic-ui/components/ad.css +264 -0
  9. data/formantic-ui/components/ad.min.css +10 -0
  10. data/formantic-ui/components/api.js +1225 -0
  11. data/formantic-ui/components/api.min.js +11 -0
  12. data/formantic-ui/components/breadcrumb.css +135 -0
  13. data/formantic-ui/components/breadcrumb.min.css +9 -0
  14. data/formantic-ui/components/button.css +4058 -0
  15. data/formantic-ui/components/button.min.css +9 -0
  16. data/formantic-ui/components/calendar.css +327 -0
  17. data/formantic-ui/components/calendar.js +2045 -0
  18. data/formantic-ui/components/calendar.min.css +9 -0
  19. data/formantic-ui/components/calendar.min.js +11 -0
  20. data/formantic-ui/components/card.css +1881 -0
  21. data/formantic-ui/components/card.min.css +9 -0
  22. data/formantic-ui/components/checkbox.css +785 -0
  23. data/formantic-ui/components/checkbox.js +888 -0
  24. data/formantic-ui/components/checkbox.min.css +9 -0
  25. data/formantic-ui/components/checkbox.min.js +11 -0
  26. data/formantic-ui/components/comment.css +283 -0
  27. data/formantic-ui/components/comment.min.css +9 -0
  28. data/formantic-ui/components/container.css +300 -0
  29. data/formantic-ui/components/container.min.css +9 -0
  30. data/formantic-ui/components/dimmer.css +367 -0
  31. data/formantic-ui/components/dimmer.js +732 -0
  32. data/formantic-ui/components/dimmer.min.css +9 -0
  33. data/formantic-ui/components/dimmer.min.js +11 -0
  34. data/formantic-ui/components/divider.css +287 -0
  35. data/formantic-ui/components/divider.min.css +9 -0
  36. data/formantic-ui/components/dropdown.css +2087 -0
  37. data/formantic-ui/components/dropdown.js +4432 -0
  38. data/formantic-ui/components/dropdown.min.css +9 -0
  39. data/formantic-ui/components/dropdown.min.js +11 -0
  40. data/formantic-ui/components/embed.css +155 -0
  41. data/formantic-ui/components/embed.js +688 -0
  42. data/formantic-ui/components/embed.min.css +9 -0
  43. data/formantic-ui/components/embed.min.js +11 -0
  44. data/formantic-ui/components/emoji.css +15311 -0
  45. data/formantic-ui/components/emoji.min.css +9 -0
  46. data/formantic-ui/components/feed.css +799 -0
  47. data/formantic-ui/components/feed.min.css +9 -0
  48. data/formantic-ui/components/flag.css +1149 -0
  49. data/formantic-ui/components/flag.min.css +9 -0
  50. data/formantic-ui/components/flyout.css +546 -0
  51. data/formantic-ui/components/flyout.js +1551 -0
  52. data/formantic-ui/components/flyout.min.css +9 -0
  53. data/formantic-ui/components/flyout.min.js +11 -0
  54. data/formantic-ui/components/form.css +1885 -0
  55. data/formantic-ui/components/form.js +2199 -0
  56. data/formantic-ui/components/form.min.css +9 -0
  57. data/formantic-ui/components/form.min.js +11 -0
  58. data/formantic-ui/components/grid.css +1952 -0
  59. data/formantic-ui/components/grid.min.css +9 -0
  60. data/formantic-ui/components/header.css +778 -0
  61. data/formantic-ui/components/header.min.css +9 -0
  62. data/formantic-ui/components/icon.css +7066 -0
  63. data/formantic-ui/components/icon.min.css +9 -0
  64. data/formantic-ui/components/image.css +315 -0
  65. data/formantic-ui/components/image.min.css +9 -0
  66. data/formantic-ui/components/input.css +1566 -0
  67. data/formantic-ui/components/input.min.css +9 -0
  68. data/formantic-ui/components/item.css +534 -0
  69. data/formantic-ui/components/item.min.css +9 -0
  70. data/formantic-ui/components/label.css +2114 -0
  71. data/formantic-ui/components/label.min.css +9 -0
  72. data/formantic-ui/components/list.css +955 -0
  73. data/formantic-ui/components/list.min.css +9 -0
  74. data/formantic-ui/components/loader.css +787 -0
  75. data/formantic-ui/components/loader.min.css +9 -0
  76. data/formantic-ui/components/menu.css +2131 -0
  77. data/formantic-ui/components/menu.min.css +9 -0
  78. data/formantic-ui/components/message.css +619 -0
  79. data/formantic-ui/components/message.min.css +9 -0
  80. data/formantic-ui/components/modal.css +779 -0
  81. data/formantic-ui/components/modal.js +1637 -0
  82. data/formantic-ui/components/modal.min.css +9 -0
  83. data/formantic-ui/components/modal.min.js +11 -0
  84. data/formantic-ui/components/nag.css +290 -0
  85. data/formantic-ui/components/nag.js +566 -0
  86. data/formantic-ui/components/nag.min.css +9 -0
  87. data/formantic-ui/components/nag.min.js +11 -0
  88. data/formantic-ui/components/placeholder.css +228 -0
  89. data/formantic-ui/components/placeholder.min.css +9 -0
  90. data/formantic-ui/components/popup.css +1184 -0
  91. data/formantic-ui/components/popup.js +1561 -0
  92. data/formantic-ui/components/popup.min.css +9 -0
  93. data/formantic-ui/components/popup.min.js +11 -0
  94. data/formantic-ui/components/progress.css +761 -0
  95. data/formantic-ui/components/progress.js +979 -0
  96. data/formantic-ui/components/progress.min.css +9 -0
  97. data/formantic-ui/components/progress.min.js +11 -0
  98. data/formantic-ui/components/rail.css +147 -0
  99. data/formantic-ui/components/rail.min.css +9 -0
  100. data/formantic-ui/components/rating.css +414 -0
  101. data/formantic-ui/components/rating.js +540 -0
  102. data/formantic-ui/components/rating.min.css +9 -0
  103. data/formantic-ui/components/rating.min.js +11 -0
  104. data/formantic-ui/components/reset.css +386 -0
  105. data/formantic-ui/components/reset.min.css +9 -0
  106. data/formantic-ui/components/reveal.css +277 -0
  107. data/formantic-ui/components/reveal.min.css +9 -0
  108. data/formantic-ui/components/search.css +541 -0
  109. data/formantic-ui/components/search.js +1641 -0
  110. data/formantic-ui/components/search.min.css +9 -0
  111. data/formantic-ui/components/search.min.js +11 -0
  112. data/formantic-ui/components/segment.css +1053 -0
  113. data/formantic-ui/components/segment.min.css +9 -0
  114. data/formantic-ui/components/shape.css +144 -0
  115. data/formantic-ui/components/shape.js +797 -0
  116. data/formantic-ui/components/shape.min.css +9 -0
  117. data/formantic-ui/components/shape.min.js +11 -0
  118. data/formantic-ui/components/sidebar.css +539 -0
  119. data/formantic-ui/components/sidebar.js +1054 -0
  120. data/formantic-ui/components/sidebar.min.css +9 -0
  121. data/formantic-ui/components/sidebar.min.js +11 -0
  122. data/formantic-ui/components/site.css +286 -0
  123. data/formantic-ui/components/site.js +455 -0
  124. data/formantic-ui/components/site.min.css +9 -0
  125. data/formantic-ui/components/site.min.js +11 -0
  126. data/formantic-ui/components/slider.css +926 -0
  127. data/formantic-ui/components/slider.js +1546 -0
  128. data/formantic-ui/components/slider.min.css +9 -0
  129. data/formantic-ui/components/slider.min.js +11 -0
  130. data/formantic-ui/components/state.js +697 -0
  131. data/formantic-ui/components/state.min.js +11 -0
  132. data/formantic-ui/components/statistic.css +586 -0
  133. data/formantic-ui/components/statistic.min.css +9 -0
  134. data/formantic-ui/components/step.css +1538 -0
  135. data/formantic-ui/components/step.min.css +9 -0
  136. data/formantic-ui/components/sticky.css +73 -0
  137. data/formantic-ui/components/sticky.js +917 -0
  138. data/formantic-ui/components/sticky.min.css +9 -0
  139. data/formantic-ui/components/sticky.min.js +11 -0
  140. data/formantic-ui/components/tab.css +84 -0
  141. data/formantic-ui/components/tab.js +967 -0
  142. data/formantic-ui/components/tab.min.css +9 -0
  143. data/formantic-ui/components/tab.min.js +11 -0
  144. data/formantic-ui/components/table.css +3473 -0
  145. data/formantic-ui/components/table.min.css +9 -0
  146. data/formantic-ui/components/text.css +155 -0
  147. data/formantic-ui/components/text.min.css +9 -0
  148. data/formantic-ui/components/toast.css +751 -0
  149. data/formantic-ui/components/toast.js +964 -0
  150. data/formantic-ui/components/toast.min.css +9 -0
  151. data/formantic-ui/components/toast.min.js +11 -0
  152. data/formantic-ui/components/transition.css +1148 -0
  153. data/formantic-ui/components/transition.js +1034 -0
  154. data/formantic-ui/components/transition.min.css +9 -0
  155. data/formantic-ui/components/transition.min.js +11 -0
  156. data/formantic-ui/components/visibility.js +1292 -0
  157. data/formantic-ui/components/visibility.min.js +11 -0
  158. data/formantic-ui/semantic.css +78485 -0
  159. data/formantic-ui/semantic.js +31036 -0
  160. data/formantic-ui/semantic.min.css +11 -0
  161. data/formantic-ui/semantic.min.js +11 -0
  162. data/formantic-ui/themes/basic/assets/fonts/LICENSE.txt +91 -0
  163. data/formantic-ui/themes/basic/assets/fonts/icons.woff +0 -0
  164. data/formantic-ui/themes/basic/assets/fonts/icons.woff2 +0 -0
  165. data/formantic-ui/themes/default/assets/fonts/LICENSE_Lato.txt +94 -0
  166. data/formantic-ui/themes/default/assets/fonts/LICENSE_icons.txt +165 -0
  167. data/formantic-ui/themes/default/assets/fonts/Lato-Bold.woff +0 -0
  168. data/formantic-ui/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
  169. data/formantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
  170. data/formantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  171. data/formantic-ui/themes/default/assets/fonts/Lato-Italic.woff +0 -0
  172. data/formantic-ui/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
  173. data/formantic-ui/themes/default/assets/fonts/Lato-Regular.woff +0 -0
  174. data/formantic-ui/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
  175. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
  176. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
  177. data/formantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
  178. data/formantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
  179. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
  180. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
  181. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
  182. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
  183. data/formantic-ui/themes/default/assets/fonts/brand-icons.woff +0 -0
  184. data/formantic-ui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
  185. data/formantic-ui/themes/default/assets/fonts/icons.woff +0 -0
  186. data/formantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
  187. data/formantic-ui/themes/default/assets/fonts/outline-icons.woff +0 -0
  188. data/formantic-ui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  189. data/formantic-ui/themes/famfamfam/assets/images/flags.png +0 -0
  190. data/formantic-ui/themes/github/assets/fonts/LICENSE.txt +94 -0
  191. data/formantic-ui/themes/github/assets/fonts/octicons.woff +0 -0
  192. data/formantic-ui/themes/github/assets/fonts/octicons.woff2 +0 -0
  193. data/formantic-ui/themes/material/assets/fonts/LICENSE.txt +202 -0
  194. data/formantic-ui/themes/material/assets/fonts/icons.woff +0 -0
  195. data/formantic-ui/themes/material/assets/fonts/icons.woff2 +0 -0
  196. data/lib/ui/version.rb +1 -1
  197. metadata +194 -1
@@ -0,0 +1,1546 @@
1
+ /*!
2
+ * # Fomantic-UI 2.9.4 - Slider
3
+ * https://github.com/fomantic/Fomantic-UI/
4
+ *
5
+ *
6
+ * Released under the MIT license
7
+ * https://opensource.org/licenses/MIT
8
+ *
9
+ */
10
+
11
+ (function ($, window, document) {
12
+ 'use strict';
13
+
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
17
+
18
+ window = window !== undefined && window.Math === Math
19
+ ? window
20
+ : globalThis;
21
+
22
+ $.fn.slider = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $document = $(document),
26
+ $window = $(window),
27
+
28
+ time = Date.now(),
29
+ performance = [],
30
+
31
+ query = arguments[0],
32
+ methodInvoked = typeof query === 'string',
33
+ queryArguments = [].slice.call(arguments, 1),
34
+
35
+ SINGLE_STEP = 1,
36
+ BIG_STEP = 2,
37
+ NO_STEP = 0,
38
+ SINGLE_BACKSTEP = -1,
39
+ BIG_BACKSTEP = -2,
40
+
41
+ // Used to manage document bound events.
42
+ // Use this so that we can distinguish between which document events are bound to which range.
43
+ currentRange = 0,
44
+
45
+ returnedValue
46
+ ;
47
+
48
+ $allModules.each(function () {
49
+ var
50
+ settings = $.isPlainObject(parameters)
51
+ ? $.extend(true, {}, $.fn.slider.settings, parameters)
52
+ : $.extend({}, $.fn.slider.settings),
53
+
54
+ className = settings.className,
55
+ metadata = settings.metadata,
56
+ namespace = settings.namespace,
57
+ error = settings.error,
58
+ keys = settings.keys,
59
+ interpretLabel = settings.interpretLabel,
60
+
61
+ isHover = false,
62
+ eventNamespace = '.' + namespace,
63
+ moduleNamespace = 'module-' + namespace,
64
+
65
+ $module = $(this),
66
+ $currThumb,
67
+ touchIdentifier,
68
+ $thumb,
69
+ $secondThumb,
70
+ $track,
71
+ $trackFill,
72
+ $labels,
73
+
74
+ element = this,
75
+ instance = $module.data(moduleNamespace),
76
+
77
+ documentEventID,
78
+
79
+ value,
80
+ position,
81
+ secondPos,
82
+ offset,
83
+ gapRatio = 1,
84
+ previousValue,
85
+
86
+ initialPosition,
87
+ initialLoad,
88
+ module
89
+ ;
90
+
91
+ module = {
92
+
93
+ initialize: function () {
94
+ module.debug('Initializing slider', settings);
95
+ initialLoad = true;
96
+
97
+ currentRange += 1;
98
+ documentEventID = currentRange;
99
+
100
+ module.setup.layout();
101
+ module.setup.labels();
102
+
103
+ module.bind.events();
104
+
105
+ module.read.metadata();
106
+ module.read.settings();
107
+
108
+ initialLoad = false;
109
+ module.instantiate();
110
+ },
111
+
112
+ instantiate: function () {
113
+ module.verbose('Storing instance of slider', module);
114
+ instance = module;
115
+ $module
116
+ .data(moduleNamespace, module)
117
+ ;
118
+ },
119
+
120
+ destroy: function () {
121
+ module.verbose('Destroying previous slider for', $module);
122
+ clearInterval(instance.interval);
123
+ module.unbind.events();
124
+ module.unbind.slidingEvents();
125
+ delete module.cache;
126
+ $module.removeData(moduleNamespace);
127
+ instance = undefined;
128
+ },
129
+
130
+ setup: {
131
+ layout: function () {
132
+ if ($module.attr('tabindex') === undefined) {
133
+ $module.attr('tabindex', 0);
134
+ }
135
+ if ($module.find('.inner').length === 0) {
136
+ $module.append('<div class="inner">'
137
+ + '<div class="track"></div>'
138
+ + '<div class="track-fill"></div>'
139
+ + '<div class="thumb"></div>'
140
+ + '</div>');
141
+ }
142
+ module.clear.cache();
143
+ $thumb = $module.find('.thumb:not(.second)');
144
+ if (settings.showThumbTooltip) {
145
+ $thumb
146
+ .attr('data-position', settings.tooltipConfig.position)
147
+ .attr('data-variation', settings.tooltipConfig.variation)
148
+ ;
149
+ }
150
+ $currThumb = $thumb;
151
+ if (module.is.range()) {
152
+ if ($module.find('.thumb.second').length === 0) {
153
+ $module.find('.inner').append('<div class="thumb second"></div>');
154
+ }
155
+ $secondThumb = $module.find('.thumb.second');
156
+ if (settings.showThumbTooltip) {
157
+ $secondThumb
158
+ .attr('data-position', settings.tooltipConfig.position)
159
+ .attr('data-variation', settings.tooltipConfig.variation)
160
+ ;
161
+ }
162
+ }
163
+ $track = $module.find('.track');
164
+ $trackFill = $module.find('.track-fill');
165
+ offset = $thumb.width() / 2;
166
+ },
167
+ labels: function () {
168
+ if (module.is.labeled()) {
169
+ $labels = $module.find('.labels:not(.auto)');
170
+ if ($labels.length > 0) {
171
+ module.setup.customLabel();
172
+ } else {
173
+ module.setup.autoLabel();
174
+ }
175
+
176
+ if (settings.highlightRange) {
177
+ $labels.addClass(className.active);
178
+ }
179
+
180
+ if (settings.showLabelTicks) {
181
+ $module.addClass(className.ticked);
182
+ } else if ($module.hasClass(className.ticked)) {
183
+ settings.showLabelTicks = 'always';
184
+ }
185
+ }
186
+ },
187
+ customLabel: function () {
188
+ var
189
+ $children = $labels.find('.label'),
190
+ numChildren = $children.length,
191
+ min = module.get.min(),
192
+ max = module.get.max(),
193
+ ratio
194
+ ;
195
+ $children.each(function (index) {
196
+ var
197
+ $child = $(this),
198
+ attrValue = $child.attr('data-value')
199
+ ;
200
+ if (attrValue) {
201
+ attrValue = attrValue > max
202
+ ? max
203
+ : (attrValue < min ? min : attrValue);
204
+ ratio = (attrValue - min) / (max - min);
205
+ } else {
206
+ ratio = (index + 1) / (numChildren + 1);
207
+ }
208
+ module.update.labelPosition(ratio, $(this));
209
+ });
210
+ },
211
+ autoLabel: function () {
212
+ $labels = $module.find('.labels');
213
+ if ($labels.length > 0) {
214
+ $labels.empty();
215
+ } else {
216
+ $labels = $module.append('<ul class="auto labels"></ul>').find('.labels');
217
+ }
218
+ var step = module.get.step(),
219
+ precision = module.get.precision(),
220
+ len = module.get.numLabels(),
221
+ ignoreLabels = len - (settings.autoAdjustLabels !== 'fixed' ? 0 : module.get.max().toString().length + 4)
222
+ ;
223
+ for (var i = 0; i <= len; i++) {
224
+ var
225
+ stepValue = Math.round(((i * (step === 0 ? 1 : step)) + module.get.min()) * precision) / precision,
226
+ labelText = module.get.label(i, stepValue),
227
+ showLabel = settings.restrictedLabels.length === 0 || settings.restrictedLabels.indexOf(labelText) >= 0,
228
+ $label = labelText !== '' && (showLabel || settings.showLabelTicks === 'always')
229
+ ? ((!(i % module.get.gapRatio()) && i < ignoreLabels) || i === len
230
+ ? $('<li/>', { class: className.label, 'data-value': stepValue, html: showLabel ? labelText : '' })
231
+ : $('<li/>', { class: 'halftick label', 'data-value': stepValue }))
232
+ : null,
233
+ ratio = i / len
234
+ ;
235
+ if ($label) {
236
+ module.update.labelPosition(ratio, $label);
237
+ $labels.append($label);
238
+ }
239
+ }
240
+ },
241
+ },
242
+
243
+ bind: {
244
+ events: function () {
245
+ module.bind.globalKeyboardEvents();
246
+ module.bind.keyboardEvents();
247
+ module.bind.mouseEvents();
248
+ if (settings.autoAdjustLabels) {
249
+ module.bind.windowEvents();
250
+ }
251
+ },
252
+ keyboardEvents: function () {
253
+ module.verbose('Binding keyboard events');
254
+ $module.on('keydown' + eventNamespace, module.event.keydown);
255
+ },
256
+ globalKeyboardEvents: function () {
257
+ $document.on('keydown' + eventNamespace + documentEventID, module.event.activateFocus);
258
+ },
259
+ mouseEvents: function () {
260
+ module.verbose('Binding mouse and touch events');
261
+ $module.find('.track, .thumb, .inner').on('mousedown' + eventNamespace, function (event) {
262
+ event.stopImmediatePropagation();
263
+ event.preventDefault();
264
+ module.event.down(event);
265
+ });
266
+ $module.on('mousedown' + eventNamespace, module.event.down);
267
+ $module.on('mouseenter' + eventNamespace, function (event) {
268
+ isHover = true;
269
+ });
270
+ $module.on('mouseleave' + eventNamespace, function (event) {
271
+ isHover = false;
272
+ });
273
+ // All touch events are invoked on the element where the touch *started*. Thus, we can bind them all
274
+ // on the thumb(s) and don't need to worry about interference with other components, i.e. no dynamic binding
275
+ // and unbinding required.
276
+ $module.find('.thumb')
277
+ .on('touchstart' + eventNamespace, module.event.touchDown)
278
+ .on('touchmove' + eventNamespace, module.event.move)
279
+ .on('touchend' + eventNamespace, module.event.up)
280
+ .on('touchcancel' + eventNamespace, module.event.touchCancel)
281
+ ;
282
+ },
283
+ slidingEvents: function () {
284
+ // these don't need the identifier because we only ever want one of them to be registered with document
285
+ module.verbose('Binding page wide events while handle is being draged');
286
+ $document.on('mousemove' + eventNamespace, module.event.move);
287
+ $document.on('mouseup' + eventNamespace, module.event.up);
288
+ },
289
+ windowEvents: function () {
290
+ $window.on('resize' + eventNamespace, module.event.resize);
291
+ },
292
+ },
293
+
294
+ unbind: {
295
+ events: function () {
296
+ $module.find('.track, .thumb, .inner').off('mousedown' + eventNamespace);
297
+ $module.off('mousedown' + eventNamespace);
298
+ $module.off('mouseenter' + eventNamespace);
299
+ $module.off('mouseleave' + eventNamespace);
300
+ $module.find('.thumb')
301
+ .off('touchstart' + eventNamespace)
302
+ .off('touchmove' + eventNamespace)
303
+ .off('touchend' + eventNamespace)
304
+ .off('touchcancel' + eventNamespace)
305
+ ;
306
+ $module.off('keydown' + eventNamespace);
307
+ $module.off('focusout' + eventNamespace);
308
+ $document.off('keydown' + eventNamespace + documentEventID, module.event.activateFocus);
309
+ $window.off('resize' + eventNamespace);
310
+ },
311
+ slidingEvents: function () {
312
+ $document.off('mousemove' + eventNamespace);
313
+ $document.off('mouseup' + eventNamespace);
314
+ },
315
+ },
316
+
317
+ event: {
318
+ down: function (event) {
319
+ event.preventDefault();
320
+ if (module.is.range()) {
321
+ var
322
+ eventPos = module.determine.eventPos(event),
323
+ newPos = module.determine.pos(eventPos)
324
+ ;
325
+ // Special handling if range mode and both thumbs have the same value
326
+ if (settings.preventCrossover && module.is.range() && module.thumbVal === module.secondThumbVal) {
327
+ initialPosition = newPos;
328
+ $currThumb = undefined;
329
+ } else {
330
+ $currThumb = module.determine.closestThumb(newPos);
331
+ }
332
+ if (previousValue === undefined) {
333
+ previousValue = module.get.currentThumbValue();
334
+ }
335
+ } else if (previousValue === undefined) {
336
+ previousValue = module.get.value();
337
+ }
338
+
339
+ if (!module.is.disabled()) {
340
+ module.bind.slidingEvents();
341
+ }
342
+ },
343
+ touchDown: function (event) {
344
+ event.preventDefault(); // disable mouse emulation and touch-scrolling
345
+ event.stopImmediatePropagation();
346
+ if (touchIdentifier !== undefined) {
347
+ // ignore multiple touches on the same slider --
348
+ // we cannot handle changing both thumbs at once due to shared state
349
+ return;
350
+ }
351
+ $currThumb = $(event.target);
352
+ var touchEvent = event.touches ? event : event.originalEvent;
353
+ touchIdentifier = touchEvent.targetTouches[0].identifier;
354
+ if (previousValue === undefined) {
355
+ previousValue = module.get.currentThumbValue();
356
+ }
357
+ },
358
+ move: function (event) {
359
+ if (event.type === 'mousemove') {
360
+ event.preventDefault(); // prevent text selection etc.
361
+ }
362
+ if (module.is.disabled()) {
363
+ // touch events are always bound, so we need to prevent touch-sliding on disabled sliders here
364
+ return;
365
+ }
366
+ var value = module.determine.valueFromEvent(event);
367
+ if (event.type === 'mousemove' && $currThumb === undefined) {
368
+ var
369
+ eventPos = module.determine.eventPos(event),
370
+ newPos = module.determine.pos(eventPos)
371
+ ;
372
+ $currThumb = initialPosition > newPos ? $thumb : $secondThumb;
373
+ }
374
+ if (module.is.range() && (settings.minRange || settings.maxRange)) {
375
+ var currentRangeDiff = module.get.currentRangeDiff(value),
376
+ isSecondThumb = $currThumb.hasClass('second')
377
+ ;
378
+ if ((settings.minRange && currentRangeDiff < settings.minRange)
379
+ || (settings.maxRange && currentRangeDiff > settings.maxRange)
380
+ || (settings.preventCrossover && !isSecondThumb && value > module.secondThumbVal)
381
+ || (settings.preventCrossover && isSecondThumb && value < module.thumbVal)
382
+ ) {
383
+ return;
384
+ }
385
+ }
386
+ if (module.get.step() === 0 || module.is.smooth()) {
387
+ var
388
+ thumbVal = module.thumbVal,
389
+ secondThumbVal = module.secondThumbVal,
390
+ thumbSmoothVal = module.determine.smoothValueFromEvent(event)
391
+ ;
392
+ if (!$currThumb.hasClass('second')) {
393
+ if (settings.preventCrossover && module.is.range()) {
394
+ value = Math.min(secondThumbVal, value);
395
+ thumbSmoothVal = Math.min(secondThumbVal, thumbSmoothVal);
396
+ }
397
+ thumbVal = value;
398
+ } else {
399
+ if (settings.preventCrossover && module.is.range()) {
400
+ value = Math.max(thumbVal, value);
401
+ thumbSmoothVal = Math.max(thumbVal, thumbSmoothVal);
402
+ }
403
+ secondThumbVal = value;
404
+ }
405
+ value = Math.abs(thumbVal - (secondThumbVal || 0));
406
+ module.update.position(thumbSmoothVal);
407
+ settings.onMove.call(element, value, thumbVal, secondThumbVal);
408
+ } else {
409
+ module.update.value(value, function (value, thumbVal, secondThumbVal) {
410
+ settings.onMove.call(element, value, thumbVal, secondThumbVal);
411
+ });
412
+ }
413
+ },
414
+ up: function (event) {
415
+ event.preventDefault();
416
+ if (module.is.disabled()) {
417
+ // touch events are always bound, so we need to prevent touch-sliding on disabled sliders here
418
+ return;
419
+ }
420
+ var value = module.determine.valueFromEvent(event);
421
+ if (module.is.range() && (settings.minRange || settings.maxRange)) {
422
+ if ($currThumb === undefined) {
423
+ $currThumb = value <= module.get.currentThumbValue() ? $thumb : $secondThumb;
424
+ }
425
+ var currentRangeDiff = module.get.currentRangeDiff(value);
426
+ if (settings.minRange && currentRangeDiff < settings.minRange) {
427
+ value = module.get.edgeValue(value, settings.minRange);
428
+ } else if (settings.maxRange && currentRangeDiff > settings.maxRange) {
429
+ value = module.get.edgeValue(value, settings.maxRange);
430
+ }
431
+ }
432
+ module.set.value(value);
433
+ module.unbind.slidingEvents();
434
+ touchIdentifier = undefined;
435
+ if (previousValue !== undefined) {
436
+ previousValue = undefined;
437
+ }
438
+ },
439
+ touchCancel: function (event) {
440
+ event.preventDefault();
441
+ touchIdentifier = undefined;
442
+ if (previousValue !== undefined) {
443
+ module.update.value(previousValue);
444
+ previousValue = undefined;
445
+ }
446
+ },
447
+ keydown: function (event, first) {
448
+ if (module.is.disabled()) {
449
+ return;
450
+ }
451
+ if (settings.preventCrossover && module.is.range() && module.thumbVal === module.secondThumbVal) {
452
+ $currThumb = undefined;
453
+ }
454
+ if (module.is.focused()) {
455
+ $document.trigger(event);
456
+ }
457
+ if (first || module.is.focused()) {
458
+ var step = module.determine.keyMovement(event);
459
+ if (step !== NO_STEP) {
460
+ event.preventDefault();
461
+ switch (step) {
462
+ case SINGLE_STEP: {
463
+ module.takeStep();
464
+
465
+ break;
466
+ }
467
+ case BIG_STEP: {
468
+ module.takeStep(module.get.multiplier());
469
+
470
+ break;
471
+ }
472
+ case SINGLE_BACKSTEP: {
473
+ module.backStep();
474
+
475
+ break;
476
+ }
477
+ case BIG_BACKSTEP: {
478
+ module.backStep(module.get.multiplier());
479
+
480
+ break;
481
+ }
482
+ }
483
+ }
484
+ }
485
+ },
486
+ activateFocus: function (event) {
487
+ if (!module.is.disabled() && !module.is.focused() && module.is.hover() && module.determine.keyMovement(event) !== NO_STEP) {
488
+ event.preventDefault();
489
+ module.event.keydown(event, true);
490
+ $module.trigger('focus');
491
+ }
492
+ },
493
+ resize: function (_event) {
494
+ // To avoid a useless performance cost, we only call the label refresh when its necessary
495
+ if (gapRatio !== module.get.gapRatio()) {
496
+ module.resync();
497
+ gapRatio = module.get.gapRatio();
498
+ }
499
+ },
500
+ },
501
+
502
+ clear: {
503
+ cache: function () {
504
+ module.cache = {};
505
+ },
506
+ },
507
+
508
+ resync: function () {
509
+ module.verbose('Resyncing thumb position based on value');
510
+ module.setup.labels();
511
+ if (module.is.range()) {
512
+ module.update.position(module.secondThumbVal, $secondThumb);
513
+ }
514
+ module.update.position(module.thumbVal, $thumb);
515
+ },
516
+ takeStep: function (multiplier) {
517
+ if (!multiplier) {
518
+ multiplier = 1;
519
+ }
520
+ var
521
+ step = module.get.step(),
522
+ currValue = module.get.currentThumbValue()
523
+ ;
524
+ module.verbose('Taking a step');
525
+ if (step > 0) {
526
+ module.set.value(currValue + step * multiplier);
527
+ } else if (step === 0) {
528
+ var
529
+ precision = module.get.precision(),
530
+ newValue = currValue + (multiplier / precision)
531
+ ;
532
+ module.set.value(Math.round(newValue * precision) / precision);
533
+ }
534
+ },
535
+
536
+ backStep: function (multiplier) {
537
+ if (!multiplier) {
538
+ multiplier = 1;
539
+ }
540
+ var
541
+ step = module.get.step(),
542
+ currValue = module.get.currentThumbValue()
543
+ ;
544
+ module.verbose('Going back a step');
545
+ if (step > 0) {
546
+ module.set.value(currValue - step * multiplier);
547
+ } else if (step === 0) {
548
+ var
549
+ precision = module.get.precision(),
550
+ newValue = currValue - (multiplier / precision)
551
+ ;
552
+ module.set.value(Math.round(newValue * precision) / precision);
553
+ }
554
+ },
555
+
556
+ is: {
557
+ prime: function (n) {
558
+ if (module.cache['prime' + n] === undefined) {
559
+ var p = true;
560
+ for (var i = 2, s = Math.sqrt(n); i <= s; i++) {
561
+ if (n % i === 0) {
562
+ p = false;
563
+
564
+ break;
565
+ }
566
+ }
567
+ if (p) {
568
+ p = n > 1;
569
+ }
570
+
571
+ module.cache['prime' + n] = p;
572
+ }
573
+
574
+ return module.cache['prime' + n];
575
+ },
576
+ range: function () {
577
+ var isRange = $module.hasClass(className.range);
578
+ if (!isRange && (settings.minRange || settings.maxRange)) {
579
+ $module.addClass(className.range);
580
+ isRange = true;
581
+ }
582
+
583
+ return isRange;
584
+ },
585
+ hover: function () {
586
+ return isHover;
587
+ },
588
+ focused: function () {
589
+ return $module.is(':focus');
590
+ },
591
+ disabled: function () {
592
+ return $module.hasClass(className.disabled);
593
+ },
594
+ labeled: function () {
595
+ var isLabeled = $module.hasClass(className.labeled);
596
+ if (!isLabeled && (settings.restrictedLabels.length > 0 || settings.showLabelTicks !== false)) {
597
+ $module.addClass(className.labeled);
598
+ isLabeled = true;
599
+ }
600
+
601
+ return isLabeled;
602
+ },
603
+ reversed: function () {
604
+ return $module.hasClass(className.reversed);
605
+ },
606
+ vertical: function () {
607
+ return $module.hasClass(className.vertical);
608
+ },
609
+ smooth: function () {
610
+ return settings.smooth || $module.hasClass(className.smooth);
611
+ },
612
+ },
613
+
614
+ get: {
615
+ currentRangeDiff: function (value) {
616
+ var currentRangeDiff;
617
+ if ($currThumb.hasClass('second')) {
618
+ currentRangeDiff = module.thumbVal < value
619
+ ? value - module.thumbVal
620
+ : module.thumbVal - value;
621
+ } else {
622
+ currentRangeDiff = module.secondThumbVal > value
623
+ ? module.secondThumbVal - value
624
+ : value - module.secondThumbVal;
625
+ }
626
+
627
+ return currentRangeDiff;
628
+ },
629
+ edgeValue: function (value, edgeValue) {
630
+ if ($currThumb.hasClass('second')) {
631
+ value = module.thumbVal < value
632
+ ? module.thumbVal + edgeValue
633
+ : module.thumbVal - edgeValue;
634
+ } else {
635
+ value = module.secondThumbVal < value
636
+ ? module.secondThumbVal + edgeValue
637
+ : module.secondThumbVal - edgeValue;
638
+ }
639
+
640
+ return value;
641
+ },
642
+ trackOffset: function () {
643
+ if (module.is.vertical()) {
644
+ return $track.offset().top;
645
+ }
646
+
647
+ return $track.offset().left;
648
+ },
649
+ trackLength: function () {
650
+ if (module.is.vertical()) {
651
+ return $track.height();
652
+ }
653
+
654
+ return $track.width();
655
+ },
656
+ trackLeft: function () {
657
+ if (module.is.vertical()) {
658
+ return $track.position().top;
659
+ }
660
+
661
+ return $track.position().left;
662
+ },
663
+ trackStartPos: function () {
664
+ return module.is.reversed() ? module.get.trackLeft() + module.get.trackLength() : module.get.trackLeft();
665
+ },
666
+ trackEndPos: function () {
667
+ return module.is.reversed() ? module.get.trackLeft() : module.get.trackLeft() + module.get.trackLength();
668
+ },
669
+ trackStartMargin: function () {
670
+ var margin;
671
+ if (module.is.vertical()) {
672
+ margin = module.is.reversed() ? $module.css('padding-bottom') : $module.css('padding-top');
673
+ } else {
674
+ margin = module.is.reversed() ? $module.css('padding-right') : $module.css('padding-left');
675
+ }
676
+
677
+ return margin || '0px';
678
+ },
679
+ trackEndMargin: function () {
680
+ var margin;
681
+ if (module.is.vertical()) {
682
+ margin = module.is.reversed() ? $module.css('padding-top') : $module.css('padding-bottom');
683
+ } else {
684
+ margin = module.is.reversed() ? $module.css('padding-left') : $module.css('padding-right');
685
+ }
686
+
687
+ return margin || '0px';
688
+ },
689
+ precision: function () {
690
+ if (module.cache.precision === undefined) {
691
+ var
692
+ decimalPlaces,
693
+ step = module.get.step()
694
+ ;
695
+ if (step !== 0) {
696
+ var split = String(step).split('.');
697
+ decimalPlaces = split.length === 2 ? split[1].length : 0;
698
+ } else {
699
+ decimalPlaces = settings.decimalPlaces;
700
+ }
701
+ var precision = Math.pow(10, decimalPlaces);
702
+ module.debug('Precision determined', precision);
703
+ module.cache.precision = precision;
704
+ }
705
+
706
+ return module.cache.precision;
707
+ },
708
+ min: function () {
709
+ return settings.min;
710
+ },
711
+ max: function () {
712
+ if (module.cache.max === undefined) {
713
+ var
714
+ step = module.get.step(),
715
+ min = module.get.min(),
716
+ precision = module.get.precision(),
717
+ quotient = step === 0 ? 0 : Math.floor(Math.round(((settings.max - min) / step) * precision) / precision),
718
+ remainder = step === 0 ? 0 : (settings.max - min) % step
719
+ ;
720
+ if (remainder > 0) {
721
+ module.debug('Max value not divisible by given step. Increasing max value.', settings.max, step);
722
+ }
723
+ module.cache.max = remainder === 0 ? settings.max : min + quotient * step;
724
+ }
725
+
726
+ return module.cache.max;
727
+ },
728
+ step: function () {
729
+ return settings.step;
730
+ },
731
+ numLabels: function () {
732
+ if (module.cache.numLabels === undefined) {
733
+ var step = module.get.step(),
734
+ precision = module.get.precision(),
735
+ value = Math.round(((module.get.max() - module.get.min()) / (step === 0 ? 1 : step)) * precision) / precision;
736
+ module.debug('Determined that there should be ' + value + ' labels');
737
+ module.cache.numLabels = value;
738
+ }
739
+
740
+ return module.cache.numLabels;
741
+ },
742
+ labelType: function () {
743
+ return settings.labelType;
744
+ },
745
+ label: function (value, stepValue) {
746
+ if (isFunction(interpretLabel)) {
747
+ return interpretLabel(value, stepValue, module);
748
+ }
749
+
750
+ switch (settings.labelType) {
751
+ case settings.labelTypes.number: {
752
+ return stepValue;
753
+ }
754
+ case settings.labelTypes.letter: {
755
+ if (value < 0 || module.get.precision() > 1) {
756
+ module.error(error.invalidLetterNumber, value);
757
+
758
+ return value;
759
+ }
760
+ var letterLabel = '',
761
+ letters = Array.isArray(settings.letters) ? settings.letters : String(settings.letters).split(''),
762
+ lettersLen = letters.length
763
+ ;
764
+
765
+ while (stepValue >= 0) {
766
+ letterLabel = letters[stepValue % lettersLen] + letterLabel;
767
+ stepValue = Math.floor(stepValue / lettersLen) - 1;
768
+ }
769
+
770
+ return letterLabel;
771
+ }
772
+ default: {
773
+ return value;
774
+ }
775
+ }
776
+ },
777
+ value: function () {
778
+ return value;
779
+ },
780
+ settings: function () {
781
+ return settings;
782
+ },
783
+ currentThumbValue: function () {
784
+ return $currThumb !== undefined && $currThumb.hasClass('second') ? module.secondThumbVal : module.thumbVal;
785
+ },
786
+ thumbValue: function (which) {
787
+ switch (which) {
788
+ case 'second': {
789
+ if (module.is.range()) {
790
+ return module.secondThumbVal;
791
+ }
792
+
793
+ module.error(error.notrange);
794
+
795
+ break;
796
+ }
797
+ default: {
798
+ return module.thumbVal;
799
+ }
800
+ }
801
+ },
802
+ multiplier: function () {
803
+ return settings.pageMultiplier;
804
+ },
805
+ thumbPosition: function (which) {
806
+ switch (which) {
807
+ case 'second': {
808
+ if (module.is.range()) {
809
+ return secondPos;
810
+ }
811
+
812
+ module.error(error.notrange);
813
+
814
+ break;
815
+ }
816
+ default: {
817
+ return position;
818
+ }
819
+ }
820
+ },
821
+ gapRatio: function () {
822
+ var gapRatio = 1;
823
+
824
+ if (settings.autoAdjustLabels) {
825
+ var
826
+ numLabels = module.get.numLabels(),
827
+ primePlus = module.is.prime(numLabels) ? 1 : 0,
828
+ trackLength = module.get.trackLength(),
829
+ gapCounter = 1
830
+ ;
831
+
832
+ // While the distance between two labels is too short,
833
+ // we divide the number of labels at each iteration
834
+ // and apply only if the modulo of the operation is an odd number.
835
+ if (trackLength > 0) {
836
+ while ((trackLength / numLabels) * gapCounter < settings.labelDistance) {
837
+ if (!((numLabels + primePlus) % gapCounter) || settings.autoAdjustLabels === 'fixed') {
838
+ gapRatio = gapCounter;
839
+ }
840
+ gapCounter += 1;
841
+ }
842
+ }
843
+ }
844
+
845
+ return gapRatio;
846
+ },
847
+ },
848
+
849
+ determine: {
850
+ pos: function (pagePos) {
851
+ return module.is.reversed()
852
+ ? module.get.trackStartPos() - pagePos + module.get.trackOffset()
853
+ : pagePos - module.get.trackOffset() - module.get.trackStartPos();
854
+ },
855
+ closestThumb: function (eventPos) {
856
+ var
857
+ thumbPos = parseFloat(module.determine.thumbPos($thumb)),
858
+ thumbDelta = Math.abs(eventPos - thumbPos),
859
+ secondThumbPos = parseFloat(module.determine.thumbPos($secondThumb)),
860
+ secondThumbDelta = Math.abs(eventPos - secondThumbPos)
861
+ ;
862
+ if (thumbDelta === secondThumbDelta && module.get.thumbValue() === module.get.min()) {
863
+ return $secondThumb;
864
+ }
865
+
866
+ return thumbDelta <= secondThumbDelta ? $thumb : $secondThumb;
867
+ },
868
+ closestThumbPos: function (eventPos) {
869
+ var
870
+ thumbPos = parseFloat(module.determine.thumbPos($thumb)),
871
+ thumbDelta = Math.abs(eventPos - thumbPos),
872
+ secondThumbPos = parseFloat(module.determine.thumbPos($secondThumb)),
873
+ secondThumbDelta = Math.abs(eventPos - secondThumbPos)
874
+ ;
875
+
876
+ return thumbDelta <= secondThumbDelta ? thumbPos : secondThumbPos;
877
+ },
878
+ thumbPos: function ($element) {
879
+ return module.is.vertical()
880
+ ? (module.is.reversed() ? $element.css('bottom') : $element.css('top'))
881
+ : (module.is.reversed() ? $element.css('right') : $element.css('left'))
882
+ ;
883
+ },
884
+ positionFromValue: function (val) {
885
+ var
886
+ min = module.get.min(),
887
+ max = module.get.max(),
888
+ value = val > max
889
+ ? max
890
+ : (val < min ? min : val),
891
+ trackLength = module.get.trackLength(),
892
+ ratio = (value - min) / (max - min),
893
+ position = Math.round(ratio * trackLength)
894
+ ;
895
+ module.verbose('Determined position: ' + position + ' from value: ' + value);
896
+
897
+ return position;
898
+ },
899
+ positionFromRatio: function (ratio) {
900
+ var
901
+ trackLength = module.get.trackLength(),
902
+ step = module.get.step(),
903
+ position = Math.round(ratio * trackLength),
904
+ adjustedPos = step === 0 ? position : Math.round(position / step) * step
905
+ ;
906
+ module.verbose('Determined position: ' + position + ' from ratio: ' + ratio);
907
+
908
+ return adjustedPos;
909
+ },
910
+ valueFromEvent: function (event) {
911
+ var
912
+ eventPos = module.determine.eventPos(event),
913
+ newPos = module.determine.pos(eventPos),
914
+ value
915
+ ;
916
+ if (eventPos < module.get.trackOffset()) {
917
+ value = module.is.reversed() ? module.get.max() : module.get.min();
918
+ } else if (eventPos > module.get.trackOffset() + module.get.trackLength()) {
919
+ value = module.is.reversed() ? module.get.min() : module.get.max();
920
+ } else {
921
+ value = module.determine.value(newPos);
922
+ }
923
+
924
+ return value;
925
+ },
926
+ smoothValueFromEvent: function (event) {
927
+ var
928
+ min = module.get.min(),
929
+ max = module.get.max(),
930
+ trackLength = module.get.trackLength(),
931
+ eventPos = module.determine.eventPos(event),
932
+ newPos = eventPos - module.get.trackOffset(),
933
+ ratio,
934
+ value
935
+ ;
936
+ newPos = newPos < 0
937
+ ? 0
938
+ : (newPos > trackLength ? trackLength : newPos);
939
+ ratio = newPos / trackLength;
940
+ if (module.is.reversed()) {
941
+ ratio = 1 - ratio;
942
+ }
943
+ value = ratio * (max - min) + min;
944
+
945
+ return value;
946
+ },
947
+ eventPos: function (event) {
948
+ if (event.type === 'touchmove' || event.type === 'touchend') {
949
+ var
950
+ touchEvent = event.touches ? event : event.originalEvent,
951
+ touch = touchEvent.changedTouches[0]; // fall back to first touch if correct touch not found
952
+ for (var i = 0; i < touchEvent.touches.length; i++) {
953
+ if (touchEvent.touches[i].identifier === touchIdentifier) {
954
+ touch = touchEvent.touches[i];
955
+
956
+ break;
957
+ }
958
+ }
959
+ var
960
+ touchY = touch.pageY,
961
+ touchX = touch.pageX
962
+ ;
963
+
964
+ return module.is.vertical() ? touchY : touchX;
965
+ }
966
+ var
967
+ clickY = event.pageY || event.originalEvent.pageY,
968
+ clickX = event.pageX || event.originalEvent.pageX
969
+ ;
970
+
971
+ return module.is.vertical() ? clickY : clickX;
972
+ },
973
+ value: function (position) {
974
+ var
975
+ precision = module.get.precision(),
976
+ startPos = module.is.reversed() ? module.get.trackEndPos() : module.get.trackStartPos(),
977
+ endPos = module.is.reversed() ? module.get.trackStartPos() : module.get.trackEndPos(),
978
+ ratio = (position - startPos) / (endPos - startPos),
979
+ range = module.get.max() - module.get.min(),
980
+ step = module.get.step(),
981
+ value = ratio * range,
982
+ difference = step === 0 ? value : Math.round(value / step) * step
983
+ ;
984
+ module.verbose('Determined value based upon position: ' + position + ' as: ' + value);
985
+ if (value !== difference) {
986
+ module.verbose('Rounding value to closest step: ' + difference);
987
+ }
988
+ // Use precision to avoid ugly Javascript floating point rounding issues
989
+ // (like 35 * .01 = 0.35000000000000003)
990
+ module.verbose('Cutting off additional decimal places');
991
+
992
+ return Math.round((difference + module.get.min()) * precision) / precision;
993
+ },
994
+ keyMovement: function (event) {
995
+ var
996
+ key = event.which,
997
+ downArrow = module.is.vertical()
998
+ ? (module.is.reversed() ? keys.downArrow : keys.upArrow)
999
+ : keys.downArrow,
1000
+ upArrow = module.is.vertical()
1001
+ ? (module.is.reversed() ? keys.upArrow : keys.downArrow)
1002
+ : keys.upArrow,
1003
+ leftArrow = !module.is.vertical()
1004
+ ? (module.is.reversed() ? keys.rightArrow : keys.leftArrow)
1005
+ : keys.leftArrow,
1006
+ rightArrow = !module.is.vertical()
1007
+ ? (module.is.reversed() ? keys.leftArrow : keys.rightArrow)
1008
+ : keys.rightArrow
1009
+ ;
1010
+ if (key === downArrow || key === leftArrow) {
1011
+ return SINGLE_BACKSTEP;
1012
+ }
1013
+ if (key === upArrow || key === rightArrow) {
1014
+ return SINGLE_STEP;
1015
+ }
1016
+ if (key === keys.pageDown) {
1017
+ return BIG_BACKSTEP;
1018
+ }
1019
+ if (key === keys.pageUp) {
1020
+ return BIG_STEP;
1021
+ }
1022
+
1023
+ return NO_STEP;
1024
+ },
1025
+ },
1026
+
1027
+ handleNewValuePosition: function (val) {
1028
+ var
1029
+ min = module.get.min(),
1030
+ max = module.get.max(),
1031
+ newPos
1032
+ ;
1033
+ if (val <= min) {
1034
+ val = min;
1035
+ } else if (val >= max) {
1036
+ val = max;
1037
+ }
1038
+ newPos = module.determine.positionFromValue(val);
1039
+
1040
+ return newPos;
1041
+ },
1042
+
1043
+ set: {
1044
+ active: function (thumbVal, secondThumbVal) {
1045
+ if (settings.highlightRange) {
1046
+ if (secondThumbVal < thumbVal) {
1047
+ var tempVal = secondThumbVal;
1048
+ secondThumbVal = thumbVal;
1049
+ thumbVal = tempVal;
1050
+ }
1051
+ var $children = $labels.find('.label');
1052
+ $children.each(function (index) {
1053
+ var
1054
+ $child = $(this),
1055
+ attrValue = $child.attr('data-value')
1056
+ ;
1057
+ if (attrValue) {
1058
+ attrValue = parseInt(attrValue, 10);
1059
+ if (attrValue >= thumbVal && attrValue <= secondThumbVal) {
1060
+ $child.addClass(className.active);
1061
+ } else {
1062
+ $child.removeClass(className.active);
1063
+ }
1064
+ }
1065
+ });
1066
+ }
1067
+ },
1068
+ value: function (newValue, fireChange) {
1069
+ fireChange = fireChange !== false;
1070
+ var toReset = previousValue === undefined;
1071
+ previousValue = previousValue === undefined ? module.get.value() : previousValue;
1072
+ module.update.value(newValue, function (value, thumbVal, secondThumbVal) {
1073
+ if ((!initialLoad || settings.fireOnInit) && fireChange) {
1074
+ if (newValue !== previousValue) {
1075
+ settings.onChange.call(element, value, thumbVal, secondThumbVal);
1076
+ }
1077
+ settings.onMove.call(element, value, thumbVal, secondThumbVal);
1078
+ }
1079
+ if (toReset) {
1080
+ previousValue = undefined;
1081
+ }
1082
+ });
1083
+ },
1084
+ rangeValue: function (first, second, fireChange) {
1085
+ fireChange = fireChange !== false;
1086
+ if (module.is.range()) {
1087
+ var
1088
+ min = module.get.min(),
1089
+ max = module.get.max(),
1090
+ toReset = previousValue === undefined
1091
+ ;
1092
+ previousValue = previousValue === undefined ? module.get.value() : previousValue;
1093
+ if (first <= min) {
1094
+ first = min;
1095
+ } else if (first >= max) {
1096
+ first = max;
1097
+ }
1098
+ if (second <= min) {
1099
+ second = min;
1100
+ } else if (second >= max) {
1101
+ second = max;
1102
+ }
1103
+ module.thumbVal = first;
1104
+ module.secondThumbVal = second;
1105
+ value = Math.abs(module.thumbVal - module.secondThumbVal);
1106
+ module.update.position(module.thumbVal, $thumb);
1107
+ module.update.position(module.secondThumbVal, $secondThumb);
1108
+ if ((!initialLoad || settings.fireOnInit) && fireChange) {
1109
+ if (value !== previousValue) {
1110
+ settings.onChange.call(element, value, module.thumbVal, module.secondThumbVal);
1111
+ }
1112
+ settings.onMove.call(element, value, module.thumbVal, module.secondThumbVal);
1113
+ }
1114
+ if (toReset) {
1115
+ previousValue = undefined;
1116
+ }
1117
+ } else {
1118
+ module.error(error.notrange);
1119
+ }
1120
+ },
1121
+ position: function (position, which) {
1122
+ var thumbVal = module.determine.value(position);
1123
+ if (which === 'second') {
1124
+ module.secondThumbVal = thumbVal;
1125
+ module.update.position(thumbVal, $secondThumb);
1126
+ } else {
1127
+ module.thumbVal = thumbVal;
1128
+ module.update.position(thumbVal, $thumb);
1129
+ }
1130
+ value = Math.abs(module.thumbVal - (module.secondThumbVal || 0));
1131
+ module.set.value(value);
1132
+ },
1133
+ },
1134
+
1135
+ update: {
1136
+ value: function (newValue, callback) {
1137
+ var
1138
+ min = module.get.min(),
1139
+ max = module.get.max()
1140
+ ;
1141
+ if (newValue <= min) {
1142
+ newValue = min;
1143
+ } else if (newValue >= max) {
1144
+ newValue = max;
1145
+ }
1146
+ if (!module.is.range()) {
1147
+ value = newValue;
1148
+ module.thumbVal = value;
1149
+ } else {
1150
+ if ($currThumb === undefined) {
1151
+ $currThumb = newValue <= module.get.currentThumbValue() ? $thumb : $secondThumb;
1152
+ }
1153
+ if (!$currThumb.hasClass('second')) {
1154
+ if (settings.preventCrossover && module.is.range()) {
1155
+ newValue = Math.min(module.secondThumbVal - (settings.minRange || 0), newValue);
1156
+ }
1157
+ module.thumbVal = newValue;
1158
+ } else {
1159
+ if (settings.preventCrossover && module.is.range()) {
1160
+ newValue = Math.max(module.thumbVal + (settings.minRange || 0), newValue);
1161
+ }
1162
+ module.secondThumbVal = newValue;
1163
+ }
1164
+ value = Math.abs(module.thumbVal - module.secondThumbVal);
1165
+ }
1166
+ module.update.position(newValue);
1167
+ module.debug('Setting slider value to ' + value);
1168
+ if (typeof callback === 'function') {
1169
+ callback(value, module.thumbVal, module.secondThumbVal);
1170
+ }
1171
+ },
1172
+ position: function (newValue, $element) {
1173
+ var
1174
+ newPos = module.handleNewValuePosition(newValue),
1175
+ $targetThumb = $element || $currThumb,
1176
+ thumbVal = module.thumbVal || module.get.min(),
1177
+ secondThumbVal = module.secondThumbVal || module.get.min()
1178
+ ;
1179
+ if (settings.showThumbTooltip) {
1180
+ var precision = module.get.precision();
1181
+ $targetThumb.attr('data-tooltip', Math.round(newValue * precision) / precision);
1182
+ }
1183
+ if (module.is.range()) {
1184
+ if (!$targetThumb.hasClass('second')) {
1185
+ position = newPos;
1186
+ thumbVal = newValue;
1187
+ } else {
1188
+ secondPos = newPos;
1189
+ secondThumbVal = newValue;
1190
+ }
1191
+ } else {
1192
+ position = newPos;
1193
+ thumbVal = newValue;
1194
+ }
1195
+ module.set.active(thumbVal, secondThumbVal);
1196
+ var
1197
+ trackPosValue,
1198
+ thumbPosValue,
1199
+ min = module.get.min(),
1200
+ max = module.get.max(),
1201
+ thumbPosPercent = 100 * ((newValue - min) / (max - min)),
1202
+ trackStartPosPercent = 100 * ((Math.min(thumbVal, secondThumbVal) - min) / (max - min)),
1203
+ trackEndPosPercent = 100 * (1 - (Math.max(thumbVal, secondThumbVal) - min) / (max - min))
1204
+ ;
1205
+ if (module.is.vertical()) {
1206
+ if (module.is.reversed()) {
1207
+ thumbPosValue = { bottom: 'calc(' + thumbPosPercent + '% - ' + offset + 'px)', top: 'auto' };
1208
+ trackPosValue = { bottom: trackStartPosPercent + '%', top: trackEndPosPercent + '%' };
1209
+ } else {
1210
+ thumbPosValue = { top: 'calc(' + thumbPosPercent + '% - ' + offset + 'px)', bottom: 'auto' };
1211
+ trackPosValue = { top: trackStartPosPercent + '%', bottom: trackEndPosPercent + '%' };
1212
+ }
1213
+ } else {
1214
+ if (module.is.reversed()) {
1215
+ thumbPosValue = { right: 'calc(' + thumbPosPercent + '% - ' + offset + 'px)', left: 'auto' };
1216
+ trackPosValue = { right: trackStartPosPercent + '%', left: trackEndPosPercent + '%' };
1217
+ } else {
1218
+ thumbPosValue = { left: 'calc(' + thumbPosPercent + '% - ' + offset + 'px)', right: 'auto' };
1219
+ trackPosValue = { left: trackStartPosPercent + '%', right: trackEndPosPercent + '%' };
1220
+ }
1221
+ }
1222
+ $targetThumb.css(thumbPosValue);
1223
+ $trackFill.css(trackPosValue);
1224
+ module.debug('Setting slider position to ' + newPos);
1225
+ },
1226
+ labelPosition: function (ratio, $label) {
1227
+ var
1228
+ startMargin = module.get.trackStartMargin(),
1229
+ endMargin = module.get.trackEndMargin(),
1230
+ posDir = module.is.vertical()
1231
+ ? (module.is.reversed() ? 'bottom' : 'top')
1232
+ : (module.is.reversed() ? 'right' : 'left'),
1233
+ startMarginMod = module.is.reversed() && !module.is.vertical()
1234
+ ? ' - '
1235
+ : ' + '
1236
+ ;
1237
+ var position = '(100% - ' + startMargin + ' - ' + endMargin + ') * ' + ratio;
1238
+ $label.css(posDir, 'calc(' + position + startMarginMod + startMargin + ')');
1239
+ },
1240
+ },
1241
+
1242
+ goto: {
1243
+ max: function () {
1244
+ module.set.value(module.get.max());
1245
+ },
1246
+ min: function () {
1247
+ module.set.value(module.get.min());
1248
+ },
1249
+ },
1250
+
1251
+ read: {
1252
+ metadata: function () {
1253
+ var
1254
+ data = {
1255
+ thumbVal: $module.data(metadata.thumbVal),
1256
+ secondThumbVal: $module.data(metadata.secondThumbVal),
1257
+ }
1258
+ ;
1259
+ if (data.thumbVal) {
1260
+ if (module.is.range() && data.secondThumbVal) {
1261
+ module.debug('Current value set from metadata', data.thumbVal, data.secondThumbVal);
1262
+ module.set.rangeValue(data.thumbVal, data.secondThumbVal);
1263
+ } else {
1264
+ module.debug('Current value set from metadata', data.thumbVal);
1265
+ module.set.value(data.thumbVal);
1266
+ }
1267
+ }
1268
+ },
1269
+ settings: function () {
1270
+ if (settings.start !== false) {
1271
+ if (module.is.range()) {
1272
+ var rangeDiff = settings.end - settings.start;
1273
+ if (rangeDiff < 0
1274
+ || (settings.minRange && rangeDiff < settings.minRange)
1275
+ || (settings.maxRange && rangeDiff > settings.maxRange)
1276
+ || (settings.minRange && settings.maxRange && settings.minRange > settings.maxRange)
1277
+ ) {
1278
+ module.error(error.invalidRanges, settings.start, settings.end, settings.minRange, settings.maxRange);
1279
+ }
1280
+ module.debug('Start position set from settings', settings.start, settings.end);
1281
+ module.set.rangeValue(settings.start, settings.end);
1282
+ } else {
1283
+ module.debug('Start position set from settings', settings.start);
1284
+ module.set.value(settings.start);
1285
+ }
1286
+ }
1287
+ },
1288
+ },
1289
+
1290
+ setting: function (name, value) {
1291
+ module.debug('Changing setting', name, value);
1292
+ if ($.isPlainObject(name)) {
1293
+ $.extend(true, settings, name);
1294
+ } else if (value !== undefined) {
1295
+ if ($.isPlainObject(settings[name])) {
1296
+ $.extend(true, settings[name], value);
1297
+ } else {
1298
+ settings[name] = value;
1299
+ }
1300
+ } else {
1301
+ return settings[name];
1302
+ }
1303
+ module.clear.cache();
1304
+ },
1305
+ internal: function (name, value) {
1306
+ if ($.isPlainObject(name)) {
1307
+ $.extend(true, module, name);
1308
+ } else if (value !== undefined) {
1309
+ module[name] = value;
1310
+ } else {
1311
+ return module[name];
1312
+ }
1313
+ },
1314
+ debug: function () {
1315
+ if (!settings.silent && settings.debug) {
1316
+ if (settings.performance) {
1317
+ module.performance.log(arguments);
1318
+ } else {
1319
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1320
+ module.debug.apply(console, arguments);
1321
+ }
1322
+ }
1323
+ },
1324
+ verbose: function () {
1325
+ if (!settings.silent && settings.verbose && settings.debug) {
1326
+ if (settings.performance) {
1327
+ module.performance.log(arguments);
1328
+ } else {
1329
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1330
+ module.verbose.apply(console, arguments);
1331
+ }
1332
+ }
1333
+ },
1334
+ error: function () {
1335
+ if (!settings.silent) {
1336
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1337
+ module.error.apply(console, arguments);
1338
+ }
1339
+ },
1340
+
1341
+ performance: {
1342
+ log: function (message) {
1343
+ var
1344
+ currentTime,
1345
+ executionTime,
1346
+ previousTime
1347
+ ;
1348
+ if (settings.performance) {
1349
+ currentTime = Date.now();
1350
+ previousTime = time || currentTime;
1351
+ executionTime = currentTime - previousTime;
1352
+ time = currentTime;
1353
+ performance.push({
1354
+ Name: message[0],
1355
+ Arguments: [].slice.call(message, 1) || '',
1356
+ Element: element,
1357
+ 'Execution Time': executionTime,
1358
+ });
1359
+ }
1360
+ clearTimeout(module.performance.timer);
1361
+ module.performance.timer = setTimeout(function () {
1362
+ module.performance.display();
1363
+ }, 500);
1364
+ },
1365
+ display: function () {
1366
+ var
1367
+ title = settings.name + ':',
1368
+ totalTime = 0
1369
+ ;
1370
+ time = false;
1371
+ clearTimeout(module.performance.timer);
1372
+ $.each(performance, function (index, data) {
1373
+ totalTime += data['Execution Time'];
1374
+ });
1375
+ title += ' ' + totalTime + 'ms';
1376
+ if (performance.length > 0) {
1377
+ console.groupCollapsed(title);
1378
+ if (console.table) {
1379
+ console.table(performance);
1380
+ } else {
1381
+ $.each(performance, function (index, data) {
1382
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
1383
+ });
1384
+ }
1385
+ console.groupEnd();
1386
+ }
1387
+ performance = [];
1388
+ },
1389
+ },
1390
+
1391
+ invoke: function (query, passedArguments, context) {
1392
+ var
1393
+ object = instance,
1394
+ maxDepth,
1395
+ found,
1396
+ response
1397
+ ;
1398
+ passedArguments = passedArguments || queryArguments;
1399
+ context = context || element;
1400
+ if (typeof query === 'string' && object !== undefined) {
1401
+ query = query.split(/[ .]/);
1402
+ maxDepth = query.length - 1;
1403
+ $.each(query, function (depth, value) {
1404
+ var camelCaseValue = depth !== maxDepth
1405
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1406
+ : query
1407
+ ;
1408
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
1409
+ object = object[camelCaseValue];
1410
+ } else if (object[camelCaseValue] !== undefined) {
1411
+ found = object[camelCaseValue];
1412
+
1413
+ return false;
1414
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
1415
+ object = object[value];
1416
+ } else if (object[value] !== undefined) {
1417
+ found = object[value];
1418
+
1419
+ return false;
1420
+ } else {
1421
+ module.error(error.method, query);
1422
+
1423
+ return false;
1424
+ }
1425
+ });
1426
+ }
1427
+ if (isFunction(found)) {
1428
+ response = found.apply(context, passedArguments);
1429
+ } else if (found !== undefined) {
1430
+ response = found;
1431
+ }
1432
+ if (Array.isArray(returnedValue)) {
1433
+ returnedValue.push(response);
1434
+ } else if (returnedValue !== undefined) {
1435
+ returnedValue = [returnedValue, response];
1436
+ } else if (response !== undefined) {
1437
+ returnedValue = response;
1438
+ }
1439
+
1440
+ return found;
1441
+ },
1442
+ };
1443
+
1444
+ if (methodInvoked) {
1445
+ if (instance === undefined) {
1446
+ module.initialize();
1447
+ }
1448
+ module.invoke(query);
1449
+ } else {
1450
+ if (instance !== undefined) {
1451
+ instance.invoke('destroy');
1452
+ }
1453
+ module.initialize();
1454
+ }
1455
+ });
1456
+
1457
+ return returnedValue !== undefined
1458
+ ? returnedValue
1459
+ : this;
1460
+ };
1461
+
1462
+ $.fn.slider.settings = {
1463
+
1464
+ silent: false,
1465
+ debug: false,
1466
+ verbose: false,
1467
+ performance: true,
1468
+
1469
+ name: 'Slider',
1470
+ namespace: 'slider',
1471
+
1472
+ error: {
1473
+ method: 'The method you called is not defined.',
1474
+ notrange: 'This slider is not a range slider',
1475
+ invalidRanges: 'Invalid range settings (start/end/minRange/maxRange)',
1476
+ invalidLetterNumber: 'Negative values or decimal places for labelType: "letter" are not supported',
1477
+ },
1478
+
1479
+ metadata: {
1480
+ thumbVal: 'thumbVal',
1481
+ secondThumbVal: 'secondThumbVal',
1482
+ },
1483
+
1484
+ min: 0,
1485
+ max: 20,
1486
+ step: 1,
1487
+ start: 0,
1488
+ end: 20,
1489
+ minRange: false,
1490
+ maxRange: false,
1491
+ labelType: 'number',
1492
+ showLabelTicks: false,
1493
+ smooth: false,
1494
+ autoAdjustLabels: true,
1495
+ labelDistance: 100,
1496
+ preventCrossover: true,
1497
+ fireOnInit: false,
1498
+ interpretLabel: false,
1499
+ letters: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1500
+
1501
+ // the decimal place to round to if step is undefined
1502
+ decimalPlaces: 2,
1503
+
1504
+ // page up/down multiplier. How many more times the steps to take on page up/down press
1505
+ pageMultiplier: 2,
1506
+
1507
+ selector: {},
1508
+
1509
+ className: {
1510
+ reversed: 'reversed',
1511
+ disabled: 'disabled',
1512
+ labeled: 'labeled',
1513
+ ticked: 'ticked',
1514
+ vertical: 'vertical',
1515
+ range: 'range',
1516
+ smooth: 'smooth',
1517
+ label: 'label',
1518
+ active: 'active',
1519
+ },
1520
+
1521
+ keys: {
1522
+ pageUp: 33,
1523
+ pageDown: 34,
1524
+ leftArrow: 37,
1525
+ upArrow: 38,
1526
+ rightArrow: 39,
1527
+ downArrow: 40,
1528
+ },
1529
+
1530
+ restrictedLabels: [],
1531
+ highlightRange: false,
1532
+ showThumbTooltip: false,
1533
+ tooltipConfig: {
1534
+ position: 'top center',
1535
+ variation: 'tiny black',
1536
+ },
1537
+
1538
+ labelTypes: {
1539
+ number: 'number',
1540
+ letter: 'letter',
1541
+ },
1542
+
1543
+ onChange: function (value, thumbVal, secondThumbVal) {},
1544
+ onMove: function (value, thumbVal, secondThumbVal) {},
1545
+ };
1546
+ })(jQuery, window, document);