⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 richtext.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 4 页
字号:
				// apparently isn't bound to it				setTimeout(function(){tr.select();}, 1);			}else{				// dojo.debug("command:", command, "arg:", argument);				argument = arguments.length > 1 ? argument : null;				if(dojo.render.html.moz){					this.document = this.iframe.contentWindow.document				}				returnValue = this.document.execCommand(command, false, argument);				// try{				// }catch(e){				// 	dojo.debug(e);				// }			}						this.onDisplayChanged();			return returnValue;		},		queryCommandEnabled: function(command, argument){			if(this.object){				if(command == "forecolor"){					command = "setforecolor";				}else if(command == "backcolor"){					command = "setbackcolor";				}				if(typeof this._activeX.command[command] == "undefined"){ return false; }				var status = this.object.QueryStatus(this._activeX.command[command]);				return ((status != this.activeX.status.notsupported)&& 					(status != this.activeX.status.diabled));			}else{				// mozilla returns true always				if(command == "unlink" && dojo.render.html.mozilla){					var node = this.getSelectedNode();					while (node.parentNode && node.nodeName != "A") { node = node.parentNode; }					return node.nodeName == "A";				} else if (command == "inserttable" && dojo.render.html.mozilla) {					return true;				}				// return this.document.queryCommandEnabled(command);				var elem = (dojo.render.html.ie) ? this.document.selection.createRange() : this.document;				return elem.queryCommandEnabled(command);			}		},		queryCommandState: function(command, argument){			if(this.object){				if(command == "forecolor"){					command = "setforecolor";				}else if(command == "backcolor"){					command = "setbackcolor";				}				if(typeof this._activeX.command[command] == "undefined"){ return null; }				var status = this.object.QueryStatus(this._activeX.command[command]);				return ((status == this._activeX.status.enabled)||					(status == this._activeX.status.ninched));			}else{				return this.document.queryCommandState(command);			}		},		queryCommandValue: function (command, argument) {			if (this.object) {				switch (command) {					case "forecolor":					case "backcolor":					case "fontsize":					case "fontname":					case "blockformat":						command = "get" + command;						return this.object.execCommand(							this._activeX.command[command],							this._activeX.ui.noprompt);				}										//var status = this.object.QueryStatus(this._activeX.command[command]);			} else {				return this.document.queryCommandValue(command);			}		},					/* Misc.	 ********/		getSelectedNode: function(){			if(!this.isLoaded){ return; }			if(this.document.selection){				return this.document.selection.createRange().parentElement();			}else if(dojo.render.html.mozilla){				return this.window.getSelection().getRangeAt(0).commonAncestorContainer;			}			return this.editNode;		},				placeCursorAtStart: function(){			if(!this.isLoaded){				dojo.event.connect(this, "onLoad", this, "placeCursorAtEnd");				return;			}			dojo.event.disconnect(this, "onLoad", this, "placeCursorAtEnd");			if(this.window.getSelection){				var selection = this.window.getSelection;				if(selection.removeAllRanges){ // Mozilla					var range = this.document.createRange();					range.selectNode(this.editNode.firstChild);					range.collapse(true);					var selection = this.window.getSelection();					selection.removeAllRanges();					selection.addRange(range);				}else{ // Safari					// not a great deal we can do				}			}else if(this.document.selection){ // IE				var range = this.document.body.createTextRange();				range.moveToElementText(this.editNode);				range.collapse(true);				range.select();			}		},		replaceEditorContent: function(html){			if(this.window.getSelection){				var selection = this.window.getSelection;				// if(selection.removeAllRanges){ // Mozilla							if(dojo.render.html.moz){ // Mozilla								var range = this.document.createRange();					range.selectNodeContents(this.editNode);					var selection = this.window.getSelection();					selection.removeAllRanges();					selection.addRange(range);					this.execCommand("inserthtml", html);				}else{ // Safari					// look ma! it's a totally f'd browser!					this.editNode.innerHTML = html;				}			}else if(this.document.selection){ // IE				var range = this.document.body.createTextRange();				range.moveToElementText(this.editNode);				range.select();				this.execCommand("inserthtml", html);			}		},				placeCursorAtEnd: function(){			if(!this.isLoaded){				dojo.event.connect(this, "onLoad", this, "placeCursorAtEnd");				return;			}			dojo.event.disconnect(this, "onLoad", this, "placeCursorAtEnd");			if(this.window.getSelection){				var selection = this.window.getSelection;				if(selection.removeAllRanges){ // Mozilla					var range = this.document.createRange();					range.selectNode(this.editNode.lastChild);					range.collapse(false);					var selection = this.window.getSelection();					selection.removeAllRanges();					selection.addRange(range);				}else{ // Safari					// not a great deal we can do				}			}else if(this.document.selection){ // IE				var range = this.document.body.createTextRange();				range.moveToElementText(this.editNode);				range.collapse(true);				range.select();			}		},		_lastHeight: 0,		/** Updates the height of the iframe to fit the contents. */		_updateHeight: function(){			if(!this.isLoaded){ return; }			if(this.height){ return; }			if(this.iframe){				/*				if(!this.document.body["offsetHeight"]){					return;				}				*/				// The height includes the padding, borders and margins so these				// need to be added on				var heights = ["margin-top", "margin-bottom",					"padding-bottom", "padding-top",					"border-width-bottom", "border-width-top"];				for(var i = 0, chromeheight = 0; i < heights.length; i++){					var height = dojo.style.getStyle(this.iframe, heights[i]);					// Safari doesn't have all the heights so we have to test					if(height){						chromeheight += Number(height.replace(/[^0-9]/g, ""));					}				}				if(this.document.body["offsetHeight"]){					this._lastHeight = Math.max(this.document.body.scrollHeight, this.document.body.offsetHeight) + chromeheight;					this.iframe.height = this._lastHeight + "px";					this.window.scrollTo(0, 0);				}				// dojo.debug(this.iframe.height);			}else if(this.object){				this.object.style.height = dojo.style.getInnerHeight(this.editNode)+"px";			}		},				/**		 * Saves the content in an onunload event if the editor has not been closed		 */		_saveContent: function(e){			var saveTextarea = document.getElementById("dojo.widget.RichText.savedContent");			saveTextarea.value += this._SEPARATOR + this.saveName + ":" + this.getEditorContent();		},		getEditorContent: function(){			var ec = "";			try{				ec = (this._content.length > 0) ? this._content : this.editNode.innerHTML;				if(dojo.string.trim(ec) == "&nbsp;"){ ec = ""; }			}catch(e){ /* squelch */ }			dojo.lang.forEach(this.contentFilters, function(ef){				ec = ef(ec);			});			if (this.relativeImageUrls) {				// why use a regexp instead of dom? because IE is stupid 				// and won't let us set img.src to a relative URL				// this comes after contentFilters because once content				// gets innerHTML'd img urls will be fully qualified				var siteBase = window.location.protocol + "//" + window.location.host;				var pathBase = window.location.pathname;				if (pathBase.match(/\/$/)) {					// ends with slash, match full path				} else {					// match parent path to find siblings					var pathParts = pathBase.split("/");					if (pathParts.length) {						pathParts.pop();					}					pathBase = pathParts.join("/") + "/";				}								var sameSite = new RegExp("(<img[^>]*\ src=[\"'])("+siteBase+"("+pathBase+")?)", "ig");				ec = ec.replace(sameSite, "$1");			}			return ec;		},				/**		 * Kills the editor and optionally writes back the modified contents to the 		 * element from which it originated.		 *		 * @param save Whether or not to save the changes. If false, the changes are		 *             discarded.		 * @return true if the contents has been modified, false otherwise		 */		close: function(save, force){			if(this.isClosed){return false; }			if (arguments.length == 0) { save = true; }			this._content = this.editNode.innerHTML;			var changed = (this.savedContent.innerHTML != this._content);						// line height is squashed for iframes			// FIXME: why was this here? if (this.iframe){ this.domNode.style.lineHeight = null; }			if(this.interval){ clearInterval(this.interval); }						if(dojo.render.html.ie && !this.object){				dojo.event.browser.clean(this.editNode);			}						if (this.iframe) {				// FIXME: should keep iframe around for later re-use				delete this.iframe;			}			this.domNode.innerHTML = "";			if(save){				// kill listeners on the saved content				dojo.event.browser.clean(this.savedContent);				if(dojo.render.html.moz){					var nc = document.createElement("span");					this.domNode.appendChild(nc);					nc.innerHTML = this.editNode.innerHTML;				}else{					this.domNode.innerHTML = this._content;				}			} else {				while (this.savedContent.hasChildNodes()) {					this.domNode.appendChild(this.savedContent.firstChild);				}			}			delete this.savedContent;						dojo.html.removeClass(this.domNode, "RichTextEditable");			this.isClosed = true;			this.isLoaded = false;			// FIXME: is this always the right thing to do?			delete this.editNode;			return changed;		},		destroyRendering: function(){}, // stub!				destroy: function (){			this.destroyRendering();			if(!this.isClosed){ this.close(false); }					// disconnect those listeners.			while(this._connected.length){				this.disconnect(this._connected[0],					this._connected[1], this._connected[2]);			}		},		_connected: [],		connect: function (targetObj, targetFunc, thisFunc) {			dojo.event.connect(targetObj, targetFunc, this, thisFunc);			// this._connected.push([targetObj, targetFunc, thisFunc]);			},				// FIXME: below two functions do not work with the above line commented out		disconnect: function (targetObj, targetFunc, thisFunc) {			for (var i = 0; i < this._connected.length; i++) {				if (this._connected[0] == targetObj &&					this._connected[1] == targetFunc &&					this._connected[2] == thisFunc) {					dojo.event.disconnect(targetObj, targetFunc, this, thisFunc);					this._connected.splice(i, 1);					break;				}			}		},				disconnectAllWithRoot: function (targetObj) {			for (var i = 0; i < this._connected.length; i++) {				if (this._connected[0] == targetObj) {					dojo.event.disconnect(targetObj,						this._connected[1], this, this._connected[2]);					this._connected.splice(i, 1);				}			}			}			},	"html",	function(){		this.contentFilters = [];		// this.contentFilters.push(this.defaultContentCleaner);				this._keyHandlers = {};	});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -