jsuites 5.0.25 → 5.0.27

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.js CHANGED
@@ -2590,7 +2590,7 @@ function Mask() {
2590
2590
  o.number = Extract.call(o, v);
2591
2591
  // Keep the raw data as a property of the tag
2592
2592
  if (o.type == 'percentage' && v.indexOf('%') !== -1) {
2593
- label = o.number / 100;
2593
+ label = obj.adjustPrecision(o.number / 100);
2594
2594
  } else {
2595
2595
  label = o.number;
2596
2596
  }
@@ -2617,6 +2617,37 @@ function Mask() {
2617
2617
  }
2618
2618
  }
2619
2619
 
2620
+ obj.adjustPrecision = function(num) {
2621
+ if (typeof num === 'number' && !Number.isInteger(num)) {
2622
+ const v = num.toString().split('.');
2623
+
2624
+ if (v[1] && v[1].length > 10) {
2625
+ let t0 = 0;
2626
+ const t1 = v[1][v[1].length - 2];
2627
+
2628
+ if (t1 == 0 || t1 == 9) {
2629
+ for (let i = v[1].length - 2; i > 0; i--) {
2630
+ if (t0 >= 0 && v[1][i] == t1) {
2631
+ t0++;
2632
+ if (t0 > 6) {
2633
+ break;
2634
+ }
2635
+ } else {
2636
+ t0 = 0;
2637
+ break;
2638
+ }
2639
+ }
2640
+
2641
+ if (t0) {
2642
+ return parseFloat(parseFloat(num).toFixed(v[1].length - 1));
2643
+ }
2644
+ }
2645
+ }
2646
+ }
2647
+
2648
+ return num;
2649
+ }
2650
+
2620
2651
  // Get the type of the mask
2621
2652
  obj.getType = getType;
2622
2653
 
@@ -2789,8 +2820,8 @@ function Mask() {
2789
2820
  }
2790
2821
  } else {
2791
2822
  // Percentage
2792
- if (type == 'percentage') {
2793
- value *= 100;
2823
+ if (type === 'percentage') {
2824
+ value = obj.adjustPrecision(value*100);
2794
2825
  }
2795
2826
  // Number of decimal places
2796
2827
  if (typeof(value) === 'number') {
@@ -4552,7 +4583,7 @@ function Tabs(el, options) {
4552
4583
  }
4553
4584
  }
4554
4585
 
4555
- obj.appendElement = function(title, cb) {
4586
+ obj.appendElement = function(title, cb, openTab) {
4556
4587
  if (! title) {
4557
4588
  var title = prompt('Title?', '');
4558
4589
  }
@@ -4572,8 +4603,12 @@ function Tabs(el, options) {
4572
4603
  if (obj.options.allowChangePosition) {
4573
4604
  h.setAttribute('draggable', 'true');
4574
4605
  }
4606
+
4575
4607
  // Open new tab
4576
- obj.selectIndex(h);
4608
+ if (openTab !== false) {
4609
+ // Open new tab
4610
+ obj.selectIndex(h);
4611
+ }
4577
4612
 
4578
4613
  // Callback
4579
4614
  if (typeof(cb) == 'function') {
@@ -4611,7 +4646,7 @@ function Tabs(el, options) {
4611
4646
  setBorder();
4612
4647
  }
4613
4648
 
4614
- obj.updatePosition = function(f, t) {
4649
+ obj.updatePosition = function(f, t, ignoreEvents) {
4615
4650
  // Ondrop update position of content
4616
4651
  if (f > t) {
4617
4652
  obj.content.insertBefore(obj.content.children[f], obj.content.children[t]);
@@ -4623,19 +4658,19 @@ function Tabs(el, options) {
4623
4658
  obj.open(t);
4624
4659
 
4625
4660
  // Call event
4626
- if (typeof(obj.options.onchangeposition) == 'function') {
4661
+ if (! ignoreEvents && typeof(obj.options.onchangeposition) == 'function') {
4627
4662
  obj.options.onchangeposition(obj.headers, f, t);
4628
4663
  }
4629
4664
  }
4630
4665
 
4631
- obj.move = function(f, t) {
4666
+ obj.move = function(f, t, ignoreEvents) {
4632
4667
  if (f > t) {
4633
4668
  obj.headers.insertBefore(obj.headers.children[f], obj.headers.children[t]);
4634
4669
  } else {
4635
4670
  obj.headers.insertBefore(obj.headers.children[f], obj.headers.children[t].nextSibling);
4636
4671
  }
4637
4672
 
4638
- obj.updatePosition(f, t);
4673
+ obj.updatePosition(f, t, ignoreEvents);
4639
4674
  }
4640
4675
 
4641
4676
  obj.setBorder = setBorder;
@@ -12655,7 +12690,7 @@ var jSuites = {
12655
12690
  ...dictionary,
12656
12691
  ...helpers,
12657
12692
  /** Current version */
12658
- version: '5.0.24',
12693
+ version: '5.0.27',
12659
12694
  /** Bind new extensions to Jsuites */
12660
12695
  setExtensions: function(o) {
12661
12696
  if (typeof(o) == 'object') {
@@ -67,13 +67,13 @@ export type Tabs = (el: HTMLElement, options: Options) => {
67
67
  /** Delete tab element */
68
68
  deleteElement: () => void;
69
69
  /** Append tab element */
70
- appendElement: () => void;
70
+ appendElement: (title?: string, callback?: Function, openTab?: boolean) => void;
71
71
  /** Get the active tab index */
72
72
  getActive: () => number;
73
73
  /** Update the content of a tab */
74
74
  updateContent: (index: number, newContent: string) => void;
75
75
  /** Update tab position */
76
- updatePosition: (from: number, to: number) => void;
76
+ updatePosition: (from: number, to: number, ignoreEvents?: boolean) => void;
77
77
  /** Update DOM position */
78
- move: (from: number, to: number) => void;
78
+ move: (from: number, to: number, ignoreEvents?: boolean) => void;
79
79
  }
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "main": "dist/jsuites.js",
27
27
  "types": "dist/jsuites.d.ts",
28
- "version": "5.0.25",
28
+ "version": "5.0.27",
29
29
  "bugs": "https://github.com/jsuites/jsuites/issues",
30
30
  "homepage": "https://github.com/jsuites/jsuites",
31
31
  "docs": "https://jsuites.net",