-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathinfragistics.ui.editors.js
12846 lines (11954 loc) · 459 KB
/
infragistics.ui.editors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!@license
* Infragistics.Web.ClientUI Editors <build_number>
*
* Copyright (c) 2011-<year> Infragistics Inc.
*
* http://www.infragistics.com/
*
* Depends on:
* jquery.js
* jquery.ui-1.9.0.js
* infragistics.util.js
* infragistics.util.jquery.js
* infragistics.ui.widget.js
* infragistics.ui.popover.js
* infragistics.ui.notifier.js
* infragistics.ui.validator.js
*/
"use strict";
(function (factory) {
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
define( [
"./infragistics.ui.widget",
"./infragistics.ui.validator"
], factory );
} else {
// Browser globals
return factory(jQuery);
}
}
(function ($) {
/* The igBaseEditor is a widget based on jQuery UI. */
$.widget("ui.igBaseEditor", $.ui.igWidget, {
localeWidgetName: "Editor",
options: {
/* type="string|number|null" Gets/Sets the width of the control.
```
//Initialize
$(".selector").%%WidgetName%%({
width : 200
});
//Get
var width = $(".selector").%%WidgetName%%("option", "width");
//Set
$(".selector").%%WidgetName%%("option", "width", 200);
```
string The widget width can be set in pixels (px) and percentage (%).
number The widget width can be set as a number in pixels.
null type="object" will stretch to fit data, if no other widths are defined.
*/
width: null,
/* type="string|number|null" Gets/Sets the height of the control.
```
//Initialize
$(".selector").%%WidgetName%%({
height : 25
});
//Get
var height = $(".selector").%%WidgetName%%("option", "height");
//Set
$(".selector").%%WidgetName%%("option", "height", 25);
```
string The height can be set in pixels (px) and percentage (%).
number The height can be set as a number in pixels.
null type="object" will fit the editor inside its parent container, if no other heights are defined.
*/
height: null,
/* type="object" Gets/Sets value in editor. The effect of setting/getting that option depends on type of editor and on dataMode options for every type of editor.
```
//Initialize
$(".selector").%%WidgetName%%({
value : "Some text"
});
//Get
var value = $(".selector").%%WidgetName%%("option", "value");
//Set
$(".selector").%%WidgetName%%("option", "value", "Some text");
```
*/
value: null,
/* type="number" Gets/Sets tabIndex attribute for the editor input.
```
//Initialize
$('.selector').%%WidgetName%%({
tabIndex: 1
});
//Get
var tabIndex = $(".selector").%%WidgetName%%("option", "tabIndex");
//Set
$(".selector").%%WidgetName%%("option", "tabIndex", 1);
```
*/
tabIndex: null,
/* type="bool" Gets/Sets whether the editor value can become null.
If that option is false, and editor has no value, then value is set to an empty string.
```
//Initialize
$(".selector").%%WidgetName%%({
allowNullValue : false
});
//Get
var allowNullValue = $(".selector").%%WidgetName%%("option", "allowNullValue");
//Set
$(".selector").%%WidgetName%%("option", "allowNullValue", false);
```
*/
allowNullValue: false,
/* type="string|number|null" Gets/Sets the representation of null value. In case of default the value for the input is set to null, which makes the input to hold an empty string
```
//Initialize
$(".selector").%%WidgetName%%({
nullValue : null
});
//Get
var nullValue = $(".selector").%%WidgetName%%("option", "nullValue");
//Set
$(".selector").%%WidgetName%%("option", "nullValue", null);
```
*/
nullValue: null,
/* type="string" Gets/Sets the name attribute of the value input. This input is used to sent the value to the server. In case the target element is input and it has name attribute, but the developer has set the inputName option, so this option overwrites the value input and removes the attribute from the element.
```
//Initialize
$(".selector").%%WidgetName%%({
inputName : "textField"
});
//Get
var inputName = $(".selector").%%WidgetName%%("option", "inputName");
//Set
$(".selector").%%WidgetName%%("option", "inputName", "textField");
```
*/
inputName: null,
/* type="bool" Gets/Sets the readonly attribute for the input. If set to true the input is readonly, and all buttons and interactions are disabled. On submitting the form the editor belongs to, the value is submitted.
```
//Initialize
$(".selector").%%WidgetName%%({
readOnly : true
});
//Get
var readOnly = $(".selector").%%WidgetName%%("option", "readOnly");
//Set
$(".selector").%%WidgetName%%("option", "readOnly", true);
```
*/
readOnly: false,
/* type="bool" Gets/Sets the disabled attribute for the input. If set to true the input is disabled, and all buttons and interactions are disabled. On submitting the form the editor belongs to, the value is not submitted.
```
//Initialize
$(".selector").%%WidgetName%%({
disabled : false
});
//Get
var disabled = $(".selector").%%WidgetName%%("option", "disabled");
//Set
$(".selector").%%WidgetName%%("option", "disabled", true);
```
*/
disabled: false,
/* type="object" Gets/Sets options supported by the [igValidator](ui.igvalidator#options) widget.
Note: Validation rules of [igValidator](ui.igvalidator#options), such as min and max value/length are applied separately triggering errors,
while the corresponding options of the editor prevent values violating the defined rules from being entered.
```
//Initialize
$(".selector").%%WidgetName%%({
validatorOptions : {
successMessage: "Success",
required: true,
onchange: true,
notificationOptions: { mode: "popover" }
}
});
//Get
var validateOptions = $(".selector").%%WidgetName%%("option", "validatorOptions");
//Set
$(".selector").%%WidgetName%%("option", "validatorOptions", {onblur: true, onchange: true});
```
*/
validatorOptions: null
},
css: {
/* Class applied to the main/top element. Default value is 'ui-igedit-input' */
editor: "ui-igedit-input",
/* Class applied to the top element when editor is rendered in container. Default value is 'ui-igedit ui-igedit-container ui-widget ui-corner-all ui-state-default' */
container: "ui-igedit ui-igedit-container ui-widget ui-corner-all ui-state-default",
/* Class applied to the top element when editor is hovered. Default value is 'ui-state-hover' */
hover: "ui-state-hover",
/* Class applied to the top element when editor is active. Default value is 'ui-state-active' */
active: "ui-state-active",
/* Class applied to the top element when editor is on focus. Default value is 'ui-state-focus' */
focus: "ui-state-focus",
/* Classes applied to the editing element in disabled state. Default value is 'ui-igedit-disabled ui-state-disabled' */
disabled: "ui-state-disabled"
},
events: {
/* igWidget events go here */
/* cancel="true" Fired before rendering of the editor has finished.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%rendering", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
rendering: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor performing rendering.
eventArgument="ui.element" argType="object" Gets a reference to the editor element.
*/
rendering: "rendering",
/* cancel="false" Fired after rendering of the editor has finished.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%rendered", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
rendered: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor performing rendering.
eventArgument="ui.element" argType="object" Gets a reference to the editor element.
*/
rendered: "rendered",
/* cancel="true" Fired on mousedown event.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%mousedown", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
mousedown: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
*/
mousedown: "mousedown",
/* cancel="false" Fired on mouseup event.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%mouseup", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
mouseup: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
*/
mouseup: "mouseup",
/* cancel="false" Fired on mousemove at any part of editor including the drop-down list.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%mousemove", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
mousemove: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
*/
mousemove: "mousemove",
/* cancel="false" Fired on mouseover at any part of editor including the drop-down list.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%mouseover", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
mouseover: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
eventArgument="ui.originalEvent" argType="object" Gets a reference to the event object of the browser.
*/
mouseover: "mouseover",
/* cancel="false" Fired on mouseleave at any part of editor including the drop-down list.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%mouseout", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
mouseout: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
eventArgument="ui.originalEvent" argType="object" Gets a reference to the event object of the browser.
*/
mouseout: "mouseout",
/* cancel="false" Fired when the input field of the editor loses focus.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%blur", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
blur: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
*/
blur: "blur",
/* cancel="false" Fired when the input field of the editor gets focus.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%focus", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
focus: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
eventArgument="ui.originalEvent" argType="object" Gets a reference to the event object of the browser.
*/
focus: "focus",
/* cancel="true" Fired on keydown event.
Return false in order to cancel key action.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%keydown", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
keydown: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object. Use evt.originalEvent to obtain reference to event of the browser.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
eventArgument="ui.key" argType="object" Gets the value of the keyCode.
*/
keydown: "keydown",
/* cancel="true" Fired on keypress event.
Return false in order to cancel key action.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%keypress", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
keypress: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object. Use evt.originalEvent to obtain reference to event of the browser.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
eventArgument="ui.key" argType="object" Gets the value of the keyCode.
eventArgument="ui.originalEvent" argType="object" Gets a reference to the event object of the browser.
*/
keypress: "keypress",
/* cancel="false" Fired on keyup event.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%keyup", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
keyup: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object. Use evt.originalEvent to obtain reference to event of the browser.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.element" argType="object" Gets a reference to the event target.
eventArgument="ui.editorInput" argType="object" Gets a reference to the editor input field.
eventArgument="ui.key" argType="object" Gets the value of the keyCode.
eventArgument="ui.originalEvent" argType="object" Gets a reference to the event object of the browser.
*/
keyup: "keyup",
/* cancel="true" Fired before changing the editor's value.
Return false in order to cancel change.
It can be raised after loosing focus or on spin events.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%valuechanging", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
valueChanging: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.editorInput" argType="object" Gets the editor input.
eventArgument="ui.newValue" argType="object" Gets the editor's new value. The argument type might differ depending on the editor type.
eventArgument="ui.oldValue" argType="object" Gets the editor's old value. The argument type might differ depending on the editor type.
*/
valueChanging: "valueChanging",
/* cancel="false" Fired after the editor value is changed. It can be raised after loosing focus or on spin events.
```
//Bind after initialization
$(".selector").on("%%WidgetNameLowered%%valuechanged", function (evt, ui) {
...
});
//Initialize
$(".selector").%%WidgetName%%({
valueChanged: function (evt, ui) {
...
}
});
```
eventArgument="evt" argType="event" jQuery event object.
eventArgument="ui.owner" argType="object" Gets a reference to the editor.
eventArgument="ui.editorInput" argType="object" Gets the editor input.
eventArgument="ui.newValue" argType="object" Gets the value entered from the user after internal formatting. The argument type might differ depending on the editor type.
eventArgument="ui.originalValue" argType="object" Gets the value entered from the user before internal formatting. The argument type might differ depending on the editor type.
*/
valueChanged: "valueChanged"
},
_createWidget: function (options) {
// Those are only the options that are defined by the user, before merged with the default ones.
this._definedOptions = options;
this._superApply(arguments);
},
_create: function () { //BaseEditor
/* igWidget constructor goes here */
this._initialize();
this._readAttributes();
this._saveDOMContent();
this._render();
this.localeContainer = this._editorContainer;
},
_initialize: function () {
this._timeouts = [];
},
_readAttributes: function () {
this._saveAttributes();
this._removeAttributesAndSetThemAsOptions();
},
_saveAttributes: function () {
var i;
var element = this.element[ 0 ], attr;
this._initialAttributes = [];
attr = element.attributes;
for (i = 0; i < attr.length; i++) {
if (attr[ i ].name !== "id") {
this._initialAttributes.push({
name: attr[ i ].name,
attrValue: attr[ i ].value // ,
// propValue: element[ attr[ i ].name ]
});
}
}
},
_removeAttributesAndSetThemAsOptions: function ( ) {
var element = this.element,
name = element.attr("name"),
value = element.attr("value"),
disabled = element.attr("disabled"),
readOnly = element.attr("readOnly");
if (name) {
element.removeAttr("name");
if (this.options.inputName === null) {
this.options.inputName = name;
}
}
if (value) {
element.removeAttr("value");
if (this.options.value === null) {
this.options.value = value;
}
}
if (disabled) {
element.removeAttr("disabled");
// If we have 'disabled' attribute, then it is applied only when 'disabled' options is not defined.
if (this._definedOptions === undefined || this._definedOptions.disabled === undefined) {
this.options.disabled = true;
}
}
if (readOnly) {
element.removeAttr("readonly");
// If we have 'readOnly' attribute, then it is applied only when 'readOnly' options is not defined.
if (this._definedOptions === undefined || this._definedOptions.readOnly === undefined) {
this.options.readOnly = true;
}
}
delete this._definedOptions;
},
_saveDOMContent: function () {
if (this.element.children().length > 0) {
// We use clone because we will preserve event binding to the elements(if any) if binging is through javascript.
// If we use innerHtml then it will be faster(better for performance) but will not preserve data binding to the element inside to the table(if any).
this._initialDOMContent = this.element.children().clone(true);
this.element.empty(); // Remove all element content before rendering it.
}
},
_render: function () {
throw new Error(this._getLocaleValue("renderErrMsg"));
},
_applyOptions: function () {
if (this.options.tabIndex !== null) {
this._setTabIndex(this.options.tabIndex);
}
if (this.options.readOnly) {
this._setReadOnly(true);
}
if (this.options.disabled) {
this._setDisabled(true);
}
if (this.options.inputName) {
this.inputName(this.options.inputName);
}
if (this.options.validatorOptions) {
this._setupValidator();
}
},
_attachEvents: function () {
var self = this;
this._editorContainer.on({
"mousedown.editor": function (event) {
self._triggerMouseDown(event);
},
"mouseup.editor": function (event) {
self._triggerMouseUp(event);
},
"mousemove.editor": function (event) {
self._triggerMouseMove(event);
},
"mouseover.editor": function (event) {
self._triggerMouseOver(event);
},
"mouseout.editor": function (event) {
self._triggerMouseOut(event);
}
});
},
_setupValidator: function () {
if (this.element.igValidator) {
// MV 9th Sep 2019 Bug #1901 Update validator language and locale correctly
var validatorOptions = $.extend(
{},
{ language: this.options.language, locale: this.options.locale },
this.options.validatorOptions
);
this._validator = this.element.igValidator(validatorOptions).data("igValidator");
this._validator.owner = this;
}
},
_destroyValidator: function () {
if (this._validator && this._validator.owner === this) {
this._validator.destroy();
this._validator = null;
}
},
_applyAria: function () {
var ariaLabeledBy = this.element.attr("aria-labelledby");
if (ariaLabeledBy) {
this.element.removeAttr("aria-labelledby");
this._editorInput.attr("aria-labelledby", ariaLabeledBy);
}
if (this._dropDownButton) {
this._editorInput.attr("role", "combobox");
} else {
this._editorInput.attr("role", "textbox");
}
},
_triggerRendering: function () {
var args = {
element: this.element,
owner: this
};
return this._trigger(this.events.rendering, null, args);
},
_triggerRendered: function () {
var args = {
element: this.element,
owner: this
};
this._trigger(this.events.rendered, null, args);
},
_triggerMouseMove: function (event) {
var args = {
owner: this,
element: event.target,
editorInput: this._editorInput
};
this._trigger(this.events.mousemove, event, args);
},
_triggerMouseDown: function (event) {
this._editorContainer.addClass(this.css.active);
var args = {
owner: this,
element: event.target,
editorInput: this._editorInput
};
return this._trigger(this.events.mousedown, event, args);
},
_triggerMouseUp: function (event) {
this._editorContainer.removeClass(this.css.active);
var args = {
owner: this,
element: event.target,
editorInput: this._editorInput
};
this._trigger(this.events.mouseup, event, args);
},
_triggerMouseOver: function (event) {
this._editorContainer.addClass(this.css.hover);
var args = {
originalEvent: event,
owner: this,
element: event.target,
editorInput: this._editorInput
};
this._trigger(this.events.mouseover, event, args);
},
_triggerMouseOut: function (event) {
this._editorContainer.removeClass(this.css.hover);
var args = {
originalEvent: event,
owner: this,
element: event.target,
editorInput: this._editorInput
};
this._trigger(this.events.mouseout, event, args);
},
_triggerFocus: function (event) {
this._editorContainer.addClass(this.css.focus);
var args = {
originalEvent: event,
owner: this,
element: event.target,
editorInput: this._editorInput
};
this._trigger(this.events.focus, event, args);
},
_triggerBlur: function (event) {
this._editorContainer.removeClass(this.css.focus);
this._editorContainer.removeClass(this.css.active);
this._clearEditorNotifier();
var args = {
owner: this,
element: event.target,
editorInput: this._editorInput
};
this._trigger(this.events.blur, event, args);
},
_setOption: function (option, value) { //Base editor
/* igBaseEditor custom setOption goes here */
var prevValue = this.options[ option ];
if (prevValue === value) {
return;
}
// The following line applies the option value to the igWidget meaning you don't
// have to perform this.options[ option ] = value;
$.Widget.prototype._setOption.apply(this, arguments);
switch (option) {
case "readOnly":
this._setReadOnly(value);
break;
case "disabled":
this._setDisabled(value);
break;
case "width":
this._setWidth(value);
break;
case "height":
this._setHeight(value);
break;
case "validatorOptions":
this._setupValidator();
break;
case "tabIndex":
this._setTabIndex(value);
break;
case "inputName":
this._valueInput.attr("name", value);
break;
default:
this.options[ option ] = prevValue;
this._super(option, value);
break;
}
},
_validateValue: function (val) {//Base editor
return val ? true : false;
},
_updateValue: function (value) { //Base Editor
// D.P. 16th Mar 2018 Bug 251229 / #1666 Don't reset edit input text in value method
this._valueInput.val(value);
this.options.value = value;
}, //BaseEditor
//This method sets the value to null, or empty string depending on the nullable option.
_clearValue: function (textOnly) {
var newValue = "";
// TODO use null, or 0 depending on the nullable option
if (this.options.allowNullValue) {
newValue = this.options.nullValue;
}
if (!this._validateValue(newValue)) {
newValue = "";
}
if (textOnly) {
this._editorInput.val(newValue);
} else {
this._updateValue(newValue);
}
},
_detachEvents: function () {
if (this._detachButtonsEvents) {
this._detachButtonsEvents();
}
if (this._detachListEvents) {
this._detachListEvents();
}
if (this._editorContainer) {
this._editorContainer
.off("mousedown.editor mouseup.editor mouseover.editor mouseout.editor");
}
},
_detachButtonsEvents: function () {
if (this._dropDownList) {
this._detachListEvents();
}
if (this._dropDownButton) {
this._detachButtonsEvents(this._dropDownButton);
}
if (this._clearButton) {
this._detachButtonsEvents(this._clearButton);
}
if (this._spinUpButton) {
this._detachButtonsEvents(this._spinUpButton);
}
if (this._spinDownButton) {
this._detachButtonsEvents(this._spinDownButton);
}
},
_restoreDOMStructure: function () {
this._removeDOM();
this._removeAttributes();
this._setPropsDefaults();
this._recoverInitialAttributes();
this._recoverInitialDOMContent();
},
_removeDOM: function () {
this._removeList();
this._removeClearButton();
this._removeSpinButtons();
this._removeContainer();
},
_removeContainer: function () {
if (this._valueInput) {
this._valueInput.remove();
}
if (this.element.is("input")) {
this.element.unwrap().unwrap();
} else if (this.element.is("div")) {
this.element.empty();
} else if (this.element.is("span")) {
this.element.empty();
this.element.unwrap().unwrap();
}
},
_removeList: function () {
if (this._dropDownList) {
this._deleteList();
this._deleteDropDownButton();
}
},
_removeClearButton: function () {
if (this._clearButton) {
this._clearButton.remove();
delete this._clearButton;
}
},
_removeSpinButtons: function () {
if (this._spinUpButton) {
this._spinUpButton.remove();
delete this._spinUpButton;
}
if (this._spinDownButton) {
this._spinDownButton.remove();
delete this._spinDownButton;
}
},
_removeAttributes: function () {
var element = this.element,
attr = element[ 0 ].attributes,
concatenatedAttr = "", i;
for (i = 0; i < attr.length; i++) {
if (attr[ i ].name !== "id") {
concatenatedAttr += (attr[ i ].name + " ") ;
}
}
element.removeAttr(concatenatedAttr.trim());
},
_setPropsDefaults: function () {
var element = this.element[ 0 ];
element.disabled = false;
element.readOnly = false;
element.checked = false;
element.value = null;
},
_recoverInitialAttributes: function () {
var i;
if (this._initialAttributes) {
for (i = 0; i < this._initialAttributes.length; i++) {
if (this._initialAttributes[ i ].name !== "id") {
this.element.attr(this._initialAttributes[ i ].name,
this._initialAttributes[ i ].attrValue);
// I.G. 11/4/2016 Fix for #487 [igBaseEditor] input value property is not restored when destroy method is called
// Restore the initial value property as it was before the widget initialization, so it is again displayed in the input
if (this._initialAttributes[ i ].name === "value" &&
(this.element.is("input"))) {
$(this.element).val(this._initialAttributes[ i ].attrValue);
}
// 3/2/2016 Bug #213138: Don't need to recover DOM information, only attributes.
// if (this._initialAttributes[ i ].propValue !== undefined) {
// this.element.prop(this._initialAttributes[ i ].name,
// this._initialAttributes[ i ].propValue);
//}
}
}
delete this._initialAttributes;
}
},
_recoverInitialDOMContent: function () {
if (this._initialDOMContent) {
this._initialDOMContent.appendTo(this.element);
delete this._initialDOMContent;
}
},
_clearStyling: function () {
if (this._editorContainer) {
this._editorContainer
.removeClass(this.css.container)
.removeClass(this.css.hover)
.removeClass(this.css.active);
}
if (this._editorInput) {
this._editorInput.removeClass(this.css.editor);
}
},
_deleteInternalProperties: function () {
delete this._editorInput;
delete this._editorContainer;
delete this._valueInput;
if (this._timeouts) {
delete this._timeouts;
}
},
_clearTimeouts: function() {
var i, timeouts = this._timeouts;
if (timeouts && timeouts instanceof Array) {
for (i = 0; i < timeouts.length; i++) {
clearTimeout(timeouts[ i ]);
}
this._timeouts = [];
}
},
_disableEditor: function (applyDisabledClass) {
//T.P. 9th Dec 2015 Bug 211010
//applyDisabledClass parameter is flag whether the ui-state-disabled class is applied to the both _editorInput and _valueInput
//In both readOnly and disabled state we have similar logic for making the editor disabled/readonly (detach event and remove classes)
if (applyDisabledClass) {
this._editorContainer.addClass(this.css.disabled);
}
this._detachEvents();
},
_setEditableMode: function () {
//Default value we don't do anything unless we implement setOption related to that.
this._editorInput.prop("readonly", false);
this._valueInput.prop("readonly", false);
this._editorInput.prop("disabled", false);
this._valueInput.prop("disabled", false);
this._editorContainer.removeClass(this.css.disabled);
this._attachEvents();
},
_setDisabled: function (activate) {
if (activate) {
this._editorInput.prop("disabled", true);