12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238 |
- require({cache:{
- 'url: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",
- 'url: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>"}});
- define("dojox/atom/widget/FeedEntryEditor", [
- "dojo/_base/kernel",
- "dojo/_base/lang",
- "dojo/_base/connect",
- "dojo/_base/fx",
- "dojo/_base/sniff",
- "dojo/dom",
- "dojo/dom-style",
- "dojo/dom-construct",
- "dijit/_Widget",
- "dijit/_Templated",
- "dijit/_Container",
- "dijit/Editor",
- "dijit/form/TextBox",
- "dijit/form/SimpleTextarea",
- "./FeedEntryViewer",
- "../io/model",
- "dojo/text!./templates/FeedEntryEditor.html",
- "dojo/text!./templates/PeopleEditor.html",
- "dojo/i18n!./nls/FeedEntryViewer",
- "dojo/i18n!./nls/FeedEntryEditor",
- "dojo/i18n!./nls/PeopleEditor",
- "dojo/_base/declare"
- ], function (dojo, lang, connect, fx, has, domUtil, domStyle, domConstruct, _Widget, _Templated, _Container, Editor, TextBox, SimpleTextarea, FeedEntryViewer, model, template, peopleEditorTemplate, i18nViewer, i18nEditor, i18nPeople) {
- dojo.experimental("dojox.atom.widget.FeedEntryEditor");
- var widget = dojo.getObject("dojox.atom.widget", true);
- widget.FeedEntryEditor = dojo.declare( FeedEntryViewer,{
-
-
-
-
- _contentEditor: null,
- _oldContent: null,
- _setObject: null,
- enableEdit: false,
- _contentEditorCreator: null,
- _editors: {},
- entryNewButton: null,
- _editable: false,
-
- templateString: template,
- postCreate: function(){
- if(this.entrySelectionTopic !== ""){
- this._subscriptions = [dojo.subscribe(this.entrySelectionTopic, this, "_handleEvent")];
- }
- var _nlsResources = i18nViewer;
- 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 = i18nEditor;
- 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;
- }
- widget.FeedEntryEditor.superclass.setEntry.call(this, entry, feed);
- this._editable = this._isEditable(entry);
- if(!leaveMenuState && !this._editable){
- domStyle.set(this.entryEditButton, 'display', 'none');
- domStyle.set(this.entrySaveCancelButtons, 'display', 'none');
- }
- if(this._editable && this.enableEdit){
- if(!leaveMenuState){
- domStyle.set(this.entryEditButton, 'display', '');
-
- if(this.enableMenuFade && this.entrySaveCancelButton){
- fx.fadeOut({node: this.entrySaveCancelButton,duration: 250}).play();
- }
- }
- }
- },
- _toggleEdit: function(){
-
-
-
-
-
-
-
- if(this._editable && this.enableEdit){
- domStyle.set(this.entryEditButton, 'display', 'none');
- domStyle.set(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){
- domStyle.set(this.entryEditButton, 'display', 'none');
- }
- 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){
- 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){
- 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){
- 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){
- 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){
- 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){
- 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){
- 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 Editor({}, node);
- this.editor = _editor;
- return _editor;
- }
- };
- }
- if(multiline){
-
- viewNode = document.createElement("textarea");
- anchorNode.appendChild(viewNode);
- domStyle.set(viewNode, 'width', '90%');
- box = new SimpleTextarea({},viewNode);
- }else{
-
- viewNode = document.createElement("input");
- anchorNode.appendChild(viewNode);
- domStyle.set(viewNode, 'width', '95%');
- box = new 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 Editor({}, node);
- this.editor = _editor;
- return _editor;
- }
- };
- }
- if(multiline){
-
- viewNode = document.createElement("textarea");
- anchorNode.appendChild(viewNode);
- domStyle.set(viewNode, 'width', '90%');
- box = new SimpleTextarea({},viewNode);
- }else{
-
- viewNode = document.createElement("input");
- anchorNode.appendChild(viewNode);
- domStyle.set(viewNode, 'width', '95%');
- box = new TextBox({},viewNode);
- }
- box.attr('value', value);
- return box;
- },
-
- _switchEditor: function(/*object*/event){
-
-
-
-
-
-
-
-
- var type = null;
- var target = null;
- var parent = null;
-
-
- if(has("ie")){
- 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.isInstanceOf(Editor)){
-
-
- value = editor.attr('value', false);
- editor.close(false,true);
- editor.destroy();
- while(parent.firstChild){
- domConstruct.destroy(parent.firstChild);
- }
- newEditor = this._createEditor(parent, {value: value}, true, false);
- this._editors[type] = newEditor;
- }
- }else{
- if(!editor.isInstanceOf(Editor)){
-
-
- value = editor.attr('value');
- editor.destroy();
- while(parent.firstChild){
- domConstruct.destroy(parent.firstChild);
- }
- newEditor = this._createEditor(parent, {value: value}, true, true);
- newEditor = lang.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 widget.PeopleEditor(node,viewNode);
- },
- saveEdits: function(){
-
-
-
-
-
-
-
-
-
- domStyle.set(this.entrySaveCancelButtons, 'display', 'none');
- domStyle.set(this.entryEditButton, 'display', '');
- domStyle.set(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 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 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 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 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 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 model.Content("content", value, null, this.entryContentSelect.value);
- domStyle.set(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;
- domStyle.set(this.entrySaveCancelButtons, 'display', 'none');
- if(this._editable){
- domStyle.set(this.entryEditButton, 'display', '');
- }
- domStyle.set(this.entryNewButton, 'display', '');
- this._editMode = false;
-
-
- this.clearEditors();
- this.setEntry(this.getEntry(), this.getFeed(), true);
- },
- clear: function(){
-
-
-
-
- this._editable=false;
- this.clearEditors();
- 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].isInstanceOf(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(){
-
-
-
-
-
-
- domStyle.set(this.entryNewButton, 'display', 'none');
- domStyle.set(this.entryEditButton, 'display', 'none');
- domStyle.set(this.entrySaveCancelButtons, 'display', '');
-
-
- this.entrySummarySelect.value = "text";
- this.entryContentSelect.value = "text";
- this.entryTitleSelect.value = "text";
-
-
- this.clearNodes();
- this._new = true;
-
- var _nlsResources = i18nViewer;
-
- var titleHeader = new 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 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 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 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 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 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 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(){
-
-
-
-
- domStyle.set(this.entrySummarySelect, 'display', 'none');
- domStyle.set(this.entryContentSelect, 'display', 'none');
- domStyle.set(this.entryTitleSelect, 'display', 'none');
-
- if(this.isFieldValid("contentedit")){
- domStyle.set(this.entryContentSelect, 'display', '');
- }
- if(this.isFieldValid("summaryedit")){
- domStyle.set(this.entrySummarySelect, 'display', '');
- }
- if(this.isFieldValid("titleedit")){
- domStyle.set(this.entryTitleSelect, 'display', '');
- }
-
- widget.FeedEntryEditor.superclass._displaySections.apply(this);
-
-
- if(this._toLoad){
- for(var i in this._toLoad){
- var editor;
- if(this._toLoad[i].generateEditor){
- editor = lang.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;
- }
- }
- });
- widget.PeopleEditor = dojo.declare( [_Widget, _Templated, _Container],{
-
-
-
-
-
- templateString: peopleEditorTemplate,
- _rows: [],
- _editors: [],
- _index: 0,
- _numRows: 0,
-
- postCreate: function(){
-
- var _nlsResources = i18nPeople;
- 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";
- domStyle.set(row, 'font-size', 'x-small');
- connect.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);
- domStyle.set(labelNode, 'width', '20%');
-
- node = document.createElement("td");
- row.appendChild(node);
-
- row = document.createElement("table");
- labelNode.appendChild(row);
- domStyle.set(row, 'width', '100%');
-
- labelNode = document.createElement("tbody");
- row.appendChild(labelNode);
-
- row = document.createElement("table");
- node.appendChild(row);
- domStyle.set(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);
- domStyle.set(viewNode, 'width', '95%');
-
- var box = new TextBox({},viewNode);
- box.attr('value', value);
- return box;
- },
-
- _removeEditor: function(/*object*/event){
-
-
-
-
-
-
-
-
- var target = null;
-
- if(has("ie")){
- 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 = domUtil.byId("editorsRow"+id);
- var parent = node.parentNode;
- parent.removeChild(node);
-
- node = domUtil.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;
- }
- });
- return widget.FeedEntryEditor;
- });
|