fomantic-ui 2.10.0-beta.62 → 2.10.0-beta.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +0 -1
- package/changelog-setup.js +10 -10
- package/dist/components/accordion.css +1 -1
- package/dist/components/accordion.js +40 -41
- package/dist/components/accordion.min.css +1 -1
- package/dist/components/accordion.min.js +2 -2
- package/dist/components/ad.css +1 -1
- package/dist/components/ad.min.css +1 -1
- package/dist/components/api.js +57 -61
- package/dist/components/api.min.js +2 -2
- package/dist/components/breadcrumb.css +1 -1
- package/dist/components/breadcrumb.min.css +1 -1
- package/dist/components/button.css +1 -1
- package/dist/components/button.min.css +1 -1
- package/dist/components/calendar.css +1 -1
- package/dist/components/calendar.js +186 -187
- package/dist/components/calendar.min.css +1 -1
- package/dist/components/calendar.min.js +2 -2
- package/dist/components/card.css +1 -1
- package/dist/components/card.min.css +1 -1
- package/dist/components/checkbox.css +1 -1
- package/dist/components/checkbox.js +29 -30
- package/dist/components/checkbox.min.css +1 -1
- package/dist/components/checkbox.min.js +2 -2
- package/dist/components/comment.css +1 -1
- package/dist/components/comment.min.css +1 -1
- package/dist/components/container.css +1 -1
- package/dist/components/container.min.css +1 -1
- package/dist/components/dimmer.css +1 -1
- package/dist/components/dimmer.js +22 -23
- package/dist/components/dimmer.min.css +1 -1
- package/dist/components/dimmer.min.js +2 -2
- package/dist/components/divider.css +1 -1
- package/dist/components/divider.min.css +1 -1
- package/dist/components/dropdown.css +1 -1
- package/dist/components/dropdown.js +293 -337
- package/dist/components/dropdown.min.css +1 -1
- package/dist/components/dropdown.min.js +2 -2
- package/dist/components/embed.css +1 -1
- package/dist/components/embed.js +33 -35
- package/dist/components/embed.min.css +1 -1
- package/dist/components/embed.min.js +2 -2
- package/dist/components/emoji.css +1 -1
- package/dist/components/emoji.min.css +1 -1
- package/dist/components/feed.css +1 -1
- package/dist/components/feed.min.css +1 -1
- package/dist/components/flag.css +1 -1
- package/dist/components/flag.min.css +1 -1
- package/dist/components/flyout.css +1 -1
- package/dist/components/flyout.js +74 -81
- package/dist/components/flyout.min.css +1 -1
- package/dist/components/flyout.min.js +2 -2
- package/dist/components/form.css +1 -1
- package/dist/components/form.js +141 -146
- package/dist/components/form.min.css +1 -1
- package/dist/components/form.min.js +2 -2
- package/dist/components/grid.css +1 -1
- package/dist/components/grid.min.css +1 -1
- package/dist/components/header.css +1 -1
- package/dist/components/header.min.css +1 -1
- package/dist/components/icon.css +1 -1
- package/dist/components/icon.min.css +1 -1
- package/dist/components/image.css +1 -1
- package/dist/components/image.min.css +1 -1
- package/dist/components/input.css +1 -1
- package/dist/components/input.min.css +1 -1
- package/dist/components/item.css +1 -1
- package/dist/components/item.min.css +1 -1
- package/dist/components/label.css +1 -1
- package/dist/components/label.min.css +1 -1
- package/dist/components/list.css +1 -1
- package/dist/components/list.min.css +1 -1
- package/dist/components/loader.css +1 -1
- package/dist/components/loader.min.css +1 -1
- package/dist/components/menu.css +1 -1
- package/dist/components/menu.min.css +1 -1
- package/dist/components/message.css +1 -1
- package/dist/components/message.min.css +1 -1
- package/dist/components/modal.css +1 -1
- package/dist/components/modal.js +80 -81
- package/dist/components/modal.min.css +1 -1
- package/dist/components/modal.min.js +2 -2
- package/dist/components/nag.css +1 -1
- package/dist/components/nag.js +27 -28
- package/dist/components/nag.min.css +1 -1
- package/dist/components/nag.min.js +2 -2
- package/dist/components/placeholder.css +1 -1
- package/dist/components/placeholder.min.css +1 -1
- package/dist/components/popup.css +1 -1
- package/dist/components/popup.js +62 -72
- package/dist/components/popup.min.css +1 -1
- package/dist/components/popup.min.js +2 -2
- package/dist/components/progress.css +1 -1
- package/dist/components/progress.js +51 -55
- package/dist/components/progress.min.css +1 -1
- package/dist/components/progress.min.js +2 -2
- package/dist/components/rail.css +1 -1
- package/dist/components/rail.min.css +1 -1
- package/dist/components/rating.css +1 -1
- package/dist/components/rating.js +33 -34
- package/dist/components/rating.min.css +1 -1
- package/dist/components/rating.min.js +2 -2
- package/dist/components/reset.css +1 -1
- package/dist/components/reset.min.css +1 -1
- package/dist/components/reveal.css +1 -1
- package/dist/components/reveal.min.css +1 -1
- package/dist/components/search.css +1 -1
- package/dist/components/search.js +96 -109
- package/dist/components/search.min.css +1 -1
- package/dist/components/search.min.js +2 -2
- package/dist/components/segment.css +1 -1
- package/dist/components/segment.min.css +1 -1
- package/dist/components/shape.css +1 -1
- package/dist/components/shape.js +44 -45
- package/dist/components/shape.min.css +1 -1
- package/dist/components/shape.min.js +2 -2
- package/dist/components/sidebar.css +1 -1
- package/dist/components/sidebar.js +56 -64
- package/dist/components/sidebar.min.css +1 -1
- package/dist/components/sidebar.min.js +2 -2
- package/dist/components/site.css +1 -1
- package/dist/components/site.js +16 -17
- package/dist/components/site.min.css +1 -1
- package/dist/components/site.min.js +2 -2
- package/dist/components/slider.css +1 -1
- package/dist/components/slider.js +143 -148
- package/dist/components/slider.min.css +1 -1
- package/dist/components/slider.min.js +2 -2
- package/dist/components/state.js +24 -25
- package/dist/components/state.min.js +2 -2
- package/dist/components/statistic.css +1 -1
- package/dist/components/statistic.min.css +1 -1
- package/dist/components/step.css +1 -1
- package/dist/components/step.min.css +1 -1
- package/dist/components/sticky.css +1 -1
- package/dist/components/sticky.js +42 -43
- package/dist/components/sticky.min.css +1 -1
- package/dist/components/sticky.min.js +2 -2
- package/dist/components/tab.css +1 -1
- package/dist/components/tab.js +57 -66
- package/dist/components/tab.min.css +1 -1
- package/dist/components/tab.min.js +2 -2
- package/dist/components/table.css +1 -1
- package/dist/components/table.min.css +1 -1
- package/dist/components/text.css +1 -1
- package/dist/components/text.min.css +1 -1
- package/dist/components/toast.css +1 -1
- package/dist/components/toast.js +32 -33
- package/dist/components/toast.min.css +1 -1
- package/dist/components/toast.min.js +2 -2
- package/dist/components/transition.css +1 -1
- package/dist/components/transition.js +38 -45
- package/dist/components/transition.min.css +1 -1
- package/dist/components/transition.min.js +2 -2
- package/dist/components/visibility.js +76 -77
- package/dist/components/visibility.min.js +2 -2
- package/dist/semantic.css +53 -53
- package/dist/semantic.js +1753 -1884
- package/dist/semantic.min.css +1 -1
- package/dist/semantic.min.js +2 -2
- package/package.json +1 -1
- package/scripts/nightly-version.js +3 -3
- package/src/definitions/behaviors/api.js +56 -60
- package/src/definitions/behaviors/form.js +140 -145
- package/src/definitions/behaviors/state.js +23 -24
- package/src/definitions/behaviors/visibility.js +75 -76
- package/src/definitions/globals/site.js +15 -16
- package/src/definitions/modules/accordion.js +39 -40
- package/src/definitions/modules/calendar.js +185 -186
- package/src/definitions/modules/checkbox.js +28 -29
- package/src/definitions/modules/dimmer.js +21 -22
- package/src/definitions/modules/dropdown.js +292 -336
- package/src/definitions/modules/embed.js +32 -34
- package/src/definitions/modules/flyout.js +73 -80
- package/src/definitions/modules/modal.js +79 -80
- package/src/definitions/modules/nag.js +26 -27
- package/src/definitions/modules/popup.js +61 -71
- package/src/definitions/modules/progress.js +50 -54
- package/src/definitions/modules/rating.js +32 -33
- package/src/definitions/modules/search.js +95 -108
- package/src/definitions/modules/shape.js +43 -44
- package/src/definitions/modules/sidebar.js +55 -63
- package/src/definitions/modules/slider.js +142 -147
- package/src/definitions/modules/sticky.js +41 -42
- package/src/definitions/modules/tab.js +56 -65
- package/src/definitions/modules/toast.js +31 -32
- package/src/definitions/modules/transition.js +37 -44
- package/tasks/admin/components/create.js +11 -11
- package/tasks/admin/components/init.js +11 -12
- package/tasks/admin/components/update.js +19 -20
- package/tasks/admin/distributions/create.js +24 -36
- package/tasks/admin/distributions/init.js +11 -12
- package/tasks/admin/distributions/update.js +18 -19
- package/tasks/admin/register.js +7 -7
- package/tasks/build/assets.js +1 -1
- package/tasks/build/css.js +1 -1
- package/tasks/build/javascript.js +1 -1
- package/tasks/config/admin/github.js +1 -1
- package/tasks/config/admin/templates/css-package.js +1 -1
- package/tasks/config/admin/templates/less-package.js +1 -1
- package/tasks/config/project/config.js +6 -6
- package/tasks/config/project/install.js +12 -12
- package/tasks/config/project/release.js +5 -11
- package/tasks/config/tasks.js +5 -5
- package/tasks/config/user.js +1 -4
- package/tasks/docs/metadata.js +11 -12
- package/tasks/install.js +9 -9
- package/test/meteor/assets.js +1 -1
- package/test/modules/module.spec.js +18 -18
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
: globalThis;
|
|
21
21
|
|
|
22
22
|
$.fn.popup = function (...args) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const $allModules = $(this);
|
|
24
|
+
const $document = $(document);
|
|
25
|
+
const $window = $(window);
|
|
26
|
+
const $body = $('body');
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const clickEvent = 'ontouchstart' in document.documentElement
|
|
29
29
|
? 'touchstart'
|
|
30
30
|
: 'click';
|
|
31
31
|
|
|
32
32
|
let time = Date.now();
|
|
33
33
|
let performance = [];
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const parameters = args[0];
|
|
36
|
+
const methodInvoked = typeof parameters === 'string';
|
|
37
|
+
const queryArguments = args.slice(1);
|
|
38
|
+
const contextCheck = function (context, win) {
|
|
39
39
|
let $context;
|
|
40
40
|
if ([window, document].includes(context)) {
|
|
41
41
|
$context = $(context);
|
|
@@ -51,24 +51,24 @@
|
|
|
51
51
|
|
|
52
52
|
let returnedValue;
|
|
53
53
|
$allModules.each(function () {
|
|
54
|
-
|
|
54
|
+
const settings = $.isPlainObject(parameters)
|
|
55
55
|
? $.extend(true, {}, $.fn.popup.settings, parameters)
|
|
56
56
|
: $.extend({}, $.fn.popup.settings);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
const selector = settings.selector;
|
|
59
|
+
const className = settings.className;
|
|
60
|
+
const error = settings.error;
|
|
61
|
+
const metadata = settings.metadata;
|
|
62
|
+
const namespace = settings.namespace;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const eventNamespace = '.' + settings.namespace;
|
|
65
|
+
const moduleNamespace = 'module-' + namespace;
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
const $module = $(this);
|
|
68
|
+
const $context = contextCheck(settings.context, window);
|
|
69
|
+
const $scrollContext = contextCheck(settings.scrollContext, window);
|
|
70
|
+
const $boundary = contextCheck(settings.boundary, window);
|
|
71
|
+
const $target = settings.target ? contextCheck(settings.target, window) : $module;
|
|
72
72
|
|
|
73
73
|
let $popup;
|
|
74
74
|
let $offsetParent;
|
|
@@ -77,15 +77,14 @@
|
|
|
77
77
|
let triedPositions = false;
|
|
78
78
|
let openedWithTouch = false;
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
const element = this;
|
|
81
81
|
let instance = $module.data(moduleNamespace);
|
|
82
82
|
|
|
83
83
|
let documentObserver;
|
|
84
84
|
let elementNamespace;
|
|
85
85
|
let id;
|
|
86
|
-
let module;
|
|
87
86
|
|
|
88
|
-
module = {
|
|
87
|
+
const module = {
|
|
89
88
|
|
|
90
89
|
// binds events
|
|
91
90
|
initialize: function () {
|
|
@@ -176,7 +175,7 @@
|
|
|
176
175
|
|
|
177
176
|
event: {
|
|
178
177
|
start: function (event) {
|
|
179
|
-
|
|
178
|
+
const delay = $.isPlainObject(settings.delay)
|
|
180
179
|
? settings.delay.show
|
|
181
180
|
: settings.delay;
|
|
182
181
|
clearTimeout(module.hideTimer);
|
|
@@ -187,7 +186,7 @@
|
|
|
187
186
|
}
|
|
188
187
|
},
|
|
189
188
|
end: function () {
|
|
190
|
-
|
|
189
|
+
const delay = $.isPlainObject(settings.delay)
|
|
191
190
|
? settings.delay.hide
|
|
192
191
|
: settings.delay;
|
|
193
192
|
clearTimeout(module.showTimer);
|
|
@@ -219,9 +218,9 @@
|
|
|
219
218
|
});
|
|
220
219
|
},
|
|
221
220
|
hideGracefully: function (event) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
const $target = $(event.target);
|
|
222
|
+
const isInDOM = document.documentElement.contains(event.target);
|
|
223
|
+
const inPopup = $target.closest(selector.popup).length > 0;
|
|
225
224
|
// don't close on clicks inside popup
|
|
226
225
|
if (event && !inPopup && isInDOM) {
|
|
227
226
|
module.debug('Click occurred outside popup hiding popup');
|
|
@@ -234,11 +233,11 @@
|
|
|
234
233
|
|
|
235
234
|
// generates popup html from metadata
|
|
236
235
|
create: function () {
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
const targetSibling = $target.next(selector.popup);
|
|
237
|
+
const contentFallback = !settings.popup && targetSibling.length === 0 ? $module.attr('title') : false;
|
|
239
238
|
let html = module.get.html();
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
const title = module.get.title();
|
|
240
|
+
const content = module.get.content(contentFallback);
|
|
242
241
|
|
|
243
242
|
if (html || content || title) {
|
|
244
243
|
module.debug('Creating pop-up html');
|
|
@@ -479,22 +478,20 @@
|
|
|
479
478
|
return $popup.offset();
|
|
480
479
|
},
|
|
481
480
|
calculations: function () {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
481
|
+
const $popupOffsetParent = module.get.offsetParent($popup);
|
|
482
|
+
const targetElement = $target[0];
|
|
483
|
+
const isWindowEl = $boundary[0] === window;
|
|
484
|
+
const targetOffset = $target.offset();
|
|
485
|
+
const parentOffset = settings.inline || (settings.popup && settings.movePopup)
|
|
487
486
|
? $target.offsetParent().offset()
|
|
488
487
|
: { top: 0, left: 0 };
|
|
489
|
-
|
|
488
|
+
const screenPosition = isWindowEl
|
|
490
489
|
? { top: 0, left: 0 }
|
|
491
490
|
: $boundary.offset();
|
|
492
|
-
|
|
493
|
-
let scroll = isWindowEl
|
|
491
|
+
const scroll = isWindowEl
|
|
494
492
|
? { top: $window.scrollTop(), left: $window.scrollLeft() }
|
|
495
493
|
: { top: 0, left: 0 };
|
|
496
|
-
|
|
497
|
-
calculations = {
|
|
494
|
+
const calculations = {
|
|
498
495
|
// element which is launching popup
|
|
499
496
|
target: {
|
|
500
497
|
element: $target[0],
|
|
@@ -529,7 +526,7 @@
|
|
|
529
526
|
|
|
530
527
|
// if popup offset context is different from target, then adjust calculations
|
|
531
528
|
if ($popupOffsetParent[0] !== $offsetParent[0]) {
|
|
532
|
-
|
|
529
|
+
const popupOffset = $popupOffsetParent.offset();
|
|
533
530
|
calculations.target.top -= popupOffset.top;
|
|
534
531
|
calculations.target.left -= popupOffset.left;
|
|
535
532
|
calculations.parent.width = $popupOffsetParent.outerWidth();
|
|
@@ -554,7 +551,7 @@
|
|
|
554
551
|
: parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10))
|
|
555
552
|
: 0;
|
|
556
553
|
// calculate screen boundaries
|
|
557
|
-
screen = calculations.screen;
|
|
554
|
+
const screen = calculations.screen;
|
|
558
555
|
calculations.boundary = {
|
|
559
556
|
top: screen.top + screen.scroll.top,
|
|
560
557
|
bottom: screen.top + screen.scroll.top + screen.height,
|
|
@@ -592,12 +589,10 @@
|
|
|
592
589
|
},
|
|
593
590
|
distanceFromBoundary: function (offset, calculations = module.get.calculations()) {
|
|
594
591
|
let distanceFromBoundary = {};
|
|
595
|
-
let popup;
|
|
596
|
-
let boundary;
|
|
597
592
|
|
|
598
593
|
// shorthand
|
|
599
|
-
popup = calculations.popup;
|
|
600
|
-
boundary = calculations.boundary;
|
|
594
|
+
const popup = calculations.popup;
|
|
595
|
+
const boundary = calculations.boundary;
|
|
601
596
|
|
|
602
597
|
if (offset) {
|
|
603
598
|
distanceFromBoundary = {
|
|
@@ -612,7 +607,7 @@
|
|
|
612
607
|
return distanceFromBoundary;
|
|
613
608
|
},
|
|
614
609
|
offsetParent: function ($element) {
|
|
615
|
-
|
|
610
|
+
const element = $element !== undefined
|
|
616
611
|
? $element[0]
|
|
617
612
|
: $target[0];
|
|
618
613
|
let parentNode = element.parentNode;
|
|
@@ -647,21 +642,21 @@
|
|
|
647
642
|
};
|
|
648
643
|
},
|
|
649
644
|
nextPosition: function (position) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
645
|
+
const positions = position.split(' ');
|
|
646
|
+
const verticalPosition = positions[0];
|
|
647
|
+
const horizontalPosition = positions[1];
|
|
648
|
+
const opposite = {
|
|
654
649
|
top: 'bottom',
|
|
655
650
|
bottom: 'top',
|
|
656
651
|
left: 'right',
|
|
657
652
|
right: 'left',
|
|
658
653
|
};
|
|
659
|
-
|
|
654
|
+
const adjacent = {
|
|
660
655
|
left: 'center',
|
|
661
656
|
center: 'right',
|
|
662
657
|
right: 'left',
|
|
663
658
|
};
|
|
664
|
-
|
|
659
|
+
const backup = {
|
|
665
660
|
'top left': 'top center',
|
|
666
661
|
'top center': 'top right',
|
|
667
662
|
'top right': 'right center',
|
|
@@ -671,7 +666,7 @@
|
|
|
671
666
|
'bottom left': 'left center',
|
|
672
667
|
'left center': 'top left',
|
|
673
668
|
};
|
|
674
|
-
|
|
669
|
+
const adjacentsAvailable = verticalPosition === 'top' || verticalPosition === 'bottom';
|
|
675
670
|
let oppositeTried = false;
|
|
676
671
|
let adjacentTried = false;
|
|
677
672
|
let nextPosition = false;
|
|
@@ -714,20 +709,15 @@
|
|
|
714
709
|
}
|
|
715
710
|
let offset;
|
|
716
711
|
let distanceAway;
|
|
717
|
-
let target;
|
|
718
|
-
let popup;
|
|
719
|
-
let parent;
|
|
720
712
|
let positioning;
|
|
721
|
-
let popupOffset;
|
|
722
|
-
let distanceFromBoundary;
|
|
723
713
|
|
|
724
714
|
offset = $module.data(metadata.offset) || settings.offset;
|
|
725
715
|
distanceAway = settings.distanceAway;
|
|
726
716
|
|
|
727
717
|
// shorthand
|
|
728
|
-
target = calculations.target;
|
|
729
|
-
popup = calculations.popup;
|
|
730
|
-
parent = calculations.parent;
|
|
718
|
+
const target = calculations.target;
|
|
719
|
+
const popup = calculations.popup;
|
|
720
|
+
const parent = calculations.parent;
|
|
731
721
|
|
|
732
722
|
if (module.should.centerArrow(calculations)) {
|
|
733
723
|
module.verbose('Adjusting offset to center arrow on small target element');
|
|
@@ -873,10 +863,10 @@
|
|
|
873
863
|
.addClass(position);
|
|
874
864
|
module.set.invisible();
|
|
875
865
|
|
|
876
|
-
popupOffset = module.get.popupOffset();
|
|
866
|
+
const popupOffset = module.get.popupOffset();
|
|
877
867
|
|
|
878
868
|
// see if any boundaries are surpassed with this tentative position
|
|
879
|
-
distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
|
|
869
|
+
const distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
|
|
880
870
|
|
|
881
871
|
if (!settings.forcePosition && module.is.offstage(distanceFromBoundary, position)) {
|
|
882
872
|
module.debug('Position is outside viewport', position);
|
|
@@ -1069,7 +1059,7 @@
|
|
|
1069
1059
|
return settings.closable;
|
|
1070
1060
|
},
|
|
1071
1061
|
offstage: function (distanceFromBoundary, position) {
|
|
1072
|
-
|
|
1062
|
+
const offstage = [];
|
|
1073
1063
|
// return boundaries that have been surpassed
|
|
1074
1064
|
$.each(distanceFromBoundary, function (direction, distance) {
|
|
1075
1065
|
if (distance < -settings.jitter) {
|
|
@@ -1213,7 +1203,7 @@
|
|
|
1213
1203
|
query = query.split(/[ .]/);
|
|
1214
1204
|
maxDepth = query.length - 1;
|
|
1215
1205
|
$.each(query, function (depth, value) {
|
|
1216
|
-
|
|
1206
|
+
const camelCaseValue = depth !== maxDepth
|
|
1217
1207
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
1218
1208
|
: query;
|
|
1219
1209
|
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
@@ -1449,7 +1439,7 @@
|
|
|
1449
1439
|
},
|
|
1450
1440
|
popup: function (text) {
|
|
1451
1441
|
let html = '';
|
|
1452
|
-
|
|
1442
|
+
const escape = $.fn.popup.settings.templates.escape;
|
|
1453
1443
|
if (text !== undefined) {
|
|
1454
1444
|
if (text.title) {
|
|
1455
1445
|
text.title = escape(text.title);
|
|
@@ -20,42 +20,41 @@
|
|
|
20
20
|
: globalThis;
|
|
21
21
|
|
|
22
22
|
$.fn.progress = function (...args) {
|
|
23
|
-
|
|
23
|
+
const $allModules = $(this);
|
|
24
24
|
|
|
25
25
|
let time = Date.now();
|
|
26
26
|
let performance = [];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const parameters = args[0];
|
|
29
|
+
const methodInvoked = typeof parameters === 'string';
|
|
30
|
+
const queryArguments = args.slice(1);
|
|
31
31
|
|
|
32
32
|
let returnedValue;
|
|
33
33
|
|
|
34
34
|
$allModules.each(function () {
|
|
35
|
-
|
|
35
|
+
const settings = $.isPlainObject(parameters)
|
|
36
36
|
? $.extend(true, {}, $.fn.progress.settings, parameters)
|
|
37
37
|
: $.extend({}, $.fn.progress.settings);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
const className = settings.className;
|
|
40
|
+
const metadata = settings.metadata;
|
|
41
|
+
const namespace = settings.namespace;
|
|
42
|
+
const selector = settings.selector;
|
|
43
|
+
const error = settings.error;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const eventNamespace = '.' + namespace;
|
|
46
|
+
const moduleNamespace = 'module-' + namespace;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const $module = $(this);
|
|
49
|
+
const $bars = $(this).find(selector.bar);
|
|
50
|
+
const $progresses = $(this).find(selector.progress);
|
|
51
|
+
const $label = $(this).find(selector.label);
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
const element = this;
|
|
54
54
|
let instance = $module.data(moduleNamespace);
|
|
55
55
|
|
|
56
56
|
let animating = false;
|
|
57
|
-
|
|
58
|
-
module = {
|
|
57
|
+
const module = {
|
|
59
58
|
helper: {
|
|
60
59
|
sum: function (nums) {
|
|
61
60
|
return Array.isArray(nums) ? nums.reduce(function (left, right) {
|
|
@@ -146,7 +145,7 @@
|
|
|
146
145
|
|
|
147
146
|
read: {
|
|
148
147
|
metadata: function () {
|
|
149
|
-
|
|
148
|
+
const data = {
|
|
150
149
|
percent: module.helper.forceArray($module.data(metadata.percent)),
|
|
151
150
|
total: $module.data(metadata.total),
|
|
152
151
|
value: module.helper.forceArray($module.data(metadata.value)),
|
|
@@ -212,7 +211,7 @@
|
|
|
212
211
|
module.set.progress(newValue);
|
|
213
212
|
},
|
|
214
213
|
decrement: function (decrementValue) {
|
|
215
|
-
|
|
214
|
+
const total = module.get.total();
|
|
216
215
|
let startValue;
|
|
217
216
|
let newValue;
|
|
218
217
|
if (total) {
|
|
@@ -241,12 +240,12 @@
|
|
|
241
240
|
|
|
242
241
|
get: {
|
|
243
242
|
text: function (templateText = '', index = 0) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
const value = module.get.value(index);
|
|
244
|
+
const total = module.get.total();
|
|
245
|
+
const percent = animating
|
|
247
246
|
? module.get.displayPercent(index)
|
|
248
247
|
: module.get.percent(index);
|
|
249
|
-
|
|
248
|
+
const left = total !== false
|
|
250
249
|
? Math.max(0, total - value)
|
|
251
250
|
: 100 - percent;
|
|
252
251
|
templateText = templateText
|
|
@@ -305,11 +304,11 @@
|
|
|
305
304
|
|
|
306
305
|
// gets current displayed percentage (if animating values, this is the intermediary value)
|
|
307
306
|
displayPercent: function (index) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
307
|
+
const $bar = $($bars[index]);
|
|
308
|
+
const barWidth = $bar.width();
|
|
309
|
+
const totalWidth = $module.width();
|
|
310
|
+
const minDisplay = parseInt($bar.css('min-width'), 10);
|
|
311
|
+
const displayPercent = barWidth > minDisplay
|
|
313
312
|
? (barWidth / totalWidth) * 100
|
|
314
313
|
: module.percent;
|
|
315
314
|
|
|
@@ -401,12 +400,12 @@
|
|
|
401
400
|
values = module.helper.forceArray(values);
|
|
402
401
|
let firstNonZeroIndex = -1;
|
|
403
402
|
let lastNonZeroIndex = -1;
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
403
|
+
const valuesSum = module.helper.sum(values);
|
|
404
|
+
const barCounts = $bars.length;
|
|
405
|
+
const isMultiple = barCounts > 1;
|
|
406
|
+
const percents = values.map(function (value, index) {
|
|
407
|
+
const allZero = index === barCounts - 1 && valuesSum === 0;
|
|
408
|
+
const $bar = $($bars[index]);
|
|
410
409
|
if (value === 0 && isMultiple && !allZero) {
|
|
411
410
|
$bar.css('display', 'none');
|
|
412
411
|
} else {
|
|
@@ -426,7 +425,7 @@
|
|
|
426
425
|
return parseFloat(value);
|
|
427
426
|
});
|
|
428
427
|
values.forEach(function (_, index) {
|
|
429
|
-
|
|
428
|
+
const $bar = $($bars[index]);
|
|
430
429
|
$bar.css({
|
|
431
430
|
borderTopLeftRadius: index === firstNonZeroIndex ? '' : '0',
|
|
432
431
|
borderBottomLeftRadius: index === firstNonZeroIndex ? '' : '0',
|
|
@@ -457,10 +456,10 @@
|
|
|
457
456
|
? Math.max(0, Math.min(100, percent))
|
|
458
457
|
: percent;
|
|
459
458
|
});
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
459
|
+
const hasTotal = module.has.total();
|
|
460
|
+
const totalPercent = module.helper.sum(percents);
|
|
461
|
+
const isMultipleValues = percents.length > 1 && hasTotal;
|
|
462
|
+
const sumTotal = module.helper.sum(module.helper.forceArray(module.value));
|
|
464
463
|
if (isMultipleValues && sumTotal > module.total) {
|
|
465
464
|
// Sum values instead of percents to avoid precision issues when summing floats
|
|
466
465
|
module.error(error.sumExceedsTotal, sumTotal, module.total);
|
|
@@ -470,14 +469,14 @@
|
|
|
470
469
|
} else if (totalPercent < 0) {
|
|
471
470
|
module.error(error.tooLow, totalPercent);
|
|
472
471
|
} else {
|
|
473
|
-
|
|
472
|
+
const autoPrecision = settings.precision > 0
|
|
474
473
|
? settings.precision
|
|
475
474
|
: (isMultipleValues
|
|
476
475
|
? module.helper.derivePrecision(Math.min.apply(null, module.value), module.total)
|
|
477
476
|
: 0);
|
|
478
477
|
|
|
479
478
|
// round display percentage
|
|
480
|
-
|
|
479
|
+
const roundedPercents = percents.map(function (percent) {
|
|
481
480
|
return autoPrecision > 0
|
|
482
481
|
? Math.round(percent * (10 * autoPrecision)) / (10 * autoPrecision)
|
|
483
482
|
: Math.round(percent);
|
|
@@ -496,7 +495,7 @@
|
|
|
496
495
|
settings.onChange.call(element, percents, module.value, module.total);
|
|
497
496
|
},
|
|
498
497
|
labelInterval: function () {
|
|
499
|
-
|
|
498
|
+
const animationCallback = function () {
|
|
500
499
|
module.verbose('Bar finished animating, removing continuous label updates');
|
|
501
500
|
clearInterval(module.interval);
|
|
502
501
|
animating = false;
|
|
@@ -506,7 +505,7 @@
|
|
|
506
505
|
module.bind.transitionEnd(animationCallback);
|
|
507
506
|
animating = true;
|
|
508
507
|
module.interval = setInterval(function () {
|
|
509
|
-
|
|
508
|
+
const isInDOM = document.documentElement.contains(element);
|
|
510
509
|
if (!isInDOM) {
|
|
511
510
|
clearInterval(module.interval);
|
|
512
511
|
animating = false;
|
|
@@ -526,10 +525,7 @@
|
|
|
526
525
|
$label.text(text);
|
|
527
526
|
}
|
|
528
527
|
},
|
|
529
|
-
state: function (percent) {
|
|
530
|
-
percent = percent !== undefined
|
|
531
|
-
? percent
|
|
532
|
-
: module.helper.sum(module.percent);
|
|
528
|
+
state: function (percent = module.helper.sum(module.percent)) {
|
|
533
529
|
if (percent === 100) {
|
|
534
530
|
if (settings.autoSuccess && $bars.length === 1 && !(module.is.warning() || module.is.error() || module.is.success())) {
|
|
535
531
|
module.set.success();
|
|
@@ -552,7 +548,7 @@
|
|
|
552
548
|
},
|
|
553
549
|
barLabel: function (text) {
|
|
554
550
|
$progresses.each(function (index, element) {
|
|
555
|
-
|
|
551
|
+
const $progress = $(element);
|
|
556
552
|
if (text !== undefined) {
|
|
557
553
|
$progress.text(module.get.text(text, index));
|
|
558
554
|
} else if (settings.label === 'ratio' && module.has.total()) {
|
|
@@ -651,7 +647,7 @@
|
|
|
651
647
|
|
|
652
648
|
update: {
|
|
653
649
|
toNextValue: function () {
|
|
654
|
-
|
|
650
|
+
const nextValue = module.nextValue;
|
|
655
651
|
if (nextValue) {
|
|
656
652
|
module.debug('Update interval complete using last updated value', nextValue);
|
|
657
653
|
module.update.progress(nextValue);
|
|
@@ -659,11 +655,11 @@
|
|
|
659
655
|
}
|
|
660
656
|
},
|
|
661
657
|
progress: function (values) {
|
|
662
|
-
|
|
658
|
+
const hasTotal = module.has.total();
|
|
663
659
|
if (hasTotal) {
|
|
664
660
|
module.set.value(values);
|
|
665
661
|
}
|
|
666
|
-
|
|
662
|
+
const percentCompletes = module.helper.forceArray(values).map(function (value) {
|
|
667
663
|
let percentComplete;
|
|
668
664
|
value = module.get.numericValue(value);
|
|
669
665
|
if (value === false) {
|
|
@@ -781,7 +777,7 @@
|
|
|
781
777
|
query = query.split(/[ .]/);
|
|
782
778
|
maxDepth = query.length - 1;
|
|
783
779
|
$.each(query, function (depth, value) {
|
|
784
|
-
|
|
780
|
+
const camelCaseValue = depth !== maxDepth
|
|
785
781
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
786
782
|
: query;
|
|
787
783
|
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|