1 | define([ |
---|
2 | "dojo/_base/kernel", |
---|
3 | "dojo/_base/connect", |
---|
4 | "dojo/_base/declare", |
---|
5 | "dojo/_base/fx", |
---|
6 | "dojo/_base/array", |
---|
7 | "dojo/dom-style", |
---|
8 | "dojo/dom-construct", |
---|
9 | "dijit/_Widget", |
---|
10 | "dijit/_Templated", |
---|
11 | "dijit/_Container", |
---|
12 | "dijit/layout/ContentPane", |
---|
13 | "../io/Connection", |
---|
14 | "dojo/text!./templates/FeedEntryViewer.html", |
---|
15 | "dojo/text!./templates/EntryHeader.html", |
---|
16 | "dojo/i18n!./nls/FeedEntryViewer" |
---|
17 | ], function (dojo, connect, declare, fx, arrayUtil, domStyle, domConstruct, _Widget, _Templated, _Container, ContentPane, Connection, template, headerTemplate, i18nViewer) { |
---|
18 | |
---|
19 | dojo.experimental("dojox.atom.widget.FeedEntryViewer"); |
---|
20 | |
---|
21 | var widget = dojo.getObject("dojox.atom.widget", true); |
---|
22 | |
---|
23 | widget.FeedEntryViewer = dojo.declare(/*===== "dojox.atom.widget.FeedEntryViewer", =====*/ [_Widget, _Templated, _Container],{ |
---|
24 | // summary: |
---|
25 | // An ATOM feed entry editor for publishing updated ATOM entries, or viewing non-editable entries. |
---|
26 | // description: |
---|
27 | // An ATOM feed entry editor for publishing updated ATOM entries, or viewing non-editable entries. |
---|
28 | entrySelectionTopic: "", //The topic to listen on for entries to edit. |
---|
29 | |
---|
30 | _validEntryFields: {}, //The entry fields that were present on the entry and are being displayed. |
---|
31 | //This works in conjuntion with what is selected to be displayed. |
---|
32 | displayEntrySections: "", //What current sections of the entries to display as a comma separated list. |
---|
33 | _displayEntrySections: null, |
---|
34 | |
---|
35 | //Control options for the display options menu. |
---|
36 | enableMenu: false, |
---|
37 | enableMenuFade: false, |
---|
38 | _optionButtonDisplayed: true, |
---|
39 | |
---|
40 | //Templates for the HTML rendering. Need to figure these out better, admittedly. |
---|
41 | templateString: template, |
---|
42 | |
---|
43 | _entry: null, //The entry that is being viewed/edited. |
---|
44 | _feed: null, //The feed the entry came from. |
---|
45 | |
---|
46 | _editMode: false, //Flag denoting the state of the widget, in edit mode or not. |
---|
47 | |
---|
48 | postCreate: function(){ |
---|
49 | if(this.entrySelectionTopic !== ""){ |
---|
50 | this._subscriptions = [dojo.subscribe(this.entrySelectionTopic, this, "_handleEvent")]; |
---|
51 | } |
---|
52 | var _nlsResources = i18nViewer; |
---|
53 | this.displayOptions.innerHTML = _nlsResources.displayOptions; |
---|
54 | this.feedEntryCheckBoxLabelTitle.innerHTML = _nlsResources.title; |
---|
55 | this.feedEntryCheckBoxLabelAuthors.innerHTML = _nlsResources.authors; |
---|
56 | this.feedEntryCheckBoxLabelContributors.innerHTML = _nlsResources.contributors; |
---|
57 | this.feedEntryCheckBoxLabelId.innerHTML = _nlsResources.id; |
---|
58 | this.close.innerHTML = _nlsResources.close; |
---|
59 | this.feedEntryCheckBoxLabelUpdated.innerHTML = _nlsResources.updated; |
---|
60 | this.feedEntryCheckBoxLabelSummary.innerHTML = _nlsResources.summary; |
---|
61 | this.feedEntryCheckBoxLabelContent.innerHTML = _nlsResources.content; |
---|
62 | }, |
---|
63 | |
---|
64 | startup: function(){ |
---|
65 | if(this.displayEntrySections === ""){ |
---|
66 | this._displayEntrySections = ["title","authors","contributors","summary","content","id","updated"]; |
---|
67 | }else{ |
---|
68 | this._displayEntrySections = this.displayEntrySections.split(","); |
---|
69 | } |
---|
70 | this._setDisplaySectionsCheckboxes(); |
---|
71 | |
---|
72 | if(this.enableMenu){ |
---|
73 | domStyle.set(this.feedEntryViewerMenu, 'display', ''); |
---|
74 | if(this.entryCheckBoxRow && this.entryCheckBoxRow2){ |
---|
75 | if(this.enableMenuFade){ |
---|
76 | fx.fadeOut({node: this.entryCheckBoxRow,duration: 250}).play(); |
---|
77 | fx.fadeOut({node: this.entryCheckBoxRow2,duration: 250}).play(); |
---|
78 | } |
---|
79 | } |
---|
80 | } |
---|
81 | }, |
---|
82 | |
---|
83 | clear: function(){ |
---|
84 | // summary: |
---|
85 | // Function to clear the state of the widget. |
---|
86 | // description: |
---|
87 | // Function to clear the state of the widget. |
---|
88 | this.destroyDescendants(); |
---|
89 | this._entry=null; |
---|
90 | this._feed=null; |
---|
91 | this.clearNodes(); |
---|
92 | }, |
---|
93 | |
---|
94 | clearNodes: function(){ |
---|
95 | // summary: |
---|
96 | // Function to clear all the display nodes for the ATOM entry from the viewer. |
---|
97 | // description: |
---|
98 | // Function to clear all the display nodes for the ATOM entry from the viewer. |
---|
99 | |
---|
100 | arrayUtil.forEach([ |
---|
101 | "entryTitleRow", "entryAuthorRow", "entryContributorRow", "entrySummaryRow", "entryContentRow", |
---|
102 | "entryIdRow", "entryUpdatedRow" |
---|
103 | ], function(node){ |
---|
104 | domStyle.set(this[node], "display", "none"); |
---|
105 | }, this); |
---|
106 | |
---|
107 | arrayUtil.forEach([ |
---|
108 | "entryTitleNode", "entryTitleHeader", "entryAuthorHeader", "entryContributorHeader", |
---|
109 | "entryContributorNode", "entrySummaryHeader", "entrySummaryNode", "entryContentHeader", |
---|
110 | "entryContentNode", "entryIdNode", "entryIdHeader", "entryUpdatedHeader", "entryUpdatedNode" |
---|
111 | ], function(part){ |
---|
112 | while(this[part].firstChild){ |
---|
113 | domConstruct.destroy(this[part].firstChild); |
---|
114 | } |
---|
115 | } |
---|
116 | ,this); |
---|
117 | |
---|
118 | }, |
---|
119 | |
---|
120 | setEntry: function(/*object*/entry, /*object*/feed, /*boolean*/leaveMenuState){ |
---|
121 | // summary: |
---|
122 | // Function to set the current entry that is being edited. |
---|
123 | // description: |
---|
124 | // Function to set the current entry that is being edited. |
---|
125 | // |
---|
126 | // entry: |
---|
127 | // Instance of dojox.atom.io.model.Entry to display for reading/editing. |
---|
128 | this.clear(); |
---|
129 | this._validEntryFields = {}; |
---|
130 | this._entry = entry; |
---|
131 | this._feed = feed; |
---|
132 | |
---|
133 | if(entry !== null){ |
---|
134 | // Handle the title. |
---|
135 | if(this.entryTitleHeader){ |
---|
136 | this.setTitleHeader(this.entryTitleHeader, entry); |
---|
137 | } |
---|
138 | |
---|
139 | if(this.entryTitleNode){ |
---|
140 | this.setTitle(this.entryTitleNode, this._editMode, entry); |
---|
141 | } |
---|
142 | |
---|
143 | if(this.entryAuthorHeader){ |
---|
144 | this.setAuthorsHeader(this.entryAuthorHeader, entry); |
---|
145 | } |
---|
146 | |
---|
147 | if(this.entryAuthorNode){ |
---|
148 | this.setAuthors(this.entryAuthorNode, this._editMode, entry); |
---|
149 | } |
---|
150 | |
---|
151 | if(this.entryContributorHeader){ |
---|
152 | this.setContributorsHeader(this.entryContributorHeader, entry); |
---|
153 | } |
---|
154 | |
---|
155 | if(this.entryContributorNode){ |
---|
156 | this.setContributors(this.entryContributorNode, this._editMode, entry); |
---|
157 | } |
---|
158 | |
---|
159 | if(this.entryIdHeader){ |
---|
160 | this.setIdHeader(this.entryIdHeader, entry); |
---|
161 | } |
---|
162 | |
---|
163 | if(this.entryIdNode){ |
---|
164 | this.setId(this.entryIdNode, this._editMode, entry); |
---|
165 | } |
---|
166 | |
---|
167 | if(this.entryUpdatedHeader){ |
---|
168 | this.setUpdatedHeader(this.entryUpdatedHeader, entry); |
---|
169 | } |
---|
170 | |
---|
171 | if(this.entryUpdatedNode){ |
---|
172 | this.setUpdated(this.entryUpdatedNode, this._editMode, entry); |
---|
173 | } |
---|
174 | |
---|
175 | if(this.entrySummaryHeader){ |
---|
176 | this.setSummaryHeader(this.entrySummaryHeader, entry); |
---|
177 | } |
---|
178 | |
---|
179 | if(this.entrySummaryNode){ |
---|
180 | this.setSummary(this.entrySummaryNode, this._editMode, entry); |
---|
181 | } |
---|
182 | |
---|
183 | if(this.entryContentHeader){ |
---|
184 | this.setContentHeader(this.entryContentHeader, entry); |
---|
185 | } |
---|
186 | |
---|
187 | if(this.entryContentNode){ |
---|
188 | this.setContent(this.entryContentNode, this._editMode, entry); |
---|
189 | } |
---|
190 | } |
---|
191 | this._displaySections(); |
---|
192 | }, |
---|
193 | |
---|
194 | setTitleHeader: function(/*DOM node*/titleHeaderNode, /*object*/entry){ |
---|
195 | // summary: |
---|
196 | // Function to set the contents of the title header node in the template to some value. |
---|
197 | // description: |
---|
198 | // Function to set the contents of the title header node in the template to some value. |
---|
199 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
200 | // |
---|
201 | // titleAchorNode: |
---|
202 | // The DOM node to attach the title data to. |
---|
203 | // editMode: |
---|
204 | // Boolean to indicate if the display should be in edit mode or not. |
---|
205 | // entry: |
---|
206 | // The Feed Entry to work with. |
---|
207 | // |
---|
208 | if(entry.title && entry.title.value && entry.title.value !== null){ |
---|
209 | var _nlsResources = i18nViewer; |
---|
210 | var titleHeader = new widget.EntryHeader({title: _nlsResources.title}); |
---|
211 | titleHeaderNode.appendChild(titleHeader.domNode); |
---|
212 | } |
---|
213 | }, |
---|
214 | |
---|
215 | setTitle: function(titleAnchorNode, editMode, entry){ |
---|
216 | // summary: |
---|
217 | // Function to set the contents of the title node in the template to some value from the entry. |
---|
218 | // description: |
---|
219 | // Function to set the contents of the title node in the template to some value from the entry. |
---|
220 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
221 | // |
---|
222 | // titleAchorNode: |
---|
223 | // The DOM node to attach the title data to. |
---|
224 | // editMode: |
---|
225 | // Boolean to indicate if the display should be in edit mode or not. |
---|
226 | // entry: |
---|
227 | // The Feed Entry to work with. |
---|
228 | if(entry.title && entry.title.value && entry.title.value !== null){ |
---|
229 | if(entry.title.type == "text"){ |
---|
230 | var titleNode = document.createTextNode(entry.title.value); |
---|
231 | titleAnchorNode.appendChild(titleNode); |
---|
232 | }else{ |
---|
233 | var titleViewNode = document.createElement("span"); |
---|
234 | var titleView = new ContentPane({refreshOnShow: true, executeScripts: false}, titleViewNode); |
---|
235 | titleView.attr('content', entry.title.value); |
---|
236 | titleAnchorNode.appendChild(titleView.domNode); |
---|
237 | } |
---|
238 | this.setFieldValidity("title", true); |
---|
239 | } |
---|
240 | }, |
---|
241 | |
---|
242 | setAuthorsHeader: function(/*DOM node*/authorHeaderNode, /*object*/entry){ |
---|
243 | // summary: |
---|
244 | // Function to set the title format for the authors section of the author row in the template to some value from the entry. |
---|
245 | // description: |
---|
246 | // Function to set the title format for the authors section of the author row in the template to some value from the entry. |
---|
247 | // This exists specifically so users can over-ride how the author data is filled out from an entry. |
---|
248 | // |
---|
249 | // authorHeaderNode: |
---|
250 | // The DOM node to attach the author section header data to. |
---|
251 | // entry: |
---|
252 | // The Feed Entry to work with. |
---|
253 | if(entry.authors && entry.authors.length > 0){ |
---|
254 | var _nlsResources = i18nViewer; |
---|
255 | var authorHeader = new widget.EntryHeader({title: _nlsResources.authors}); |
---|
256 | authorHeaderNode.appendChild(authorHeader.domNode); |
---|
257 | } |
---|
258 | }, |
---|
259 | |
---|
260 | setAuthors: function(/*DOM node*/authorsAnchorNode, /*boolean*/editMode, /*object*/entry){ |
---|
261 | // summary: |
---|
262 | // Function to set the contents of the author node in the template to some value from the entry. |
---|
263 | // description: |
---|
264 | // Function to set the contents of the author node in the template to some value from the entry. |
---|
265 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
266 | // |
---|
267 | // authorsAchorNode: |
---|
268 | // The DOM node to attach the author data to. |
---|
269 | // editMode: |
---|
270 | // Boolean to indicate if the display should be in edit mode or not. |
---|
271 | // entry: |
---|
272 | // The Feed Entry to work with. |
---|
273 | authorsAnchorNode.innerHTML = ""; |
---|
274 | if(entry.authors && entry.authors.length > 0){ |
---|
275 | for(var i in entry.authors){ |
---|
276 | if(entry.authors[i].name){ |
---|
277 | var anchor = authorsAnchorNode; |
---|
278 | if(entry.authors[i].uri){ |
---|
279 | var link = document.createElement("a"); |
---|
280 | anchor.appendChild(link); |
---|
281 | link.href = entry.authors[i].uri; |
---|
282 | anchor = link; |
---|
283 | } |
---|
284 | var name = entry.authors[i].name; |
---|
285 | if(entry.authors[i].email){ |
---|
286 | name = name + " (" + entry.authors[i].email + ")"; |
---|
287 | } |
---|
288 | var authorNode = document.createTextNode(name); |
---|
289 | anchor.appendChild(authorNode); |
---|
290 | var breakNode = document.createElement("br"); |
---|
291 | authorsAnchorNode.appendChild(breakNode); |
---|
292 | this.setFieldValidity("authors", true); |
---|
293 | } |
---|
294 | } |
---|
295 | } |
---|
296 | }, |
---|
297 | |
---|
298 | setContributorsHeader: function(/*DOM node*/contributorsHeaderNode, /*object*/entry){ |
---|
299 | // summary: |
---|
300 | // Function to set the contents of the contributor header node in the template to some value from the entry. |
---|
301 | // description: |
---|
302 | // Function to set the contents of the contributor header node in the template to some value from the entry. |
---|
303 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
304 | // |
---|
305 | // contributorsHeaderNode: |
---|
306 | // The DOM node to attach the contributor title to. |
---|
307 | // entry: |
---|
308 | // The Feed Entry to work with. |
---|
309 | if(entry.contributors && entry.contributors.length > 0){ |
---|
310 | var _nlsResources = i18nViewer; |
---|
311 | var contributorHeader = new widget.EntryHeader({title: _nlsResources.contributors}); |
---|
312 | contributorsHeaderNode.appendChild(contributorHeader.domNode); |
---|
313 | } |
---|
314 | }, |
---|
315 | |
---|
316 | |
---|
317 | setContributors: function(/*DOM node*/contributorsAnchorNode, /*boolean*/editMode, /*object*/entry){ |
---|
318 | // summary: |
---|
319 | // Function to set the contents of the contributor node in the template to some value from the entry. |
---|
320 | // description: |
---|
321 | // Function to set the contents of the contributor node in the template to some value from the entry. |
---|
322 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
323 | // |
---|
324 | // contributorsAnchorNode: |
---|
325 | // The DOM node to attach the contributor data to. |
---|
326 | // editMode: |
---|
327 | // Boolean to indicate if the display should be in edit mode or not. |
---|
328 | // entry: |
---|
329 | // The Feed Entry to work with. |
---|
330 | if(entry.contributors && entry.contributors.length > 0){ |
---|
331 | for(var i in entry.contributors){ |
---|
332 | var contributorNode = document.createTextNode(entry.contributors[i].name); |
---|
333 | contributorsAnchorNode.appendChild(contributorNode); |
---|
334 | var breakNode = document.createElement("br"); |
---|
335 | contributorsAnchorNode.appendChild(breakNode); |
---|
336 | this.setFieldValidity("contributors", true); |
---|
337 | } |
---|
338 | } |
---|
339 | }, |
---|
340 | |
---|
341 | |
---|
342 | setIdHeader: function(/*DOM node*/idHeaderNode, /*object*/entry){ |
---|
343 | // summary: |
---|
344 | // Function to set the contents of the ID node in the template to some value from the entry. |
---|
345 | // description: |
---|
346 | // Function to set the contents of the ID node in the template to some value from the entry. |
---|
347 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
348 | // |
---|
349 | // idAnchorNode: |
---|
350 | // The DOM node to attach the ID data to. |
---|
351 | // entry: |
---|
352 | // The Feed Entry to work with. |
---|
353 | if(entry.id && entry.id !== null){ |
---|
354 | var _nlsResources = i18nViewer; |
---|
355 | var idHeader = new widget.EntryHeader({title: _nlsResources.id}); |
---|
356 | idHeaderNode.appendChild(idHeader.domNode); |
---|
357 | } |
---|
358 | }, |
---|
359 | |
---|
360 | |
---|
361 | setId: function(/*DOM node*/idAnchorNode, /*boolean*/editMode, /*object*/entry){ |
---|
362 | // summary: |
---|
363 | // Function to set the contents of the ID node in the template to some value from the entry. |
---|
364 | // description: |
---|
365 | // Function to set the contents of the ID node in the template to some value from the entry. |
---|
366 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
367 | // |
---|
368 | // idAnchorNode: |
---|
369 | // The DOM node to attach the ID data to. |
---|
370 | // editMode: |
---|
371 | // Boolean to indicate if the display should be in edit mode or not. |
---|
372 | // entry: |
---|
373 | // The Feed Entry to work with. |
---|
374 | if(entry.id && entry.id !== null){ |
---|
375 | var idNode = document.createTextNode(entry.id); |
---|
376 | idAnchorNode.appendChild(idNode); |
---|
377 | this.setFieldValidity("id", true); |
---|
378 | } |
---|
379 | }, |
---|
380 | |
---|
381 | setUpdatedHeader: function(/*DOM node*/updatedHeaderNode, /*object*/entry){ |
---|
382 | // summary: |
---|
383 | // Function to set the contents of the updated header node in the template to some value from the entry. |
---|
384 | // description: |
---|
385 | // Function to set the contents of the updated header node in the template to some value from the entry. |
---|
386 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
387 | // |
---|
388 | // updatedHeaderNode: |
---|
389 | // The DOM node to attach the updated header data to. |
---|
390 | // entry: |
---|
391 | // The Feed Entry to work with. |
---|
392 | if(entry.updated && entry.updated !== null){ |
---|
393 | var _nlsResources = i18nViewer; |
---|
394 | var updatedHeader = new widget.EntryHeader({title: _nlsResources.updated}); |
---|
395 | updatedHeaderNode.appendChild(updatedHeader.domNode); |
---|
396 | } |
---|
397 | }, |
---|
398 | |
---|
399 | setUpdated: function(/*DOM node*/updatedAnchorNode, /*boolean*/editMode, /*object*/entry){ |
---|
400 | // summary: |
---|
401 | // Function to set the contents of the updated node in the template to some value from the entry. |
---|
402 | // description: |
---|
403 | // Function to set the contents of the updated node in the template to some value from the entry. |
---|
404 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
405 | // |
---|
406 | // updatedAnchorNode: |
---|
407 | // The DOM node to attach the udpated data to. |
---|
408 | // editMode: |
---|
409 | // Boolean to indicate if the display should be in edit mode or not. |
---|
410 | // entry: |
---|
411 | // The Feed Entry to work with. |
---|
412 | if(entry.updated && entry.updated !== null){ |
---|
413 | var updatedNode = document.createTextNode(entry.updated); |
---|
414 | updatedAnchorNode.appendChild(updatedNode); |
---|
415 | this.setFieldValidity("updated", true); |
---|
416 | } |
---|
417 | }, |
---|
418 | |
---|
419 | setSummaryHeader: function(/*DOM node*/summaryHeaderNode, /*object*/entry){ |
---|
420 | // summary: |
---|
421 | // Function to set the contents of the summary node in the template to some value from the entry. |
---|
422 | // description: |
---|
423 | // Function to set the contents of the summary node in the template to some value from the entry. |
---|
424 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
425 | // |
---|
426 | // summaryHeaderNode: |
---|
427 | // The DOM node to attach the summary title to. |
---|
428 | // entry: |
---|
429 | // The Feed Entry to work with. |
---|
430 | if(entry.summary && entry.summary.value && entry.summary.value !== null){ |
---|
431 | var _nlsResources = i18nViewer; |
---|
432 | var summaryHeader = new widget.EntryHeader({title: _nlsResources.summary}); |
---|
433 | summaryHeaderNode.appendChild(summaryHeader.domNode); |
---|
434 | } |
---|
435 | }, |
---|
436 | |
---|
437 | |
---|
438 | setSummary: function(/*DOM node*/summaryAnchorNode, /*boolean*/editMode, /*object*/entry){ |
---|
439 | // summary: |
---|
440 | // Function to set the contents of the summary node in the template to some value from the entry. |
---|
441 | // description: |
---|
442 | // Function to set the contents of the summary node in the template to some value from the entry. |
---|
443 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
444 | // |
---|
445 | // summaryAnchorNode: |
---|
446 | // The DOM node to attach the summary data to. |
---|
447 | // editMode: |
---|
448 | // Boolean to indicate if the display should be in edit mode or not. |
---|
449 | // entry: |
---|
450 | // The Feed Entry to work with. |
---|
451 | if(entry.summary && entry.summary.value && entry.summary.value !== null){ |
---|
452 | var summaryViewNode = document.createElement("span"); |
---|
453 | var summaryView = new ContentPane({refreshOnShow: true, executeScripts: false}, summaryViewNode); |
---|
454 | summaryView.attr('content', entry.summary.value); |
---|
455 | summaryAnchorNode.appendChild(summaryView.domNode); |
---|
456 | this.setFieldValidity("summary", true); |
---|
457 | } |
---|
458 | }, |
---|
459 | |
---|
460 | setContentHeader: function(/*DOM node*/contentHeaderNode, /*object*/entry){ |
---|
461 | // summary: |
---|
462 | // Function to set the contents of the content node in the template to some value from the entry. |
---|
463 | // description: |
---|
464 | // Function to set the contents of the content node in the template to some value from the entry. |
---|
465 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
466 | // |
---|
467 | // contentHeaderNode: |
---|
468 | // The DOM node to attach the content data to. |
---|
469 | // entry: |
---|
470 | // The Feed Entry to work with. |
---|
471 | if(entry.content && entry.content.value && entry.content.value !== null){ |
---|
472 | var _nlsResources = i18nViewer; |
---|
473 | var contentHeader = new widget.EntryHeader({title: _nlsResources.content}); |
---|
474 | contentHeaderNode.appendChild(contentHeader.domNode); |
---|
475 | } |
---|
476 | }, |
---|
477 | |
---|
478 | setContent: function(/*DOM node*/contentAnchorNode, /*boolean*/editMode, /*object*/entry){ |
---|
479 | // summary: |
---|
480 | // Function to set the contents of the content node in the template to some value from the entry. |
---|
481 | // description: |
---|
482 | // Function to set the contents of the content node in the template to some value from the entry. |
---|
483 | // This exists specifically so users can over-ride how the title data is filled out from an entry. |
---|
484 | // |
---|
485 | // contentAnchorNode: |
---|
486 | // The DOM node to attach the content data to. |
---|
487 | // editMode: |
---|
488 | // Boolean to indicate if the display should be in edit mode or not. |
---|
489 | // entry: |
---|
490 | // The Feed Entry to work with. |
---|
491 | if(entry.content && entry.content.value && entry.content.value !== null){ |
---|
492 | var contentViewNode = document.createElement("span"); |
---|
493 | var contentView = new ContentPane({refreshOnShow: true, executeScripts: false},contentViewNode); |
---|
494 | contentView.attr('content', entry.content.value); |
---|
495 | contentAnchorNode.appendChild(contentView.domNode); |
---|
496 | this.setFieldValidity("content", true); |
---|
497 | } |
---|
498 | }, |
---|
499 | |
---|
500 | |
---|
501 | _displaySections: function(){ |
---|
502 | // summary: |
---|
503 | // Internal function for determining which sections of the view to actually display. |
---|
504 | // description: |
---|
505 | // Internal function for determining which sections of the view to actually display. |
---|
506 | // |
---|
507 | // returns: |
---|
508 | // Nothing. |
---|
509 | domStyle.set(this.entryTitleRow, 'display', 'none'); |
---|
510 | domStyle.set(this.entryAuthorRow, 'display', 'none'); |
---|
511 | domStyle.set(this.entryContributorRow, 'display', 'none'); |
---|
512 | domStyle.set(this.entrySummaryRow, 'display', 'none'); |
---|
513 | domStyle.set(this.entryContentRow, 'display', 'none'); |
---|
514 | domStyle.set(this.entryIdRow, 'display', 'none'); |
---|
515 | domStyle.set(this.entryUpdatedRow, 'display', 'none'); |
---|
516 | |
---|
517 | for(var i in this._displayEntrySections){ |
---|
518 | var section = this._displayEntrySections[i].toLowerCase(); |
---|
519 | if(section === "title" && this.isFieldValid("title")){ |
---|
520 | domStyle.set(this.entryTitleRow, 'display', ''); |
---|
521 | } |
---|
522 | if(section === "authors" && this.isFieldValid("authors")){ |
---|
523 | domStyle.set(this.entryAuthorRow, 'display', ''); |
---|
524 | } |
---|
525 | if(section === "contributors" && this.isFieldValid("contributors")){ |
---|
526 | domStyle.set(this.entryContributorRow, 'display', ''); |
---|
527 | } |
---|
528 | if(section === "summary" && this.isFieldValid("summary")){ |
---|
529 | domStyle.set(this.entrySummaryRow, 'display', ''); |
---|
530 | } |
---|
531 | if(section === "content" && this.isFieldValid("content")){ |
---|
532 | domStyle.set(this.entryContentRow, 'display', ''); |
---|
533 | } |
---|
534 | if(section === "id" && this.isFieldValid("id")){ |
---|
535 | domStyle.set(this.entryIdRow, 'display', ''); |
---|
536 | } |
---|
537 | if(section === "updated" && this.isFieldValid("updated")){ |
---|
538 | domStyle.set(this.entryUpdatedRow, 'display', ''); |
---|
539 | } |
---|
540 | |
---|
541 | } |
---|
542 | }, |
---|
543 | |
---|
544 | setDisplaySections: function(/*array*/sectionsArray){ |
---|
545 | // summary: |
---|
546 | // Function for setting which sections of the entry should be displayed. |
---|
547 | // description: |
---|
548 | // Function for setting which sections of the entry should be displayed. |
---|
549 | // |
---|
550 | // sectionsArray: |
---|
551 | // Array of string names that indicate which sections to display. |
---|
552 | // |
---|
553 | // returns: |
---|
554 | // Nothing. |
---|
555 | if(sectionsArray !== null){ |
---|
556 | this._displayEntrySections = sectionsArray; |
---|
557 | this._displaySections(); |
---|
558 | }else{ |
---|
559 | this._displayEntrySections = ["title","authors","contributors","summary","content","id","updated"]; |
---|
560 | } |
---|
561 | }, |
---|
562 | |
---|
563 | _setDisplaySectionsCheckboxes: function(){ |
---|
564 | // summary: |
---|
565 | // Internal function for setting which checkboxes on the display are selected. |
---|
566 | // description: |
---|
567 | // Internal function for setting which checkboxes on the display are selected. |
---|
568 | // |
---|
569 | // returns: |
---|
570 | // Nothing. |
---|
571 | var items = ["title","authors","contributors","summary","content","id","updated"]; |
---|
572 | for(var i in items){ |
---|
573 | if(arrayUtil.indexOf(this._displayEntrySections, items[i]) == -1){ |
---|
574 | domStyle.set(this["feedEntryCell"+items[i]], 'display', 'none'); |
---|
575 | }else{ |
---|
576 | this["feedEntryCheckBox"+items[i].substring(0,1).toUpperCase()+items[i].substring(1)].checked=true; |
---|
577 | } |
---|
578 | } |
---|
579 | }, |
---|
580 | |
---|
581 | _readDisplaySections: function(){ |
---|
582 | // summary: |
---|
583 | // Internal function for reading what is currently checked for display and generating the display list from it. |
---|
584 | // description: |
---|
585 | // Internal function for reading what is currently checked for display and generating the display list from it. |
---|
586 | // |
---|
587 | // returns: |
---|
588 | // Nothing. |
---|
589 | var checkedList = []; |
---|
590 | |
---|
591 | if(this.feedEntryCheckBoxTitle.checked){ |
---|
592 | checkedList.push("title"); |
---|
593 | } |
---|
594 | if(this.feedEntryCheckBoxAuthors.checked){ |
---|
595 | checkedList.push("authors"); |
---|
596 | } |
---|
597 | if(this.feedEntryCheckBoxContributors.checked){ |
---|
598 | checkedList.push("contributors"); |
---|
599 | } |
---|
600 | if(this.feedEntryCheckBoxSummary.checked){ |
---|
601 | checkedList.push("summary"); |
---|
602 | } |
---|
603 | if(this.feedEntryCheckBoxContent.checked){ |
---|
604 | checkedList.push("content"); |
---|
605 | } |
---|
606 | if(this.feedEntryCheckBoxId.checked){ |
---|
607 | checkedList.push("id"); |
---|
608 | } |
---|
609 | if(this.feedEntryCheckBoxUpdated.checked){ |
---|
610 | checkedList.push("updated"); |
---|
611 | } |
---|
612 | this._displayEntrySections = checkedList; |
---|
613 | }, |
---|
614 | |
---|
615 | _toggleCheckbox: function(/*object*/checkBox){ |
---|
616 | // summary: |
---|
617 | // Internal function for determining of a particular entry is editable. |
---|
618 | // description: |
---|
619 | // Internal function for determining of a particular entry is editable. |
---|
620 | // This is used for determining if the delete action should be displayed or not. |
---|
621 | // |
---|
622 | // checkBox: |
---|
623 | // The checkbox object to toggle the selection on. |
---|
624 | // |
---|
625 | // returns: |
---|
626 | // Nothing |
---|
627 | if(checkBox.checked){ |
---|
628 | checkBox.checked=false; |
---|
629 | }else{ |
---|
630 | checkBox.checked=true; |
---|
631 | } |
---|
632 | this._readDisplaySections(); |
---|
633 | this._displaySections(); |
---|
634 | }, |
---|
635 | |
---|
636 | _toggleOptions: function(/*object*/checkBox){ |
---|
637 | // summary: |
---|
638 | // Internal function for determining of a particular entry is editable. |
---|
639 | // description: |
---|
640 | // Internal function for determining of a particular entry is editable. |
---|
641 | // This is used for determining if the delete action should be displayed or not. |
---|
642 | // |
---|
643 | // checkBox: |
---|
644 | // The checkbox object to toggle the selection on. |
---|
645 | // |
---|
646 | // returns: |
---|
647 | // Nothing |
---|
648 | if(this.enableMenu){ |
---|
649 | var fade = null; |
---|
650 | var anim; |
---|
651 | var anim2; |
---|
652 | if(this._optionButtonDisplayed){ |
---|
653 | if(this.enableMenuFade){ |
---|
654 | anim = fx.fadeOut({node: this.entryCheckBoxDisplayOptions,duration: 250}); |
---|
655 | connect.connect(anim, "onEnd", this, function(){ |
---|
656 | domStyle.set(this.entryCheckBoxDisplayOptions, 'display', 'none'); |
---|
657 | domStyle.set(this.entryCheckBoxRow, 'display', ''); |
---|
658 | domStyle.set(this.entryCheckBoxRow2, 'display', ''); |
---|
659 | fx.fadeIn({node: this.entryCheckBoxRow, duration: 250}).play(); |
---|
660 | fx.fadeIn({node: this.entryCheckBoxRow2, duration: 250}).play(); |
---|
661 | }); |
---|
662 | anim.play(); |
---|
663 | }else{ |
---|
664 | domStyle.set(this.entryCheckBoxDisplayOptions, 'display', 'none'); |
---|
665 | domStyle.set(this.entryCheckBoxRow, 'display', ''); |
---|
666 | domStyle.set(this.entryCheckBoxRow2, 'display', ''); |
---|
667 | } |
---|
668 | this._optionButtonDisplayed=false; |
---|
669 | }else{ |
---|
670 | if(this.enableMenuFade){ |
---|
671 | anim = fx.fadeOut({node: this.entryCheckBoxRow,duration: 250}); |
---|
672 | anim2 = fx.fadeOut({node: this.entryCheckBoxRow2,duration: 250}); |
---|
673 | connect.connect(anim, "onEnd", this, function(){ |
---|
674 | domStyle.set(this.entryCheckBoxRow, 'display', 'none'); |
---|
675 | domStyle.set(this.entryCheckBoxRow2, 'display', 'none'); |
---|
676 | domStyle.set(this.entryCheckBoxDisplayOptions, 'display', ''); |
---|
677 | fx.fadeIn({node: this.entryCheckBoxDisplayOptions, duration: 250}).play(); |
---|
678 | }); |
---|
679 | anim.play(); |
---|
680 | anim2.play(); |
---|
681 | }else{ |
---|
682 | domStyle.set(this.entryCheckBoxRow, 'display', 'none'); |
---|
683 | domStyle.set(this.entryCheckBoxRow2, 'display', 'none'); |
---|
684 | domStyle.set(this.entryCheckBoxDisplayOptions, 'display', ''); |
---|
685 | } |
---|
686 | this._optionButtonDisplayed=true; |
---|
687 | } |
---|
688 | } |
---|
689 | }, |
---|
690 | |
---|
691 | _handleEvent: function(/*object*/entrySelectionEvent){ |
---|
692 | // summary: |
---|
693 | // Internal function for listening to a topic that will handle entry notification. |
---|
694 | // description: |
---|
695 | // Internal function for listening to a topic that will handle entry notification. |
---|
696 | // |
---|
697 | // entrySelectionEvent: |
---|
698 | // The topic message containing the entry that was selected for view. |
---|
699 | // |
---|
700 | // returns: |
---|
701 | // Nothing. |
---|
702 | if(entrySelectionEvent.source != this){ |
---|
703 | if(entrySelectionEvent.action == "set" && entrySelectionEvent.entry){ |
---|
704 | this.setEntry(entrySelectionEvent.entry, entrySelectionEvent.feed); |
---|
705 | }else if(entrySelectionEvent.action == "delete" && entrySelectionEvent.entry && entrySelectionEvent.entry == this._entry){ |
---|
706 | this.clear(); |
---|
707 | } |
---|
708 | } |
---|
709 | }, |
---|
710 | |
---|
711 | setFieldValidity: function(/*string*/field, /*boolean*/isValid){ |
---|
712 | // summary: |
---|
713 | // Function to set whether a field in the view is valid and displayable. |
---|
714 | // description: |
---|
715 | // Function to set whether a field in the view is valid and displayable. |
---|
716 | // This is needed for over-riding of the set* functions and customization of how data is displayed in the attach point. |
---|
717 | // So if custom implementations use their own display logic, they can still enable the field. |
---|
718 | // |
---|
719 | // field: |
---|
720 | // The field name to set the valid parameter on. Such as 'content', 'id', etc. |
---|
721 | // isValid: |
---|
722 | // Flag denoting if the field is valid or not. |
---|
723 | // |
---|
724 | // returns: |
---|
725 | // Nothing. |
---|
726 | if(field){ |
---|
727 | var lowerField = field.toLowerCase(); |
---|
728 | this._validEntryFields[field] = isValid; |
---|
729 | } |
---|
730 | }, |
---|
731 | |
---|
732 | isFieldValid: function(/*string*/field){ |
---|
733 | // summary: |
---|
734 | // Function to return if a displayable field is valid or not |
---|
735 | // description: |
---|
736 | // Function to return if a displayable field is valid or not |
---|
737 | // |
---|
738 | // field: |
---|
739 | // The field name to get the valid parameter of. Such as 'content', 'id', etc. |
---|
740 | // |
---|
741 | // returns: |
---|
742 | // boolean denoting if the field is valid and set. |
---|
743 | return this._validEntryFields[field.toLowerCase()]; |
---|
744 | }, |
---|
745 | |
---|
746 | getEntry: function(){ |
---|
747 | return this._entry; |
---|
748 | }, |
---|
749 | |
---|
750 | getFeed: function(){ |
---|
751 | return this._feed; |
---|
752 | }, |
---|
753 | |
---|
754 | destroy: function(){ |
---|
755 | this.clear(); |
---|
756 | arrayUtil.forEach(this._subscriptions, dojo.unsubscribe); |
---|
757 | } |
---|
758 | }); |
---|
759 | |
---|
760 | widget.EntryHeader = dojo.declare(/*===== "dojox.atom.widget.EntryHeader", =====*/ [_Widget, _Templated, _Container],{ |
---|
761 | // summary: |
---|
762 | // Widget representing a header in a FeedEntryViewer/Editor |
---|
763 | // description: |
---|
764 | // Widget representing a header in a FeedEntryViewer/Editor |
---|
765 | title: "", |
---|
766 | templateString: headerTemplate, |
---|
767 | |
---|
768 | postCreate: function(){ |
---|
769 | this.setListHeader(); |
---|
770 | }, |
---|
771 | |
---|
772 | setListHeader: function(/*string*/title){ |
---|
773 | this.clear(); |
---|
774 | if(title){ |
---|
775 | this.title = title; |
---|
776 | } |
---|
777 | var textNode = document.createTextNode(this.title); |
---|
778 | this.entryHeaderNode.appendChild(textNode); |
---|
779 | }, |
---|
780 | |
---|
781 | clear: function(){ |
---|
782 | this.destroyDescendants(); |
---|
783 | if(this.entryHeaderNode){ |
---|
784 | for(var i = 0; i < this.entryHeaderNode.childNodes.length; i++){ |
---|
785 | this.entryHeaderNode.removeChild(this.entryHeaderNode.childNodes[i]); |
---|
786 | } |
---|
787 | } |
---|
788 | }, |
---|
789 | |
---|
790 | destroy: function(){ |
---|
791 | this.clear(); |
---|
792 | } |
---|
793 | }); |
---|
794 | |
---|
795 | return widget.FeedEntryViewer; |
---|
796 | }); |
---|