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

📄 editor2toolbar.js

📁 对java中如何使用Ajax技术
💻 JS
📖 第 1 页 / 共 2 页
字号:
//		dojo.widget.Editor2ToolbarFormatBlockPlainSelect.superclass.create.apply(this, arguments);		this._domNode = node;		this._parentToolbar = toolbar;		//TODO: check node is a select		this._domNode = node;		this.disableSelection(this._domNode);		dojo.event.connect(this._domNode, 'onchange', this, 'onChange');	},	destroy: function(){		this._domNode = null;	},	onChange: function(){		if(this._parentToolbar.checkAvailability()){			var sv = this._domNode.value.toLowerCase();			var curInst = dojo.widget.Editor2Manager.getCurrentInstance();			if(curInst){				var _command = curInst.getCommand(this._name);				if(_command){					_command.execute(sv);				}			}		}	},	refreshState: function(){		if(this._domNode){			dojo.widget.Editor2ToolbarFormatBlockPlainSelect.superclass.refreshState.call(this);			var curInst = dojo.widget.Editor2Manager.getCurrentInstance();			if(curInst){				var _command = curInst.getCommand(this._name);				if(_command){					var format = _command.getValue();					if(!format){ format = ""; }					dojo.lang.forEach(this._domNode.options, function(item){						if(item.value.toLowerCase() == format.toLowerCase()){							item.selected = true;						}					});				}			}		}	}});dojo.declare("dojo.widget.Editor2ToolbarComboItem", dojo.widget.Editor2ToolbarDropDownButton,{	// summary: dojo.widget.Editor2ToolbarComboItem provides an external loaded dropdown list	href: null,	create: function(node, toolbar){		dojo.widget.Editor2ToolbarComboItem.superclass.create.apply(this, arguments);		//do not use lazy initilization, as we need the local names in refreshState()		if(!this._contentPane){			dojo.require("dojo.widget.ContentPane");			this._contentPane = dojo.widget.createWidget("ContentPane", {preload: 'true'});			this._contentPane.addOnLoad(this, "setup");			this._contentPane.setUrl(this.href);		}	},	onMouseOver: function(e){		if(this._lastState != dojo.widget.Editor2Manager.commandState.Disabled){			dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle);		}	},	onMouseOut:function(e){		dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle);	},	onDropDownShown: function(){		if(!this._dropdown.__addedContentPage){			this._dropdown.addChild(this._contentPane);			this._dropdown.__addedContentPage = true;		}	},	setup: function(){		// summary: overload this to connect event	},	onChange: function(e){		if(this._parentToolbar.checkAvailability()){			var name = e.currentTarget.getAttribute("dropDownItemName");			var curInst = dojo.widget.Editor2Manager.getCurrentInstance();			if(curInst){				var _command = curInst.getCommand(this._name);				if(_command){					_command.execute(name);				}			}		}		this._dropdown.close();	},	onMouseOverItem: function(e){		dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle);	},	onMouseOutItem: function(e){		dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle);	}});dojo.declare("dojo.widget.Editor2ToolbarFormatBlockSelect", dojo.widget.Editor2ToolbarComboItem, {	// summary: dojo.widget.Editor2ToolbarFormatBlockSelect is an improved format block setting item	href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FormatBlock.html"),	setup: function(){		dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this);		var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*");		this._blockNames = {};		this._blockDisplayNames = {};		for(var x=0; x<nodes.length; x++){			var node = nodes[x];			dojo.html.disableSelection(node);			var name=node.getAttribute("dropDownItemName")			if(name){				this._blockNames[name] = node;				var childrennodes = node.getElementsByTagName(name);				this._blockDisplayNames[name] = childrennodes[childrennodes.length-1].innerHTML;			}		}		for(var name in this._blockNames){			dojo.event.connect(this._blockNames[name], "onclick", this, "onChange");			dojo.event.connect(this._blockNames[name], "onmouseover", this, "onMouseOverItem");			dojo.event.connect(this._blockNames[name], "onmouseout", this, "onMouseOutItem");		}	},	onDropDownDestroy: function(){		if(this._blockNames){			for(var name in this._blockNames){				delete this._blockNames[name];				delete this._blockDisplayNames[name];			}		}	},	refreshState: function(){		dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this);		if(this._lastState != dojo.widget.Editor2Manager.commandState.Disabled){			var curInst = dojo.widget.Editor2Manager.getCurrentInstance();			if(curInst){				var _command = curInst.getCommand(this._name);				if(_command){					var format = _command.getValue();					if(format == this._lastSelectedFormat && this._blockDisplayNames){						return this._lastState;					}					this._lastSelectedFormat = format;					var label = this._domNode.getElementsByTagName("label")[0];					var isSet = false;					if(this._blockDisplayNames){						for(var name in this._blockDisplayNames){							if(name == format){								label.innerHTML = 	this._blockDisplayNames[name];								isSet = true;								break;							}						}						if(!isSet){							label.innerHTML = "&nbsp;";						}					}				}			}		}		return this._lastState;	}});dojo.declare("dojo.widget.Editor2ToolbarFontSizeSelect", dojo.widget.Editor2ToolbarComboItem,{	// summary: dojo.widget.Editor2ToolbarFontSizeSelect provides a dropdown list for setting fontsize	href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontSize.html"),	setup: function(){		dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this);		var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*");		this._fontsizes = {};		this._fontSizeDisplayNames = {};		for(var x=0; x<nodes.length; x++){			var node = nodes[x];			dojo.html.disableSelection(node);			var name=node.getAttribute("dropDownItemName")			if(name){				this._fontsizes[name] = node;				this._fontSizeDisplayNames[name] = node.getElementsByTagName('font')[0].innerHTML;			}		}		for(var name in this._fontsizes){			dojo.event.connect(this._fontsizes[name], "onclick", this, "onChange");			dojo.event.connect(this._fontsizes[name], "onmouseover", this, "onMouseOverItem");			dojo.event.connect(this._fontsizes[name], "onmouseout", this, "onMouseOutItem");		}	},	onDropDownDestroy: function(){		if(this._fontsizes){			for(var name in this._fontsizes){				delete this._fontsizes[name];				delete this._fontSizeDisplayNames[name];			}		}	},	refreshState: function(){		dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this);		if(this._lastState != dojo.widget.Editor2Manager.commandState.Disabled){			var curInst = dojo.widget.Editor2Manager.getCurrentInstance();			if(curInst){				var _command = curInst.getCommand(this._name);				if(_command){					var size = _command.getValue();					if(size == this._lastSelectedSize && this._fontSizeDisplayNames){						return this._lastState;					}					this._lastSelectedSize = size;					var label = this._domNode.getElementsByTagName("label")[0];					var isSet = false;					if(this._fontSizeDisplayNames){						for(var name in this._fontSizeDisplayNames){							if(name == size){								label.innerHTML = 	this._fontSizeDisplayNames[name];								isSet = true;								break;							}						}						if(!isSet){							label.innerHTML = "&nbsp;";						}					}				}			}		}		return this._lastState;	}});dojo.declare("dojo.widget.Editor2ToolbarFontNameSelect", dojo.widget.Editor2ToolbarFontSizeSelect, {	// summary: dojo.widget.Editor2ToolbarFontNameSelect provides a dropdown list for setting fontname	href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontName.html")});dojo.widget.defineWidget(	"dojo.widget.Editor2Toolbar",	dojo.widget.HtmlWidget,	function(){		dojo.event.connect(this, "fillInTemplate", dojo.lang.hitch(this, function(){			if(dojo.render.html.ie){				this.domNode.style.zoom = 1.0;			}		}));	},	{		// summary:		//		dojo.widget.Editor2Toolbar is the main widget for the toolbar associated with an Editor2		templatePath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.html"),		templateCssPath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.css"),		// ToolbarLatchedItemStyle: String: class name for latched toolbar button items		ToolbarLatchedItemStyle: "ToolbarButtonLatched",		// ToolbarEnabledItemStyle: String: class name for enabled toolbar button items		ToolbarEnabledItemStyle: "ToolbarButtonEnabled",		// ToolbarDisabledItemStyle: String: class name for disabled toolbar button items		ToolbarDisabledItemStyle: "ToolbarButtonDisabled",		// ToolbarHighlightedItemStyle: String: class name for highlighted toolbar button items		ToolbarHighlightedItemStyle: "ToolbarButtonHighlighted",		// ToolbarHighlightedSelectStyle: String: class name for highlighted toolbar select items		ToolbarHighlightedSelectStyle: "ToolbarSelectHighlighted",		// ToolbarHighlightedSelectItemStyle: String: class name for highlighted toolbar select dropdown items		ToolbarHighlightedSelectItemStyle: "ToolbarSelectHighlightedItem",//		itemNodeType: 'span', //all the items (with attribute dojoETItemName set) defined in the toolbar should be a of this type		postCreate: function(){			var nodes = dojo.html.getElementsByClass("dojoEditorToolbarItem", this.domNode/*, this.itemNodeType*/);			this.items = {};			for(var x=0; x<nodes.length; x++){				var node = nodes[x];				var itemname = node.getAttribute("dojoETItemName");				if(itemname){					var item = dojo.widget.Editor2ToolbarItemManager.getToolbarItem(itemname);					if(item){						item.create(node, this);						this.items[itemname.toLowerCase()] = item;					}else{						//hide unsupported toolbar items						node.style.display = "none";					}				}			}		},		update: function(){			// summary: update all the toolbar items			for(var cmd in this.items){				this.items[cmd].refreshState();			}		},		shareGroup: '',		checkAvailability: function(){			// summary: returns whether items in this toolbar can be executed			// description: 			//		For unshared toolbar, when clicking on a toolbar, the corresponding			//		editor will be focused, and this function always return true. For shared			//		toolbar, if the current focued editor is not one of the instances sharing			//		this toolbar, this function return false, otherwise true.			if(!this.shareGroup){				this.parent.focus();				return true;			}			var curInst = dojo.widget.Editor2Manager.getCurrentInstance();			if(this.shareGroup == curInst.toolbarGroup){				return true;			}			return false;		},		destroy: function(){			for(var it in this.items){				this.items[it].destroy();				delete this.items[it];			}			dojo.widget.Editor2Toolbar.superclass.destroy.call(this);		}	});

⌨️ 快捷键说明

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