@oat-sa/tao-core-ui 1.62.0 → 1.63.0
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/dist/actionbar.js +3 -3
- package/dist/animable/absorbable/css/absorb.css.map +1 -1
- package/dist/animable/pulsable/css/pulse.css.map +1 -1
- package/dist/autocomplete/css/autocomplete.css.map +1 -1
- package/dist/autocomplete.js +8 -10
- package/dist/badge/css/badge.css.map +1 -1
- package/dist/breadcrumbs/css/breadcrumbs.css.map +1 -1
- package/dist/breadcrumbs.js +17 -17
- package/dist/btngrouper.js +3 -3
- package/dist/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
- package/dist/calculator/css/calculator.css.map +1 -1
- package/dist/calculator.js +1 -1
- package/dist/cascadingComboBox.js +5 -5
- package/dist/ckeditor/ckConfigurator.js +9 -1
- package/dist/ckeditor/dtdHandler.js +4 -4
- package/dist/class/css/selector.css.map +1 -1
- package/dist/component/css/components.css.map +1 -1
- package/dist/component/css/windowComponent.css.map +1 -1
- package/dist/contextualPopup/css/contextualPopup.css.map +1 -1
- package/dist/contextualPopup.js +7 -7
- package/dist/dashboard/css/dashboard.css.map +1 -1
- package/dist/dashboard.js +3 -2
- package/dist/datalist/css/datalist.css.map +1 -1
- package/dist/datatable/css/datatable.css.map +1 -1
- package/dist/datatable/filterStrategy/single.js +2 -2
- package/dist/datatable.js +4 -4
- package/dist/dateRange/css/dateRange.css.map +1 -1
- package/dist/datetime/css/picker.css.map +1 -1
- package/dist/deleter.js +9 -9
- package/dist/destination/css/selector.css.map +1 -1
- package/dist/dialog.js +3 -5
- package/dist/documentViewer/css/documentViewer.css.map +1 -1
- package/dist/dropdown/css/dropdown.css.map +1 -1
- package/dist/durationer.js +6 -8
- package/dist/dynamicComponent/css/dynamicComponent.css.map +1 -1
- package/dist/dynamicComponent.js +2 -3
- package/dist/filesender.js +6 -8
- package/dist/filter.js +6 -10
- package/dist/form/css/dropdownForm.css.map +1 -1
- package/dist/form/css/form.css.map +1 -1
- package/dist/form/validator/css/validator.css.map +1 -1
- package/dist/form/widget/css/widget.css.map +1 -1
- package/dist/form.js +3 -3
- package/dist/formValidator/highlighters/highlighter.js +5 -4
- package/dist/formValidator/highlighters/message.js +1 -3
- package/dist/generis/form/css/form.css.map +1 -1
- package/dist/generis/validator/css/validator.css.map +1 -1
- package/dist/generis/widget/comboBox/comboBox.js +2 -2
- package/dist/generis/widget/css/widget.css.map +1 -1
- package/dist/generis/widget/hiddenBox/hiddenBox.js +2 -2
- package/dist/generis/widget/textBox/textBox.js +2 -2
- package/dist/groupedComboBox.js +3 -3
- package/dist/highlighter.js +49 -47
- package/dist/incrementer.js +17 -16
- package/dist/inplacer.js +4 -4
- package/dist/itemButtonList/css/item-button-list.css.map +1 -1
- package/dist/listbox/css/listbox.css.map +1 -1
- package/dist/listbox.js +1 -0
- package/dist/liststyler.js +1 -1
- package/dist/loadingButton/css/button.css.map +1 -1
- package/dist/lock.js +4 -4
- package/dist/login/login.js +4 -4
- package/dist/maths/calculator/css/calculator.css.map +1 -1
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +2 -2
- package/dist/mediaEditor/plugins/mediaDimension/helper.js +4 -4
- package/dist/mediaplayer/css/player.css.map +1 -1
- package/dist/mediaplayer/players/youtube.js +1 -1
- package/dist/mediaplayer/youtubeManager.js +1 -1
- package/dist/mediaplayer.js +3 -3
- package/dist/modal.js +1 -1
- package/dist/pageSizeSelector.js +3 -3
- package/dist/pagination/css/pagination.css.map +1 -1
- package/dist/pagination.js +5 -5
- package/dist/propertySelector/css/propertySelector.css.map +1 -1
- package/dist/propertySelector/propertySelector.js +3 -3
- package/dist/resource/css/selector.css.map +1 -1
- package/dist/resourcemgr/css/resourcemgr.css.map +1 -1
- package/dist/resourcemgr/fileSelector.js +6 -4
- package/dist/searchModal/css/advancedSearch.css.map +1 -1
- package/dist/searchModal/css/searchModal.css.map +1 -1
- package/dist/searchModal.js +16 -17
- package/dist/switch/css/switch.css.map +1 -1
- package/dist/tabs/css/tabs.css.map +1 -1
- package/dist/taskQueue/css/taskQueue.css.map +1 -1
- package/dist/taskQueue/status.js +4 -4
- package/dist/taskQueue/table.js +1 -1
- package/dist/taskQueue.js +7 -7
- package/dist/taskQueueButton/css/taskable.css.map +1 -1
- package/dist/taskQueueButton/css/treeButton.css.map +1 -1
- package/dist/taskQueueButton/treeButton.js +2 -2
- package/dist/toggler.js +4 -4
- package/dist/transformer.js +2 -2
- package/dist/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
- package/dist/validator/Validator.js +4 -4
- package/dist/validator/validators.js +3 -5
- package/dist/validator.js +54 -54
- package/dist/waitingDialog/css/waitingDialog.css.map +1 -1
- package/package.json +3 -2
- package/scss/.DS_Store +0 -0
- package/scss/ckeditor/.DS_Store +0 -0
- package/scss/ckeditor/skins/.DS_Store +0 -0
- package/scss/ckeditor/skins/tao/.DS_Store +0 -0
- package/scss/ckeditor/skins/tao/scss/.DS_Store +0 -0
- package/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +1 -0
- package/scss/font/.DS_Store +0 -0
- package/scss/font/tao/tao.svg +1 -0
- package/scss/font/tao/tao.ttf +0 -0
- package/scss/font/tao/tao.woff +0 -0
- package/scss/inc/.DS_Store +0 -0
- package/scss/inc/fonts/_tao-icon-classes.scss +2 -1
- package/scss/inc/fonts/_tao-icon-def.scss +3 -3
- package/scss/inc/fonts/_tao-icon-vars.scss +2 -1
- package/src/actionbar.js +7 -7
- package/src/animable/absorbable/css/absorb.css.map +1 -1
- package/src/animable/pulsable/css/pulse.css.map +1 -1
- package/src/autocomplete/css/autocomplete.css.map +1 -1
- package/src/autocomplete.js +74 -76
- package/src/badge/css/badge.css.map +1 -1
- package/src/breadcrumbs/css/breadcrumbs.css.map +1 -1
- package/src/breadcrumbs.js +17 -17
- package/src/btngrouper.js +14 -14
- package/src/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
- package/src/calculator/css/calculator.css.map +1 -1
- package/src/calculator.js +11 -11
- package/src/cascadingComboBox.js +9 -9
- package/src/ckeditor/ckConfigurator.js +6 -0
- package/src/ckeditor/dtdHandler.js +15 -15
- package/src/class/css/selector.css.map +1 -1
- package/src/component/css/components.css.map +1 -1
- package/src/component/css/windowComponent.css.map +1 -1
- package/src/contextualPopup/css/contextualPopup.css.map +1 -1
- package/src/contextualPopup.js +11 -14
- package/src/css/basic.css +19 -5
- package/src/css/basic.css.map +1 -1
- package/src/dashboard/css/dashboard.css.map +1 -1
- package/src/dashboard.js +9 -14
- package/src/datalist/css/datalist.css.map +1 -1
- package/src/datatable/css/datatable.css.map +1 -1
- package/src/datatable/filterStrategy/single.js +7 -7
- package/src/datatable.js +6 -6
- package/src/dateRange/css/dateRange.css.map +1 -1
- package/src/datetime/css/picker.css.map +1 -1
- package/src/deleter.js +21 -21
- package/src/destination/css/selector.css.map +1 -1
- package/src/dialog.js +25 -25
- package/src/documentViewer/css/documentViewer.css.map +1 -1
- package/src/dropdown/css/dropdown.css.map +1 -1
- package/src/durationer.js +18 -20
- package/src/dynamicComponent/css/dynamicComponent.css.map +1 -1
- package/src/dynamicComponent.js +22 -23
- package/src/filesender.js +9 -11
- package/src/filter.js +8 -14
- package/src/form/css/dropdownForm.css.map +1 -1
- package/src/form/css/form.css.map +1 -1
- package/src/form/validator/css/validator.css.map +1 -1
- package/src/form/widget/css/widget.css.map +1 -1
- package/src/form.js +5 -11
- package/src/formValidator/highlighters/highlighter.js +6 -5
- package/src/formValidator/highlighters/message.js +1 -3
- package/src/generis/form/css/form.css.map +1 -1
- package/src/generis/validator/css/validator.css.map +1 -1
- package/src/generis/widget/comboBox/comboBox.js +0 -1
- package/src/generis/widget/css/widget.css.map +1 -1
- package/src/generis/widget/hiddenBox/hiddenBox.js +2 -3
- package/src/generis/widget/textBox/textBox.js +0 -1
- package/src/groupedComboBox.js +5 -5
- package/src/highlighter.js +99 -73
- package/src/incrementer.js +41 -52
- package/src/inplacer.js +21 -22
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/src/keyNavigation/navigableDomElement.js +22 -19
- package/src/keyNavigation/navigator.js +18 -26
- package/src/listbox/css/listbox.css.map +1 -1
- package/src/listbox.js +3 -2
- package/src/liststyler.js +7 -7
- package/src/loadingButton/css/button.css.map +1 -1
- package/src/lock.js +17 -19
- package/src/login/login.js +14 -19
- package/src/maths/calculator/css/calculator.css.map +1 -1
- package/src/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +7 -8
- package/src/mediaEditor/plugins/mediaDimension/helper.js +5 -4
- package/src/mediaplayer/css/player.css.map +1 -1
- package/src/mediaplayer/players/youtube.js +1 -1
- package/src/mediaplayer/youtubeManager.js +1 -1
- package/src/mediaplayer.js +3 -3
- package/src/modal.js +18 -18
- package/src/pageSizeSelector.js +7 -8
- package/src/pagination/css/pagination.css.map +1 -1
- package/src/pagination.js +14 -14
- package/src/propertySelector/css/propertySelector.css.map +1 -1
- package/src/propertySelector/propertySelector.js +3 -3
- package/src/resource/css/selector.css.map +1 -1
- package/src/resource/list.js +11 -11
- package/src/resource/tree.js +15 -17
- package/src/resourcemgr/css/resourcemgr.css.map +1 -1
- package/src/resourcemgr/fileSelector.js +46 -72
- package/src/searchModal/css/advancedSearch.css.map +1 -1
- package/src/searchModal/css/searchModal.css.map +1 -1
- package/src/searchModal.js +24 -25
- package/src/switch/css/switch.css.map +1 -1
- package/src/tabs/css/tabs.css.map +1 -1
- package/src/taskQueue/css/taskQueue.css.map +1 -1
- package/src/taskQueue/status.js +12 -12
- package/src/taskQueue/table.js +15 -15
- package/src/taskQueue.js +13 -15
- package/src/taskQueueButton/css/taskable.css.map +1 -1
- package/src/taskQueueButton/css/treeButton.css.map +1 -1
- package/src/taskQueueButton/treeButton.js +2 -3
- package/src/toggler.js +13 -13
- package/src/transformer.js +6 -6
- package/src/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
- package/src/validator/Validator.js +15 -15
- package/src/validator/validators.js +10 -13
- package/src/validator.js +70 -72
- package/src/waitingDialog/css/waitingDialog.css.map +1 -1
package/src/highlighter.js
CHANGED
|
@@ -64,10 +64,10 @@ export default function (options) {
|
|
|
64
64
|
* an optional passed-in blacklist is merged with local defaults
|
|
65
65
|
* @type {Array}
|
|
66
66
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const containersBlackList = _.union(defaultBlackList, options.containersBlackList);
|
|
68
|
+
const containersBlackListSelector = containersBlackList.join(', ');
|
|
69
|
+
let containersWhiteListSelector = null;
|
|
70
|
+
let containersBlackAndWhiteListSelector = containersBlackListSelector;
|
|
71
71
|
if (options.keepEmptyNodes && options.containersWhiteList) {
|
|
72
72
|
containersWhiteListSelector = options.containersWhiteList.join(', ');
|
|
73
73
|
containersBlackAndWhiteListSelector = _.union(containersBlackList, options.containersWhiteList).join(', ');
|
|
@@ -77,25 +77,25 @@ export default function (options) {
|
|
|
77
77
|
* used in recursive loops to decide if we should wrap or not the current node
|
|
78
78
|
* @type {boolean}
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
let isWrapping = false;
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* performance improvement to break out of a potentially big recursive loop once the wrapping has ended
|
|
84
84
|
* @type {boolean}
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
let hasWrapped = false;
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* used in recursive loops to assign a group Id to the current wrapped node
|
|
90
90
|
* @type {number}
|
|
91
91
|
*/
|
|
92
|
-
|
|
92
|
+
let currentGroupId;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* used in recursive loops to build the index of text nodes
|
|
96
96
|
* @type {number}
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
let textNodesIndex;
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Returns the node in which highlighting is allowed
|
|
@@ -150,7 +150,11 @@ export default function (options) {
|
|
|
150
150
|
if (!keepEmptyNodes) {
|
|
151
151
|
range.surroundContents(wrapperNode);
|
|
152
152
|
} else {
|
|
153
|
-
addSplitData(
|
|
153
|
+
addSplitData(
|
|
154
|
+
wrapperNode,
|
|
155
|
+
range.startOffset > 0,
|
|
156
|
+
range.endOffset < range.commonAncestorContainer.length
|
|
157
|
+
);
|
|
154
158
|
rangeSurroundContentsNoEmptyNodes(range, wrapperNode);
|
|
155
159
|
}
|
|
156
160
|
} else if (
|
|
@@ -169,9 +173,10 @@ export default function (options) {
|
|
|
169
173
|
startNodeContainer: range.startContainer,
|
|
170
174
|
startOffset: range.startOffset,
|
|
171
175
|
|
|
172
|
-
endNode:
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
endNode:
|
|
177
|
+
isElement(range.endContainer) && range.endOffset > 0
|
|
178
|
+
? range.endContainer.childNodes[range.endOffset - 1]
|
|
179
|
+
: range.endContainer,
|
|
175
180
|
endNodeContainer: range.endContainer,
|
|
176
181
|
endOffset: range.endOffset,
|
|
177
182
|
commonRange: range
|
|
@@ -313,9 +318,11 @@ export default function (options) {
|
|
|
313
318
|
const wrapperNode = wrapTextNode(currentNode, currentGroupId);
|
|
314
319
|
if (wrapperNode) {
|
|
315
320
|
const splitData = splitDatas.find(d => d.node === currentNode);
|
|
316
|
-
addSplitData(
|
|
321
|
+
addSplitData(
|
|
322
|
+
wrapperNode,
|
|
317
323
|
splitData ? splitData.beforeWasSplit : false,
|
|
318
|
-
splitData ? splitData.afterWasSplit : false
|
|
324
|
+
splitData ? splitData.afterWasSplit : false
|
|
325
|
+
);
|
|
319
326
|
}
|
|
320
327
|
}
|
|
321
328
|
|
|
@@ -343,9 +350,9 @@ export default function (options) {
|
|
|
343
350
|
* @param {Node} textNode
|
|
344
351
|
* @param {string} activeClass
|
|
345
352
|
* @param {Range} selectedRange
|
|
346
|
-
* @param {number}
|
|
353
|
+
* @param {number} groupId
|
|
347
354
|
*/
|
|
348
|
-
function highlightContainerNodes(textNode, activeClass, selectedRange,
|
|
355
|
+
function highlightContainerNodes(textNode, activeClass, selectedRange, groupId) {
|
|
349
356
|
const container = textNode.parentNode;
|
|
350
357
|
const range = new Range();
|
|
351
358
|
range.selectNodeContents(textNode);
|
|
@@ -409,13 +416,13 @@ export default function (options) {
|
|
|
409
416
|
textNode.parentNode.className = activeClass;
|
|
410
417
|
} else if (isSelectionCoversNodeStart) {
|
|
411
418
|
textNode.splitText(selectedRange.endOffset);
|
|
412
|
-
wrapContainerChildNodes(container, 0, activeClass,
|
|
419
|
+
wrapContainerChildNodes(container, 0, activeClass, groupId);
|
|
413
420
|
} else if (isSelectionCoversNodeEnd) {
|
|
414
421
|
textNode.splitText(selectedRange.startOffset);
|
|
415
|
-
wrapContainerChildNodes(container, 1, activeClass,
|
|
422
|
+
wrapContainerChildNodes(container, 1, activeClass, groupId);
|
|
416
423
|
} else {
|
|
417
424
|
textNode.splitText(selectedRange.startOffset).splitText(selectedRange.endOffset);
|
|
418
|
-
wrapContainerChildNodes(container, 1, activeClass,
|
|
425
|
+
wrapContainerChildNodes(container, 1, activeClass, groupId);
|
|
419
426
|
}
|
|
420
427
|
}
|
|
421
428
|
|
|
@@ -425,9 +432,9 @@ export default function (options) {
|
|
|
425
432
|
* @param {Element} container
|
|
426
433
|
* @param {number} indexToWrapNode
|
|
427
434
|
* @param {string} activeClass
|
|
428
|
-
* @param {number}
|
|
435
|
+
* @param {number} groupId
|
|
429
436
|
*/
|
|
430
|
-
function wrapContainerChildNodes(container, indexToWrapNode, activeClass,
|
|
437
|
+
function wrapContainerChildNodes(container, indexToWrapNode, activeClass, groupId) {
|
|
431
438
|
const containerClass = container.className;
|
|
432
439
|
const fragment = new DocumentFragment();
|
|
433
440
|
const childNodesLength = container.childNodes.length;
|
|
@@ -435,16 +442,18 @@ export default function (options) {
|
|
|
435
442
|
container.childNodes.forEach((node, index) => {
|
|
436
443
|
var wrapperNode;
|
|
437
444
|
if (index === indexToWrapNode) {
|
|
438
|
-
wrapperNode = wrapNode(node.cloneNode(), activeClass,
|
|
445
|
+
wrapperNode = wrapNode(node.cloneNode(), activeClass, groupId);
|
|
439
446
|
} else {
|
|
440
|
-
wrapperNode = wrapNode(node.cloneNode(), containerClass,
|
|
447
|
+
wrapperNode = wrapNode(node.cloneNode(), containerClass, groupId);
|
|
441
448
|
}
|
|
442
449
|
fragment.appendChild(wrapperNode);
|
|
443
450
|
|
|
444
451
|
if (keepEmptyNodes) {
|
|
445
|
-
addSplitData(
|
|
452
|
+
addSplitData(
|
|
453
|
+
wrapperNode,
|
|
446
454
|
index === 0 ? container.dataset.beforeWasSplit : true,
|
|
447
|
-
index === childNodesLength - 1 ? container.dataset.afterWasSplit : true
|
|
455
|
+
index === childNodesLength - 1 ? container.dataset.afterWasSplit : true
|
|
456
|
+
);
|
|
448
457
|
}
|
|
449
458
|
});
|
|
450
459
|
|
|
@@ -476,8 +485,8 @@ export default function (options) {
|
|
|
476
485
|
return;
|
|
477
486
|
}
|
|
478
487
|
|
|
479
|
-
|
|
480
|
-
|
|
488
|
+
const childNodes = rootNode.childNodes;
|
|
489
|
+
let i, currentNode, parent;
|
|
481
490
|
|
|
482
491
|
for (i = 0; i < childNodes.length; i++) {
|
|
483
492
|
currentNode = childNodes[i];
|
|
@@ -509,8 +518,8 @@ export default function (options) {
|
|
|
509
518
|
return;
|
|
510
519
|
}
|
|
511
520
|
|
|
512
|
-
|
|
513
|
-
|
|
521
|
+
const childNodes = rootNode.childNodes;
|
|
522
|
+
let i, currentNode;
|
|
514
523
|
|
|
515
524
|
for (i = 0; i < childNodes.length; i++) {
|
|
516
525
|
currentNode = childNodes[i];
|
|
@@ -528,7 +537,11 @@ export default function (options) {
|
|
|
528
537
|
}
|
|
529
538
|
currentNode.firstChild.textContent += currentNode.nextSibling.firstChild.textContent;
|
|
530
539
|
if (keepEmptyNodes) {
|
|
531
|
-
addSplitData(
|
|
540
|
+
addSplitData(
|
|
541
|
+
currentNode,
|
|
542
|
+
currentNode.dataset.beforeWasSplit,
|
|
543
|
+
currentNode.nextSibling.dataset.afterWasSplit
|
|
544
|
+
);
|
|
532
545
|
}
|
|
533
546
|
currentNode.parentNode.removeChild(currentNode.nextSibling);
|
|
534
547
|
}
|
|
@@ -569,12 +582,14 @@ export default function (options) {
|
|
|
569
582
|
return true;
|
|
570
583
|
}
|
|
571
584
|
const prevNode = node.previousSibling;
|
|
572
|
-
const canWrapperBeMergedWithPreviousSibling =
|
|
585
|
+
const canWrapperBeMergedWithPreviousSibling =
|
|
586
|
+
prevNode && isWrappingNode(prevNode) && prevNode.className === className;
|
|
573
587
|
if (canWrapperBeMergedWithPreviousSibling) {
|
|
574
588
|
return true;
|
|
575
589
|
}
|
|
576
590
|
const nextNode = node.nextSibling;
|
|
577
|
-
const canWrapperBeMergedWithNextSibling =
|
|
591
|
+
const canWrapperBeMergedWithNextSibling =
|
|
592
|
+
nextNode && isWrappingNode(nextNode) && nextNode.className === className;
|
|
578
593
|
if (canWrapperBeMergedWithNextSibling) {
|
|
579
594
|
return true;
|
|
580
595
|
}
|
|
@@ -615,7 +630,7 @@ export default function (options) {
|
|
|
615
630
|
function clearHighlights() {
|
|
616
631
|
getHighlightedNodes().each(function (i, elem) {
|
|
617
632
|
if (!keepEmptyNodes) {
|
|
618
|
-
|
|
633
|
+
const $wrapped = $(this);
|
|
619
634
|
$wrapped.replaceWith($wrapped.text());
|
|
620
635
|
} else {
|
|
621
636
|
clearSingleHighlight({ target: elem });
|
|
@@ -650,13 +665,17 @@ export default function (options) {
|
|
|
650
665
|
prevNode.textContent += nodeToRemoveText;
|
|
651
666
|
nodeToRemove.remove();
|
|
652
667
|
|
|
653
|
-
if (
|
|
668
|
+
if (
|
|
669
|
+
afterWasSplit &&
|
|
670
|
+
prevNode.nextSibling &&
|
|
671
|
+
isText(prevNode.nextSibling) &&
|
|
672
|
+
prevNode.nextSibling.textContent
|
|
673
|
+
) {
|
|
654
674
|
//merge it with next sibling
|
|
655
675
|
prevNode.textContent += prevNode.nextSibling.textContent;
|
|
656
676
|
prevNode.nextSibling.remove();
|
|
657
677
|
}
|
|
658
|
-
}
|
|
659
|
-
else if (afterWasSplit && nextNode && isText(nextNode) && nextNode.textContent) {
|
|
678
|
+
} else if (afterWasSplit && nextNode && isText(nextNode) && nextNode.textContent) {
|
|
660
679
|
//append text to next sibling
|
|
661
680
|
nextNode.textContent = nodeToRemoveText + nextNode.textContent;
|
|
662
681
|
nodeToRemove.remove();
|
|
@@ -689,7 +708,7 @@ export default function (options) {
|
|
|
689
708
|
function getHighlightIndex() {
|
|
690
709
|
var rootNode = getContainer();
|
|
691
710
|
if (!keepEmptyNodes) {
|
|
692
|
-
|
|
711
|
+
const highlightIndex = [];
|
|
693
712
|
if (rootNode) {
|
|
694
713
|
rootNode.normalize();
|
|
695
714
|
textNodesIndex = 0;
|
|
@@ -711,8 +730,8 @@ export default function (options) {
|
|
|
711
730
|
* @param {Object[]} highlightIndex
|
|
712
731
|
*/
|
|
713
732
|
function buildHighlightIndex(rootNode, highlightIndex) {
|
|
714
|
-
|
|
715
|
-
|
|
733
|
+
const childNodes = rootNode.childNodes;
|
|
734
|
+
let i, currentNode;
|
|
716
735
|
var nodeInfos, inlineRange, inlineOffset, nodesToSkip;
|
|
717
736
|
|
|
718
737
|
for (i = 0; i < childNodes.length; i++) {
|
|
@@ -812,28 +831,29 @@ export default function (options) {
|
|
|
812
831
|
function buildHighlightModelKeepEmpty(rootNode) {
|
|
813
832
|
const classNames = options.colors ? Object.values(options.colors) : [className];
|
|
814
833
|
const wrapperNodesSelector = classNames.map(cls => containerSelector + ' .' + cls).join(', ');
|
|
815
|
-
const wrapperNodes = Array.from(document.querySelectorAll(wrapperNodesSelector))
|
|
816
|
-
|
|
834
|
+
const wrapperNodes = Array.from(document.querySelectorAll(wrapperNodesSelector)).filter(
|
|
835
|
+
node => !isBlacklisted(node)
|
|
836
|
+
);
|
|
817
837
|
|
|
818
838
|
if (!wrapperNodes.length) {
|
|
819
839
|
return null;
|
|
820
840
|
}
|
|
821
841
|
|
|
822
|
-
|
|
842
|
+
const highlightModel = [];
|
|
823
843
|
const indexCache = new Map();
|
|
824
|
-
for (
|
|
825
|
-
|
|
844
|
+
for (let k = 0; k < wrapperNodes.length; k++) {
|
|
845
|
+
const wrapperNode = wrapperNodes[k];
|
|
826
846
|
|
|
827
847
|
//get info about highlight itself
|
|
828
|
-
|
|
829
|
-
|
|
848
|
+
let offsetBefore = 0;
|
|
849
|
+
const prevNode = wrapperNode.previousSibling;
|
|
830
850
|
if (prevNode && isText(prevNode)) {
|
|
831
851
|
const beforeWasSplit = wrapperNode.dataset.beforeWasSplit === 'true';
|
|
832
852
|
if (beforeWasSplit) {
|
|
833
853
|
offsetBefore = prevNode.textContent.length;
|
|
834
854
|
}
|
|
835
855
|
}
|
|
836
|
-
|
|
856
|
+
const highlightData = {
|
|
837
857
|
groupId: wrapperNode.getAttribute(GROUP_ATTR),
|
|
838
858
|
c: getColorByClassName(wrapperNode.className),
|
|
839
859
|
offsetBefore,
|
|
@@ -849,7 +869,9 @@ export default function (options) {
|
|
|
849
869
|
let indexInModel = indexCache.get(currentNode);
|
|
850
870
|
if (!indexInModel && indexInModel !== 0) {
|
|
851
871
|
//should be more reliable to ignore empty nodes when indexing
|
|
852
|
-
const childNodes = Array.from(currentNode.parentNode.childNodes).filter(
|
|
872
|
+
const childNodes = Array.from(currentNode.parentNode.childNodes).filter(
|
|
873
|
+
node => !(isText(node) && !node.textContent.length)
|
|
874
|
+
);
|
|
853
875
|
//index among its non-empty siblings
|
|
854
876
|
indexInModel = childNodes.indexOf(currentNode);
|
|
855
877
|
indexCache.set(currentNode, indexInModel);
|
|
@@ -889,7 +911,7 @@ export default function (options) {
|
|
|
889
911
|
* @param {Node} rootNode
|
|
890
912
|
* @param {Object[]} highlightIndex
|
|
891
913
|
*/
|
|
892
|
-
|
|
914
|
+
function restoreHighlight(rootNode, highlightIndex) {
|
|
893
915
|
var childNodes = rootNode.childNodes;
|
|
894
916
|
var i, currentNode, parent;
|
|
895
917
|
var nodeInfos, nodesToSkip, range, initialChildCount;
|
|
@@ -930,7 +952,7 @@ export default function (options) {
|
|
|
930
952
|
restoreHighlight(currentNode, highlightIndex);
|
|
931
953
|
}
|
|
932
954
|
}
|
|
933
|
-
|
|
955
|
+
}
|
|
934
956
|
|
|
935
957
|
/**
|
|
936
958
|
* For `keepEmptyNodes` option, wraps the text nodes according to highlights data model.
|
|
@@ -943,9 +965,9 @@ export default function (options) {
|
|
|
943
965
|
return;
|
|
944
966
|
}
|
|
945
967
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
for (
|
|
968
|
+
let currentModel;
|
|
969
|
+
let range;
|
|
970
|
+
for (let k = 0; k < highlightModel.length; k++) {
|
|
949
971
|
currentModel = highlightModel[k];
|
|
950
972
|
|
|
951
973
|
//find node to wrap - go through nodes until we reach level where node to wrap will be
|
|
@@ -956,9 +978,11 @@ export default function (options) {
|
|
|
956
978
|
if (!currentModel.path || !currentModel.path.length) {
|
|
957
979
|
continue; //something went wrong
|
|
958
980
|
}
|
|
959
|
-
for (
|
|
981
|
+
for (let m = 0; m < currentModel.path.length; m++) {
|
|
960
982
|
//path was counted among non-empty nodes
|
|
961
|
-
childNodes = Array.from(currentParentNode.childNodes).filter(
|
|
983
|
+
childNodes = Array.from(currentParentNode.childNodes).filter(
|
|
984
|
+
node => !(isText(node) && !node.textContent.length)
|
|
985
|
+
);
|
|
962
986
|
indexInModel = currentModel.path[m];
|
|
963
987
|
currentParentNode = childNodes[indexInModel];
|
|
964
988
|
if (!currentParentNode && m < currentModel.path.length - 1) {
|
|
@@ -972,7 +996,7 @@ export default function (options) {
|
|
|
972
996
|
}
|
|
973
997
|
|
|
974
998
|
//add single highlight
|
|
975
|
-
|
|
999
|
+
let nodeAtIndex = null;
|
|
976
1000
|
if (!currentModel.offsetBefore) {
|
|
977
1001
|
//wrap starts on this node
|
|
978
1002
|
nodeAtIndex = childNodes[indexInModel];
|
|
@@ -981,9 +1005,13 @@ export default function (options) {
|
|
|
981
1005
|
}
|
|
982
1006
|
} else {
|
|
983
1007
|
//split previousSibling to create a node for wrapping
|
|
984
|
-
|
|
985
|
-
if (
|
|
986
|
-
|
|
1008
|
+
const nodeBefore = childNodes[indexInModel - 1];
|
|
1009
|
+
if (
|
|
1010
|
+
!nodeBefore ||
|
|
1011
|
+
!isText(nodeBefore) ||
|
|
1012
|
+
nodeBefore.textContent.length <= currentModel.offsetBefore ||
|
|
1013
|
+
isBlacklisted(nodeBefore)
|
|
1014
|
+
) {
|
|
987
1015
|
continue; //something went wrong
|
|
988
1016
|
}
|
|
989
1017
|
nodeAtIndex = nodeBefore.splitText(currentModel.offsetBefore);
|
|
@@ -1006,11 +1034,11 @@ export default function (options) {
|
|
|
1006
1034
|
* Set highlighter color
|
|
1007
1035
|
* @param {string} color Active highlighter color
|
|
1008
1036
|
*/
|
|
1009
|
-
|
|
1037
|
+
function setActiveColor(color) {
|
|
1010
1038
|
if (options.colors[color]) {
|
|
1011
1039
|
className = options.colors[color];
|
|
1012
1040
|
}
|
|
1013
|
-
}
|
|
1041
|
+
}
|
|
1014
1042
|
|
|
1015
1043
|
/**
|
|
1016
1044
|
* Helpers
|
|
@@ -1022,33 +1050,33 @@ export default function (options) {
|
|
|
1022
1050
|
* @param {any} value
|
|
1023
1051
|
* @return {string|undefined}
|
|
1024
1052
|
*/
|
|
1025
|
-
|
|
1053
|
+
function getKeyByValue(object, value) {
|
|
1054
|
+
return Object.keys(object).find(key => object[key] === value);
|
|
1055
|
+
}
|
|
1026
1056
|
|
|
1027
1057
|
/**
|
|
1028
1058
|
* Returns color identifier for the given class name
|
|
1029
1059
|
* @param {string} highlighterClassName Class name of highlighter classes
|
|
1030
1060
|
* @returns {string|number} Color identifier
|
|
1031
1061
|
*/
|
|
1032
|
-
|
|
1062
|
+
function getColorByClassName(highlighterClassName) {
|
|
1033
1063
|
if (options.colors) {
|
|
1034
1064
|
return getKeyByValue(options.colors, highlighterClassName);
|
|
1035
1065
|
}
|
|
1036
|
-
|
|
1037
1066
|
return className;
|
|
1038
|
-
}
|
|
1067
|
+
}
|
|
1039
1068
|
|
|
1040
1069
|
/**
|
|
1041
1070
|
* Returns class name for the given color identifier
|
|
1042
1071
|
* @param {string|number} color Color identifier
|
|
1043
1072
|
* @returns {string} Class name
|
|
1044
1073
|
*/
|
|
1045
|
-
|
|
1074
|
+
function getClassNameByColor(color) {
|
|
1046
1075
|
if (options.colors && options.colors[color]) {
|
|
1047
1076
|
return options.colors[color];
|
|
1048
1077
|
}
|
|
1049
|
-
|
|
1050
1078
|
return className;
|
|
1051
|
-
}
|
|
1079
|
+
}
|
|
1052
1080
|
|
|
1053
1081
|
/**
|
|
1054
1082
|
* Check if the given node is a wrapper
|
|
@@ -1090,12 +1118,11 @@ export default function (options) {
|
|
|
1090
1118
|
/**
|
|
1091
1119
|
* Wraps text node to the highlighter wrapper element
|
|
1092
1120
|
* @param {Node} textNode Text node to wrap
|
|
1093
|
-
* @param {string}
|
|
1121
|
+
* @param {string} wrapperClassName Wrapper class name
|
|
1094
1122
|
* @param {number} groupId Group id
|
|
1095
1123
|
*/
|
|
1096
|
-
function wrapNode(textNode,
|
|
1097
|
-
const element = getWrapper(groupId,
|
|
1098
|
-
|
|
1124
|
+
function wrapNode(textNode, wrapperClassName, groupId) {
|
|
1125
|
+
const element = getWrapper(groupId, wrapperClassName);
|
|
1099
1126
|
element.appendChild(textNode);
|
|
1100
1127
|
return element;
|
|
1101
1128
|
}
|
|
@@ -1107,7 +1134,6 @@ export default function (options) {
|
|
|
1107
1134
|
*/
|
|
1108
1135
|
function getWrapper(groupId, wrapperClass) {
|
|
1109
1136
|
const wrapper = document.createElement('span');
|
|
1110
|
-
|
|
1111
1137
|
wrapper.className = wrapperClass || className;
|
|
1112
1138
|
wrapper.setAttribute(GROUP_ATTR, `${groupId}`);
|
|
1113
1139
|
return wrapper;
|
package/src/incrementer.js
CHANGED
|
@@ -44,13 +44,11 @@ var Incrementer = {
|
|
|
44
44
|
* @param {Number} [options.zero] - whether input can take zero value even in min value more than zero
|
|
45
45
|
* @returns {jQueryElement} for chaining
|
|
46
46
|
*/
|
|
47
|
-
init: function(options) {
|
|
48
|
-
var self = Incrementer;
|
|
49
|
-
|
|
47
|
+
init: function (options) {
|
|
50
48
|
//get options using default
|
|
51
49
|
options = _.defaults(options || {}, defaults);
|
|
52
50
|
|
|
53
|
-
return this.each(function() {
|
|
51
|
+
return this.each(function () {
|
|
54
52
|
var $elt = $(this);
|
|
55
53
|
var wrapper = $('<span>', { class: options.incrementerWrapperClass });
|
|
56
54
|
var $ctrl, currentValue;
|
|
@@ -66,25 +64,19 @@ var Incrementer = {
|
|
|
66
64
|
.addClass(options.incrementerClass) //add the css class
|
|
67
65
|
.after(
|
|
68
66
|
//set up controls
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
options.step +
|
|
74
|
-
'" tabindex="-1"></a>' +
|
|
75
|
-
'<a href="#" class="dec" title="-' +
|
|
76
|
-
options.step +
|
|
77
|
-
'" tabindex="-1"></a>' +
|
|
78
|
-
'</span>'
|
|
67
|
+
`<span class="ctrl ${options.incrementerCtrlClass}">
|
|
68
|
+
<a href="#" class="inc" title="${options.step}" tabindex="-1"></a>
|
|
69
|
+
<a href="#" class="dec" title="-${options.step}" tabindex="-1"></a>
|
|
70
|
+
</span>`
|
|
79
71
|
)
|
|
80
|
-
.on('keydown', function(e) {
|
|
72
|
+
.on('keydown', function (e) {
|
|
81
73
|
if (e.which === 38) {
|
|
82
74
|
//up
|
|
83
|
-
|
|
75
|
+
Incrementer._inc($elt);
|
|
84
76
|
this.select();
|
|
85
77
|
} else if (e.which === 40) {
|
|
86
78
|
//down
|
|
87
|
-
|
|
79
|
+
Incrementer._dec($elt);
|
|
88
80
|
this.select();
|
|
89
81
|
}
|
|
90
82
|
})
|
|
@@ -92,13 +84,13 @@ var Incrementer = {
|
|
|
92
84
|
//(for instance, while taping an negative value)
|
|
93
85
|
.on(
|
|
94
86
|
'keyup',
|
|
95
|
-
_.debounce(function() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
_.debounce(function () {
|
|
88
|
+
let value = $elt.val();
|
|
89
|
+
const negative = value.charAt(0) === '-';
|
|
90
|
+
const dataOptions = $elt.data(dataNs);
|
|
99
91
|
|
|
100
92
|
//sanitize the string by removing all invalid characters (only allow digit and dot)
|
|
101
|
-
value = parseFloat(value.replace(/[^\d
|
|
93
|
+
value = parseFloat(value.replace(/[^\d.]/g, ''));
|
|
102
94
|
|
|
103
95
|
if (isNaN(value)) {
|
|
104
96
|
//allow empty input
|
|
@@ -109,19 +101,22 @@ var Incrementer = {
|
|
|
109
101
|
|
|
110
102
|
//check if the min and max are respected:
|
|
111
103
|
if (
|
|
112
|
-
|
|
113
|
-
(_.isNumber(
|
|
114
|
-
(
|
|
104
|
+
dataOptions.min === null ||
|
|
105
|
+
(_.isNumber(dataOptions.min) && value >= dataOptions.min) ||
|
|
106
|
+
(dataOptions.zero === true && value === 0)
|
|
115
107
|
) {
|
|
116
108
|
$elt.val(value);
|
|
117
109
|
} else {
|
|
118
|
-
$elt.val(
|
|
119
|
-
value =
|
|
110
|
+
$elt.val(dataOptions.min);
|
|
111
|
+
value = dataOptions.min;
|
|
120
112
|
}
|
|
121
|
-
if (
|
|
113
|
+
if (
|
|
114
|
+
dataOptions.max === null ||
|
|
115
|
+
(_.isNumber(dataOptions.max) && value <= dataOptions.max)
|
|
116
|
+
) {
|
|
122
117
|
$elt.val(value);
|
|
123
118
|
} else {
|
|
124
|
-
$elt.val(
|
|
119
|
+
$elt.val(dataOptions.max);
|
|
125
120
|
}
|
|
126
121
|
}
|
|
127
122
|
|
|
@@ -129,22 +124,16 @@ var Incrementer = {
|
|
|
129
124
|
$elt.trigger('change');
|
|
130
125
|
}, 600)
|
|
131
126
|
)
|
|
132
|
-
.on('focus', function() {
|
|
127
|
+
.on('focus', function () {
|
|
133
128
|
this.select();
|
|
134
129
|
})
|
|
135
|
-
.on('disable.incrementer', function() {
|
|
130
|
+
.on('disable.incrementer', function () {
|
|
136
131
|
$elt.prop('disabled', true).addClass('disabled');
|
|
137
|
-
$ctrl
|
|
138
|
-
.find('.inc,.dec')
|
|
139
|
-
.prop('disabled', true)
|
|
140
|
-
.addClass('disabled');
|
|
132
|
+
$ctrl.find('.inc,.dec').prop('disabled', true).addClass('disabled');
|
|
141
133
|
})
|
|
142
|
-
.on('enable.incrementer', function() {
|
|
134
|
+
.on('enable.incrementer', function () {
|
|
143
135
|
$elt.prop('disabled', false).removeClass('disabled');
|
|
144
|
-
$ctrl
|
|
145
|
-
.find('.inc,.dec')
|
|
146
|
-
.removeProp('disabled')
|
|
147
|
-
.removeClass('disabled');
|
|
136
|
+
$ctrl.find('.inc,.dec').removeProp('disabled').removeClass('disabled');
|
|
148
137
|
});
|
|
149
138
|
|
|
150
139
|
//set up the default value if needed
|
|
@@ -158,16 +147,16 @@ var Incrementer = {
|
|
|
158
147
|
|
|
159
148
|
$ctrl = $elt.next('.' + options.incrementerCtrlClass);
|
|
160
149
|
|
|
161
|
-
$ctrl.find('.inc').click(function(e) {
|
|
150
|
+
$ctrl.find('.inc').click(function (e) {
|
|
162
151
|
e.preventDefault();
|
|
163
152
|
if (!$(this).prop('disabled')) {
|
|
164
|
-
|
|
153
|
+
Incrementer._inc($elt);
|
|
165
154
|
}
|
|
166
155
|
});
|
|
167
|
-
$ctrl.find('.dec').click(function(e) {
|
|
156
|
+
$ctrl.find('.dec').click(function (e) {
|
|
168
157
|
e.preventDefault();
|
|
169
158
|
if (!$(this).prop('disabled')) {
|
|
170
|
-
|
|
159
|
+
Incrementer._dec($elt);
|
|
171
160
|
}
|
|
172
161
|
});
|
|
173
162
|
|
|
@@ -181,12 +170,12 @@ var Incrementer = {
|
|
|
181
170
|
});
|
|
182
171
|
},
|
|
183
172
|
|
|
184
|
-
_toFixedDown: function(number, precision) {
|
|
173
|
+
_toFixedDown: function (number, precision) {
|
|
185
174
|
var m = Math.pow(10, precision || 0);
|
|
186
175
|
return Math.floor(number * m) / m;
|
|
187
176
|
},
|
|
188
177
|
|
|
189
|
-
_decimalPlaces: function(number) {
|
|
178
|
+
_decimalPlaces: function (number) {
|
|
190
179
|
var match = ('' + number).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
|
|
191
180
|
if (!match) {
|
|
192
181
|
return 0;
|
|
@@ -201,7 +190,7 @@ var Incrementer = {
|
|
|
201
190
|
* @param {jQueryElement} $elt - plugin's element
|
|
202
191
|
* @fires Incrementer#plus.incrementer
|
|
203
192
|
*/
|
|
204
|
-
_inc: function($elt) {
|
|
193
|
+
_inc: function ($elt) {
|
|
205
194
|
var options = $elt.data(dataNs),
|
|
206
195
|
current = parseFloat($elt.val() || 0),
|
|
207
196
|
value;
|
|
@@ -228,7 +217,7 @@ var Incrementer = {
|
|
|
228
217
|
* @param {jQueryElement} $elt - plugin's element
|
|
229
218
|
* @fires Incrementer#minus.incrementer
|
|
230
219
|
*/
|
|
231
|
-
_dec: function($elt) {
|
|
220
|
+
_dec: function ($elt) {
|
|
232
221
|
var options = $elt.data(dataNs),
|
|
233
222
|
current = parseFloat($elt.val() || 0),
|
|
234
223
|
value;
|
|
@@ -260,8 +249,8 @@ var Incrementer = {
|
|
|
260
249
|
* @example $('selector').incrementer('destroy');
|
|
261
250
|
* @public
|
|
262
251
|
*/
|
|
263
|
-
destroy: function() {
|
|
264
|
-
this.each(function() {
|
|
252
|
+
destroy: function () {
|
|
253
|
+
this.each(function () {
|
|
265
254
|
var $elt = $(this);
|
|
266
255
|
var options = $elt.data(dataNs);
|
|
267
256
|
$elt.off('keyup keydown')
|
|
@@ -288,7 +277,7 @@ Pluginifier.register(ns, Incrementer);
|
|
|
288
277
|
* @param {jQueryElement} $container - the root context to listen in
|
|
289
278
|
*/
|
|
290
279
|
export default function listenDataAttr($container) {
|
|
291
|
-
$container.find('[data-increment]').each(function() {
|
|
280
|
+
$container.find('[data-increment]').each(function () {
|
|
292
281
|
var $elt = $(this);
|
|
293
282
|
var decimal = Incrementer._decimalPlaces($elt.attr('data-increment'));
|
|
294
283
|
var step = parseFloat($elt.attr('data-increment'));
|
|
@@ -317,4 +306,4 @@ export default function listenDataAttr($container) {
|
|
|
317
306
|
}
|
|
318
307
|
$elt.incrementer(options);
|
|
319
308
|
});
|
|
320
|
-
}
|
|
309
|
+
}
|