//////////////////////////////////////////////////////////////////////////////////////////////////////////////// 声明命名空间//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.namespace('AE.run.wholesale.list');//////////////////////////////////////////////////////////////////////////////////////////////////////////////// 列表选中属性展示相关//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.run.wholesale.list.refineSelected = function(config){	this.config = {		// refine-selected 目标容器		refineSelected	:	get("refine-selected"),	// 目标容器		showFloatBoxTimeout : 0,					// 鼠标移过延迟触发时间		hideFloatBoxTimeout : 0						// 鼠标离开延迟触发时间	};		this.temp = {		refineSelectedItems : []					// 所有的选中属性	};		this.showFloatBoxTimeoutId = "";				// timeoutId for show	this.hideFloatBoxTimeoutId = "";				// timeoutId for hidden	this.lastFloatBox = null;						// 最后一个浮动层	// 返回对象	return this;};AE.run.wholesale.list.refineSelected.prototype = {		// 鼠标滑过加亮显示	colorTheMouseOver : function(ev,args){		YUD.addClass(args.target,"mouseover");	},		// 鼠标滑过取消加亮显示	colorTheMouseOut : function(ev,args){		YUD.removeClass(args.target,"mouseover");	},		// 点击元素	clickTheItem : function(ev,args){		var link = args.target.getElementsByTagName("a")[0];		top.location.href = link.href;	},		// 显示target对应浮动层，正常情况是它的前一个节点	showFloatBox : function(ev,args){			if(this.config.lastFloatBox){this.config.lastFloatBox.style.display = "none";}				var hoverBody = YUD.getPreviousSibling(args.target);				if(!YUD.hasClass(hoverBody,"hover"))return;				hoverBody.style.display = "block";				this.config.lastFloatBox = hoverBody;	},	// 隐藏target对应浮动层，正常情况是它的前一个节点	hideFloatBox : function(ev,args){			var hoverBody = args.target;				hoverBody.style.display = "none";	},		// 鼠标延迟触发显示	showFloatBoxDelay : function(ev,args){			var _self = this,config = this.config,temp = this.temp;			if(_self.showFloatBoxTimeoutId){clearTimeout(_self.showFloatBoxTimeoutId)};			_self.showFloatBoxTimeoutId = setTimeout(function(){				_self.showFloatBox(ev,args);			},config.showFloatBoxTimeout);	},		// 鼠标延迟触发隐藏	hideFloatBoxDelay : function(ev,args){			var _self = this,config = this.config,temp = this.temp;			if(_self.hideFloatBoxTimeoutId){clearTimeout(_self.hideFloatBoxTimeoutId)};			_self.hideFloatBoxTimeoutId = setTimeout(function(){				_self.hideFloatBox(ev,args);			},config.hideFloatBoxTimeout);	},	// 初始化	init : function(customConfig){			// 合并配置			this.config = YL.merge(this.config,customConfig||{});			// 定义_self			var _self = this,config = this.config,temp = this.temp;						// 判断是否继续			if(!config.refineSelected)return;			// 处理空链接			AE.tool.defineEmptyLinks(config.refineSelected);			var items = _self.temp.refineSelectedItems = config.refineSelected.getElementsByTagName("dl");			for(var i=0;i<items.length; i++){					var item = items[i];					if(YUD.hasClass(item,"hover")){						AE.event.onLeave(item,_self.hideFloatBoxDelay,{target:item},_self);					}else{						AE.event.onEnter(item,_self.showFloatBoxDelay,{target:item},_self);												// 无 hoverBody浮动层的事件捆绑						AE.event.onEnter(item,_self.colorTheMouseOver,{target:item},_self);						AE.event.onLeave(item,_self.colorTheMouseOut,{target:item},_self);						YUE.on(item,"click",_self.clickTheItem,{target:item},_self);					}			}						// 回收内存			if(AE.bom.isIE){ CollectGarbage(); }						// 返回对象			return _self;	}};//////////////////////////////////////////////////////////////////////////////////////////////////////////////// List属性或类目refine-by列表相关 refineList//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.run.wholesale.list.refineList = function(config){	this.config = {		refineList		:	get("refine-list"),		// refine-list 目标容器		collapseClass	:	"collapse",				// item收起时候的className		viewMoreClass	:	"view-more-handle",		// item中的view-more标识		toggleHeight	:	26,						// item收起时候保留标题的高度		expandTime		:	0.25,					// 展开动画时间		collapseTime	:	0.25,					// 收起动画时间		collapseAllClass	:	"collapse-all",		// 全部收起item按钮clasName		scrollView		: false,						// 是否自动滚动到用户视野		autoExpandViewMore	:	true,					// 展开item时候是否同时展开viewMore		viewMoreText : "View More",		viewMoreTextClass : "view-more",		viewLessText : "View Less",		viewLessTextClass : "view-less"	};		this.temp = {		refineListItems : [],	// 所有listItem缓存		viewMoreHandles	: [],	// 所有viewMore按钮缓存		collapseAllBtn : get("collapse-all"),	// 全部收起按钮		collapseItems : []		// 当前收起的items	};		// 返回对象	return this;};AE.run.wholesale.list.refineList.prototype = {	// 专用 toggle 方法 (改变高度)	toggle : function(ev,args){		var _self = this,config = this.config,temp = this.temp;				//{ 必须传入的args配置 ->		// 触发托柄		var handle = args.handle;		// 触发托柄收起状态CSS Class标记		var collapseClass = args.collapseClass;		// 展示目标		var target = args.target;		// 内容原始高度		var toggleHeight = args.toggleHeight;		//}				// 可选传入args		// beforeExpandCall beforeCollapseCall afterExpandCall afterCollapseCall 事件函数		// collapseForce expandForce 是否强行控制展开与否				// 动画中无视执行		if(handle.locked == true)return;				// 如果处于收起状态		if(YUD.hasClass(handle,collapseClass)){			if(args.collapseForce == true)return;						if(args.beforeExpandCall){				args.beforeExpandCall.call(_self, args);			}						target.style.height = "auto";			var toHeight = target.offsetHeight;			target.style.height = toggleHeight + "px";			var attributes = {				height: { to: toHeight }			};			var anim = new YAHOO.util.Anim(target, attributes, config.expandTime, YAHOO.util.Easing.easeOut); 			anim.onComplete.subscribe(function(s, o) {				handle.locked = false;				target.style.height = "auto";				YUD.removeClass(args.handle,args.collapseClass);				if(args.afterExpandCall){					args.afterExpandCall.call(_self, args);				}			});						handle.locked = true;			anim.animate();					}else{			if(args.expandForce == true)return;						if(args.beforeCollapseCall){				args.beforeCollapseCall.call(_self, args);			}						var attributes = {   				height: { to: toggleHeight }			};			var anim = new YAHOO.util.Anim(target, attributes, config.collapseTime, YAHOO.util.Easing.easeOut); 			anim.onComplete.subscribe(function(s, o) {				handle.locked = false;				YUD.addClass(args.handle,args.collapseClass);				if(args.afterCollapseCall){					args.afterCollapseCall.call(_self, args);				}			});						handle.locked = true;			anim.animate();		}	},	// refineItem展开前执行	toggleBeforeExpand : function(args){		var _self = this,config = this.config,temp = this.temp;		// init时早有属性缓存 节省资源		if(args.target.viewMoreHandle && config.autoExpandViewMore){			args.target.viewMoreHandle.style.display = "none";			args.target.viewMoreBox.style.height = "auto";		}		// 滚动到用户视野范围内		if(config.scrollView){			var scrollAnim = new YAHOO.util.Scroll(document.documentElement||document.body, {scroll: { to: [0,YUD.getY(args.target) ] }},config.expandTime);			scrollAnim.animate();		}	},		// refineItem收起前执行	// toggleBeforeCollapse : function(args){},	// refineItem收起后执行	toggleAfterCollapse : function(args){		var _self = this,config = this.config,temp = this.temp;		_self.temp.collapseItems = YUD.getElementsByClassName(config.collapseClass,"*",config.refineList);		var collapseNum = _self.temp.collapseItems.length;		// 全部收起隐藏收起按钮		if(collapseNum == _self.temp.refineListItems.length){			_self.temp.collapseAllBtn.style.display = "none";		};		if(AE.bom.isIE){ CollectGarbage(); }	},	// refineItem展开后执行	toggleAfterExpand : function(args){		var _self = this,config = this.config,temp = this.temp;		if(_self.temp.collapseAllBtn.style.display == "none"){			_self.temp.collapseAllBtn.style.display = "";		}		if(AE.bom.isIE){ CollectGarbage(); }	},		// refineItem-viewMore收起后执行	viewMoreAfterCollapse : function(args){		var _self = this,config = this.config,temp = this.temp;		args.handleText.innerHTML = config.viewMoreText;		YUD.replaceClass(args.handleText,config.viewLessTextClass,config.viewMoreTextClass);		if(AE.bom.isIE){ CollectGarbage(); }	},		// refineItem-viewMore展开后执行	viewMoreAfterExpand : function(args){		var _self = this,config = this.config,temp = this.temp;		args.handleText.innerHTML = config.viewLessText;		YUD.replaceClass(args.handleText,config.viewMoreTextClass,config.viewLessTextClass);		if(AE.bom.isIE){ CollectGarbage(); }	},	// 全部折叠 整理为全局观看	collapseAll : function(){		var _self = this,config = this.config,temp = this.temp;		var items = _self.temp.refineListItems;		for(var i=0;i<items.length; i++){			var item = items[i];			var toggleTitle = item.toggleTitle;			_self.toggle("function",						 	{								handle:toggleTitle.parentNode,						   	collapseClass:config.collapseClass,								target:item,								toggleHeight:config.toggleHeight,								collapseForce : true							})		}		_self.temp.collapseAllBtn.style.display = "none";	},		// 初始化	init : function(customConfig){			// 合并配置			this.config = YL.merge(this.config,customConfig||{});			// 定义_self			var _self = this,config = this.config,temp = this.temp;						// 处理空链接			AE.tool.defineEmptyLinks(config.refineList);						// 判断是否继续			if(!config.refineList)return;						var items = _self.temp.refineListItems = config.refineList.getElementsByTagName("dl");			for(var i=0;i<items.length; i++){					var item = items[i];										// toggle function					var toggleTitle = item.toggleTitle = item.getElementsByTagName("dt")[0];					YUE.on(toggleTitle,"click",_self.toggle,						   {								handle:toggleTitle.parentNode,						   		collapseClass:config.collapseClass,								target:item,								toggleHeight:config.toggleHeight,								beforeExpandCall : _self.toggleBeforeExpand,								afterExpandCall : _self.toggleAfterExpand,								afterCollapseCall : _self.toggleAfterCollapse							},_self);										if(YUD.hasClass(item,config.collapseClass)){						_self.temp.collapseItems.push(item);					}										// view-more in toggle					var viewMoreHandle = YUD.getElementsByClassName(config.viewMoreClass,"*",item)[0];					if(viewMoreHandle){						// 属性缓存 缓存相关元素到外层DD大元素的属性						item.viewMoreHandle = viewMoreHandle;						var viewMoreHandleText = item.viewMoreHandleText = viewMoreHandle.getElementsByTagName("span")[0];						var viewMoreBox = item.viewMoreBox = YUD.getNextSibling(viewMoreHandle);						YUE.on(viewMoreHandle,"click",_self.toggle,							   {									handle:viewMoreHandle,									handleText:viewMoreHandleText,									collapseClass:config.viewMoreClass,									target:viewMoreBox,									toggleHeight:0,									afterCollapseCall : _self.viewMoreAfterCollapse,									afterExpandCall : _self.viewMoreAfterExpand								},_self);						_self.temp.viewMoreHandles.push(viewMoreHandle);					}			}						// init collapseAll Btn			var collapseAllBtn = _self.temp.collapseAllBtn = YUD.getElementsByClassName(config.collapseAllClass,"*",config.refineList)[0];			if(collapseAllBtn){				YUE.on(collapseAllBtn,"click",function(){_self.collapseAll()});			}			// 回收内存			if(AE.bom.isIE){ CollectGarbage(); }						// 返回对象			return _self;	}};//////////////////////////////////////////////////////////////////////////////////////////////////////////////// List 筛选器相关 filter//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.run.wholesale.list.filter = function(config){	this.config = {		filterQuantity		:	get("filter-quantity"),		// refine-list 目标容器		filterQuantityBox	:	get("filter-quantity-box"),		filterPrice			:	get("filter-price"),		filterPriceFrom		:	get("filter-price-from"),		filterPriceTo		:	get("filter-price-to"),		filterPriceBox		:	get("filter-price-box"),		filterForm			:	get("filter-form"),		filterSelectClass	:	"filter-selector",		priceChar			:	"$",		priceSplitCharTo	:	"-",		priceSplitCharAnd	:	"&",		priceAboveChar		:	""	};		this.temp = {		filterQuantityClickShow : "",		filterPriceClickShow	: ""	};		// 返回对象	return this;};AE.run.wholesale.list.filter.prototype = {		limitInputInt : function(target,event){		var _self = this,config = this.config,temp = this.temp;				// 左右键放行		if("|37|39|".indexOf(event.keyCode)>0)return;				target.value=target.value.replace(/\D/g,"");		target.value=target.value.replace(/^0$/g,"");		// 键入隐藏提示框		if(config.filterQuantityBox){			_self.temp.filterQuantityClickShow.hiddenDirectly(null,true);		}		if(config.filterPriceBox){			_self.temp.filterPriceClickShow.hiddenDirectly(null,true);		}	},	limitInputFloat : function(target,event){		var _self = this,config = this.config,temp = this.temp;		// 左右键放行		if("|37|39|".indexOf(event.keyCode)>0)return;				if(event.type == "paste"){			setTimeout(function(){				target.value = target.value.replace(/[^\d\.]/g,"");				if(target.value.indexOf(".") != -1 && target.value.match(/\./g).length >= 1 && target.value != ""){					var firstPart = target.value.substring(0,target.value.lastIndexOf(".")).replace(/\./g,"");					var lastPart = target.value.substring(target.value.lastIndexOf("."));					if(lastPart == "."){lastPart = "";}					target.value = firstPart+lastPart;					if(lastPart.length > 0){						target.value = parseFloat(target.value,10).toFixed(2);					}				}			},10);		}else{	    if(!(/^\d{0,}(\.\d{0,2})?$/.test(target.value))){								if(typeof(target.selectionStart) == "number"){					var nowPos = target.selectionStart-1;					var firstPart = target.value.substring(0,nowPos);					var lastPart = target.value.substring(nowPos+1);					target.value = firstPart+lastPart;					target.setSelectionRange(nowPos,nowPos);				}else{					var r = document.selection.createRange(); 					r.collapse(false); 					r.setEndPoint("StartToStart", target.createTextRange()); 					var nowPos = r.text.length-1; 										var rng=target.createTextRange()					rng.collapse(); 					rng.select();										var sel = document.selection.createRange();					sel.collapse(false); 					sel.moveStart("character", nowPos);					sel.moveEnd("character", 1);					sel.select();					document.selection.clear();				}	    		    	if(AE.bom.isIE){event.returnValue=false;}else{event.preventDefault();}	 		}		}				// 键入隐藏提示框		if(config.filterQuantityBox){			_self.temp.filterQuantityClickShow.hiddenDirectly(null,true);		}		if(config.filterPriceBox){			_self.temp.filterPriceClickShow.hiddenDirectly(null,true);		}			},	// 初始化	init : function(customConfig){			// 合并配置			this.config = YL.merge(this.config,customConfig||{});			// 定义_self			var _self = this,config = this.config,temp = this.temp;									config.filterQuantity.setAttribute("autocomplete","off");			config.filterPriceFrom.setAttribute("autocomplete","off");			config.filterPriceTo.setAttribute("autocomplete","off");						// 以下代码未整理						var filterQuantityClickShow = _self.temp.filterQuantityClickShow = new AE.widget.clickShow();			filterQuantityClickShow.init({				targetId:config.filterQuantity,				contentId:config.filterQuantityBox,				needMask:true,				showOrHidden :false,				excursion:[0,22]			});						var fqLinks = config.filterQuantityBox.fqLinks = config.filterQuantityBox.getElementsByTagName("a");			for(var i=0;i<fqLinks.length; i++){				var link = fqLinks[i];				YUE.on(link,"click",function(){											 	config.filterQuantity.value = this.innerHTML;											 	filterQuantityClickShow.hiddenDirectly("",true);											 })			}			YUE.on(config.filterQuantity,"keyup",function(event){				_self.limitInputInt(this,event);			});						YUE.on(config.filterQuantity,"keydown",function(event){				_self.limitInputInt(this,event);			});			YUE.on(config.filterPriceFrom,"keyup",function(event){				_self.limitInputFloat(this,event);			});						YUE.on(config.filterPriceFrom,"keydown",function(event){				_self.limitInputFloat(this,event);			});						YUE.on(config.filterPriceTo,"keyup",function(event){				_self.limitInputFloat(this,event);			});						YUE.on(config.filterPriceTo,"keydown",function(event){				_self.limitInputFloat(this,event);			});						YUE.on(config.filterQuantity,"paste",function(event){				_self.limitInputInt(this,event);			});			YUE.on(config.filterPriceFrom,"paste",function(event){				_self.limitInputFloat(this,event);			});						YUE.on(config.filterPriceTo,"paste",function(event){				_self.limitInputFloat(this,event);			});			var filterPriceClickShow = _self.temp.filterPriceClickShow = new AE.widget.clickShow();			filterPriceClickShow.init({				targetId:config.filterPrice,				contentId:config.filterPriceBox,				needMask:true,				showOrHidden :false,				excursion:[0,22]			});						var fpLinks = config.filterPriceBox.fpLinks = config.filterPriceBox.getElementsByTagName("a");			for(var i=0;i<fpLinks.length; i++){				var link = fpLinks[i];				YUE.on(link,"click",function(){											 	if(this.innerHTML.indexOf(config.priceSplitCharTo) > 0){													var priceFromTo = this.innerHTML.split(config.priceSplitCharTo);													config.filterPriceFrom.value = trim(priceFromTo[0]).replace(config.priceChar,"");													config.filterPriceTo.value = trim(priceFromTo[1]).replace(config.priceChar,"");												}else{													var priceFromTo = this.innerHTML.split(config.priceSplitCharAnd);													config.filterPriceFrom.value = trim(priceFromTo[0]).replace(config.priceChar,"");													config.filterPriceTo.value = config.priceAboveChar;												}												filterPriceClickShow.hiddenDirectly("",true);											 })			};			// 校验定义			config.filterForm.onsubmit = function(){								// 数值转换				if(config.filterPriceFrom.value != "" && config.filterPriceFrom.value != 0){					config.filterPriceFrom.value = parseFloat(config.filterPriceFrom.value)?parseFloat(config.filterPriceFrom.value,10):"";				}				if(config.filterPriceTo.value != "" && config.filterPriceTo.value != 0){					config.filterPriceTo.value = parseFloat(config.filterPriceTo.value)?parseFloat(config.filterPriceTo.value,10):"";				}								// 如果没有填写最大 补上				if(trim(config.filterPriceTo.value) == ""){					config.filterPriceTo.value = config.priceAboveChar;				}								// 大小比较自动更换顺序				if(trim(config.filterPriceTo.value) != "" && (parseFloat(config.filterPriceFrom.value) > parseFloat(config.filterPriceTo.value)) ){					var temp = config.filterPriceFrom.value;					config.filterPriceFrom.value = config.filterPriceTo.value;					config.filterPriceTo.value = temp;				}			}			AE.tool.defineEmptyLinks([config.filterQuantityBox,config.filterPriceBox]);						// 回收内存			if(AE.bom.isIE){ CollectGarbage(); }			// 返回对象			return _self;	}};//////////////////////////////////////////////////////////////////////////////////////////////////////////////// 翻页相关//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.run.wholesale.list.pagination = function(config){	this.config = {		 target			:	get("pagination-bottom"),		 pageInput	: get("pagination-bottom-input"),		 goToInput	: get("pagination-bottom-goto"),		 /*url : "/?page=*page*&others",*/		 max	: ""	};		// 返回对象	return this;};AE.run.wholesale.list.pagination.prototype = {		// 限制输入	limitInput : function(target,event){		var _self = this,config = this.config,temp = this.temp;				// 左右键放行		if("|37|39|".indexOf(event.keyCode)>0)return;				target.value=target.value.replace(/\D/g,"");		target.value=target.value.replace(/^0$/g,"");				/* 退格功能    if(config.max && (target.value > config.max)){    	target.value = target.value.substring(0, target.value.length-1);    	if(AE.bom.isIE){event.returnValue=false;}else{event.preventDefault();} 		} 		*/	},		// Go To	goto : function(pageNum){		var _self = this,config = this.config,temp = this.temp;				if(pageNum == "" || pageNum == 0)return;				// 超出最大页等于最后一页		if(pageNum>0 && (pageNum <= config.max)){			var toPage = config.pageInput.value;		}else{			var toPage = config.max;		}				window.location.href = config.target.getElementsByTagName("a")[0].href.replace(eval("/(.*\\/).*(\\.html.*)/ig"),"$1" + toPage + "$2");	},	// 初始化	init : function(customConfig){			// 合并配置			this.config = YL.merge(this.config,customConfig||{});			// 定义_self			var _self = this,config = this.config,temp = this.temp;						var pageInput = config.pageInput;									YUE.on(pageInput,"keyup",function(event){				_self.limitInput(this,event);			});						YUE.on(pageInput,"keydown",function(event){				_self.limitInput(this,event);			});			YUE.on(pageInput,"paste",function(event){				_self.limitInput(this,event);			});			YUE.on(config.goToInput,"click",function(){				_self.goto(config.pageInput.value);			});			YUE.on(config.pageInput,"keyup",function(e){				if(e.keyCode == 13){					_self.goto(config.pageInput.value);				}			});			// 回收内存			if(AE.bom.isIE){ CollectGarbage(); }			// 返回对象			return _self;	}};//////////////////////////////////////////////////////////////////////////////////////////////////////////////// linkFakeSelectors相关	// PS.移植自sourcing//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.run.wholesale.list.linkFakeSelectors = function(config){	this.config = {		 root	: get("main-wrap"),		 targetClass : "link-fake-selector",		 listContainerClass : "list-container",		 selectorMoverClass : "selector-mover",		 maskEnableClass : "mask-enable",		 optionOpenClass : "option-open",		 searchBar : get("page").searchBar,		 filter : get("filter").filter	};		this.temp = {		// linkFakeSelectors : ""		// lastActive : ""	};		// 返回对象	return this;};AE.run.wholesale.list.linkFakeSelectors.prototype = {	// 是否显示	transDisplay : function(el, flagClass){		var result;		if(!YL.isArray(el)){el = [el];}		for(var i = 0, j = el.length; i < j; i++){			var elItem = el[i];			if(YUD.hasClass(elItem, flagClass)){				YUD.removeClass(elItem, flagClass);								// 消失时候失去keyListenerInput焦点				var keyListenerInput = elItem.parentNode.keyListenerInput;				keyListenerInput.blur();				result = false;			}else{				YUD.addClass(elItem, flagClass);				result = true;			}		}		return result;	},		// 初始化	init : function(customConfig){			// 合并配置			this.config = YL.merge(this.config,customConfig||{});			// 定义_self			var _self = this,config = this.config,temp = this.temp;			var refineByBox = config.root;			var linkFakeSelectors = YUD.getElementsByClassName(config.targetClass, 'div', refineByBox);			var linkFakeSelectorsLists = YUD.getElementsByClassName(config.listContainerClass, 'div', refineByBox);			var selectorOnMouseover = function(){					//YUD.addClass(this, config.selectorMoverClass);										// 滑过即去掉当前所选样式					if(this.keyListenerInput){						YUD.removeClass(this.keyListenerInput.lastSelect,"current");						this.keyListenerInput.lastKeyIndex = "";						this.keyListenerInput.keyIndexTimes = 0;					}			};						//var selectorOnMouseout = function(){YUD.removeClass(this, config.selectorMoverClass);};			var selectorOnClick = function(e){								var curList = YUD.getElementsByClassName(config.listContainerClass, 'div', this)[0];				var masks   = YUD.getElementsByClassName(config.maskEnableClass, 'iframe', refineByBox);				var curMask = this.getElementsByTagName('iframe');				YUE.stopPropagation(e);				for(var i = 0; i < linkFakeSelectorsLists.length; i++){					var list = linkFakeSelectorsLists[i];					if(list !== curList){						YUD.removeClass(list, config.optionOpenClass);					}				}				// ↓ 模拟按键事件				if(!this.keyListenerInput){		// first init									// 创建隐藏input 获取焦点和keyCode								var linkFakeSelector = this.parentNode;								var keyListenerInput = this.keyListenerInput = document.createElement("input");								keyListenerInput.style.position = "absolute";								keyListenerInput.style.left = "-5000px";								// 仅允许/切换到英文输入								keyListenerInput.style.imeMode="disabled";								keyListenerInput.maxLength = 0;								linkFakeSelector.appendChild(keyListenerInput);								keyListenerInput.focus();								// 取得所有option								var options = curList.getElementsByTagName("a");																// 生成首字母map								linkFakeSelector.optionsList = {};								for(var i=0; i<options.length; i++){									var option = options[i];									var optionContent = option.innerText?option.innerText:option.textContent;									if(!optionContent)continue;									var firstLetterIndex = trim(optionContent).charAt(0).toUpperCase();									if(!linkFakeSelector.optionsList[firstLetterIndex]){										linkFakeSelector.optionsList[firstLetterIndex] = [];									}																		linkFakeSelector.optionsList[firstLetterIndex].push(option);								}													keyListenerInput.lastSelect = "";								keyListenerInput.lastKeyIndex = "";								keyListenerInput.keyIndexTimes = 0;																								// 按键事件动作初始化								YUE.on(keyListenerInput,"keydown",function(event){										// 清除上个选中										if(this.lastSelect){											YUD.removeClass(this.lastSelect,"current");										}																			 // 回车									 if(event.keyCode == 13){									 	top.location.href = this.lastSelect.href;									 }									 									 // 首字匹配									 var keyIndex = String.fromCharCode(event.keyCode).toUpperCase();									 // 首字匹配 tab = 下一个匹配									 if(event.keyCode == 9){									 	keyIndex = keyListenerInput.lastKeyIndex;									 	if(AE.bom.isIE){event.returnValue=false;}else{event.preventDefault();}									 }									 // ← ↑ = 上一个邻居									 if("|37|38|".indexOf(event.keyCode) > 0 ){											if(!this.lastSelect || !YUD.getPreviousSibling(this.lastSelect)){												this.lastSelect = options[options.length-1];											}else{												this.lastSelect = YUD.getPreviousSibling(this.lastSelect);											}									 }									 // → ↓ = 下一个邻居									 if("|40|39|".indexOf(event.keyCode) > 0 ){											if(!this.lastSelect || !YUD.getNextSibling(this.lastSelect)){												this.lastSelect = options[0];											}else{												this.lastSelect = YUD.getNextSibling(this.lastSelect);											}									 }									 									 // 上下左右控制									 if("|37|38|40|39|".indexOf(event.keyCode) > 0){									 		YUD.addClass(this.lastSelect,"current");										if(curList.scrollHeight > curList.offsetHeight){	// 有滚动条的情况											var scrollAnim = new YAHOO.util.Scroll(curList,{scroll:{to:[0,((YUD.getY(this.lastSelect)+curList.scrollTop) - YUD.getY(curList) - 3)]}},0.2);											scrollAnim.animate();										}																			 		return this.lastSelect;									 }									 									 // 如果是首字匹配模式									 if(linkFakeSelector.optionsList[keyIndex] && "|37|38|40|39|".indexOf(event.keyCode) == -1){									 										 											 if(keyIndex == keyListenerInput.lastKeyIndex){										 	 this.keyIndexTimes++;										 }										 								 		// 循环									 	if(this.keyIndexTimes+1 > linkFakeSelector.optionsList[keyIndex].length){									 		this.keyIndexTimes = 0;									 	}									 										 	var selectOption = linkFakeSelector.optionsList[keyIndex][this.keyIndexTimes];									 	YUD.addClass(selectOption,"current");																														if(curList.scrollHeight > curList.offsetHeight){	// 有滚动条的情况											var scrollAnim = new YAHOO.util.Scroll(curList,{scroll:{to:[0,((YUD.getY(selectOption)+curList.scrollTop) - YUD.getY(curList) - 3)]}},0.2);											scrollAnim.animate();										}																			 	this.lastSelect = selectOption;									 	this.lastKeyIndex = keyIndex;									 }									 									 									 if("|13|9|37|38|39|40|".indexOf(event.keyCode) > 0 ){									 	if(AE.bom.isIE){event.returnValue=false;}else{event.preventDefault();}									 }									 								})													YUE.on(curList,"scroll",function(){									keyListenerInput.focus();								})									}else{								// 第二次点开								curList.scrollTop = 0;								YUD.removeClass(this.keyListenerInput.lastSelect,"current");								this.keyListenerInput.lastKeyIndex = "";								this.keyListenerInput.keyIndexTimes = 0;								this.keyListenerInput.focus();				}				// ↑ 模拟按键事件				_self.transDisplay(curList, config.optionOpenClass);				if(masks.length > 0){YUD.removeClass(masks, config.maskEnableClass);};				if(curMask.length > 0){					YUD.setStyle(curMask[0], 'width', curList.offsetWidth + 'px');					YUD.setStyle(curMask[0], 'height', curList.offsetHeight + 'px');					_self.transDisplay(curMask[0], config.maskEnableClass);				}								if(config.searchBar){					searchBar.intelligentObj.UIController.hideList();					searchBar.selectorTop.rollup();				}								if(config.filter){					config.filter.temp.filterPriceClickShow.hiddenDirectly(null,true);					config.filter.temp.filterQuantityClickShow.hiddenDirectly(null,true);				}								//_self.temp.lastActive = curList;			};						YUE.on(linkFakeSelectors, 'mouseover', selectorOnMouseover);			//YUE.on(linkFakeSelectors, 'mouseout', selectorOnMouseout);			YUE.on(linkFakeSelectors, 'click', selectorOnClick);			YUE.on(document.body || document.documentElement, 'click', function(){				var masks = YUD.getElementsByClassName(config.maskEnableClass, 'iframe', refineByBox);				if(masks.length > 0){YUD.removeClass(masks, config.maskEnableClass);};				YUD.removeClass(linkFakeSelectorsLists, config.optionOpenClass);			});		// 回收内存		if(AE.bom.isIE){ CollectGarbage(); }		return _self;	}};//////////////////////////////////////////////////////////////////////////////////////////////////////////////// relatedSearches相关//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.run.wholesale.list.relatedSearches = function(config){	this.config = {		target : get("related-searches"),		viewMoreClass : "view-more",		viewMoreContentClass : "view-more-content"	};		this.temp = {		viewMoreBtn : "",		viewMoreContent : ""	};		// 返回对象	return this;};AE.run.wholesale.list.relatedSearches.prototype = {	// 初始化	init : function(customConfig){			// 合并配置			this.config = YL.merge(this.config,customConfig||{});			// 定义_self			var _self = this,config = this.config,temp = this.temp;			var viewMoreBtn = _self.temp.viewMoreBtn = YUD.getElementsByClassName(config.viewMoreClass,"*",config.target)[0];			var viewMoreContent = _self.temp.viewMoreContent = YUD.getElementsByClassName(config.viewMoreContentClass,"*",config.target)[0];			YUE.on(viewMoreBtn,"click",function(){													if(YUD.hasClass(viewMoreBtn,"view-more")){														YUD.replaceClass(viewMoreBtn,"view-more","view-less");														viewMoreBtn.innerHTML = "View Less";														viewMoreContent.style.display = "block";													}else{														YUD.replaceClass(viewMoreBtn,"view-less","view-more");														viewMoreBtn.innerHTML = "View More";														viewMoreContent.style.display = "none";													}												 })			AE.tool.defineEmptyLinks(config.target);	}};//////////////////////////////////////////////////////////////////////////////////////////////////////////////// LIST ITEMS 相关//////////////////////////////////////////////////////////////////////////////////////////////////////////////AE.run.wholesale.list.listItems = function(config){	this.config = {		target : get("list-items"),									// 产品列表组件		listForm : get("list-form"),								// list form		checkAllBtn : get("list-form-checkall"),		// 全选按钮		selectedIdsInput : get("list-form-selected-ids"),	// 选中 id input		itemCheckBoxClass : "item-checkbox",				// item checkbox class name		noSelectText : "No item(s) selected.",			// 未选中				listFormReportAction : "report.htm",				// linkFormAction report action		reportBtn : get("list-form-report-btn"),		// 投诉按钮		noPhotoSrc : "http://img.alibaba.com/images/eng/wholesale/icon/nophoto.gif"		// 无图替代	};		this.temp = {		productPics : [],		//	所有产品列表中的图片		checkboxs		:	[]		//	所有产品的checkbox	};		return this;};AE.run.wholesale.list.listItems.prototype = {		// 填充已选序号到form隐藏域	fillSelectedId : function(){		var _self = this,config = this.config,temp = this.temp;		config.selectedIdsInput.value = "";		var selectedIds = [];		for(var i = 0; i<temp.checkboxs.length; i++){			var chk = temp.checkboxs[i];			if(chk.checked){				selectedIds.push(chk.value);			}		};		config.selectedIdsInput.value = selectedIds.join(",");	},		// 全选/反选	checkAllBoxes : function(args){	//	o : 全选input obj		var _self = this,config = this.config,temp = this.temp;		var checkStatus = args.o.checked;		for(var i = 0; i<temp.checkboxs.length; i++){			var chk = temp.checkboxs[i];			chk.checked = checkStatus;		};	},		// 点选checkbox	checkBoxCheck : function(args){	//	o : 当前选择的checkbox		var _self = this,config = this.config,temp = this.temp;		var checkbox = args.o;		if(_self.isCheckAll()){			config.checkAllBtn.checked = true;		}else{			config.checkAllBtn.checked = false;		}	},		// 是否已全选	isCheckAll : function(){		var _self = this,config = this.config,temp = this.temp;		for(var i = 0; i<temp.checkboxs.length; i++){			var chk = temp.checkboxs[i];			if(!chk.checked){return false}		};		return true;	},		// 举报操作	itemReport : function(){		var _self = this,config = this.config,temp = this.temp;		_self.fillSelectedId();		if(config.selectedIdsInput.value == ""){			alert(config.noSelectText);			return;		}		config.listForm.action = config.listFormReportAction;		config.listForm.submit();	},	defineTemps : function(){		var _self = this,config = this.config,temp = this.temp;		// 缓存产品列表中的图片		temp.productPics = YUD.getElementsByClassName("picCore","img",config.target);		// 页面checkboxes		temp.checkboxs = YUD.getElementsByClassName(config.itemCheckBoxClass,"input",config.target);	},		defineEvents : function(){		var _self = this,config = this.config,temp = this.temp;				// 全选勾选框		YUE.on(config.checkAllBtn,"click",function(){			_self.checkAllBoxes({o:this});		});				// checkbox 捆绑		YUE.on(temp.checkboxs,"click",function(){			_self.checkBoxCheck({o:this});		});				// report event		YUE.on(config.reportBtn,"click",function(){			_self.itemReport();		});			},		run : function(){		var _self = this,config = this.config,temp = this.temp;		// 图片 no photo 探测 重置 src		YUE.on(window,"load",function(){			if(AE.bom.isIE){				for(var i=0;i<temp.productPics.length;i++){					var productPic = temp.productPics[i];					if(productPic.readyState != "complete"){						productPic.src = config.noPhotoSrc;					};				};			}else{				// for ff & other				for(var i=0;i<temp.productPics.length;i++){					var productPic = temp.productPics[i];										// 清除alt再计算offsetHeight					var bakAlt = productPic.alt;					productPic.removeAttribute("alt");										// 清除瞬间不能得到正确的offsetHeight					setTimeout(function(o){						if(o.pic.offsetHeight == 0){							o.pic.src = config.noPhotoSrc;							if(o.alt){								o.pic.setAttribute("alt",o.alt);							}						};					},10,{pic:productPic,alt:bakAlt});				};			}		});	},		// 初始化	init : function(customConfig){			// 合并配置			this.config = YL.merge(this.config,customConfig||{});			// 定义_self			var _self = this,config = this.config,temp = this.temp;			_self.defineTemps();			_self.defineEvents();			_self.run();			if(AE.bom.isIE){ CollectGarbage(); }			return _self;	}};/** * 加载 Add to Cart */if(!AE.run.AddToCartList) {AE.run.AddToCartList = function () {	// 默认配置	this.config = {		listId					:'',	// 列表元素		itemClassName			:'',	// 条目元素		buttonClassName			:'',	// 按钮		productIdClassName		:'',	// 产品 ID		productStandardClassName:'',	// 产品规格		loadingClassName		:'',	// 加载类名		successClassName		:'',	// 成功类名		failedClassName			:'',	// 失败类名		loadingMessage			:'',	// 加载信息		successMessage			:'',	// 成功信息		failedMessage			:'',	// 失败信息		actionUrl				:'',	// 提交事件的 URL		proxyUrl				:'',	// 提交代理的 URL		proxyDomain			:'alibaba.com'	// 代理域名	};};AE.run.AddToCartList.prototype = {	init: function(customConfig) {		this.config = YL.merge(this.config,customConfig || {});		var _self = this, config = this.config;		var list = get(config.listId);		var items = YUD.getElementsByClassName(config.itemClassName, '*', list);		for(var i=0; i<items.length; i++) {			var item = items[i];			var button = YUD.getElementsByClassName(config.buttonClassName, '*', item)[0];			var productId = YUD.getElementsByClassName(config.productIdClassName, '*', item)[0].value;			var productStandard = YUD.getElementsByClassName(config.productStandardClassName, '*', item)[0].value;			YUE.on(button, 'click', _self.add, {				_self			:_self,				button			:button,				productId		:productId,				productStandard	:productStandard			});		}	},	add: function(ev, args) {		var _self = args._self;		var config = _self.config;		var button = args.button;		var productId = args.productId;		var productStandard = args.productStandard;		var wrap = button.parentNode;		wrap.innerHTML = _self.getContent(config.loadingClassName, config.loadingMessage);				// 参数		var params = 'productId=' + productId + '&standard=' + productStandard;		// 异步处理		(new AE.run.ajaxProxy()).asyncRequest('POST', config.actionUrl, {			success: function(data) {				wrap.innerHTML = _self.getContent(config.successClassName, config.successMessage);			},			failure: function(data) {				wrap.innerHTML = _self.getContent(config.failedClassName, config.failedMessage);			},			timeout: 5000		}, params, {proxy: config.proxyUrl, domain:config.proxyDomain});	},	getContent: function(className, message) {		return '<span class="' + className + '">' + message + '</span>';	}};}