fomantic-ui 2.9.1-beta.16 → 2.9.1-beta.18

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 (252) hide show
  1. package/.eslintrc.js +109 -0
  2. package/.github/workflows/ci.yml +13 -3
  3. package/dist/components/accordion.css +1 -1
  4. package/dist/components/accordion.js +571 -598
  5. package/dist/components/accordion.min.css +1 -1
  6. package/dist/components/accordion.min.js +1 -1
  7. package/dist/components/ad.css +1 -1
  8. package/dist/components/ad.min.css +1 -1
  9. package/dist/components/api.js +1164 -1186
  10. package/dist/components/api.min.js +1 -1
  11. package/dist/components/breadcrumb.css +1 -1
  12. package/dist/components/breadcrumb.min.css +1 -1
  13. package/dist/components/button.css +1 -1
  14. package/dist/components/button.min.css +1 -1
  15. package/dist/components/calendar.css +1 -1
  16. package/dist/components/calendar.js +1897 -1818
  17. package/dist/components/calendar.min.css +1 -1
  18. package/dist/components/calendar.min.js +1 -1
  19. package/dist/components/card.css +1 -1
  20. package/dist/components/card.min.css +1 -1
  21. package/dist/components/checkbox.css +1 -1
  22. package/dist/components/checkbox.js +844 -841
  23. package/dist/components/checkbox.min.css +1 -1
  24. package/dist/components/checkbox.min.js +1 -1
  25. package/dist/components/comment.css +1 -1
  26. package/dist/components/comment.min.css +1 -1
  27. package/dist/components/container.css +3 -1
  28. package/dist/components/container.min.css +2 -2
  29. package/dist/components/dimmer.css +1 -1
  30. package/dist/components/dimmer.js +710 -737
  31. package/dist/components/dimmer.min.css +1 -1
  32. package/dist/components/dimmer.min.js +1 -1
  33. package/dist/components/divider.css +1 -1
  34. package/dist/components/divider.min.css +1 -1
  35. package/dist/components/dropdown.css +11 -8
  36. package/dist/components/dropdown.js +4163 -4234
  37. package/dist/components/dropdown.min.css +2 -2
  38. package/dist/components/dropdown.min.js +2 -2
  39. package/dist/components/embed.css +1 -1
  40. package/dist/components/embed.js +653 -675
  41. package/dist/components/embed.min.css +1 -1
  42. package/dist/components/embed.min.js +1 -1
  43. package/dist/components/feed.css +1 -1
  44. package/dist/components/feed.min.css +1 -1
  45. package/dist/components/flag.css +1 -1
  46. package/dist/components/flag.min.css +1 -1
  47. package/dist/components/flyout.css +6 -3
  48. package/dist/components/flyout.js +1466 -1467
  49. package/dist/components/flyout.min.css +2 -2
  50. package/dist/components/flyout.min.js +1 -1
  51. package/dist/components/form.css +1 -1
  52. package/dist/components/form.js +1981 -2004
  53. package/dist/components/form.min.css +1 -1
  54. package/dist/components/form.min.js +1 -1
  55. package/dist/components/grid.css +1 -1
  56. package/dist/components/grid.min.css +1 -1
  57. package/dist/components/header.css +1 -1
  58. package/dist/components/header.min.css +1 -1
  59. package/dist/components/icon.css +1 -1
  60. package/dist/components/icon.min.css +1 -1
  61. package/dist/components/image.css +1 -1
  62. package/dist/components/image.min.css +1 -1
  63. package/dist/components/input.css +1 -1
  64. package/dist/components/input.min.css +1 -1
  65. package/dist/components/item.css +1 -1
  66. package/dist/components/item.min.css +1 -1
  67. package/dist/components/label.css +1 -1
  68. package/dist/components/label.min.css +1 -1
  69. package/dist/components/list.css +1 -1
  70. package/dist/components/list.min.css +1 -1
  71. package/dist/components/loader.css +1 -1
  72. package/dist/components/loader.min.css +1 -1
  73. package/dist/components/message.css +1 -1
  74. package/dist/components/message.min.css +1 -1
  75. package/dist/components/modal.css +7 -1
  76. package/dist/components/modal.js +1493 -1487
  77. package/dist/components/modal.min.css +2 -2
  78. package/dist/components/modal.min.js +1 -1
  79. package/dist/components/nag.css +1 -1
  80. package/dist/components/nag.js +520 -529
  81. package/dist/components/nag.min.css +1 -1
  82. package/dist/components/nag.min.js +1 -1
  83. package/dist/components/placeholder.css +1 -1
  84. package/dist/components/placeholder.min.css +1 -1
  85. package/dist/components/popup.css +1 -1
  86. package/dist/components/popup.js +1439 -1456
  87. package/dist/components/popup.min.css +1 -1
  88. package/dist/components/popup.min.js +1 -1
  89. package/dist/components/progress.css +1 -1
  90. package/dist/components/progress.js +971 -997
  91. package/dist/components/progress.min.css +1 -1
  92. package/dist/components/progress.min.js +1 -1
  93. package/dist/components/rail.css +1 -1
  94. package/dist/components/rail.min.css +1 -1
  95. package/dist/components/rating.css +1 -1
  96. package/dist/components/rating.js +508 -524
  97. package/dist/components/rating.min.css +1 -1
  98. package/dist/components/rating.min.js +1 -1
  99. package/dist/components/reset.css +1 -1
  100. package/dist/components/reset.min.css +1 -1
  101. package/dist/components/reveal.css +1 -1
  102. package/dist/components/reveal.min.css +1 -1
  103. package/dist/components/search.css +3 -1
  104. package/dist/components/search.js +1500 -1534
  105. package/dist/components/search.min.css +2 -2
  106. package/dist/components/search.min.js +1 -1
  107. package/dist/components/segment.css +3 -1
  108. package/dist/components/segment.min.css +2 -2
  109. package/dist/components/shape.css +1 -1
  110. package/dist/components/shape.js +794 -809
  111. package/dist/components/shape.min.css +1 -1
  112. package/dist/components/shape.min.js +1 -1
  113. package/dist/components/sidebar.css +3 -1
  114. package/dist/components/sidebar.js +1079 -1104
  115. package/dist/components/sidebar.min.css +2 -2
  116. package/dist/components/sidebar.min.js +1 -1
  117. package/dist/components/site.css +1 -1
  118. package/dist/components/site.js +457 -472
  119. package/dist/components/site.min.css +1 -1
  120. package/dist/components/site.min.js +1 -1
  121. package/dist/components/slider.js +1289 -1311
  122. package/dist/components/slider.min.js +1 -1
  123. package/dist/components/state.js +641 -657
  124. package/dist/components/state.min.js +1 -1
  125. package/dist/components/statistic.css +1 -1
  126. package/dist/components/statistic.min.css +1 -1
  127. package/dist/components/step.css +1 -1
  128. package/dist/components/step.min.css +1 -1
  129. package/dist/components/sticky.css +1 -1
  130. package/dist/components/sticky.js +859 -903
  131. package/dist/components/sticky.min.css +1 -1
  132. package/dist/components/sticky.min.js +1 -1
  133. package/dist/components/tab.css +1 -1
  134. package/dist/components/tab.js +923 -963
  135. package/dist/components/tab.min.css +1 -1
  136. package/dist/components/tab.min.js +1 -1
  137. package/dist/components/table.css +5 -1
  138. package/dist/components/table.min.css +2 -2
  139. package/dist/components/text.css +1 -1
  140. package/dist/components/text.min.css +1 -1
  141. package/dist/components/toast.css +1 -1
  142. package/dist/components/toast.js +889 -891
  143. package/dist/components/toast.min.css +1 -1
  144. package/dist/components/toast.min.js +1 -1
  145. package/dist/components/transition.css +1 -1
  146. package/dist/components/transition.js +1043 -1077
  147. package/dist/components/transition.min.css +1 -1
  148. package/dist/components/transition.min.js +1 -1
  149. package/dist/components/visibility.js +1222 -1244
  150. package/dist/components/visibility.min.js +1 -1
  151. package/dist/semantic.css +84 -60
  152. package/dist/semantic.js +29033 -29475
  153. package/dist/semantic.min.css +2 -2
  154. package/dist/semantic.min.js +2 -2
  155. package/examples/assets/show-examples.js +13 -13
  156. package/gulpfile.js +9 -10
  157. package/package.json +5 -2
  158. package/scripts/nightly-version.js +81 -75
  159. package/src/definitions/behaviors/api.js +1163 -1185
  160. package/src/definitions/behaviors/form.js +1980 -2003
  161. package/src/definitions/behaviors/state.js +647 -663
  162. package/src/definitions/behaviors/visibility.js +1221 -1243
  163. package/src/definitions/collections/table.less +2 -0
  164. package/src/definitions/elements/container.less +1 -0
  165. package/src/definitions/elements/segment.less +1 -0
  166. package/src/definitions/globals/site.js +456 -471
  167. package/src/definitions/modules/accordion.js +570 -597
  168. package/src/definitions/modules/calendar.js +1896 -1817
  169. package/src/definitions/modules/checkbox.js +849 -846
  170. package/src/definitions/modules/dimmer.js +709 -736
  171. package/src/definitions/modules/dropdown.js +4162 -4233
  172. package/src/definitions/modules/dropdown.less +5 -8
  173. package/src/definitions/modules/embed.js +652 -674
  174. package/src/definitions/modules/flyout.js +1465 -1466
  175. package/src/definitions/modules/flyout.less +15 -12
  176. package/src/definitions/modules/modal.js +1492 -1486
  177. package/src/definitions/modules/modal.less +3 -0
  178. package/src/definitions/modules/nag.js +519 -528
  179. package/src/definitions/modules/popup.js +1438 -1455
  180. package/src/definitions/modules/progress.js +970 -996
  181. package/src/definitions/modules/rating.js +507 -523
  182. package/src/definitions/modules/search.js +1499 -1533
  183. package/src/definitions/modules/search.less +1 -0
  184. package/src/definitions/modules/shape.js +801 -816
  185. package/src/definitions/modules/sidebar.js +1078 -1103
  186. package/src/definitions/modules/sidebar.less +1 -0
  187. package/src/definitions/modules/slider.js +1288 -1310
  188. package/src/definitions/modules/sticky.js +875 -919
  189. package/src/definitions/modules/tab.js +922 -962
  190. package/src/definitions/modules/toast.js +888 -890
  191. package/src/definitions/modules/transition.js +1048 -1082
  192. package/src/themes/default/elements/container.variables +0 -7
  193. package/src/themes/default/elements/segment.variables +0 -7
  194. package/src/themes/default/globals/site.variables +7 -0
  195. package/src/themes/default/globals/variation.variables +1 -0
  196. package/tasks/admin/components/create.js +274 -276
  197. package/tasks/admin/components/init.js +123 -130
  198. package/tasks/admin/components/update.js +149 -157
  199. package/tasks/admin/distributions/create.js +184 -187
  200. package/tasks/admin/distributions/init.js +123 -130
  201. package/tasks/admin/distributions/update.js +145 -152
  202. package/tasks/admin/publish.js +5 -7
  203. package/tasks/admin/register.js +36 -38
  204. package/tasks/admin/release.js +8 -10
  205. package/tasks/build/assets.js +42 -39
  206. package/tasks/build/css.js +225 -216
  207. package/tasks/build/javascript.js +118 -113
  208. package/tasks/build.js +10 -10
  209. package/tasks/check-install.js +14 -16
  210. package/tasks/clean.js +5 -5
  211. package/tasks/collections/admin.js +34 -36
  212. package/tasks/collections/build.js +18 -20
  213. package/tasks/collections/docs.js +9 -11
  214. package/tasks/collections/install.js +9 -11
  215. package/tasks/collections/rtl.js +9 -11
  216. package/tasks/collections/various.js +8 -10
  217. package/tasks/config/admin/github.js +17 -17
  218. package/tasks/config/admin/oauth.example.js +4 -4
  219. package/tasks/config/admin/release.js +98 -98
  220. package/tasks/config/admin/templates/component-package.js +9 -10
  221. package/tasks/config/admin/templates/css-package.js +18 -20
  222. package/tasks/config/admin/templates/less-package.js +11 -13
  223. package/tasks/config/defaults.js +116 -116
  224. package/tasks/config/docs.js +23 -23
  225. package/tasks/config/npm/gulpfile.js +8 -9
  226. package/tasks/config/project/config.js +127 -134
  227. package/tasks/config/project/install.js +715 -713
  228. package/tasks/config/project/release.js +32 -38
  229. package/tasks/config/tasks.js +163 -164
  230. package/tasks/config/user.js +23 -29
  231. package/tasks/docs/build.js +97 -95
  232. package/tasks/docs/metadata.js +90 -96
  233. package/tasks/docs/serve.js +80 -81
  234. package/tasks/install.js +370 -378
  235. package/tasks/rtl/build.js +2 -2
  236. package/tasks/rtl/watch.js +2 -2
  237. package/tasks/version.js +4 -4
  238. package/tasks/watch.js +28 -30
  239. package/test/meteor/assets.js +10 -13
  240. package/test/meteor/fonts.js +12 -13
  241. package/test/modules/accordion.spec.js +6 -8
  242. package/test/modules/checkbox.spec.js +5 -7
  243. package/test/modules/dropdown.spec.js +5 -7
  244. package/test/modules/modal.spec.js +6 -8
  245. package/test/modules/module.spec.js +158 -178
  246. package/test/modules/popup.spec.js +5 -7
  247. package/test/modules/search.spec.js +5 -7
  248. package/test/modules/shape.spec.js +5 -7
  249. package/test/modules/sidebar.spec.js +5 -7
  250. package/test/modules/tab.spec.js +6 -8
  251. package/test/modules/transition.spec.js +5 -7
  252. package/test/modules/video.spec.js +5 -7
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * # Fomantic-UI 2.9.1-beta.16+7071e59 - Progress
2
+ * # Fomantic-UI 2.9.1-beta.18+935e235 - Progress
3
3
  * https://github.com/fomantic/Fomantic-UI/
