@pageboard/html 0.14.18 → 0.14.20

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