jsuites 4.9.36 → 4.10.4

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.
@@ -531,13 +531,12 @@ div[data-before]:before {
531
531
  .jcolor {
532
532
  display: none;
533
533
  outline: none;
534
+ position: absolute;
534
535
  }
535
536
 
536
537
  .jcolor-input {
537
- padding-right:18px;
538
- background-image: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' width='18px' height='18px'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z'/%3E%3C/svg%3E");
539
- background-position:top 50% right 5px;
540
- background-repeat:no-repeat;
538
+ padding-right: 24px !important;
539
+ background: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' width='18px' height='18px'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z'/%3E%3C/svg%3E") top 50% right 4px no-repeat, content-box;
541
540
  box-sizing: border-box;
542
541
  }
543
542
 
@@ -557,6 +556,10 @@ div[data-before]:before {
557
556
  min-width: 260px;
558
557
  }
559
558
 
559
+ .jmodal .jcolor-content {
560
+ position: fixed;
561
+ }
562
+
560
563
  .jcolor-controls {
561
564
  display: flex;
562
565
  padding: 10px;
@@ -17,7 +17,7 @@
17
17
 
18
18
  var jSuites = function(options) {
19
19
  var obj = {}
20
- var version = '4.9.36';
20
+ var version = '4.10.4';
21
21
 
22
22
  var find = function(DOMElement, component) {
23
23
  if (DOMElement[component.type] && DOMElement[component.type] == component) {
@@ -29,10 +29,10 @@ var jSuites = function(options) {
29
29
  return false;
30
30
  }
31
31
 
32
- var isOpened = function(element) {
32
+ var isOpened = function(e) {
33
33
  if (jSuites.current.length > 0) {
34
34
  for (var i = 0; i < jSuites.current.length; i++) {
35
- if (jSuites.current[i] && ! find(element, jSuites.current[i])) {
35
+ if (jSuites.current[i] && ! find(e, jSuites.current[i])) {
36
36
  jSuites.current[i].close();
37
37
  }
38
38
  }
@@ -40,9 +40,66 @@ var jSuites = function(options) {
40
40
  }
41
41
 
42
42
  obj.init = function() {
43
+ // Width of the border
44
+ var cornerSize = 15;
45
+
46
+ // Current element
43
47
  var element = null;
44
48
 
45
- document.addEventListener("mousedown", function(e) {
49
+ // Controllers
50
+ var editorAction = false;
51
+
52
+ // Event state
53
+ var state = {
54
+ x: null,
55
+ y: null,
56
+ }
57
+
58
+ // Events
59
+ var editorMouseDown = function(e) {
60
+ // Check if this is the floating
61
+ var item = jSuites.findElement(e.target, 'jpanel');
62
+ // Jfloating found
63
+ if (item && ! item.classList.contains("readonly")) {
64
+ // Add focus to the chart container
65
+ item.focus();
66
+ // Keep the tracking information
67
+ var rect = e.target.getBoundingClientRect();
68
+ editorAction = {
69
+ e: item,
70
+ x: e.clientX,
71
+ y: e.clientY,
72
+ w: rect.width,
73
+ h: rect.height,
74
+ d: item.style.cursor,
75
+ resizing: item.style.cursor ? true : false,
76
+ }
77
+
78
+ // Make sure width and height styling is OK
79
+ if (! item.style.width) {
80
+ item.style.width = rect.width + 'px';
81
+ }
82
+
83
+ if (! item.style.height) {
84
+ item.style.height = rect.height + 'px';
85
+ }
86
+
87
+ // Remove any selection from the page
88
+ var s = window.getSelection();
89
+ if (s.rangeCount) {
90
+ for (var i = 0; i < s.rangeCount; i++) {
91
+ s.removeRange(s.getRangeAt(i));
92
+ }
93
+ }
94
+
95
+ e.preventDefault();
96
+ e.stopPropagation();
97
+ } else {
98
+ // No floating action found
99
+ editorAction = false;
100
+ }
101
+
102
+ // Verify current components tracking
46
103
  if (e.changedTouches && e.changedTouches[0]) {
47
104
  var x = e.changedTouches[0].clientX;
48
105
  var y = e.changedTouches[0].clientY;
@@ -51,10 +108,14 @@ var jSuites = function(options) {
51
108
  var y = e.clientY;
52
109
  }
53
110
 
111
+ // Which component I am clicking
54
112
  var path = event.path || (event.composedPath && event.composedPath());
113
+
114
+ // If path available get the first element in the chain
55
115
  if (path) {
56
116
  element = path[0];
57
117
  } else {
118
+ // Try to guess using the coordinates
58
119
  if (e.target && e.target.shadowRoot) {
59
120
  var d = e.target.shadowRoot;
60
121
  } else {
@@ -63,12 +124,186 @@ var jSuites = function(options) {
63
124
  // Get the first target element
64
125
  element = d.elementFromPoint(x, y);
65
126
  }
66
- });
67
127
 
68
- document.addEventListener("click", function(e) {
69
- // Check opened components
70
128
  isOpened(element);
71
- });
129
+ }
130
+
131
+ var editorMouseUp = function(e) {
132
+ if (editorAction && editorAction.e) {
133
+ if (typeof(editorAction.e.refresh) == 'function') {
134
+ editorAction.e.refresh();
135
+ }
136
+ editorAction.e.style.cursor = '';
137
+ }
138
+
139
+ // Reset
140
+ state = {
141
+ x: null,
142
+ y: null,
143
+ }
144
+
145
+ editorAction = false;
146
+ }
147
+
148
+ var editorMouseMove = function(e) {
149
+ if (editorAction) {
150
+ var x = e.clientX || e.pageX;
151
+ var y = e.clientY || e.pageY;
152
+
153
+ // Action on going
154
+ if (! editorAction.resizing) {
155
+ if (state.x == null && state.y == null) {
156
+ state.x = x;
157
+ state.y = y;
158
+ }
159
+
160
+ var dx = x - state.x;
161
+ var dy = y - state.y;
162
+ var top = editorAction.e.offsetTop + dy;
163
+ var left = editorAction.e.offsetLeft + dx;
164
+
165
+ // Update position
166
+ editorAction.e.style.top = top + 'px';
167
+ editorAction.e.style.left = left + 'px';
168
+ editorAction.e.style.cursor = "move";
169
+
170
+ state.x = x;
171
+ state.y = y;
172
+
173
+
174
+ // Update element
175
+ if (typeof(editorAction.e.refresh) == 'function') {
176
+ editorAction.e.refresh('position', top, left);
177
+ }
178
+ } else {
179
+ var width = null;
180
+ var height = null;
181
+
182
+ if (editorAction.d == 'e-resize' || editorAction.d == 'ne-resize' || editorAction.d == 'se-resize') {
183
+ // Update width
184
+ width = editorAction.w + (x - editorAction.x);
185
+ editorAction.e.style.width = width + 'px';
186
+
187
+ // Update Height
188
+ if (e.shiftKey) {
189
+ var newHeight = (x - editorAction.x) * (editorAction.h / editorAction.w);
190
+ height = editorAction.h + newHeight;
191
+ editorAction.e.style.height = height + 'px';
192
+ } else {
193
+ var newHeight = false;
194
+ }
195
+ }
196
+
197
+ if (! newHeight) {
198
+ if (editorAction.d == 's-resize' || editorAction.d == 'se-resize' || editorAction.d == 'sw-resize') {
199
+ height = editorAction.h + (y - editorAction.y);
200
+ editorAction.e.style.height = height + 'px';
201
+ }
202
+ }
203
+
204
+ // Update element
205
+ if (typeof(editorAction.e.refresh) == 'function') {
206
+ editorAction.e.refresh('dimensions', width, height);
207
+ }
208
+ }
209
+ } else {
210
+ // Resizing action
211
+ var item = jSuites.findElement(e.target, 'jpanel');
212
+ // Found eligible component
213
+ if (item) {
214
+ if (item.getAttribute('tabindex')) {
215
+ var rect = item.getBoundingClientRect();
216
+ if (e.clientY - rect.top < cornerSize) {
217
+ if (rect.width - (e.clientX - rect.left) < cornerSize) {
218
+ item.style.cursor = 'ne-resize';
219
+ } else if (e.clientX - rect.left < cornerSize) {
220
+ item.style.cursor = 'nw-resize';
221
+ } else {
222
+ item.style.cursor = 'n-resize';
223
+ }
224
+ } else if (rect.height - (e.clientY - rect.top) < cornerSize) {
225
+ if (rect.width - (e.clientX - rect.left) < cornerSize) {
226
+ item.style.cursor = 'se-resize';
227
+ } else if (e.clientX - rect.left < cornerSize) {
228
+ item.style.cursor = 'sw-resize';
229
+ } else {
230
+ item.style.cursor = 's-resize';
231
+ }
232
+ } else if (rect.width - (e.clientX - rect.left) < cornerSize) {
233
+ item.style.cursor = 'e-resize';
234
+ } else if (e.clientX - rect.left < cornerSize) {
235
+ item.style.cursor = 'w-resize';
236
+ } else {
237
+ item.style.cursor = '';
238
+ }
239
+ }
240
+ }
241
+ }
242
+ }
243
+
244
+ var editorDblClick = function(e) {
245
+ var item = jSuites.findElement(e.target, 'jpanel');
246
+ if (item && typeof(item.dblclick) == 'function') {
247
+ // Create edition
248
+ item.dblclick(e);
249
+ }
250
+ }
251
+
252
+ var editorContextmenu = function(e) {
253
+ var item = document.activeElement;
254
+ if (item && typeof(item.contextmenu) == 'function') {
255
+ // Create edition
256
+ item.contextmenu(e);
257
+
258
+ e.preventDefault();
259
+ e.stopImmediatePropagation();
260
+ } else {
261
+ // Search for possible context menus
262
+ item = jSuites.findElement(e.target, function(o) {
263
+ return o.tagName && o.getAttribute('aria-contextmenu-id');
264
+ });
265
+
266
+ if (item) {
267
+ var o = document.querySelector('#' + item);
268
+ if (! o) {
269
+ console.error('JSUITES: contextmenu id not found: ' + item);
270
+ } else {
271
+ o.contextmenu.open(e);
272
+ e.preventDefault();
273
+ e.stopImmediatePropagation();
274
+ }
275
+ }
276
+ }
277
+ }
278
+
279
+ var editorKeyDown = function(e) {
280
+ var item = document.activeElement;
281
+ if (item) {
282
+ if (e.key == "Delete" && typeof(item.delete) == 'function') {
283
+ item.delete();
284
+ e.preventDefault();
285
+ e.stopImmediatePropagation();
286
+ }
287
+ }
288
+
289
+ if (jSuites.current.length) {
290
+ if (item = jSuites.current[jSuites.current.length - 1]) {
291
+ if (e.key == "Escape" && typeof(item.close) == 'function') {
292
+ item.close();
293
+ e.preventDefault();
294
+ e.stopImmediatePropagation();
295
+ }
296
+ }
297
+ }
298
+ }
299
+
300
+ document.addEventListener('mouseup', editorMouseUp);
301
+ document.addEventListener("mousedown", editorMouseDown);
302
+ document.addEventListener('mousemove', editorMouseMove);
303
+ document.addEventListener('dblclick', editorDblClick);
304
+ document.addEventListener('keydown', editorKeyDown);
305
+ document.addEventListener('contextmenu', editorContextmenu);
306
+ document.dictionary = {};
72
307
 
73
308
  obj.version = version;
74
309
  }
@@ -96,7 +331,7 @@ var jSuites = function(options) {
96
331
  } else {
97
332
  var index = jSuites.current.indexOf(component);
98
333
  if (index >= 0) {
99
- jSuites.current[index] = null;
334
+ jSuites.current.splice(index, 1);
100
335
  }
101
336
  }
102
337
  }
@@ -147,15 +382,13 @@ var jSuites = function(options) {
147
382
 
148
383
  // Update dictionary
149
384
  obj.setDictionary = function(d) {
150
- var k = Object.keys(obj.dictionary);
151
- if (k.length == 0) {
152
- obj.dictionary = d;
153
- } else {
154
- // Replace the key into the dictionary and append the new ones
155
- var k = Object.keys(d);
156
- for (var i = 0; i < k.length; i++) {
157
- obj.dictionary[k[i]] = d[k[i]];
158
- }
385
+ if (! document.dictionary) {
386
+ document.dictionary = {}
387
+ }
388
+ // Replace the key into the dictionary and append the new ones
389
+ var k = Object.keys(d);
390
+ for (var i = 0; i < k.length; i++) {
391
+ document.dictionary[k[i]] = d[k[i]];
159
392
  }
160
393
 
161
394
  // Translations
@@ -176,12 +409,13 @@ var jSuites = function(options) {
176
409
  }
177
410
  }
178
411
 
179
- // Dictionary
180
- obj.dictionary = {};
181
-
182
412
  // Translate
183
413
  obj.translate = function(t) {
184
- return obj.dictionary[t] || t;
414
+ if (document.dictionary) {
415
+ return document.dictionary[t] || t;
416
+ } else {
417
+ return t;
418
+ }
185
419
  }
186
420
 
187
421
  // Array of opened components
@@ -342,6 +576,10 @@ jSuites.ajax = (function(options, complete) {
342
576
  jSuites.ajax.beforeSend(httpRequest);
343
577
  }
344
578
 
579
+ if (document.ajax && typeof(document.ajax.beforeSend) == 'function') {
580
+ document.ajax.beforeSend(httpRequest);
581
+ }
582
+
345
583
  httpRequest.onload = function() {
346
584
  if (httpRequest.status === 200) {
347
585
  if (options.dataType == 'json') {
@@ -2019,6 +2257,10 @@ jSuites.color = (function(el, options) {
2019
2257
  // Value
2020
2258
  if (typeof obj.options.value === 'string') {
2021
2259
  el.value = obj.options.value;
2260
+ if (el.tagName === 'INPUT') {
2261
+ el.style.color = el.value;
2262
+ el.style.backgroundColor = el.value;
2263
+ }
2022
2264
  }
2023
2265
 
2024
2266
  // Placeholder
@@ -2033,6 +2275,19 @@ jSuites.color = (function(el, options) {
2033
2275
  return obj;
2034
2276
  }
2035
2277
 
2278
+ obj.select = function(color) {
2279
+ // Remove current selecded mark
2280
+ var selected = container.querySelector('.jcolor-selected');
2281
+ if (selected) {
2282
+ selected.classList.remove('jcolor-selected');
2283
+ }
2284
+
2285
+ // Mark cell as selected
2286
+ if (obj.values[color]) {
2287
+ obj.values[color].classList.add('jcolor-selected');
2288
+ }
2289
+ }
2290
+
2036
2291
  /**
2037
2292
  * Open color pallete
2038
2293
  */
@@ -2041,9 +2296,14 @@ jSuites.color = (function(el, options) {
2041
2296
  // Start tracking
2042
2297
  jSuites.tracking(obj, true);
2043
2298
 
2044
- // Show colorpicker
2299
+ // Show color picker
2045
2300
  container.classList.add('jcolor-focus');
2046
2301
 
2302
+ // Select current color
2303
+ if (obj.options.value) {
2304
+ obj.select(obj.options.value);
2305
+ }
2306
+
2047
2307
  // Reset margin
2048
2308
  content.style.marginTop = '';
2049
2309
  content.style.marginLeft = '';
@@ -2128,15 +2388,7 @@ jSuites.color = (function(el, options) {
2128
2388
  slidersResult = color;
2129
2389
 
2130
2390
  // Remove current selecded mark
2131
- var selected = container.querySelector('.jcolor-selected');
2132
- if (selected) {
2133
- selected.classList.remove('jcolor-selected');
2134
- }
2135
-
2136
- // Mark cell as selected
2137
- if (obj.values[color]) {
2138
- obj.values[color].classList.add('jcolor-selected');
2139
- }
2391
+ obj.select(color);
2140
2392
 
2141
2393
  // Onchange
2142
2394
  if (typeof(obj.options.onchange) == 'function') {
@@ -2147,6 +2399,11 @@ jSuites.color = (function(el, options) {
2147
2399
  if (el.value != obj.options.value) {
2148
2400
  // Set input value
2149
2401
  el.value = obj.options.value;
2402
+ if (el.tagName === 'INPUT') {
2403
+ el.style.color = el.value;
2404
+ el.style.backgroundColor = el.value;
2405
+ }
2406
+
2150
2407
  // Element onchange native
2151
2408
  if (typeof(el.oninput) == 'function') {
2152
2409
  el.oninput({
@@ -2233,16 +2490,6 @@ jSuites.color = (function(el, options) {
2233
2490
  // Append to the table
2234
2491
  tableContainer.appendChild(t);
2235
2492
 
2236
- // Select color
2237
- tableContainer.addEventListener("mousedown", function(e) {
2238
- if (e.target.tagName == 'TD') {
2239
- var value = e.target.getAttribute('data-value');
2240
- if (value) {
2241
- obj.setValue(value);
2242
- }
2243
- }
2244
- });
2245
-
2246
2493
  return tableContainer;
2247
2494
  }
2248
2495
 
@@ -2474,22 +2721,12 @@ jSuites.color = (function(el, options) {
2474
2721
  resetButton = document.createElement('div');
2475
2722
  resetButton.className = 'jcolor-reset';
2476
2723
  resetButton.innerHTML = obj.options.resetLabel;
2477
- resetButton.onclick = function(e) {
2478
- obj.setValue('');
2479
- obj.close();
2480
- }
2481
2724
  controls.appendChild(resetButton);
2482
2725
 
2483
2726
  // Close button
2484
2727
  closeButton = document.createElement('div');
2485
2728
  closeButton.className = 'jcolor-close';
2486
2729
  closeButton.innerHTML = obj.options.doneLabel;
2487
- closeButton.onclick = function(e) {
2488
- if (jsuitesTabs.getActive() > 0) {
2489
- obj.setValue(slidersResult);
2490
- }
2491
- obj.close();
2492
- }
2493
2730
  controls.appendChild(closeButton);
2494
2731
 
2495
2732
  // Element that will be used to create the tabs
@@ -2541,6 +2778,27 @@ jSuites.color = (function(el, options) {
2541
2778
  el.appendChild(container);
2542
2779
  }
2543
2780
 
2781
+ container.addEventListener("click", function(e) {
2782
+ if (e.target.tagName == 'TD') {
2783
+ var value = e.target.getAttribute('data-value');
2784
+ if (value) {
2785
+ obj.setValue(value);
2786
+ }
2787
+ } else if (e.target.classList.contains('jcolor-reset')) {
2788
+ obj.setValue('');
2789
+ obj.close();
2790
+ } else if (e.target.classList.contains('jcolor-close')) {
2791
+ if (jsuitesTabs.getActive() > 0) {
2792
+ obj.setValue(slidersResult);
2793
+ }
2794
+ obj.close();
2795
+ } else if (e.target.classList.contains('jcolor-backdrop')) {
2796
+ obj.close();
2797
+ } else {
2798
+ obj.open();
2799
+ }
2800
+ });
2801
+
2544
2802
  /**
2545
2803
  * If element is focus open the picker
2546
2804
  */
@@ -2548,17 +2806,6 @@ jSuites.color = (function(el, options) {
2548
2806
  obj.open();
2549
2807
  });
2550
2808
 
2551
- backdrop.addEventListener("mousedown", function(e) {
2552
- backdropClickControl = true;
2553
- });
2554
-
2555
- backdrop.addEventListener("click", function(e) {
2556
- if (backdropClickControl) {
2557
- backdropClickControl = false;
2558
- obj.close();
2559
- }
2560
- });
2561
-
2562
2809
  // If the picker is open on the spectrum tab, it changes the canvas size when the window size is changed
2563
2810
  window.addEventListener('resize', function() {
2564
2811
  if (container.classList.contains('jcolor-focus') && jsuitesTabs.getActive() == 1) {
@@ -2590,6 +2837,18 @@ jSuites.color = (function(el, options) {
2590
2837
  container.color = obj;
2591
2838
  }
2592
2839
 
2840
+ obj.toHex = function(rgb) {
2841
+ var hex = function(x) {
2842
+ return ("0" + parseInt(x).toString(16)).slice(-2);
2843
+ }
2844
+ if (/^#[0-9A-F]{6}$/i.test(rgb)) {
2845
+ return rgb;
2846
+ } else {
2847
+ rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
2848
+ return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
2849
+ }
2850
+ }
2851
+
2593
2852
  init();
2594
2853
 
2595
2854
  return obj;
@@ -2598,7 +2857,8 @@ jSuites.color = (function(el, options) {
2598
2857
 
2599
2858
 
2600
2859
  jSuites.contextmenu = (function(el, options) {
2601
- var obj = {};
2860
+ // New instance
2861
+ var obj = { type:'contextmenu'};
2602
2862
  obj.options = {};
2603
2863
 
2604
2864
  // Default configuration
@@ -2618,8 +2878,6 @@ jSuites.contextmenu = (function(el, options) {
2618
2878
 
2619
2879
  // Class definition
2620
2880
  el.classList.add('jcontextmenu');
2621
- // Focusable
2622
- el.setAttribute('tabindex', '900');
2623
2881
 
2624
2882
  /**
2625
2883
  * Open contextmenu
@@ -2632,6 +2890,20 @@ jSuites.contextmenu = (function(el, options) {
2632
2890
  obj.create(items);
2633
2891
  }
2634
2892
 
2893
+ // Close current contextmenu
2894
+ if (jSuites.contextmenu.current) {
2895
+ jSuites.contextmenu.current.close();
2896
+ }
2897
+
2898
+ // Add to the opened components monitor
2899
+ jSuites.tracking(obj, true);
2900
+
2901
+ // Show context menu
2902
+ el.classList.add('jcontextmenu-focus');
2903
+
2904
+ // Current
2905
+ jSuites.contextmenu.current = obj;
2906
+
2635
2907
  // Coordinates
2636
2908
  if ((obj.options.items && obj.options.items.length > 0) || el.children.length) {
2637
2909
  if (e.target) {
@@ -2642,9 +2914,6 @@ jSuites.contextmenu = (function(el, options) {
2642
2914
  var y = e.y;
2643
2915
  }
2644
2916
 
2645
- el.classList.add('jcontextmenu-focus');
2646
- el.focus();
2647
-
2648
2917
  var rect = el.getBoundingClientRect();
2649
2918
 
2650
2919
  if (window.innerHeight < y + rect.height) {
@@ -2676,6 +2945,7 @@ jSuites.contextmenu = (function(el, options) {
2676
2945
  if (el.classList.contains('jcontextmenu-focus')) {
2677
2946
  el.classList.remove('jcontextmenu-focus');
2678
2947
  }
2948
+ jSuites.tracking(obj, false);
2679
2949
  }
2680
2950
 
2681
2951
  /**
@@ -2805,54 +3075,15 @@ jSuites.contextmenu = (function(el, options) {
2805
3075
  obj.create(obj.options.items);
2806
3076
  }
2807
3077
 
2808
- el.addEventListener('blur', function(e) {
3078
+ window.addEventListener("mousewheel", function() {
2809
3079
  obj.close();
2810
3080
  });
2811
3081
 
2812
- if (! jSuites.contextmenu.hasEvents) {
2813
- window.addEventListener("mousewheel", function() {
2814
- obj.close();
2815
- });
2816
-
2817
- document.addEventListener("contextmenu", function(e) {
2818
- var id = jSuites.contextmenu.getElement(e.target);
2819
- if (id) {
2820
- var element = document.querySelector('#' + id);
2821
- if (! element) {
2822
- console.error('JSUITES: Contextmenu id not found');
2823
- } else {
2824
- element.contextmenu.open(e);
2825
- e.preventDefault();
2826
- }
2827
- }
2828
- });
2829
-
2830
- jSuites.contextmenu.hasEvents = true;
2831
- }
2832
-
2833
3082
  el.contextmenu = obj;
2834
3083
 
2835
3084
  return obj;
2836
3085
  });
2837
3086
 
2838
- jSuites.contextmenu.getElement = function(element) {
2839
- var foundId = 0;
2840
-
2841
- function path (element) {
2842
- if (element.parentNode && element.getAttribute('aria-contextmenu-id')) {
2843
- foundId = element.getAttribute('aria-contextmenu-id')
2844
- } else {
2845
- if (element.parentNode) {
2846
- path(element.parentNode);
2847
- }
2848
- }
2849
- }
2850
-
2851
- path(element);
2852
-
2853
- return foundId;
2854
- }
2855
-
2856
3087
 
2857
3088
  jSuites.dropdown = (function(el, options) {
2858
3089
  // Already created, update options
@@ -3745,11 +3976,6 @@ jSuites.dropdown = (function(el, options) {
3745
3976
  * Change event
3746
3977
  */
3747
3978
  var change = function(oldValue) {
3748
- // Events
3749
- if (typeof(obj.options.onchange) == 'function') {
3750
- obj.options.onchange(el, obj, oldValue, obj.options.value);
3751
- }
3752
-
3753
3979
  // Lemonade JS
3754
3980
  if (el.value != obj.options.value) {
3755
3981
  el.value = obj.options.value;
@@ -3761,6 +3987,11 @@ jSuites.dropdown = (function(el, options) {
3761
3987
  });
3762
3988
  }
3763
3989
  }
3990
+
3991
+ // Events
3992
+ if (typeof(obj.options.onchange) == 'function') {
3993
+ obj.options.onchange(el, obj, oldValue, obj.options.value);
3994
+ }
3764
3995
  }
3765
3996
 
3766
3997
  /**
@@ -7670,7 +7901,7 @@ jSuites.mask = (function() {
7670
7901
  o.tokens = getTokens.call(o, o.mask);
7671
7902
  }
7672
7903
  // On new input
7673
- if (typeof(e) !== 'object' || ! e.inputType || e.inputType == 'insertText' || e.inputType == 'insertFromPaste') {
7904
+ if (typeof(e) !== 'object' || ! e.inputType || ! e.inputType.indexOf('insert') || ! e.inputType.indexOf('delete')) {
7674
7905
  // Start tranformation
7675
7906
  if (o.locale) {
7676
7907
  if (o.input) {