123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230 |
- if(!dojo._hasResource["dojox.atom.widget.FeedEntryEditor"]){
- dojo._hasResource["dojox.atom.widget.FeedEntryEditor"] = true;
- dojo.provide("dojox.atom.widget.FeedEntryEditor");
- dojo.require("dojox.atom.widget.FeedEntryViewer");
- dojo.require("dijit._Widget");
- dojo.require("dijit._Templated");
- dojo.require("dijit._Container");
- dojo.require("dijit.Editor");
- dojo.require("dijit.form.TextBox");
- dojo.require("dijit.form.SimpleTextarea");
- dojo.requireLocalization("dojox.atom.widget", "FeedEntryEditor", null, "ROOT,ar,az,bg,ca,cs,da,de,el,es,fi,fr,he,hr,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
- dojo.requireLocalization("dojox.atom.widget", "PeopleEditor", null, "ROOT,ar,az,bg,ca,cs,da,de,el,es,fi,fr,he,hr,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
- dojo.experimental("dojox.atom.widget.FeedEntryEditor");
- 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(){
- if(this.entrySelectionTopic !== ""){
- this._subscriptions = [dojo.subscribe(this.entrySelectionTopic, this, "_handleEvent")];
- }
- var _nlsResources = dojo.i18n.getLocalization("dojox.atom.widget", "FeedEntryViewer");
- this.displayOptions.innerHTML = _nlsResources.displayOptions;
- this.feedEntryCheckBoxLabelTitle.innerHTML = _nlsResources.title;
- this.feedEntryCheckBoxLabelAuthors.innerHTML = _nlsResources.authors;
- this.feedEntryCheckBoxLabelContributors.innerHTML = _nlsResources.contributors;
- this.feedEntryCheckBoxLabelId.innerHTML = _nlsResources.id;
- this.close.innerHTML = _nlsResources.close;
- this.feedEntryCheckBoxLabelUpdated.innerHTML = _nlsResources.updated;
- this.feedEntryCheckBoxLabelSummary.innerHTML = _nlsResources.summary;
- this.feedEntryCheckBoxLabelContent.innerHTML = _nlsResources.content;
- _nlsResources = dojo.i18n.getLocalization("dojox.atom.widget", "FeedEntryEditor");
- this.doNew.innerHTML = _nlsResources.doNew;
- this.edit.innerHTML = _nlsResources.edit;
- this.save.innerHTML = _nlsResources.save;
- this.cancel.innerHTML = _nlsResources.cancel;
- },
-
- setEntry: function(/*object*/entry, /*object*/feed, /*boolean*/leaveMenuState){
-
-
-
-
-
-
-
- if(this._entry !== entry){
-
- this._editMode=false;
- leaveMenuState=false;
- }else{
- leaveMenuState = true;
- }
- dojox.atom.widget.FeedEntryEditor.superclass.setEntry.call(this, entry, feed);
- this._editable = this._isEditable(entry);
- if(!leaveMenuState && !this._editable){
- dojo.style(this.entryEditButton, 'display', 'none');
- dojo.style(this.entrySaveCancelButtons, 'display', 'none');
- }
- if(this._editable && this.enableEdit){
- if(!leaveMenuState){
- dojo.style(this.entryEditButton, 'display', '');
-
- if(this.enableMenuFade && this.entrySaveCancelButton){
- dojo.fadeOut({node: this.entrySaveCancelButton,duration: 250}).play();
- }
- }
- }
- },
- _toggleEdit: function(){
-
-
-
-
-
-
-
- if(this._editable && this.enableEdit){
- dojo.style(this.entryEditButton, 'display', 'none');
- dojo.style(this.entrySaveCancelButtons, 'display', '');
- this._editMode = true;
-
- this.setEntry(this._entry, this._feed, true);
- }
- },
- _handleEvent: function(/*object*/entrySelectionEvent){
-
-
-
-
-
-
-
-
-
-
- if(entrySelectionEvent.source != this && entrySelectionEvent.action == "delete" &&
- entrySelectionEvent.entry && entrySelectionEvent.entry == this._entry){
- dojo.style(this.entryEditButton, 'display', 'none');
- }
- dojox.atom.widget.FeedEntryEditor.superclass._handleEvent.call(this, entrySelectionEvent);
- },
- _isEditable: function(/*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
- var retVal = false;
- if(entry && entry !== null && entry.links && entry.links !== null){
- for(var x in entry.links){
- if(entry.links[x].rel && entry.links[x].rel == "edit"){
- retVal = true;
- break;
- }
- }
- }
- return retVal;
- },
-
-
-
- setTitle: function(/*DOM node*/titleAnchorNode, /*boolean*/editMode, /*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(!editMode){
- dojox.atom.widget.FeedEntryEditor.superclass.setTitle.call(this, titleAnchorNode, editMode, entry);
- if(entry.title && entry.title.value && entry.title.value !== null){
- this.setFieldValidity("title", true);
- }
- }else{
- if(entry.title && entry.title.value && entry.title.value !== null){
- if(!this._toLoad){
- this._toLoad = [];
- }
- this.entryTitleSelect.value = entry.title.type;
-
- var editor = this._createEditor(titleAnchorNode, entry.title, true, entry.title.type === "html" || entry.title.type === "xhtml");
- editor.name = "title";
- this._toLoad.push(editor);
- this.setFieldValidity("titleedit",true);
- this.setFieldValidity("title",true);
- }
- }
- },
- setAuthors: function(/*DOM node*/authorsAnchorNode, /*boolean*/editMode, /*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
-
- if(!editMode){
- dojox.atom.widget.FeedEntryEditor.superclass.setAuthors.call(this, authorsAnchorNode, editMode, entry);
- if(entry.authors && entry.authors.length > 0){
- this.setFieldValidity("authors", true);
- }
- }else{
- if(entry.authors && entry.authors.length > 0){
- this._editors.authors = this._createPeopleEditor(this.entryAuthorNode, {data: entry.authors, name: "Author"});
- this.setFieldValidity("authors", true);
- }
- }
- },
- setContributors: function(/*DOM node*/contributorsAnchorNode, /*boolean*/editMode, /*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
-
- if(!editMode){
- dojox.atom.widget.FeedEntryEditor.superclass.setContributors.call(this, contributorsAnchorNode, editMode, entry);
- if(entry.contributors && entry.contributors.length > 0){
- this.setFieldValidity("contributors", true);
- }
- }else{
- if(entry.contributors && entry.contributors.length > 0){
- this._editors.contributors = this._createPeopleEditor(this.entryContributorNode, {data: entry.contributors, name: "Contributor"});
- this.setFieldValidity("contributors", true);
- }
- }
- },
- setId: function(/*DOM node*/idAnchorNode, /*boolean*/editMode, /*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
-
- if(!editMode){
- dojox.atom.widget.FeedEntryEditor.superclass.setId.call(this, idAnchorNode, editMode, entry);
- if(entry.id && entry.id !== null){
- this.setFieldValidity("id", true);
- }
- }else{
- if(entry.id && entry.id !== null){
- this._editors.id = this._createEditor(idAnchorNode, entry.id);
- this.setFieldValidity("id",true);
- }
- }
- },
- setUpdated: function(/*DOM node*/updatedAnchorNode, /*boolean*/editMode, /*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
-
- if(!editMode){
- dojox.atom.widget.FeedEntryEditor.superclass.setUpdated.call(this, updatedAnchorNode, editMode, entry);
- if(entry.updated && entry.updated !== null){
- this.setFieldValidity("updated", true);
- }
- }else{
- if(entry.updated && entry.updated !== null){
- this._editors.updated = this._createEditor(updatedAnchorNode, entry.updated);
- this.setFieldValidity("updated",true);
- }
- }
- },
- setSummary: function(/*DOM node*/summaryAnchorNode, /*boolean*/editMode, /*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
-
- if(!editMode){
- dojox.atom.widget.FeedEntryEditor.superclass.setSummary.call(this, summaryAnchorNode, editMode, entry);
- if(entry.summary && entry.summary.value && entry.summary.value !== null){
- this.setFieldValidity("summary", true);
- }
- }else{
- if(entry.summary && entry.summary.value && entry.summary.value !== null){
- if(!this._toLoad){
- this._toLoad = [];
- }
- this.entrySummarySelect.value = entry.summary.type;
-
- var editor = this._createEditor(summaryAnchorNode, entry.summary, true, entry.summary.type === "html" || entry.summary.type === "xhtml");
- editor.name = "summary";
- this._toLoad.push(editor);
- this.setFieldValidity("summaryedit",true);
- this.setFieldValidity("summary",true);
- }
- }
- },
- setContent: function(/*DOM node*/contentAnchorNode, /*boolean*/editMode, /*object*/entry){
-
-
-
-
-
-
-
-
-
-
-
-
- if(!editMode){
- dojox.atom.widget.FeedEntryEditor.superclass.setContent.call(this, contentAnchorNode, editMode, entry);
- if(entry.content && entry.content.value && entry.content.value !== null){
- this.setFieldValidity("content",true);
- }
- }else{
- if(entry.content && entry.content.value && entry.content.value !== null){
- if(!this._toLoad){
- this._toLoad = [];
- }
- this.entryContentSelect.value = entry.content.type;
- var editor = this._createEditor(contentAnchorNode, entry.content, true, entry.content.type === "html" || entry.content.type === "xhtml");
- editor.name = "content";
- this._toLoad.push(editor);
- this.setFieldValidity("contentedit",true);
- this.setFieldValidity("content",true);
- }
- }
- },
-
- _createEditor: function(/*DOM node*/anchorNode, /*DOM node*/node, /*boolean*/multiline, /*object*/rte){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var viewNode;
- var box;
- if(!node){
- if(rte){
-
-
- return {anchorNode: anchorNode,
- entryValue: "",
- editor: null,
- generateEditor: function(){
-
-
-
- var node = document.createElement("div");
- node.innerHTML = this.entryValue;
- this.anchorNode.appendChild(node);
- var _editor = new dijit.Editor({}, node);
- this.editor = _editor;
- return _editor;
- }
- };
- }
- if(multiline){
-
- viewNode = document.createElement("textarea");
- anchorNode.appendChild(viewNode);
- dojo.style(viewNode, 'width', '90%');
- box = new dijit.form.SimpleTextarea({},viewNode);
- }else{
-
- viewNode = document.createElement("input");
- anchorNode.appendChild(viewNode);
- dojo.style(viewNode, 'width', '95%');
- box = new dijit.form.TextBox({},viewNode);
- }
- box.attr('value', '');
- return box;
- }
-
- var value;
- if(node.value !== undefined){
- value = node.value;
- }else if(node.attr){
- value = node.attr('value');
- }else{
- value = node;
- }
- if(rte){
-
-
- if(value.indexOf("<") != -1){
- value = value.replace(/</g, "<");
- }
- return {anchorNode: anchorNode,
- entryValue: value,
- editor: null,
- generateEditor: function(){
-
-
-
- var node = document.createElement("div");
- node.innerHTML = this.entryValue;
- this.anchorNode.appendChild(node);
- var _editor = new dijit.Editor({}, node);
- this.editor = _editor;
- return _editor;
- }
- };
- }
- if(multiline){
-
- viewNode = document.createElement("textarea");
- anchorNode.appendChild(viewNode);
- dojo.style(viewNode, 'width', '90%');
- box = new dijit.form.SimpleTextarea({},viewNode);
- }else{
-
- viewNode = document.createElement("input");
- anchorNode.appendChild(viewNode);
- dojo.style(viewNode, 'width', '95%');
- box = new dijit.form.TextBox({},viewNode);
- }
- box.attr('value', value);
- return box;
- },
-
- _switchEditor: function(/*object*/event){
-
-
-
-
-
-
-
-
- var type = null;
- var target = null;
- var parent = null;
-
-
- if(dojo.isIE){
- target = event.srcElement;
- }else{
- target = event.target;
- }
-
-
- if(target === this.entryTitleSelect){
- parent = this.entryTitleNode;
- type = "title";
- } else if(target === this.entrySummarySelect){
- parent = this.entrySummaryNode;
- type = "summary";
- }else{
- parent = this.entryContentNode;
- type = "content";
- }
-
- var editor = this._editors[type];
- var newEditor;
- var value;
-
- if(target.value === "text"){
- if(editor.declaredClass === "dijit.Editor"){
-
-
- value = editor.attr('value', false);
- editor.close(false,true);
- editor.destroy();
- while(parent.firstChild){
- dojo.destroy(parent.firstChild);
- }
- newEditor = this._createEditor(parent, {value: value}, true, false);
- this._editors[type] = newEditor;
- }
- }else{
- if(editor.declaredClass != "dijit.Editor"){
-
-
- value = editor.attr('value');
- editor.destroy();
- while(parent.firstChild){
- dojo.destroy(parent.firstChild);
- }
- newEditor = this._createEditor(parent, {value: value}, true, true);
- newEditor = dojo.hitch(newEditor, newEditor.generateEditor)();
- this._editors[type] = newEditor;
- }
- }
- },
-
- _createPeopleEditor: function(/*DOM node*/anchorNode, /*DOM node*/node){
-
-
-
-
-
-
-
-
-
-
-
-
- var viewNode = document.createElement("div");
- anchorNode.appendChild(viewNode);
- return new dojox.atom.widget.PeopleEditor(node,viewNode);
- },
- saveEdits: function(){
-
-
-
-
-
-
-
-
-
- dojo.style(this.entrySaveCancelButtons, 'display', 'none');
- dojo.style(this.entryEditButton, 'display', '');
- dojo.style(this.entryNewButton, 'display', '');
- var modifiedEntry = false;
- var value;
- var i;
- var changed;
- var entry;
- var authors;
- var contributors;
- if(!this._new){
- entry = this.getEntry();
- if(this._editors.title && (this._editors.title.attr('value') != entry.title.value || this.entryTitleSelect.value != entry.title.type)){
- value = this._editors.title.attr('value');
- if(this.entryTitleSelect.value === "xhtml"){
- value = this._enforceXhtml(value);
- if(value.indexOf('<div xmlns="http://www.w3.org/1999/xhtml">') !== 0){
- value = '<div xmlns="http://www.w3.org/1999/xhtml">' + value + '</div>';
- }
- }
- entry.title = new dojox.atom.io.model.Content("title", value, null, this.entryTitleSelect.value);
- modifiedEntry = true;
- }
-
- if(this._editors.id.attr('value') != entry.id){
- entry.id = this._editors.id.attr('value');
- modifiedEntry = true;
- }
-
- if(this._editors.summary && (this._editors.summary.attr('value') != entry.summary.value || this.entrySummarySelect.value != entry.summary.type)){
- value = this._editors.summary.attr('value');
- if(this.entrySummarySelect.value === "xhtml"){
- value = this._enforceXhtml(value);
- if(value.indexOf('<div xmlns="http://www.w3.org/1999/xhtml">') !== 0){
- value = '<div xmlns="http://www.w3.org/1999/xhtml">' + value + '</div>';
- }
- }
- entry.summary = new dojox.atom.io.model.Content("summary", value, null, this.entrySummarySelect.value);
- modifiedEntry = true;
- }
-
- if(this._editors.content && (this._editors.content.attr('value') != entry.content.value || this.entryContentSelect.value != entry.content.type)){
- value = this._editors.content.attr('value');
- if(this.entryContentSelect.value === "xhtml"){
- value = this._enforceXhtml(value);
- if(value.indexOf('<div xmlns="http://www.w3.org/1999/xhtml">') !== 0){
- value = '<div xmlns="http://www.w3.org/1999/xhtml">' + value + '</div>';
- }
- }
- entry.content = new dojox.atom.io.model.Content("content", value, null, this.entryContentSelect.value);
- modifiedEntry = true;
- }
-
- if(this._editors.authors){
- if(modifiedEntry){
- entry.authors = [];
- authors = this._editors.authors.getValues();
- for(i in authors){
- if(authors[i].name || authors[i].email || authors[i].uri){
- entry.addAuthor(authors[i].name, authors[i].email, authors[i].uri);
- }
- }
- }else{
- var currentAuthors = entry.authors;
- var searchAuthors = function(name, email, uri){
- for(i in currentAuthors){
- if(currentAuthors[i].name === name && currentAuthors[i].email === email && currentAuthors[i].uri === uri){
- return true;
- }
- }
- return false;
- };
- authors = this._editors.authors.getValues();
- changed = false;
- for(i in authors){
- if(!searchAuthors(authors[i].name, authors[i].email, authors[i].uri)){
- changed = true;
- break;
- }
- }
- if(changed){
- entry.authors = [];
- for(i in authors){
- if(authors[i].name || authors[i].email || authors[i].uri){
- entry.addAuthor(authors[i].name, authors[i].email, authors[i].uri);
- }
- }
- modifiedEntry = true;
- }
- }
- }
-
- if(this._editors.contributors){
- if(modifiedEntry){
- entry.contributors = [];
- contributors = this._editors.contributors.getValues();
- for(i in contributors){
- if(contributors[i].name || contributors[i].email || contributors[i].uri){
- entry.addAuthor(contributors[i].name, contributors[i].email, contributors[i].uri);
- }
- }
- }else{
- var currentContributors = entry.contributors;
- var searchContributors = function(name, email, uri){
- for(i in currentContributors){
- if(currentContributors[i].name === name && currentContributors[i].email === email && currentContributors[i].uri === uri){
- return true;
- }
- }
- return false;
- };
- contributors = this._editors.contributors.getValues();
- changed = false;
- for(i in contributors){
- if(searchContributors(contributors[i].name, contributors[i].email, contributors[i].uri)){
- changed = true;
- break;
- }
- }
- if(changed){
- entry.contributors = [];
- for(i in contributors){
- if(contributors[i].name || contributors[i].email || contributors[i].uri){
- entry.addContributor(contributors[i].name, contributors[i].email, contributors[i].uri);
- }
- }
- modifiedEntry = true;
- }
- }
- }
- if(modifiedEntry){
- dojo.publish(this.entrySelectionTopic, [{action: "update", source: this, entry: entry, callback: this._handleSave }]);
-
-
-
-
-
-
- }
- }else{
- this._new = false;
- entry = new dojox.atom.io.model.Entry();
-
- value = this._editors.title.attr('value');
- if(this.entryTitleSelect.value === "xhtml"){
- value = this._enforceXhtml(value);
- value = '<div xmlns="http://www.w3.org/1999/xhtml">' + value + '</div>';
- }
- entry.setTitle(value, this.entryTitleSelect.value);
- entry.id = this._editors.id.attr('value');
-
- authors = this._editors.authors.getValues();
- for(i in authors){
- if(authors[i].name || authors[i].email || authors[i].uri){
- entry.addAuthor(authors[i].name, authors[i].email, authors[i].uri);
- }
- }
-
- contributors = this._editors.contributors.getValues();
- for(i in contributors){
- if(contributors[i].name || contributors[i].email || contributors[i].uri){
- entry.addContributor(contributors[i].name, contributors[i].email, contributors[i].uri);
- }
- }
-
- value = this._editors.summary.attr('value');
- if(this.entrySummarySelect.value === "xhtml"){
- value = this._enforceXhtml(value);
- value = '<div xmlns="http://www.w3.org/1999/xhtml">' + value + '</div>';
- }
- entry.summary = new dojox.atom.io.model.Content("summary", value, null, this.entrySummarySelect.value);
- value = this._editors.content.attr('value');
- if(this.entryContentSelect.value === "xhtml"){
- value = this._enforceXhtml(value);
- value = '<div xmlns="http://www.w3.org/1999/xhtml">' + value + '</div>';
- }
- entry.content = new dojox.atom.io.model.Content("content", value, null, this.entryContentSelect.value);
- dojo.style(this.entryNewButton, 'display', '');
- dojo.publish(this.entrySelectionTopic, [{action: "post", source: this, entry: entry }]);
- }
- this._editMode = false;
-
-
- this.setEntry(entry, this._feed, true);
- },
-
- _handleSave: function(/*object*/entry, /*string*/location){
-
-
-
-
-
-
-
-
-
-
-
-
- this._editMode = false;
-
-
- this.clear();
- this.setEntry(entry, this.getFeed(), true);
- },
- cancelEdits: function(){
-
-
-
-
-
-
-
- this._new = false;
- dojo.style(this.entrySaveCancelButtons, 'display', 'none');
- if(this._editable){
- dojo.style(this.entryEditButton, 'display', '');
- }
- dojo.style(this.entryNewButton, 'display', '');
- this._editMode = false;
-
-
- this.clearEditors();
- this.setEntry(this.getEntry(), this.getFeed(), true);
- },
- clear: function(){
-
-
-
-
- this._editable=false;
- this.clearEditors();
- dojox.atom.widget.FeedEntryEditor.superclass.clear.apply(this);
- if(this._contentEditor){
-
-
- this._contentEditor = this._setObject = this._oldContent = this._contentEditorCreator = null;
- this._editors = {};
- }
- },
-
- clearEditors: function(){
- for(var key in this._editors){
- if(this._editors[key].declaredClass === "dijit.Editor"){
- this._editors[key].close(false, true);
- }
- this._editors[key].destroy();
- }
- this._editors = {};
- },
- _enforceXhtml: function(/*string*/html){
-
-
-
-
-
-
-
-
-
-
- var xhtml = null;
- if(html){
-
- var brRegExp = /<br>/g;
- xhtml = html.replace(brRegExp, "<br/>");
-
- xhtml = this._closeTag(xhtml, "hr");
-
- xhtml = this._closeTag(xhtml, "img");
- }
- return xhtml;
- },
- _closeTag: function(/*string*/xhtml, /*string*/tag){
-
-
-
-
-
-
-
-
-
-
-
-
-
- var tagStart = "<" + tag;
- var tagIndex = xhtml.indexOf(tagStart);
- if(tagIndex !== -1){
- while (tagIndex !== -1){
- var tempString = "";
- var foundTagEnd = false;
- for (var i = 0; i < xhtml.length; i++){
- var c = xhtml.charAt(i);
- if(i <= tagIndex ||foundTagEnd){
- tempString += c;
- }
- else
- {
- if(c === '>'){
- tempString += "/";
- foundTagEnd = true;
- }
- tempString +=c;
- }
- }
- xhtml = tempString;
- tagIndex = xhtml.indexOf(tagStart, tagIndex + 1);
- }
- }
- return xhtml;
- },
-
- _toggleNew: function(){
-
-
-
-
-
-
- dojo.style(this.entryNewButton, 'display', 'none');
- dojo.style(this.entryEditButton, 'display', 'none');
- dojo.style(this.entrySaveCancelButtons, 'display', '');
-
-
- this.entrySummarySelect.value = "text";
- this.entryContentSelect.value = "text";
- this.entryTitleSelect.value = "text";
-
-
- this.clearNodes();
- this._new = true;
-
- var _nlsResources = dojo.i18n.getLocalization("dojox.atom.widget", "FeedEntryViewer");
-
- var titleHeader = new dojox.atom.widget.EntryHeader({title: _nlsResources.title});
- this.entryTitleHeader.appendChild(titleHeader.domNode);
-
- this._editors.title = this._createEditor(this.entryTitleNode, null);
- this.setFieldValidity("title",true);
-
- var authorHeader = new dojox.atom.widget.EntryHeader({title: _nlsResources.authors});
- this.entryAuthorHeader.appendChild(authorHeader.domNode);
- this._editors.authors = this._createPeopleEditor(this.entryAuthorNode, {name: "Author"});
- this.setFieldValidity("authors", true);
-
- var contributorHeader = new dojox.atom.widget.EntryHeader({title: _nlsResources.contributors});
- this.entryContributorHeader.appendChild(contributorHeader.domNode);
- this._editors.contributors = this._createPeopleEditor(this.entryContributorNode, {name: "Contributor"});
- this.setFieldValidity("contributors", true);
-
- var idHeader = new dojox.atom.widget.EntryHeader({title: _nlsResources.id});
- this.entryIdHeader.appendChild(idHeader.domNode);
-
- this._editors.id = this._createEditor(this.entryIdNode, null);
- this.setFieldValidity("id",true);
- var updatedHeader = new dojox.atom.widget.EntryHeader({title: _nlsResources.updated});
- this.entryUpdatedHeader.appendChild(updatedHeader.domNode);
-
- this._editors.updated = this._createEditor(this.entryUpdatedNode, null);
- this.setFieldValidity("updated",true);
- var summaryHeader = new dojox.atom.widget.EntryHeader({title: _nlsResources.summary});
- this.entrySummaryHeader.appendChild(summaryHeader.domNode);
-
- this._editors.summary = this._createEditor(this.entrySummaryNode, null, true);
- this.setFieldValidity("summaryedit",true);
- this.setFieldValidity("summary",true);
- var contentHeader = new dojox.atom.widget.EntryHeader({title: _nlsResources.content});
- this.entryContentHeader.appendChild(contentHeader.domNode);
-
- this._editors.content = this._createEditor(this.entryContentNode, null, true);
- this.setFieldValidity("contentedit",true);
- this.setFieldValidity("content",true);
-
- this._displaySections();
- },
-
- _displaySections: function(){
-
-
-
-
- dojo.style(this.entrySummarySelect, 'display', 'none');
- dojo.style(this.entryContentSelect, 'display', 'none');
- dojo.style(this.entryTitleSelect, 'display', 'none');
-
- if(this.isFieldValid("contentedit")){
- dojo.style(this.entryContentSelect, 'display', '');
- }
- if(this.isFieldValid("summaryedit")){
- dojo.style(this.entrySummarySelect, 'display', '');
- }
- if(this.isFieldValid("titleedit")){
- dojo.style(this.entryTitleSelect, 'display', '');
- }
-
- dojox.atom.widget.FeedEntryEditor.superclass._displaySections.apply(this);
-
-
- if(this._toLoad){
- for(var i in this._toLoad){
- var editor;
- if(this._toLoad[i].generateEditor){
- editor = dojo.hitch(this._toLoad[i], this._toLoad[i].generateEditor)();
- }else{
- editor = this._toLoad[i];
- }
- this._editors[this._toLoad[i].name] = editor;
- this._toLoad[i] = null;
- }
- this._toLoad = null;
- }
- }
- });
- 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(){
-
- var _nlsResources = dojo.i18n.getLocalization("dojox.atom.widget", "PeopleEditor");
- if(this.name){
- if(this.name == "Author"){
- this.peopleEditorButton.appendChild(document.createTextNode("["+_nlsResources.addAuthor+"]"));
- }else if(this.name == "Contributor"){
- this.peopleEditorButton.appendChild(document.createTextNode("["+_nlsResources.addContributor+"]"));
- }
- }else{
- this.peopleEditorButton.appendChild(document.createTextNode("["+_nlsResources.add+"]"));
- }
- this._editors = [];
- if(!this.data || this.data.length===0){
- this._createEditors(null, null, null, 0, this.name);
- this._index = 1;
- }else{
- for(var i in this.data){
- this._createEditors(this.data[i].name, this.data[i].email, this.data[i].uri, i);
- this._index++;
- this._numRows++;
- }
- }
- },
-
- destroy: function(){
- for(var key in this._editors){
- for(var key2 in this._editors[key]){
- this._editors[key][key2].destroy();
- }
- }
- this._editors = [];
- },
-
- _createEditors: function(/*string*/name, /*string*/email, /*string*/uri, /*int*/index, /*string*/widgetName){
-
-
-
-
-
-
-
-
-
-
-
-
-
- var row = document.createElement("tr");
- this.peopleEditorEditors.appendChild(row);
- row.id = "removeRow"+index;
-
- var node = document.createElement("td");
- node.setAttribute('align', 'right');
- row.appendChild(node);
- node.colSpan = 2;
-
- if(this._numRows>0){
- var hr = document.createElement("hr");
- node.appendChild(hr);
- hr.id = "hr"+index;
- }
-
- row = document.createElement("span");
- node.appendChild(row);
- row.className = "peopleEditorButton";
- dojo.style(row, 'font-size', 'x-small');
- dojo.connect(row, "onclick", this, "_removeEditor");
- row.id = "remove"+index;
-
- node = document.createTextNode("[X]");
- row.appendChild(node);
-
- row = document.createElement("tr");
- this.peopleEditorEditors.appendChild(row);
- row.id = "editorsRow"+index;
-
- var labelNode = document.createElement("td");
- row.appendChild(labelNode);
- dojo.style(labelNode, 'width', '20%');
-
- node = document.createElement("td");
- row.appendChild(node);
-
- row = document.createElement("table");
- labelNode.appendChild(row);
- dojo.style(row, 'width', '100%');
-
- labelNode = document.createElement("tbody");
- row.appendChild(labelNode);
-
- row = document.createElement("table");
- node.appendChild(row);
- dojo.style(row, 'width', '100%');
-
- node = document.createElement("tbody");
- row.appendChild(node);
- this._editors[index] = [];
- this._editors[index].push(this._createEditor(name, widgetName+'name'+index, 'Name:', labelNode, node));
- this._editors[index].push(this._createEditor(email, widgetName+'email'+index, 'Email:', labelNode, node));
- this._editors[index].push(this._createEditor(uri, widgetName+'uri'+index, 'URI:', labelNode, node));
- },
-
- _createEditor: function(/*string*/value, /*string*/id, /*string*/name, /*DOM node*/labelNode, /*DOM node*/node){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var row = document.createElement("tr");
- labelNode.appendChild(row);
-
- var label = document.createElement("label");
- label.setAttribute('for', id);
- label.appendChild(document.createTextNode(name));
- labelNode = document.createElement("td");
- labelNode.appendChild(label);
- row.appendChild(labelNode);
-
- row = document.createElement("tr");
- node.appendChild(row);
-
- node = document.createElement("td");
- row.appendChild(node);
-
- var viewNode = document.createElement("input");
- viewNode.setAttribute('id', id);
- node.appendChild(viewNode);
- dojo.style(viewNode, 'width', '95%');
-
- var box = new dijit.form.TextBox({},viewNode);
- box.attr('value', value);
- return box;
- },
-
- _removeEditor: function(/*object*/event){
-
-
-
-
-
-
-
-
- var target = null;
-
- if(dojo.isIE){
- target = event.srcElement;
- }else{
- target = event.target;
- }
-
- var id = target.id;
- id = id.substring(6);
- for(var key in this._editors[id]){
- this._editors[id][key].destroy();
- }
-
- var node = dojo.byId("editorsRow"+id);
- var parent = node.parentNode;
- parent.removeChild(node);
-
- node = dojo.byId("removeRow"+id);
- parent = node.parentNode;
- parent.removeChild(node);
- this._numRows--;
- if(this._numRows === 1 && parent.firstChild.firstChild.firstChild.tagName.toLowerCase() === "hr"){
- node = parent.firstChild.firstChild;
- node.removeChild(node.firstChild);
- }
- this._editors[id] = null;
- },
-
- _add: function(){
-
-
-
-
- this._createEditors(null, null, null, this._index);
- this._index++;
- this._numRows++;
- },
-
- getValues: function(){
-
-
-
-
-
-
-
- var values = [];
- for(var i in this._editors){
- if(this._editors[i]){
- values.push({name: this._editors[i][0].attr('value'), email: this._editors[i][1].attr('value'), uri: this._editors[i][2].attr('value')});
- }
- }
- return values;
- }
- });
- }
|