jsuites 4.12.9 → 4.13.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.
@@ -15,14 +15,17 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- var jSuites = function(options) {
19
- var obj = {}
20
- var version = '4.12.9';
18
+ var Version = '4.13.0';
19
+
20
+ var Events = function() {
21
21
 
22
22
  var find = function(DOMElement, component) {
23
23
  if (DOMElement[component.type] && DOMElement[component.type] == component) {
24
24
  return true;
25
25
  }
26
+ if (DOMElement.component && DOMElement.component == component) {
27
+ return true;
28
+ }
26
29
  if (DOMElement.parentNode) {
27
30
  return find(DOMElement.parentNode, component);
28
31
  }
@@ -30,7 +33,7 @@ var jSuites = function(options) {
30
33
  }
31
34
 
32
35
  var isOpened = function(e) {
33
- if (jSuites.current.length > 0) {
36
+ if (jSuites.current && jSuites.current.length > 0) {
34
37
  for (var i = 0; i < jSuites.current.length; i++) {
35
38
  if (jSuites.current[i] && ! find(e, jSuites.current[i])) {
36
39
  jSuites.current[i].close();
@@ -39,428 +42,430 @@ var jSuites = function(options) {
39
42
  }
40
43
  }
41
44
 
42
- obj.init = function() {
43
- // Width of the border
44
- var cornerSize = 15;
45
+ // Width of the border
46
+ var cornerSize = 15;
45
47
 
46
- // Current element
47
- var element = null;
48
+ // Current element
49
+ var element = null;
48
50
 
49
- // Controllers
50
- var editorAction = false;
51
+ // Controllers
52
+ var editorAction = false;
51
53
 
52
- // Event state
53
- var state = {
54
- x: null,
55
- y: null,
56
- }
54
+ // Event state
55
+ var state = {
56
+ x: null,
57
+ y: null,
58
+ }
57
59
 
58
- // Tooltip element
59
- var tooltip = document.createElement('div')
60
- tooltip.classList.add('jtooltip');
60
+ // Tooltip element
61
+ var tooltip = document.createElement('div')
62
+ tooltip.classList.add('jtooltip');
61
63
 
62
- // Events
63
- var mouseDown = function(e) {
64
- // Check if this is the floating
65
- var item = jSuites.findElement(e.target, 'jpanel');
66
- // Jfloating found
67
- if (item && ! item.classList.contains("readonly")) {
68
- // Add focus to the chart container
69
- item.focus();
70
- // Keep the tracking information
71
- var rect = e.target.getBoundingClientRect();
72
- editorAction = {
73
- e: item,
74
- x: e.clientX,
75
- y: e.clientY,
76
- w: rect.width,
77
- h: rect.height,
78
- d: item.style.cursor,
79
- resizing: item.style.cursor ? true : false,
80
- actioned: false,
81
- }
64
+ // Events
65
+ var mouseDown = function(e) {
66
+ // Check if this is the floating
67
+ var item = jSuites.findElement(e.target, 'jpanel');
68
+ // Jfloating found
69
+ if (item && ! item.classList.contains("readonly")) {
70
+ // Add focus to the chart container
71
+ item.focus();
72
+ // Keep the tracking information
73
+ var rect = e.target.getBoundingClientRect();
74
+ editorAction = {
75
+ e: item,
76
+ x: e.clientX,
77
+ y: e.clientY,
78
+ w: rect.width,
79
+ h: rect.height,
80
+ d: item.style.cursor,
81
+ resizing: item.style.cursor ? true : false,
82
+ actioned: false,
83
+ }
82
84
 
83
- // Make sure width and height styling is OK
84
- if (! item.style.width) {
85
- item.style.width = rect.width + 'px';
86
- }
85
+ // Make sure width and height styling is OK
86
+ if (! item.style.width) {
87
+ item.style.width = rect.width + 'px';
88
+ }
87
89
 
88
- if (! item.style.height) {
89
- item.style.height = rect.height + 'px';
90
- }
90
+ if (! item.style.height) {
91
+ item.style.height = rect.height + 'px';
92
+ }
91
93
 
92
- // Remove any selection from the page
93
- var s = window.getSelection();
94
- if (s.rangeCount) {
95
- for (var i = 0; i < s.rangeCount; i++) {
96
- s.removeRange(s.getRangeAt(i));
97
- }
94
+ // Remove any selection from the page
95
+ var s = window.getSelection();
96
+ if (s.rangeCount) {
97
+ for (var i = 0; i < s.rangeCount; i++) {
98
+ s.removeRange(s.getRangeAt(i));
98
99
  }
99
-
100
- e.preventDefault();
101
- e.stopPropagation();
102
- } else {
103
- // No floating action found
104
- editorAction = false;
105
100
  }
106
101
 
107
- // Verify current components tracking
108
- if (e.changedTouches && e.changedTouches[0]) {
109
- var x = e.changedTouches[0].clientX;
110
- var y = e.changedTouches[0].clientY;
111
- } else {
112
- var x = e.clientX;
113
- var y = e.clientY;
114
- }
102
+ e.preventDefault();
103
+ e.stopPropagation();
104
+ } else {
105
+ // No floating action found
106
+ editorAction = false;
107
+ }
108
+
109
+ // Verify current components tracking
110
+ if (e.changedTouches && e.changedTouches[0]) {
111
+ var x = e.changedTouches[0].clientX;
112
+ var y = e.changedTouches[0].clientY;
113
+ } else {
114
+ var x = e.clientX;
115
+ var y = e.clientY;
116
+ }
115
117
 
116
- // Which component I am clicking
117
- var path = event.path || (event.composedPath && event.composedPath());
118
+ // Which component I am clicking
119
+ var path = event.path || (event.composedPath && event.composedPath());
118
120
 
119
- // If path available get the first element in the chain
120
- if (path) {
121
- element = path[0];
121
+ // If path available get the first element in the chain
122
+ if (path) {
123
+ element = path[0];
124
+ } else {
125
+ // Try to guess using the coordinates
126
+ if (e.target && e.target.shadowRoot) {
127
+ var d = e.target.shadowRoot;
122
128
  } else {
123
- // Try to guess using the coordinates
124
- if (e.target && e.target.shadowRoot) {
125
- var d = e.target.shadowRoot;
126
- } else {
127
- var d = document;
128
- }
129
- // Get the first target element
130
- element = d.elementFromPoint(x, y);
129
+ var d = document;
131
130
  }
132
-
133
- isOpened(element);
131
+ // Get the first target element
132
+ element = d.elementFromPoint(x, y);
134
133
  }
135
134
 
136
- var mouseUp = function(e) {
137
- if (editorAction && editorAction.e) {
138
- if (typeof(editorAction.e.refresh) == 'function' && state.actioned) {
139
- editorAction.e.refresh();
140
- }
141
- editorAction.e.style.cursor = '';
142
- }
135
+ isOpened(element);
136
+ }
143
137
 
144
- // Reset
145
- state = {
146
- x: null,
147
- y: null,
138
+ var mouseUp = function(e) {
139
+ if (editorAction && editorAction.e) {
140
+ if (typeof(editorAction.e.refresh) == 'function' && state.actioned) {
141
+ editorAction.e.refresh();
148
142
  }
149
-
150
- editorAction = false;
143
+ editorAction.e.style.cursor = '';
151
144
  }
152
145
 
153
- var mouseMove = function(e) {
154
- if (editorAction) {
155
- var x = e.clientX || e.pageX;
156
- var y = e.clientY || e.pageY;
157
-
158
- // Action on going
159
- if (! editorAction.resizing) {
160
- if (state.x == null && state.y == null) {
161
- state.x = x;
162
- state.y = y;
163
- }
146
+ // Reset
147
+ state = {
148
+ x: null,
149
+ y: null,
150
+ }
164
151
 
165
- var dx = x - state.x;
166
- var dy = y - state.y;
167
- var top = editorAction.e.offsetTop + dy;
168
- var left = editorAction.e.offsetLeft + dx;
152
+ editorAction = false;
153
+ }
169
154
 
170
- // Update position
171
- editorAction.e.style.top = top + 'px';
172
- editorAction.e.style.left = left + 'px';
173
- editorAction.e.style.cursor = "move";
155
+ var mouseMove = function(e) {
156
+ if (editorAction) {
157
+ var x = e.clientX || e.pageX;
158
+ var y = e.clientY || e.pageY;
174
159
 
160
+ // Action on going
161
+ if (! editorAction.resizing) {
162
+ if (state.x == null && state.y == null) {
175
163
  state.x = x;
176
164
  state.y = y;
165
+ }
177
166
 
167
+ var dx = x - state.x;
168
+ var dy = y - state.y;
169
+ var top = editorAction.e.offsetTop + dy;
170
+ var left = editorAction.e.offsetLeft + dx;
178
171
 
179
- // Update element
180
- if (typeof(editorAction.e.refresh) == 'function') {
181
- state.actioned = true;
182
- editorAction.e.refresh('position', top, left);
183
- }
184
- } else {
185
- var width = null;
186
- var height = null;
187
-
188
- if (editorAction.d == 'e-resize' || editorAction.d == 'ne-resize' || editorAction.d == 'se-resize') {
189
- // Update width
190
- width = editorAction.w + (x - editorAction.x);
191
- editorAction.e.style.width = width + 'px';
192
-
193
- // Update Height
194
- if (e.shiftKey) {
195
- var newHeight = (x - editorAction.x) * (editorAction.h / editorAction.w);
196
- height = editorAction.h + newHeight;
197
- editorAction.e.style.height = height + 'px';
198
- } else {
199
- var newHeight = false;
200
- }
201
- }
172
+ // Update position
173
+ editorAction.e.style.top = top + 'px';
174
+ editorAction.e.style.left = left + 'px';
175
+ editorAction.e.style.cursor = "move";
202
176
 
203
- if (! newHeight) {
204
- if (editorAction.d == 's-resize' || editorAction.d == 'se-resize' || editorAction.d == 'sw-resize') {
205
- height = editorAction.h + (y - editorAction.y);
206
- editorAction.e.style.height = height + 'px';
207
- }
177
+ state.x = x;
178
+ state.y = y;
179
+
180
+
181
+ // Update element
182
+ if (typeof(editorAction.e.refresh) == 'function') {
183
+ state.actioned = true;
184
+ editorAction.e.refresh('position', top, left);
185
+ }
186
+ } else {
187
+ var width = null;
188
+ var height = null;
189
+
190
+ if (editorAction.d == 'e-resize' || editorAction.d == 'ne-resize' || editorAction.d == 'se-resize') {
191
+ // Update width
192
+ width = editorAction.w + (x - editorAction.x);
193
+ editorAction.e.style.width = width + 'px';
194
+
195
+ // Update Height
196
+ if (e.shiftKey) {
197
+ var newHeight = (x - editorAction.x) * (editorAction.h / editorAction.w);
198
+ height = editorAction.h + newHeight;
199
+ editorAction.e.style.height = height + 'px';
200
+ } else {
201
+ var newHeight = false;
208
202
  }
203
+ }
209
204
 
210
- // Update element
211
- if (typeof(editorAction.e.refresh) == 'function') {
212
- state.actioned = true;
213
- editorAction.e.refresh('dimensions', width, height);
205
+ if (! newHeight) {
206
+ if (editorAction.d == 's-resize' || editorAction.d == 'se-resize' || editorAction.d == 'sw-resize') {
207
+ height = editorAction.h + (y - editorAction.y);
208
+ editorAction.e.style.height = height + 'px';
214
209
  }
215
210
  }
216
- } else {
217
- // Resizing action
218
- var item = jSuites.findElement(e.target, 'jpanel');
219
- // Found eligible component
220
- if (item) {
221
- if (item.getAttribute('tabindex')) {
222
- var rect = item.getBoundingClientRect();
223
- if (e.clientY - rect.top < cornerSize) {
224
- if (rect.width - (e.clientX - rect.left) < cornerSize) {
225
- item.style.cursor = 'ne-resize';
226
- } else if (e.clientX - rect.left < cornerSize) {
227
- item.style.cursor = 'nw-resize';
228
- } else {
229
- item.style.cursor = 'n-resize';
230
- }
231
- } else if (rect.height - (e.clientY - rect.top) < cornerSize) {
232
- if (rect.width - (e.clientX - rect.left) < cornerSize) {
233
- item.style.cursor = 'se-resize';
234
- } else if (e.clientX - rect.left < cornerSize) {
235
- item.style.cursor = 'sw-resize';
236
- } else {
237
- item.style.cursor = 's-resize';
238
- }
239
- } else if (rect.width - (e.clientX - rect.left) < cornerSize) {
240
- item.style.cursor = 'e-resize';
211
+
212
+ // Update element
213
+ if (typeof(editorAction.e.refresh) == 'function') {
214
+ state.actioned = true;
215
+ editorAction.e.refresh('dimensions', width, height);
216
+ }
217
+ }
218
+ } else {
219
+ // Resizing action
220
+ var item = jSuites.findElement(e.target, 'jpanel');
221
+ // Found eligible component
222
+ if (item) {
223
+ if (item.getAttribute('tabindex')) {
224
+ var rect = item.getBoundingClientRect();
225
+ if (e.clientY - rect.top < cornerSize) {
226
+ if (rect.width - (e.clientX - rect.left) < cornerSize) {
227
+ item.style.cursor = 'ne-resize';
228
+ } else if (e.clientX - rect.left < cornerSize) {
229
+ item.style.cursor = 'nw-resize';
230
+ } else {
231
+ item.style.cursor = 'n-resize';
232
+ }
233
+ } else if (rect.height - (e.clientY - rect.top) < cornerSize) {
234
+ if (rect.width - (e.clientX - rect.left) < cornerSize) {
235
+ item.style.cursor = 'se-resize';
241
236
  } else if (e.clientX - rect.left < cornerSize) {
242
- item.style.cursor = 'w-resize';
237
+ item.style.cursor = 'sw-resize';
243
238
  } else {
244
- item.style.cursor = '';
239
+ item.style.cursor = 's-resize';
245
240
  }
241
+ } else if (rect.width - (e.clientX - rect.left) < cornerSize) {
242
+ item.style.cursor = 'e-resize';
243
+ } else if (e.clientX - rect.left < cornerSize) {
244
+ item.style.cursor = 'w-resize';
245
+ } else {
246
+ item.style.cursor = '';
246
247
  }
247
248
  }
248
249
  }
249
250
  }
251
+ }
250
252
 
251
- var mouseOver = function(e) {
252
- var message = e.target.getAttribute('data-tooltip');
253
- if (message) {
254
- // Instructions
255
- tooltip.innerText = message;
256
-
257
- // Position
258
- if (e.changedTouches && e.changedTouches[0]) {
259
- var x = e.changedTouches[0].clientX;
260
- var y = e.changedTouches[0].clientY;
261
- } else {
262
- var x = e.clientX;
263
- var y = e.clientY;
264
- }
253
+ var mouseOver = function(e) {
254
+ var message = e.target.getAttribute('data-tooltip');
255
+ if (message) {
256
+ // Instructions
257
+ tooltip.innerText = message;
265
258
 
266
- tooltip.style.top = y + 'px';
267
- tooltip.style.left = x + 'px';
268
- document.body.appendChild(tooltip);
269
- } else if (tooltip.innerText) {
270
- tooltip.innerText = '';
271
- document.body.removeChild(tooltip);
259
+ // Position
260
+ if (e.changedTouches && e.changedTouches[0]) {
261
+ var x = e.changedTouches[0].clientX;
262
+ var y = e.changedTouches[0].clientY;
263
+ } else {
264
+ var x = e.clientX;
265
+ var y = e.clientY;
272
266
  }
273
- }
274
267
 
275
- var dblClick = function(e) {
276
- var item = jSuites.findElement(e.target, 'jpanel');
277
- if (item && typeof(item.dblclick) == 'function') {
278
- // Create edition
279
- item.dblclick(e);
280
- }
268
+ tooltip.style.top = y + 'px';
269
+ tooltip.style.left = x + 'px';
270
+ document.body.appendChild(tooltip);
271
+ } else if (tooltip.innerText) {
272
+ tooltip.innerText = '';
273
+ document.body.removeChild(tooltip);
281
274
  }
275
+ }
282
276
 
283
- var contextMenu = function(e) {
284
- var item = document.activeElement;
285
- if (item && typeof(item.contextmenu) == 'function') {
286
- // Create edition
287
- item.contextmenu(e);
277
+ var dblClick = function(e) {
278
+ var item = jSuites.findElement(e.target, 'jpanel');
279
+ if (item && typeof(item.dblclick) == 'function') {
280
+ // Create edition
281
+ item.dblclick(e);
282
+ }
283
+ }
288
284
 
289
- e.preventDefault();
290
- e.stopImmediatePropagation();
291
- } else {
292
- // Search for possible context menus
293
- item = jSuites.findElement(e.target, function(o) {
294
- return o.tagName && o.getAttribute('aria-contextmenu-id');
295
- });
285
+ var contextMenu = function(e) {
286
+ var item = document.activeElement;
287
+ if (item && typeof(item.contextmenu) == 'function') {
288
+ // Create edition
289
+ item.contextmenu(e);
296
290
 
297
- if (item) {
298
- var o = document.querySelector('#' + item);
299
- if (! o) {
300
- console.error('JSUITES: contextmenu id not found: ' + item);
301
- } else {
302
- o.contextmenu.open(e);
303
- e.preventDefault();
304
- e.stopImmediatePropagation();
305
- }
306
- }
307
- }
308
- }
291
+ e.preventDefault();
292
+ e.stopImmediatePropagation();
293
+ } else {
294
+ // Search for possible context menus
295
+ item = jSuites.findElement(e.target, function(o) {
296
+ return o.tagName && o.getAttribute('aria-contextmenu-id');
297
+ });
309
298
 
310
- var keyDown = function(e) {
311
- var item = document.activeElement;
312
299
  if (item) {
313
- if (e.key == "Delete" && typeof(item.delete) == 'function') {
314
- item.delete();
300
+ var o = document.querySelector('#' + item);
301
+ if (! o) {
302
+ console.error('JSUITES: contextmenu id not found: ' + item);
303
+ } else {
304
+ o.contextmenu.open(e);
315
305
  e.preventDefault();
316
306
  e.stopImmediatePropagation();
317
307
  }
318
308
  }
309
+ }
310
+ }
319
311
 
320
- if (jSuites.current.length) {
321
- if (item = jSuites.current[jSuites.current.length - 1]) {
322
- if (e.key == "Escape" && typeof(item.close) == 'function') {
323
- item.close();
324
- e.preventDefault();
325
- e.stopImmediatePropagation();
326
- }
312
+ var keyDown = function(e) {
313
+ var item = document.activeElement;
314
+ if (item) {
315
+ if (e.key == "Delete" && typeof(item.delete) == 'function') {
316
+ item.delete();
317
+ e.preventDefault();
318
+ e.stopImmediatePropagation();
319
+ }
320
+ }
321
+
322
+ if (jSuites.current && jSuites.current.length) {
323
+ if (item = jSuites.current[jSuites.current.length - 1]) {
324
+ if (e.key == "Escape" && typeof(item.close) == 'function') {
325
+ item.close();
326
+ e.preventDefault();
327
+ e.stopImmediatePropagation();
327
328
  }
328
329
  }
329
330
  }
331
+ }
332
+
333
+ document.addEventListener('mouseup', mouseUp);
334
+ document.addEventListener("mousedown", mouseDown);
335
+ document.addEventListener('mousemove', mouseMove);
336
+ document.addEventListener('mouseover', mouseOver);
337
+ document.addEventListener('dblclick', dblClick);
338
+ document.addEventListener('keydown', keyDown);
339
+ document.addEventListener('contextmenu', contextMenu);
340
+ };
330
341
 
331
- document.addEventListener('mouseup', mouseUp);
332
- document.addEventListener("mousedown", mouseDown);
333
- document.addEventListener('mousemove', mouseMove);
334
- document.addEventListener('mouseover', mouseOver);
335
- document.addEventListener('dblclick', dblClick);
336
- document.addEventListener('keydown', keyDown);
337
- document.addEventListener('contextmenu', contextMenu);
338
- document.dictionary = {};
342
+ var jSuites = {};
339
343
 
340
- obj.version = version;
344
+ /**
345
+ * Global jsuites event
346
+ */
347
+ if (typeof(document) !== "undefined") {
348
+ if (window.jSuites) {
349
+ jSuites = window.jSuites;
350
+ } else {
351
+ Events();
341
352
  }
353
+ }
342
354
 
343
- obj.setExtensions = function(o) {
344
- if (typeof(o) == 'object') {
345
- var k = Object.keys(o);
346
- for (var i = 0; i < k.length; i++) {
347
- obj[k[i]] = o[k[i]];
348
- }
355
+ jSuites.version = Version;
356
+
357
+ jSuites.setExtensions = function(o) {
358
+ if (typeof(o) == 'object') {
359
+ var k = Object.keys(o);
360
+ for (var i = 0; i < k.length; i++) {
361
+ jSuites[k[i]] = o[k[i]];
349
362
  }
350
363
  }
364
+ }
351
365
 
352
- obj.tracking = function(component, state) {
353
- if (state == true) {
354
- jSuites.current = jSuites.current.filter(function(v) {
355
- return v !== null;
356
- });
366
+ jSuites.tracking = function(component, state) {
367
+ if (! jSuites.current) {
368
+ jSuites.current = [];
369
+ }
357
370
 
358
- // Start after all events
359
- setTimeout(function() {
360
- jSuites.current.push(component);
361
- }, 0);
371
+ if (state == true) {
372
+ jSuites.current = jSuites.current.filter(function(v) {
373
+ return v !== null;
374
+ });
362
375
 
363
- } else {
364
- var index = jSuites.current.indexOf(component);
365
- if (index >= 0) {
366
- jSuites.current.splice(index, 1);
367
- }
376
+ // Start after all events
377
+ setTimeout(function() {
378
+ jSuites.current.push(component);
379
+ }, 0);
380
+
381
+ } else {
382
+ var index = jSuites.current.indexOf(component);
383
+ if (index >= 0) {
384
+ jSuites.current.splice(index, 1);
368
385
  }
369
386
  }
387
+ }
370
388
 
371
- /**
372
- * Get or set a property from a JSON from a string.
373
- */
374
- obj.path = function(str, val) {
375
- str = str.split('.');
376
- if (str.length) {
377
- var o = this;
378
- var p = null;
379
- while (str.length > 1) {
380
- // Get the property
381
- p = str.shift();
382
- // Check if the property exists
383
- if (o.hasOwnProperty(p)) {
384
- o = o[p];
385
- } else {
386
- // Property does not exists
387
- if (val === undefined) {
388
- return undefined;
389
- } else {
390
- // Create the property
391
- o[p] = {};
392
- // Next property
393
- o = o[p];
394
- }
395
- }
396
- }
389
+ /**
390
+ * Get or set a property from a JSON from a string.
391
+ */
392
+ jSuites.path = function(str, val) {
393
+ str = str.split('.');
394
+ if (str.length) {
395
+ var o = this;
396
+ var p = null;
397
+ while (str.length > 1) {
397
398
  // Get the property
398
399
  p = str.shift();
399
- // Set or get the value
400
- if (val !== undefined) {
401
- o[p] = val;
402
- // Success
403
- return true;
400
+ // Check if the property exists
401
+ if (o.hasOwnProperty(p)) {
402
+ o = o[p];
404
403
  } else {
405
- // Return the value
406
- if (o) {
407
- return o[p];
404
+ // Property does not exists
405
+ if (val === undefined) {
406
+ return undefined;
407
+ } else {
408
+ // Create the property
409
+ o[p] = {};
410
+ // Next property
411
+ o = o[p];
408
412
  }
409
413
  }
410
414
  }
411
- // Something went wrong
412
- return false;
413
- }
414
-
415
- // Update dictionary
416
- obj.setDictionary = function(d) {
417
- if (! document.dictionary) {
418
- document.dictionary = {}
419
- }
420
- // Replace the key into the dictionary and append the new ones
421
- var k = Object.keys(d);
422
- for (var i = 0; i < k.length; i++) {
423
- document.dictionary[k[i]] = d[k[i]];
424
- }
425
-
426
- // Translations
427
- var t = null;
428
- for (var i = 0; i < jSuites.calendar.weekdays.length; i++) {
429
- t = jSuites.translate(jSuites.calendar.weekdays[i]);
430
- if (jSuites.calendar.weekdays[i]) {
431
- jSuites.calendar.weekdays[i] = t;
432
- jSuites.calendar.weekdaysShort[i] = t.substr(0,3);
433
- }
434
- }
435
- for (var i = 0; i < jSuites.calendar.months.length; i++) {
436
- t = jSuites.translate(jSuites.calendar.months[i]);
437
- if (t) {
438
- jSuites.calendar.months[i] = t;
439
- jSuites.calendar.monthsShort[i] = t.substr(0,3);
415
+ // Get the property
416
+ p = str.shift();
417
+ // Set or get the value
418
+ if (val !== undefined) {
419
+ o[p] = val;
420
+ // Success
421
+ return true;
422
+ } else {
423
+ // Return the value
424
+ if (o) {
425
+ return o[p];
440
426
  }
441
427
  }
442
428
  }
429
+ // Something went wrong
430
+ return false;
431
+ }
443
432
 
444
- // Translate
445
- obj.translate = function(t) {
446
- if (document.dictionary) {
447
- return document.dictionary[t] || t;
448
- } else {
449
- return t;
450
- }
433
+ // Update dictionary
434
+ jSuites.setDictionary = function(d) {
435
+ if (! document.dictionary) {
436
+ document.dictionary = {}
437
+ }
438
+ // Replace the key into the dictionary and append the new ones
439
+ var k = Object.keys(d);
440
+ for (var i = 0; i < k.length; i++) {
441
+ document.dictionary[k[i]] = d[k[i]];
451
442
  }
452
443
 
453
- // Array of opened components
454
- obj.current = [];
455
-
456
- return obj;
457
- }();
444
+ // Translations
445
+ var t = null;
446
+ for (var i = 0; i < jSuites.calendar.weekdays.length; i++) {
447
+ t = jSuites.translate(jSuites.calendar.weekdays[i]);
448
+ if (jSuites.calendar.weekdays[i]) {
449
+ jSuites.calendar.weekdays[i] = t;
450
+ jSuites.calendar.weekdaysShort[i] = t.substr(0,3);
451
+ }
452
+ }
453
+ for (var i = 0; i < jSuites.calendar.months.length; i++) {
454
+ t = jSuites.translate(jSuites.calendar.months[i]);
455
+ if (t) {
456
+ jSuites.calendar.months[i] = t;
457
+ jSuites.calendar.monthsShort[i] = t.substr(0,3);
458
+ }
459
+ }
460
+ }
458
461
 
459
- /**
460
- * Global jsuites event
461
- */
462
- if (typeof(document) !== "undefined") {
463
- jSuites.init();
462
+ // Translate
463
+ jSuites.translate = function(t) {
464
+ if (document.dictionary) {
465
+ return document.dictionary[t] || t;
466
+ } else {
467
+ return t;
468
+ }
464
469
  }
465
470
 
466
471
  jSuites.ajax = (function(options, complete) {
@@ -8121,7 +8126,11 @@ jSuites.mask = (function() {
8121
8126
  parse.call(o);
8122
8127
  }
8123
8128
 
8124
- if (isNumeric(o.type)) {
8129
+ // New value
8130
+ var newValue = o.values.join('');
8131
+
8132
+ // Add tokens to the end of string only if string is not empty
8133
+ if (isNumeric(o.type) && newValue !== '') {
8125
8134
  // Complement things in the end of the mask
8126
8135
  while (typeof(o.tokens[o.index]) !== 'undefined') {
8127
8136
  var t = getMethod.call(o, o.tokens[o.index]);
@@ -8137,7 +8146,7 @@ jSuites.mask = (function() {
8137
8146
  }
8138
8147
 
8139
8148
  // New value
8140
- var newValue = o.values.join('');
8149
+ newValue = o.values.join('');
8141
8150
 
8142
8151
  // Reset value
8143
8152
  if (o.input) {