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

📄 combobox.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 3 页
字号:
if(!dojo._hasResource["dijit.form.ComboBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dijit.form.ComboBox"] = true;dojo.provide("dijit.form.ComboBox");dojo.require("dijit.form.ValidationTextBox");dojo.requireLocalization("dijit.form", "ComboBox", null, "zh,ROOT,pt,da,tr,ru,de,sv,ja,he,fi,nb,el,ar,pt-pt,cs,fr,es,ko,nl,zh-tw,pl,it,hu");dojo.declare(	"dijit.form.ComboBoxMixin",	null,	{		// item: Object		//		This is the item returned by the dojo.data.store implementation that		//		provides the data for this cobobox, it's the currently selected item.		item: null,		// pageSize: Integer		//		Argument to data provider.		//		Specifies number of search results per page (before hitting "next" button)		pageSize: Infinity,		// store: Object		//		Reference to data provider object used by this ComboBox		store: null,		// query: Object		//		A query that can be passed to 'store' to initially filter the items,		//		before doing further filtering based on `searchAttr` and the key.		//		Any reference to the `searchAttr` is ignored.		query: {},		// autoComplete: Boolean		//		If you type in a partial string, and then tab out of the `<input>` box,		//		automatically copy the first entry displayed in the drop down list to		//		the `<input>` field		autoComplete: true,		// searchDelay: Integer		//		Delay in milliseconds between when user types something and we start		//		searching based on that value		searchDelay: 100,		// searchAttr: String		//		Searches pattern match against this field		searchAttr: "name",		// queryExpr: String		//		dojo.data query expression pattern.		//		`${0}` will be substituted for the user text.		//		`*` is used for wildcards.		//		`${0}*` means "starts with", `*${0}*` means "contains", `${0}` means "is"		queryExpr: "${0}*",		// ignoreCase: Boolean		//		Set true if the ComboBox should ignore case when matching possible items		ignoreCase: true,		// hasDownArrow: Boolean		//		Set this textbox to have a down arrow button.		//		Defaults to true.		hasDownArrow:true,		templateString:"<div class=\"dijit dijitReset dijitInlineTable dijitLeft\"\n\tid=\"widget_${id}\"\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse\" dojoAttachPoint=\"comboNode\" waiRole=\"combobox\" tabIndex=\"-1\"\n\t><div style=\"overflow:hidden;\"\n\t\t><div class='dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton'\n\t\t\tdojoAttachPoint=\"downArrowNode\" waiRole=\"presentation\"\n\t\t\tdojoAttachEvent=\"onmousedown:_onArrowMouseDown,onmouseup:_onMouse,onmouseenter:_onMouse,onmouseleave:_onMouse\"\n\t\t\t><div class=\"dijitArrowButtonInner\">&thinsp;</div\n\t\t\t><div class=\"dijitArrowButtonChar\">&#9660;</div\n\t\t></div\n\t\t><div class=\"dijitReset dijitValidationIcon\"><br></div\n\t\t><div class=\"dijitReset dijitValidationIconText\">&Chi;</div\n\t\t><div class=\"dijitReset dijitInputField\"\n\t\t\t><input type=\"text\" autocomplete=\"off\" name=\"${name}\" class='dijitReset'\n\t\t\tdojoAttachEvent=\"onkeypress:_onKeyPress, onfocus:_update, compositionend,onkeyup\"\n\t\t\tdojoAttachPoint=\"textbox,focusNode\" waiRole=\"textbox\" waiState=\"haspopup-true,autocomplete-list\"\n\t\t/></div\n\t></div\n></div>\n",		baseClass:"dijitComboBox",		_getCaretPos: function(/*DomNode*/ element){			// khtml 3.5.2 has selection* methods as does webkit nightlies from 2005-06-22			var pos = 0;			if(typeof(element.selectionStart)=="number"){				// FIXME: this is totally borked on Moz < 1.3. Any recourse?				pos = element.selectionStart;			}else if(dojo.isIE){				// in the case of a mouse click in a popup being handled,				// then the dojo.doc.selection is not the textarea, but the popup				// var r = dojo.doc.selection.createRange();				// hack to get IE 6 to play nice. What a POS browser.				var tr = dojo.doc.selection.createRange().duplicate();				var ntr = element.createTextRange();				tr.move("character",0);				ntr.move("character",0);				try{					// If control doesnt have focus, you get an exception.					// Seems to happen on reverse-tab, but can also happen on tab (seems to be a race condition - only happens sometimes).					// There appears to be no workaround for this - googled for quite a while.					ntr.setEndPoint("EndToEnd", tr);					pos = String(ntr.text).replace(/\r/g,"").length;				}catch(e){					// If focus has shifted, 0 is fine for caret pos.				}			}			return pos;		},		_setCaretPos: function(/*DomNode*/ element, /*Number*/ location){			location = parseInt(location);			dijit.selectInputText(element, location, location);		},		_setAttribute: function(/*String*/ attr, /*anything*/ value){			// summary: additional code to set disablbed state of combobox node			if (attr == "disabled"){				dijit.setWaiState(this.comboNode, "disabled", value);			}		},					_onKeyPress: function(/*Event*/ evt){			// summary: handles keyboard events			//except for pasting case - ctrl + v(118)			if(evt.altKey || (evt.ctrlKey && evt.charCode != 118)){				return;			}			var doSearch = false;			var pw = this._popupWidget;			var dk = dojo.keys;			if(this._isShowingNow){				pw.handleKey(evt);			}			switch(evt.keyCode){				case dk.PAGE_DOWN:				case dk.DOWN_ARROW:					if(!this._isShowingNow||this._prev_key_esc){						this._arrowPressed();						doSearch=true;					}else{						this._announceOption(pw.getHighlightedOption());					}					dojo.stopEvent(evt);					this._prev_key_backspace = false;					this._prev_key_esc = false;					break;				case dk.PAGE_UP:				case dk.UP_ARROW:					if(this._isShowingNow){						this._announceOption(pw.getHighlightedOption());					}					dojo.stopEvent(evt);					this._prev_key_backspace = false;					this._prev_key_esc = false;					break;				case dk.ENTER:					// prevent submitting form if user presses enter. Also					// prevent accepting the value if either Next or Previous					// are selected					var highlighted;					if(	this._isShowingNow && 						(highlighted = pw.getHighlightedOption())					){						// only stop event on prev/next						if(highlighted == pw.nextButton){							this._nextSearch(1);							dojo.stopEvent(evt);							break;						}else if(highlighted == pw.previousButton){							this._nextSearch(-1);							dojo.stopEvent(evt);							break;						}					}else{						this.setDisplayedValue(this.getDisplayedValue());					}					// default case:					// prevent submit, but allow event to bubble					evt.preventDefault();					// fall through				case dk.TAB:					var newvalue = this.getDisplayedValue();					// #4617: 					//		if the user had More Choices selected fall into the					//		_onBlur handler					if(pw && (						newvalue == pw._messages["previousMessage"] ||						newvalue == pw._messages["nextMessage"])					){						break;					}					if(this._isShowingNow){						this._prev_key_backspace = false;						this._prev_key_esc = false;						if(pw.getHighlightedOption()){							pw.setValue({ target: pw.getHighlightedOption() }, true);						}						this._hideResultList();					}					break;				case dk.SPACE:					this._prev_key_backspace = false;					this._prev_key_esc = false;					if(this._isShowingNow && pw.getHighlightedOption()){						dojo.stopEvent(evt);						this._selectOption();						this._hideResultList();					}else{						doSearch = true;					}					break;				case dk.ESCAPE:					this._prev_key_backspace = false;					this._prev_key_esc = true;					if(this._isShowingNow){						dojo.stopEvent(evt);						this._hideResultList();					}					this.inherited(arguments);					break;				case dk.DELETE:				case dk.BACKSPACE:					this._prev_key_esc = false;					this._prev_key_backspace = true;					doSearch = true;					break;				case dk.RIGHT_ARROW: // fall through				case dk.LEFT_ARROW: 					this._prev_key_backspace = false;					this._prev_key_esc = false;					break;				default: // non char keys (F1-F12 etc..)  shouldn't open list					this._prev_key_backspace = false;					this._prev_key_esc = false;					if(dojo.isIE || evt.charCode != 0){						doSearch = true;					}			}			if(this.searchTimer){				clearTimeout(this.searchTimer);			}			if(doSearch){				// need to wait a tad before start search so that the event				// bubbles through DOM and we have value visible				setTimeout(dojo.hitch(this, "_startSearchFromInput"),1);			}		},		_autoCompleteText: function(/*String*/ text){			// summary:			// 		Fill in the textbox with the first item from the drop down			// 		list, and highlight the characters that were			// 		auto-completed. For example, if user typed "CA" and the			// 		drop down list appeared, the textbox would be changed to			// 		"California" and "ifornia" would be highlighted.			var fn = this.focusNode;			// IE7: clear selection so next highlight works all the time			dijit.selectInputText(fn, fn.value.length);			// does text autoComplete the value in the textbox?			var caseFilter = this.ignoreCase? 'toLowerCase' : 'substr';			if(text[caseFilter](0).indexOf(this.focusNode.value[caseFilter](0)) == 0){				var cpos = this._getCaretPos(fn);				// only try to extend if we added the last character at the end of the input				if((cpos+1) > fn.value.length){					// only add to input node as we would overwrite Capitalisation of chars					// actually, that is ok					fn.value = text;//.substr(cpos);					// visually highlight the autocompleted characters					dijit.selectInputText(fn, cpos);				}			}else{				// text does not autoComplete; replace the whole value and highlight				fn.value = text;				dijit.selectInputText(fn);			}		},		_openResultList: function(/*Object*/ results, /*Object*/ dataObject){			if(	this.disabled || 				this.readOnly || 				(dataObject.query[this.searchAttr] != this._lastQuery)			){				return;			}			this._popupWidget.clearResultList();			if(!results.length){				this._hideResultList();				return;			}			// Fill in the textbox with the first item from the drop down list,			// and highlight the characters that were auto-completed. For			// example, if user typed "CA" and the drop down list appeared, the			// textbox would be changed to "California" and "ifornia" would be			// highlighted.			var zerothvalue = new String(this.store.getValue(results[0], this.searchAttr));			if(zerothvalue && this.autoComplete && !this._prev_key_backspace &&				(dataObject.query[this.searchAttr] != "*")){				// when the user clicks the arrow button to show the full list,				// startSearch looks for "*".				// it does not make sense to autocomplete				// if they are just previewing the options available.				this._autoCompleteText(zerothvalue);			}			this._popupWidget.createOptions(				results, 				dataObject, 				dojo.hitch(this, "_getMenuLabelFromItem")			);			// show our list (only if we have content, else nothing)			this._showResultList();			// #4091:			//		tell the screen reader that the paging callback finished by			//		shouting the next choice			if(dataObject.direction){				if(1 == dataObject.direction){					this._popupWidget.highlightFirstOption();				}else if(-1 == dataObject.direction){					this._popupWidget.highlightLastOption();				}				this._announceOption(this._popupWidget.getHighlightedOption());			}		},		_showResultList: function(){			this._hideResultList();			var items = this._popupWidget.getItems(),				visibleCount = Math.min(items.length,this.maxListLength);			this._arrowPressed();			// hide the tooltip			this.displayMessage("");						// Position the list and if it's too big to fit on the screen then			// size it to the maximum possible height			// Our dear friend IE doesnt take max-height so we need to			// calculate that on our own every time			// TODO: want to redo this, see 			//		http://trac.dojotoolkit.org/ticket/3272			//	and			//		http://trac.dojotoolkit.org/ticket/4108			with(this._popupWidget.domNode.style){				// natural size of the list has changed, so erase old				// width/height settings, which were hardcoded in a previous				// call to this function (via dojo.marginBox() call) 				width = "";				height = "";			}			var best = this.open();			// #3212:			//		only set auto scroll bars if necessary prevents issues with			//		scroll bars appearing when they shouldn't when node is made			//		wider (fractional pixels cause this)			var popupbox = dojo.marginBox(this._popupWidget.domNode);

⌨️ 快捷键说明

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