jsuites 4.10.5 → 4.11.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/jsuites.basic.js +120 -21
- package/dist/jsuites.js +330 -127
- package/package.json +1 -1
package/dist/jsuites.basic.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
var jSuites = function(options) {
|
|
19
19
|
var obj = {}
|
|
20
|
-
var version = '4.
|
|
20
|
+
var version = '4.11.0';
|
|
21
21
|
|
|
22
22
|
var find = function(DOMElement, component) {
|
|
23
23
|
if (DOMElement[component.type] && DOMElement[component.type] == component) {
|
|
@@ -4880,6 +4880,7 @@ jSuites.editor = (function(el, options) {
|
|
|
4880
4880
|
onkeyup: null,
|
|
4881
4881
|
onkeydown: null,
|
|
4882
4882
|
onchange: null,
|
|
4883
|
+
userSearch: null,
|
|
4883
4884
|
};
|
|
4884
4885
|
|
|
4885
4886
|
// Loop through our object
|
|
@@ -4958,7 +4959,7 @@ jSuites.editor = (function(el, options) {
|
|
|
4958
4959
|
if (obj.options.value) {
|
|
4959
4960
|
var value = obj.options.value;
|
|
4960
4961
|
} else {
|
|
4961
|
-
var value = el.innerHTML ? el.innerHTML : '';
|
|
4962
|
+
var value = el.innerHTML ? el.innerHTML : '';
|
|
4962
4963
|
}
|
|
4963
4964
|
|
|
4964
4965
|
if (! value) {
|
|
@@ -4969,7 +4970,7 @@ jSuites.editor = (function(el, options) {
|
|
|
4969
4970
|
* Onchange event controllers
|
|
4970
4971
|
*/
|
|
4971
4972
|
var change = function(e) {
|
|
4972
|
-
if (typeof(obj.options.onchange) == 'function') {
|
|
4973
|
+
if (typeof(obj.options.onchange) == 'function') {
|
|
4973
4974
|
obj.options.onchange(el, obj, e);
|
|
4974
4975
|
}
|
|
4975
4976
|
|
|
@@ -4989,6 +4990,25 @@ jSuites.editor = (function(el, options) {
|
|
|
4989
4990
|
}
|
|
4990
4991
|
}
|
|
4991
4992
|
|
|
4993
|
+
// Create node
|
|
4994
|
+
var createUserSearchNode = function() {
|
|
4995
|
+
// Get coordinates from caret
|
|
4996
|
+
var sel = window.getSelection ? window.getSelection() : document.selection;
|
|
4997
|
+
var range = sel.getRangeAt(0);
|
|
4998
|
+
range.deleteContents();
|
|
4999
|
+
// Append text node
|
|
5000
|
+
var input = document.createElement('a');
|
|
5001
|
+
input.innerText = '@';
|
|
5002
|
+
input.searchable = true;
|
|
5003
|
+
range.insertNode(input);
|
|
5004
|
+
var node = range.getBoundingClientRect();
|
|
5005
|
+
range.collapse(false);
|
|
5006
|
+
// Position
|
|
5007
|
+
userSearch.style.position = 'fixed';
|
|
5008
|
+
userSearch.style.top = node.top + node.height + 10 + 'px';
|
|
5009
|
+
userSearch.style.left = node.left + 2 + 'px';
|
|
5010
|
+
}
|
|
5011
|
+
|
|
4992
5012
|
/**
|
|
4993
5013
|
* Extract images from a HTML string
|
|
4994
5014
|
*/
|
|
@@ -5019,10 +5039,10 @@ jSuites.editor = (function(el, options) {
|
|
|
5019
5039
|
range = sel.getRangeAt(0);
|
|
5020
5040
|
var selectedText = range.toString();
|
|
5021
5041
|
range.deleteContents();
|
|
5022
|
-
range.insertNode(newNode);
|
|
5042
|
+
range.insertNode(newNode);
|
|
5023
5043
|
// move the cursor after element
|
|
5024
5044
|
range.setStartAfter(newNode);
|
|
5025
|
-
range.setEndAfter(newNode);
|
|
5045
|
+
range.setEndAfter(newNode);
|
|
5026
5046
|
sel.removeAllRanges();
|
|
5027
5047
|
sel.addRange(range);
|
|
5028
5048
|
}
|
|
@@ -5104,7 +5124,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5104
5124
|
var html = editor.innerHTML.replace(/\n/g, ' ');
|
|
5105
5125
|
var container = document.createElement('div');
|
|
5106
5126
|
container.innerHTML = html;
|
|
5107
|
-
var text = container.innerText;
|
|
5127
|
+
var text = container.innerText;
|
|
5108
5128
|
var url = jSuites.editor.detectUrl(text);
|
|
5109
5129
|
|
|
5110
5130
|
if (url) {
|
|
@@ -5250,8 +5270,31 @@ jSuites.editor = (function(el, options) {
|
|
|
5250
5270
|
}
|
|
5251
5271
|
}
|
|
5252
5272
|
|
|
5273
|
+
// Users
|
|
5274
|
+
if (userSearch) {
|
|
5275
|
+
// Get tag users
|
|
5276
|
+
var tagged = editor.querySelectorAll('a[data-user]');
|
|
5277
|
+
if (tagged.length) {
|
|
5278
|
+
data.users = [];
|
|
5279
|
+
for (var i = 0; i < tagged.length; i++) {
|
|
5280
|
+
var userId = tagged[i].getAttribute('data-user');
|
|
5281
|
+
if (userId) {
|
|
5282
|
+
data.users.push(userId);
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
data.users = data.users.join(',');
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
|
|
5253
5289
|
// Get content
|
|
5254
|
-
var
|
|
5290
|
+
var d = document.createElement('div');
|
|
5291
|
+
d.innerHTML = editor.innerHTML;
|
|
5292
|
+
var s = d.querySelector('.jsnippet');
|
|
5293
|
+
if (s) {
|
|
5294
|
+
s.remove();
|
|
5295
|
+
}
|
|
5296
|
+
|
|
5297
|
+
var text = d.innerHTML;
|
|
5255
5298
|
text = text.replace(/<br>/g, "\n");
|
|
5256
5299
|
text = text.replace(/<\/div>/g, "<\/div>\n");
|
|
5257
5300
|
text = text.replace(/<(?:.|\n)*?>/gm, "");
|
|
@@ -5410,13 +5453,8 @@ jSuites.editor = (function(el, options) {
|
|
|
5410
5453
|
editor.removeEventListener('dragover', editorDragOver);
|
|
5411
5454
|
editor.removeEventListener('drop', editorDrop);
|
|
5412
5455
|
editor.removeEventListener('paste', editorPaste);
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
editor.removeEventListener('blur', editorBlur);
|
|
5416
|
-
}
|
|
5417
|
-
if (typeof(obj.options.onfocus) == 'function') {
|
|
5418
|
-
editor.removeEventListener('focus', editorFocus);
|
|
5419
|
-
}
|
|
5456
|
+
editor.removeEventListener('blur', editorBlur);
|
|
5457
|
+
editor.removeEventListener('focus', editorFocus);
|
|
5420
5458
|
|
|
5421
5459
|
el.editor = null;
|
|
5422
5460
|
el.classList.remove('jeditor-container');
|
|
@@ -5480,7 +5518,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5480
5518
|
} else {
|
|
5481
5519
|
editorAction = true;
|
|
5482
5520
|
}
|
|
5483
|
-
} else {
|
|
5521
|
+
} else {
|
|
5484
5522
|
if (e.target.classList.contains('jsnippet')) {
|
|
5485
5523
|
close(e.target);
|
|
5486
5524
|
} else if (e.target.parentNode.classList.contains('jsnippet')) {
|
|
@@ -5549,7 +5587,23 @@ jSuites.editor = (function(el, options) {
|
|
|
5549
5587
|
editor.innerHTML = '<div><br></div>';
|
|
5550
5588
|
}
|
|
5551
5589
|
|
|
5552
|
-
if (
|
|
5590
|
+
if (userSearch) {
|
|
5591
|
+
var t = jSuites.getNode();
|
|
5592
|
+
if (t) {
|
|
5593
|
+
if (t.searchable === true) {
|
|
5594
|
+
if (t.innerText && t.innerText.substr(0,1) == '@') {
|
|
5595
|
+
userSearchInstance(t.innerText.substr(1));
|
|
5596
|
+
}
|
|
5597
|
+
} else if (t.searchable === false) {
|
|
5598
|
+
if (t.innerText !== t.getAttribute('data-label')) {
|
|
5599
|
+
t.searchable = true;
|
|
5600
|
+
t.removeAttribute('href');
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
}
|
|
5605
|
+
|
|
5606
|
+
if (typeof(obj.options.onkeyup) == 'function') {
|
|
5553
5607
|
obj.options.onkeyup(el, obj, e);
|
|
5554
5608
|
}
|
|
5555
5609
|
}
|
|
@@ -5561,7 +5615,18 @@ jSuites.editor = (function(el, options) {
|
|
|
5561
5615
|
verifyEditor();
|
|
5562
5616
|
}
|
|
5563
5617
|
|
|
5564
|
-
if (
|
|
5618
|
+
if (userSearch) {
|
|
5619
|
+
if (e.key == '@') {
|
|
5620
|
+
createUserSearchNode(editor);
|
|
5621
|
+
e.preventDefault();
|
|
5622
|
+
} else {
|
|
5623
|
+
if (userSearchInstance.isOpened()) {
|
|
5624
|
+
userSearchInstance.keydown(e);
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
}
|
|
5628
|
+
|
|
5629
|
+
if (typeof(obj.options.onkeydown) == 'function') {
|
|
5565
5630
|
obj.options.onkeydown(el, obj, e);
|
|
5566
5631
|
}
|
|
5567
5632
|
|
|
@@ -5653,7 +5718,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5653
5718
|
var span = document.createElement('span');
|
|
5654
5719
|
span.innerHTML = d.firstChild.innerHTML;
|
|
5655
5720
|
return span;
|
|
5656
|
-
}
|
|
5721
|
+
}
|
|
5657
5722
|
|
|
5658
5723
|
var editorPaste = function(e) {
|
|
5659
5724
|
if (obj.options.filterPaste == true) {
|
|
@@ -5747,7 +5812,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5747
5812
|
var html = (e.originalEvent || e).dataTransfer.getData('text/html');
|
|
5748
5813
|
var text = (e.originalEvent || e).dataTransfer.getData('text/plain');
|
|
5749
5814
|
var file = (e.originalEvent || e).dataTransfer.files;
|
|
5750
|
-
|
|
5815
|
+
|
|
5751
5816
|
if (file.length) {
|
|
5752
5817
|
obj.addFile(file);
|
|
5753
5818
|
} else if (text) {
|
|
@@ -5760,6 +5825,10 @@ jSuites.editor = (function(el, options) {
|
|
|
5760
5825
|
}
|
|
5761
5826
|
|
|
5762
5827
|
var editorBlur = function(e) {
|
|
5828
|
+
if (userSearch && userSearchInstance.isOpened()) {
|
|
5829
|
+
userSearchInstance.close();
|
|
5830
|
+
}
|
|
5831
|
+
|
|
5763
5832
|
// Blur
|
|
5764
5833
|
if (typeof(obj.options.onblur) == 'function') {
|
|
5765
5834
|
obj.options.onblur(el, obj, e);
|
|
@@ -5821,6 +5890,33 @@ jSuites.editor = (function(el, options) {
|
|
|
5821
5890
|
});
|
|
5822
5891
|
}
|
|
5823
5892
|
|
|
5893
|
+
// Add user search
|
|
5894
|
+
var userSearch = null;
|
|
5895
|
+
var userSearchInstance = null;
|
|
5896
|
+
if (obj.options.userSearch) {
|
|
5897
|
+
userSearch = document.createElement('div');
|
|
5898
|
+
el.appendChild(userSearch);
|
|
5899
|
+
|
|
5900
|
+
// Component
|
|
5901
|
+
userSearchInstance = jSuites.search(userSearch, {
|
|
5902
|
+
data: obj.options.userSearch,
|
|
5903
|
+
placeholder: jSuites.translate('Type the name a user'),
|
|
5904
|
+
onselect: function(a,b,c,d) {
|
|
5905
|
+
if (userSearchInstance.isOpened()) {
|
|
5906
|
+
var t = jSuites.getNode();
|
|
5907
|
+
if (t && t.searchable == true && (t.innerText.trim() && t.innerText.substr(1))) {
|
|
5908
|
+
t.innerText = '@' + c;
|
|
5909
|
+
t.href = '/' + c;
|
|
5910
|
+
t.setAttribute('data-user', d);
|
|
5911
|
+
t.setAttribute('data-label', t.innerText);
|
|
5912
|
+
t.searchable = false;
|
|
5913
|
+
jSuites.focus(t);
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
}
|
|
5917
|
+
});
|
|
5918
|
+
}
|
|
5919
|
+
|
|
5824
5920
|
// Focus to the editor
|
|
5825
5921
|
if (obj.options.focus) {
|
|
5826
5922
|
jSuites.editor.setCursor(editor, obj.options.focus == 'initial' ? true : false);
|
|
@@ -8044,8 +8140,11 @@ jSuites.mask = (function() {
|
|
|
8044
8140
|
type = getType.call(options, options.mask);
|
|
8045
8141
|
}
|
|
8046
8142
|
|
|
8143
|
+
if (type === 'general') {
|
|
8144
|
+
var o = obj(v, options, true);
|
|
8047
8145
|
|
|
8048
|
-
|
|
8146
|
+
value = v;
|
|
8147
|
+
} else if (type === 'datetime') {
|
|
8049
8148
|
if (v instanceof Date) {
|
|
8050
8149
|
var t = jSuites.calendar.getDateString(value, options.mask);
|
|
8051
8150
|
}
|
|
@@ -8665,7 +8764,7 @@ jSuites.picker = (function(el, options) {
|
|
|
8665
8764
|
obj.setValue(item.k);
|
|
8666
8765
|
// Call method
|
|
8667
8766
|
if (typeof(obj.options.onchange) == 'function') {
|
|
8668
|
-
obj.options.onchange.call(obj, el, obj, item.v, item.v, item.k);
|
|
8767
|
+
obj.options.onchange.call(obj, el, obj, item.v, item.v, item.k, e);
|
|
8669
8768
|
}
|
|
8670
8769
|
}
|
|
8671
8770
|
}
|
package/dist/jsuites.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
var jSuites = function(options) {
|
|
19
19
|
var obj = {}
|
|
20
|
-
var version = '4.
|
|
20
|
+
var version = '4.11.0';
|
|
21
21
|
|
|
22
22
|
var find = function(DOMElement, component) {
|
|
23
23
|
if (DOMElement[component.type] && DOMElement[component.type] == component) {
|
|
@@ -4891,6 +4891,7 @@ jSuites.editor = (function(el, options) {
|
|
|
4891
4891
|
onkeyup: null,
|
|
4892
4892
|
onkeydown: null,
|
|
4893
4893
|
onchange: null,
|
|
4894
|
+
userSearch: null,
|
|
4894
4895
|
};
|
|
4895
4896
|
|
|
4896
4897
|
// Loop through our object
|
|
@@ -4969,7 +4970,7 @@ jSuites.editor = (function(el, options) {
|
|
|
4969
4970
|
if (obj.options.value) {
|
|
4970
4971
|
var value = obj.options.value;
|
|
4971
4972
|
} else {
|
|
4972
|
-
var value = el.innerHTML ? el.innerHTML : '';
|
|
4973
|
+
var value = el.innerHTML ? el.innerHTML : '';
|
|
4973
4974
|
}
|
|
4974
4975
|
|
|
4975
4976
|
if (! value) {
|
|
@@ -4980,7 +4981,7 @@ jSuites.editor = (function(el, options) {
|
|
|
4980
4981
|
* Onchange event controllers
|
|
4981
4982
|
*/
|
|
4982
4983
|
var change = function(e) {
|
|
4983
|
-
if (typeof(obj.options.onchange) == 'function') {
|
|
4984
|
+
if (typeof(obj.options.onchange) == 'function') {
|
|
4984
4985
|
obj.options.onchange(el, obj, e);
|
|
4985
4986
|
}
|
|
4986
4987
|
|
|
@@ -5000,6 +5001,25 @@ jSuites.editor = (function(el, options) {
|
|
|
5000
5001
|
}
|
|
5001
5002
|
}
|
|
5002
5003
|
|
|
5004
|
+
// Create node
|
|
5005
|
+
var createUserSearchNode = function() {
|
|
5006
|
+
// Get coordinates from caret
|
|
5007
|
+
var sel = window.getSelection ? window.getSelection() : document.selection;
|
|
5008
|
+
var range = sel.getRangeAt(0);
|
|
5009
|
+
range.deleteContents();
|
|
5010
|
+
// Append text node
|
|
5011
|
+
var input = document.createElement('a');
|
|
5012
|
+
input.innerText = '@';
|
|
5013
|
+
input.searchable = true;
|
|
5014
|
+
range.insertNode(input);
|
|
5015
|
+
var node = range.getBoundingClientRect();
|
|
5016
|
+
range.collapse(false);
|
|
5017
|
+
// Position
|
|
5018
|
+
userSearch.style.position = 'fixed';
|
|
5019
|
+
userSearch.style.top = node.top + node.height + 10 + 'px';
|
|
5020
|
+
userSearch.style.left = node.left + 2 + 'px';
|
|
5021
|
+
}
|
|
5022
|
+
|
|
5003
5023
|
/**
|
|
5004
5024
|
* Extract images from a HTML string
|
|
5005
5025
|
*/
|
|
@@ -5030,10 +5050,10 @@ jSuites.editor = (function(el, options) {
|
|
|
5030
5050
|
range = sel.getRangeAt(0);
|
|
5031
5051
|
var selectedText = range.toString();
|
|
5032
5052
|
range.deleteContents();
|
|
5033
|
-
range.insertNode(newNode);
|
|
5053
|
+
range.insertNode(newNode);
|
|
5034
5054
|
// move the cursor after element
|
|
5035
5055
|
range.setStartAfter(newNode);
|
|
5036
|
-
range.setEndAfter(newNode);
|
|
5056
|
+
range.setEndAfter(newNode);
|
|
5037
5057
|
sel.removeAllRanges();
|
|
5038
5058
|
sel.addRange(range);
|
|
5039
5059
|
}
|
|
@@ -5115,7 +5135,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5115
5135
|
var html = editor.innerHTML.replace(/\n/g, ' ');
|
|
5116
5136
|
var container = document.createElement('div');
|
|
5117
5137
|
container.innerHTML = html;
|
|
5118
|
-
var text = container.innerText;
|
|
5138
|
+
var text = container.innerText;
|
|
5119
5139
|
var url = jSuites.editor.detectUrl(text);
|
|
5120
5140
|
|
|
5121
5141
|
if (url) {
|
|
@@ -5261,8 +5281,31 @@ jSuites.editor = (function(el, options) {
|
|
|
5261
5281
|
}
|
|
5262
5282
|
}
|
|
5263
5283
|
|
|
5284
|
+
// Users
|
|
5285
|
+
if (userSearch) {
|
|
5286
|
+
// Get tag users
|
|
5287
|
+
var tagged = editor.querySelectorAll('a[data-user]');
|
|
5288
|
+
if (tagged.length) {
|
|
5289
|
+
data.users = [];
|
|
5290
|
+
for (var i = 0; i < tagged.length; i++) {
|
|
5291
|
+
var userId = tagged[i].getAttribute('data-user');
|
|
5292
|
+
if (userId) {
|
|
5293
|
+
data.users.push(userId);
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
data.users = data.users.join(',');
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
5299
|
+
|
|
5264
5300
|
// Get content
|
|
5265
|
-
var
|
|
5301
|
+
var d = document.createElement('div');
|
|
5302
|
+
d.innerHTML = editor.innerHTML;
|
|
5303
|
+
var s = d.querySelector('.jsnippet');
|
|
5304
|
+
if (s) {
|
|
5305
|
+
s.remove();
|
|
5306
|
+
}
|
|
5307
|
+
|
|
5308
|
+
var text = d.innerHTML;
|
|
5266
5309
|
text = text.replace(/<br>/g, "\n");
|
|
5267
5310
|
text = text.replace(/<\/div>/g, "<\/div>\n");
|
|
5268
5311
|
text = text.replace(/<(?:.|\n)*?>/gm, "");
|
|
@@ -5421,13 +5464,8 @@ jSuites.editor = (function(el, options) {
|
|
|
5421
5464
|
editor.removeEventListener('dragover', editorDragOver);
|
|
5422
5465
|
editor.removeEventListener('drop', editorDrop);
|
|
5423
5466
|
editor.removeEventListener('paste', editorPaste);
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
editor.removeEventListener('blur', editorBlur);
|
|
5427
|
-
}
|
|
5428
|
-
if (typeof(obj.options.onfocus) == 'function') {
|
|
5429
|
-
editor.removeEventListener('focus', editorFocus);
|
|
5430
|
-
}
|
|
5467
|
+
editor.removeEventListener('blur', editorBlur);
|
|
5468
|
+
editor.removeEventListener('focus', editorFocus);
|
|
5431
5469
|
|
|
5432
5470
|
el.editor = null;
|
|
5433
5471
|
el.classList.remove('jeditor-container');
|
|
@@ -5491,7 +5529,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5491
5529
|
} else {
|
|
5492
5530
|
editorAction = true;
|
|
5493
5531
|
}
|
|
5494
|
-
} else {
|
|
5532
|
+
} else {
|
|
5495
5533
|
if (e.target.classList.contains('jsnippet')) {
|
|
5496
5534
|
close(e.target);
|
|
5497
5535
|
} else if (e.target.parentNode.classList.contains('jsnippet')) {
|
|
@@ -5560,7 +5598,23 @@ jSuites.editor = (function(el, options) {
|
|
|
5560
5598
|
editor.innerHTML = '<div><br></div>';
|
|
5561
5599
|
}
|
|
5562
5600
|
|
|
5563
|
-
if (
|
|
5601
|
+
if (userSearch) {
|
|
5602
|
+
var t = jSuites.getNode();
|
|
5603
|
+
if (t) {
|
|
5604
|
+
if (t.searchable === true) {
|
|
5605
|
+
if (t.innerText && t.innerText.substr(0,1) == '@') {
|
|
5606
|
+
userSearchInstance(t.innerText.substr(1));
|
|
5607
|
+
}
|
|
5608
|
+
} else if (t.searchable === false) {
|
|
5609
|
+
if (t.innerText !== t.getAttribute('data-label')) {
|
|
5610
|
+
t.searchable = true;
|
|
5611
|
+
t.removeAttribute('href');
|
|
5612
|
+
}
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
}
|
|
5616
|
+
|
|
5617
|
+
if (typeof(obj.options.onkeyup) == 'function') {
|
|
5564
5618
|
obj.options.onkeyup(el, obj, e);
|
|
5565
5619
|
}
|
|
5566
5620
|
}
|
|
@@ -5572,7 +5626,18 @@ jSuites.editor = (function(el, options) {
|
|
|
5572
5626
|
verifyEditor();
|
|
5573
5627
|
}
|
|
5574
5628
|
|
|
5575
|
-
if (
|
|
5629
|
+
if (userSearch) {
|
|
5630
|
+
if (e.key == '@') {
|
|
5631
|
+
createUserSearchNode(editor);
|
|
5632
|
+
e.preventDefault();
|
|
5633
|
+
} else {
|
|
5634
|
+
if (userSearchInstance.isOpened()) {
|
|
5635
|
+
userSearchInstance.keydown(e);
|
|
5636
|
+
}
|
|
5637
|
+
}
|
|
5638
|
+
}
|
|
5639
|
+
|
|
5640
|
+
if (typeof(obj.options.onkeydown) == 'function') {
|
|
5576
5641
|
obj.options.onkeydown(el, obj, e);
|
|
5577
5642
|
}
|
|
5578
5643
|
|
|
@@ -5664,7 +5729,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5664
5729
|
var span = document.createElement('span');
|
|
5665
5730
|
span.innerHTML = d.firstChild.innerHTML;
|
|
5666
5731
|
return span;
|
|
5667
|
-
}
|
|
5732
|
+
}
|
|
5668
5733
|
|
|
5669
5734
|
var editorPaste = function(e) {
|
|
5670
5735
|
if (obj.options.filterPaste == true) {
|
|
@@ -5758,7 +5823,7 @@ jSuites.editor = (function(el, options) {
|
|
|
5758
5823
|
var html = (e.originalEvent || e).dataTransfer.getData('text/html');
|
|
5759
5824
|
var text = (e.originalEvent || e).dataTransfer.getData('text/plain');
|
|
5760
5825
|
var file = (e.originalEvent || e).dataTransfer.files;
|
|
5761
|
-
|
|
5826
|
+
|
|
5762
5827
|
if (file.length) {
|
|
5763
5828
|
obj.addFile(file);
|
|
5764
5829
|
} else if (text) {
|
|
@@ -5771,6 +5836,10 @@ jSuites.editor = (function(el, options) {
|
|
|
5771
5836
|
}
|
|
5772
5837
|
|
|
5773
5838
|
var editorBlur = function(e) {
|
|
5839
|
+
if (userSearch && userSearchInstance.isOpened()) {
|
|
5840
|
+
userSearchInstance.close();
|
|
5841
|
+
}
|
|
5842
|
+
|
|
5774
5843
|
// Blur
|
|
5775
5844
|
if (typeof(obj.options.onblur) == 'function') {
|
|
5776
5845
|
obj.options.onblur(el, obj, e);
|
|
@@ -5832,6 +5901,33 @@ jSuites.editor = (function(el, options) {
|
|
|
5832
5901
|
});
|
|
5833
5902
|
}
|
|
5834
5903
|
|
|
5904
|
+
// Add user search
|
|
5905
|
+
var userSearch = null;
|
|
5906
|
+
var userSearchInstance = null;
|
|
5907
|
+
if (obj.options.userSearch) {
|
|
5908
|
+
userSearch = document.createElement('div');
|
|
5909
|
+
el.appendChild(userSearch);
|
|
5910
|
+
|
|
5911
|
+
// Component
|
|
5912
|
+
userSearchInstance = jSuites.search(userSearch, {
|
|
5913
|
+
data: obj.options.userSearch,
|
|
5914
|
+
placeholder: jSuites.translate('Type the name a user'),
|
|
5915
|
+
onselect: function(a,b,c,d) {
|
|
5916
|
+
if (userSearchInstance.isOpened()) {
|
|
5917
|
+
var t = jSuites.getNode();
|
|
5918
|
+
if (t && t.searchable == true && (t.innerText.trim() && t.innerText.substr(1))) {
|
|
5919
|
+
t.innerText = '@' + c;
|
|
5920
|
+
t.href = '/' + c;
|
|
5921
|
+
t.setAttribute('data-user', d);
|
|
5922
|
+
t.setAttribute('data-label', t.innerText);
|
|
5923
|
+
t.searchable = false;
|
|
5924
|
+
jSuites.focus(t);
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
}
|
|
5928
|
+
});
|
|
5929
|
+
}
|
|
5930
|
+
|
|
5835
5931
|
// Focus to the editor
|
|
5836
5932
|
if (obj.options.focus) {
|
|
5837
5933
|
jSuites.editor.setCursor(editor, obj.options.focus == 'initial' ? true : false);
|
|
@@ -8469,8 +8565,11 @@ jSuites.mask = (function() {
|
|
|
8469
8565
|
type = getType.call(options, options.mask);
|
|
8470
8566
|
}
|
|
8471
8567
|
|
|
8568
|
+
if (type === 'general') {
|
|
8569
|
+
var o = obj(v, options, true);
|
|
8472
8570
|
|
|
8473
|
-
|
|
8571
|
+
value = v;
|
|
8572
|
+
} else if (type === 'datetime') {
|
|
8474
8573
|
if (v instanceof Date) {
|
|
8475
8574
|
var t = jSuites.calendar.getDateString(value, options.mask);
|
|
8476
8575
|
}
|
|
@@ -8773,6 +8872,24 @@ jSuites.modal = (function(el, options) {
|
|
|
8773
8872
|
});
|
|
8774
8873
|
|
|
8775
8874
|
document.addEventListener('mouseup', function(e) {
|
|
8875
|
+
var item = jSuites.findElement(e.target, 'jmodal');
|
|
8876
|
+
if (item) {
|
|
8877
|
+
// Get target info
|
|
8878
|
+
var rect = item.getBoundingClientRect();
|
|
8879
|
+
|
|
8880
|
+
if (e.changedTouches && e.changedTouches[0]) {
|
|
8881
|
+
var x = e.changedTouches[0].clientX;
|
|
8882
|
+
var y = e.changedTouches[0].clientY;
|
|
8883
|
+
} else {
|
|
8884
|
+
var x = e.clientX;
|
|
8885
|
+
var y = e.clientY;
|
|
8886
|
+
}
|
|
8887
|
+
|
|
8888
|
+
if (rect.width - (x - rect.left) < 50 && (y - rect.top) < 50) {
|
|
8889
|
+
item.parentNode.modal.close();
|
|
8890
|
+
}
|
|
8891
|
+
}
|
|
8892
|
+
|
|
8776
8893
|
if (tracker) {
|
|
8777
8894
|
tracker.element.style.cursor = 'auto';
|
|
8778
8895
|
tracker = null;
|
|
@@ -8794,7 +8911,7 @@ jSuites.modal = (function(el, options) {
|
|
|
8794
8911
|
}
|
|
8795
8912
|
|
|
8796
8913
|
if (rect.width - (x - rect.left) < 50 && (y - rect.top) < 50) {
|
|
8797
|
-
|
|
8914
|
+
// Do nothing
|
|
8798
8915
|
} else {
|
|
8799
8916
|
if (e.target.getAttribute('title') && (y - rect.top) < 50) {
|
|
8800
8917
|
if (document.selection) {
|
|
@@ -9319,7 +9436,7 @@ jSuites.picker = (function(el, options) {
|
|
|
9319
9436
|
obj.setValue(item.k);
|
|
9320
9437
|
// Call method
|
|
9321
9438
|
if (typeof(obj.options.onchange) == 'function') {
|
|
9322
|
-
obj.options.onchange.call(obj, el, obj, item.v, item.v, item.k);
|
|
9439
|
+
obj.options.onchange.call(obj, el, obj, item.v, item.v, item.k, e);
|
|
9323
9440
|
}
|
|
9324
9441
|
}
|
|
9325
9442
|
}
|
|
@@ -9764,8 +9881,10 @@ jSuites.search = (function(el, options) {
|
|
|
9764
9881
|
obj.options = {
|
|
9765
9882
|
data: options.data || null,
|
|
9766
9883
|
input: options.input || null,
|
|
9884
|
+
searchByNode: options.searchByNode || null,
|
|
9767
9885
|
onselect: options.onselect || null,
|
|
9768
9886
|
forceSelect: options.forceSelect,
|
|
9887
|
+
onbeforesearch: options.onbeforesearch || null,
|
|
9769
9888
|
};
|
|
9770
9889
|
|
|
9771
9890
|
obj.selectIndex = function(item) {
|
|
@@ -9839,15 +9958,33 @@ jSuites.search = (function(el, options) {
|
|
|
9839
9958
|
}
|
|
9840
9959
|
|
|
9841
9960
|
obj.keyup = function(e) {
|
|
9842
|
-
if (obj.options.
|
|
9843
|
-
|
|
9961
|
+
if (! obj.options.searchByNode) {
|
|
9962
|
+
if (obj.options.input.tagName === 'DIV') {
|
|
9963
|
+
var terms = obj.options.input.innerText;
|
|
9964
|
+
} else {
|
|
9965
|
+
var terms = obj.options.input.value;
|
|
9966
|
+
}
|
|
9844
9967
|
} else {
|
|
9845
9968
|
// Current node
|
|
9846
9969
|
var node = jSuites.getNode();
|
|
9847
9970
|
if (node) {
|
|
9848
|
-
|
|
9971
|
+
var terms = node.innerText;
|
|
9849
9972
|
}
|
|
9850
9973
|
}
|
|
9974
|
+
|
|
9975
|
+
if (typeof(obj.options.onbeforesearch) == 'function') {
|
|
9976
|
+
var ret = obj.options.onbeforesearch(obj, terms);
|
|
9977
|
+
if (ret) {
|
|
9978
|
+
terms = ret;
|
|
9979
|
+
} else {
|
|
9980
|
+
if (ret === false) {
|
|
9981
|
+
// Ignore event
|
|
9982
|
+
return;
|
|
9983
|
+
}
|
|
9984
|
+
}
|
|
9985
|
+
}
|
|
9986
|
+
|
|
9987
|
+
obj(terms);
|
|
9851
9988
|
}
|
|
9852
9989
|
|
|
9853
9990
|
// Add events
|
|
@@ -11705,136 +11842,202 @@ jSuites.toolbar = (function(el, options) {
|
|
|
11705
11842
|
return obj;
|
|
11706
11843
|
});
|
|
11707
11844
|
|
|
11708
|
-
jSuites.validations = function(
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11845
|
+
jSuites.validations = (function() {
|
|
11846
|
+
/**
|
|
11847
|
+
* Options: Object,
|
|
11848
|
+
* Properties:
|
|
11849
|
+
* Constraint,
|
|
11850
|
+
* Reference,
|
|
11851
|
+
* Value
|
|
11852
|
+
*/
|
|
11714
11853
|
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
return data && pattern.test(data) ? true : false;
|
|
11719
|
-
}
|
|
11854
|
+
var isNumeric = function(num) {
|
|
11855
|
+
return !isNaN(num) && num !== null && num !== '';
|
|
11856
|
+
}
|
|
11720
11857
|
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11858
|
+
var numberCriterias = {
|
|
11859
|
+
'between': function(value, range) {
|
|
11860
|
+
return value >= range[0] && value <= range[1];
|
|
11861
|
+
},
|
|
11862
|
+
'not between': function(value, range) {
|
|
11863
|
+
return value < range[0] || value > range[1];
|
|
11864
|
+
},
|
|
11865
|
+
'<': function(value, range) {
|
|
11866
|
+
return value < range[0];
|
|
11867
|
+
},
|
|
11868
|
+
'<=': function(value, range) {
|
|
11869
|
+
return value <= range[0];
|
|
11870
|
+
},
|
|
11871
|
+
'>': function(value, range) {
|
|
11872
|
+
return value > range[0];
|
|
11873
|
+
},
|
|
11874
|
+
'>=': function(value, range) {
|
|
11875
|
+
return value >= range[0];
|
|
11876
|
+
},
|
|
11877
|
+
'=': function(value, range) {
|
|
11878
|
+
return value === range[0];
|
|
11879
|
+
},
|
|
11880
|
+
'!=': function(value, range) {
|
|
11881
|
+
return value !== range[0];
|
|
11882
|
+
},
|
|
11883
|
+
}
|
|
11724
11884
|
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11885
|
+
var dateCriterias = {
|
|
11886
|
+
'valid date': function() {
|
|
11887
|
+
return true;
|
|
11888
|
+
},
|
|
11889
|
+
'=': function(value, range) {
|
|
11890
|
+
return value === range[0];
|
|
11891
|
+
},
|
|
11892
|
+
'<': function(value, range) {
|
|
11893
|
+
return value < range[0];
|
|
11894
|
+
},
|
|
11895
|
+
'<=': function(value, range) {
|
|
11896
|
+
return value <= range[0];
|
|
11897
|
+
},
|
|
11898
|
+
'>': function(value, range) {
|
|
11899
|
+
return value > range[0];
|
|
11900
|
+
},
|
|
11901
|
+
'>=': function(value, range) {
|
|
11902
|
+
return value >= range[0];
|
|
11903
|
+
},
|
|
11904
|
+
'between': function(value, range) {
|
|
11905
|
+
return value >= range[0] && value <= range[1];
|
|
11906
|
+
},
|
|
11907
|
+
'not between': function(value, range) {
|
|
11908
|
+
return value < range[0] || value > range[1];
|
|
11909
|
+
},
|
|
11910
|
+
}
|
|
11728
11911
|
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
}
|
|
11912
|
+
var textCriterias = {
|
|
11913
|
+
'contains': function(value, range) {
|
|
11914
|
+
return value.includes(range[0]);
|
|
11915
|
+
},
|
|
11916
|
+
'not contains': function(value, range) {
|
|
11917
|
+
return !value.includes(range[0]);
|
|
11918
|
+
},
|
|
11919
|
+
'=': function(value, range) {
|
|
11920
|
+
return value === range[0];
|
|
11921
|
+
},
|
|
11922
|
+
'valid email': function(value) {
|
|
11923
|
+
var pattern = new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/);
|
|
11733
11924
|
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
*
|
|
11738
|
-
* Reference,
|
|
11739
|
-
* Value
|
|
11740
|
-
*/
|
|
11925
|
+
return pattern.test(value);
|
|
11926
|
+
},
|
|
11927
|
+
'valid url': function(value) {
|
|
11928
|
+
var pattern = new RegExp(/(((https?:\/\/)|(www\.))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]+)/ig);
|
|
11741
11929
|
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
return data === options.reference;
|
|
11745
|
-
}
|
|
11746
|
-
if (options.constraint === '<') {
|
|
11747
|
-
return data < options.reference;
|
|
11748
|
-
}
|
|
11749
|
-
if (options.constraint === '<=') {
|
|
11750
|
-
return data <= options.reference;
|
|
11930
|
+
return pattern.test(value);
|
|
11931
|
+
},
|
|
11751
11932
|
}
|
|
11752
|
-
|
|
11753
|
-
|
|
11933
|
+
|
|
11934
|
+
// Component router
|
|
11935
|
+
var component = function(value, options) {
|
|
11936
|
+
if (typeof(component[options.type]) === 'function') {
|
|
11937
|
+
if (options.allowBlank && value === '') {
|
|
11938
|
+
return true;
|
|
11939
|
+
}
|
|
11940
|
+
|
|
11941
|
+
return component[options.type](value, options);
|
|
11942
|
+
}
|
|
11943
|
+
return null;
|
|
11754
11944
|
}
|
|
11755
|
-
|
|
11756
|
-
|
|
11945
|
+
|
|
11946
|
+
component.url = function() {
|
|
11947
|
+
var pattern = new RegExp(/(((https?:\/\/)|(www\.))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]+)/ig);
|
|
11948
|
+
return pattern.test(data) ? true : false;
|
|
11757
11949
|
}
|
|
11758
|
-
|
|
11759
|
-
|
|
11950
|
+
|
|
11951
|
+
component.email = function(data) {
|
|
11952
|
+
var pattern = new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/);
|
|
11953
|
+
return data && pattern.test(data) ? true : false;
|
|
11760
11954
|
}
|
|
11761
|
-
|
|
11762
|
-
|
|
11955
|
+
|
|
11956
|
+
component.required = function(data) {
|
|
11957
|
+
return data.trim() ? true : false;
|
|
11763
11958
|
}
|
|
11959
|
+
|
|
11960
|
+
component.number = function(data, options) {
|
|
11961
|
+
if (! isNumeric(data)) {
|
|
11962
|
+
return false;
|
|
11963
|
+
}
|
|
11764
11964
|
|
|
11765
|
-
|
|
11766
|
-
|
|
11965
|
+
if (!options || !options.criteria) {
|
|
11966
|
+
return true;
|
|
11967
|
+
}
|
|
11767
11968
|
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11969
|
+
if (!numberCriterias[options.criteria]) {
|
|
11970
|
+
return false;
|
|
11971
|
+
}
|
|
11972
|
+
|
|
11973
|
+
return numberCriterias[options.criteria](
|
|
11974
|
+
data,
|
|
11975
|
+
options.value.map(function(num) {
|
|
11976
|
+
return parseFloat(num);
|
|
11977
|
+
}),
|
|
11978
|
+
);
|
|
11979
|
+
};
|
|
11772
11980
|
|
|
11773
|
-
|
|
11774
|
-
|
|
11981
|
+
component.login = function(data) {
|
|
11982
|
+
var pattern = new RegExp(/^[a-zA-Z0-9\_\-\.\s+]+$/);
|
|
11983
|
+
return data && pattern.test(data) ? true : false;
|
|
11775
11984
|
}
|
|
11776
11985
|
|
|
11777
|
-
|
|
11778
|
-
|
|
11986
|
+
component.list = function(data, options) {
|
|
11987
|
+
var dataType = typeof data;
|
|
11988
|
+
if (dataType !== 'string' && dataType !== 'number') {
|
|
11989
|
+
return false;
|
|
11990
|
+
}
|
|
11779
11991
|
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11992
|
+
var validOption = options.value[0].split(',').findIndex(function name(item) {
|
|
11993
|
+
return item == data;
|
|
11994
|
+
});
|
|
11995
|
+
|
|
11996
|
+
return validOption > -1;
|
|
11783
11997
|
}
|
|
11784
11998
|
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11999
|
+
component.date = function(data, options) {
|
|
12000
|
+
if (new Date(data) == 'Invalid Date') {
|
|
12001
|
+
return false;
|
|
12002
|
+
}
|
|
11789
12003
|
|
|
11790
|
-
if (
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
12004
|
+
if (!options || !options.criteria) {
|
|
12005
|
+
return true;
|
|
12006
|
+
}
|
|
12007
|
+
|
|
12008
|
+
if (!dateCriterias[options.criteria]) {
|
|
12009
|
+
return false;
|
|
11796
12010
|
}
|
|
11797
12011
|
|
|
11798
|
-
return
|
|
12012
|
+
return dateCriterias[options.criteria](
|
|
12013
|
+
new Date(data).getTime(),
|
|
12014
|
+
options.value.map(function(date) {
|
|
12015
|
+
return new Date(date).getTime();
|
|
12016
|
+
}),
|
|
12017
|
+
);
|
|
11799
12018
|
}
|
|
11800
|
-
return null;
|
|
11801
|
-
}
|
|
11802
12019
|
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
}
|
|
12020
|
+
component.text = function(data, options) {
|
|
12021
|
+
if (typeof data !== 'string') {
|
|
12022
|
+
return false;
|
|
12023
|
+
}
|
|
11808
12024
|
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
}
|
|
12025
|
+
if (!options || !options.criteria) {
|
|
12026
|
+
return true;
|
|
12027
|
+
}
|
|
11813
12028
|
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
return
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
}
|
|
11823
|
-
if (options.constraint === 'not contain') {
|
|
11824
|
-
return !data.includes(options.reference);
|
|
11825
|
-
}
|
|
11826
|
-
if (options.constraint === 'email') {
|
|
11827
|
-
return jSuites.validations.email(data);
|
|
11828
|
-
}
|
|
11829
|
-
if (options.constraint === 'url') {
|
|
11830
|
-
var pattern = new RegExp(/(((https?:\/\/)|(www\.))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]+)/ig);
|
|
11831
|
-
return pattern.test(data) ? true : false;
|
|
12029
|
+
if (!textCriterias[options.criteria]) {
|
|
12030
|
+
return false;
|
|
12031
|
+
}
|
|
12032
|
+
|
|
12033
|
+
return textCriterias[options.criteria](
|
|
12034
|
+
data,
|
|
12035
|
+
options.value,
|
|
12036
|
+
);
|
|
11832
12037
|
}
|
|
11833
|
-
return null;
|
|
11834
|
-
}
|
|
11835
12038
|
|
|
11836
|
-
|
|
11837
|
-
}
|
|
12039
|
+
return component;
|
|
12040
|
+
})();
|
|
11838
12041
|
|
|
11839
12042
|
|
|
11840
12043
|
|
package/package.json
CHANGED