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

📄 richtext.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 4 页
字号:
						ifr.style.minHeight = this.minHeight;					}				}else{					ifr.style.height = this.height ? this.height : this.minHeight;				}				if(dojo.isIE){					this._localizeEditorCommands();				}				this.onLoad();				this.savedContent = this.getValue(true);			});			if(dojo.isIE && dojo.isIE < 7){ // IE 6 is a steaming pile...				var t = setInterval(function(){					if(ifr.contentWindow.isLoaded){						clearInterval(t);						loadFunc();					}				}, 100);			}else{ // blissful sanity!				h = dojo.connect(					((dojo.isIE) ? ifr.contentWindow : ifr), "onload", loadFunc				);			}		}else{ // designMode in iframe			this._drawIframe(html);			this.savedContent = this.getValue(true);		}		// TODO: this is a guess at the default line-height, kinda works		if(this.domNode.nodeName == "LI"){ this.domNode.lastChild.style.marginTop = "-1.2em"; }		this.domNode.className += " RichTextEditable";	},	//static cache variables shared among all instance of this class	_local2NativeFormatNames: {},	_native2LocalFormatNames: {},	_localizedIframeTitles: null,	_getIframeDocTxt: function(/* String */ html){		var _cs = dojo.getComputedStyle(this.domNode);		if(dojo.isIE || (!this.height && !dojo.isMoz)){			html="<div>"+html+"</div>";		}		var font = [ _cs.fontWeight, _cs.fontSize, _cs.fontFamily ].join(" ");		// line height is tricky - applying a units value will mess things up.		// if we can't get a non-units value, bail out.		var lineHeight = _cs.lineHeight;		if(lineHeight.indexOf("px") >= 0){			lineHeight = parseFloat(lineHeight)/parseFloat(_cs.fontSize);			// console.debug(lineHeight);		}else if(lineHeight.indexOf("em")>=0){			lineHeight = parseFloat(lineHeight);		}else{			lineHeight = "1.0";		}		return [			this.isLeftToRight() ? "<html><head>" : "<html dir='rtl'><head>",			(dojo.isMoz ? "<title>" + this._localizedIframeTitles.iframeEditTitle + "</title>" : ""),			"<style>",			"body,html {",			"	background:transparent;",			"	font:", font, ";",			"	padding: 1em 0 0 0;",			"	margin: -1em 0 0 0;", // remove extraneous vertical scrollbar on safari and firefox			"	height: 100%;",			"}",			// TODO: left positioning will cause contents to disappear out of view			//	   if it gets too wide for the visible area			"body{",			"	top:0px; left:0px; right:0px;",				((this.height||dojo.isOpera) ? "" : "position: fixed;"),			// FIXME: IE 6 won't understand min-height?			"	min-height:", this.minHeight, ";",			"	line-height:", lineHeight,			"}",			"p{ margin: 1em 0 !important; }",			(this.height ? // height:auto undoes the height:100%				"" : "body,html{height:auto;overflow-y:hidden;/*for IE*/} body > div {overflow-x:auto;/*for FF to show vertical scrollbar*/}"			),			"li > ul:-moz-first-node, li > ol:-moz-first-node{ padding-top: 1.2em; } ",			"li{ min-height:1.2em; }",			"</style>",			this._applyEditingAreaStyleSheets(),			"</head><body>"+html+"</body></html>"		].join(""); // String	},	_drawIframe: function(/*String*/html){		// summary:		//		Draws an iFrame using the existing one if one exists.		//		Used by Mozilla, Safari, and Opera		if(!this.iframe){			var ifr = this.iframe = dojo.doc.createElement("iframe");			ifr.id=this.id;			// this.iframe.src = "about:blank";			// dojo.doc.body.appendChild(this.iframe);			// console.debug(this.iframe.contentDocument.open());			// dojo.body().appendChild(this.iframe);			var ifrs = ifr.style;			// ifrs.border = "1px solid black";			ifrs.border = "none";			ifrs.lineHeight = "0"; // squash line height			ifrs.verticalAlign = "bottom";//			ifrs.scrolling = this.height ? "auto" : "vertical";			this.editorObject = this.iframe;			// get screen reader text for mozilla here, too			this._localizedIframeTitles = dojo.i18n.getLocalization("dijit.form", "Textarea");			// need to find any associated label element and update iframe document title			var label=dojo.query('label[for="'+this.id+'"]');			if(label.length){				this._localizedIframeTitles.iframeEditTitle = label[0].innerHTML + " " + this._localizedIframeTitles.iframeEditTitle;			}		}		// opera likes this to be outside the with block		//	this.iframe.src = "javascript:void(0)";//dojo.uri.dojoUri("src/widget/templates/richtextframe.html") + ((dojo.doc.domain != currentDomain) ? ("#"+dojo.doc.domain) : "");		this.iframe.style.width = this.inheritWidth ? this._oldWidth : "100%";		if(this.height){			this.iframe.style.height = this.height;		}else{			this.iframe.height = this._oldHeight;		}		var tmpContent;		if(this.textarea){			tmpContent = this.srcNodeRef;		}else{			tmpContent = dojo.doc.createElement('div');			tmpContent.style.display="none";			tmpContent.innerHTML = html;			//append tmpContent to under the current domNode so that the margin			//calculation below is correct			this.editingArea.appendChild(tmpContent);		}		this.editingArea.appendChild(this.iframe);		//do we want to show the content before the editing area finish loading here?		//if external style sheets are used for the editing area, the appearance now		//and after loading of the editing area won't be the same (and padding/margin		//calculation above may not be accurate)		//	tmpContent.style.display = "none";		//	this.editingArea.appendChild(this.iframe);		var _iframeInitialized = false;		// console.debug(this.iframe);		// var contentDoc = this.iframe.contentWindow.document;		// note that on Safari lower than 420+, we have to get the iframe		// by ID in order to get something w/ a contentDocument property		var contentDoc = this.iframe.contentDocument;		contentDoc.open();		if(dojo.isAIR){			contentDoc.body.innerHTML = html;		}else{			contentDoc.write(this._getIframeDocTxt(html));		}		contentDoc.close();		// now we wait for onload. Janky hack!		var ifrFunc = dojo.hitch(this, function(){			if(!_iframeInitialized){				_iframeInitialized = true;			}else{ return; }			if(!this.editNode){				try{					if(this.iframe.contentWindow){						this.window = this.iframe.contentWindow;						this.document = this.iframe.contentWindow.document					}else if(this.iframe.contentDocument){						// for opera						this.window = this.iframe.contentDocument.window;						this.document = this.iframe.contentDocument;					}					if(!this.document.body){						throw 'Error';					}				}catch(e){					setTimeout(ifrFunc,500);					_iframeInitialized = false;					return;				}				dojo._destroyElement(tmpContent);				this.onLoad();			}else{				dojo._destroyElement(tmpContent);				this.editNode.innerHTML = html;				this.onDisplayChanged();			}			this._preDomFilterContent(this.editNode);		});		ifrFunc();	},	_applyEditingAreaStyleSheets: function(){		// summary:		//		apply the specified css files in styleSheets		var files = [];		if(this.styleSheets){			files = this.styleSheets.split(';');			this.styleSheets = '';		}		//empty this.editingAreaStyleSheets here, as it will be filled in addStyleSheet		files = files.concat(this.editingAreaStyleSheets);		this.editingAreaStyleSheets = [];		var text='', i=0, url;		while((url=files[i++])){			var abstring = (new dojo._Url(dojo.global.location, url)).toString();			this.editingAreaStyleSheets.push(abstring);			text += '<link rel="stylesheet" type="text/css" href="'+abstring+'"/>'		}		return text;	},	addStyleSheet: function(/*dojo._Url*/uri){		// summary:		//		add an external stylesheet for the editing area		// uri:	a dojo.uri.Uri pointing to the url of the external css file		var url=uri.toString();		//if uri is relative, then convert it to absolute so that it can be resolved correctly in iframe		if(url.charAt(0) == '.' || (url.charAt(0) != '/' && !uri.host)){			url = (new dojo._Url(dojo.global.location, url)).toString();		}		if(dojo.indexOf(this.editingAreaStyleSheets, url) > -1){//			console.debug("dijit._editor.RichText.addStyleSheet: Style sheet "+url+" is already applied");			return;		}		this.editingAreaStyleSheets.push(url);		if(this.document.createStyleSheet){ //IE			this.document.createStyleSheet(url);		}else{ //other browser			var head = this.document.getElementsByTagName("head")[0];			var stylesheet = this.document.createElement("link");			with(stylesheet){				rel="stylesheet";				type="text/css";				href=url;			}			head.appendChild(stylesheet);		}	},	removeStyleSheet: function(/*dojo._Url*/uri){		// summary:		//		remove an external stylesheet for the editing area		var url=uri.toString();		//if uri is relative, then convert it to absolute so that it can be resolved correctly in iframe		if(url.charAt(0) == '.' || (url.charAt(0) != '/' && !uri.host)){			url = (new dojo._Url(dojo.global.location, url)).toString();		}		var index = dojo.indexOf(this.editingAreaStyleSheets, url);		if(index == -1){//			console.debug("dijit._editor.RichText.removeStyleSheet: Style sheet "+url+" has not been applied");			return;		}		delete this.editingAreaStyleSheets[index];		dojo.withGlobal(this.window,'query', dojo, ['link:[href="'+url+'"]']).orphan()	},	disabled: true,	_mozSettingProps: ['styleWithCSS','insertBrOnReturn'],	setDisabled: function(/*Boolean*/ disabled){		if(dojo.isIE || dojo.isSafari || dojo.isOpera){			if(dojo.isIE){ this.editNode.unselectable = "on"; } // prevent IE from setting focus			this.editNode.contentEditable = !disabled;			if(dojo.isIE){				var _this = this;				setTimeout(function(){ _this.editNode.unselectable = "off"; }, 0);			}		}else{ //moz			if(disabled){				//AP: why isn't this set in the constructor, or put in mozSettingProps as a hash?				this._mozSettings=[false,this.blockNodeForEnter==='BR'];			}			this.document.designMode=(disabled?'off':'on');			if(!disabled && this._mozSettings){				dojo.forEach(this._mozSettingProps, function(s,i){					this.document.execCommand(s,false,this._mozSettings[i]);				},this);			}//			this.document.execCommand('contentReadOnly', false, disabled);//				if(disabled){//					this.blur(); //to remove the blinking caret//				}		}		this.disabled = disabled;	},/* Event handlers *****************/	_isResized: function(){ return false; },	onLoad: function(/* Event */ e){		// summary: handler after the content of the document finishes loading		this.isLoaded = true;		if(!this.window.__registeredWindow){			this.window.__registeredWindow=true;			dijit.registerWin(this.window);		}		if(!dojo.isIE && (this.height || dojo.isMoz)){			this.editNode=this.document.body;		}else{			this.editNode=this.document.body.firstChild;			var _this = this;			if(dojo.isIE){ // #4996 IE wants to focus the BODY tag				var tabStop = this.tabStop = dojo.doc.createElement('<div tabIndex=-1>');				this.editingArea.appendChild(tabStop);				this.iframe.onfocus = function(){ _this.editNode.setActive(); }			}		}		try{			this.setDisabled(false);		}catch(e){			// Firefox throws an exception if the editor is initially hidden			// so, if this fails, try again onClick by adding "once" advice			var handle = dojo.connect(this, "onClick", this, function(){				this.setDisabled(false);				dojo.disconnect(handle);			});		}		this._preDomFilterContent(this.editNode);		var events=this.events.concat(this.captureEvents),i=0,et;		while((et=events[i++])){			this.connect(this.document, et.toLowerCase(), et);		}		if(!dojo.isIE){			try{ // sanity check for Mozilla			//AP: what's the point of this?//					this.document.execCommand("useCSS", false, true); // old moz call				this.document.execCommand("styleWithCSS", false, false); // new moz call				//this.document.execCommand("insertBrOnReturn", false, false); // new moz call			}catch(e2){ }			// FIXME: when scrollbars appear/disappear this needs to be fired		}else{ // IE contentEditable			// give the node Layout on IE			this.connect(this.document, "onmousedown", "_onMouseDown"); // #4996 fix focus			this.editNode.style.zoom = 1.0;		}		if(this.focusOnLoad){			setTimeout(dojo.hitch(this, "focus"), 0); // have to wait for IE to set unselectable=off		}		this.onDisplayChanged(e);		if(this.onLoadDeferred){			this.onLoadDeferred.callback(true);

⌨️ 快捷键说明

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