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

📄 toolbar.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 2 页
字号:
	_onmouseout: function(e) {		dojo.html.removeClass(this.domNode, "hover");		dojo.html.removeClass(this.domNode, "down");		if(!this._selected) {			dojo.html.removeClass(this.domNode, "selected");		}	},	_onclick: function(e) {		// FIXME: buttons never seem to have this._enabled set to true on Opera 9		// dojo.debug("widget:", this.widgetType, ":", this.getName(), ", enabled:", this._enabled);		if(this._enabled && !this._toggleItem) {			this._fireEvent("onClick");		}	},	_onmousedown: function(e) {		if(e.preventDefault) { e.preventDefault(); }		if(!this._enabled) { return };		dojo.html.addClass(this.domNode, "down");		if(this._toggleItem) {			if(this.parent.preventDeselect && this._selected) {				return;			}			this.toggleSelected();		}	},	_onmouseup: function(e) {		dojo.html.removeClass(this.domNode, "down");	},	fillInTemplate: function(args, frag) {		if(args.name) { this._name = args.name; }		if(args.selected) { this.select(); }		if(args.disabled) { this.disable(); }		if(args.label) { this.setLabel(args.label); }		if(args.icon) { this.setIcon(args.icon); }		if(args.toggleitem||args.toggleItem) { this.setToggleItem(true); }	}});dojo.widget.ToolbarItem.make = function(wh, whIsType, props) {	var item = null;	if(wh instanceof Array) {		item = dojo.widget.createWidget("ToolbarButtonGroup", props);		item.setName(wh[0]);		for(var i = 1; i < wh.length; i++) {			item.addChild(wh[i]);		}	} else if(wh instanceof dojo.widget.ToolbarItem) {		item = wh;	} else if(wh instanceof dojo.uri.Uri) {		item = dojo.widget.createWidget("ToolbarButton",			dojo.lang.mixin(props||{}, {icon: new dojo.widget.Icon(wh.toString())}));	} else if(whIsType) {		item = dojo.widget.createWidget(wh, props)	} else if(typeof wh == "string" || wh instanceof String) {		switch(wh.charAt(0)) {			case "|":			case "-":			case "/":				item = dojo.widget.createWidget("ToolbarSeparator", props);				break;			case " ":				if(wh.length == 1) {					item = dojo.widget.createWidget("ToolbarSpace", props);				} else {					item = dojo.widget.createWidget("ToolbarFlexibleSpace", props);				}				break;			default:				if(/\.(gif|jpg|jpeg|png)$/i.test(wh)) {					item = dojo.widget.createWidget("ToolbarButton",						dojo.lang.mixin(props||{}, {icon: new dojo.widget.Icon(wh.toString())}));				} else {					item = dojo.widget.createWidget("ToolbarButton",						dojo.lang.mixin(props||{}, {label: wh.toString()}));				}		}	} else if(wh && wh.tagName && /^img$/i.test(wh.tagName)) {		item = dojo.widget.createWidget("ToolbarButton",			dojo.lang.mixin(props||{}, {icon: wh}));	} else {		item = dojo.widget.createWidget("ToolbarButton",			dojo.lang.mixin(props||{}, {label: wh.toString()}));	}	return item;}/* ToolbarButtonGroup *********************/dojo.widget.tags.addParseTreeHandler("dojo:toolbarButtonGroup");dojo.widget.html.ToolbarButtonGroup = function() {	dojo.widget.ToolbarItem.call(this);}dojo.inherits(dojo.widget.html.ToolbarButtonGroup, dojo.widget.ToolbarItem);dojo.lang.extend(dojo.widget.html.ToolbarButtonGroup, {	widgetType: "ToolbarButtonGroup",	isContainer: true,	templateString: '<span unselectable="on" class="toolbarButtonGroup" dojoAttachPoint="containerNode"></span>',	// if a button has the same name, it will be selected	// if this is set to a number, the button at that index will be selected	defaultButton: "",    postCreate: function() {        for (var i = 0; i < this.children.length; i++) {            this._injectChild(this.children[i]);        }    },	addChild: function(item, pos, props) {		var widget = dojo.widget.ToolbarItem.make(item, null, dojo.lang.mixin(props||{}, {toggleItem:true}));		var ret = dojo.widget.html.ToolbarButtonGroup.superclass.addChild.call(this, widget, null, pos, null);        this._injectChild(widget);        return ret;    },    _injectChild: function(widget) {        dojo.event.connect(widget, "onSelect", this, "onChildSelected");        dojo.event.connect(widget, "onDeselect", this, "onChildDeSelected");        if(widget._name == this.defaultButton			|| (typeof this.defaultButton == "number"			&& this.children.length-1 == this.defaultButton)) {			widget.select(false, true);		}	},	getItem: function(name) {		if(name instanceof dojo.widget.ToolbarItem) { return name; }		for(var i = 0; i < this.children.length; i++) {			var child = this.children[i];			if(child instanceof dojo.widget.ToolbarItem				&& child._name == name) { return child; }		}		return null;	},	getItems: function() {		var items = [];		for(var i = 0; i < this.children.length; i++) {			var child = this.children[i];			if(child instanceof dojo.widget.ToolbarItem) {				items.push(child);			}		}		return items;	},	onChildSelected: function(e) {		this.select(e._name);	},	onChildDeSelected: function(e) {		this._fireEvent("onChangeSelect", this._value);	},	enable: function(force, preventEvent) {		for(var i = 0; i < this.children.length; i++) {			var child = this.children[i];			if(child instanceof dojo.widget.ToolbarItem) {				child.enable(force, preventEvent);				if(child._name == this._value) {					child.select(force, preventEvent);				}			}		}	},	disable: function(force, preventEvent) {		for(var i = 0; i < this.children.length; i++) {			var child = this.children[i];			if(child instanceof dojo.widget.ToolbarItem) {				child.disable(force, preventEvent);			}		}	},	_value: "",	getValue: function() { return this._value; },	select: function(name, force, preventEvent) {		for(var i = 0; i < this.children.length; i++) {			var child = this.children[i];			if(child instanceof dojo.widget.ToolbarItem) {				if(child._name == name) {					child.select(force, preventEvent);					this._value = name;				} else {					child.deselect(true, true);				}			}		}		if(!preventEvent) {			this._fireEvent("onSelect", this._value);			this._fireEvent("onChangeSelect", this._value);		}	},	setValue: this.select,	preventDeselect: false // if true, once you select one, you can't have none selected});/* ToolbarButton ***********************/dojo.widget.tags.addParseTreeHandler("dojo:toolbarButton");dojo.widget.html.ToolbarButton = function() {	dojo.widget.ToolbarItem.call(this);}dojo.inherits(dojo.widget.html.ToolbarButton, dojo.widget.ToolbarItem);dojo.lang.extend(dojo.widget.html.ToolbarButton, {	widgetType: "ToolbarButton",	fillInTemplate: function(args, frag) {		dojo.widget.html.ToolbarButton.superclass.fillInTemplate.call(this, args, frag);		dojo.html.addClass(this.domNode, "toolbarButton");		if(this._icon) {			this.setIcon(this._icon);		}		if(this._label) {			this.setLabel(this._label);		}		if(!this._name) {			if(this._label) {				this.setName(this._label);			} else if(this._icon) {				var src = this._icon.getSrc("enabled").match(/[\/^]([^\.\/]+)\.(gif|jpg|jpeg|png)$/i);				if(src) { this.setName(src[1]); }			} else {				this._name = this._widgetId;			}		}	}});/* ToolbarDialog **********************/dojo.widget.tags.addParseTreeHandler("dojo:toolbarDialog");dojo.widget.html.ToolbarDialog = function() {	dojo.widget.html.ToolbarButton.call(this);}dojo.inherits(dojo.widget.html.ToolbarDialog, dojo.widget.html.ToolbarButton);dojo.lang.extend(dojo.widget.html.ToolbarDialog, {	widgetType: "ToolbarDialog",		fillInTemplate: function (args, frag) {		dojo.widget.html.ToolbarDialog.superclass.fillInTemplate.call(this, args, frag);		dojo.event.connect(this, "onSelect", this, "showDialog");		dojo.event.connect(this, "onDeselect", this, "hideDialog");	},		showDialog: function (e) {		dojo.lang.setTimeout(dojo.event.connect, 1, document, "onmousedown", this, "deselect");	},		hideDialog: function (e) {		dojo.event.disconnect(document, "onmousedown", this, "deselect");	}});/* ToolbarMenu **********************/dojo.widget.tags.addParseTreeHandler("dojo:toolbarMenu");dojo.widget.html.ToolbarMenu = function() {	dojo.widget.html.ToolbarDialog.call(this);	this.widgetType = "ToolbarMenu";}dojo.inherits(dojo.widget.html.ToolbarMenu, dojo.widget.html.ToolbarDialog);/* ToolbarMenuItem ******************/dojo.widget.ToolbarMenuItem = function() {}/* ToolbarSeparator **********************/dojo.widget.tags.addParseTreeHandler("dojo:toolbarSeparator");dojo.widget.html.ToolbarSeparator = function() {    dojo.widget.ToolbarItem.call(this);}dojo.inherits(dojo.widget.html.ToolbarSeparator, dojo.widget.ToolbarItem);dojo.lang.extend(dojo.widget.html.ToolbarSeparator, {	widgetType: "ToolbarSeparator",	templateString: '<span unselectable="on" class="toolbarItem toolbarSeparator"></span>',	defaultIconPath: new dojo.uri.dojoUri("src/widget/templates/buttons/-.gif"),	fillInTemplate: function(args, frag, skip) {		dojo.widget.html.ToolbarSeparator.superclass.fillInTemplate.call(this, args, frag);		this._name = this.widgetId;		if(!skip) {			if(!this._icon) {				this.setIcon(this.defaultIconPath);			}			this.domNode.appendChild(this._icon.getNode());		}	},	// don't want events!	_onmouseover: null,     _onmouseout: null,     _onclick: null,     _onmousedown: null,     _onmouseup: null });/* ToolbarSpace **********************/dojo.widget.tags.addParseTreeHandler("dojo:toolbarSpace");dojo.widget.html.ToolbarSpace = function() {	dojo.widget.html.ToolbarSeparator.call(this);}dojo.inherits(dojo.widget.html.ToolbarSpace, dojo.widget.html.ToolbarSeparator);dojo.lang.extend(dojo.widget.html.ToolbarSpace, {    widgetType: "ToolbarSpace",	fillInTemplate: function(args, frag, skip) {		dojo.widget.html.ToolbarSpace.superclass.fillInTemplate.call(this, args, frag, true);		if(!skip) {			dojo.html.addClass(this.domNode, "toolbarSpace");		}	}});/* ToolbarSelect ******************/ dojo.widget.tags.addParseTreeHandler("dojo:toolbarSelect");dojo.widget.html.ToolbarSelect = function() {	dojo.widget.ToolbarItem.call(this);}dojo.inherits(dojo.widget.html.ToolbarSelect, dojo.widget.ToolbarItem);dojo.lang.extend(dojo.widget.html.ToolbarSelect, {    widgetType: "ToolbarSelect",	templateString: '<span class="toolbarItem toolbarSelect" unselectable="on"><select dojoAttachPoint="selectBox" dojoOnChange="changed"></select></span>',	fillInTemplate: function(args, frag) {		dojo.widget.html.ToolbarSelect.superclass.fillInTemplate.call(this, args, frag, true);		var keys = args.values;		var i = 0;		for(var val in keys) {			var opt = document.createElement("option");			opt.setAttribute("value", keys[val]);			opt.innerHTML = val;			this.selectBox.appendChild(opt);		}	},	changed: function(e) {		this._fireEvent("onSetValue", this.selectBox.value);	},	setEnabled: function(is, force, preventEvent) {		var ret = dojo.widget.html.ToolbarSelect.superclass.setEnabled.call(this, is, force, preventEvent);		this.selectBox.disabled = !this._enabled;		return ret;	},	// don't want events!	_onmouseover: null,    _onmouseout: null,    _onclick: null,    _onmousedown: null,    _onmouseup: null});/* Icon *********/// arguments can be IMG nodes, Image() instances or URLs -- enabled is the only one requireddojo.widget.Icon = function(enabled, disabled, hover, selected){	if(!arguments.length){		// FIXME: should this be dojo.raise?		throw new Error("Icon must have at least an enabled state");	}	var states = ["enabled", "disabled", "hover", "selected"];	var currentState = "enabled";	var domNode = document.createElement("img");	this.getState = function(){ return currentState; }	this.setState = function(value){		if(dojo.lang.inArray(value, states)){			if(this[value]){				currentState = value;				domNode.setAttribute("src", this[currentState].src);			}		}else{			throw new Error("Invalid state set on Icon (state: " + value + ")");		}	}	this.setSrc = function(state, value){		if(/^img$/i.test(value.tagName)){			this[state] = value;		}else if(typeof value == "string" || value instanceof String			|| value instanceof dojo.uri.Uri){			this[state] = new Image();			this[state].src = value.toString();		}		return this[state];	}	this.setIcon = function(icon){		for(var i = 0; i < states.length; i++){			if(icon[states[i]]){				this.setSrc(states[i], icon[states[i]]);			}		}		this.update();	}	this.enable = function(){ this.setState("enabled"); }	this.disable = function(){ this.setState("disabled"); }	this.hover = function(){ this.setState("hover"); }	this.select = function(){ this.setState("selected"); }	this.getSize = function(){		return {			width: domNode.width||domNode.offsetWidth,			height: domNode.height||domNode.offsetHeight		};	}	this.setSize = function(w, h){		domNode.width = w;		domNode.height = h;		return { width: w, height: h };	}	this.getNode = function(){		return domNode;	}	this.getSrc = function(state){		if(state){ return this[state].src; }		return domNode.src||"";	}	this.update = function(){		this.setState(currentState);	}	for(var i = 0; i < states.length; i++){		var arg = arguments[i];		var state = states[i];		this[state] = null;		if(!arg){ continue; }		this.setSrc(state, arg);	}	this.enable();}dojo.widget.Icon.make = function(a,b,c,d){	for(var i = 0; i < arguments.length; i++){		if(arguments[i] instanceof dojo.widget.Icon){			return arguments[i];		}	}	return new dojo.widget.Icon(a,b,c,d);}

⌨️ 快捷键说明

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