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