Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / atom / widget / FeedEntryEditor.js

History | View | Annotate | Download (31.9 KB)

1 9 andrej.cim
/*
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.atom.widget.FeedEntryEditor"]){
9
dojo._hasResource["dojox.atom.widget.FeedEntryEditor"]=true;
10
dojo.provide("dojox.atom.widget.FeedEntryEditor");
11
dojo.require("dojox.atom.widget.FeedEntryViewer");
12
dojo.require("dijit._Widget");
13
dojo.require("dijit._Templated");
14
dojo.require("dijit._Container");
15
dojo.require("dijit.Editor");
16
dojo.require("dijit.form.TextBox");
17
dojo.require("dijit.form.SimpleTextarea");
18
dojo.requireLocalization("dojox.atom.widget","FeedEntryEditor",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");
19
dojo.requireLocalization("dojox.atom.widget","PeopleEditor",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");
20
dojo.experimental("dojox.atom.widget.FeedEntryEditor");
21
dojo.declare("dojox.atom.widget.FeedEntryEditor",dojox.atom.widget.FeedEntryViewer,{_contentEditor:null,_oldContent:null,_setObject:null,enableEdit:false,_contentEditorCreator:null,_editors:{},entryNewButton:null,_editable:false,templateString:dojo.cache("dojox.atom","widget/templates/FeedEntryEditor.html","<div class=\"feedEntryViewer\">\n    <table border=\"0\" width=\"100%\" class=\"feedEntryViewerMenuTable\" dojoAttachPoint=\"feedEntryViewerMenu\" style=\"display: none;\">\n        <tr width=\"100%\"  dojoAttachPoint=\"entryCheckBoxDisplayOptions\">\n        \t<td align=\"left\" dojoAttachPoint=\"entryNewButton\">\n                <span class=\"feedEntryViewerMenu\" dojoAttachPoint=\"doNew\" dojoAttachEvent=\"onclick:_toggleNew\"></span>\n        \t</td>\n            <td align=\"left\" dojoAttachPoint=\"entryEditButton\" style=\"display: none;\">\n                <span class=\"feedEntryViewerMenu\" dojoAttachPoint=\"edit\" dojoAttachEvent=\"onclick:_toggleEdit\"></span>\n            </td>\n            <td align=\"left\" dojoAttachPoint=\"entrySaveCancelButtons\" style=\"display: none;\">\n                <span class=\"feedEntryViewerMenu\" dojoAttachPoint=\"save\" dojoAttachEvent=\"onclick:saveEdits\"></span>\n                <span class=\"feedEntryViewerMenu\" dojoAttachPoint=\"cancel\" dojoAttachEvent=\"onclick:cancelEdits\"></span>\n            </td>\n            <td align=\"right\">\n                <span class=\"feedEntryViewerMenu\" dojoAttachPoint=\"displayOptions\" dojoAttachEvent=\"onclick:_toggleOptions\"></span>\n            </td>\n        </tr>\n        <tr class=\"feedEntryViewerDisplayCheckbox\" dojoAttachPoint=\"entryCheckBoxRow\" width=\"100%\" style=\"display: none;\">\n            <td dojoAttachPoint=\"feedEntryCelltitle\">\n                <input type=\"checkbox\" name=\"title\" value=\"Title\" dojoAttachPoint=\"feedEntryCheckBoxTitle\" dojoAttachEvent=\"onclick:_toggleCheckbox\"/>\n\t\t\t\t<label for=\"title\" dojoAttachPoint=\"feedEntryCheckBoxLabelTitle\"></label>\n            </td>\n            <td dojoAttachPoint=\"feedEntryCellauthors\">\n                <input type=\"checkbox\" name=\"authors\" value=\"Authors\" dojoAttachPoint=\"feedEntryCheckBoxAuthors\" dojoAttachEvent=\"onclick:_toggleCheckbox\"/>\n\t\t\t\t<label for=\"title\" dojoAttachPoint=\"feedEntryCheckBoxLabelAuthors\"></label>\n            </td>\n            <td dojoAttachPoint=\"feedEntryCellcontributors\">\n                <input type=\"checkbox\" name=\"contributors\" value=\"Contributors\" dojoAttachPoint=\"feedEntryCheckBoxContributors\" dojoAttachEvent=\"onclick:_toggleCheckbox\"/>\n\t\t\t\t<label for=\"title\" dojoAttachPoint=\"feedEntryCheckBoxLabelContributors\"></label>\n            </td>\n            <td dojoAttachPoint=\"feedEntryCellid\">\n                <input type=\"checkbox\" name=\"id\" value=\"Id\" dojoAttachPoint=\"feedEntryCheckBoxId\" dojoAttachEvent=\"onclick:_toggleCheckbox\"/>\n\t\t\t\t<label for=\"title\" dojoAttachPoint=\"feedEntryCheckBoxLabelId\"></label>\n            </td>\n            <td rowspan=\"2\" align=\"right\">\n                <span class=\"feedEntryViewerMenu\" dojoAttachPoint=\"close\" dojoAttachEvent=\"onclick:_toggleOptions\"></span>\n            </td>\n\t\t</tr>\n\t\t<tr class=\"feedEntryViewerDisplayCheckbox\" dojoAttachPoint=\"entryCheckBoxRow2\" width=\"100%\" style=\"display: none;\">\n            <td dojoAttachPoint=\"feedEntryCellupdated\">\n                <input type=\"checkbox\" name=\"updated\" value=\"Updated\" dojoAttachPoint=\"feedEntryCheckBoxUpdated\" dojoAttachEvent=\"onclick:_toggleCheckbox\"/>\n\t\t\t\t<label for=\"title\" dojoAttachPoint=\"feedEntryCheckBoxLabelUpdated\"></label>\n            </td>\n            <td dojoAttachPoint=\"feedEntryCellsummary\">\n                <input type=\"checkbox\" name=\"summary\" value=\"Summary\" dojoAttachPoint=\"feedEntryCheckBoxSummary\" dojoAttachEvent=\"onclick:_toggleCheckbox\"/>\n\t\t\t\t<label for=\"title\" dojoAttachPoint=\"feedEntryCheckBoxLabelSummary\"></label>\n            </td>\n            <td dojoAttachPoint=\"feedEntryCellcontent\">\n                <input type=\"checkbox\" name=\"content\" value=\"Content\" dojoAttachPoint=\"feedEntryCheckBoxContent\" dojoAttachEvent=\"onclick:_toggleCheckbox\"/>\n\t\t\t\t<label for=\"title\" dojoAttachPoint=\"feedEntryCheckBoxLabelContent\"></label>\n            </td>\n        </tr>\n    </table>\n    \n    <table class=\"feedEntryViewerContainer\" border=\"0\" width=\"100%\">\n        <tr class=\"feedEntryViewerTitle\" dojoAttachPoint=\"entryTitleRow\" style=\"display: none;\">\n            <td>\n                <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n                    <tr class=\"graphic-tab-lgray\">\n\t\t\t\t\t\t<td class=\"lp2\">\n\t\t\t\t\t\t\t<span class=\"lp\" dojoAttachPoint=\"entryTitleHeader\"></span>\n\t\t\t\t\t\t</td>\n                    </tr>\n                    <tr>\n                        <td>\n                        \t<select dojoAttachPoint=\"entryTitleSelect\" dojoAttachEvent=\"onchange:_switchEditor\" style=\"display: none\">\n                        \t\t<option value=\"text\">Text</option>\n\t\t\t\t\t\t\t\t<option value=\"html\">HTML</option>\n\t\t\t\t\t\t\t\t<option value=\"xhtml\">XHTML</option>\n                        \t</select>\n                        </td>\n                    </tr>\n                    <tr>\n                        <td colspan=\"2\" dojoAttachPoint=\"entryTitleNode\">\n                        </td>\n                    </tr>\n                </table>\n            </td>\n        </tr>\n\n        <tr class=\"feedEntryViewerAuthor\" dojoAttachPoint=\"entryAuthorRow\" style=\"display: none;\">\n            <td>\n                <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n                    <tr class=\"graphic-tab-lgray\">\n\t\t\t\t\t\t<td class=\"lp2\">\n\t\t\t\t\t\t\t<span class=\"lp\" dojoAttachPoint=\"entryAuthorHeader\"></span>\n\t\t\t\t\t\t</td>\n                    </tr>\n                    <tr>\n                        <td dojoAttachPoint=\"entryAuthorNode\">\n                        </td>\n                    </tr>\n                </table>\n            </td>\n        </tr>\n\n        <tr class=\"feedEntryViewerContributor\" dojoAttachPoint=\"entryContributorRow\" style=\"display: none;\">\n            <td>\n                <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n                    <tr class=\"graphic-tab-lgray\">\n\t\t\t\t\t\t<td class=\"lp2\">\n\t\t\t\t\t\t\t<span class=\"lp\" dojoAttachPoint=\"entryContributorHeader\"></span>\n\t\t\t\t\t\t</td>\n                    </tr>\n                    <tr>\n                        <td dojoAttachPoint=\"entryContributorNode\" class=\"feedEntryViewerContributorNames\">\n                        </td>\n                    </tr>\n                </table>\n            </td>\n        </tr>\n        \n        <tr class=\"feedEntryViewerId\" dojoAttachPoint=\"entryIdRow\" style=\"display: none;\">\n            <td>\n                <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n                    <tr class=\"graphic-tab-lgray\">\n\t\t\t\t\t\t<td class=\"lp2\">\n\t\t\t\t\t\t\t<span class=\"lp\" dojoAttachPoint=\"entryIdHeader\"></span>\n\t\t\t\t\t\t</td>\n                    </tr>\n                    <tr>\n                        <td dojoAttachPoint=\"entryIdNode\" class=\"feedEntryViewerIdText\">\n                        </td>\n                    </tr>\n                </table>\n            </td>\n        </tr>\n    \n        <tr class=\"feedEntryViewerUpdated\" dojoAttachPoint=\"entryUpdatedRow\" style=\"display: none;\">\n            <td>\n                <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n                    <tr class=\"graphic-tab-lgray\">\n\t\t\t\t\t\t<td class=\"lp2\">\n\t\t\t\t\t\t\t<span class=\"lp\" dojoAttachPoint=\"entryUpdatedHeader\"></span>\n\t\t\t\t\t\t</td>\n                    </tr>\n                    <tr>\n                        <td dojoAttachPoint=\"entryUpdatedNode\" class=\"feedEntryViewerUpdatedText\">\n                        </td>\n                    </tr>\n                </table>\n            </td>\n        </tr>\n    \n        <tr class=\"feedEntryViewerSummary\" dojoAttachPoint=\"entrySummaryRow\" style=\"display: none;\">\n            <td>\n                <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n                    <tr class=\"graphic-tab-lgray\">\n\t\t\t\t\t\t<td class=\"lp2\" colspan=\"2\">\n\t\t\t\t\t\t\t<span class=\"lp\" dojoAttachPoint=\"entrySummaryHeader\"></span>\n\t\t\t\t\t\t</td>\n                    </tr>\n                    <tr>\n                        <td>\n                        \t<select dojoAttachPoint=\"entrySummarySelect\" dojoAttachEvent=\"onchange:_switchEditor\" style=\"display: none\">\n                        \t\t<option value=\"text\">Text</option>\n\t\t\t\t\t\t\t\t<option value=\"html\">HTML</option>\n\t\t\t\t\t\t\t\t<option value=\"xhtml\">XHTML</option>\n                        \t</select>\n                        </td>\n                    </tr>\n                    <tr>\n                        <td dojoAttachPoint=\"entrySummaryNode\">\n                        </td>\n                    </tr>\n                </table>\n            </td>\n        </tr>\n    \n        <tr class=\"feedEntryViewerContent\" dojoAttachPoint=\"entryContentRow\" style=\"display: none;\">\n            <td>\n                <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n                    <tr class=\"graphic-tab-lgray\">\n\t\t\t\t\t\t<td class=\"lp2\">\n\t\t\t\t\t\t\t<span class=\"lp\" dojoAttachPoint=\"entryContentHeader\"></span>\n\t\t\t\t\t\t</td>\n                    </tr>\n                    <tr>\n                        <td>\n                        \t<select dojoAttachPoint=\"entryContentSelect\" dojoAttachEvent=\"onchange:_switchEditor\" style=\"display: none\">\n                        \t\t<option value=\"text\">Text</option>\n\t\t\t\t\t\t\t\t<option value=\"html\">HTML</option>\n\t\t\t\t\t\t\t\t<option value=\"xhtml\">XHTML</option>\n                        \t</select>\n                        </td>\n                    </tr>\n                    <tr>\n                        <td dojoAttachPoint=\"entryContentNode\">\n                        </td>\n                    </tr>\n                </table>\n            </td>\n        </tr>\n    </table>\n</div>\n"),postCreate:function(){
22
if(this.entrySelectionTopic!==""){
23
this._subscriptions=[dojo.subscribe(this.entrySelectionTopic,this,"_handleEvent")];
24
}
25
var _1=dojo.i18n.getLocalization("dojox.atom.widget","FeedEntryViewer");
26
this.displayOptions.innerHTML=_1.displayOptions;
27
this.feedEntryCheckBoxLabelTitle.innerHTML=_1.title;
28
this.feedEntryCheckBoxLabelAuthors.innerHTML=_1.authors;
29
this.feedEntryCheckBoxLabelContributors.innerHTML=_1.contributors;
30
this.feedEntryCheckBoxLabelId.innerHTML=_1.id;
31
this.close.innerHTML=_1.close;
32
this.feedEntryCheckBoxLabelUpdated.innerHTML=_1.updated;
33
this.feedEntryCheckBoxLabelSummary.innerHTML=_1.summary;
34
this.feedEntryCheckBoxLabelContent.innerHTML=_1.content;
35
_1=dojo.i18n.getLocalization("dojox.atom.widget","FeedEntryEditor");
36
this.doNew.innerHTML=_1.doNew;
37
this.edit.innerHTML=_1.edit;
38
this.save.innerHTML=_1.save;
39
this.cancel.innerHTML=_1.cancel;
40
},setEntry:function(_2,_3,_4){
41
if(this._entry!==_2){
42
this._editMode=false;
43
_4=false;
44
}else{
45
_4=true;
46
}
47
dojox.atom.widget.FeedEntryEditor.superclass.setEntry.call(this,_2,_3);
48
this._editable=this._isEditable(_2);
49
if(!_4&&!this._editable){
50
dojo.style(this.entryEditButton,"display","none");
51
dojo.style(this.entrySaveCancelButtons,"display","none");
52
}
53
if(this._editable&&this.enableEdit){
54
if(!_4){
55
dojo.style(this.entryEditButton,"display","");
56
if(this.enableMenuFade&&this.entrySaveCancelButton){
57
dojo.fadeOut({node:this.entrySaveCancelButton,duration:250}).play();
58
}
59
}
60
}
61
},_toggleEdit:function(){
62
if(this._editable&&this.enableEdit){
63
dojo.style(this.entryEditButton,"display","none");
64
dojo.style(this.entrySaveCancelButtons,"display","");
65
this._editMode=true;
66
this.setEntry(this._entry,this._feed,true);
67
}
68
},_handleEvent:function(_5){
69
if(_5.source!=this&&_5.action=="delete"&&_5.entry&&_5.entry==this._entry){
70
dojo.style(this.entryEditButton,"display","none");
71
}
72
dojox.atom.widget.FeedEntryEditor.superclass._handleEvent.call(this,_5);
73
},_isEditable:function(_6){
74
var _7=false;
75
if(_6&&_6!==null&&_6.links&&_6.links!==null){
76
for(var x in _6.links){
77
if(_6.links[x].rel&&_6.links[x].rel=="edit"){
78
_7=true;
79
break;
80
}
81
}
82
}
83
return _7;
84
},setTitle:function(_8,_9,_a){
85
if(!_9){
86
dojox.atom.widget.FeedEntryEditor.superclass.setTitle.call(this,_8,_9,_a);
87
if(_a.title&&_a.title.value&&_a.title.value!==null){
88
this.setFieldValidity("title",true);
89
}
90
}else{
91
if(_a.title&&_a.title.value&&_a.title.value!==null){
92
if(!this._toLoad){
93
this._toLoad=[];
94
}
95
this.entryTitleSelect.value=_a.title.type;
96
var _b=this._createEditor(_8,_a.title,true,_a.title.type==="html"||_a.title.type==="xhtml");
97
_b.name="title";
98
this._toLoad.push(_b);
99
this.setFieldValidity("titleedit",true);
100
this.setFieldValidity("title",true);
101
}
102
}
103
},setAuthors:function(_c,_d,_e){
104
if(!_d){
105
dojox.atom.widget.FeedEntryEditor.superclass.setAuthors.call(this,_c,_d,_e);
106
if(_e.authors&&_e.authors.length>0){
107
this.setFieldValidity("authors",true);
108
}
109
}else{
110
if(_e.authors&&_e.authors.length>0){
111
this._editors.authors=this._createPeopleEditor(this.entryAuthorNode,{data:_e.authors,name:"Author"});
112
this.setFieldValidity("authors",true);
113
}
114
}
115
},setContributors:function(_f,_10,_11){
116
if(!_10){
117
dojox.atom.widget.FeedEntryEditor.superclass.setContributors.call(this,_f,_10,_11);
118
if(_11.contributors&&_11.contributors.length>0){
119
this.setFieldValidity("contributors",true);
120
}
121
}else{
122
if(_11.contributors&&_11.contributors.length>0){
123
this._editors.contributors=this._createPeopleEditor(this.entryContributorNode,{data:_11.contributors,name:"Contributor"});
124
this.setFieldValidity("contributors",true);
125
}
126
}
127
},setId:function(_12,_13,_14){
128
if(!_13){
129
dojox.atom.widget.FeedEntryEditor.superclass.setId.call(this,_12,_13,_14);
130
if(_14.id&&_14.id!==null){
131
this.setFieldValidity("id",true);
132
}
133
}else{
134
if(_14.id&&_14.id!==null){
135
this._editors.id=this._createEditor(_12,_14.id);
136
this.setFieldValidity("id",true);
137
}
138
}
139
},setUpdated:function(_15,_16,_17){
140
if(!_16){
141
dojox.atom.widget.FeedEntryEditor.superclass.setUpdated.call(this,_15,_16,_17);
142
if(_17.updated&&_17.updated!==null){
143
this.setFieldValidity("updated",true);
144
}
145
}else{
146
if(_17.updated&&_17.updated!==null){
147
this._editors.updated=this._createEditor(_15,_17.updated);
148
this.setFieldValidity("updated",true);
149
}
150
}
151
},setSummary:function(_18,_19,_1a){
152
if(!_19){
153
dojox.atom.widget.FeedEntryEditor.superclass.setSummary.call(this,_18,_19,_1a);
154
if(_1a.summary&&_1a.summary.value&&_1a.summary.value!==null){
155
this.setFieldValidity("summary",true);
156
}
157
}else{
158
if(_1a.summary&&_1a.summary.value&&_1a.summary.value!==null){
159
if(!this._toLoad){
160
this._toLoad=[];
161
}
162
this.entrySummarySelect.value=_1a.summary.type;
163
var _1b=this._createEditor(_18,_1a.summary,true,_1a.summary.type==="html"||_1a.summary.type==="xhtml");
164
_1b.name="summary";
165
this._toLoad.push(_1b);
166
this.setFieldValidity("summaryedit",true);
167
this.setFieldValidity("summary",true);
168
}
169
}
170
},setContent:function(_1c,_1d,_1e){
171
if(!_1d){
172
dojox.atom.widget.FeedEntryEditor.superclass.setContent.call(this,_1c,_1d,_1e);
173
if(_1e.content&&_1e.content.value&&_1e.content.value!==null){
174
this.setFieldValidity("content",true);
175
}
176
}else{
177
if(_1e.content&&_1e.content.value&&_1e.content.value!==null){
178
if(!this._toLoad){
179
this._toLoad=[];
180
}
181
this.entryContentSelect.value=_1e.content.type;
182
var _1f=this._createEditor(_1c,_1e.content,true,_1e.content.type==="html"||_1e.content.type==="xhtml");
183
_1f.name="content";
184
this._toLoad.push(_1f);
185
this.setFieldValidity("contentedit",true);
186
this.setFieldValidity("content",true);
187
}
188
}
189
},_createEditor:function(_20,_21,_22,rte){
190
var _23;
191
var box;
192
if(!_21){
193
if(rte){
194
return {anchorNode:_20,entryValue:"",editor:null,generateEditor:function(){
195
var _24=document.createElement("div");
196
_24.innerHTML=this.entryValue;
197
this.anchorNode.appendChild(_24);
198
var _25=new dijit.Editor({},_24);
199
this.editor=_25;
200
return _25;
201
}};
202
}
203
if(_22){
204
_23=document.createElement("textarea");
205
_20.appendChild(_23);
206
dojo.style(_23,"width","90%");
207
box=new dijit.form.SimpleTextarea({},_23);
208
}else{
209
_23=document.createElement("input");
210
_20.appendChild(_23);
211
dojo.style(_23,"width","95%");
212
box=new dijit.form.TextBox({},_23);
213
}
214
box.attr("value","");
215
return box;
216
}
217
var _26;
218
if(_21.value!==undefined){
219
_26=_21.value;
220
}else{
221
if(_21.attr){
222
_26=_21.attr("value");
223
}else{
224
_26=_21;
225
}
226
}
227
if(rte){
228
if(_26.indexOf("<")!=-1){
229
_26=_26.replace(/</g,"&lt;");
230
}
231
return {anchorNode:_20,entryValue:_26,editor:null,generateEditor:function(){
232
var _27=document.createElement("div");
233
_27.innerHTML=this.entryValue;
234
this.anchorNode.appendChild(_27);
235
var _28=new dijit.Editor({},_27);
236
this.editor=_28;
237
return _28;
238
}};
239
}
240
if(_22){
241
_23=document.createElement("textarea");
242
_20.appendChild(_23);
243
dojo.style(_23,"width","90%");
244
box=new dijit.form.SimpleTextarea({},_23);
245
}else{
246
_23=document.createElement("input");
247
_20.appendChild(_23);
248
dojo.style(_23,"width","95%");
249
box=new dijit.form.TextBox({},_23);
250
}
251
box.attr("value",_26);
252
return box;
253
},_switchEditor:function(_29){
254
var _2a=null;
255
var _2b=null;
256
var _2c=null;
257
if(dojo.isIE){
258
_2b=_29.srcElement;
259
}else{
260
_2b=_29.target;
261
}
262
if(_2b===this.entryTitleSelect){
263
_2c=this.entryTitleNode;
264
_2a="title";
265
}else{
266
if(_2b===this.entrySummarySelect){
267
_2c=this.entrySummaryNode;
268
_2a="summary";
269
}else{
270
_2c=this.entryContentNode;
271
_2a="content";
272
}
273
}
274
var _2d=this._editors[_2a];
275
var _2e;
276
var _2f;
277
if(_2b.value==="text"){
278
if(_2d.declaredClass==="dijit.Editor"){
279
_2f=_2d.attr("value",false);
280
_2d.close(false,true);
281
_2d.destroy();
282
while(_2c.firstChild){
283
dojo.destroy(_2c.firstChild);
284
}
285
_2e=this._createEditor(_2c,{value:_2f},true,false);
286
this._editors[_2a]=_2e;
287
}
288
}else{
289
if(_2d.declaredClass!="dijit.Editor"){
290
_2f=_2d.attr("value");
291
_2d.destroy();
292
while(_2c.firstChild){
293
dojo.destroy(_2c.firstChild);
294
}
295
_2e=this._createEditor(_2c,{value:_2f},true,true);
296
_2e=dojo.hitch(_2e,_2e.generateEditor)();
297
this._editors[_2a]=_2e;
298
}
299
}
300
},_createPeopleEditor:function(_30,_31){
301
var _32=document.createElement("div");
302
_30.appendChild(_32);
303
return new dojox.atom.widget.PeopleEditor(_31,_32);
304
},saveEdits:function(){
305
dojo.style(this.entrySaveCancelButtons,"display","none");
306
dojo.style(this.entryEditButton,"display","");
307
dojo.style(this.entryNewButton,"display","");
308
var _33=false;
309
var _34;
310
var i;
311
var _35;
312
var _36;
313
var _37;
314
var _38;
315
if(!this._new){
316
_36=this.getEntry();
317
if(this._editors.title&&(this._editors.title.attr("value")!=_36.title.value||this.entryTitleSelect.value!=_36.title.type)){
318
_34=this._editors.title.attr("value");
319
if(this.entryTitleSelect.value==="xhtml"){
320
_34=this._enforceXhtml(_34);
321
if(_34.indexOf("<div xmlns=\"http://www.w3.org/1999/xhtml\">")!==0){
322
_34="<div xmlns=\"http://www.w3.org/1999/xhtml\">"+_34+"</div>";
323
}
324
}
325
_36.title=new dojox.atom.io.model.Content("title",_34,null,this.entryTitleSelect.value);
326
_33=true;
327
}
328
if(this._editors.id.attr("value")!=_36.id){
329
_36.id=this._editors.id.attr("value");
330
_33=true;
331
}
332
if(this._editors.summary&&(this._editors.summary.attr("value")!=_36.summary.value||this.entrySummarySelect.value!=_36.summary.type)){
333
_34=this._editors.summary.attr("value");
334
if(this.entrySummarySelect.value==="xhtml"){
335
_34=this._enforceXhtml(_34);
336
if(_34.indexOf("<div xmlns=\"http://www.w3.org/1999/xhtml\">")!==0){
337
_34="<div xmlns=\"http://www.w3.org/1999/xhtml\">"+_34+"</div>";
338
}
339
}
340
_36.summary=new dojox.atom.io.model.Content("summary",_34,null,this.entrySummarySelect.value);
341
_33=true;
342
}
343
if(this._editors.content&&(this._editors.content.attr("value")!=_36.content.value||this.entryContentSelect.value!=_36.content.type)){
344
_34=this._editors.content.attr("value");
345
if(this.entryContentSelect.value==="xhtml"){
346
_34=this._enforceXhtml(_34);
347
if(_34.indexOf("<div xmlns=\"http://www.w3.org/1999/xhtml\">")!==0){
348
_34="<div xmlns=\"http://www.w3.org/1999/xhtml\">"+_34+"</div>";
349
}
350
}
351
_36.content=new dojox.atom.io.model.Content("content",_34,null,this.entryContentSelect.value);
352
_33=true;
353
}
354
if(this._editors.authors){
355
if(_33){
356
_36.authors=[];
357
_37=this._editors.authors.getValues();
358
for(i in _37){
359
if(_37[i].name||_37[i].email||_37[i].uri){
360
_36.addAuthor(_37[i].name,_37[i].email,_37[i].uri);
361
}
362
}
363
}else{
364
var _39=_36.authors;
365
var _3a=function(_3b,_3c,uri){
366
for(i in _39){
367
if(_39[i].name===_3b&&_39[i].email===_3c&&_39[i].uri===uri){
368
return true;
369
}
370
}
371
return false;
372
};
373
_37=this._editors.authors.getValues();
374
_35=false;
375
for(i in _37){
376
if(!_3a(_37[i].name,_37[i].email,_37[i].uri)){
377
_35=true;
378
break;
379
}
380
}
381
if(_35){
382
_36.authors=[];
383
for(i in _37){
384
if(_37[i].name||_37[i].email||_37[i].uri){
385
_36.addAuthor(_37[i].name,_37[i].email,_37[i].uri);
386
}
387
}
388
_33=true;
389
}
390
}
391
}
392
if(this._editors.contributors){
393
if(_33){
394
_36.contributors=[];
395
_38=this._editors.contributors.getValues();
396
for(i in _38){
397
if(_38[i].name||_38[i].email||_38[i].uri){
398
_36.addAuthor(_38[i].name,_38[i].email,_38[i].uri);
399
}
400
}
401
}else{
402
var _3d=_36.contributors;
403
var _3e=function(_3f,_40,uri){
404
for(i in _3d){
405
if(_3d[i].name===_3f&&_3d[i].email===_40&&_3d[i].uri===uri){
406
return true;
407
}
408
}
409
return false;
410
};
411
_38=this._editors.contributors.getValues();
412
_35=false;
413
for(i in _38){
414
if(_3e(_38[i].name,_38[i].email,_38[i].uri)){
415
_35=true;
416
break;
417
}
418
}
419
if(_35){
420
_36.contributors=[];
421
for(i in _38){
422
if(_38[i].name||_38[i].email||_38[i].uri){
423
_36.addContributor(_38[i].name,_38[i].email,_38[i].uri);
424
}
425
}
426
_33=true;
427
}
428
}
429
}
430
if(_33){
431
dojo.publish(this.entrySelectionTopic,[{action:"update",source:this,entry:_36,callback:this._handleSave}]);
432
}
433
}else{
434
this._new=false;
435
_36=new dojox.atom.io.model.Entry();
436
_34=this._editors.title.attr("value");
437
if(this.entryTitleSelect.value==="xhtml"){
438
_34=this._enforceXhtml(_34);
439
_34="<div xmlns=\"http://www.w3.org/1999/xhtml\">"+_34+"</div>";
440
}
441
_36.setTitle(_34,this.entryTitleSelect.value);
442
_36.id=this._editors.id.attr("value");
443
_37=this._editors.authors.getValues();
444
for(i in _37){
445
if(_37[i].name||_37[i].email||_37[i].uri){
446
_36.addAuthor(_37[i].name,_37[i].email,_37[i].uri);
447
}
448
}
449
_38=this._editors.contributors.getValues();
450
for(i in _38){
451
if(_38[i].name||_38[i].email||_38[i].uri){
452
_36.addContributor(_38[i].name,_38[i].email,_38[i].uri);
453
}
454
}
455
_34=this._editors.summary.attr("value");
456
if(this.entrySummarySelect.value==="xhtml"){
457
_34=this._enforceXhtml(_34);
458
_34="<div xmlns=\"http://www.w3.org/1999/xhtml\">"+_34+"</div>";
459
}
460
_36.summary=new dojox.atom.io.model.Content("summary",_34,null,this.entrySummarySelect.value);
461
_34=this._editors.content.attr("value");
462
if(this.entryContentSelect.value==="xhtml"){
463
_34=this._enforceXhtml(_34);
464
_34="<div xmlns=\"http://www.w3.org/1999/xhtml\">"+_34+"</div>";
465
}
466
_36.content=new dojox.atom.io.model.Content("content",_34,null,this.entryContentSelect.value);
467
dojo.style(this.entryNewButton,"display","");
468
dojo.publish(this.entrySelectionTopic,[{action:"post",source:this,entry:_36}]);
469
}
470
this._editMode=false;
471
this.setEntry(_36,this._feed,true);
472
},_handleSave:function(_41,_42){
473
this._editMode=false;
474
this.clear();
475
this.setEntry(_41,this.getFeed(),true);
476
},cancelEdits:function(){
477
this._new=false;
478
dojo.style(this.entrySaveCancelButtons,"display","none");
479
if(this._editable){
480
dojo.style(this.entryEditButton,"display","");
481
}
482
dojo.style(this.entryNewButton,"display","");
483
this._editMode=false;
484
this.clearEditors();
485
this.setEntry(this.getEntry(),this.getFeed(),true);
486
},clear:function(){
487
this._editable=false;
488
this.clearEditors();
489
dojox.atom.widget.FeedEntryEditor.superclass.clear.apply(this);
490
if(this._contentEditor){
491
this._contentEditor=this._setObject=this._oldContent=this._contentEditorCreator=null;
492
this._editors={};
493
}
494
},clearEditors:function(){
495
for(var key in this._editors){
496
if(this._editors[key].declaredClass==="dijit.Editor"){
497
this._editors[key].close(false,true);
498
}
499
this._editors[key].destroy();
500
}
501
this._editors={};
502
},_enforceXhtml:function(_43){
503
var _44=null;
504
if(_43){
505
var _45=/<br>/g;
506
_44=_43.replace(_45,"<br/>");
507
_44=this._closeTag(_44,"hr");
508
_44=this._closeTag(_44,"img");
509
}
510
return _44;
511
},_closeTag:function(_46,tag){
512
var _47="<"+tag;
513
var _48=_46.indexOf(_47);
514
if(_48!==-1){
515
while(_48!==-1){
516
var _49="";
517
var _4a=false;
518
for(var i=0;i<_46.length;i++){
519
var c=_46.charAt(i);
520
if(i<=_48||_4a){
521
_49+=c;
522
}else{
523
if(c===">"){
524
_49+="/";
525
_4a=true;
526
}
527
_49+=c;
528
}
529
}
530
_46=_49;
531
_48=_46.indexOf(_47,_48+1);
532
}
533
}
534
return _46;
535
},_toggleNew:function(){
536
dojo.style(this.entryNewButton,"display","none");
537
dojo.style(this.entryEditButton,"display","none");
538
dojo.style(this.entrySaveCancelButtons,"display","");
539
this.entrySummarySelect.value="text";
540
this.entryContentSelect.value="text";
541
this.entryTitleSelect.value="text";
542
this.clearNodes();
543
this._new=true;
544
var _4b=dojo.i18n.getLocalization("dojox.atom.widget","FeedEntryViewer");
545
var _4c=new dojox.atom.widget.EntryHeader({title:_4b.title});
546
this.entryTitleHeader.appendChild(_4c.domNode);
547
this._editors.title=this._createEditor(this.entryTitleNode,null);
548
this.setFieldValidity("title",true);
549
var _4d=new dojox.atom.widget.EntryHeader({title:_4b.authors});
550
this.entryAuthorHeader.appendChild(_4d.domNode);
551
this._editors.authors=this._createPeopleEditor(this.entryAuthorNode,{name:"Author"});
552
this.setFieldValidity("authors",true);
553
var _4e=new dojox.atom.widget.EntryHeader({title:_4b.contributors});
554
this.entryContributorHeader.appendChild(_4e.domNode);
555
this._editors.contributors=this._createPeopleEditor(this.entryContributorNode,{name:"Contributor"});
556
this.setFieldValidity("contributors",true);
557
var _4f=new dojox.atom.widget.EntryHeader({title:_4b.id});
558
this.entryIdHeader.appendChild(_4f.domNode);
559
this._editors.id=this._createEditor(this.entryIdNode,null);
560
this.setFieldValidity("id",true);
561
var _50=new dojox.atom.widget.EntryHeader({title:_4b.updated});
562
this.entryUpdatedHeader.appendChild(_50.domNode);
563
this._editors.updated=this._createEditor(this.entryUpdatedNode,null);
564
this.setFieldValidity("updated",true);
565
var _51=new dojox.atom.widget.EntryHeader({title:_4b.summary});
566
this.entrySummaryHeader.appendChild(_51.domNode);
567
this._editors.summary=this._createEditor(this.entrySummaryNode,null,true);
568
this.setFieldValidity("summaryedit",true);
569
this.setFieldValidity("summary",true);
570
var _52=new dojox.atom.widget.EntryHeader({title:_4b.content});
571
this.entryContentHeader.appendChild(_52.domNode);
572
this._editors.content=this._createEditor(this.entryContentNode,null,true);
573
this.setFieldValidity("contentedit",true);
574
this.setFieldValidity("content",true);
575
this._displaySections();
576
},_displaySections:function(){
577
dojo.style(this.entrySummarySelect,"display","none");
578
dojo.style(this.entryContentSelect,"display","none");
579
dojo.style(this.entryTitleSelect,"display","none");
580
if(this.isFieldValid("contentedit")){
581
dojo.style(this.entryContentSelect,"display","");
582
}
583
if(this.isFieldValid("summaryedit")){
584
dojo.style(this.entrySummarySelect,"display","");
585
}
586
if(this.isFieldValid("titleedit")){
587
dojo.style(this.entryTitleSelect,"display","");
588
}
589
dojox.atom.widget.FeedEntryEditor.superclass._displaySections.apply(this);
590
if(this._toLoad){
591
for(var i in this._toLoad){
592
var _53;
593
if(this._toLoad[i].generateEditor){
594
_53=dojo.hitch(this._toLoad[i],this._toLoad[i].generateEditor)();
595
}else{
596
_53=this._toLoad[i];
597
}
598
this._editors[this._toLoad[i].name]=_53;
599
this._toLoad[i]=null;
600
}
601
this._toLoad=null;
602
}
603
}});
604
dojo.declare("dojox.atom.widget.PeopleEditor",[dijit._Widget,dijit._Templated,dijit._Container],{templateString:dojo.cache("dojox.atom","widget/templates/PeopleEditor.html","<div class=\"peopleEditor\">\n\t<table style=\"width: 100%\">\n\t\t<tbody dojoAttachPoint=\"peopleEditorEditors\"></tbody>\n\t</table>\n\t<span class=\"peopleEditorButton\" dojoAttachPoint=\"peopleEditorButton\" dojoAttachEvent=\"onclick:_add\"></span>\n</div>\n"),_rows:[],_editors:[],_index:0,_numRows:0,postCreate:function(){
605
var _54=dojo.i18n.getLocalization("dojox.atom.widget","PeopleEditor");
606
if(this.name){
607
if(this.name=="Author"){
608
this.peopleEditorButton.appendChild(document.createTextNode("["+_54.addAuthor+"]"));
609
}else{
610
if(this.name=="Contributor"){
611
this.peopleEditorButton.appendChild(document.createTextNode("["+_54.addContributor+"]"));
612
}
613
}
614
}else{
615
this.peopleEditorButton.appendChild(document.createTextNode("["+_54.add+"]"));
616
}
617
this._editors=[];
618
if(!this.data||this.data.length===0){
619
this._createEditors(null,null,null,0,this.name);
620
this._index=1;
621
}else{
622
for(var i in this.data){
623
this._createEditors(this.data[i].name,this.data[i].email,this.data[i].uri,i);
624
this._index++;
625
this._numRows++;
626
}
627
}
628
},destroy:function(){
629
for(var key in this._editors){
630
for(var _55 in this._editors[key]){
631
this._editors[key][_55].destroy();
632
}
633
}
634
this._editors=[];
635
},_createEditors:function(_56,_57,uri,_58,_59){
636
var row=document.createElement("tr");
637
this.peopleEditorEditors.appendChild(row);
638
row.id="removeRow"+_58;
639
var _5a=document.createElement("td");
640
_5a.setAttribute("align","right");
641
row.appendChild(_5a);
642
_5a.colSpan=2;
643
if(this._numRows>0){
644
var hr=document.createElement("hr");
645
_5a.appendChild(hr);
646
hr.id="hr"+_58;
647
}
648
row=document.createElement("span");
649
_5a.appendChild(row);
650
row.className="peopleEditorButton";
651
dojo.style(row,"font-size","x-small");
652
dojo.connect(row,"onclick",this,"_removeEditor");
653
row.id="remove"+_58;
654
_5a=document.createTextNode("[X]");
655
row.appendChild(_5a);
656
row=document.createElement("tr");
657
this.peopleEditorEditors.appendChild(row);
658
row.id="editorsRow"+_58;
659
var _5b=document.createElement("td");
660
row.appendChild(_5b);
661
dojo.style(_5b,"width","20%");
662
_5a=document.createElement("td");
663
row.appendChild(_5a);
664
row=document.createElement("table");
665
_5b.appendChild(row);
666
dojo.style(row,"width","100%");
667
_5b=document.createElement("tbody");
668
row.appendChild(_5b);
669
row=document.createElement("table");
670
_5a.appendChild(row);
671
dojo.style(row,"width","100%");
672
_5a=document.createElement("tbody");
673
row.appendChild(_5a);
674
this._editors[_58]=[];
675
this._editors[_58].push(this._createEditor(_56,_59+"name"+_58,"Name:",_5b,_5a));
676
this._editors[_58].push(this._createEditor(_57,_59+"email"+_58,"Email:",_5b,_5a));
677
this._editors[_58].push(this._createEditor(uri,_59+"uri"+_58,"URI:",_5b,_5a));
678
},_createEditor:function(_5c,id,_5d,_5e,_5f){
679
var row=document.createElement("tr");
680
_5e.appendChild(row);
681
var _60=document.createElement("label");
682
_60.setAttribute("for",id);
683
_60.appendChild(document.createTextNode(_5d));
684
_5e=document.createElement("td");
685
_5e.appendChild(_60);
686
row.appendChild(_5e);
687
row=document.createElement("tr");
688
_5f.appendChild(row);
689
_5f=document.createElement("td");
690
row.appendChild(_5f);
691
var _61=document.createElement("input");
692
_61.setAttribute("id",id);
693
_5f.appendChild(_61);
694
dojo.style(_61,"width","95%");
695
var box=new dijit.form.TextBox({},_61);
696
box.attr("value",_5c);
697
return box;
698
},_removeEditor:function(_62){
699
var _63=null;
700
if(dojo.isIE){
701
_63=_62.srcElement;
702
}else{
703
_63=_62.target;
704
}
705
var id=_63.id;
706
id=id.substring(6);
707
for(var key in this._editors[id]){
708
this._editors[id][key].destroy();
709
}
710
var _64=dojo.byId("editorsRow"+id);
711
var _65=_64.parentNode;
712
_65.removeChild(_64);
713
_64=dojo.byId("removeRow"+id);
714
_65=_64.parentNode;
715
_65.removeChild(_64);
716
this._numRows--;
717
if(this._numRows===1&&_65.firstChild.firstChild.firstChild.tagName.toLowerCase()==="hr"){
718
_64=_65.firstChild.firstChild;
719
_64.removeChild(_64.firstChild);
720
}
721
this._editors[id]=null;
722
},_add:function(){
723
this._createEditors(null,null,null,this._index);
724
this._index++;
725
this._numRows++;
726
},getValues:function(){
727
var _66=[];
728
for(var i in this._editors){
729
if(this._editors[i]){
730
_66.push({name:this._editors[i][0].attr("value"),email:this._editors[i][1].attr("value"),uri:this._editors[i][2].attr("value")});
731
}
732
}
733
return _66;
734
}});
735
}