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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
|
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
dojo._xdResourceLoaded(function(dojo, dijit, dojox){
return {depends: [["provide", "dojox.editor.plugins.TablePlugins"],
["require", "dijit.form.Button"],
["require", "dijit.Dialog"],
["require", "dijit.form.TextBox"],
["require", "dijit.form.FilteringSelect"],
["require", "dijit._editor._Plugin"],
["require", "dijit._editor.selection"],
["require", "dijit.Menu"],
["require", "dijit.ColorPalette"],
["require", "dojox.widget.ColorPicker"],
["require", "dojo.i18n"],
["requireLocalization", "dojox.editor.plugins", "TableDialog", null, "ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw", "ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"]],
defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.editor.plugins.TablePlugins"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.editor.plugins.TablePlugins"] = true;
dojo.provide("dojox.editor.plugins.TablePlugins");
dojo.require("dijit.form.Button");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit._editor.selection");
dojo.require("dijit.Menu");
dojo.require("dijit.ColorPalette");
dojo.require("dojox.widget.ColorPicker");
dojo.require("dojo.i18n");
;
dojo.experimental("dojox.editor.plugins.TablePlugins");
// summary:
// A series of plugins that give the Editor the ability to create and edit
// HTML tables. See the end of this document for all avaiable plugins
// and dojox/editorPlugins/tests/editorTablePlugs.html for an example
//
// example:
// | <div dojoType="dijit.Editor" plugins="[
// | 'bold','italic','|',
// | {name: 'dojox.editor.plugins.TablePlugins', command: 'insertTable'},
// | {name: 'dojox.editor.plugins.TablePlugins', command: 'modifyTable'}
// | ]">
// | Editor text is here
// | </div>
//
// TODO:
// Currently not supporting merging or splitting cells
//
// FIXME: Undo is very buggy, and therefore unimeplented in all browsers
// except IE - which itself has only been lightly tested.
//
// FIXME: Selecting multiple table cells in Firefox looks to be impossible.
// This affect the 'colorTableCell' plugin. Cells can still be
// colored individually or in rows.
dojo.declare("dojox.editor.plugins._TableHandler", dijit._editor._Plugin,{
// summary:
// A global object that handles common tasks for all the plugins. Since
// there are several plugins that are all calling common methods, it's preferable
// that they call a centralized location that either has a set variable or a
// timeout to only repeat code-heavy calls when necessary.
//
tablesConnected:false,
currentlyAvailable: false,
alwaysAvailable:false,
availableCurrentlySet:false,
initialized:false,
tableData: null,
shiftKeyDown:false,
editorDomNode: null,
undoEnabled: true, //Using custom undo for all browsers.
refCount: 0,
doMixins: function(){
dojo.mixin(this.editor,{
getAncestorElement: function(tagName){
return dojo.withGlobal(this.window, "getAncestorElement",dijit._editor.selection, [tagName]);
},
hasAncestorElement: function(tagName){
return dojo.withGlobal(this.window, "hasAncestorElement",dijit._editor.selection, [tagName]);
},
selectElement: function(elem){
dojo.withGlobal(this.window, "selectElement",dijit._editor.selection, [elem]);
},
byId: function(id){
return dojo.withGlobal(this.window, "byId", dojo, [id]);
},
query: function(arg, scope, returnFirstOnly){
// this shortcut is dubious - not sure scoping is necessary
var ar = dojo.withGlobal(this.window, "query", dojo, [arg, scope]);
return (returnFirstOnly) ? ar[0] : ar;
}
});
},
initialize: function(editor){
// summary:
// Initialize the global handler upon a plugin's first instance of setEditor
//
// All plugins will attempt initialization. We only need to do so once.
// But keep track so that it is cleaned up when all usage of it for an editor has
// been removed.
this.refCount++;
// Turn on custom undo for all.
editor.customUndo = true;
if(this.initialized){ return; }
this.initialized = true;
this.editor = editor;
this.editor._tablePluginHandler = this;
//Editor loads async, can't assume doc is ready yet. So, use the deferred of the
//editor to init at the right time.
editor.onLoadDeferred.addCallback(dojo.hitch(this, function(){
this.editorDomNode = this.editor.editNode || this.editor.iframe.document.body.firstChild;
// RichText should have a mouseup connection to recognize drag-selections
// Example would be selecting multiple table cells
this._myListeners = [];
this._myListeners.push(dojo.connect(this.editorDomNode , "mouseup", this.editor, "onClick"));
this._myListeners.push(dojo.connect(this.editor, "onDisplayChanged", this, "checkAvailable"));
this._myListeners.push(dojo.connect(this.editor, "onBlur", this, "checkAvailable"));
this.doMixins();
this.connectDraggable();
}));
},
getTableInfo: function(forceNewData){
// summary:
// Gets the table in focus
// Collects info on the table - see return params
//
if(forceNewData){ this._tempStoreTableData(false); }
if(this.tableData){
// tableData is set for a short amount of time, so that all
// plugins get the same return without doing the method over
//console.log("returning current tableData:", this.tableData);
return this.tableData;
}
var tr, trs, td, tds, tbl, cols, tdIndex, trIndex;
td = this.editor.getAncestorElement("td");
if(td){ tr = td.parentNode; }
tbl = this.editor.getAncestorElement("table");
//console.log("td:", td);console.log("tr:", tr);console.log("tbl:", tbl)
tds = dojo.query("td", tbl);
tds.forEach(function(d, i){
if(td==d){tdIndex = i;}
});
trs = dojo.query("tr", tbl);
trs.forEach(function(r, i){
if(tr==r){trIndex = i;}
});
cols = tds.length/trs.length;
var o = {
tbl:tbl, // focused table
td:td, // focused TD
tr:tr, // focused TR
trs:trs, // rows
tds:tds, // cells
rows:trs.length,// row amount
cols:cols, // column amount
tdIndex:tdIndex,// index of focused cell
trIndex:trIndex, // index of focused row
colIndex:tdIndex%cols
};
//console.log("NEW tableData:",o);
this.tableData = o;
this._tempStoreTableData(500);
return this.tableData;
},
connectDraggable: function(){
// summary:
// Detects drag-n-drop in the editor (could probably be moved to there)
// Currently only checks if item dragged was a TABLE, and removes its align attr
// DOES NOT WORK IN FF - it could - but FF's drag detection is a monster
//
if(!dojo.isIE){
//console.warn("Drag and Drop is currently only detectable in IE.");
return;
}
// IE ONLY
this.editorDomNode.ondragstart = dojo.hitch(this, "onDragStart");
this.editorDomNode.ondragend = dojo.hitch(this, "onDragEnd");
//NOTES:
// FF _ Able to detect the drag-over object (the editor.domNode)
// Not able to detect an item's ondrag() event
// Don't know why - I actually got it working when there was an error
// Something to do with different documents or windows I'm sure
//
//console.log("connectDraggable", tbl);
/*tbl.ondragstart=dojo.hitch(this, "onDragStart");
tbl.addEventListener("dragstart", dojo.hitch(this, "onDragStart"), false);
tbl.addEventListener("drag", dojo.hitch(this, "onDragStart2"), false);
tbl.addEventListener("dragend", dojo.hitch(this, "onDragStart3"), false);
dojo.withGlobal(this.editor.window, "selectElement",dijit._editor.selection, [tbl]);
tbl.ondragstart = function(){
//console.log("ondragstart");
};
tbl.ondrag = function(){
alert("drag")
//console.log("ondrag");
*/
},
onDragStart: function(){
var e = window.event;
if(!e.srcElement.id){
e.srcElement.id = "tbl_"+(new Date().getTime());
}
//console.log("onDragStart", e.srcElement.id);
},
onDragEnd: function(){
// summary:
// Detects that an object has been dragged into place
// Currently, this code is only used for when a table is dragged
// and clears the "align" attribute, so that the table will look
// to be more in the place that the user expected.
// TODO: This code can be used for other things, most
// notably UNDO, which currently is not quite usable.
// This code could also find itself in the Editor code when it is
// complete.
//console.log("onDragEnd");
var e = window.event;
var node = e.srcElement;
var id = node.id;
var win = this.editor.window;
//console.log("NODE:", node.tagName, node.id, dojo.attr(node, "align"));
// clearing a table's align attr
// TODO: when ondrag becomes more robust, this code block
// should move to its own method
if(node.tagName.toLowerCase()=="table"){
setTimeout(function(){
var node = dojo.withGlobal(win, "byId", dojo, [id]);
dojo.removeAttr(node, "align");
//console.log("set", node.tagName, dojo.attr(node, "align"))
}, 100);
}
},
checkAvailable: function(){
// summary:
// For table plugs
// Checking if a table or part of a table has focus so that
// Plugs can change their status
//
if(this.availableCurrentlySet){
// availableCurrentlySet is set for a short amount of time, so that all
// plugins get the same return without doing the method over
//console.log("availableCurrentlySet:", this.availableCurrentlySet, "currentlyAvailable:", this.currentlyAvailable)
return this.currentlyAvailable;
}
//console.log("G - checkAvailable...");
if(!this.editor) {
//console.log("editor not ready")
return false;
}
if(this.alwaysAvailable) {
//console.log(" return always available")
return true;
}
// Only return avalable if the editor is focused.
this.currentlyAvailable = this.editor._focused ? this.editor.hasAncestorElement("table") : false;
if(this.currentlyAvailable){
this.connectTableKeys();
}else{
this.disconnectTableKeys();
}
this._tempAvailability(500);
dojo.publish(this.editor.id + "_tablePlugins", [ this.currentlyAvailable ]);
return this.currentlyAvailable;
},
_prepareTable: function(tbl){
// For IE's sake, we are adding IDs to the TDs if none is there
// We go ahead and use it for other code for convenience
//
var tds = this.editor.query("td", tbl);
console.log("prep:", tds, tbl);
if(!tds[0].id){
tds.forEach(function(td, i){
if(!td.id){
td.id = "tdid"+i+this.getTimeStamp();
}
}, this);
}
return tds;
},
getTimeStamp: function(){
return new Date().getTime(); // Fixed the bug that this method always returns the same timestamp
// return Math.floor(new Date().getTime() * 0.00000001);
},
_tempStoreTableData: function(type){
// caching or clearing table data, depending on the arg
//
if(type===true){
//store indefinitely
}else if(type===false){
// clear object
this.tableData = null;
}else if(type===undefined){
console.warn("_tempStoreTableData must be passed an argument");
}else{
// type is a number/ms
setTimeout(dojo.hitch(this, function(){
this.tableData = null;
}), type);
}
},
_tempAvailability: function(type){
// caching or clearing availability, depending on the arg
if(type===true){
//store indefinitely
this.availableCurrentlySet = true;
}else if(type===false){
// clear object
this.availableCurrentlySet = false;
}else if(type===undefined){
console.warn("_tempAvailability must be passed an argument");
}else{
// type is a number/ms
this.availableCurrentlySet = true;
setTimeout(dojo.hitch(this, function(){
this.availableCurrentlySet = false;
}), type);
}
},
connectTableKeys: function(){
// summary:
// When a table is in focus, start detecting keys
// Mainly checking for the TAB key so user can tab
// through a table (blocking the browser's desire to
// tab away from teh editor completely)
if(this.tablesConnected){ return; }
this.tablesConnected = true;
var node = (this.editor.iframe) ? this.editor.document : this.editor.editNode;
this.cnKeyDn = dojo.connect(node, "onkeydown", this, "onKeyDown");
this.cnKeyUp = dojo.connect(node, "onkeyup", this, "onKeyUp");
this._myListeners.push(dojo.connect(node, "onkeypress", this, "onKeyUp"));
},
disconnectTableKeys: function(){
//console.log("disconnect")
dojo.disconnect(this.cnKeyDn);
dojo.disconnect(this.cnKeyUp);
this.tablesConnected = false;
},
onKeyDown: function(evt){
var key = evt.keyCode;
//console.log(" -> DOWN:", key);
if(key == 16){ this.shiftKeyDown = true;}
if(key == 9) {
var o = this.getTableInfo();
//console.log("TAB ", o.tdIndex, o);
// modifying the o.tdIndex in the tableData directly, because we may save it
// FIXME: tabTo is a global
o.tdIndex = (this.shiftKeyDown) ? o.tdIndex-1 : tabTo = o.tdIndex+1;
if(o.tdIndex>=0 && o.tdIndex<o.tds.length){
this.editor.selectElement(o.tds[o.tdIndex]);
// we know we are still within a table, so block the need
// to run the method
this.currentlyAvailable = true;
this._tempAvailability(true);
//
this._tempStoreTableData(true);
this.stopEvent = true;
}else{
//tabbed out of table
this.stopEvent = false;
this.onDisplayChanged();
}
if(this.stopEvent) {
dojo.stopEvent(evt);
}
}
},
onKeyUp: function(evt){
var key = evt.keyCode;
//console.log(" -> UP:", key)
if(key == 16){ this.shiftKeyDown = false;}
if(key == 37 || key == 38 || key == 39 || key == 40 ){
// user can arrow or tab out of table - need to recheck
this.onDisplayChanged();
}
if(key == 9 && this.stopEvent){ dojo.stopEvent(evt);}
},
onDisplayChanged: function(){
//console.log("onDisplayChanged")
this.currentlyAvailable = false;
this._tempStoreTableData(false);
this._tempAvailability(false);
this.checkAvailable();
},
uninitialize: function(editor){
// summary:
// Function to handle cleaning up of connects
// and such. It only finally destroys everything once
// all 'references' to it have gone. As in all plugins
// that called init on it destroyed their refs in their
// cleanup calls.
// editor:
// The editor to detach from.
if(this.editor == editor){
this.refCount--;
if(!this.refCount && this.initialized){
if(this.tablesConnected){
this.disconnectTableKeys();
}
this.initialized = false;
dojo.forEach(this._myListeners, function(l){
dojo.disconnect(l);
});
delete this._myListeners;
delete this.editor._tablePluginHandler;
delete this.editor;
}
this.inherited(arguments);
}
}
});
dojo.declare("dojox.editor.plugins.TablePlugins",
dijit._editor._Plugin,
{
//summary:
// A collection of Plugins for inserting and modifying tables in the Editor
// See end of this document for all avaiable plugs
// and dojox/editorPlugins/tests/editorTablePlugs.html for an example
//
// NOT IMPLEMENTED: Not handling cell merge, span or split
//
iconClassPrefix: "editorIcon",
useDefaultCommand: false,
buttonClass: dijit.form.Button,
commandName:"",
label:"",
alwaysAvailable:false,
undoEnabled:true,
onDisplayChanged: function(withinTable){
// subscribed to from the global object's publish method
//
//console.log("onDisplayChanged", this.commandName);
if(!this.alwaysAvailable){
this.available = withinTable;
this.button.set('disabled', !this.available);
}
},
setEditor: function(editor){
this.editor = editor;
this.editor.customUndo = true;
this.inherited(arguments);
this._availableTopic = dojo.subscribe(this.editor.id + "_tablePlugins", this, "onDisplayChanged");
this.onEditorLoaded();
},
onEditorLoaded: function(){
if(!this.editor._tablePluginHandler){
// Create it and init it off the editor. This
// will create the _tablePluginHandler reference on
// the dijit.Editor instance. This avoids a global.
var tablePluginHandler = new dojox.editor.plugins._TableHandler();
tablePluginHandler.initialize(this.editor);
}else{
this.editor._tablePluginHandler.initialize(this.editor);
}
},
selectTable: function(){
// selects table that is in focus
var o = this.getTableInfo();
if(o && o.tbl){
dojo.withGlobal(this.editor.window, "selectElement",dijit._editor.selection, [o.tbl]);
}
},
_initButton: function(){
this.command = this.commandName;
this.label = this.editor.commands[this.command] = this._makeTitle(this.command);
this.inherited(arguments);
delete this.command;
this.connect(this.button, "onClick", "modTable");
this.onDisplayChanged(false);
},
modTable: function(cmd, args){
// summary:
// Where each plugin performs its action
// Note: not using execCommand. In spite of their presence in the
// Editor as query-able plugins, I was not able to find any evidence
// that they are supported (especially in NOT IE). If they are
// supported in other browsers, it may help with the undo problem.
//
this.begEdit();
var o = this.getTableInfo();
var sw = (dojo.isString(cmd))?cmd : this.commandName;
var r, c, i;
var adjustColWidth = false;
//console.log("modTable:", sw)
if(dojo.isIE){
// IE can lose selections on focus changes, so focus back
// in order to restore it.
this.editor.focus();
}
switch(sw){
case "insertTableRowBefore":
r = o.tbl.insertRow(o.trIndex);
for(i=0;i<o.cols;i++){
c = r.insertCell(-1);
c.innerHTML = " ";
}
break;
case "insertTableRowAfter":
r = o.tbl.insertRow(o.trIndex+1);
for(i=0;i<o.cols;i++){
c = r.insertCell(-1);
c.innerHTML = " ";
}
break;
case "insertTableColumnBefore":
o.trs.forEach(function(r){
c = r.insertCell(o.colIndex);
c.innerHTML = " ";
});
adjustColWidth = true;
break;
case "insertTableColumnAfter":
o.trs.forEach(function(r){
c = r.insertCell(o.colIndex+1);
c.innerHTML = " ";
});
adjustColWidth = true;
break;
case "deleteTableRow":
o.tbl.deleteRow(o.trIndex);
console.log("TableInfo:", this.getTableInfo());
break;
case "deleteTableColumn":
o.trs.forEach(function(tr){
tr.deleteCell(o.colIndex);
});
adjustColWidth = true;
break;
case "modifyTable":
break;
case "insertTable":
break;
}
if(adjustColWidth){
this.makeColumnsEven();
}
this.endEdit();
},
begEdit: function(){
if(this.editor._tablePluginHandler.undoEnabled){
//console.log("UNDO:", this.editor.customUndo);
if(this.editor.customUndo){
this.editor.beginEditing();
}else{
this.valBeforeUndo = this.editor.getValue();
//console.log("VAL:", this.valBeforeUndo);
}
}
},
endEdit: function(){
if(this.editor._tablePluginHandler.undoEnabled){
if(this.editor.customUndo){
this.editor.endEditing();
}else{
// This code ALMOST works for undo -
// It seems to only work for one step
// back in history however
var afterUndo = this.editor.getValue();
//this.editor.execCommand("inserthtml", "<p>mike</p>");
this.editor.setValue(this.valBeforeUndo);
this.editor.replaceValue(afterUndo);
}
this.editor.onDisplayChanged();
}
},
makeColumnsEven: function(){
//summary:
// After changing column amount, change widths to
// keep columns even
//
// the timeout helps prevent an occasional snafu
setTimeout(dojo.hitch(this, function(){
var o = this.getTableInfo(true);
var w = Math.floor(100/o.cols);
o.tds.forEach(function(d){
dojo.attr(d, "width", w+"%");
});
}), 10);
},
getTableInfo: function(forceNewData){
// summary:
// Gets the table in focus
// Collects info on the table - see return params
//
return this.editor._tablePluginHandler.getTableInfo(forceNewData);
},
_makeTitle: function(str){
// Parses the commandName into a Title
// based on camelCase
var ns = [];
dojo.forEach(str, function(c, i){
if(c.charCodeAt(0)<91 && i>0 && ns[i-1].charCodeAt(0)!=32){
ns.push(" ");
}
if(i===0){ c = c.toUpperCase();}
ns.push(c);
});
return ns.join("");
},
getSelectedCells: function(){
// summary:
// Gets the selected cells from the passed table
// Returns: array of TDs or empty array
var cells = [];
var tbl = this.getTableInfo().tbl;
this.editor._tablePluginHandler._prepareTable(tbl);
var e = this.editor;
// Lets do this the way IE originally was (Looking up ids). Walking the selection
// is inconsistent in the browsers (and painful), so going by ids is simpler.
var text = dojo.withGlobal(e.window, "getSelectedHtml",dijit._editor.selection, [null]);
var str = text.match(/id="*\w*"*/g);
dojo.forEach(str, function(a){
var id = a.substring(3, a.length);
if(id.charAt(0) == "\"" && id.charAt(id.length - 1) == "\""){
id = id.substring(1, id.length - 1);
}
var node = e.byId(id);
if(node && node.tagName.toLowerCase() == "td"){
cells.push(node);
}
}, this);
if(!cells.length){
//May just be in a cell (cursor point, or selection in a cell), so look upwards.
//for a cell container.
var sel = dijit.range.getSelection(e.window);
if(sel.rangeCount){
var r = sel.getRangeAt(0);
var node = r.startContainer;
while(node && node != e.editNode && node != e.document){
if(node.nodeType === 1){
var tg = node.tagName ? node.tagName.toLowerCase() : "";
if(tg === "td"){
return [node];
}
}
node = node.parentNode;
}
}
}
return cells;
},
updateState: function(){
// summary:
// Over-ride for button state control for disabled to work.
if(this.button){
if((this.available || this.alwaysAvailable) && !this.get("disabled")){
this.button.set("disabled",false);
}else{
this.button.set("disabled",true);
}
}
},
destroy: function(){
// summary:
// Over-ridden destroy to do some cleanup.
this.inherited(arguments);
dojo.unsubscribe(this._availableTopic);
// Disconnect the editor from the handler
// to clean up refs. Moved to using a per-editor
// 'handler' to avoid collisions on the old global.
this.editor._tablePluginHandler.uninitialize(this.editor);
}
}
);
dojo.declare("dojox.editor.plugins.TableContextMenu",
dojox.editor.plugins.TablePlugins,
{
constructor: function(){
// summary:
// Initialize certain plugins
//
this.connect(this, "setEditor", function(editor){
editor.onLoadDeferred.addCallback(dojo.hitch(this, function() {
this._createContextMenu();
}));
this.button.domNode.style.display = "none";
});
},
destroy: function(){
// summary:
// Over-ride to do menu cleanup.
if(this.menu){
this.menu.destroyRecursive();
delete this.menu;
}
this.inherited(arguments);
},
_initButton: function(){
this.inherited(arguments);
if(this.commandName=="tableContextMenu"){ this.button.domNode.display = "none";}
},
_createContextMenu: function(){
// summary
// Building context menu for right-click shortcuts within a table
//
var pMenu = new dijit.Menu({targetNodeIds:[this.editor.iframe]});
var messages = dojo.i18n.getLocalization("dojox.editor.plugins", "TableDialog", this.lang);
pMenu.addChild(new dijit.MenuItem({label: messages.selectTableLabel, onClick: dojo.hitch(this, "selectTable")}));
pMenu.addChild(new dijit.MenuSeparator());
pMenu.addChild(new dijit.MenuItem({label: messages.insertTableRowBeforeLabel, onClick: dojo.hitch(this, "modTable", "insertTableRowBefore" )}));
pMenu.addChild(new dijit.MenuItem({label: messages.insertTableRowAfterLabel, onClick: dojo.hitch(this, "modTable", "insertTableRowAfter" )}));
pMenu.addChild(new dijit.MenuItem({label: messages.insertTableColumnBeforeLabel, onClick: dojo.hitch(this, "modTable", "insertTableColumnBefore" )}));
pMenu.addChild(new dijit.MenuItem({label: messages.insertTableColumnAfterLabel, onClick: dojo.hitch(this, "modTable", "insertTableColumnAfter" )}));
pMenu.addChild(new dijit.MenuSeparator());
pMenu.addChild(new dijit.MenuItem({label: messages.deleteTableRowLabel, onClick: dojo.hitch(this, "modTable", "deleteTableRow" )}));
pMenu.addChild(new dijit.MenuItem({label: messages.deleteTableColumnLabel, onClick: dojo.hitch(this, "modTable", "deleteTableColumn" )}));
this.menu = pMenu;
}
});
dojo.declare("dojox.editor.plugins.InsertTable",
dojox.editor.plugins.TablePlugins,
{
alwaysAvailable: true,
modTable: function(){
var w = new dojox.editor.plugins.EditorTableDialog({});
w.show();
var c = dojo.connect(w, "onBuildTable", this, function(obj){
dojo.disconnect(c);
var res = this.editor.execCommand('inserthtml', obj.htmlText);
// commenting this line, due to msg below
//var td = this.editor.query("td", this.editor.byId(obj.id));
//HMMMM.... This throws a security error now. didn't used to.
//this.editor.selectElement(td);
});
}
});
dojo.declare("dojox.editor.plugins.ModifyTable",
dojox.editor.plugins.TablePlugins,
{
modTable: function(){
if (!this.editor._tablePluginHandler.checkAvailable()) {return;}
var o = this.getTableInfo();
//console.log("LAUNCH DIALOG");
var w = new dojox.editor.plugins.EditorModifyTableDialog({table:o.tbl});
w.show();
this.connect(w, "onSetTable", function(color){
// uhm... not sure whats going on here...
var o = this.getTableInfo();
//console.log("set color:", color);
dojo.attr(o.td, "bgcolor", color);
});
}
});
dojo.declare("dojox.editor.plugins._CellColorDropDown", [dijit._Widget, dijit._Templated], {
// summary:
// A smple widget that uses/creates a dropdown with a dojox.widget.ColorPicker. Also provides
// passthroughs to the value of the color picker and convenient hook points.
// tags:
// private
// templateString: String
// The template used to create the ColorPicker.
templateString:
"<div style='display: none; position: absolute; top: -10000; z-index: -10000'>" +
"<div dojoType='dijit.TooltipDialog' dojoAttachPoint='dialog' class='dojoxEditorColorPicker'>" +
"<div dojoType='dojox.widget.ColorPicker' dojoAttachPoint='_colorPicker'></div>" +
"<div style='margin: 0.5em 0em 0em 0em'>" +
"<button dojoType='dijit.form.Button' type='button' dojoAttachPoint='_setButton'>${buttonSet}</button>" +
" " +
"<button dojoType='dijit.form.Button' type='button' dojoAttachPoint='_cancelButton'>${buttonCancel}</button>" +
"</div>" +
"</div>" +
"</div>",
// widgetsInTemplate: Boolean
// Flag denoting widgets are contained in the template.
widgetsInTemplate: true,
constructor: function(){
// summary:
// Constructor over-ride so that the translated strings are mixsed in so
// the template fills out.
var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "TableDialog");
dojo.mixin(this, strings);
},
startup: function(){
// summary:
// Over-ride of startup to do the basic connect setups and such.
if(!this._started){
this.inherited(arguments);
this.connect(this._setButton, "onClick", function(){
this.onChange(this.get("value"));
});
this.connect(this._cancelButton, "onClick", function(){
dijit.popup.close(this.dialog);
this.onCancel();
});
// Fully statred, so go ahead and remove the hide.
dojo.style(this.domNode, "display", "block");
}
},
_setValueAttr: function(value, priorityChange){
// summary:
// Passthrough function for the color picker value.
// value: String
// The value to set in the color picker
// priorityChange:
// Value to indicate whether or not to trigger an onChange event.
this._colorPicker.set("value", value, priorityChange);
},
_getValueAttr: function(){
// summary:
// Passthrough function for the color picker value.
return this._colorPicker.get("value");
},
setColor: function(/*String*/ color){
this._colorPicker.setColor(color, false);
},
onChange: function(value){
// summary:
// Hook point to get the value when the color picker value is selected.
// value: String
// The value from the color picker.
},
onCancel: function(){
// summary:
// Hook point to get when the dialog is canceled.
}
});
dojo.declare("dojox.editor.plugins.ColorTableCell", dojox.editor.plugins.TablePlugins, {
constructor: function(){
// summary:
// Initialize ColorTableCell plugin
this.closable = true;
this.buttonClass = dijit.form.DropDownButton;
var picker = new dojox.editor.plugins._CellColorDropDown();
dojo.body().appendChild(picker.domNode);
picker.startup();
this.dropDown = picker.dialog;
this.connect(picker, "onChange", function(color){
this.modTable(null, color);
this.editor.focus();
});
this.connect(picker, "onCancel", function(color){
this.editor.focus();
});
this.connect(picker.dialog, "onOpen", function(){
var o = this.getTableInfo(),
tds = this.getSelectedCells(o.tbl);
if(tds && tds.length > 0){
var t = tds[0] == this.lastObject ? tds[0] : tds[tds.length - 1],
color;
while(t && ((color = dojo.style(t, "backgroundColor")) == "transparent" || color.indexOf("rgba") == 0)){
t = t.parentNode;
}
color = dojo.style(t, "backgroundColor");
if(color != "transparent" && color.indexOf("rgba") != 0){
picker.setColor(color);
}
}
});
this.connect(this, "setEditor", function(editor){
editor.onLoadDeferred.addCallback(dojo.hitch(this, function(){
this.connect(this.editor.editNode, "onmouseup", function(evt){
this.lastObject = evt.target;
});
}));
});
},
_initButton: function(){
this.command = this.commandName;
this.label = this.editor.commands[this.command] = this._makeTitle(this.command);
this.inherited(arguments);
delete this.command;
this.onDisplayChanged(false);
},
modTable: function(cmd, args){
// summary
// Where each plugin performs its action
// Note: not using execCommand. In spite of their presence in the
// Editor as query-able plugins, I was not able to find any evidence
// that they are supported (especially in NOT IE). If they are
// supported in other browsers, it may help with the undo problem.
//
this.begEdit();
var o = this.getTableInfo();
// The one plugin that really needs use of the very verbose
// getSelectedCells()
var tds = this.getSelectedCells(o.tbl);
//console.debug("SELECTED CELLS ", tds , " FOR ", o);
dojo.forEach(tds, function(td){
dojo.style(td, "backgroundColor", args);
});
this.endEdit();
}
});
dojo.declare("dojox.editor.plugins.EditorTableDialog", [dijit.Dialog], {
// summary:
// Dialog box with options for table creation
//
baseClass:"EditorTableDialog",
widgetsInTemplate:true,
templateString: dojo.cache("dojox.editor.plugins", "resources/insertTable.html", "<div class=\"dijitDialog\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"${id}_title\">\r\n\t<div dojoAttachPoint=\"titleBar\" class=\"dijitDialogTitleBar\">\r\n\t<span dojoAttachPoint=\"titleNode\" class=\"dijitDialogTitle\" id=\"${id}_title\">${insertTableTitle}</span>\r\n\t<span dojoAttachPoint=\"closeButtonNode\" class=\"dijitDialogCloseIcon\" dojoAttachEvent=\"onclick: onCancel\" title=\"${buttonCancel}\">\r\n\t\t<span dojoAttachPoint=\"closeText\" class=\"closeText\" title=\"${buttonCancel}\">x</span>\r\n\t</span>\r\n\t</div>\r\n <div dojoAttachPoint=\"containerNode\" class=\"dijitDialogPaneContent\">\r\n <table class=\"etdTable\"><tr>\r\n <td>\r\n <label>${rows}</label>\r\n\t\t\t</td><td>\r\n <span dojoAttachPoint=\"selectRow\" dojoType=\"dijit.form.TextBox\" value=\"2\"></span>\r\n </td><td><table><tr><td class=\"inner\">\r\n <label>${columns}</label>\r\n\t\t\t</td><td class=\"inner\">\r\n <span dojoAttachPoint=\"selectCol\" dojoType=\"dijit.form.TextBox\" value=\"2\"></span>\r\n </td></tr></table></td></tr>\t\t\r\n\t\t\t<tr><td>\r\n <label>${tableWidth}</label>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectWidth\" dojoType=\"dijit.form.TextBox\" value=\"100\"></span>\r\n\t\t\t</td><td>\r\n <select dojoAttachPoint=\"selectWidthType\" hasDownArrow=\"true\" dojoType=\"dijit.form.FilteringSelect\">\r\n <option value=\"percent\">${percent}</option>\r\n <option value=\"pixels\">${pixels}</option>\r\n </select></td></tr>\t\r\n <tr><td>\r\n <label>${borderThickness}</label></td>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectBorder\" dojoType=\"dijit.form.TextBox\" value=\"1\"></span>\r\n </td><td>\r\n ${pixels}\r\n </td></tr><tr><td>\r\n <label>${cellPadding}</label></td>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectPad\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\r\n </td><td class=\"cellpad\"></td></tr><tr><td>\r\n <label>${cellSpacing}</label>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectSpace\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\r\n </td><td class=\"cellspace\"></td></tr></table>\r\n <div class=\"dialogButtonContainer\">\r\n <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onInsert\">${buttonInsert}</div>\r\n <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onCancel\">${buttonCancel}</div>\r\n </div>\r\n\t</div>\r\n</div>\r\n"),
postMixInProperties: function(){
var messages = dojo.i18n.getLocalization("dojox.editor.plugins", "TableDialog", this.lang);
dojo.mixin(this, messages);
this.inherited(arguments);
},
postCreate: function(){
dojo.addClass(this.domNode, this.baseClass); //FIXME - why isn't Dialog accepting the baseClass?
this.inherited(arguments);
},
onInsert: function(){
console.log("insert");
var rows = this.selectRow.get("value") || 1,
cols = this.selectCol.get("value") || 1,
width = this.selectWidth.get("value"),
widthType = this.selectWidthType.get("value"),
border = this.selectBorder.get("value"),
pad = this.selectPad.get("value"),
space = this.selectSpace.get("value"),
_id = "tbl_"+(new Date().getTime()),
t = '<table id="'+_id+'"width="'+width+((widthType=="percent")?'%':'')+'" border="'+border+'" cellspacing="'+space+'" cellpadding="'+pad+'">\n';
for(var r=0;r<rows;r++){
t += '\t<tr>\n';
for(var c=0;c<cols;c++){
t += '\t\t<td width="'+(Math.floor(100/cols))+'%"> </td>\n';
}
t += '\t</tr>\n';
}
t += '</table>';
//console.log(t);
this.onBuildTable({htmlText:t, id:_id});
var cl = dojo.connect(this, "onHide", function(){
dojo.disconnect(cl);
var self = this;
setTimeout(function(){
self.destroyRecursive();
}, 10);
});
this.hide();
},
onCancel: function(){
// summary:
// Function to clean up memory so that the dialog is destroyed
// when closed.
var c = dojo.connect(this, "onHide", function(){
dojo.disconnect(c);
var self = this;
setTimeout(function(){
self.destroyRecursive();
}, 10);
});
},
onBuildTable: function(tableText){
//stub
}
});
dojo.declare("dojox.editor.plugins.EditorModifyTableDialog", [dijit.Dialog], {
// summary:
// Dialog box with options for editing a table
//
baseClass:"EditorTableDialog",
widgetsInTemplate:true,
table:null, //html table to be modified
tableAtts:{},
templateString: dojo.cache("dojox.editor.plugins", "resources/modifyTable.html", "<div class=\"dijitDialog\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"${id}_title\">\r\n\t<div dojoAttachPoint=\"titleBar\" class=\"dijitDialogTitleBar\">\r\n\t<span dojoAttachPoint=\"titleNode\" class=\"dijitDialogTitle\" id=\"${id}_title\">${modifyTableTitle}</span>\r\n\t<span dojoAttachPoint=\"closeButtonNode\" class=\"dijitDialogCloseIcon\" dojoAttachEvent=\"onclick: onCancel\" title=\"${buttonCancel}\">\r\n\t\t<span dojoAttachPoint=\"closeText\" class=\"closeText\" title=\"${buttonCancel}\">x</span>\r\n\t</span>\r\n\t</div>\r\n <div dojoAttachPoint=\"containerNode\" class=\"dijitDialogPaneContent\">\r\n <table class=\"etdTable\">\r\n <tr><td>\r\n <label>${backgroundColor}</label>\r\n </td><td colspan=\"2\">\r\n <span class=\"colorSwatchBtn\" dojoAttachPoint=\"backgroundCol\"></span>\r\n </td></tr><tr><td>\r\n <label>${borderColor}</label>\r\n </td><td colspan=\"2\">\r\n <span class=\"colorSwatchBtn\" dojoAttachPoint=\"borderCol\"></span>\r\n </td></tr><tr><td>\r\n <label>${align}</label>\r\n </td><td colspan=\"2\">\t\r\n <select dojoAttachPoint=\"selectAlign\" dojoType=\"dijit.form.FilteringSelect\">\r\n <option value=\"default\">${default}</option>\r\n <option value=\"left\">${left}</option>\r\n <option value=\"center\">${center}</option>\r\n <option value=\"right\">${right}</option>\r\n </select>\r\n </td></tr>\r\n <tr><td>\r\n <label>${tableWidth}</label>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectWidth\" dojoType=\"dijit.form.TextBox\" value=\"100\"></span>\r\n </td><td>\r\n <select dojoAttachPoint=\"selectWidthType\" hasDownArrow=\"true\" dojoType=\"dijit.form.FilteringSelect\">\r\n <option value=\"percent\">${percent}</option>\r\n <option value=\"pixels\">${pixels}</option>\r\n </select></td></tr>\t\r\n <tr><td>\r\n <label>${borderThickness}</label></td>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectBorder\" dojoType=\"dijit.form.TextBox\" value=\"1\"></span>\r\n </td><td>\r\n ${pixels}\r\n </td></tr><tr><td>\r\n <label>${cellPadding}</label></td>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectPad\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\r\n </td><td class=\"cellpad\"></td></tr><tr><td>\r\n <label>${cellSpacing}</label>\r\n </td><td>\r\n <span dojoAttachPoint=\"selectSpace\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\r\n </td><td class=\"cellspace\"></td></tr>\r\n </table>\r\n <div class=\"dialogButtonContainer\">\r\n <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onSet\">${buttonSet}</div>\r\n <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onCancel\">${buttonCancel}</div>\r\n </div>\r\n\t</div>\r\n</div>\r\n"),
postMixInProperties: function(){
var messages = dojo.i18n.getLocalization("dojox.editor.plugins", "TableDialog", this.lang);
dojo.mixin(this, messages);
this.inherited(arguments);
},
postCreate: function(){
dojo.addClass(this.domNode, this.baseClass); //FIXME - why isn't Dialog accepting the baseClass?
this.inherited(arguments);
this._cleanupWidgets = [];
var w1 = new dijit.ColorPalette({});
this.connect(w1, "onChange", function(color){
dijit.popup.close(w1);
this.setBrdColor(color);
});
this.connect(w1, "onBlur", function(){
dijit.popup.close(w1);
});
this.connect(this.borderCol, "click", function(){
dijit.popup.open({popup:w1, around:this.borderCol});
w1.focus();
});
var w2 = new dijit.ColorPalette({});
this.connect(w2, "onChange", function(color){
dijit.popup.close(w2);
this.setBkColor(color);
});
this.connect(w2, "onBlur", function(){
dijit.popup.close(w2);
});
this.connect(this.backgroundCol, "click", function(){
dijit.popup.open({popup:w2, around:this.backgroundCol});
w2.focus();
});
this._cleanupWidgets.push(w1);
this._cleanupWidgets.push(w2);
this.setBrdColor(dojo.attr(this.table, "bordercolor"));
this.setBkColor(dojo.attr(this.table, "bgcolor"));
var w = dojo.attr(this.table, "width");
if(!w){
w = this.table.style.width;
}
var p = "pixels";
if(dojo.isString(w) && w.indexOf("%")>-1){
p = "percent";
w = w.replace(/%/, "");
}
if(w){
this.selectWidth.set("value", w);
this.selectWidthType.set("value", p);
}else{
this.selectWidth.set("value", "");
this.selectWidthType.set("value", "percent");
}
this.selectBorder.set("value", dojo.attr(this.table, "border"));
this.selectPad.set("value", dojo.attr(this.table, "cellPadding"));
this.selectSpace.set("value", dojo.attr(this.table, "cellSpacing"));
this.selectAlign.set("value", dojo.attr(this.table, "align"));
},
setBrdColor: function(color){
this.brdColor = color;
dojo.style(this.borderCol, "backgroundColor", color);
},
setBkColor: function(color){
this.bkColor = color;
dojo.style(this.backgroundCol, "backgroundColor", color);
},
onSet: function(){
dojo.attr(this.table, "borderColor", this.brdColor);
dojo.attr(this.table, "bgColor", this.bkColor);
if(this.selectWidth.get("value")){
// Just in case, remove it from style since we're setting it as a table attribute.
dojo.style(this.table, "width", "");
dojo.attr(this.table, "width", (this.selectWidth.get("value") + ((this.selectWidthType.get("value")=="pixels")?"":"%") ));
}
dojo.attr(this.table, "border", this.selectBorder.get("value"));
dojo.attr(this.table, "cellPadding", this.selectPad.get("value"));
dojo.attr(this.table, "cellSpacing", this.selectSpace.get("value"));
dojo.attr(this.table, "align", this.selectAlign.get("value"));
var c = dojo.connect(this, "onHide", function(){
dojo.disconnect(c);
var self = this;
setTimeout(function(){
self.destroyRecursive();
}, 10);
});
this.hide();
},
onCancel: function(){
// summary:
// Function to clean up memory so that the dialog is destroyed
// when closed.
var c = dojo.connect(this, "onHide", function(){
dojo.disconnect(c);
var self = this;
setTimeout(function(){
self.destroyRecursive();
}, 10);
});
},
onSetTable: function(tableText){
//stub
},
destroy: function(){
// summary:
// Cleanup function.
this.inherited(arguments);
dojo.forEach(this._cleanupWidgets, function(w){
if(w && w.destroy){
w.destroy();
}
});
delete this._cleanupWidgets;
}
});
dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){
if(o.plugin){ return; }
// make first character lower case
if(o.args && o.args.command){
var cmd = o.args.command.charAt(0).toLowerCase()+o.args.command.substring(1,o.args.command.length);
switch(cmd){
case "insertTableRowBefore":
case "insertTableRowAfter":
case "insertTableColumnBefore":
case "insertTableColumnAfter":
case "deleteTableRow":
case "deleteTableColumn":
o.plugin = new dojox.editor.plugins.TablePlugins({commandName: cmd});
break;
case "colorTableCell":
o.plugin = new dojox.editor.plugins.ColorTableCell({commandName: cmd});
break;
case "modifyTable":
o.plugin = new dojox.editor.plugins.ModifyTable({commandName: cmd});
break;
case "insertTable":
o.plugin = new dojox.editor.plugins.InsertTable({commandName: cmd});
break;
case "tableContextMenu":
o.plugin = new dojox.editor.plugins.TableContextMenu({commandName: cmd});
break;
}
}
});
}
}};});
|