fomantic-ui-sass 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +370 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +177 -0
- data/Rakefile +8 -0
- data/app/assets/fonts/semantic-ui/brand-icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/brand-icons.svg +1008 -0
- 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.otf +0 -0
- data/app/assets/fonts/semantic-ui/icons.svg +1518 -0
- 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 +366 -0
- 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/images/semantic-ui/flags.png +0 -0
- data/app/assets/javascripts/semantic-ui.js +27 -0
- data/app/assets/javascripts/semantic-ui/accordion.js +613 -0
- data/app/assets/javascripts/semantic-ui/api.js +1167 -0
- data/app/assets/javascripts/semantic-ui/calendar.js +1476 -0
- data/app/assets/javascripts/semantic-ui/checkbox.js +828 -0
- data/app/assets/javascripts/semantic-ui/colorize.js +280 -0
- data/app/assets/javascripts/semantic-ui/dimmer.js +735 -0
- data/app/assets/javascripts/semantic-ui/dropdown.js +4030 -0
- data/app/assets/javascripts/semantic-ui/embed.js +706 -0
- data/app/assets/javascripts/semantic-ui/form.js +1707 -0
- data/app/assets/javascripts/semantic-ui/modal.js +1090 -0
- data/app/assets/javascripts/semantic-ui/nag.js +507 -0
- data/app/assets/javascripts/semantic-ui/popup.js +1532 -0
- data/app/assets/javascripts/semantic-ui/progress.js +923 -0
- data/app/assets/javascripts/semantic-ui/range.js +278 -0
- data/app/assets/javascripts/semantic-ui/rating.js +511 -0
- data/app/assets/javascripts/semantic-ui/search.js +1515 -0
- data/app/assets/javascripts/semantic-ui/shape.js +921 -0
- data/app/assets/javascripts/semantic-ui/sidebar.js +1033 -0
- data/app/assets/javascripts/semantic-ui/site.js +490 -0
- data/app/assets/javascripts/semantic-ui/state.js +708 -0
- data/app/assets/javascripts/semantic-ui/sticky.js +959 -0
- data/app/assets/javascripts/semantic-ui/tab.js +952 -0
- data/app/assets/javascripts/semantic-ui/toast.js +592 -0
- data/app/assets/javascripts/semantic-ui/transition.js +1106 -0
- data/app/assets/javascripts/semantic-ui/video.js +532 -0
- data/app/assets/javascripts/semantic-ui/visibility.js +1311 -0
- data/app/assets/javascripts/semantic-ui/visit.js +525 -0
- data/app/assets/stylesheets/semantic-ui.scss +5 -0
- data/app/assets/stylesheets/semantic-ui/collections/_all.scss +6 -0
- data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +124 -0
- data/app/assets/stylesheets/semantic-ui/collections/_form.scss +1158 -0
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +2093 -0
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +2193 -0
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +606 -0
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +1117 -0
- data/app/assets/stylesheets/semantic-ui/elements/_all.scss +16 -0
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +4530 -0
- data/app/assets/stylesheets/semantic-ui/elements/_container.scss +145 -0
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +259 -0
- data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1036 -0
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +762 -0
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +6330 -0
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +310 -0
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +519 -0
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +1395 -0
- data/app/assets/stylesheets/semantic-ui/elements/_list.scss +959 -0
- data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +458 -0
- data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +242 -0
- data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +152 -0
- data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +295 -0
- data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +884 -0
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +675 -0
- data/app/assets/stylesheets/semantic-ui/globals/_all.scss +3 -0
- data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +485 -0
- data/app/assets/stylesheets/semantic-ui/globals/_site.scss +206 -0
- data/app/assets/stylesheets/semantic-ui/globals/_variables.scss +4 -0
- data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +247 -0
- data/app/assets/stylesheets/semantic-ui/modules/_all.scss +20 -0
- data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +165 -0
- data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +718 -0
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +464 -0
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +1745 -0
- data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +165 -0
- data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +646 -0
- data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +148 -0
- data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +789 -0
- data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +523 -0
- data/app/assets/stylesheets/semantic-ui/modules/_range.scss +192 -0
- data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +263 -0
- data/app/assets/stylesheets/semantic-ui/modules/_search.scss +445 -0
- data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +154 -0
- data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +626 -0
- data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +78 -0
- data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +92 -0
- data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +291 -0
- data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +2059 -0
- data/app/assets/stylesheets/semantic-ui/modules/_video.scss +125 -0
- data/app/assets/stylesheets/semantic-ui/views/_ad.scss +275 -0
- data/app/assets/stylesheets/semantic-ui/views/_all.scss +6 -0
- data/app/assets/stylesheets/semantic-ui/views/_card.scss +1124 -0
- data/app/assets/stylesheets/semantic-ui/views/_comment.scss +296 -0
- data/app/assets/stylesheets/semantic-ui/views/_feed.scss +314 -0
- data/app/assets/stylesheets/semantic-ui/views/_item.scss +555 -0
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +583 -0
- data/app/helpers/semantic_breadcrumbs_helper.rb +10 -0
- data/app/helpers/semantic_flash_helper.rb +22 -0
- data/app/helpers/semantic_icon_helper.rb +8 -0
- data/app/views/semantic/_breadcrumbs.html.erb +12 -0
- data/fomantic-ui-sass.gemspec +31 -0
- data/lib/fomantic-ui-sass.rb +62 -0
- data/lib/fomantic/ui/sass/breadcrumbs.rb +41 -0
- data/lib/fomantic/ui/sass/engine.rb +23 -0
- data/lib/fomantic/ui/sass/version.rb +8 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/semantic_breadcrumbs_helper_spec.rb +38 -0
- data/spec/helpers/semantic_flash_helper_spec.rb +36 -0
- data/spec/helpers/semantic_icon_helper_spec.rb +48 -0
- data/spec/spec_helper.rb +17 -0
- data/tasks/converter.rb +216 -0
- data/templates/project/manifest.rb +29 -0
- data/templates/project/styles.scss +1 -0
- metadata +390 -0
@@ -0,0 +1,923 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI - Progress
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Released under the MIT license
|
7
|
+
* http://opensource.org/licenses/MIT
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
;(function ($, window, document, undefined) {
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
window = (typeof window != 'undefined' && window.Math == Math)
|
16
|
+
? window
|
17
|
+
: (typeof self != 'undefined' && self.Math == Math)
|
18
|
+
? self
|
19
|
+
: Function('return this')()
|
20
|
+
;
|
21
|
+
|
22
|
+
$.fn.progress = function(parameters) {
|
23
|
+
var
|
24
|
+
$allModules = $(this),
|
25
|
+
|
26
|
+
moduleSelector = $allModules.selector || '',
|
27
|
+
|
28
|
+
time = new Date().getTime(),
|
29
|
+
performance = [],
|
30
|
+
|
31
|
+
query = arguments[0],
|
32
|
+
methodInvoked = (typeof query == 'string'),
|
33
|
+
queryArguments = [].slice.call(arguments, 1),
|
34
|
+
|
35
|
+
returnedValue
|
36
|
+
;
|
37
|
+
|
38
|
+
$allModules
|
39
|
+
.each(function() {
|
40
|
+
var
|
41
|
+
settings = ( $.isPlainObject(parameters) )
|
42
|
+
? $.extend(true, {}, $.fn.progress.settings, parameters)
|
43
|
+
: $.extend({}, $.fn.progress.settings),
|
44
|
+
|
45
|
+
className = settings.className,
|
46
|
+
metadata = settings.metadata,
|
47
|
+
namespace = settings.namespace,
|
48
|
+
selector = settings.selector,
|
49
|
+
error = settings.error,
|
50
|
+
|
51
|
+
eventNamespace = '.' + namespace,
|
52
|
+
moduleNamespace = 'module-' + namespace,
|
53
|
+
|
54
|
+
$module = $(this),
|
55
|
+
$bar = $(this).find(selector.bar),
|
56
|
+
$progress = $(this).find(selector.progress),
|
57
|
+
$label = $(this).find(selector.label),
|
58
|
+
|
59
|
+
element = this,
|
60
|
+
instance = $module.data(moduleNamespace),
|
61
|
+
|
62
|
+
animating = false,
|
63
|
+
transitionEnd,
|
64
|
+
module
|
65
|
+
;
|
66
|
+
|
67
|
+
module = {
|
68
|
+
|
69
|
+
initialize: function() {
|
70
|
+
module.debug('Initializing progress bar', settings);
|
71
|
+
|
72
|
+
module.set.duration();
|
73
|
+
module.set.transitionEvent();
|
74
|
+
|
75
|
+
module.read.metadata();
|
76
|
+
module.read.settings();
|
77
|
+
|
78
|
+
module.instantiate();
|
79
|
+
},
|
80
|
+
|
81
|
+
instantiate: function() {
|
82
|
+
module.verbose('Storing instance of progress', module);
|
83
|
+
instance = module;
|
84
|
+
$module
|
85
|
+
.data(moduleNamespace, module)
|
86
|
+
;
|
87
|
+
},
|
88
|
+
destroy: function() {
|
89
|
+
module.verbose('Destroying previous progress for', $module);
|
90
|
+
clearInterval(instance.interval);
|
91
|
+
module.remove.state();
|
92
|
+
$module.removeData(moduleNamespace);
|
93
|
+
instance = undefined;
|
94
|
+
},
|
95
|
+
|
96
|
+
reset: function() {
|
97
|
+
module.remove.nextValue();
|
98
|
+
module.update.progress(0);
|
99
|
+
},
|
100
|
+
|
101
|
+
complete: function() {
|
102
|
+
if(module.percent === undefined || module.percent < 100) {
|
103
|
+
module.remove.progressPoll();
|
104
|
+
module.set.percent(100);
|
105
|
+
}
|
106
|
+
},
|
107
|
+
|
108
|
+
read: {
|
109
|
+
metadata: function() {
|
110
|
+
var
|
111
|
+
data = {
|
112
|
+
percent : $module.data(metadata.percent),
|
113
|
+
total : $module.data(metadata.total),
|
114
|
+
value : $module.data(metadata.value)
|
115
|
+
}
|
116
|
+
;
|
117
|
+
if(data.percent) {
|
118
|
+
module.debug('Current percent value set from metadata', data.percent);
|
119
|
+
module.set.percent(data.percent);
|
120
|
+
}
|
121
|
+
if(data.total) {
|
122
|
+
module.debug('Total value set from metadata', data.total);
|
123
|
+
module.set.total(data.total);
|
124
|
+
}
|
125
|
+
if(data.value) {
|
126
|
+
module.debug('Current value set from metadata', data.value);
|
127
|
+
module.set.value(data.value);
|
128
|
+
module.set.progress(data.value);
|
129
|
+
}
|
130
|
+
},
|
131
|
+
settings: function() {
|
132
|
+
if(settings.total !== false) {
|
133
|
+
module.debug('Current total set in settings', settings.total);
|
134
|
+
module.set.total(settings.total);
|
135
|
+
}
|
136
|
+
if(settings.value !== false) {
|
137
|
+
module.debug('Current value set in settings', settings.value);
|
138
|
+
module.set.value(settings.value);
|
139
|
+
module.set.progress(module.value);
|
140
|
+
}
|
141
|
+
if(settings.percent !== false) {
|
142
|
+
module.debug('Current percent set in settings', settings.percent);
|
143
|
+
module.set.percent(settings.percent);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
},
|
147
|
+
|
148
|
+
bind: {
|
149
|
+
transitionEnd: function(callback) {
|
150
|
+
var
|
151
|
+
transitionEnd = module.get.transitionEnd()
|
152
|
+
;
|
153
|
+
$bar
|
154
|
+
.one(transitionEnd + eventNamespace, function(event) {
|
155
|
+
clearTimeout(module.failSafeTimer);
|
156
|
+
callback.call(this, event);
|
157
|
+
})
|
158
|
+
;
|
159
|
+
module.failSafeTimer = setTimeout(function() {
|
160
|
+
$bar.triggerHandler(transitionEnd);
|
161
|
+
}, settings.duration + settings.failSafeDelay);
|
162
|
+
module.verbose('Adding fail safe timer', module.timer);
|
163
|
+
}
|
164
|
+
},
|
165
|
+
|
166
|
+
increment: function(incrementValue) {
|
167
|
+
var
|
168
|
+
maxValue,
|
169
|
+
startValue,
|
170
|
+
newValue
|
171
|
+
;
|
172
|
+
if( module.has.total() ) {
|
173
|
+
startValue = module.get.value();
|
174
|
+
incrementValue = incrementValue || 1;
|
175
|
+
newValue = startValue + incrementValue;
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
startValue = module.get.percent();
|
179
|
+
incrementValue = incrementValue || module.get.randomValue();
|
180
|
+
|
181
|
+
newValue = startValue + incrementValue;
|
182
|
+
maxValue = 100;
|
183
|
+
module.debug('Incrementing percentage by', startValue, newValue);
|
184
|
+
}
|
185
|
+
newValue = module.get.normalizedValue(newValue);
|
186
|
+
module.set.progress(newValue);
|
187
|
+
},
|
188
|
+
decrement: function(decrementValue) {
|
189
|
+
var
|
190
|
+
total = module.get.total(),
|
191
|
+
startValue,
|
192
|
+
newValue
|
193
|
+
;
|
194
|
+
if(total) {
|
195
|
+
startValue = module.get.value();
|
196
|
+
decrementValue = decrementValue || 1;
|
197
|
+
newValue = startValue - decrementValue;
|
198
|
+
module.debug('Decrementing value by', decrementValue, startValue);
|
199
|
+
}
|
200
|
+
else {
|
201
|
+
startValue = module.get.percent();
|
202
|
+
decrementValue = decrementValue || module.get.randomValue();
|
203
|
+
newValue = startValue - decrementValue;
|
204
|
+
module.debug('Decrementing percentage by', decrementValue, startValue);
|
205
|
+
}
|
206
|
+
newValue = module.get.normalizedValue(newValue);
|
207
|
+
module.set.progress(newValue);
|
208
|
+
},
|
209
|
+
|
210
|
+
has: {
|
211
|
+
progressPoll: function() {
|
212
|
+
return module.progressPoll;
|
213
|
+
},
|
214
|
+
total: function() {
|
215
|
+
return (module.get.total() !== false);
|
216
|
+
}
|
217
|
+
},
|
218
|
+
|
219
|
+
get: {
|
220
|
+
text: function(templateText) {
|
221
|
+
var
|
222
|
+
value = module.value || 0,
|
223
|
+
total = module.total || 0,
|
224
|
+
percent = (animating)
|
225
|
+
? module.get.displayPercent()
|
226
|
+
: module.percent || 0,
|
227
|
+
left = (module.total > 0)
|
228
|
+
? (total - value)
|
229
|
+
: (100 - percent)
|
230
|
+
;
|
231
|
+
templateText = templateText || '';
|
232
|
+
templateText = templateText
|
233
|
+
.replace('{value}', value)
|
234
|
+
.replace('{total}', total)
|
235
|
+
.replace('{left}', left)
|
236
|
+
.replace('{percent}', percent)
|
237
|
+
;
|
238
|
+
module.verbose('Adding variables to progress bar text', templateText);
|
239
|
+
return templateText;
|
240
|
+
},
|
241
|
+
|
242
|
+
normalizedValue: function(value) {
|
243
|
+
if(value < 0) {
|
244
|
+
module.debug('Value cannot decrement below 0');
|
245
|
+
return 0;
|
246
|
+
}
|
247
|
+
if(module.has.total()) {
|
248
|
+
if(value > module.total) {
|
249
|
+
module.debug('Value cannot increment above total', module.total);
|
250
|
+
return module.total;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
else if(value > 100 ) {
|
254
|
+
module.debug('Value cannot increment above 100 percent');
|
255
|
+
return 100;
|
256
|
+
}
|
257
|
+
return value;
|
258
|
+
},
|
259
|
+
|
260
|
+
updateInterval: function() {
|
261
|
+
if(settings.updateInterval == 'auto') {
|
262
|
+
return settings.duration;
|
263
|
+
}
|
264
|
+
return settings.updateInterval;
|
265
|
+
},
|
266
|
+
|
267
|
+
randomValue: function() {
|
268
|
+
module.debug('Generating random increment percentage');
|
269
|
+
return Math.floor((Math.random() * settings.random.max) + settings.random.min);
|
270
|
+
},
|
271
|
+
|
272
|
+
numericValue: function(value) {
|
273
|
+
return (typeof value === 'string')
|
274
|
+
? (value.replace(/[^\d.]/g, '') !== '')
|
275
|
+
? +(value.replace(/[^\d.]/g, ''))
|
276
|
+
: false
|
277
|
+
: value
|
278
|
+
;
|
279
|
+
},
|
280
|
+
|
281
|
+
transitionEnd: function() {
|
282
|
+
var
|
283
|
+
element = document.createElement('element'),
|
284
|
+
transitions = {
|
285
|
+
'transition' :'transitionend',
|
286
|
+
'OTransition' :'oTransitionEnd',
|
287
|
+
'MozTransition' :'transitionend',
|
288
|
+
'WebkitTransition' :'webkitTransitionEnd'
|
289
|
+
},
|
290
|
+
transition
|
291
|
+
;
|
292
|
+
for(transition in transitions){
|
293
|
+
if( element.style[transition] !== undefined ){
|
294
|
+
return transitions[transition];
|
295
|
+
}
|
296
|
+
}
|
297
|
+
},
|
298
|
+
|
299
|
+
// gets current displayed percentage (if animating values this is the intermediary value)
|
300
|
+
displayPercent: function() {
|
301
|
+
var
|
302
|
+
barWidth = $bar.width(),
|
303
|
+
totalWidth = $module.width(),
|
304
|
+
minDisplay = parseInt($bar.css('min-width'), 10),
|
305
|
+
displayPercent = (barWidth > minDisplay)
|
306
|
+
? (barWidth / totalWidth * 100)
|
307
|
+
: module.percent
|
308
|
+
;
|
309
|
+
return (settings.precision > 0)
|
310
|
+
? Math.round(displayPercent * (10 * settings.precision)) / (10 * settings.precision)
|
311
|
+
: Math.round(displayPercent)
|
312
|
+
;
|
313
|
+
},
|
314
|
+
|
315
|
+
percent: function() {
|
316
|
+
return module.percent || 0;
|
317
|
+
},
|
318
|
+
value: function() {
|
319
|
+
return module.nextValue || module.value || 0;
|
320
|
+
},
|
321
|
+
total: function() {
|
322
|
+
return module.total || false;
|
323
|
+
}
|
324
|
+
},
|
325
|
+
|
326
|
+
create: {
|
327
|
+
progressPoll: function() {
|
328
|
+
module.progressPoll = setTimeout(function() {
|
329
|
+
module.update.toNextValue();
|
330
|
+
module.remove.progressPoll();
|
331
|
+
}, module.get.updateInterval());
|
332
|
+
},
|
333
|
+
},
|
334
|
+
|
335
|
+
is: {
|
336
|
+
complete: function() {
|
337
|
+
return module.is.success() || module.is.warning() || module.is.error();
|
338
|
+
},
|
339
|
+
success: function() {
|
340
|
+
return $module.hasClass(className.success);
|
341
|
+
},
|
342
|
+
warning: function() {
|
343
|
+
return $module.hasClass(className.warning);
|
344
|
+
},
|
345
|
+
error: function() {
|
346
|
+
return $module.hasClass(className.error);
|
347
|
+
},
|
348
|
+
active: function() {
|
349
|
+
return $module.hasClass(className.active);
|
350
|
+
},
|
351
|
+
visible: function() {
|
352
|
+
return $module.is(':visible');
|
353
|
+
}
|
354
|
+
},
|
355
|
+
|
356
|
+
remove: {
|
357
|
+
progressPoll: function() {
|
358
|
+
module.verbose('Removing progress poll timer');
|
359
|
+
if(module.progressPoll) {
|
360
|
+
clearTimeout(module.progressPoll);
|
361
|
+
delete module.progressPoll;
|
362
|
+
}
|
363
|
+
},
|
364
|
+
nextValue: function() {
|
365
|
+
module.verbose('Removing progress value stored for next update');
|
366
|
+
delete module.nextValue;
|
367
|
+
},
|
368
|
+
state: function() {
|
369
|
+
module.verbose('Removing stored state');
|
370
|
+
delete module.total;
|
371
|
+
delete module.percent;
|
372
|
+
delete module.value;
|
373
|
+
},
|
374
|
+
active: function() {
|
375
|
+
module.verbose('Removing active state');
|
376
|
+
$module.removeClass(className.active);
|
377
|
+
},
|
378
|
+
success: function() {
|
379
|
+
module.verbose('Removing success state');
|
380
|
+
$module.removeClass(className.success);
|
381
|
+
},
|
382
|
+
warning: function() {
|
383
|
+
module.verbose('Removing warning state');
|
384
|
+
$module.removeClass(className.warning);
|
385
|
+
},
|
386
|
+
error: function() {
|
387
|
+
module.verbose('Removing error state');
|
388
|
+
$module.removeClass(className.error);
|
389
|
+
}
|
390
|
+
},
|
391
|
+
|
392
|
+
set: {
|
393
|
+
barWidth: function(value) {
|
394
|
+
if(value > 100) {
|
395
|
+
module.error(error.tooHigh, value);
|
396
|
+
}
|
397
|
+
else if (value < 0) {
|
398
|
+
module.error(error.tooLow, value);
|
399
|
+
}
|
400
|
+
else {
|
401
|
+
$bar
|
402
|
+
.css('width', value + '%')
|
403
|
+
;
|
404
|
+
$module
|
405
|
+
.attr('data-percent', parseInt(value, 10))
|
406
|
+
;
|
407
|
+
}
|
408
|
+
},
|
409
|
+
duration: function(duration) {
|
410
|
+
duration = duration || settings.duration;
|
411
|
+
duration = (typeof duration == 'number')
|
412
|
+
? duration + 'ms'
|
413
|
+
: duration
|
414
|
+
;
|
415
|
+
module.verbose('Setting progress bar transition duration', duration);
|
416
|
+
$bar
|
417
|
+
.css({
|
418
|
+
'transition-duration': duration
|
419
|
+
})
|
420
|
+
;
|
421
|
+
},
|
422
|
+
percent: function(percent) {
|
423
|
+
percent = (typeof percent == 'string')
|
424
|
+
? +(percent.replace('%', ''))
|
425
|
+
: percent
|
426
|
+
;
|
427
|
+
// round display percentage
|
428
|
+
percent = (settings.precision > 0)
|
429
|
+
? Math.round(percent * (10 * settings.precision)) / (10 * settings.precision)
|
430
|
+
: Math.round(percent)
|
431
|
+
;
|
432
|
+
module.percent = percent;
|
433
|
+
if( !module.has.total() ) {
|
434
|
+
module.value = (settings.precision > 0)
|
435
|
+
? Math.round( (percent / 100) * module.total * (10 * settings.precision)) / (10 * settings.precision)
|
436
|
+
: Math.round( (percent / 100) * module.total * 10) / 10
|
437
|
+
;
|
438
|
+
if(settings.limitValues) {
|
439
|
+
module.value = (module.value > 100)
|
440
|
+
? 100
|
441
|
+
: (module.value < 0)
|
442
|
+
? 0
|
443
|
+
: module.value
|
444
|
+
;
|
445
|
+
}
|
446
|
+
}
|
447
|
+
module.set.barWidth(percent);
|
448
|
+
module.set.labelInterval();
|
449
|
+
module.set.labels();
|
450
|
+
settings.onChange.call(element, percent, module.value, module.total);
|
451
|
+
},
|
452
|
+
labelInterval: function() {
|
453
|
+
var
|
454
|
+
animationCallback = function() {
|
455
|
+
module.verbose('Bar finished animating, removing continuous label updates');
|
456
|
+
clearInterval(module.interval);
|
457
|
+
animating = false;
|
458
|
+
module.set.labels();
|
459
|
+
}
|
460
|
+
;
|
461
|
+
clearInterval(module.interval);
|
462
|
+
module.bind.transitionEnd(animationCallback);
|
463
|
+
animating = true;
|
464
|
+
module.interval = setInterval(function() {
|
465
|
+
var
|
466
|
+
isInDOM = $.contains(document.documentElement, element)
|
467
|
+
;
|
468
|
+
if(!isInDOM) {
|
469
|
+
clearInterval(module.interval);
|
470
|
+
animating = false;
|
471
|
+
}
|
472
|
+
module.set.labels();
|
473
|
+
}, settings.framerate);
|
474
|
+
},
|
475
|
+
labels: function() {
|
476
|
+
module.verbose('Setting both bar progress and outer label text');
|
477
|
+
module.set.barLabel();
|
478
|
+
module.set.state();
|
479
|
+
},
|
480
|
+
label: function(text) {
|
481
|
+
text = text || '';
|
482
|
+
if(text) {
|
483
|
+
text = module.get.text(text);
|
484
|
+
module.verbose('Setting label to text', text);
|
485
|
+
$label.text(text);
|
486
|
+
}
|
487
|
+
},
|
488
|
+
state: function(percent) {
|
489
|
+
percent = (percent !== undefined)
|
490
|
+
? percent
|
491
|
+
: module.percent
|
492
|
+
;
|
493
|
+
if(percent === 100) {
|
494
|
+
if(settings.autoSuccess && !(module.is.warning() || module.is.error() || module.is.success())) {
|
495
|
+
module.set.success();
|
496
|
+
module.debug('Automatically triggering success at 100%');
|
497
|
+
}
|
498
|
+
else {
|
499
|
+
module.verbose('Reached 100% removing active state');
|
500
|
+
module.remove.active();
|
501
|
+
module.remove.progressPoll();
|
502
|
+
}
|
503
|
+
}
|
504
|
+
else if(percent > 0) {
|
505
|
+
module.verbose('Adjusting active progress bar label', percent);
|
506
|
+
module.set.active();
|
507
|
+
}
|
508
|
+
else {
|
509
|
+
module.remove.active();
|
510
|
+
module.set.label(settings.text.active);
|
511
|
+
}
|
512
|
+
},
|
513
|
+
barLabel: function(text) {
|
514
|
+
if(text !== undefined) {
|
515
|
+
$progress.text( module.get.text(text) );
|
516
|
+
}
|
517
|
+
else if(settings.label == 'ratio' && module.total) {
|
518
|
+
module.verbose('Adding ratio to bar label');
|
519
|
+
$progress.text( module.get.text(settings.text.ratio) );
|
520
|
+
}
|
521
|
+
else if(settings.label == 'percent') {
|
522
|
+
module.verbose('Adding percentage to bar label');
|
523
|
+
$progress.text( module.get.text(settings.text.percent) );
|
524
|
+
}
|
525
|
+
},
|
526
|
+
active: function(text) {
|
527
|
+
text = text || settings.text.active;
|
528
|
+
module.debug('Setting active state');
|
529
|
+
if(settings.showActivity && !module.is.active() ) {
|
530
|
+
$module.addClass(className.active);
|
531
|
+
}
|
532
|
+
module.remove.warning();
|
533
|
+
module.remove.error();
|
534
|
+
module.remove.success();
|
535
|
+
text = settings.onLabelUpdate('active', text, module.value, module.total);
|
536
|
+
if(text) {
|
537
|
+
module.set.label(text);
|
538
|
+
}
|
539
|
+
module.bind.transitionEnd(function() {
|
540
|
+
settings.onActive.call(element, module.value, module.total);
|
541
|
+
});
|
542
|
+
},
|
543
|
+
success : function(text) {
|
544
|
+
text = text || settings.text.success || settings.text.active;
|
545
|
+
module.debug('Setting success state');
|
546
|
+
$module.addClass(className.success);
|
547
|
+
module.remove.active();
|
548
|
+
module.remove.warning();
|
549
|
+
module.remove.error();
|
550
|
+
module.complete();
|
551
|
+
if(settings.text.success) {
|
552
|
+
text = settings.onLabelUpdate('success', text, module.value, module.total);
|
553
|
+
module.set.label(text);
|
554
|
+
}
|
555
|
+
else {
|
556
|
+
text = settings.onLabelUpdate('active', text, module.value, module.total);
|
557
|
+
module.set.label(text);
|
558
|
+
}
|
559
|
+
module.bind.transitionEnd(function() {
|
560
|
+
settings.onSuccess.call(element, module.total);
|
561
|
+
});
|
562
|
+
},
|
563
|
+
warning : function(text) {
|
564
|
+
text = text || settings.text.warning;
|
565
|
+
module.debug('Setting warning state');
|
566
|
+
$module.addClass(className.warning);
|
567
|
+
module.remove.active();
|
568
|
+
module.remove.success();
|
569
|
+
module.remove.error();
|
570
|
+
module.complete();
|
571
|
+
text = settings.onLabelUpdate('warning', text, module.value, module.total);
|
572
|
+
if(text) {
|
573
|
+
module.set.label(text);
|
574
|
+
}
|
575
|
+
module.bind.transitionEnd(function() {
|
576
|
+
settings.onWarning.call(element, module.value, module.total);
|
577
|
+
});
|
578
|
+
},
|
579
|
+
error : function(text) {
|
580
|
+
text = text || settings.text.error;
|
581
|
+
module.debug('Setting error state');
|
582
|
+
$module.addClass(className.error);
|
583
|
+
module.remove.active();
|
584
|
+
module.remove.success();
|
585
|
+
module.remove.warning();
|
586
|
+
module.complete();
|
587
|
+
text = settings.onLabelUpdate('error', text, module.value, module.total);
|
588
|
+
if(text) {
|
589
|
+
module.set.label(text);
|
590
|
+
}
|
591
|
+
module.bind.transitionEnd(function() {
|
592
|
+
settings.onError.call(element, module.value, module.total);
|
593
|
+
});
|
594
|
+
},
|
595
|
+
transitionEvent: function() {
|
596
|
+
transitionEnd = module.get.transitionEnd();
|
597
|
+
},
|
598
|
+
total: function(totalValue) {
|
599
|
+
module.total = totalValue;
|
600
|
+
},
|
601
|
+
value: function(value) {
|
602
|
+
module.value = value;
|
603
|
+
},
|
604
|
+
progress: function(value) {
|
605
|
+
if(!module.has.progressPoll()) {
|
606
|
+
module.debug('First update in progress update interval, immediately updating', value);
|
607
|
+
module.update.progress(value);
|
608
|
+
module.create.progressPoll();
|
609
|
+
}
|
610
|
+
else {
|
611
|
+
module.debug('Updated within interval, setting next update to use new value', value);
|
612
|
+
module.set.nextValue(value);
|
613
|
+
}
|
614
|
+
},
|
615
|
+
nextValue: function(value) {
|
616
|
+
module.nextValue = value;
|
617
|
+
}
|
618
|
+
},
|
619
|
+
|
620
|
+
update: {
|
621
|
+
toNextValue: function() {
|
622
|
+
var
|
623
|
+
nextValue = module.nextValue
|
624
|
+
;
|
625
|
+
if(nextValue) {
|
626
|
+
module.debug('Update interval complete using last updated value', nextValue);
|
627
|
+
module.update.progress(nextValue);
|
628
|
+
module.remove.nextValue();
|
629
|
+
}
|
630
|
+
},
|
631
|
+
progress: function(value) {
|
632
|
+
var
|
633
|
+
percentComplete
|
634
|
+
;
|
635
|
+
value = module.get.numericValue(value);
|
636
|
+
if(value === false) {
|
637
|
+
module.error(error.nonNumeric, value);
|
638
|
+
}
|
639
|
+
value = module.get.normalizedValue(value);
|
640
|
+
if( module.has.total() ) {
|
641
|
+
module.set.value(value);
|
642
|
+
percentComplete = (value / module.total) * 100;
|
643
|
+
module.debug('Calculating percent complete from total', percentComplete);
|
644
|
+
module.set.percent( percentComplete );
|
645
|
+
}
|
646
|
+
else {
|
647
|
+
percentComplete = value;
|
648
|
+
module.debug('Setting value to exact percentage value', percentComplete);
|
649
|
+
module.set.percent( percentComplete );
|
650
|
+
}
|
651
|
+
}
|
652
|
+
},
|
653
|
+
|
654
|
+
setting: function(name, value) {
|
655
|
+
module.debug('Changing setting', name, value);
|
656
|
+
if( $.isPlainObject(name) ) {
|
657
|
+
$.extend(true, settings, name);
|
658
|
+
}
|
659
|
+
else if(value !== undefined) {
|
660
|
+
if($.isPlainObject(settings[name])) {
|
661
|
+
$.extend(true, settings[name], value);
|
662
|
+
}
|
663
|
+
else {
|
664
|
+
settings[name] = value;
|
665
|
+
}
|
666
|
+
}
|
667
|
+
else {
|
668
|
+
return settings[name];
|
669
|
+
}
|
670
|
+
},
|
671
|
+
internal: function(name, value) {
|
672
|
+
if( $.isPlainObject(name) ) {
|
673
|
+
$.extend(true, module, name);
|
674
|
+
}
|
675
|
+
else if(value !== undefined) {
|
676
|
+
module[name] = value;
|
677
|
+
}
|
678
|
+
else {
|
679
|
+
return module[name];
|
680
|
+
}
|
681
|
+
},
|
682
|
+
debug: function() {
|
683
|
+
if(!settings.silent && settings.debug) {
|
684
|
+
if(settings.performance) {
|
685
|
+
module.performance.log(arguments);
|
686
|
+
}
|
687
|
+
else {
|
688
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
689
|
+
module.debug.apply(console, arguments);
|
690
|
+
}
|
691
|
+
}
|
692
|
+
},
|
693
|
+
verbose: function() {
|
694
|
+
if(!settings.silent && settings.verbose && settings.debug) {
|
695
|
+
if(settings.performance) {
|
696
|
+
module.performance.log(arguments);
|
697
|
+
}
|
698
|
+
else {
|
699
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
700
|
+
module.verbose.apply(console, arguments);
|
701
|
+
}
|
702
|
+
}
|
703
|
+
},
|
704
|
+
error: function() {
|
705
|
+
if(!settings.silent) {
|
706
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
707
|
+
module.error.apply(console, arguments);
|
708
|
+
}
|
709
|
+
},
|
710
|
+
performance: {
|
711
|
+
log: function(message) {
|
712
|
+
var
|
713
|
+
currentTime,
|
714
|
+
executionTime,
|
715
|
+
previousTime
|
716
|
+
;
|
717
|
+
if(settings.performance) {
|
718
|
+
currentTime = new Date().getTime();
|
719
|
+
previousTime = time || currentTime;
|
720
|
+
executionTime = currentTime - previousTime;
|
721
|
+
time = currentTime;
|
722
|
+
performance.push({
|
723
|
+
'Name' : message[0],
|
724
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
725
|
+
'Element' : element,
|
726
|
+
'Execution Time' : executionTime
|
727
|
+
});
|
728
|
+
}
|
729
|
+
clearTimeout(module.performance.timer);
|
730
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
731
|
+
},
|
732
|
+
display: function() {
|
733
|
+
var
|
734
|
+
title = settings.name + ':',
|
735
|
+
totalTime = 0
|
736
|
+
;
|
737
|
+
time = false;
|
738
|
+
clearTimeout(module.performance.timer);
|
739
|
+
$.each(performance, function(index, data) {
|
740
|
+
totalTime += data['Execution Time'];
|
741
|
+
});
|
742
|
+
title += ' ' + totalTime + 'ms';
|
743
|
+
if(moduleSelector) {
|
744
|
+
title += ' \'' + moduleSelector + '\'';
|
745
|
+
}
|
746
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
747
|
+
console.groupCollapsed(title);
|
748
|
+
if(console.table) {
|
749
|
+
console.table(performance);
|
750
|
+
}
|
751
|
+
else {
|
752
|
+
$.each(performance, function(index, data) {
|
753
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
754
|
+
});
|
755
|
+
}
|
756
|
+
console.groupEnd();
|
757
|
+
}
|
758
|
+
performance = [];
|
759
|
+
}
|
760
|
+
},
|
761
|
+
invoke: function(query, passedArguments, context) {
|
762
|
+
var
|
763
|
+
object = instance,
|
764
|
+
maxDepth,
|
765
|
+
found,
|
766
|
+
response
|
767
|
+
;
|
768
|
+
passedArguments = passedArguments || queryArguments;
|
769
|
+
context = element || context;
|
770
|
+
if(typeof query == 'string' && object !== undefined) {
|
771
|
+
query = query.split(/[\. ]/);
|
772
|
+
maxDepth = query.length - 1;
|
773
|
+
$.each(query, function(depth, value) {
|
774
|
+
var camelCaseValue = (depth != maxDepth)
|
775
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
776
|
+
: query
|
777
|
+
;
|
778
|
+
if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
|
779
|
+
object = object[camelCaseValue];
|
780
|
+
}
|
781
|
+
else if( object[camelCaseValue] !== undefined ) {
|
782
|
+
found = object[camelCaseValue];
|
783
|
+
return false;
|
784
|
+
}
|
785
|
+
else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
|
786
|
+
object = object[value];
|
787
|
+
}
|
788
|
+
else if( object[value] !== undefined ) {
|
789
|
+
found = object[value];
|
790
|
+
return false;
|
791
|
+
}
|
792
|
+
else {
|
793
|
+
module.error(error.method, query);
|
794
|
+
return false;
|
795
|
+
}
|
796
|
+
});
|
797
|
+
}
|
798
|
+
if ( $.isFunction( found ) ) {
|
799
|
+
response = found.apply(context, passedArguments);
|
800
|
+
}
|
801
|
+
else if(found !== undefined) {
|
802
|
+
response = found;
|
803
|
+
}
|
804
|
+
if($.isArray(returnedValue)) {
|
805
|
+
returnedValue.push(response);
|
806
|
+
}
|
807
|
+
else if(returnedValue !== undefined) {
|
808
|
+
returnedValue = [returnedValue, response];
|
809
|
+
}
|
810
|
+
else if(response !== undefined) {
|
811
|
+
returnedValue = response;
|
812
|
+
}
|
813
|
+
return found;
|
814
|
+
}
|
815
|
+
};
|
816
|
+
|
817
|
+
if(methodInvoked) {
|
818
|
+
if(instance === undefined) {
|
819
|
+
module.initialize();
|
820
|
+
}
|
821
|
+
module.invoke(query);
|
822
|
+
}
|
823
|
+
else {
|
824
|
+
if(instance !== undefined) {
|
825
|
+
instance.invoke('destroy');
|
826
|
+
}
|
827
|
+
module.initialize();
|
828
|
+
}
|
829
|
+
})
|
830
|
+
;
|
831
|
+
|
832
|
+
return (returnedValue !== undefined)
|
833
|
+
? returnedValue
|
834
|
+
: this
|
835
|
+
;
|
836
|
+
};
|
837
|
+
|
838
|
+
$.fn.progress.settings = {
|
839
|
+
|
840
|
+
name : 'Progress',
|
841
|
+
namespace : 'progress',
|
842
|
+
|
843
|
+
silent : false,
|
844
|
+
debug : false,
|
845
|
+
verbose : false,
|
846
|
+
performance : true,
|
847
|
+
|
848
|
+
random : {
|
849
|
+
min : 2,
|
850
|
+
max : 5
|
851
|
+
},
|
852
|
+
|
853
|
+
duration : 300,
|
854
|
+
|
855
|
+
updateInterval : 'auto',
|
856
|
+
|
857
|
+
autoSuccess : true,
|
858
|
+
showActivity : true,
|
859
|
+
limitValues : true,
|
860
|
+
|
861
|
+
label : 'percent',
|
862
|
+
precision : 0,
|
863
|
+
framerate : (1000 / 30), /// 30 fps
|
864
|
+
|
865
|
+
percent : false,
|
866
|
+
total : false,
|
867
|
+
value : false,
|
868
|
+
|
869
|
+
// delay in ms for fail safe animation callback
|
870
|
+
failSafeDelay : 100,
|
871
|
+
|
872
|
+
onLabelUpdate : function(state, text, value, total){
|
873
|
+
return text;
|
874
|
+
},
|
875
|
+
onChange : function(percent, value, total){},
|
876
|
+
onSuccess : function(total){},
|
877
|
+
onActive : function(value, total){},
|
878
|
+
onError : function(value, total){},
|
879
|
+
onWarning : function(value, total){},
|
880
|
+
|
881
|
+
error : {
|
882
|
+
method : 'The method you called is not defined.',
|
883
|
+
nonNumeric : 'Progress value is non numeric',
|
884
|
+
tooHigh : 'Value specified is above 100%',
|
885
|
+
tooLow : 'Value specified is below 0%'
|
886
|
+
},
|
887
|
+
|
888
|
+
regExp: {
|
889
|
+
variable: /\{\$*[A-z0-9]+\}/g
|
890
|
+
},
|
891
|
+
|
892
|
+
metadata: {
|
893
|
+
percent : 'percent',
|
894
|
+
total : 'total',
|
895
|
+
value : 'value'
|
896
|
+
},
|
897
|
+
|
898
|
+
selector : {
|
899
|
+
bar : '> .bar',
|
900
|
+
label : '> .label',
|
901
|
+
progress : '.bar > .progress'
|
902
|
+
},
|
903
|
+
|
904
|
+
text : {
|
905
|
+
active : false,
|
906
|
+
error : false,
|
907
|
+
success : false,
|
908
|
+
warning : false,
|
909
|
+
percent : '{percent}%',
|
910
|
+
ratio : '{value} of {total}'
|
911
|
+
},
|
912
|
+
|
913
|
+
className : {
|
914
|
+
active : 'active',
|
915
|
+
error : 'error',
|
916
|
+
success : 'success',
|
917
|
+
warning : 'warning'
|
918
|
+
}
|
919
|
+
|
920
|
+
};
|
921
|
+
|
922
|
+
|
923
|
+
})( jQuery, window, document );
|