fomantic-ui-sass 2.8.8.1 → 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/CHANGELOG.md +4 -0
- 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.eot +0 -0
- data/app/assets/fonts/semantic-ui/brand-icons.svg +41 -6
- data/app/assets/fonts/semantic-ui/brand-icons.ttf +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.eot +0 -0
- data/app/assets/fonts/semantic-ui/icons.svg +245 -7
- data/app/assets/fonts/semantic-ui/icons.ttf +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.eot +0 -0
- data/app/assets/fonts/semantic-ui/outline-icons.svg +2 -2
- data/app/assets/fonts/semantic-ui/outline-icons.ttf +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 -590
- data/app/assets/javascripts/semantic-ui/api.js +1153 -1116
- data/app/assets/javascripts/semantic-ui/calendar.js +1941 -1698
- data/app/assets/javascripts/semantic-ui/checkbox.js +862 -854
- data/app/assets/javascripts/semantic-ui/dimmer.js +697 -713
- data/app/assets/javascripts/semantic-ui/dropdown.js +4196 -4192
- data/app/assets/javascripts/semantic-ui/embed.js +646 -672
- data/app/assets/javascripts/semantic-ui/flyout.js +1579 -0
- data/app/assets/javascripts/semantic-ui/form.js +2024 -2000
- data/app/assets/javascripts/semantic-ui/modal.js +1546 -1384
- data/app/assets/javascripts/semantic-ui/nag.js +521 -527
- data/app/assets/javascripts/semantic-ui/popup.js +1457 -1463
- data/app/assets/javascripts/semantic-ui/progress.js +970 -995
- data/app/assets/javascripts/semantic-ui/rating.js +508 -520
- data/app/assets/javascripts/semantic-ui/search.js +1521 -1508
- data/app/assets/javascripts/semantic-ui/shape.js +784 -811
- data/app/assets/javascripts/semantic-ui/sidebar.js +1061 -1002
- data/app/assets/javascripts/semantic-ui/site.js +437 -477
- data/app/assets/javascripts/semantic-ui/slider.js +1311 -1297
- data/app/assets/javascripts/semantic-ui/state.js +639 -658
- data/app/assets/javascripts/semantic-ui/sticky.js +848 -891
- data/app/assets/javascripts/semantic-ui/tab.js +895 -941
- data/app/assets/javascripts/semantic-ui/toast.js +911 -851
- data/app/assets/javascripts/semantic-ui/transition.js +1049 -1073
- 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 +389 -407
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +203 -345
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +372 -501
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +154 -226
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +2065 -880
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +867 -1232
- data/app/assets/stylesheets/semantic-ui/elements/_container.scss +101 -6
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +75 -93
- data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +11148 -9190
- data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1037 -929
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +124 -146
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +2728 -2759
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +41 -65
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +982 -163
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +432 -479
- data/app/assets/stylesheets/semantic-ui/elements/_list.scss +80 -101
- data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +452 -540
- data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +56 -76
- 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 +263 -255
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +106 -179
- data/app/assets/stylesheets/semantic-ui/elements/_text.scss +33 -33
- data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +14 -18
- data/app/assets/stylesheets/semantic-ui/globals/_site.scss +132 -48
- data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +196 -74
- data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +43 -29
- data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +210 -280
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +78 -182
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +339 -423
- data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +24 -35
- data/app/assets/stylesheets/semantic-ui/modules/_flyout.scss +546 -0
- data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +150 -153
- data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +55 -65
- data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +530 -310
- data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +108 -213
- data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +88 -168
- data/app/assets/stylesheets/semantic-ui/modules/_search.scss +73 -102
- data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +16 -32
- data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +126 -215
- data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +110 -138
- data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +3 -7
- data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +16 -20
- data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +111 -141
- data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +371 -1282
- data/app/assets/stylesheets/semantic-ui/views/_ad.scss +39 -50
- data/app/assets/stylesheets/semantic-ui/views/_card.scss +949 -458
- data/app/assets/stylesheets/semantic-ui/views/_comment.scss +44 -62
- data/app/assets/stylesheets/semantic-ui/views/_feed.scss +50 -72
- data/app/assets/stylesheets/semantic-ui/views/_item.scss +89 -136
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +78 -119
- data/lib/fomantic/ui/sass/version.rb +2 -2
- data/tasks/converter.rb +1 -1
- metadata +21 -3
@@ -1,1033 +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 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
|
-
|
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.set.label(settings.text.active);
|
611
|
-
}
|
612
|
-
},
|
613
|
-
barLabel: function(text) {
|
614
|
-
$progresses.map(function(index, element){
|
615
|
-
var $progress = $(element);
|
616
|
-
if (text !== undefined) {
|
617
|
-
$progress.text( module.get.text(text, index) );
|
618
|
-
}
|
619
|
-
else if (settings.label == 'ratio' && module.has.total()) {
|
620
|
-
module.verbose('Adding ratio to bar label');
|
621
|
-
$progress.text( module.get.text(settings.text.ratio, index) );
|
622
|
-
}
|
623
|
-
else if (settings.label == 'percent') {
|
624
|
-
module.verbose('Adding percentage to bar label');
|
625
|
-
$progress.text( module.get.text(settings.text.percent, index) );
|
626
|
-
}
|
627
|
-
});
|
628
|
-
},
|
629
|
-
active: function(text) {
|
630
|
-
text = text || settings.text.active;
|
631
|
-
module.debug('Setting active state');
|
632
|
-
if(settings.showActivity && !module.is.active() ) {
|
633
|
-
$module.addClass(className.active);
|
634
|
-
}
|
635
|
-
module.remove.warning();
|
636
|
-
module.remove.error();
|
637
|
-
module.remove.success();
|
638
|
-
text = settings.onLabelUpdate('active', text, module.value, module.total);
|
639
|
-
if(text) {
|
640
|
-
module.set.label(text);
|
641
|
-
}
|
642
|
-
module.bind.transitionEnd(function() {
|
643
|
-
settings.onActive.call(element, module.value, module.total);
|
644
|
-
});
|
645
|
-
},
|
646
|
-
success : function(text, keepState) {
|
647
|
-
text = text || settings.text.success || settings.text.active;
|
648
|
-
module.debug('Setting success state');
|
649
|
-
$module.addClass(className.success);
|
650
|
-
module.remove.active();
|
651
|
-
module.remove.warning();
|
652
|
-
module.remove.error();
|
653
|
-
module.complete(keepState);
|
654
|
-
if(settings.text.success) {
|
655
|
-
text = settings.onLabelUpdate('success', text, module.value, module.total);
|
656
|
-
module.set.label(text);
|
657
|
-
}
|
658
|
-
else {
|
659
|
-
text = settings.onLabelUpdate('active', text, module.value, module.total);
|
660
|
-
module.set.label(text);
|
661
|
-
}
|
662
|
-
module.bind.transitionEnd(function() {
|
663
|
-
settings.onSuccess.call(element, module.total);
|
664
|
-
});
|
665
|
-
},
|
666
|
-
warning : function(text, keepState) {
|
667
|
-
text = text || settings.text.warning;
|
668
|
-
module.debug('Setting warning state');
|
669
|
-
$module.addClass(className.warning);
|
670
|
-
module.remove.active();
|
671
|
-
module.remove.success();
|
672
|
-
module.remove.error();
|
673
|
-
module.complete(keepState);
|
674
|
-
text = settings.onLabelUpdate('warning', text, module.value, module.total);
|
675
|
-
if(text) {
|
676
|
-
module.set.label(text);
|
677
|
-
}
|
678
|
-
module.bind.transitionEnd(function() {
|
679
|
-
settings.onWarning.call(element, module.value, module.total);
|
680
|
-
});
|
681
|
-
},
|
682
|
-
error : function(text, keepState) {
|
683
|
-
text = text || settings.text.error;
|
684
|
-
module.debug('Setting error state');
|
685
|
-
$module.addClass(className.error);
|
686
|
-
module.remove.active();
|
687
|
-
module.remove.success();
|
688
|
-
module.remove.warning();
|
689
|
-
module.complete(keepState);
|
690
|
-
text = settings.onLabelUpdate('error', text, module.value, module.total);
|
691
|
-
if(text) {
|
692
|
-
module.set.label(text);
|
693
|
-
}
|
694
|
-
module.bind.transitionEnd(function() {
|
695
|
-
settings.onError.call(element, module.value, module.total);
|
696
|
-
});
|
697
|
-
},
|
698
|
-
transitionEvent: function() {
|
699
|
-
transitionEnd = module.get.transitionEnd();
|
700
|
-
},
|
701
|
-
total: function(totalValue) {
|
702
|
-
module.total = totalValue;
|
703
|
-
},
|
704
|
-
value: function(value) {
|
705
|
-
module.value = module.helper.forceArray(value);
|
706
|
-
},
|
707
|
-
progress: function(value) {
|
708
|
-
if(!module.has.progressPoll()) {
|
709
|
-
module.debug('First update in progress update interval, immediately updating', value);
|
710
|
-
module.update.progress(value);
|
711
|
-
module.create.progressPoll();
|
712
|
-
}
|
713
|
-
else {
|
714
|
-
module.debug('Updated within interval, setting next update to use new value', value);
|
715
|
-
module.set.nextValue(value);
|
716
|
-
}
|
717
|
-
},
|
718
|
-
nextValue: function(value) {
|
719
|
-
module.nextValue = value;
|
720
|
-
}
|
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',
|
721
972
|
},
|
722
973
|
|
723
|
-
|
724
|
-
|
725
|
-
var
|
726
|
-
nextValue = module.nextValue
|
727
|
-
;
|
728
|
-
if(nextValue) {
|
729
|
-
module.debug('Update interval complete using last updated value', nextValue);
|
730
|
-
module.update.progress(nextValue);
|
731
|
-
module.remove.nextValue();
|
732
|
-
}
|
733
|
-
},
|
734
|
-
progress: function(values) {
|
735
|
-
var hasTotal = module.has.total();
|
736
|
-
if (hasTotal) {
|
737
|
-
module.set.value(values);
|
738
|
-
}
|
739
|
-
var percentCompletes = module.helper.forceArray(values).map(function(value) {
|
740
|
-
var
|
741
|
-
percentComplete
|
742
|
-
;
|
743
|
-
value = module.get.numericValue(value);
|
744
|
-
if (value === false) {
|
745
|
-
module.error(error.nonNumeric, value);
|
746
|
-
}
|
747
|
-
value = module.get.normalizedValue(value);
|
748
|
-
if (hasTotal) {
|
749
|
-
percentComplete = module.total > 0 ? (value / module.total) * 100 : 100;
|
750
|
-
module.debug('Calculating percent complete from total', percentComplete);
|
751
|
-
}
|
752
|
-
else {
|
753
|
-
percentComplete = value;
|
754
|
-
module.debug('Setting value to exact percentage value', percentComplete);
|
755
|
-
}
|
756
|
-
return percentComplete;
|
757
|
-
});
|
758
|
-
module.set.percent( percentCompletes );
|
759
|
-
}
|
974
|
+
regExp: {
|
975
|
+
variable: /{\$*[\da-z]+}/gi,
|
760
976
|
},
|
761
977
|
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
}
|
767
|
-
else if(value !== undefined) {
|
768
|
-
if($.isPlainObject(settings[name])) {
|
769
|
-
$.extend(true, settings[name], value);
|
770
|
-
}
|
771
|
-
else {
|
772
|
-
settings[name] = value;
|
773
|
-
}
|
774
|
-
}
|
775
|
-
else {
|
776
|
-
return settings[name];
|
777
|
-
}
|
978
|
+
metadata: {
|
979
|
+
percent: 'percent',
|
980
|
+
total: 'total',
|
981
|
+
value: 'value',
|
778
982
|
},
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
module[name] = value;
|
785
|
-
}
|
786
|
-
else {
|
787
|
-
return module[name];
|
788
|
-
}
|
789
|
-
},
|
790
|
-
debug: function() {
|
791
|
-
if(!settings.silent && settings.debug) {
|
792
|
-
if(settings.performance) {
|
793
|
-
module.performance.log(arguments);
|
794
|
-
}
|
795
|
-
else {
|
796
|
-
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
797
|
-
module.debug.apply(console, arguments);
|
798
|
-
}
|
799
|
-
}
|
800
|
-
},
|
801
|
-
verbose: function() {
|
802
|
-
if(!settings.silent && settings.verbose && settings.debug) {
|
803
|
-
if(settings.performance) {
|
804
|
-
module.performance.log(arguments);
|
805
|
-
}
|
806
|
-
else {
|
807
|
-
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
808
|
-
module.verbose.apply(console, arguments);
|
809
|
-
}
|
810
|
-
}
|
983
|
+
|
984
|
+
selector: {
|
985
|
+
bar: '> .bar',
|
986
|
+
label: '> .label',
|
987
|
+
progress: '.bar > .progress',
|
811
988
|
},
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
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: [''],
|
817
998
|
},
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
;
|
825
|
-
if(settings.performance) {
|
826
|
-
currentTime = new Date().getTime();
|
827
|
-
previousTime = time || currentTime;
|
828
|
-
executionTime = currentTime - previousTime;
|
829
|
-
time = currentTime;
|
830
|
-
performance.push({
|
831
|
-
'Name' : message[0],
|
832
|
-
'Arguments' : [].slice.call(message, 1) || '',
|
833
|
-
'Element' : element,
|
834
|
-
'Execution Time' : executionTime
|
835
|
-
});
|
836
|
-
}
|
837
|
-
clearTimeout(module.performance.timer);
|
838
|
-
module.performance.timer = setTimeout(module.performance.display, 500);
|
839
|
-
},
|
840
|
-
display: function() {
|
841
|
-
var
|
842
|
-
title = settings.name + ':',
|
843
|
-
totalTime = 0
|
844
|
-
;
|
845
|
-
time = false;
|
846
|
-
clearTimeout(module.performance.timer);
|
847
|
-
$.each(performance, function(index, data) {
|
848
|
-
totalTime += data['Execution Time'];
|
849
|
-
});
|
850
|
-
title += ' ' + totalTime + 'ms';
|
851
|
-
if(moduleSelector) {
|
852
|
-
title += ' \'' + moduleSelector + '\'';
|
853
|
-
}
|
854
|
-
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
855
|
-
console.groupCollapsed(title);
|
856
|
-
if(console.table) {
|
857
|
-
console.table(performance);
|
858
|
-
}
|
859
|
-
else {
|
860
|
-
$.each(performance, function(index, data) {
|
861
|
-
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
862
|
-
});
|
863
|
-
}
|
864
|
-
console.groupEnd();
|
865
|
-
}
|
866
|
-
performance = [];
|
867
|
-
}
|
999
|
+
|
1000
|
+
className: {
|
1001
|
+
active: 'active',
|
1002
|
+
error: 'error',
|
1003
|
+
success: 'success',
|
1004
|
+
warning: 'warning',
|
868
1005
|
},
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
maxDepth,
|
873
|
-
found,
|
874
|
-
response
|
875
|
-
;
|
876
|
-
passedArguments = passedArguments || queryArguments;
|
877
|
-
context = element || context;
|
878
|
-
if(typeof query == 'string' && object !== undefined) {
|
879
|
-
query = query.split(/[\. ]/);
|
880
|
-
maxDepth = query.length - 1;
|
881
|
-
$.each(query, function(depth, value) {
|
882
|
-
var camelCaseValue = (depth != maxDepth)
|
883
|
-
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
884
|
-
: query
|
885
|
-
;
|
886
|
-
if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
|
887
|
-
object = object[camelCaseValue];
|
888
|
-
}
|
889
|
-
else if( object[camelCaseValue] !== undefined ) {
|
890
|
-
found = object[camelCaseValue];
|
891
|
-
return false;
|
892
|
-
}
|
893
|
-
else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
|
894
|
-
object = object[value];
|
895
|
-
}
|
896
|
-
else if( object[value] !== undefined ) {
|
897
|
-
found = object[value];
|
898
|
-
return false;
|
899
|
-
}
|
900
|
-
else {
|
901
|
-
module.error(error.method, query);
|
902
|
-
return false;
|
903
|
-
}
|
904
|
-
});
|
905
|
-
}
|
906
|
-
if ( $.isFunction( found ) ) {
|
907
|
-
response = found.apply(context, passedArguments);
|
908
|
-
}
|
909
|
-
else if(found !== undefined) {
|
910
|
-
response = found;
|
911
|
-
}
|
912
|
-
if(Array.isArray(returnedValue)) {
|
913
|
-
returnedValue.push(response);
|
914
|
-
}
|
915
|
-
else if(returnedValue !== undefined) {
|
916
|
-
returnedValue = [returnedValue, response];
|
917
|
-
}
|
918
|
-
else if(response !== undefined) {
|
919
|
-
returnedValue = response;
|
920
|
-
}
|
921
|
-
return found;
|
922
|
-
}
|
923
|
-
};
|
924
|
-
|
925
|
-
if(methodInvoked) {
|
926
|
-
if(instance === undefined) {
|
927
|
-
module.initialize();
|
928
|
-
}
|
929
|
-
module.invoke(query);
|
930
|
-
}
|
931
|
-
else {
|
932
|
-
if(instance !== undefined) {
|
933
|
-
instance.invoke('destroy');
|
934
|
-
}
|
935
|
-
module.initialize();
|
936
|
-
}
|
937
|
-
})
|
938
|
-
;
|
939
|
-
|
940
|
-
return (returnedValue !== undefined)
|
941
|
-
? returnedValue
|
942
|
-
: this
|
943
|
-
;
|
944
|
-
};
|
945
|
-
|
946
|
-
$.fn.progress.settings = {
|
947
|
-
|
948
|
-
name : 'Progress',
|
949
|
-
namespace : 'progress',
|
950
|
-
|
951
|
-
silent : false,
|
952
|
-
debug : false,
|
953
|
-
verbose : false,
|
954
|
-
performance : true,
|
955
|
-
|
956
|
-
random : {
|
957
|
-
min : 2,
|
958
|
-
max : 5
|
959
|
-
},
|
960
|
-
|
961
|
-
duration : 300,
|
962
|
-
|
963
|
-
updateInterval : 'auto',
|
964
|
-
|
965
|
-
autoSuccess : true,
|
966
|
-
showActivity : true,
|
967
|
-
limitValues : true,
|
968
|
-
|
969
|
-
label : 'percent',
|
970
|
-
precision : 0,
|
971
|
-
framerate : (1000 / 30), /// 30 fps
|
972
|
-
|
973
|
-
percent : false,
|
974
|
-
total : false,
|
975
|
-
value : false,
|
976
|
-
|
977
|
-
// delay in ms for fail safe animation callback
|
978
|
-
failSafeDelay : 100,
|
979
|
-
|
980
|
-
onLabelUpdate : function(state, text, value, total){
|
981
|
-
return text;
|
982
|
-
},
|
983
|
-
onChange : function(percent, value, total){},
|
984
|
-
onSuccess : function(total){},
|
985
|
-
onActive : function(value, total){},
|
986
|
-
onError : function(value, total){},
|
987
|
-
onWarning : function(value, total){},
|
988
|
-
|
989
|
-
error : {
|
990
|
-
method : 'The method you called is not defined.',
|
991
|
-
nonNumeric : 'Progress value is non numeric',
|
992
|
-
tooHigh : 'Value specified is above 100%',
|
993
|
-
tooLow : 'Value specified is below 0%',
|
994
|
-
sumExceedsTotal : 'Sum of multple values exceed total',
|
995
|
-
},
|
996
|
-
|
997
|
-
regExp: {
|
998
|
-
variable: /\{\$*[A-z0-9]+\}/g
|
999
|
-
},
|
1000
|
-
|
1001
|
-
metadata: {
|
1002
|
-
percent : 'percent',
|
1003
|
-
total : 'total',
|
1004
|
-
value : 'value'
|
1005
|
-
},
|
1006
|
-
|
1007
|
-
selector : {
|
1008
|
-
bar : '> .bar',
|
1009
|
-
label : '> .label',
|
1010
|
-
progress : '.bar > .progress'
|
1011
|
-
},
|
1012
|
-
|
1013
|
-
text : {
|
1014
|
-
active : false,
|
1015
|
-
error : false,
|
1016
|
-
success : false,
|
1017
|
-
warning : false,
|
1018
|
-
percent : '{percent}%',
|
1019
|
-
ratio : '{value} of {total}',
|
1020
|
-
bars : ['']
|
1021
|
-
},
|
1022
|
-
|
1023
|
-
className : {
|
1024
|
-
active : 'active',
|
1025
|
-
error : 'error',
|
1026
|
-
success : 'success',
|
1027
|
-
warning : 'warning'
|
1028
|
-
}
|
1029
|
-
|
1030
|
-
};
|
1031
|
-
|
1032
|
-
|
1033
|
-
})( jQuery, window, document );
|
1006
|
+
|
1007
|
+
};
|
1008
|
+
})(jQuery, window, document);
|