4
4
  *
5
5
  *
@@ -8,1029 +8,1003 @@
8
8
  *
9
9
  */
10
10
 
11
- ;(function ($, window, document, undefined) {
12
-
13
- 'use strict';
14
-
15
- function isFunction(obj) {
16
- return typeof obj === "function" && typeof obj.nodeType !== "number";
17
- }
18
-
19
- window = (typeof window != 'undefined' && window.Math == Math)
20
- ? window
21
- : (typeof self != 'undefined' && self.Math == Math)
22
- ? self
23
- : Function('return this')()
24
- ;
25
-
26
- $.fn.progress = function(parameters) {
27
- var
28
- $allModules = $(this),
29
-
30
- moduleSelector = $allModules.selector || '',
31
-
32
- time = new Date().getTime(),
33
- performance = [],
34
-
35
- query = arguments[0],
36
- methodInvoked = (typeof query == 'string'),
37
- queryArguments = [].slice.call(arguments, 1),
38
-
39
- returnedValue
40
- ;
41
-
42
- $allModules
43
- .each(function() {
44
- var
45
- settings = ( $.isPlainObject(parameters) )
46
- ? $.extend(true, {}, $.fn.progress.settings, parameters)
47
- : $.extend({}, $.fn.progress.settings),
48
-
49
- className = settings.className,
50
- metadata = settings.metadata,
51
- namespace = settings.namespace,
52
- selector = settings.selector,
53
- error = settings.error,
54
-
55
- eventNamespace = '.' + namespace,
56
- moduleNamespace = 'module-' + namespace,
57
-
58
- $module = $(this),
59
- $bars = $(this).find(selector.bar),
60
- $progresses = $(this).find(selector.progress),
61
- $label = $(this).find(selector.label),
62
-
63
- element = this,
64
- instance = $module.data(moduleNamespace),
65
-
66
- animating = false,
67
- transitionEnd,
68
- module
69
- ;
70
- module = {
71
- helper: {
72
- sum: function (nums) {
73
- return Array.isArray(nums) ? nums.reduce(function (left, right) {
74
- return left + Number(right);
75
- }, 0) : 0;
76
- },
77
- /**
78
- * Derive precision for multiple progress with total and values.
79
- *
80
- * This helper dervices a precision that is sufficiently large to show minimum value of multiple progress.
81
- *
82
- * Example1
83
- * - total: 1122
84
- * - values: [325, 111, 74, 612]
85
- * - min ratio: 74/1122 = 0.0659...
86
- * - required precision: 100
87
- *
88
- * Example2
89
- * - total: 10541
90
- * - values: [3235, 1111, 74, 6121]
91
- * - min ratio: 74/10541 = 0.0070...
92
- * - required precision: 1000
93
- *
94
- * @param min A minimum value within multiple values
95
- * @param total A total amount of multiple values
96
- * @returns {number} A precision. Could be 1, 10, 100, ... 1e+10.
97
- */
98
- derivePrecision: function(min, total) {
99
- var precisionPower = 0
100
- var precision = 1;
101
- var ratio = min / total;
102
- while (precisionPower < 10) {
103
- ratio = ratio * precision;
104
- if (ratio > 1) {
105
- break;
106
- }
107
- precision = Math.pow(10, precisionPower++);
108
- }
109
- return precision;
110
- },
111
- forceArray: function (element) {
112
- return Array.isArray(element)
113
- ? element
114
- : !isNaN(element)
115
- ? [element]
116
- : typeof element == 'string'
117
- ? element.split(',')
118
- : []
119
- ;
120
- }
121
- },
11
+ (function ($, window, document, undefined) {
12
+ 'use strict';
122
13
 
123
- initialize: function() {
124
- module.set.duration();
125
- module.set.transitionEvent();
126
- module.debug(element);
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
127
17
 
128
- module.read.metadata();
129
- module.read.settings();
18
+ window = (typeof window != 'undefined' && window.Math == Math)
19
+ ? window
20
+ : (typeof self != 'undefined' && self.Math == Math)
21
+ ? self
22
+ : Function('return this')();
130
23
 
131
- module.instantiate();
132
- },
24
+ $.fn.progress = function (parameters) {
25
+ var
26
+ $allModules = $(this),
133
27
 
134
- instantiate: function() {
135
- module.verbose('Storing instance of progress', module);
136
- instance = module;
137
- $module
138
- .data(moduleNamespace, module)
139
- ;
140
- },
141
- destroy: function() {
142
- module.verbose('Destroying previous progress for', $module);
143
- clearInterval(instance.interval);
144
- module.remove.state();
145
- $module.removeData(moduleNamespace);
146
- instance = undefined;
147
- },
28
+ moduleSelector = $allModules.selector || '',
148
29
 
149
- reset: function() {
150
- module.remove.nextValue();
151
- module.update.progress(0);
152
- },
30
+ time = new Date().getTime(),
31
+ performance = [],
153
32
 
154
- complete: function(keepState) {
155
- if(module.percent === undefined || module.percent < 100) {
156
- module.remove.progressPoll();
157
- if(keepState !== true){
158
- module.set.percent(100);
159
- }
160
- }
161
- },
33
+ query = arguments[0],
34
+ methodInvoked = (typeof query == 'string'),
35
+ queryArguments = [].slice.call(arguments, 1),
36
+
37
+ returnedValue
38
+ ;
162
39
 
163
- read: {
164
- metadata: function() {
40
+ $allModules.each(function () {
165
41
  var
166
- data = {
167
- percent : module.helper.forceArray($module.data(metadata.percent)),
168
- total : $module.data(metadata.total),
169
- value : module.helper.forceArray($module.data(metadata.value))
170
- }
42
+ settings = ($.isPlainObject(parameters))
43
+ ? $.extend(true, {}, $.fn.progress.settings, parameters)
44
+ : $.extend({}, $.fn.progress.settings),
45
+
46
+ className = settings.className,
47
+ metadata = settings.metadata,
48
+ namespace = settings.namespace,
49
+ selector = settings.selector,
50
+ error = settings.error,
51
+
52
+ eventNamespace = '.' + namespace,
53
+ moduleNamespace = 'module-' + namespace,
54
+
55
+ $module = $(this),
56
+ $bars = $(this).find(selector.bar),
57
+ $progresses = $(this).find(selector.progress),
58
+ $label = $(this).find(selector.label),
59
+
60
+ element = this,
61
+ instance = $module.data(moduleNamespace),
62
+
63
+ animating = false,
64
+ transitionEnd,
65
+ module
171
66
  ;
172
- if(data.total !== undefined) {
173
- module.debug('Total value set from metadata', data.total);
174
- module.set.total(data.total);
175
- }
176
- if(data.value.length > 0) {
177
- module.debug('Current value set from metadata', data.value);
178
- module.set.value(data.value);
179
- module.set.progress(data.value);
180
- }
181
- if(data.percent.length > 0) {
182
- module.debug('Current percent value set from metadata', data.percent);
183
- module.set.percent(data.percent);
184
- }
185
- },
186
- settings: function() {
187
- if(settings.total !== false) {
188
- module.debug('Current total set in settings', settings.total);
189
- module.set.total(settings.total);
190
- }
191
- if(settings.value !== false) {
192
- module.debug('Current value set in settings', settings.value);
193
- module.set.value(settings.value);
194
- module.set.progress(module.value);
195
- }
196
- if(settings.percent !== false) {
197
- module.debug('Current percent set in settings', settings.percent);
198
- module.set.percent(settings.percent);
67
+ module = {
68
+ helper: {
69
+ sum: function (nums) {
70
+ return Array.isArray(nums) ? nums.reduce(function (left, right) {
71
+ return left + Number(right);
72
+ }, 0) : 0;
73
+ },
74
+ /**
75
+ * Derive precision for multiple progress with total and values.
76
+ *
77
+ * This helper dervices a precision that is sufficiently large to show minimum value of multiple progress.
78
+ *
79
+ * Example1
80
+ * - total: 1122
81
+ * - values: [325, 111, 74, 612]
82
+ * - min ratio: 74/1122 = 0.0659...
83
+ * - required precision: 100
84
+ *
85
+ * Example2
86
+ * - total: 10541
87
+ * - values: [3235, 1111, 74, 6121]
88
+ * - min ratio: 74/10541 = 0.0070...
89
+ * - required precision: 1000
90
+ *
91
+ * @param min A minimum value within multiple values
92
+ * @param total A total amount of multiple values
93
+ * @returns {number} A precision. Could be 1, 10, 100, ... 1e+10.
94
+ */
95
+ derivePrecision: function (min, total) {
96
+ var precisionPower = 0;
97
+ var precision = 1;
98
+ var ratio = min / total;
99
+ while (precisionPower < 10) {
100
+ ratio = ratio * precision;
101
+ if (ratio > 1) {
102
+ break;
103
+ }
104
+ precision = Math.pow(10, precisionPower++);
105
+ }
106
+
107
+ return precision;
108
+ },
109
+ forceArray: function (element) {
110
+ return Array.isArray(element)
111
+ ? element
112
+ : !isNaN(element)
113
+ ? [element]
114
+ : typeof element == 'string'
115
+ ? element.split(',')
116
+ : [];
117
+ },
118
+ },
119
+
120
+ initialize: function () {
121
+ module.set.duration();
122
+ module.set.transitionEvent();
123
+ module.debug(element);
124
+
125
+ module.read.metadata();
126
+ module.read.settings();
127
+
128
+ module.instantiate();
129
+ },
130
+
131
+ instantiate: function () {
132
+ module.verbose('Storing instance of progress', module);
133
+ instance = module;
134
+ $module
135
+ .data(moduleNamespace, module)
136
+ ;
137
+ },
138
+ destroy: function () {
139
+ module.verbose('Destroying previous progress for', $module);
140
+ clearInterval(instance.interval);
141
+ module.remove.state();
142
+ $module.removeData(moduleNamespace);
143
+ instance = undefined;
144
+ },
145
+
146
+ reset: function () {
147
+ module.remove.nextValue();
148
+ module.update.progress(0);
149
+ },
150
+
151
+ complete: function (keepState) {
152
+ if (module.percent === undefined || module.percent < 100) {
153
+ module.remove.progressPoll();
154
+ if (keepState !== true) {
155
+ module.set.percent(100);
156
+ }
157
+ }
158
+ },
159
+
160
+ read: {
161
+ metadata: function () {
162
+ var
163
+ data = {
164
+ percent: module.helper.forceArray($module.data(metadata.percent)),
165
+ total: $module.data(metadata.total),
166
+ value: module.helper.forceArray($module.data(metadata.value)),
167
+ }
168
+ ;
169
+ if (data.total !== undefined) {
170
+ module.debug('Total value set from metadata', data.total);
171
+ module.set.total(data.total);
172
+ }
173
+ if (data.value.length > 0) {
174
+ module.debug('Current value set from metadata', data.value);
175
+ module.set.value(data.value);
176
+ module.set.progress(data.value);
177
+ }
178
+ if (data.percent.length > 0) {
179
+ module.debug('Current percent value set from metadata', data.percent);
180
+ module.set.percent(data.percent);
181
+ }
182
+ },
183
+ settings: function () {
184
+ if (settings.total !== false) {
185
+ module.debug('Current total set in settings', settings.total);
186
+ module.set.total(settings.total);
187
+ }
188
+ if (settings.value !== false) {
189
+ module.debug('Current value set in settings', settings.value);
190
+ module.set.value(settings.value);
191
+ module.set.progress(module.value);
192
+ }
193
+ if (settings.percent !== false) {
194
+ module.debug('Current percent set in settings', settings.percent);
195
+ module.set.percent(settings.percent);
196
+ }
197
+ },
198
+ },
199
+
200
+ bind: {
201
+ transitionEnd: function (callback) {
202
+ var
203
+ transitionEnd = module.get.transitionEnd()
204
+ ;
205
+ $bars
206
+ .one(transitionEnd + eventNamespace, function (event) {
207
+ clearTimeout(module.failSafeTimer);
208
+ callback.call(this, event);
209
+ })
210
+ ;
211
+ module.failSafeTimer = setTimeout(function () {
212
+ $bars.triggerHandler(transitionEnd);
213
+ }, settings.duration + settings.failSafeDelay);
214
+ module.verbose('Adding fail safe timer', module.timer);
215
+ },
216
+ },
217
+
218
+ increment: function (incrementValue) {
219
+ var
220
+ startValue,
221
+ newValue
222
+ ;
223
+ if (module.has.total()) {
224
+ startValue = module.get.value();
225
+ incrementValue = incrementValue || 1;
226
+ } else {
227
+ startValue = module.get.percent();
228
+ incrementValue = incrementValue || module.get.randomValue();
229
+ }
230
+ newValue = startValue + incrementValue;
231
+ module.debug('Incrementing percentage by', startValue, newValue, incrementValue);
232
+ newValue = module.get.normalizedValue(newValue);
233
+ module.set.progress(newValue);
234
+ },
235
+ decrement: function (decrementValue) {
236
+ var
237
+ total = module.get.total(),
238
+ startValue,
239
+ newValue
240
+ ;
241
+ if (total) {
242
+ startValue = module.get.value();
243
+ decrementValue = decrementValue || 1;
244
+ newValue = startValue - decrementValue;
245
+ module.debug('Decrementing value by', decrementValue, startValue);
246
+ } else {
247
+ startValue = module.get.percent();
248
+ decrementValue = decrementValue || module.get.randomValue();
249
+ newValue = startValue - decrementValue;
250
+ module.debug('Decrementing percentage by', decrementValue, startValue);
251
+ }
252
+ newValue = module.get.normalizedValue(newValue);
253
+ module.set.progress(newValue);
254
+ },
255
+
256
+ has: {
257
+ progressPoll: function () {
258
+ return module.progressPoll;
259
+ },
260
+ total: function () {
261
+ return (module.get.total() !== false);
262
+ },
263
+ },
264
+
265
+ get: {
266
+ text: function (templateText, index) {
267
+ var
268
+ index_ = index || 0,
269
+ value = module.get.value(index_),
270
+ total = module.get.total(),
271
+ percent = (animating)
272
+ ? module.get.displayPercent(index_)
273
+ : module.get.percent(index_),
274
+ left = (total !== false)
275
+ ? Math.max(0, total - value)
276
+ : (100 - percent)
277
+ ;
278
+ templateText = templateText || '';
279
+ templateText = templateText
280
+ .replace('{value}', value)
281
+ .replace('{total}', total || 0)
282
+ .replace('{left}', left)
283
+ .replace('{percent}', percent)
284
+ .replace('{bar}', settings.text.bars[index_] || '')
285
+ ;
286
+ module.verbose('Adding variables to progress bar text', templateText);
287
+
288
+ return templateText;
289
+ },
290
+
291
+ normalizedValue: function (value) {
292
+ if (value < 0) {
293
+ module.debug('Value cannot decrement below 0');
294
+
295
+ return 0;
296
+ }
297
+ if (module.has.total()) {
298
+ if (value > module.total) {
299
+ module.debug('Value cannot increment above total', module.total);
300
+
301
+ return module.total;
302
+ }
303
+ } else if (value > 100) {
304
+ module.debug('Value cannot increment above 100 percent');
305
+
306
+ return 100;
307
+ }
308
+
309
+ return value;
310
+ },
311
+
312
+ updateInterval: function () {
313
+ if (settings.updateInterval == 'auto') {
314
+ return settings.duration;
315
+ }
316
+
317
+ return settings.updateInterval;
318
+ },
319
+
320
+ randomValue: function () {
321
+ module.debug('Generating random increment percentage');
322
+
323
+ return Math.floor((Math.random() * settings.random.max) + settings.random.min);
324
+ },
325
+
326
+ numericValue: function (value) {
327
+ return (typeof value === 'string')
328
+ ? (value.replace(/[^\d.]/g, '') !== '')
329
+ ? +(value.replace(/[^\d.]/g, ''))
330
+ : false
331
+ : value;
332
+ },
333
+
334
+ transitionEnd: function () {
335
+ var
336
+ element = document.createElement('element'),
337
+ transitions = {
338
+ transition: 'transitionend',
339
+ OTransition: 'oTransitionEnd',
340
+ MozTransition: 'transitionend',
341
+ WebkitTransition: 'webkitTransitionEnd',
342
+ },
343
+ transition
344
+ ;
345
+ for (transition in transitions) {
346
+ if (element.style[transition] !== undefined) {
347
+ return transitions[transition];
348
+ }
349
+ }
350
+ },
351
+
352
+ // gets current displayed percentage (if animating values this is the intermediary value)
353
+ displayPercent: function (index) {
354
+ var
355
+ $bar = $($bars[index]),
356
+ barWidth = $bar.width(),
357
+ totalWidth = $module.width(),
358
+ minDisplay = parseInt($bar.css('min-width'), 10),
359
+ displayPercent = (barWidth > minDisplay)
360
+ ? (barWidth / totalWidth * 100)
361
+ : module.percent
362
+ ;
363
+
364
+ return (settings.precision > 0)
365
+ ? Math.round(displayPercent * (10 * settings.precision)) / (10 * settings.precision)
366
+ : Math.round(displayPercent);
367
+ },
368
+
369
+ percent: function (index) {
370
+ return module.percent && module.percent[index || 0] || 0;
371
+ },
372
+ value: function (index) {
373
+ return module.nextValue || module.value && module.value[index || 0] || 0;
374
+ },
375
+ total: function () {
376
+ return module.total !== undefined ? module.total : false;
377
+ },
378
+ },
379
+
380
+ create: {
381
+ progressPoll: function () {
382
+ module.progressPoll = setTimeout(function () {
383
+ module.update.toNextValue();
384
+ module.remove.progressPoll();
385
+ }, module.get.updateInterval());
386
+ },
387
+ },
388
+
389
+ is: {
390
+ complete: function () {
391
+ return module.is.success() || module.is.warning() || module.is.error();
392
+ },
393
+ success: function () {
394
+ return $module.hasClass(className.success);
395
+ },
396
+ warning: function () {
397
+ return $module.hasClass(className.warning);
398
+ },
399
+ error: function () {
400
+ return $module.hasClass(className.error);
401
+ },
402
+ active: function () {
403
+ return $module.hasClass(className.active);
404
+ },
405
+ visible: function () {
406
+ return $module.is(':visible');
407
+ },
408
+ },
409
+
410
+ remove: {
411
+ progressPoll: function () {
412
+ module.verbose('Removing progress poll timer');
413
+ if (module.progressPoll) {
414
+ clearTimeout(module.progressPoll);
415
+ delete module.progressPoll;
416
+ }
417
+ },
418
+ nextValue: function () {
419
+ module.verbose('Removing progress value stored for next update');
420
+ delete module.nextValue;
421
+ },
422
+ state: function () {
423
+ module.verbose('Removing stored state');
424
+ delete module.total;
425
+ delete module.percent;
426
+ delete module.value;
427
+ },
428
+ active: function () {
429
+ module.verbose('Removing active state');
430
+ $module.removeClass(className.active);
431
+ },
432
+ success: function () {
433
+ module.verbose('Removing success state');
434
+ $module.removeClass(className.success);
435
+ },
436
+ warning: function () {
437
+ module.verbose('Removing warning state');
438
+ $module.removeClass(className.warning);
439
+ },
440
+ error: function () {
441
+ module.verbose('Removing error state');
442
+ $module.removeClass(className.error);
443
+ },
444
+ },
445
+
446
+ set: {
447
+ barWidth: function (values) {
448
+ module.debug('set bar width with ', values);
449
+ values = module.helper.forceArray(values);
450
+ var firstNonZeroIndex = -1;
451
+ var lastNonZeroIndex = -1;
452
+ var valuesSum = module.helper.sum(values);
453
+ var barCounts = $bars.length;
454
+ var isMultiple = barCounts > 1;
455
+ var percents = values.map(function (value, index) {
456
+ var allZero = (index === barCounts - 1 && valuesSum === 0);
457
+ var $bar = $($bars[index]);
458
+ if (value === 0 && isMultiple && !allZero) {
459
+ $bar.css('display', 'none');
460
+ } else {
461
+ if (isMultiple && allZero) {
462
+ $bar.css('background', 'transparent');
463
+ }
464
+ if (firstNonZeroIndex == -1) {
465
+ firstNonZeroIndex = index;
466
+ }
467
+ lastNonZeroIndex = index;
468
+ $bar.css({
469
+ display: 'block',
470
+ width: value + '%',
471
+ });
472
+ }
473
+
474
+ return parseFloat(value);
475
+ });
476
+ values.forEach(function (_, index) {
477
+ var $bar = $($bars[index]);
478
+ $bar.css({
479
+ borderTopLeftRadius: index == firstNonZeroIndex ? '' : '0',
480
+ borderBottomLeftRadius: index == firstNonZeroIndex ? '' : '0',
481
+ borderTopRightRadius: index == lastNonZeroIndex ? '' : '0',
482
+ borderBottomRightRadius: index == lastNonZeroIndex ? '' : '0',
483
+ });
484
+ });
485
+ $module
486
+ .attr('data-percent', percents)
487
+ ;
488
+ },
489
+ duration: function (duration) {
490
+ duration = duration || settings.duration;
491
+ duration = (typeof duration == 'number')
492
+ ? duration + 'ms'
493
+ : duration;
494
+ module.verbose('Setting progress bar transition duration', duration);
495
+ $bars
496
+ .css({
497
+ 'transition-duration': duration,
498
+ })
499
+ ;
500
+ },
501
+ percent: function (percents) {
502
+ percents = module.helper.forceArray(percents).map(function (percent) {
503
+ percent = (typeof percent == 'string')
504
+ ? +(percent.replace('%', ''))
505
+ : percent;
506
+
507
+ return (settings.limitValues)
508
+ ? Math.max(0, Math.min(100, percent))
509
+ : percent;
510
+ });
511
+ var hasTotal = module.has.total();
512
+ var totalPercent = module.helper.sum(percents);
513
+ var isMultipleValues = percents.length > 1 && hasTotal;
514
+ var sumTotal = module.helper.sum(module.helper.forceArray(module.value));
515
+ if (isMultipleValues && sumTotal > module.total) {
516
+ // Sum values instead of pecents to avoid precision issues when summing floats
517
+ module.error(error.sumExceedsTotal, sumTotal, module.total);
518
+ } else if (!isMultipleValues && totalPercent > 100) {
519
+ // Sum before rounding since sum of rounded may have error though sum of actual is fine
520
+ module.error(error.tooHigh, totalPercent);
521
+ } else if (totalPercent < 0) {
522
+ module.error(error.tooLow, totalPercent);
523
+ } else {
524
+ var autoPrecision = settings.precision > 0
525
+ ? settings.precision
526
+ : isMultipleValues
527
+ ? module.helper.derivePrecision(Math.min.apply(null, module.value), module.total)
528
+ : 0;
529
+
530
+ // round display percentage
531
+ var roundedPercents = percents.map(function (percent) {
532
+ return (autoPrecision > 0)
533
+ ? Math.round(percent * (10 * autoPrecision)) / (10 * autoPrecision)
534
+ : Math.round(percent)
535
+ ;
536
+ });
537
+ module.percent = roundedPercents;
538
+ if (hasTotal) {
539
+ module.value = percents.map(function (percent) {
540
+ return (autoPrecision > 0)
541
+ ? Math.round((percent / 100) * module.total * (10 * autoPrecision)) / (10 * autoPrecision)
542
+ : Math.round((percent / 100) * module.total * 10) / 10;
543
+ });
544
+ }
545
+ module.set.barWidth(percents);
546
+ module.set.labelInterval();
547
+ }
548
+ settings.onChange.call(element, percents, module.value, module.total);
549
+ },
550
+ labelInterval: function () {
551
+ var
552
+ animationCallback = function () {
553
+ module.verbose('Bar finished animating, removing continuous label updates');
554
+ clearInterval(module.interval);
555
+ animating = false;
556
+ module.set.labels();
557
+ }
558
+ ;
559
+ clearInterval(module.interval);
560
+ module.bind.transitionEnd(animationCallback);
561
+ animating = true;
562
+ module.interval = setInterval(function () {
563
+ var
564
+ isInDOM = $.contains(document.documentElement, element)
565
+ ;
566
+ if (!isInDOM) {
567
+ clearInterval(module.interval);
568
+ animating = false;
569
+ }
570
+ module.set.labels();
571
+ }, settings.framerate);
572
+ },
573
+ labels: function () {
574
+ module.verbose('Setting both bar progress and outer label text');
575
+ module.set.barLabel();
576
+ module.set.state();
577
+ },
578
+ label: function (text) {
579
+ text = text || '';
580
+ if (text) {
581
+ text = module.get.text(text);
582
+ module.verbose('Setting label to text', text);
583
+ $label.text(text);
584
+ }
585
+ },
586
+ state: function (percent) {
587
+ percent = (percent !== undefined)
588
+ ? percent
589
+ : module.helper.sum(module.percent);
590
+ if (percent === 100) {
591
+ if (settings.autoSuccess && $bars.length === 1 && !(module.is.warning() || module.is.error() || module.is.success())) {
592
+ module.set.success();
593
+ module.debug('Automatically triggering success at 100%');
594
+ } else {
595
+ module.verbose('Reached 100% removing active state');
596
+ module.remove.active();
597
+ module.remove.progressPoll();
598
+ }
599
+ } else if (percent > 0) {
600
+ module.verbose('Adjusting active progress bar label', percent);
601
+ module.set.active();
602
+ } else {
603
+ module.remove.active();
604
+ module.remove.warning();
605
+ module.remove.error();
606
+ module.remove.success();
607
+ module.set.label(settings.text.active);
608
+ }
609
+ },
610
+ barLabel: function (text) {
611
+ $progresses.map(function (index, element) {
612
+ var $progress = $(element);
613
+ if (text !== undefined) {
614
+ $progress.text(module.get.text(text, index));
615
+ } else if (settings.label == 'ratio' && module.has.total()) {
616
+ module.verbose('Adding ratio to bar label');
617
+ $progress.text(module.get.text(settings.text.ratio, index));
618
+ } else if (settings.label == 'percent') {
619
+ module.verbose('Adding percentage to bar label');
620
+ $progress.text(module.get.text(settings.text.percent, index));
621
+ }
622
+ });
623
+ },
624
+ active: function (text) {
625
+ text = text || settings.text.active;
626
+ module.debug('Setting active state');
627
+ if (settings.showActivity && !module.is.active()) {
628
+ $module.addClass(className.active);
629
+ }
630
+ module.remove.warning();
631
+ module.remove.error();
632
+ module.remove.success();
633
+ text = settings.onLabelUpdate('active', text, module.value, module.total);
634
+ if (text) {
635
+ module.set.label(text);
636
+ }
637
+ module.bind.transitionEnd(function () {
638
+ settings.onActive.call(element, module.value, module.total);
639
+ });
640
+ },
641
+ success: function (text, keepState) {
642
+ text = text || settings.text.success || settings.text.active;
643
+ module.debug('Setting success state');
644
+ $module.addClass(className.success);
645
+ module.remove.active();
646
+ module.remove.warning();
647
+ module.remove.error();
648
+ module.complete(keepState);
649
+ if (settings.text.success) {
650
+ text = settings.onLabelUpdate('success', text, module.value, module.total);
651
+ module.set.label(text);
652
+ } else {
653
+ text = settings.onLabelUpdate('active', text, module.value, module.total);
654
+ module.set.label(text);
655
+ }
656
+ module.bind.transitionEnd(function () {
657
+ settings.onSuccess.call(element, module.total);
658
+ });
659
+ },
660
+ warning: function (text, keepState) {
661
+ text = text || settings.text.warning;
662
+ module.debug('Setting warning state');
663
+ $module.addClass(className.warning);
664
+ module.remove.active();
665
+ module.remove.success();
666
+ module.remove.error();
667
+ module.complete(keepState);
668
+ text = settings.onLabelUpdate('warning', text, module.value, module.total);
669
+ if (text) {
670
+ module.set.label(text);
671
+ }
672
+ module.bind.transitionEnd(function () {
673
+ settings.onWarning.call(element, module.value, module.total);
674
+ });
675
+ },
676
+ error: function (text, keepState) {
677
+ text = text || settings.text.error;
678
+ module.debug('Setting error state');
679
+ $module.addClass(className.error);
680
+ module.remove.active();
681
+ module.remove.success();
682
+ module.remove.warning();
683
+ module.complete(keepState);
684
+ text = settings.onLabelUpdate('error', text, module.value, module.total);
685
+ if (text) {
686
+ module.set.label(text);
687
+ }
688
+ module.bind.transitionEnd(function () {
689
+ settings.onError.call(element, module.value, module.total);
690
+ });
691
+ },
692
+ transitionEvent: function () {
693
+ transitionEnd = module.get.transitionEnd();
694
+ },
695
+ total: function (totalValue) {
696
+ module.total = totalValue;
697
+ },
698
+ value: function (value) {
699
+ module.value = module.helper.forceArray(value);
700
+ },
701
+ progress: function (value) {
702
+ if (!module.has.progressPoll()) {
703
+ module.debug('First update in progress update interval, immediately updating', value);
704
+ module.update.progress(value);
705
+ module.create.progressPoll();
706
+ } else {
707
+ module.debug('Updated within interval, setting next update to use new value', value);
708
+ module.set.nextValue(value);
709
+ }
710
+ },
711
+ nextValue: function (value) {
712
+ module.nextValue = value;
713
+ },
714
+ },
715
+
716
+ update: {
717
+ toNextValue: function () {
718
+ var
719
+ nextValue = module.nextValue
720
+ ;
721
+ if (nextValue) {
722
+ module.debug('Update interval complete using last updated value', nextValue);
723
+ module.update.progress(nextValue);
724
+ module.remove.nextValue();
725
+ }
726
+ },
727
+ progress: function (values) {
728
+ var hasTotal = module.has.total();
729
+ if (hasTotal) {
730
+ module.set.value(values);
731
+ }
732
+ var percentCompletes = module.helper.forceArray(values).map(function (value) {
733
+ var
734
+ percentComplete
735
+ ;
736
+ value = module.get.numericValue(value);
737
+ if (value === false) {
738
+ module.error(error.nonNumeric, value);
739
+ }
740
+ value = module.get.normalizedValue(value);
741
+ if (hasTotal) {
742
+ percentComplete = module.total > 0 ? (value / module.total) * 100 : 100;
743
+ module.debug('Calculating percent complete from total', percentComplete);
744
+ } else {
745
+ percentComplete = value;
746
+ module.debug('Setting value to exact percentage value', percentComplete);
747
+ }
748
+
749
+ return percentComplete;
750
+ });
751
+ module.set.percent(percentCompletes);
752
+ },
753
+ },
754
+
755
+ setting: function (name, value) {
756
+ module.debug('Changing setting', name, value);
757
+ if ($.isPlainObject(name)) {
758
+ $.extend(true, settings, name);
759
+ } else if (value !== undefined) {
760
+ if ($.isPlainObject(settings[name])) {
761
+ $.extend(true, settings[name], value);
762
+ } else {
763
+ settings[name] = value;
764
+ }
765
+ } else {
766
+ return settings[name];
767
+ }
768
+ },
769
+ internal: function (name, value) {
770
+ if ($.isPlainObject(name)) {
771
+ $.extend(true, module, name);
772
+ } else if (value !== undefined) {
773
+ module[name] = value;
774
+ } else {
775
+ return module[name];
776
+ }
777
+ },
778
+ debug: function () {
779
+ if (!settings.silent && settings.debug) {
780
+ if (settings.performance) {
781
+ module.performance.log(arguments);
782
+ } else {
783
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
784
+ module.debug.apply(console, arguments);
785
+ }
786
+ }
787
+ },
788
+ verbose: function () {
789
+ if (!settings.silent && settings.verbose && settings.debug) {
790
+ if (settings.performance) {
791
+ module.performance.log(arguments);
792
+ } else {
793
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
794
+ module.verbose.apply(console, arguments);
795
+ }
796
+ }
797
+ },
798
+ error: function () {
799
+ if (!settings.silent) {
800
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
801
+ module.error.apply(console, arguments);
802
+ }
803
+ },
804
+ performance: {
805
+ log: function (message) {
806
+ var
807
+ currentTime,
808
+ executionTime,
809
+ previousTime
810
+ ;
811
+ if (settings.performance) {
812
+ currentTime = new Date().getTime();
813
+ previousTime = time || currentTime;
814
+ executionTime = currentTime - previousTime;
815
+ time = currentTime;
816
+ performance.push({
817
+ Name: message[0],
818
+ Arguments: [].slice.call(message, 1) || '',
819
+ Element: element,
820
+ 'Execution Time': executionTime,
821
+ });
822
+ }
823
+ clearTimeout(module.performance.timer);
824
+ module.performance.timer = setTimeout(module.performance.display, 500);
825
+ },
826
+ display: function () {
827
+ var
828
+ title = settings.name + ':',
829
+ totalTime = 0
830
+ ;
831
+ time = false;
832
+ clearTimeout(module.performance.timer);
833
+ $.each(performance, function (index, data) {
834
+ totalTime += data['Execution Time'];
835
+ });
836
+ title += ' ' + totalTime + 'ms';
837
+ if (moduleSelector) {
838
+ title += ' \'' + moduleSelector + '\'';
839
+ }
840
+ if ((console.group !== undefined || console.table !== undefined) && performance.length > 0) {
841
+ console.groupCollapsed(title);
842
+ if (console.table) {
843
+ console.table(performance);
844
+ } else {
845
+ $.each(performance, function (index, data) {
846
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
847
+ });
848
+ }
849
+ console.groupEnd();
850
+ }
851
+ performance = [];
852
+ },
853
+ },
854
+ invoke: function (query, passedArguments, context) {
855
+ var
856
+ object = instance,
857
+ maxDepth,
858
+ found,
859
+ response
860
+ ;
861
+ passedArguments = passedArguments || queryArguments;
862
+ context = context || element;
863
+ if (typeof query == 'string' && object !== undefined) {
864
+ query = query.split(/[\. ]/);
865
+ maxDepth = query.length - 1;
866
+ $.each(query, function (depth, value) {
867
+ var camelCaseValue = (depth != maxDepth)
868
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
869
+ : query
870
+ ;
871
+ if ($.isPlainObject(object[camelCaseValue]) && (depth != maxDepth)) {
872
+ object = object[camelCaseValue];
873
+ } else if (object[camelCaseValue] !== undefined) {
874
+ found = object[camelCaseValue];
875
+
876
+ return false;
877
+ } else if ($.isPlainObject(object[value]) && (depth != maxDepth)) {
878
+ object = object[value];
879
+ } else if (object[value] !== undefined) {
880
+ found = object[value];
881
+
882
+ return false;
883
+ } else {
884
+ module.error(error.method, query);
885
+
886
+ return false;
887
+ }
888
+ });
889
+ }
890
+ if (isFunction(found)) {
891
+ response = found.apply(context, passedArguments);
892
+ } else if (found !== undefined) {
893
+ response = found;
894
+ }
895
+ if (Array.isArray(returnedValue)) {
896
+ returnedValue.push(response);
897
+ } else if (returnedValue !== undefined) {
898
+ returnedValue = [returnedValue, response];
899
+ } else if (response !== undefined) {
900
+ returnedValue = response;
901
+ }
902
+
903
+ return found;
904
+ },
905
+ };
906
+
907
+ if (methodInvoked) {
908
+ if (instance === undefined) {
909
+ module.initialize();
910
+ }
911
+ module.invoke(query);
912
+ } else {
913
+ if (instance !== undefined) {
914
+ instance.invoke('destroy');
915
+ }
916
+ module.initialize();
199
917
  }
200
- }
201
- },
918
+ });
202
919
 
203
- bind: {
204
- transitionEnd: function(callback) {
205
- var
206
- transitionEnd = module.get.transitionEnd()
207
- ;
208
- $bars
209
- .one(transitionEnd + eventNamespace, function(event) {
210
- clearTimeout(module.failSafeTimer);
211
- callback.call(this, event);
212
- })
213
- ;
214
- module.failSafeTimer = setTimeout(function() {
215
- $bars.triggerHandler(transitionEnd);
216
- }, settings.duration + settings.failSafeDelay);
217
- module.verbose('Adding fail safe timer', module.timer);
218
- }
219
- },
920
+ return (returnedValue !== undefined)
921
+ ? returnedValue
922
+ : this;
923
+ };
220
924
 
221
- increment: function(incrementValue) {
222
- var
223
- startValue,
224
- newValue
225
- ;
226
- if( module.has.total() ) {
227
- startValue = module.get.value();
228
- incrementValue = incrementValue || 1;
229
- }
230
- else {
231
- startValue = module.get.percent();
232
- incrementValue = incrementValue || module.get.randomValue();
233
- }
234
- newValue = startValue + incrementValue;
235
- module.debug('Incrementing percentage by', startValue, newValue, incrementValue);
236
- newValue = module.get.normalizedValue(newValue);
237
- module.set.progress(newValue);
238
- },
239
- decrement: function(decrementValue) {
240
- var
241
- total = module.get.total(),
242
- startValue,
243
- newValue
244
- ;
245
- if(total) {
246
- startValue = module.get.value();
247
- decrementValue = decrementValue || 1;
248
- newValue = startValue - decrementValue;
249
- module.debug('Decrementing value by', decrementValue, startValue);
250
- }
251
- else {
252
- startValue = module.get.percent();
253
- decrementValue = decrementValue || module.get.randomValue();
254
- newValue = startValue - decrementValue;
255
- module.debug('Decrementing percentage by', decrementValue, startValue);
256
- }
257
- newValue = module.get.normalizedValue(newValue);
258
- module.set.progress(newValue);
259
- },
925
+ $.fn.progress.settings = {
926
+
927
+ name: 'Progress',
928
+ namespace: 'progress',
929
+
930
+ silent: false,
931
+ debug: false,
932
+ verbose: false,
933
+ performance: true,
260
934
 
261
- has: {
262
- progressPoll: function() {
263
- return module.progressPoll;
264
- },
265
- total: function() {
266
- return (module.get.total() !== false);
267
- }
935
+ random: {
936
+ min: 2,
937
+ max: 5,
268
938
  },
269
939
 
270
- get: {
271
- text: function(templateText, index) {
272
- var
273
- index_ = index || 0,
274
- value = module.get.value(index_),
275
- total = module.get.total(),
276
- percent = (animating)
277
- ? module.get.displayPercent(index_)
278
- : module.get.percent(index_),
279
- left = (total !== false)
280
- ? Math.max(0,total - value)
281
- : (100 - percent)
282
- ;
283
- templateText = templateText || '';
284
- templateText = templateText
285
- .replace('{value}', value)
286
- .replace('{total}', total || 0)
287
- .replace('{left}', left)
288
- .replace('{percent}', percent)
289
- .replace('{bar}', settings.text.bars[index_] || '')
290
- ;
291
- module.verbose('Adding variables to progress bar text', templateText);
292
- return templateText;
293
- },
294
-
295
- normalizedValue: function(value) {
296
- if(value < 0) {
297
- module.debug('Value cannot decrement below 0');
298
- return 0;
299
- }
300
- if(module.has.total()) {
301
- if(value > module.total) {
302
- module.debug('Value cannot increment above total', module.total);
303
- return module.total;
304
- }
305
- }
306
- else if(value > 100 ) {
307
- module.debug('Value cannot increment above 100 percent');
308
- return 100;
309
- }
310
- return value;
311
- },
940
+ duration: 300,
312
941
 
313
- updateInterval: function() {
314
- if(settings.updateInterval == 'auto') {
315
- return settings.duration;
316
- }
317
- return settings.updateInterval;
318
- },
319
-
320
- randomValue: function() {
321
- module.debug('Generating random increment percentage');
322
- return Math.floor((Math.random() * settings.random.max) + settings.random.min);
323
- },
324
-
325
- numericValue: function(value) {
326
- return (typeof value === 'string')
327
- ? (value.replace(/[^\d.]/g, '') !== '')
328
- ? +(value.replace(/[^\d.]/g, ''))
329
- : false
330
- : value
331
- ;
332
- },
942
+ updateInterval: 'auto',
333
943
 
334
- transitionEnd: function() {
335
- var
336
- element = document.createElement('element'),
337
- transitions = {
338
- 'transition' :'transitionend',
339
- 'OTransition' :'oTransitionEnd',
340
- 'MozTransition' :'transitionend',
341
- 'WebkitTransition' :'webkitTransitionEnd'
342
- },
343
- transition
344
- ;
345
- for(transition in transitions){
346
- if( element.style[transition] !== undefined ){
347
- return transitions[transition];
348
- }
349
- }
350
- },
944
+ autoSuccess: true,
945
+ showActivity: true,
946
+ limitValues: true,
351
947
 
352
- // gets current displayed percentage (if animating values this is the intermediary value)
353
- displayPercent: function(index) {
354
- var
355
- $bar = $($bars[index]),
356
- barWidth = $bar.width(),
357
- totalWidth = $module.width(),
358
- minDisplay = parseInt($bar.css('min-width'), 10),
359
- displayPercent = (barWidth > minDisplay)
360
- ? (barWidth / totalWidth * 100)
361
- : module.percent
362
- ;
363
- return (settings.precision > 0)
364
- ? Math.round(displayPercent * (10 * settings.precision)) / (10 * settings.precision)
365
- : Math.round(displayPercent)
366
- ;
367
- },
368
-
369
- percent: function(index) {
370
- return module.percent && module.percent[index || 0] || 0;
371
- },
372
- value: function(index) {
373
- return module.nextValue || module.value && module.value[index || 0] || 0;
374
- },
375
- total: function() {
376
- return module.total !== undefined ? module.total : false;
377
- }
378
- },
948
+ label: 'percent',
949
+ precision: 0,
950
+ framerate: (1000 / 30), /// 30 fps
379
951
 
380
- create: {
381
- progressPoll: function() {
382
- module.progressPoll = setTimeout(function() {
383
- module.update.toNextValue();
384
- module.remove.progressPoll();
385
- }, module.get.updateInterval());
386
- },
387
- },
952
+ percent: false,
953
+ total: false,
954
+ value: false,
388
955
 
389
- is: {
390
- complete: function() {
391
- return module.is.success() || module.is.warning() || module.is.error();
392
- },
393
- success: function() {
394
- return $module.hasClass(className.success);
395
- },
396
- warning: function() {
397
- return $module.hasClass(className.warning);
398
- },
399
- error: function() {
400
- return $module.hasClass(className.error);
401
- },
402
- active: function() {
403
- return $module.hasClass(className.active);
404
- },
405
- visible: function() {
406
- return $module.is(':visible');
407
- }
408
- },
956
+ // delay in ms for fail safe animation callback
957
+ failSafeDelay: 100,
409
958
 
410
- remove: {
411
- progressPoll: function() {
412
- module.verbose('Removing progress poll timer');
413
- if(module.progressPoll) {
414
- clearTimeout(module.progressPoll);
415
- delete module.progressPoll;
416
- }
417
- },
418
- nextValue: function() {
419
- module.verbose('Removing progress value stored for next update');
420
- delete module.nextValue;
421
- },
422
- state: function() {
423
- module.verbose('Removing stored state');
424
- delete module.total;
425
- delete module.percent;
426
- delete module.value;
427
- },
428
- active: function() {
429
- module.verbose('Removing active state');
430
- $module.removeClass(className.active);
431
- },
432
- success: function() {
433
- module.verbose('Removing success state');
434
- $module.removeClass(className.success);
435
- },
436
- warning: function() {
437
- module.verbose('Removing warning state');
438
- $module.removeClass(className.warning);
439
- },
440
- error: function() {
441
- module.verbose('Removing error state');
442
- $module.removeClass(className.error);
443
- }
959
+ onLabelUpdate: function (state, text, value, total) {
960
+ return text;
444
961
  },
445
-
446
- set: {
447
- barWidth: function(values) {
448
- module.debug("set bar width with ", values);
449
- values = module.helper.forceArray(values);
450
- var firstNonZeroIndex = -1;
451
- var lastNonZeroIndex = -1;
452
- var valuesSum = module.helper.sum(values);
453
- var barCounts = $bars.length;
454
- var isMultiple = barCounts > 1;
455
- var percents = values.map(function(value, index) {
456
- var allZero = (index === barCounts - 1 && valuesSum === 0);
457
- var $bar = $($bars[index]);
458
- if (value === 0 && isMultiple && !allZero) {
459
- $bar.css('display', 'none');
460
- } else {
461
- if (isMultiple && allZero) {
462
- $bar.css('background', 'transparent');
463
- }
464
- if (firstNonZeroIndex == -1) {
465
- firstNonZeroIndex = index;
466
- }
467
- lastNonZeroIndex = index;
468
- $bar.css({
469
- display: 'block',
470
- width: value + '%'
471
- });
472
- }
473
- return parseFloat(value);
474
- });
475
- values.forEach(function(_, index) {
476
- var $bar = $($bars[index]);
477
- $bar.css({
478
- borderTopLeftRadius: index == firstNonZeroIndex ? '' : '0',
479
- borderBottomLeftRadius: index == firstNonZeroIndex ? '' : '0',
480
- borderTopRightRadius: index == lastNonZeroIndex ? '' : '0',
481
- borderBottomRightRadius: index == lastNonZeroIndex ? '' : '0'
482
- });
483
- });
484
- $module
485
- .attr('data-percent', percents)
486
- ;
487
- },
488
- duration: function(duration) {
489
- duration = duration || settings.duration;
490
- duration = (typeof duration == 'number')
491
- ? duration + 'ms'
492
- : duration
493
- ;
494
- module.verbose('Setting progress bar transition duration', duration);
495
- $bars
496
- .css({
497
- 'transition-duration': duration
498
- })
499
- ;
500
- },
501
- percent: function(percents) {
502
- percents = module.helper.forceArray(percents).map(function(percent) {
503
- percent = (typeof percent == 'string')
504
- ? +(percent.replace('%', ''))
505
- : percent
506
- ;
507
- return (settings.limitValues)
508
- ? Math.max(0, Math.min(100, percent))
509
- : percent
510
- ;
511
- });
512
- var hasTotal = module.has.total();
513
- var totalPercent = module.helper.sum(percents);
514
- var isMultipleValues = percents.length > 1 && hasTotal;
515
- var sumTotal = module.helper.sum(module.helper.forceArray(module.value));
516
- if (isMultipleValues && sumTotal > module.total) {
517
- // Sum values instead of pecents to avoid precision issues when summing floats
518
- module.error(error.sumExceedsTotal, sumTotal, module.total);
519
- } else if (!isMultipleValues && totalPercent > 100) {
520
- // Sum before rounding since sum of rounded may have error though sum of actual is fine
521
- module.error(error.tooHigh, totalPercent);
522
- } else if (totalPercent < 0) {
523
- module.error(error.tooLow, totalPercent);
524
- } else {
525
- var autoPrecision = settings.precision > 0
526
- ? settings.precision
527
- : isMultipleValues
528
- ? module.helper.derivePrecision(Math.min.apply(null, module.value), module.total)
529
- : 0;
530
-
531
- // round display percentage
532
- var roundedPercents = percents.map(function (percent) {
533
- return (autoPrecision > 0)
534
- ? Math.round(percent * (10 * autoPrecision)) / (10 * autoPrecision)
535
- : Math.round(percent)
536
- ;
537
- });
538
- module.percent = roundedPercents;
539
- if (hasTotal) {
540
- module.value = percents.map(function (percent) {
541
- return (autoPrecision > 0)
542
- ? Math.round((percent / 100) * module.total * (10 * autoPrecision)) / (10 * autoPrecision)
543
- : Math.round((percent / 100) * module.total * 10) / 10
544
- ;
545
- });
546
- }
547
- module.set.barWidth(percents);
548
- module.set.labelInterval();
549
- }
550
- settings.onChange.call(element, percents, module.value, module.total);
551
- },
552
- labelInterval: function() {
553
- var
554
- animationCallback = function() {
555
- module.verbose('Bar finished animating, removing continuous label updates');
556
- clearInterval(module.interval);
557
- animating = false;
558
- module.set.labels();
559
- }
560
- ;
561
- clearInterval(module.interval);
562
- module.bind.transitionEnd(animationCallback);
563
- animating = true;
564
- module.interval = setInterval(function() {
565
- var
566
- isInDOM = $.contains(document.documentElement, element)
567
- ;
568
- if(!isInDOM) {
569
- clearInterval(module.interval);
570
- animating = false;
571
- }
572
- module.set.labels();
573
- }, settings.framerate);
574
- },
575
- labels: function() {
576
- module.verbose('Setting both bar progress and outer label text');
577
- module.set.barLabel();
578
- module.set.state();
579
- },
580
- label: function(text) {
581
- text = text || '';
582
- if(text) {
583
- text = module.get.text(text);
584
- module.verbose('Setting label to text', text);
585
- $label.text(text);
586
- }
587
- },
588
- state: function(percent) {
589
- percent = (percent !== undefined)
590
- ? percent
591
- : module.helper.sum(module.percent)
592
- ;
593
- if(percent === 100) {
594
- if(settings.autoSuccess && $bars.length === 1 && !(module.is.warning() || module.is.error() || module.is.success())) {
595
- module.set.success();
596
- module.debug('Automatically triggering success at 100%');
597
- }
598
- else {
599
- module.verbose('Reached 100% removing active state');
600
- module.remove.active();
601
- module.remove.progressPoll();
602
- }
603
- }
604
- else if(percent > 0) {
605
- module.verbose('Adjusting active progress bar label', percent);
606
- module.set.active();
607
- }
608
- else {
609
- module.remove.active();
610
- module.remove.warning();
611
- module.remove.error();
612
- module.remove.success();
613
- module.set.label(settings.text.active);
614
- }
615
- },
616
- barLabel: function(text) {
617
- $progresses.map(function(index, element){
618
- var $progress = $(element);
619
- if (text !== undefined) {
620
- $progress.text( module.get.text(text, index) );
621
- }
622
- else if (settings.label == 'ratio' && module.has.total()) {
623
- module.verbose('Adding ratio to bar label');
624
- $progress.text( module.get.text(settings.text.ratio, index) );
625
- }
626
- else if (settings.label == 'percent') {
627
- module.verbose('Adding percentage to bar label');
628
- $progress.text( module.get.text(settings.text.percent, index) );
629
- }
630
- });
631
- },
632
- active: function(text) {
633
- text = text || settings.text.active;
634
- module.debug('Setting active state');
635
- if(settings.showActivity && !module.is.active() ) {
636
- $module.addClass(className.active);
637
- }
638
- module.remove.warning();
639
- module.remove.error();
640
- module.remove.success();
641
- text = settings.onLabelUpdate('active', text, module.value, module.total);
642
- if(text) {
643
- module.set.label(text);
644
- }
645
- module.bind.transitionEnd(function() {
646
- settings.onActive.call(element, module.value, module.total);
647
- });
648
- },
649
- success : function(text, keepState) {
650
- text = text || settings.text.success || settings.text.active;
651
- module.debug('Setting success state');
652
- $module.addClass(className.success);
653
- module.remove.active();
654
- module.remove.warning();
655
- module.remove.error();
656
- module.complete(keepState);
657
- if(settings.text.success) {
658
- text = settings.onLabelUpdate('success', text, module.value, module.total);
659
- module.set.label(text);
660
- }
661
- else {
662
- text = settings.onLabelUpdate('active', text, module.value, module.total);
663
- module.set.label(text);
664
- }
665
- module.bind.transitionEnd(function() {
666
- settings.onSuccess.call(element, module.total);
667
- });
668
- },
669
- warning : function(text, keepState) {
670
- text = text || settings.text.warning;
671
- module.debug('Setting warning state');
672
- $module.addClass(className.warning);
673
- module.remove.active();
674
- module.remove.success();
675
- module.remove.error();
676
- module.complete(keepState);
677
- text = settings.onLabelUpdate('warning', text, module.value, module.total);
678
- if(text) {
679
- module.set.label(text);
680
- }
681
- module.bind.transitionEnd(function() {
682
- settings.onWarning.call(element, module.value, module.total);
683
- });
684
- },
685
- error : function(text, keepState) {
686
- text = text || settings.text.error;
687
- module.debug('Setting error state');
688
- $module.addClass(className.error);
689
- module.remove.active();
690
- module.remove.success();
691
- module.remove.warning();
692
- module.complete(keepState);
693
- text = settings.onLabelUpdate('error', text, module.value, module.total);
694
- if(text) {
695
- module.set.label(text);
696
- }
697
- module.bind.transitionEnd(function() {
698
- settings.onError.call(element, module.value, module.total);
699
- });
700
- },
701
- transitionEvent: function() {
702
- transitionEnd = module.get.transitionEnd();
703
- },
704
- total: function(totalValue) {
705
- module.total = totalValue;
706
- },
707
- value: function(value) {
708
- module.value = module.helper.forceArray(value);
709
- },
710
- progress: function(value) {
711
- if(!module.has.progressPoll()) {
712
- module.debug('First update in progress update interval, immediately updating', value);
713
- module.update.progress(value);
714
- module.create.progressPoll();
715
- }
716
- else {
717
- module.debug('Updated within interval, setting next update to use new value', value);
718
- module.set.nextValue(value);
719
- }
720
- },
721
- nextValue: function(value) {
722
- module.nextValue = value;
723
- }
962
+ onChange: function (percent, value, total) {},
963
+ onSuccess: function (total) {},
964
+ onActive: function (value, total) {},
965
+ onError: function (value, total) {},
966
+ onWarning: function (value, total) {},
967
+
968
+ error: {
969
+ method: 'The method you called is not defined.',
970
+ nonNumeric: 'Progress value is non numeric',
971
+ tooHigh: 'Value specified is above 100%',
972
+ tooLow: 'Value specified is below 0%',
973
+ sumExceedsTotal: 'Sum of multiple values exceed total',
724
974
  },
725
975
 
726
- update: {
727
- toNextValue: function() {
728
- var
729
- nextValue = module.nextValue
730
- ;
731
- if(nextValue) {
732
- module.debug('Update interval complete using last updated value', nextValue);
733
- module.update.progress(nextValue);
734
- module.remove.nextValue();
735
- }
736
- },
737
- progress: function(values) {
738
- var hasTotal = module.has.total();
739
- if (hasTotal) {
740
- module.set.value(values);
741
- }
742
- var percentCompletes = module.helper.forceArray(values).map(function(value) {
743
- var
744
- percentComplete
745
- ;
746
- value = module.get.numericValue(value);
747
- if (value === false) {
748
- module.error(error.nonNumeric, value);
749
- }
750
- value = module.get.normalizedValue(value);
751
- if (hasTotal) {
752
- percentComplete = module.total > 0 ? (value / module.total) * 100 : 100;
753
- module.debug('Calculating percent complete from total', percentComplete);
754
- }
755
- else {
756
- percentComplete = value;
757
- module.debug('Setting value to exact percentage value', percentComplete);
758
- }
759
- return percentComplete;
760
- });
761
- module.set.percent( percentCompletes );
762
- }
976
+ regExp: {
977
+ variable: /\{\$*[a-z0-9]+\}/gi,
763
978
  },
764
979
 
765
- setting: function(name, value) {
766
- module.debug('Changing setting', name, value);
767
- if( $.isPlainObject(name) ) {
768
- $.extend(true, settings, name);
769
- }
770
- else if(value !== undefined) {
771
- if($.isPlainObject(settings[name])) {
772
- $.extend(true, settings[name], value);
773
- }
774
- else {
775
- settings[name] = value;
776
- }
777
- }
778
- else {
779
- return settings[name];
780
- }
980
+ metadata: {
981
+ percent: 'percent',
982
+ total: 'total',
983
+ value: 'value',
781
984
  },
782
- internal: function(name, value) {
783
- if( $.isPlainObject(name) ) {
784
- $.extend(true, module, name);
785
- }
786
- else if(value !== undefined) {
787
- module[name] = value;
788
- }
789
- else {
790
- return module[name];
791
- }
792
- },
793
- debug: function() {
794
- if(!settings.silent && settings.debug) {
795
- if(settings.performance) {
796
- module.performance.log(arguments);
797
- }
798
- else {
799
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
800
- module.debug.apply(console, arguments);
801
- }
802
- }
803
- },
804
- verbose: function() {
805
- if(!settings.silent && settings.verbose && settings.debug) {
806
- if(settings.performance) {
807
- module.performance.log(arguments);
808
- }
809
- else {
810
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
811
- module.verbose.apply(console, arguments);
812
- }
813
- }
985
+
986
+ selector: {
987
+ bar: '> .bar',
988
+ label: '> .label',
989
+ progress: '.bar > .progress',
814
990
  },
815
- error: function() {
816
- if(!settings.silent) {
817
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
818
- module.error.apply(console, arguments);
819
- }
991
+
992
+ text: {
993
+ active: false,
994
+ error: false,
995
+ success: false,
996
+ warning: false,
997
+ percent: '{percent}%',
998
+ ratio: '{value} of {total}',
999
+ bars: [''],
820
1000
  },
821
- performance: {
822
- log: function(message) {
823
- var
824
- currentTime,
825
- executionTime,
826
- previousTime
827
- ;
828
- if(settings.performance) {
829
- currentTime = new Date().getTime();
830
- previousTime = time || currentTime;
831
- executionTime = currentTime - previousTime;
832
- time = currentTime;
833
- performance.push({
834
- 'Name' : message[0],
835
- 'Arguments' : [].slice.call(message, 1) || '',
836
- 'Element' : element,
837
- 'Execution Time' : executionTime
838
- });
839
- }
840
- clearTimeout(module.performance.timer);
841
- module.performance.timer = setTimeout(module.performance.display, 500);
842
- },
843
- display: function() {
844
- var
845
- title = settings.name + ':',
846
- totalTime = 0
847
- ;
848
- time = false;
849
- clearTimeout(module.performance.timer);
850
- $.each(performance, function(index, data) {
851
- totalTime += data['Execution Time'];
852
- });
853
- title += ' ' + totalTime + 'ms';
854
- if(moduleSelector) {
855
- title += ' \'' + moduleSelector + '\'';
856
- }
857
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
858
- console.groupCollapsed(title);
859
- if(console.table) {
860
- console.table(performance);
861
- }
862
- else {
863
- $.each(performance, function(index, data) {
864
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
865
- });
866
- }
867
- console.groupEnd();
868
- }
869
- performance = [];
870
- }
1001
+
1002
+ className: {
1003
+ active: 'active',
1004
+ error: 'error',
1005
+ success: 'success',
1006
+ warning: 'warning',
871
1007
  },
872
- invoke: function(query, passedArguments, context) {
873
- var
874
- object = instance,
875
- maxDepth,
876
- found,
877
- response
878
- ;
879
- passedArguments = passedArguments || queryArguments;
880
- context = context || element;
881
- if(typeof query == 'string' && object !== undefined) {
882
- query = query.split(/[\. ]/);
883
- maxDepth = query.length - 1;
884
- $.each(query, function(depth, value) {
885
- var camelCaseValue = (depth != maxDepth)
886
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
887
- : query
888
- ;
889
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
890
- object = object[camelCaseValue];
891
- }
892
- else if( object[camelCaseValue] !== undefined ) {
893
- found = object[camelCaseValue];
894
- return false;
895
- }
896
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
897
- object = object[value];
898
- }
899
- else if( object[value] !== undefined ) {
900
- found = object[value];
901
- return false;
902
- }
903
- else {
904
- module.error(error.method, query);
905
- return false;
906
- }
907
- });
908
- }
909
- if ( isFunction( found ) ) {
910
- response = found.apply(context, passedArguments);
911
- }
912
- else if(found !== undefined) {
913
- response = found;
914
- }
915
- if(Array.isArray(returnedValue)) {
916
- returnedValue.push(response);
917
- }
918
- else if(returnedValue !== undefined) {
919
- returnedValue = [returnedValue, response];
920
- }
921
- else if(response !== undefined) {
922
- returnedValue = response;
923
- }
924
- return found;
925
- }
926
- };
927
-
928
- if(methodInvoked) {
929
- if(instance === undefined) {
930
- module.initialize();
931
- }
932
- module.invoke(query);
933
- }
934
- else {
935
- if(instance !== undefined) {
936
- instance.invoke('destroy');
937
- }
938
- module.initialize();
939
- }
940
- })
941
- ;
942
-
943
- return (returnedValue !== undefined)
944
- ? returnedValue
945
- : this
946
- ;
947
- };
948
-
949
- $.fn.progress.settings = {
950
-
951
- name : 'Progress',
952
- namespace : 'progress',
953
-
954
- silent : false,
955
- debug : false,
956
- verbose : false,
957
- performance : true,
958
-
959
- random : {
960
- min : 2,
961
- max : 5
962
- },
963
-
964
- duration : 300,
965
-
966
- updateInterval : 'auto',
967
-
968
- autoSuccess : true,
969
- showActivity : true,
970
- limitValues : true,
971
-
972
- label : 'percent',
973
- precision : 0,
974
- framerate : (1000 / 30), /// 30 fps
975
-
976
- percent : false,
977
- total : false,
978
- value : false,
979
-
980
- // delay in ms for fail safe animation callback
981
- failSafeDelay : 100,
982
-
983
- onLabelUpdate : function(state, text, value, total){
984
- return text;
985
- },
986
- onChange : function(percent, value, total){},
987
- onSuccess : function(total){},
988
- onActive : function(value, total){},
989
- onError : function(value, total){},
990
- onWarning : function(value, total){},
991
-
992
- error : {
993
- method : 'The method you called is not defined.',
994
- nonNumeric : 'Progress value is non numeric',
995
- tooHigh : 'Value specified is above 100%',
996
- tooLow : 'Value specified is below 0%',
997
- sumExceedsTotal : 'Sum of multiple values exceed total',
998
- },
999
-
1000
- regExp: {
1001
- variable: /\{\$*[a-z0-9]+\}/gi
1002
- },
1003
-
1004
- metadata: {
1005
- percent : 'percent',
1006
- total : 'total',
1007
- value : 'value'
1008
- },
1009
-
1010
- selector : {
1011
- bar : '> .bar',
1012
- label : '> .label',
1013
- progress : '.bar > .progress'
1014
- },
1015
-
1016
- text : {
1017
- active : false,
1018
- error : false,
1019
- success : false,
1020
- warning : false,
1021
- percent : '{percent}%',
1022
- ratio : '{value} of {total}',
1023
- bars : ['']
1024
- },
1025
-
1026
- className : {
1027
- active : 'active',
1028
- error : 'error',
1029
- success : 'success',
1030
- warning : 'warning'
1031
- }
1032
-
1033
- };
1034
-
1035
-
1036
- })( jQuery, window, document );
1008
+
1009
+ };
1010
+ })(jQuery, window, document);