FeedEntryViewer.js 36 KB

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