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