@ntlab/ntjs-assets 2.0.2 → 2.0.3

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