jsuites 4.13.3 → 4.13.6

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.
@@ -16,6 +16,10 @@
16
16
  --safe-area-bottom: env(safe-area-inset-bottom);
17
17
  }
18
18
 
19
+ [data-visible="false"] {
20
+ display: none;
21
+ }
22
+
19
23
  div[data-before]:before {
20
24
  content: attr(data-before);
21
25
  }
@@ -858,6 +862,7 @@ div[data-before]:before {
858
862
  font-size: 15px;
859
863
  position: absolute;
860
864
  left: 9px;
865
+ top: 5px;
861
866
  }
862
867
 
863
868
  .jcontextmenu.symbols > div::before {
@@ -15,10 +15,14 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- var Version = '4.13.0';
18
+ var jSuites = {};
19
+
20
+ var Version = '4.13.6';
19
21
 
20
22
  var Events = function() {
21
23
 
24
+ document.jsuitesComponents = [];
25
+
22
26
  var find = function(DOMElement, component) {
23
27
  if (DOMElement[component.type] && DOMElement[component.type] == component) {
24
28
  return true;
@@ -33,10 +37,10 @@ var Events = function() {
33
37
  }
34
38
 
35
39
  var isOpened = function(e) {
36
- if (jSuites.current && jSuites.current.length > 0) {
37
- for (var i = 0; i < jSuites.current.length; i++) {
38
- if (jSuites.current[i] && ! find(e, jSuites.current[i])) {
39
- jSuites.current[i].close();
40
+ if (document.jsuitesComponents && document.jsuitesComponents.length > 0) {
41
+ for (var i = 0; i < document.jsuitesComponents.length; i++) {
42
+ if (document.jsuitesComponents[i] && ! find(e, document.jsuitesComponents[i])) {
43
+ document.jsuitesComponents[i].close();
40
44
  }
41
45
  }
42
46
  }
@@ -319,8 +323,8 @@ var Events = function() {
319
323
  }
320
324
  }
321
325
 
322
- if (jSuites.current && jSuites.current.length) {
323
- if (item = jSuites.current[jSuites.current.length - 1]) {
326
+ if (document.jsuitesComponents && document.jsuitesComponents.length) {
327
+ if (item = document.jsuitesComponents[document.jsuitesComponents.length - 1]) {
324
328
  if (e.key == "Escape" && typeof(item.close) == 'function') {
325
329
  item.close();
326
330
  e.preventDefault();
@@ -337,22 +341,13 @@ var Events = function() {
337
341
  document.addEventListener('dblclick', dblClick);
338
342
  document.addEventListener('keydown', keyDown);
339
343
  document.addEventListener('contextmenu', contextMenu);
340
- };
341
-
342
- var jSuites = {};
344
+ }
343
345
 
344
346
  /**
345
347
  * Global jsuites event
346
348
  */
347
- if (typeof(document) !== "undefined") {
348
- if (window.jSuites) {
349
- jSuites = window.jSuites;
350
- } else {
351
- Events();
352
-
353
- // Keep references
354
- window.jSuites = jSuites;
355
- }
349
+ if (typeof(document) !== "undefined" && ! document.jsuitesComponents) {
350
+ Events();
356
351
  }
357
352
 
358
353
  jSuites.version = Version;
@@ -367,24 +362,20 @@ jSuites.setExtensions = function(o) {
367
362
  }
368
363
 
369
364
  jSuites.tracking = function(component, state) {
370
- if (! jSuites.current) {
371
- jSuites.current = [];
372
- }
373
-
374
365
  if (state == true) {
375
- jSuites.current = jSuites.current.filter(function(v) {
366
+ document.jsuitesComponents = document.jsuitesComponents.filter(function(v) {
376
367
  return v !== null;
377
368
  });
378
369
 
379
370
  // Start after all events
380
371
  setTimeout(function() {
381
- jSuites.current.push(component);
372
+ document.jsuitesComponents.push(component);
382
373
  }, 0);
383
374
 
384
375
  } else {
385
- var index = jSuites.current.indexOf(component);
376
+ var index = document.jsuitesComponents.indexOf(component);
386
377
  if (index >= 0) {
387
- jSuites.current.splice(index, 1);
378
+ document.jsuitesComponents.splice(index, 1);
388
379
  }
389
380
  }
390
381
  }
@@ -3973,8 +3964,20 @@ jSuites.dropdown = (function(el, options) {
3973
3964
  }
3974
3965
 
3975
3966
  obj.setData = function(data) {
3967
+ // Reset current value
3968
+ resetValue();
3969
+
3970
+ // Make sure the content container is blank
3971
+ content.innerHTML = '';
3972
+
3973
+ // Reset
3974
+ obj.header.value = '';
3975
+
3976
+ // Reset items and values
3977
+ obj.items = [];
3978
+
3976
3979
  // Prepare data
3977
- if (data.length) {
3980
+ if (data && data.length) {
3978
3981
  for (var i = 0; i < data.length; i++) {
3979
3982
  // Compatibility
3980
3983
  if (typeof(data[i]) != 'object') {
@@ -3993,24 +3996,17 @@ jSuites.dropdown = (function(el, options) {
3993
3996
  }
3994
3997
  }
3995
3998
 
3996
- // Reset current value
3997
- resetValue();
3998
-
3999
- // Make sure the content container is blank
4000
- content.innerHTML = '';
4001
-
4002
- // Reset
4003
- obj.header.value = '';
4004
-
4005
- // Reset items and values
4006
- obj.items = [];
4007
-
4008
3999
  // Append data
4009
4000
  obj.appendData(data);
4010
4001
 
4011
4002
  // Update data
4012
4003
  obj.options.data = data;
4004
+ } else {
4005
+ // Update data
4006
+ obj.options.data = [];
4013
4007
  }
4008
+
4009
+ obj.close();
4014
4010
  }
4015
4011
 
4016
4012
  obj.getData = function() {
@@ -6274,6 +6270,9 @@ jSuites.focus = function(el) {
6274
6270
  }
6275
6271
 
6276
6272
  jSuites.isNumeric = (function (num) {
6273
+ if (typeof(num) === 'string') {
6274
+ num = num.trim();
6275
+ }
6277
6276
  return !isNaN(num) && num !== null && num !== '';
6278
6277
  });
6279
6278
 
@@ -8434,6 +8433,20 @@ jSuites.mask = (function() {
8434
8433
 
8435
8434
  value = obj(value, options);
8436
8435
 
8436
+ // Numeric mask, number of zeros
8437
+ if (fullMask && type === 'numeric') {
8438
+ var maskZeros = options.mask.match(new RegExp(/^[0]+$/gm));
8439
+ if (maskZeros && maskZeros.length === 1) {
8440
+ var maskLength = maskZeros[0].length;
8441
+ if (maskLength > 3) {
8442
+ value = '' + value;
8443
+ while (value.length < maskLength) {
8444
+ value = '0' + value;
8445
+ }
8446
+ }
8447
+ }
8448
+ }
8449
+
8437
8450
  return value;
8438
8451
  }
8439
8452
 
package/dist/jsuites.css CHANGED
@@ -16,6 +16,10 @@
16
16
  --safe-area-bottom: env(safe-area-inset-bottom);
17
17
  }
18
18
 
19
+ [data-visible="false"] {
20
+ display: none;
21
+ }
22
+
19
23
  div[data-before]:before {
20
24
  content: attr(data-before);
21
25
  }
@@ -858,6 +862,7 @@ div[data-before]:before {
858
862
  font-size: 15px;
859
863
  position: absolute;
860
864
  left: 9px;
865
+ top: 5px;
861
866
  }
862
867
 
863
868
  .jcontextmenu.symbols > div::before {
package/dist/jsuites.js CHANGED
@@ -15,10 +15,14 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- var Version = '4.13.0';
18
+ var jSuites = {};
19
+
20
+ var Version = '4.13.6';
19
21
 
20
22
  var Events = function() {
21
23
 
24
+ document.jsuitesComponents = [];
25
+
22
26
  var find = function(DOMElement, component) {
23
27
  if (DOMElement[component.type] && DOMElement[component.type] == component) {
24
28
  return true;
@@ -33,10 +37,10 @@ var Events = function() {
33
37
  }
34
38
 
35
39
  var isOpened = function(e) {
36
- if (jSuites.current && jSuites.current.length > 0) {
37
- for (var i = 0; i < jSuites.current.length; i++) {
38
- if (jSuites.current[i] && ! find(e, jSuites.current[i])) {
39
- jSuites.current[i].close();
40
+ if (document.jsuitesComponents && document.jsuitesComponents.length > 0) {
41
+ for (var i = 0; i < document.jsuitesComponents.length; i++) {
42
+ if (document.jsuitesComponents[i] && ! find(e, document.jsuitesComponents[i])) {
43
+ document.jsuitesComponents[i].close();
40
44
  }
41
45
  }
42
46
  }
@@ -319,8 +323,8 @@ var Events = function() {
319
323
  }
320
324
  }
321
325
 
322
- if (jSuites.current && jSuites.current.length) {
323
- if (item = jSuites.current[jSuites.current.length - 1]) {
326
+ if (document.jsuitesComponents && document.jsuitesComponents.length) {
327
+ if (item = document.jsuitesComponents[document.jsuitesComponents.length - 1]) {
324
328
  if (e.key == "Escape" && typeof(item.close) == 'function') {
325
329
  item.close();
326
330
  e.preventDefault();
@@ -337,22 +341,13 @@ var Events = function() {
337
341
  document.addEventListener('dblclick', dblClick);
338
342
  document.addEventListener('keydown', keyDown);
339
343
  document.addEventListener('contextmenu', contextMenu);
340
- };
341
-
342
- var jSuites = {};
344
+ }
343
345
 
344
346
  /**
345
347
  * Global jsuites event
346
348
  */
347
- if (typeof(document) !== "undefined") {
348
- if (window.jSuites) {
349
- jSuites = window.jSuites;
350
- } else {
351
- Events();
352
-
353
- // Keep references
354
- window.jSuites = jSuites;
355
- }
349
+ if (typeof(document) !== "undefined" && ! document.jsuitesComponents) {
350
+ Events();
356
351
  }
357
352
 
358
353
  jSuites.version = Version;
@@ -367,24 +362,20 @@ jSuites.setExtensions = function(o) {
367
362
  }
368
363
 
369
364
  jSuites.tracking = function(component, state) {
370
- if (! jSuites.current) {
371
- jSuites.current = [];
372
- }
373
-
374
365
  if (state == true) {
375
- jSuites.current = jSuites.current.filter(function(v) {
366
+ document.jsuitesComponents = document.jsuitesComponents.filter(function(v) {
376
367
  return v !== null;
377
368
  });
378
369
 
379
370
  // Start after all events
380
371
  setTimeout(function() {
381
- jSuites.current.push(component);
372
+ document.jsuitesComponents.push(component);
382
373
  }, 0);
383
374
 
384
375
  } else {
385
- var index = jSuites.current.indexOf(component);
376
+ var index = document.jsuitesComponents.indexOf(component);
386
377
  if (index >= 0) {
387
- jSuites.current.splice(index, 1);
378
+ document.jsuitesComponents.splice(index, 1);
388
379
  }
389
380
  }
390
381
  }
@@ -3984,8 +3975,20 @@ jSuites.dropdown = (function(el, options) {
3984
3975
  }
3985
3976
 
3986
3977
  obj.setData = function(data) {
3978
+ // Reset current value
3979
+ resetValue();
3980
+
3981
+ // Make sure the content container is blank
3982
+ content.innerHTML = '';
3983
+
3984
+ // Reset
3985
+ obj.header.value = '';
3986
+
3987
+ // Reset items and values
3988
+ obj.items = [];
3989
+
3987
3990
  // Prepare data
3988
- if (data.length) {
3991
+ if (data && data.length) {
3989
3992
  for (var i = 0; i < data.length; i++) {
3990
3993
  // Compatibility
3991
3994
  if (typeof(data[i]) != 'object') {
@@ -4004,24 +4007,17 @@ jSuites.dropdown = (function(el, options) {
4004
4007
  }
4005
4008
  }
4006
4009
 
4007
- // Reset current value
4008
- resetValue();
4009
-
4010
- // Make sure the content container is blank
4011
- content.innerHTML = '';
4012
-
4013
- // Reset
4014
- obj.header.value = '';
4015
-
4016
- // Reset items and values
4017
- obj.items = [];
4018
-
4019
4010
  // Append data
4020
4011
  obj.appendData(data);
4021
4012
 
4022
4013
  // Update data
4023
4014
  obj.options.data = data;
4015
+ } else {
4016
+ // Update data
4017
+ obj.options.data = [];
4024
4018
  }
4019
+
4020
+ obj.close();
4025
4021
  }
4026
4022
 
4027
4023
  obj.getData = function() {
@@ -6699,6 +6695,9 @@ jSuites.focus = function(el) {
6699
6695
  }
6700
6696
 
6701
6697
  jSuites.isNumeric = (function (num) {
6698
+ if (typeof(num) === 'string') {
6699
+ num = num.trim();
6700
+ }
6702
6701
  return !isNaN(num) && num !== null && num !== '';
6703
6702
  });
6704
6703
 
@@ -8859,6 +8858,20 @@ jSuites.mask = (function() {
8859
8858
 
8860
8859
  value = obj(value, options);
8861
8860
 
8861
+ // Numeric mask, number of zeros
8862
+ if (fullMask && type === 'numeric') {
8863
+ var maskZeros = options.mask.match(new RegExp(/^[0]+$/gm));
8864
+ if (maskZeros && maskZeros.length === 1) {
8865
+ var maskLength = maskZeros[0].length;
8866
+ if (maskLength > 3) {
8867
+ value = '' + value;
8868
+ while (value.length < maskLength) {
8869
+ value = '0' + value;
8870
+ }
8871
+ }
8872
+ }
8873
+ }
8874
+
8862
8875
  return value;
8863
8876
  }
8864
8877
 
@@ -12165,8 +12178,13 @@ jSuites.validations = (function() {
12165
12178
  if (dataType !== 'string' && dataType !== 'number') {
12166
12179
  return false;
12167
12180
  }
12181
+ if (typeof(options.value[0]) === 'string') {
12182
+ var list = options.value[0].split(',');
12183
+ } else {
12184
+ var list = options.value[0];
12185
+ }
12168
12186
 
12169
- var validOption = options.value[0].findIndex(function name(item) {
12187
+ var validOption = list.findIndex(function name(item) {
12170
12188
  return item == data;
12171
12189
  });
12172
12190
 
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "javascript plugins"
20
20
  ],
21
21
  "main": "dist/jsuites.js",
22
- "version": "4.13.3",
22
+ "version": "4.13.6",
23
23
  "bugs": "https://github.com/jsuites/jsuites/issues",
24
24
  "homepage": "https://github.com/jsuites/jsuites",
25
25
  "docs": "https://jsuites.net",