Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / editor / plugins / TablePlugins.js

History | View | Annotate | Download (24.3 KB)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.editor.plugins.TablePlugins"]){
9
dojo._hasResource["dojox.editor.plugins.TablePlugins"]=true;
10
dojo.provide("dojox.editor.plugins.TablePlugins");
11
dojo.require("dijit._editor._Plugin");
12
dojo.require("dijit._editor.selection");
13
dojo.require("dijit.Menu");
14
dojo.require("dojo.i18n");
15
dojo.requireLocalization("dojox.editor.plugins","TableDialog",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
16
dojo.experimental("dojox.editor.plugins.TablePlugins");
17
dojo.declare("dojox.editor.plugins._TableHandler",dijit._editor._Plugin,{tablesConnected:false,currentlyAvailable:false,alwaysAvailable:false,availableCurrentlySet:false,initialized:false,tableData:null,shiftKeyDown:false,editorDomNode:null,undoEnabled:true,refCount:0,doMixins:function(){
18
dojo.mixin(this.editor,{getAncestorElement:function(_1){
19
return dojo.withGlobal(this.window,"getAncestorElement",dijit._editor.selection,[_1]);
20
},hasAncestorElement:function(_2){
21
return dojo.withGlobal(this.window,"hasAncestorElement",dijit._editor.selection,[_2]);
22
},selectElement:function(_3){
23
dojo.withGlobal(this.window,"selectElement",dijit._editor.selection,[_3]);
24
},byId:function(id){
25
return dojo.withGlobal(this.window,"byId",dojo,[id]);
26
},query:function(_4,_5,_6){
27
var ar=dojo.withGlobal(this.window,"query",dojo,[_4,_5]);
28
return (_6)?ar[0]:ar;
29
}});
30
},initialize:function(_7){
31
this.refCount++;
32
_7.customUndo=true;
33
if(this.initialized){
34
return;
35
}
36
this.initialized=true;
37
this.editor=_7;
38
this.editor._tablePluginHandler=this;
39
_7.onLoadDeferred.addCallback(dojo.hitch(this,function(){
40
this.editorDomNode=this.editor.editNode||this.editor.iframe.document.body.firstChild;
41
this._myListeners=[];
42
this._myListeners.push(dojo.connect(this.editorDomNode,"mouseup",this.editor,"onClick"));
43
this._myListeners.push(dojo.connect(this.editor,"onDisplayChanged",this,"checkAvailable"));
44
this._myListeners.push(dojo.connect(this.editor,"onBlur",this,"checkAvailable"));
45
this.doMixins();
46
this.connectDraggable();
47
}));
48
},getTableInfo:function(_8){
49
if(_8){
50
this._tempStoreTableData(false);
51
}
52
if(this.tableData){
53
return this.tableData;
54
}
55
var tr,_9,td,_a,_b,_c,_d,_e;
56
td=this.editor.getAncestorElement("td");
57
if(td){
58
tr=td.parentNode;
59
}
60
_b=this.editor.getAncestorElement("table");
61
_a=dojo.query("td",_b);
62
_a.forEach(function(d,i){
63
if(td==d){
64
_d=i;
65
}
66
});
67
_9=dojo.query("tr",_b);
68
_9.forEach(function(r,i){
69
if(tr==r){
70
_e=i;
71
}
72
});
73
_c=_a.length/_9.length;
74
var o={tbl:_b,td:td,tr:tr,trs:_9,tds:_a,rows:_9.length,cols:_c,tdIndex:_d,trIndex:_e,colIndex:_d%_c};
75
this.tableData=o;
76
this._tempStoreTableData(500);
77
return this.tableData;
78
},connectDraggable:function(){
79
if(!dojo.isIE){
80
return;
81
}
82
this.editorDomNode.ondragstart=dojo.hitch(this,"onDragStart");
83
this.editorDomNode.ondragend=dojo.hitch(this,"onDragEnd");
84
},onDragStart:function(){
85
var e=window.event;
86
if(!e.srcElement.id){
87
e.srcElement.id="tbl_"+(new Date().getTime());
88
}
89
},onDragEnd:function(){
90
var e=window.event;
91
var _f=e.srcElement;
92
var id=_f.id;
93
var win=this.editor.window;
94
if(_f.tagName.toLowerCase()=="table"){
95
setTimeout(function(){
96
var _10=dojo.withGlobal(win,"byId",dojo,[id]);
97
dojo.removeAttr(_10,"align");
98
},100);
99
}
100
},checkAvailable:function(){
101
if(this.availableCurrentlySet){
102
return this.currentlyAvailable;
103
}
104
if(!this.editor){
105
return false;
106
}
107
if(this.alwaysAvailable){
108
return true;
109
}
110
this.currentlyAvailable=this.editor._focused?this.editor.hasAncestorElement("table"):false;
111
if(this.currentlyAvailable){
112
this.connectTableKeys();
113
}else{
114
this.disconnectTableKeys();
115
}
116
this._tempAvailability(500);
117
dojo.publish(this.editor.id+"_tablePlugins",[this.currentlyAvailable]);
118
return this.currentlyAvailable;
119
},_prepareTable:function(tbl){
120
var tds=this.editor.query("td",tbl);
121
if(!tds[0].id){
122
tds.forEach(function(td,i){
123
if(!td.id){
124
td.id="tdid"+i+this.getTimeStamp();
125
}
126
},this);
127
}
128
return tds;
129
},getTimeStamp:function(){
130
return Math.floor(new Date().getTime()*1e-8);
131
},_tempStoreTableData:function(_11){
132
if(_11===true){
133
}else{
134
if(_11===false){
135
this.tableData=null;
136
}else{
137
if(_11===undefined){
138
console.warn("_tempStoreTableData must be passed an argument");
139
}else{
140
setTimeout(dojo.hitch(this,function(){
141
this.tableData=null;
142
}),_11);
143
}
144
}
145
}
146
},_tempAvailability:function(_12){
147
if(_12===true){
148
this.availableCurrentlySet=true;
149
}else{
150
if(_12===false){
151
this.availableCurrentlySet=false;
152
}else{
153
if(_12===undefined){
154
console.warn("_tempAvailability must be passed an argument");
155
}else{
156
this.availableCurrentlySet=true;
157
setTimeout(dojo.hitch(this,function(){
158
this.availableCurrentlySet=false;
159
}),_12);
160
}
161
}
162
}
163
},connectTableKeys:function(){
164
if(this.tablesConnected){
165
return;
166
}
167
this.tablesConnected=true;
168
var _13=(this.editor.iframe)?this.editor.document:this.editor.editNode;
169
this.cnKeyDn=dojo.connect(_13,"onkeydown",this,"onKeyDown");
170
this.cnKeyUp=dojo.connect(_13,"onkeyup",this,"onKeyUp");
171
this._myListeners.push(dojo.connect(_13,"onkeypress",this,"onKeyUp"));
172
},disconnectTableKeys:function(){
173
dojo.disconnect(this.cnKeyDn);
174
dojo.disconnect(this.cnKeyUp);
175
this.tablesConnected=false;
176
},onKeyDown:function(evt){
177
var key=evt.keyCode;
178
if(key==16){
179
this.shiftKeyDown=true;
180
}
181
if(key==9){
182
var o=this.getTableInfo();
183
o.tdIndex=(this.shiftKeyDown)?o.tdIndex-1:tabTo=o.tdIndex+1;
184
if(o.tdIndex>=0&&o.tdIndex<o.tds.length){
185
this.editor.selectElement(o.tds[o.tdIndex]);
186
this.currentlyAvailable=true;
187
this._tempAvailability(true);
188
this._tempStoreTableData(true);
189
this.stopEvent=true;
190
}else{
191
this.stopEvent=false;
192
this.onDisplayChanged();
193
}
194
if(this.stopEvent){
195
dojo.stopEvent(evt);
196
}
197
}
198
},onKeyUp:function(evt){
199
var key=evt.keyCode;
200
if(key==16){
201
this.shiftKeyDown=false;
202
}
203
if(key==37||key==38||key==39||key==40){
204
this.onDisplayChanged();
205
}
206
if(key==9&&this.stopEvent){
207
dojo.stopEvent(evt);
208
}
209
},onDisplayChanged:function(){
210
this.currentlyAvailable=false;
211
this._tempStoreTableData(false);
212
this._tempAvailability(false);
213
this.checkAvailable();
214
},uninitialize:function(_14){
215
if(this.editor==_14){
216
this.refCount--;
217
if(!this.refCount&&this.initialized){
218
if(this.tablesConnected){
219
this.disconnectTableKeys();
220
}
221
this.initialized=false;
222
dojo.forEach(this._myListeners,function(l){
223
dojo.disconnect(l);
224
});
225
delete this._myListeners;
226
delete this.editor._tablePluginHandler;
227
delete this.editor;
228
}
229
this.inherited(arguments);
230
}
231
}});
232
dojo.declare("dojox.editor.plugins.TablePlugins",dijit._editor._Plugin,{iconClassPrefix:"editorIcon",useDefaultCommand:false,buttonClass:dijit.form.Button,commandName:"",label:"",alwaysAvailable:false,undoEnabled:true,onDisplayChanged:function(_15){
233
if(!this.alwaysAvailable){
234
this.available=_15;
235
this.button.set("disabled",!this.available);
236
}
237
},setEditor:function(_16){
238
this.editor=_16;
239
this.editor.customUndo=true;
240
this.inherited(arguments);
241
this._availableTopic=dojo.subscribe(this.editor.id+"_tablePlugins",this,"onDisplayChanged");
242
this.onEditorLoaded();
243
},onEditorLoaded:function(){
244
if(!this.editor._tablePluginHandler){
245
var _17=new dojox.editor.plugins._TableHandler();
246
_17.initialize(this.editor);
247
}else{
248
this.editor._tablePluginHandler.initialize(this.editor);
249
}
250
},selectTable:function(){
251
var o=this.getTableInfo();
252
if(o&&o.tbl){
253
dojo.withGlobal(this.editor.window,"selectElement",dijit._editor.selection,[o.tbl]);
254
}
255
},_initButton:function(){
256
this.command=this.commandName;
257
this.label=this.editor.commands[this.command]=this._makeTitle(this.command);
258
this.inherited(arguments);
259
delete this.command;
260
this.connect(this.button,"onClick","modTable");
261
this.onDisplayChanged(false);
262
},modTable:function(cmd,_18){
263
this.begEdit();
264
var o=this.getTableInfo();
265
var sw=(dojo.isString(cmd))?cmd:this.commandName;
266
var r,c,i;
267
var _19=false;
268
if(dojo.isIE){
269
this.editor.focus();
270
}
271
switch(sw){
272
case "insertTableRowBefore":
273
r=o.tbl.insertRow(o.trIndex);
274
for(i=0;i<o.cols;i++){
275
c=r.insertCell(-1);
276
c.innerHTML="&nbsp;";
277
}
278
break;
279
case "insertTableRowAfter":
280
r=o.tbl.insertRow(o.trIndex+1);
281
for(i=0;i<o.cols;i++){
282
c=r.insertCell(-1);
283
c.innerHTML="&nbsp;";
284
}
285
break;
286
case "insertTableColumnBefore":
287
o.trs.forEach(function(r){
288
c=r.insertCell(o.colIndex);
289
c.innerHTML="&nbsp;";
290
});
291
_19=true;
292
break;
293
case "insertTableColumnAfter":
294
o.trs.forEach(function(r){
295
c=r.insertCell(o.colIndex+1);
296
c.innerHTML="&nbsp;";
297
});
298
_19=true;
299
break;
300
case "deleteTableRow":
301
o.tbl.deleteRow(o.trIndex);
302
break;
303
case "deleteTableColumn":
304
o.trs.forEach(function(tr){
305
tr.deleteCell(o.colIndex);
306
});
307
_19=true;
308
break;
309
case "modifyTable":
310
break;
311
case "insertTable":
312
break;
313
}
314
if(_19){
315
this.makeColumnsEven();
316
}
317
this.endEdit();
318
},begEdit:function(){
319
if(this.editor._tablePluginHandler.undoEnabled){
320
if(this.editor.customUndo){
321
this.editor.beginEditing();
322
}else{
323
this.valBeforeUndo=this.editor.getValue();
324
}
325
}
326
},endEdit:function(){
327
if(this.editor._tablePluginHandler.undoEnabled){
328
if(this.editor.customUndo){
329
this.editor.endEditing();
330
}else{
331
var _1a=this.editor.getValue();
332
this.editor.setValue(this.valBeforeUndo);
333
this.editor.replaceValue(_1a);
334
}
335
this.editor.onDisplayChanged();
336
}
337
},makeColumnsEven:function(){
338
setTimeout(dojo.hitch(this,function(){
339
var o=this.getTableInfo(true);
340
var w=Math.floor(100/o.cols);
341
o.tds.forEach(function(d){
342
dojo.attr(d,"width",w+"%");
343
});
344
}),10);
345
},getTableInfo:function(_1b){
346
return this.editor._tablePluginHandler.getTableInfo(_1b);
347
},_makeTitle:function(str){
348
var ns=[];
349
dojo.forEach(str,function(c,i){
350
if(c.charCodeAt(0)<91&&i>0&&ns[i-1].charCodeAt(0)!=32){
351
ns.push(" ");
352
}
353
if(i===0){
354
c=c.toUpperCase();
355
}
356
ns.push(c);
357
});
358
return ns.join("");
359
},getSelectedCells:function(){
360
var _1c=[];
361
var tbl=this.getTableInfo().tbl;
362
this.editor._tablePluginHandler._prepareTable(tbl);
363
var e=this.editor;
364
var _1d=dojo.withGlobal(e.window,"getSelectedHtml",dijit._editor.selection,[null]);
365
var str=_1d.match(/id="*\w*"*/g);
366
dojo.forEach(str,function(a){
367
var id=a.substring(3,a.length);
368
if(id.charAt(0)=="\""&&id.charAt(id.length-1)=="\""){
369
id=id.substring(1,id.length-1);
370
}
371
var _1e=e.byId(id);
372
if(_1e&&_1e.tagName.toLowerCase()=="td"){
373
_1c.push(_1e);
374
}
375
},this);
376
if(!_1c.length){
377
var sel=dijit.range.getSelection(e.window);
378
if(sel.rangeCount){
379
var r=sel.getRangeAt(0);
380
var _1f=r.startContainer;
381
while(_1f&&_1f!=e.editNode&&_1f!=e.document){
382
if(_1f.nodeType===1){
383
var tg=_1f.tagName?_1f.tagName.toLowerCase():"";
384
if(tg==="td"){
385
return [_1f];
386
}
387
}
388
_1f=_1f.parentNode;
389
}
390
}
391
}
392
return _1c;
393
},destroy:function(){
394
this.inherited(arguments);
395
dojo.unsubscribe(this._availableTopic);
396
this.editor._tablePluginHandler.uninitialize(this.editor);
397
}});
398
dojo.declare("dojox.editor.plugins.TableContextMenu",dojox.editor.plugins.TablePlugins,{constructor:function(){
399
this.connect(this,"setEditor",function(_20){
400
_20.onLoadDeferred.addCallback(dojo.hitch(this,function(){
401
this._createContextMenu();
402
}));
403
this.button.domNode.style.display="none";
404
});
405
},_initButton:function(){
406
this.inherited(arguments);
407
if(this.commandName=="tableContextMenu"){
408
this.button.domNode.display="none";
409
}
410
},_createContextMenu:function(){
411
var _21=new dijit.Menu({targetNodeIds:[this.editor.iframe]});
412
var _22=dojo.i18n.getLocalization("dojox.editor.plugins","TableDialog",this.lang);
413
_21.addChild(new dijit.MenuItem({label:_22.selectTableLabel,onClick:dojo.hitch(this,"selectTable")}));
414
_21.addChild(new dijit.MenuSeparator());
415
_21.addChild(new dijit.MenuItem({label:_22.insertTableRowBeforeLabel,onClick:dojo.hitch(this,"modTable","insertTableRowBefore")}));
416
_21.addChild(new dijit.MenuItem({label:_22.insertTableRowAfterLabel,onClick:dojo.hitch(this,"modTable","insertTableRowAfter")}));
417
_21.addChild(new dijit.MenuItem({label:_22.insertTableColumnBeforeLabel,onClick:dojo.hitch(this,"modTable","insertTableColumnBefore")}));
418
_21.addChild(new dijit.MenuItem({label:_22.insertTableColumnAfterLabel,onClick:dojo.hitch(this,"modTable","insertTableColumnAfter")}));
419
_21.addChild(new dijit.MenuSeparator());
420
_21.addChild(new dijit.MenuItem({label:_22.deleteTableRowLabel,onClick:dojo.hitch(this,"modTable","deleteTableRow")}));
421
_21.addChild(new dijit.MenuItem({label:_22.deleteTableColumnLabel,onClick:dojo.hitch(this,"modTable","deleteTableColumn")}));
422
this.menu=_21;
423
}});
424
dojo.declare("dojox.editor.plugins.InsertTable",dojox.editor.plugins.TablePlugins,{alwaysAvailable:true,modTable:function(){
425
var w=new dojox.editor.plugins.EditorTableDialog({});
426
w.show();
427
var c=dojo.connect(w,"onBuildTable",this,function(obj){
428
dojo.disconnect(c);
429
var res=this.editor.execCommand("inserthtml",obj.htmlText);
430
});
431
}});
432
dojo.declare("dojox.editor.plugins.ModifyTable",dojox.editor.plugins.TablePlugins,{modTable:function(){
433
if(!this.editor._tablePluginHandler.checkAvailable()){
434
return;
435
}
436
var o=this.getTableInfo();
437
var w=new dojox.editor.plugins.EditorModifyTableDialog({table:o.tbl});
438
w.show();
439
this.connect(w,"onSetTable",function(_23){
440
var o=this.getTableInfo();
441
dojo.attr(o.td,"bgcolor",_23);
442
});
443
}});
444
dojo.declare("dojox.editor.plugins.ColorTableCell",dojox.editor.plugins.TablePlugins,{constructor:function(){
445
this.buttonClass=dijit.form.DropDownButton;
446
this.dropDown=new dijit.ColorPalette();
447
this.connect(this.dropDown,"onChange",function(_24){
448
this.modTable(null,_24);
449
});
450
},_initButton:function(){
451
this.command=this.commandName;
452
this.label=this.editor.commands[this.command]=this._makeTitle(this.command);
453
this.inherited(arguments);
454
delete this.command;
455
this.onDisplayChanged(false);
456
},modTable:function(cmd,_25){
457
this.begEdit();
458
var o=this.getTableInfo();
459
var tds=this.getSelectedCells(o.tbl);
460
dojo.forEach(tds,function(td){
461
dojo.style(td,"backgroundColor",_25);
462
});
463
this.endEdit();
464
}});
465
dojo.provide("dojox.editor.plugins.EditorTableDialog");
466
dojo.require("dijit.Dialog");
467
dojo.require("dijit.form.TextBox");
468
dojo.require("dijit.form.FilteringSelect");
469
dojo.require("dijit.form.Button");
470
dojo.declare("dojox.editor.plugins.EditorTableDialog",[dijit.Dialog],{baseClass:"EditorTableDialog",widgetsInTemplate:true,templateString:dojo.cache("dojox.editor.plugins","resources/insertTable.html","<div class=\"dijitDialog\" tabindex=\"-1\" waiRole=\"dialog\" waiState=\"labelledby-${id}_title\">\n\t<div dojoAttachPoint=\"titleBar\" class=\"dijitDialogTitleBar\">\n\t<span dojoAttachPoint=\"titleNode\" class=\"dijitDialogTitle\" id=\"${id}_title\">${insertTableTitle}</span>\n\t<span dojoAttachPoint=\"closeButtonNode\" class=\"dijitDialogCloseIcon\" dojoAttachEvent=\"onclick: onCancel\" title=\"${buttonCancel}\">\n\t\t<span dojoAttachPoint=\"closeText\" class=\"closeText\" title=\"${buttonCancel}\">x</span>\n\t</span>\n\t</div>\n    <div dojoAttachPoint=\"containerNode\" class=\"dijitDialogPaneContent\">\n        <table class=\"etdTable\"><tr>\n            <td class=\"left\">\n                <span dojoAttachPoint=\"selectRow\" dojoType=\"dijit.form.TextBox\" value=\"2\"></span>\n                <label>${rows}</label>\n            </td><td class=\"right\">\n                <span dojoAttachPoint=\"selectCol\" dojoType=\"dijit.form.TextBox\" value=\"2\"></span>\n                <label>${columns}</label>\n            </td></tr><tr><td>\n                <span dojoAttachPoint=\"selectWidth\" dojoType=\"dijit.form.TextBox\" value=\"100\"></span>\n                <label>${tableWidth}</label>\n            </td><td>\n                <select dojoAttachPoint=\"selectWidthType\" hasDownArrow=\"true\" dojoType=\"dijit.form.FilteringSelect\">\n                  <option value=\"percent\">${percent}</option>\n                  <option value=\"pixels\">${pixels}</option>\n                </select></td></tr>\n          <tr><td>\n                <span dojoAttachPoint=\"selectBorder\" dojoType=\"dijit.form.TextBox\" value=\"1\"></span>\n                <label>${borderThickness}</label></td>\n            <td>\n                ${pixels}\n            </td></tr><tr><td>\n                <span dojoAttachPoint=\"selectPad\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\n                <label>${cellPadding}</label></td>\n            <td class=\"cellpad\"></td></tr><tr><td>\n                <span dojoAttachPoint=\"selectSpace\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\n                <label>${cellSpacing}</label>\n            </td><td class=\"cellspace\"></td></tr></table>\n        <div class=\"dialogButtonContainer\">\n            <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onInsert\">${buttonInsert}</div>\n            <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onCancel\">${buttonCancel}</div>\n        </div>\n\t</div>\n</div>\n"),postMixInProperties:function(){
471
var _26=dojo.i18n.getLocalization("dojox.editor.plugins","TableDialog",this.lang);
472
dojo.mixin(this,_26);
473
this.inherited(arguments);
474
},postCreate:function(){
475
dojo.addClass(this.domNode,this.baseClass);
476
this.inherited(arguments);
477
},onInsert:function(){
478
var _27=this.selectRow.get("value")||1,_28=this.selectCol.get("value")||1,_29=this.selectWidth.get("value"),_2a=this.selectWidthType.get("value"),_2b=this.selectBorder.get("value"),pad=this.selectPad.get("value"),_2c=this.selectSpace.get("value"),_2d="tbl_"+(new Date().getTime()),t="<table id=\""+_2d+"\"width=\""+_29+((_2a=="percent")?"%":"")+"\" border=\""+_2b+"\" cellspacing=\""+_2c+"\" cellpadding=\""+pad+"\">\n";
479
for(var r=0;r<_27;r++){
480
t+="\t<tr>\n";
481
for(var c=0;c<_28;c++){
482
t+="\t\t<td width=\""+(Math.floor(100/_28))+"%\">&nbsp;</td>\n";
483
}
484
t+="\t</tr>\n";
485
}
486
t+="</table>";
487
this.onBuildTable({htmlText:t,id:_2d});
488
var cl=dojo.connect(this,"onHide",function(){
489
dojo.disconnect(cl);
490
var _2e=this;
491
setTimeout(function(){
492
_2e.destroyRecursive();
493
},10);
494
});
495
this.hide();
496
},onCancel:function(){
497
var c=dojo.connect(this,"onHide",function(){
498
dojo.disconnect(c);
499
var _2f=this;
500
setTimeout(function(){
501
_2f.destroyRecursive();
502
},10);
503
});
504
},onBuildTable:function(_30){
505
}});
506
dojo.provide("dojox.editor.plugins.EditorModifyTableDialog");
507
dojo.require("dijit.ColorPalette");
508
dojo.declare("dojox.editor.plugins.EditorModifyTableDialog",[dijit.Dialog],{baseClass:"EditorTableDialog",widgetsInTemplate:true,table:null,tableAtts:{},templateString:dojo.cache("dojox.editor.plugins","resources/modifyTable.html","<div class=\"dijitDialog\" tabindex=\"-1\" waiRole=\"dialog\" waiState=\"labelledby-${id}_title\">\n\t<div dojoAttachPoint=\"titleBar\" class=\"dijitDialogTitleBar\">\n\t<span dojoAttachPoint=\"titleNode\" class=\"dijitDialogTitle\" id=\"${id}_title\">${modifyTableTitle}</span>\n\t<span dojoAttachPoint=\"closeButtonNode\" class=\"dijitDialogCloseIcon\" dojoAttachEvent=\"onclick: onCancel\" title=\"${buttonCancel}\">\n\t\t<span dojoAttachPoint=\"closeText\" class=\"closeText\" title=\"${buttonCancel}\">x</span>\n\t</span>\n\t</div>\n    <div dojoAttachPoint=\"containerNode\" class=\"dijitDialogPaneContent\">\n        <table class=\"etdTable\">\n          <tr><td class=\"left\">\n                <span class=\"colorSwatchBtn\" dojoAttachPoint=\"backgroundCol\"></span>\n                <label>${backgroundColor}</label>\n            </td><td class=\"right\">\n                <span class=\"colorSwatchBtn\" dojoAttachPoint=\"borderCol\"></span>\n                <label>${borderColor}</label>\n            </td></tr><tr><td>\n                <span dojoAttachPoint=\"selectBorder\" dojoType=\"dijit.form.TextBox\" value=\"1\"></span>\n                <label>${borderThickness}</label>\n            </td><td>\n            ${pixels}\n            </td></tr><tr><td>\n                <select class=\"floatDijit\" dojoAttachPoint=\"selectAlign\" dojoType=\"dijit.form.FilteringSelect\">\n                  <option value=\"default\">${default}</option>\n                  <option value=\"left\">${left}</option>\n                  <option value=\"center\">${center}</option>\n                  <option value=\"right\">${right}</option>\n                </select>\n                <label>${align}</label>\n            </td><td></td></tr><tr><td>\n                <span dojoAttachPoint=\"selectWidth\" dojoType=\"dijit.form.TextBox\" value=\"100\"></span>\n                <label>${tableWidth}</label>\n            </td><td>\n                <select dojoAttachPoint=\"selectWidthType\" hasDownArrow=\"true\" dojoType=\"dijit.form.FilteringSelect\">\n                  <option value=\"percent\">${percent}</option>\n                  <option value=\"pixels\">${pixels}</option>\n                </select>\n                </td></tr><tr><td>\n                <span dojoAttachPoint=\"selectPad\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\n                <label>${cellPadding}</label></td>\n            <td class=\"cellpad\"></td></tr><tr><td>\n                <span dojoAttachPoint=\"selectSpace\" dojoType=\"dijit.form.TextBox\" value=\"0\"></span>\n                <label>${cellSpacing}</label>\n            </td><td class=\"cellspace\"></td></tr>\n        </table>\n        <div class=\"dialogButtonContainer\">\n            <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onSet\">${buttonSet}</div>\n            <div dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick: onCancel\">${buttonCancel}</div>\n        </div>\n\t</div>\n</div>\n"),postMixInProperties:function(){
509
var _31=dojo.i18n.getLocalization("dojox.editor.plugins","TableDialog",this.lang);
510
dojo.mixin(this,_31);
511
this.inherited(arguments);
512
},postCreate:function(){
513
dojo.addClass(this.domNode,this.baseClass);
514
this.inherited(arguments);
515
this._cleanupWidgets=[];
516
var w1=new dijit.ColorPalette({});
517
this.connect(w1,"onChange",function(_32){
518
dijit.popup.close(w1);
519
this.setBrdColor(_32);
520
});
521
this.connect(w1,"onBlur",function(){
522
dijit.popup.close(w1);
523
});
524
this.connect(this.borderCol,"click",function(){
525
dijit.popup.open({popup:w1,around:this.borderCol});
526
w1.focus();
527
});
528
var w2=new dijit.ColorPalette({});
529
this.connect(w2,"onChange",function(_33){
530
dijit.popup.close(w2);
531
this.setBkColor(_33);
532
});
533
this.connect(w2,"onBlur",function(){
534
dijit.popup.close(w2);
535
});
536
this.connect(this.backgroundCol,"click",function(){
537
dijit.popup.open({popup:w2,around:this.backgroundCol});
538
w2.focus();
539
});
540
this._cleanupWidgets.push(w1);
541
this._cleanupWidgets.push(w2);
542
this.setBrdColor(dojo.attr(this.table,"bordercolor"));
543
this.setBkColor(dojo.attr(this.table,"bgcolor"));
544
var w=dojo.attr(this.table,"width");
545
if(!w){
546
w=this.table.style.width;
547
}
548
var p="pixels";
549
if(dojo.isString(w)&&w.indexOf("%")>-1){
550
p="percent";
551
w=w.replace(/%/,"");
552
}
553
if(w){
554
this.selectWidth.set("value",w);
555
this.selectWidthType.set("value",p);
556
}else{
557
this.selectWidth.set("value","");
558
this.selectWidthType.set("value","percent");
559
}
560
this.selectBorder.set("value",dojo.attr(this.table,"border"));
561
this.selectPad.set("value",dojo.attr(this.table,"cellPadding"));
562
this.selectSpace.set("value",dojo.attr(this.table,"cellSpacing"));
563
this.selectAlign.set("value",dojo.attr(this.table,"align"));
564
},setBrdColor:function(_34){
565
this.brdColor=_34;
566
dojo.style(this.borderCol,"backgroundColor",_34);
567
},setBkColor:function(_35){
568
this.bkColor=_35;
569
dojo.style(this.backgroundCol,"backgroundColor",_35);
570
},onSet:function(){
571
dojo.attr(this.table,"borderColor",this.brdColor);
572
dojo.attr(this.table,"bgColor",this.bkColor);
573
if(this.selectWidth.get("value")){
574
dojo.style(this.table,"width","");
575
dojo.attr(this.table,"width",(this.selectWidth.get("value")+((this.selectWidthType.get("value")=="pixels")?"":"%")));
576
}
577
dojo.attr(this.table,"border",this.selectBorder.get("value"));
578
dojo.attr(this.table,"cellPadding",this.selectPad.get("value"));
579
dojo.attr(this.table,"cellSpacing",this.selectSpace.get("value"));
580
dojo.attr(this.table,"align",this.selectAlign.get("value"));
581
var c=dojo.connect(this,"onHide",function(){
582
dojo.disconnect(c);
583
var _36=this;
584
setTimeout(function(){
585
_36.destroyRecursive();
586
},10);
587
});
588
this.hide();
589
},onCancel:function(){
590
var c=dojo.connect(this,"onHide",function(){
591
dojo.disconnect(c);
592
var _37=this;
593
setTimeout(function(){
594
_37.destroyRecursive();
595
},10);
596
});
597
},onSetTable:function(_38){
598
},destroy:function(){
599
this.inherited(arguments);
600
dojo.forEach(this._cleanupWidgets,function(w){
601
if(w&&w.destroy){
602
w.destroy();
603
}
604
});
605
delete this._cleanupWidgets;
606
}});
607
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
608
if(o.plugin){
609
return;
610
}
611
if(o.args&&o.args.command){
612
var cmd=o.args.command.charAt(0).toLowerCase()+o.args.command.substring(1,o.args.command.length);
613
switch(cmd){
614
case "insertTableRowBefore":
615
case "insertTableRowAfter":
616
case "insertTableColumnBefore":
617
case "insertTableColumnAfter":
618
case "deleteTableRow":
619
case "deleteTableColumn":
620
o.plugin=new dojox.editor.plugins.TablePlugins({commandName:cmd});
621
break;
622
case "colorTableCell":
623
o.plugin=new dojox.editor.plugins.ColorTableCell({commandName:cmd});
624
break;
625
case "modifyTable":
626
o.plugin=new dojox.editor.plugins.ModifyTable({commandName:cmd});
627
break;
628
case "insertTable":
629
o.plugin=new dojox.editor.plugins.InsertTable({commandName:cmd});
630
break;
631
case "tableContextMenu":
632
o.plugin=new dojox.editor.plugins.TableContextMenu({commandName:cmd});
633
break;
634
}
635
}
636
});
637
}