releaseGoods.js
87.1 KB
/*! dili 2016-01-06 */
function isIdCardNo(num){num=num.toUpperCase();var intCheckDigit,factorArr=new Array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1),parityBit=new Array("1","0","X","9","8","7","6","5","4","3","2"),varArray=new Array,lngProduct=0,intStrLen=num.length,idNumber=num;if(15!=intStrLen&&18!=intStrLen)return!1;for(i=0;i<intStrLen;i++){if(varArray[i]=idNumber.charAt(i),(varArray[i]<"0"||varArray[i]>"9")&&17!=i)return!1;i<17&&(varArray[i]=varArray[i]*factorArr[i])}if(18==intStrLen){var date8=idNumber.substring(6,14);if(0==isDate8(date8))return!1;for(i=0;i<17;i++)lngProduct+=varArray[i];if(intCheckDigit=parityBit[lngProduct%11],varArray[17]!=intCheckDigit)return!1}else{var date6=idNumber.substring(6,12);if(0==isDate6(date6))return!1}return!0}function isDate6(sDate){if(!/^[0-9]{6}$/.test(sDate))return!1;var year,month,myDate=new Date,nowyear=myDate.getFullYear();return year=sDate.substring(0,4),month=sDate.substring(4,6),year>nowyear?!1:1700>year||year>2500?!1:1>month||month>12?!1:!0}function isDate8(sDate){if(!/^[0-9]{8}$/.test(sDate))return!1;var year,month,day,myDate=new Date,nowyear=myDate.getFullYear();year=sDate.substring(0,4),month=sDate.substring(4,6),day=sDate.substring(6,8);var iaMonthDays=[31,28,31,30,31,30,31,31,30,31,30,31];return year>nowyear?!1:1700>year||year>2500?!1:((year%4==0&&year%100!=0||year%400==0)&&(iaMonthDays[1]=29),1>month||month>12?!1:1>day||day>iaMonthDays[month-1]?!1:!0)}function reg(value){var len=value.length;switch(len){case 13:return/[0-9a-zA-Z]{13}/.test(value);case 15:return/[0-9a-zA-Z]{15}/.test(value);case 18:return/[0-9a-zA-Z]{18}/.test(value);default:return!1}}define(function(require,exports,module){var SalesData=function(arges){var array=[],len=0,indexs={},config={odata:{},sdata:[],trview:arges.rootView&&$(arges.rootView).find("tr").length>0?$(arges.rootView).find("tr"):$(arges.rootView).find(".attribute"),radioview:arges.radioNmae?$(arges.radioNmae):null,currentview:arges.showView?$(arges.showView):null,titles:[],data:[],isdata:{},setview:null,res:[{"class":"price",dilipattern:"/^[0-9]+$/,可售量有误!",value:"",name:""},{"class":"stockNum",dilipattern:"/^[0-9]+$/,可售量有误!",dilimethod:"checkProductStockNum",value:"",name:""},{"class":"minNum",dilipattern:"/^[0-9]+$/,可售量有误!",dilimethod:"checkProductStockNum",value:"",name:""}],httpdata:{},sku:{}},events={change:null},methods={updata:function(){config.sdata=[],config.data=[],array=[];for(i in config.odata)config.sdata.push(config.odata[i].data);for(var i=0;i<config.sdata.length;i++){for(var list=[],k=0;k<config.sdata[i].length;k++)if(config.sdata[i][k].bl){var ack=config.sdata[i][k];list.push({txt:ack.name,val:ack.val,data:ack.data?ack.data:null})}list.length>0&&array.push(list)}len=array.length,methods.specialSort(-1),methods.setdata()},getdata:function(){for(var texts=[],skus={},i=0;i<config.setdata.length;i++)if(config.setdata[i].sku){for(var txt="",attribute=methods.skuString(config.setdata[i].sku),keys=config.setdata[i].sku.split(":"),k=0;k<attribute.length;k++)skus[keys[k]]||texts.push({txt:attribute[k],sku:keys[k]}),txt+=attribute[k];config.setdata[i].attribute=attribute,config.httpdata[txt]=config.setdata[i]}methods.upview(texts);var w=0;for(i in config.odata)config.odata[i].changeData(),w++},skuString:function(sku){for(var sku=sku.split(":"),attribute=[],i=0;i<sku.length;i++)attribute.push(config.sku[sku[i]]);return attribute},setdata:function(){var unit=config.radioview.find("option:selected").length>0?config.radioview.find("option:selected").text():$("#unit").text(),results=config.data,current=config.currentview.find("tbody");return current.html(""),methods.showdata(results),""==unit||results.length<=0||results[0].length<config.sdata.length?!1:void(config.setview?config.setview(unit):methods.updateview(unit))},showdata:function(results){config.isdata={};for(var i=0;i<results.length;i++){for(var text="",sku="",abj={},attribute=[],adata=results[i],k=0;k<adata.length;k++)sku+=adata[k].val,k!=adata.length-1&&(sku+=":"),text+=adata[k].txt,attribute.push(adata[k].txt);config.httpdata[text]?config.isdata[text]=config.httpdata[text]:(abj.sku=sku,abj.data=methods.copy(),abj.attribute=attribute,config.isdata[text]=abj)}},oevent:function(cals){this.data=[];var self=this;return $("."+cals).bind("change",function(){self.data=[],self.changeData()}),this.changeData=function(data){$("."+cals).each(function(){var name=$(this).attr("alt");"checked"==$(this).attr("checked")?self.data.push({bl:!0,name:name,val:$(this).attr("value"),data:data?data:null}):self.data.push({bl:!1,name:name,val:"",data:data?data:null})}),methods.updata()},this},upview:function(data){config.trview.find(":checkbox").prop("checked",!1),config.trview.each(function(){$(this).hasClass("attribute")&&$(this).find("input").each(function(){for(var val=$(this).val(),key=$(this).attr("alt"),i=0;i<data.length;i++)data[i].txt?val==data[i].sku&&$(this).prop("checked",!0):key==data[i]&&$(this).prop("checked",!0)})})},start:function(){$.extend(config,arges),config.trview.each(function(){if($(this).hasClass("attribute")){var title=$(this).find("input").attr("class"),checkbox=new methods.oevent(title);config.odata[title]=checkbox,config.sdata.push(checkbox.data),$(this).find("input").each(function(){config.sku[$(this).val()]=$(this).attr("alt")})}}),config.setdata&&methods.getdata(),methods.eventinput()},specialSort:function(start){if(start++,!(start>len-1))for(indexs[start]||(indexs[start]=0),array[start]instanceof Array||(array[start]=[array[start]]),indexs[start]=0;indexs[start]<array[start].length;indexs[start]++)if(methods.specialSort(start),start==len-1){for(var temp=[],i=len-1;i>=0;i--)array[start-i]instanceof Array||(array[start-i]=[array[start-i]]),temp.push(array[start-i][indexs[start-i]]);config.data.push(temp)}},unique:function(list){for(var res=[],json={},i=0;i<list.length;i++)json[list[i]]||(res.push(list[i]),json[list[i]]=1);return res},updateview:function(unit){var current=config.currentview.find("tbody");current.html("");var data=config.isdata;for(k in data){for(var view="<tr>",alist=data[k].attribute,moredata=data[k].data,i=0;i<alist.length;i++)view+='<td class="txt" val="'+data[k].sku+'">'+alist[i]+"</td>";view+=moredata&&moredata[0]?methods.issku(moredata,unit,data[k].sku):methods.onsku(moredata,unit,data[k].sku),current.append(view)}},issku:function(moredata,unit,sku){for(var view="",j=0;j<moredata.length;j++)view+='<td><input index="'+j+'" type="text" sku='+sku,view+=methods.automatic(moredata[j],sku),view+=" />"+(moredata[j]["class"]&&(methods.hasClass(moredata[j]["class"],"stockNum")||methods.hasClass(moredata[j]["class"],"minNum"))?"":"元/")+'<span class="t-unit">'+unit+"</span></td>";return view},onsku:function(moredata,unit,sku){for(var view="",k=0;k<moredata.length;k++)view+='<td><input index="'+k+'" type="text" sku='+sku+methods.automatic(config.res[k],sku)+" />"+(config.res[k]["class"]&&(methods.hasClass(config.res[k]["class"],"stockNum")||methods.hasClass(config.res[k]["class"],"minNum"))?"":"元/")+'<span class="t-unit">'+unit+"</span></td>";return view},automatic:function(data,sku){var view=" ";for(f in data)view+="name"!=f||data[f]?" "+f+'="'+data[f]+'"':" "+f+'="'+(sku+":"+data["class"])+'"';return view},eventinput:function(){var current=config.currentview;current.find("input").live("change",function(){var thisview=$(this),pview=thisview.parent().parent(),text="",index=0,attribute=[],sku="";if(pview.find(".txt").each(function(){text+=$(this).html(),attribute.push($(this).html())}),sku=thisview.attr("sku"),index=parseInt(thisview.attr("index")),config.httpdata[text])config.httpdata[text].data[index].value=thisview.val();else{var aobj={attribute:attribute,sku:sku,data:methods.copy()};aobj.data[index].value=thisview.val(),config.httpdata[text]=aobj}}),config.radioview.change(function(){events.change&&events.change()})},cloneObj:function(obj){var newO={};obj instanceof Array&&(newO=[]);for(var key in obj){var val=obj[key];newO[key]="object"==typeof val?arguments.callee(val):val}return newO},copy:function(){var res=new Array;for(i in config.res)res.push(methods.cloneObj(config.res[i]));return res},hasClass:function(text,txt){text=text.split(" ");for(i in text)if(text[i]==txt)return!0;return!1}};return this.event=function(key,callback){"function"==typeof callback&&(events[key]=callback)},this.setData=function(data){config.setdata=data,methods.getdata()},this.changeData=function(){var texts=[],data=[];for(i in config.isdata){i;data=config.isdata[i].attribute;for(var k=0;k<data.length;k++)texts.push(data[k])}methods.upview(methods.unique(texts));var w=0;for(i in config.odata)config.odata[i].changeData(),w++},this.eachData=function(){var data=[];config.odata.length;if(config.currentview.find("tbody tr").each(function(){var abj={data:[]};abj.sku=$(this).find("td").eq(0).attr("val").split(":").slice(1);for(var key="",k=0;k<abj.sku.length;k++)key+=abj.sku[k],k!=abj.sku.length-1&&(key+=":");abj.sku=key,$(this).find("input").each(function(){var elProp={};$(this).attr("dilipattern")&&(elProp.dilipattern=$(this).attr("dilipattern")),$(this).attr("dilimethod")&&(elProp.dilimethod=$(this).attr("dilimethod")),$(this).attr("money")&&(elProp.money=$(this).attr("money")),$(this).attr("digits")&&(elProp.digits=$(this).attr("digits")),$(this).attr("maxlength")&&(elProp.maxlength=$(this).attr("maxlength")),$(this).attr("range")&&(elProp.range=$(this).attr("range")),$(this).attr("min")&&(elProp.min=$(this).attr("min")),$(this).attr("max")&&(elProp.max=$(this).attr("max")),elProp.value=$(this).val(),elProp["class"]=$(this).attr("class"),elProp.sku=$(this).attr("sku"),elProp.vsku=$(this).attr("vsku"),elProp.name=$(this).attr("name"),abj.data.push(elProp)}),data.push(abj)}),data.length<=0)return!1;config.setdata=data,methods.getdata();var w=0;for(i in config.odata)config.odata[i].changeData(),w++},methods.start(),this};return SalesData}),define("jselect",function(require){function jselectMain(target,_this,options){this.target=target,this._total_len=_this.length,this.opt={viewNum:8,disabledClass:"model_disabled",unClickClass:"disabled_click",selectedClass:this.name+"-selected",searchBar:!1,onSelect:function(){}},$.extend(this.opt,options),this.Init()}function domsearch(target,options){this.target=target,this.opt={dataItem:null,dataSource:null,autoQuick:!0},$.extend(this.opt,options),this.init()}var prevTarget=null,_list=[],jselect=function(elems,options){var _list=$(elems);_list.each(function(i){this._index=i,new jselectMain(this,_list,options)})};return jselectMain.prototype={name:"pack_jselect",Init:function(){this.GetModel(),$(this.target).is(":disabled"),this.Bind()},GetModel:function(){var _this=this,id=$(this.target).attr("id"),zi=parseInt(this._total_len)-parseInt(this.target._index);(void 0==id||""==id)&&(id=(new Date).getTime()*Math.round(999*Math.random())),id=id+"-"+this.name,(void 0==zi||isNaN(zi))&&(zi=0);var selectedOp=$(this.target).find("option:selected"),curClass=$(this.target).attr("class"),searchBarHtml=_this.opt.searchBar&&$(this.target).find("option").length>10?'<p class="s-select-bar"><input type="text"/></p>':"",htmlArr=[" <div style='z-index:"+zi+";' id='"+id+"' class='"+this.name+" "+curClass+"'> <div style=\"position:relative;z-index:1;overflow:hidden;\" class='"+(selectedOp.attr("class")||"")+"' value='"+selectedOp.val()+"'> <span>"+selectedOp.text()+"</span> <em class='"+this.name+"_arrow'><em></em></em> </div> <input style=\"position:absolute;z-index:-1;width:1px;height:1px;border:0;margin:0 0 0 -10000px;\" id='"+id+"-search' class='"+this.name+'-search\' type="text" value="" name='+id+'/> <ol class="s-pack_jselect-list" style=\'z-index:'+zi+";'>"+searchBarHtml+" <ul>"];$(this.target).find("option").each(function(i){var selectedClass=$(this).attr("class")?$(this).attr("class"):"",oClass=$(this).attr("class")?"oclass="+$(this).attr("class"):"";selectedOp.index()==i&&(selectedClass+=" "+_this.opt.selectedClass);var bgpart="",s_color=$(this).attr("s-color");if(s_color){var bg="";bg=/^#/.test(s_color)?"background-color: "+s_color:'background-image: url("'+s_color+'")',bgpart="<b class='s-color' style='"+bg+"'></b>"}var _disabledClass=$(this).is(":disabled")?_this.opt.unClickClass:"";htmlArr.push('<li class="'+_disabledClass+" "+selectedClass+'" '+oClass+' value="'+$(this).val()+'">'+bgpart+"<span>"+$(this).text()+"</span></li>")}),htmlArr.push("</ul></ol></div>"),$("#"+id).length&&$("#"+id).remove(),$(this.target).after(htmlArr.join("")),this.target._$smodel=$("#"+id),$(this.target).is(":disabled")&&this.target._$smodel.addClass(this.opt.disabledClass).attr("disabled","disabled"),_list.push(this.target._$smodel),this._$focus=this.target._$smodel.find("div"),this._$ul=this.target._$smodel.find(".s-pack_jselect-list"),this._$search=$("#"+id+"-search"),this.SetStyle()},SetStyle:function(){var real_w=this.target._$smodel.find("."+this.name+"_arrow").outerWidth(!0)+$(this.target).outerWidth(!0);this.target._$smodel.css("width",real_w);var toSet=$(this.target).attr("rel");if(toSet)for(var setArr=toSet.split(","),i=0;i<setArr.length;i++){var s=setArr[i],sArr=s.split(":"),pro=sArr[0],val=sArr[1];this.target._$smodel.css(pro,val)}this.SetModelListHeight(),$(this.target).hide(),this._$ul.hide()},SetModelListHeight:function(){var _this=this;if(this.opt.viewNum&&$(this.target).find("option").length>this.opt.viewNum){var hei=0;this._$ul.find("li").each(function(i){i<_this.opt.viewNum&&(hei+=$(this).outerHeight(!0))}),this._$ul.find("ul").css({height:hei,"overflow-y":"scroll"})}},GetMaxIndex:function(){var z=0,list=$(".pack_jselect"),len=list.length;return list.each(function(){var zi=parseInt($(this).css("z-index"));z=Math.max(z,zi?zi:len)}),z+1},Bind:function(fn){var _this=this;this._$focus.bind("click."+this.name,function(event){return clearTimeout(_this.timer),$(_this._$ul).css("z-index",_this.GetMaxIndex()),_this.target._$smodel&&_this.target._$smodel.hasClass(_this.opt.disabledClass)||void 0!==_this.target._$smodel.attr("disabled")?void 0:(_this.timer=setTimeout(function(){event.target!==prevTarget&&$.each(_list,function(i,item){item.find(".s-pack_jselect-list").hide(),item.css({"z-index":"1"})}),_this[_this._$ul.is(":hidden")?"Open":"Close"](),prevTarget=event.target},100),!1)}),$(this.target).bind("change."+this.name,function(){var selectedOption=$(this).find("option:selected"),selectedIndex=selectedOption.index();_this.UpdateModel(selectedIndex),""!=$(this).val()&&$(this).parent().find("label.error").length>0&&$(this).parent().find("label.error").remove()}),this._$ul.find("li").each(function(i){this._index=i}).bind("click."+this.name,function(){return $(this).hasClass(_this.opt.unClickClass)||$(this).hasClass("s-select-bar")?!1:void($(this).hasClass("pack_jselect-selected")?_this.Close():_this.Apply(this._index))}).bind("mouseover."+this.name,function(){var firstWord=$(this).text().charAt(0);_this._$search.val(firstWord)}),this._$ul.bind("mouseover."+this.name,function(){_this._in=!0}),this._$ul.bind("mouseout."+this.name,function(){_this._in=!1}),this._$search.bind("keyup."+this.name,function(event){var v=_this._$search.val(),lastWord=v.charAt(v.length-1),index=_this.matchIndex(lastWord);null!==index&&0!==index&&(_this.UpdateModel(index),_this.SetDropScrollTop(index)),13==event.keyCode&&(_this.Apply(index),_this._$search.val(""))}),this.opt.searchBar&&new domsearch(this._$ul.find(".s-select-bar input"),{dataItem:this._$ul.find("ul li"),dataSource:"span",autoQuick:!0}),$(document).bind("click."+this.name,function(){_this._in||_this.Close()}),this._$focus.bind("selectstart",function(){return!1}),this._$focus.bind("select",function(){document.selection.empty()})},Apply:function(index){var _this=this,elem=$(this.target).attr("sml:sametrigger")?$($(this.target).attr("sml:sametrigger")):$(this.target);elem.each(function(){var curOption=$(this).find("option").eq(index),curLi=_this._$ul.find("li").eq(index);curOption.attr("selected","selected"),$(this).triggerHandler("change"),_this.opt.onSelect.call(curOption,index,curLi)}),this.UpdateModel(index),this._$ul.fadeOut(100)},Open:function(){this._$ul.css({width:this._$focus.innerWidth()}),this._$search.focus(),this._$ul.fadeIn(100),this.target._$smodel.css({"z-index":"9999"}),this.opt.searchBar&&this._$ul.find(".s-select-bar input").focus()},Close:function(){$.each(_list,function(i,item){}),this._$ul.fadeOut(100),this.target._$smodel.css({"z-index":"1"}),this._in=!1},UpdateModel:function(index){var list=this._$ul.find("li"),c=void 0==list.eq(index).attr("oclass")?"":list.eq(index).attr("oclass");this._$focus.attr({value:list.eq(index).attr("val"),"class":c}),this._$focus.find("span").html(list.eq(index).text()),list.removeClass(this.opt.selectedClass),list.eq(index).addClass(this.opt.selectedClass)},SetDropScrollTop:function(index){var list=this._$ul.find("li"),cur=list.eq(index);this._$ul.scrollTop(cur.outerHeight(!0)*index)},matchIndex:function(str){for(var list=this._$ul.find("li"),i=0;i<list.length;i++){var item=list.eq(i),firstWord=item.text().charAt(0);if(firstWord.toLocaleUpperCase()===str.toLocaleUpperCase())return i}return null}},domsearch.prototype={init:function(){var _this=this;this.opt.autoQuick&&this.createQuick(),$(this.target).keyup(function(){var arr=_this.getMatch($.trim($(this).val()));_this.reload(arr)})},createQuick:function(){var _this=this;$(this.opt.dataItem).each(function(){var elem=_this.getDataFrom(this),text=_this.getText(elem);if(text.length&&"string"==typeof text){for(var qstr="",arr=text.split(""),i=0;i<arr.length;i++)qstr+=arr[i].charAt(0);elem.attr("dom-search-autoquick",qstr)}})},getMatch:function(val){var _this=this,match_arr=[],expr=new RegExp("^.*"+val,"i");return $(this.opt.dataItem).each(function(){var elem=_this.getDataFrom(this);(expr.test(_this.getText(elem))||expr.test(elem.attr("dom-search-autoquick")))&&match_arr.push(this)}),match_arr},getDataFrom:function(target){var ds=this.opt.dataSource;return ds?/^@/.test(ds)?$(target):$(target).find(ds):$(target)},getText:function(elem){var ds=this.opt.dataSource;return/^@/.test(ds)?elem.attr(ds.replace(/^@/,"")):elem.text()},reload:function(arr){$(this.opt.dataItem).not(arr).hide(),$(this.opt.dataItem).filter(arr).show()}},jselect});var region=function(){var regions=[],param={floor:0},MultiLevel=function(){var _this=this,config={data:{},view:"",parameter:{url:"",setUrl:"",id:0,field:{pid:"parentId",did:"regionId",name:"regionName"},param:"parentId",setNmae:"city"},heads:[],sub:0,constraintTier:0,page:0,isEvents:!0,isinternation:0,forcePage:1},methods={foundView:function(verify,sub){var place=config.view.attr("data-place");place?0:place="请选择";var _v=verify,view='<div class="title"><span><input type="text" readonly="readonly" '+(_v?'class="required"':"")+"name=region"+sub+' placeholder="'+place+'"/></span><span class="s-live"></span><p class="region-data" style="display: none;"></p></div><div class="region-view"><div class="head"><ul></ul><span class="reset">重置</span></div><div class="cont clearfix"><ul></ul></div></div>';config.view.html(view),this.parseParam(),methods.events()},parseParam:function(){var param=null;try{param=config.view.attr("data"),param=param.split(","),config.parameter.setNmae=param[0],config.parameter.field.pid=param[1],config.parameter.field.did=param[2],config.parameter.field.name=param[3],config.parameter.param=param[4],config.constraintTier=parseInt(param[5]),config.forcePage=param[6]?parseInt(param[6]):1}catch(error){methods.error("朋友参数传递错误了,请仔细检查下",error)}return config.view.attr("setUrl")?(config.parameter.setUrl=config.view.attr("setUrl"),methods.setValue(),!1):void methods.http()},setUrl:function(){config.view.attr("url")?config.parameter.url=config.view.attr("url"):methods.error("朋友参数url没有设置,请仔细检查下"),config.parameter.url=config.parameter.url+"?"+config.parameter.param+"="+config.parameter.id},http:function(){return param.floor&&config.heads.length>=param.floor?(methods.setData(),!1):methods.getStorage(config.parameter.id)?(methods.setView(methods.getStorage(config.parameter.id)),!0):(methods.setUrl(),void $.ajax({type:"GET",url:config.parameter.url,dataType:"jsonp",success:function(data){methods.setStorage(data)},error:function(e,s,c){methods.error("请求数据异常~~~",{e:e,s:s,c:c})}}))},setStorage:function(data){data=methods.tidiesData(data),data&&data.length>0?(config.data[config.parameter.id]=data,methods.setView(data)):(methods.setData(),config.view.find(".region-view").hide())},tidiesData:function(data){var list=[];for(i in data)if(-9999==data[i][config.parameter.field.pid])data[i][config.parameter.field.pid]=0,list.push(data[i]),config.isinternation=1;else{if(0!=data[i][config.parameter.field.pid]||!config.isinternation)return data;data[i][config.parameter.field.pid]=-10,list.push(data[i])}return list},getStorage:function(id){return config.data[id]?config.data[id]:!1},setView:function(data){methods.setHead(data),methods.setCont(data)},setHead:function(data){config.view.find(".head ul").html("");var view="";for(i in config.heads)view+='<li class="" zindex="'+config.page+'" did="'+config.heads[i].id+'" pid="'+config.heads[i].pid+'">'+config.heads[i].name+"</li>";view+='<li class="act" zindex="'+config.page+'" pid="">请选择</li>',config.view.find(".head ul").html(view)},setCont:function(data){config.view.find(".cont ul").html("");var view="";for(i in data)"其他城市"!=data[i].regionName&&"其他省份"!=data[i].regionName&&"其他区县"!=data[i].regionName&&(view+='<li class="" zindex="'+config.page+'" pid="'+data[i][config.parameter.field.pid]+'" did="'+data[i][config.parameter.field.did]+'">'+data[i][config.parameter.field.name]+"</li>");config.view.find(".cont ul").html(view)},setData:function(data){var list=[],id=0,str="";list=data?data:config.heads;for(i in list)str+=" "+list[i].name,parseInt(i)==list.length-1&&(id=list[i].id);var isInput=config.view.prevAll(".region-hide");if(!isInput.attr("type")||"hidden"!=isInput.attr("type")&&"text"!=isInput.attr("type")){var view='<input type="hidden" class="region-hide" name="'+config.parameter.setNmae+'" value="'+(str+"/"+id)+'" />';config.view.before($(view)),isInput.val(str+"/"+id)}else isInput.val(str+"/"+id);isInput.trigger("change"),config.forcePage||$("body").trigger("click"),config.view.find(".title input").val(str),config.view.find(".region-data").html(JSON.stringify(config.heads));var _name=(config.heads.length-1,isInput.attr("name")),_errorTips=config.view.parent().siblings('label[for="'+_name+'"]');_errorTips.length>0&&_errorTips.hide()},headDel:function(id){var page=0;for(i in config.heads)config.heads[i].pid==id&&(page=parseInt(i));config.heads.splice(page,config.heads.length-page),methods.http()},headIsNmae:function(view){var text=view.html(),pid=view.attr("pid"),did=view.attr("did");for(i in config.heads)if(config.heads[i].pid==pid)return config.heads[i]={id:did,name:text,pid:pid},!1;return!0},isConstraintTier:function(){var leng=config.heads.length-1;return config.constraintTier&&leng>=config.constraintTier?!0:!1},events:function(){config.view.find(".head").on("click","li",function(){config.parameter.id=$(this).attr("pid"),methods.headDel(config.parameter.id)}),config.view.find(".cont").on("click","li",function(){config.parameter.id=$(this).attr("did"),methods.headIsNmae($(this))&&config.heads.push({id:$(this).attr("did"),name:$(this).html(),pid:$(this).attr("pid")}),/getCountryJsonpList/.test(config.view.attr("url"))&&1==config.view.attr("isLimit")&&-10==$(this).attr("pid")&&methods.setData(),methods.isConstraintTier()?(methods.setData(),config.forcePage&&methods.http()):methods.http()}),config.view.find(".title").click(function(){for(var rg=$("body").find(".m-region .region-view"),i=0,l=rg.length;l>i;i++)config.view.attr("sub")!=rg.eq(i).attr("sub")&&rg.eq(i).hide();return $(this).next().show(),!1}),config.view.find(".reset").click(function(){return _this.reset(),!1}),config.view.click(function(){return!1}),$(document).click(function(e){return $(e.target).hasClass("m-region")?!1:void config.view.find(".region-view").hide()})},error:function(txt,error){},setValue:function(){$.ajax({type:"GET",url:config.parameter.setUrl,dataType:"jsonp",success:function(data){try{data=data.reverse();var list=[];for(i in data)list.push({id:data[i][config.parameter.field.did],name:data[i][config.parameter.field.name],pid:data[i][config.parameter.field.pid]});methods.setData(list),config.parameter.id=0,config.heads=[]}catch(error){}methods.http()},error:function(error){methods.error("请求数据异常~~~",error)}})},listenChange:function(fn){var cacheInput=$('<input type="hidden" class="region_cache_'+config.view.attr("sub")+'" />');config.view.before(cacheInput),config.view.find(".cont").on("click","li",function(){var _cityNames=[],_cityIds=[];$.each(config.heads,function(i,elem){$.each(elem,function(k,v){"name"==k?_cityNames.push(v):"id"==k&&_cityIds.push(v)})}),cacheInput.val(_cityNames.join(",")+"/"+_cityIds.join(",")),"function"==typeof fn?fn():0})}};return this.start=function(view,sub,verify){config.sub=sub,config.view=$(view),config.view.attr("sub",sub),methods.foundView(verify,sub)},this.getData=function(){methods.getData()},this.update=function(){config.view.attr("setUrl")&&(config.parameter.setUrl=config.view.attr("setUrl"),methods.setValue())},this.reset=function(){config.heads=[],config.parameter.id=0,methods.http(),config.view.find(".title input").val(""),config.view.find(".s-live").html(""),config.view.prev().attr("value",""),config.view.find(".region-data").html("[]")},this.listenChange=function(fn){methods.listenChange(fn)},this};return{start:function(verify){this.allregion(verify)},allregion:function(verify){$(".m-region").each(function(){if(!$(this).attr("sub")){var ml=new MultiLevel;regions.push(ml),ml.start(this,regions.length-1,verify),ml.listenChange(verify)}})},aRegion:function(view){var ml=new MultiLevel;return regions.push(ml),ml.start(view,regions.length-1),ml},del:function(page){return page?($(".m-region").each(function(i){return i==page?(regions.splice(i,1),!0):void 0}),!1):!1},setParam:function(obj){$.extend(param,obj)}}}();!function($){$.extend($.fn,{validate:function(options){if(!this.length)return void(options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing"));var validator=$.data(this[0],"validator");return validator?validator:(this.attr("novalidate","novalidate"),validator=new $.validator(options,this[0]),$.data(this[0],"validator",validator),validator.settings.onsubmit&&(this.validateDelegate(":submit","click",function(ev){validator.settings.submitHandler&&(validator.submitButton=ev.target),$(ev.target).hasClass("cancel")&&(validator.cancelSubmit=!0)}),this.submit(function(event){function handle(){var hidden;return validator.settings.submitHandler?(validator.submitButton&&(hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm)),validator.settings.submitHandler.call(validator,validator.currentForm,event),validator.submitButton&&hidden.remove(),!1):!0}return validator.settings.debug&&event.preventDefault(),validator.cancelSubmit?(validator.cancelSubmit=!1,handle()):validator.form()?validator.pendingRequest?(validator.formSubmitted=!0,!1):handle():(validator.focusInvalid(),!1)})),validator)},valid:function(){if($(this[0]).is("form"))return this.validate().form();var valid=!0,validator=$(this[0].form).validate();return this.each(function(){valid&=validator.element(this)}),valid},removeAttrs:function(attributes){var result={},$element=this;return $.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value),$element.removeAttr(value)}),result},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,"validator").settings,staticRules=settings.rules,existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument)),staticRules[element.name]=existingRules,argument.messages&&(settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages));break;case"remove":if(!argument)return delete staticRules[element.name],existingRules;var filtered={};return $.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method],delete existingRules[method]}),filtered}}var data=$.validator.normalizeRules($.extend({},$.validator.metadataRules(element),$.validator.classRules(element),$.validator.attributeRules(element),$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required,data=$.extend({required:param},data)}return data}}),$.extend($.expr[":"],{blank:function(a){return!$.trim(""+a.value)},filled:function(a){return!!$.trim(""+a.value)},unchecked:function(a){return!a.checked}}),$.validator=function(options,form){this.settings=$.extend(!0,{},$.validator.defaults,options),this.currentForm=form,this.init()},$.validator.format=function(source,params){return 1===arguments.length?function(){var args=$.makeArray(arguments);return args.unshift(source),$.validator.format.apply(this,args)}:(arguments.length>2&¶ms.constructor!==Array&&(params=$.makeArray(arguments).slice(1)),params.constructor!==Array&&(params=[params]),$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n)}),source)},$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(element,event){this.lastActive=element,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(element)).hide())},onfocusout:function(element,event){this.checkable(element)||!(element.name in this.submitted)&&this.optional(element)||this.element(element)},onkeyup:function(element,event){(9!==event.which||""!==this.elementValue(element))&&(element.name in this.submitted||element===this.lastActive)&&this.element(element)},onclick:function(element,event){element.name in this.submitted?this.element(element):element.parentNode.name in this.submitted&&this.element(element.parentNode)},highlight:function(element,errorClass,validClass){"radio"===element.type?this.findByName(element.name).addClass(errorClass).removeClass(validClass):$(element).addClass(errorClass).removeClass(validClass)},unhighlight:function(element,errorClass,validClass){"radio"===element.type?this.findByName(element.name).removeClass(errorClass).addClass(validClass):$(element).removeClass(errorClass).addClass(validClass)}},setDefaults:function(settings){$.extend($.validator.defaults,settings)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function delegate(event){var validator=$.data(this[0].form,"validator"),eventType="on"+event.type.replace(/^validate/,"");validator&&validator.settings[eventType]&&validator.settings[eventType].call(validator,this[0],event)}this.labelContainer=$(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm),
this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var groups=this.groups={};$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key})});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value)}),$(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",delegate).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",delegate),this.settings.invalidHandler&&$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),$.extend(this.submitted,this.errorMap),this.invalid=$.extend({},this.errorMap),this.valid()||$(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var i=0,elements=this.currentElements=this.elements();elements[i];i++)this.check(elements[i]);return this.valid()},element:function(element){element=this.validationTargetFor(this.clean(element)),this.lastElement=element,this.prepareElement(element),this.currentElements=$(element);var result=this.check(element)!==!1;return result?delete this.invalid[element.name]:this.invalid[element.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),result},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors),this.errorList=[];for(var name in errors)this.errorList.push({message:errors[name],element:this.findByName(name)[0]});this.successList=$.grep(this.successList,function(element){return!(element.name in errors)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){$.fn.resetForm&&$(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(obj){var count=0;for(var i in obj)count++;return count},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&1===$.grep(this.errorList,function(n){return n.element.name===lastActive.name}).length&&lastActive},elements:function(){var validator=this,rulesCache={};return $(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in rulesCache||!validator.objectLength($(this).rules())?!1:(rulesCache[this.name]=!0,!0)})},clean:function(selector){return $(selector)[0]},errors:function(){var errorClass=this.settings.errorClass.replace(" ",".");return $(this.settings.errorElement+"."+errorClass,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=$([]),this.toHide=$([]),this.currentElements=$([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(element){this.reset(),this.toHide=this.errorsFor(element)},elementValue:function(element){var type=$(element).attr("type"),val=$(element).val();return"radio"===type||"checkbox"===type?$('input[name="'+$(element).attr("name")+'"]:checked').val():"string"==typeof val?val.replace(/\r/g,""):val},check:function(element){element=this.validationTargetFor(this.clean(element));var result,rules=$(element).rules(),dependencyMismatch=!1,val=this.elementValue(element);for(var method in rules){var rule={method:method,parameters:rules[method]};try{if(result=$.validator.methods[method].call(this,val,element,rule.parameters),"dependency-mismatch"===result){dependencyMismatch=!0;continue}if(dependencyMismatch=!1,"pending"===result)return void(this.toHide=this.toHide.not(this.errorsFor(element)));if(!result)return this.formatAndAdd(element,rule),!1}catch(e){throw this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id+", check the '"+rule.method+"' method",e),e}}return dependencyMismatch?void 0:(this.objectLength(rules)&&this.successList.push(element),!0)},customMetaMessage:function(element,method){if($.metadata){var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method]}},customDataMessage:function(element,method){return $(element).data("msg-"+method.toLowerCase())||element.attributes&&$(element).attr("data-msg-"+method.toLowerCase())},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor===String?m:m[method])},findDefined:function(){for(var i=0;i<arguments.length;i++)if(void 0!==arguments[i])return arguments[i];return void 0},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customDataMessage(element,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||void 0,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>")},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule.method),theregex=/\$?\{(\d+)\}/g;"function"==typeof message?message=message.call(this,rule.parameters,element):theregex.test(message)&&(message=$.validator.format(message.replace(theregex,"{$1}"),rule.parameters)),this.errorList.push({message:message,element:element}),this.errorMap[element.name]=message,this.submitted[element.name]=message},addWrapper:function(toToggle){return this.settings.wrapper&&(toToggle=toToggle.add(toToggle.parent(this.settings.wrapper))),toToggle},defaultShowErrors:function(){var i,elements;for(i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass),this.showLabel(error.element,error.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(i=0;this.successList[i];i++)this.showLabel(this.successList[i]);if(this.settings.unhighlight)for(i=0,elements=this.validElements();elements[i];i++)this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return $(this.errorList).map(function(){return this.element})},showLabel:function(element,message){var label=this.errorsFor(element);label.length?(label.removeClass(this.settings.validClass).addClass(this.settings.errorClass),label.attr("generated")&&label.html(message)):(label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:!0}).addClass(this.settings.errorClass).html(message||""),this.settings.wrapper&&(label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(label).length||(this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element))),!message&&this.settings.success&&(label.text(""),"string"==typeof this.settings.success?label.addClass(this.settings.success):this.settings.success(label,element)),this.toShow=this.toShow.add(label)},errorsFor:function(element){var name=this.idOrName(element);return this.errors().filter(function(){return $(this).attr("for")===name})},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name)},validationTargetFor:function(element){return this.checkable(element)&&(element=this.findByName(element.name).not(this.settings.ignore)[0]),element},checkable:function(element){return/radio|checkbox/i.test(element.type)},findByName:function(name){return $(this.currentForm).find('[name="'+name+'"]')},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case"select":return $("option:selected",element).length;case"input":if(this.checkable(element))return this.findByName(element.name).filter(":checked").length}return value.length},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):!0},dependTypes:{"boolean":function(param,element){return param},string:function(param,element){return!!$(param,element.form).length},"function":function(param,element){return param(element)}},optional:function(element){var val=this.elementValue(element);return!$.validator.methods.required.call(this,val,element)&&"dependency-mismatch"},startRequest:function(element){this.pending[element.name]||(this.pendingRequest++,this.pending[element.name]=!0)},stopRequest:function(element,valid){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[element.name],valid&&0===this.pendingRequest&&this.formSubmitted&&this.form()?($(this.currentForm).submit(),this.formSubmitted=!1):!valid&&0===this.pendingRequest&&this.formSubmitted&&($(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:!0,message:this.defaultMessage(element,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(className,rules){className.constructor===String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className)},classRules:function(element){var rules={},classes=$(element).attr("class");return classes&&$.each(classes.split(" "),function(){this in $.validator.classRuleSettings&&$.extend(rules,$.validator.classRuleSettings[this])}),rules},attributeRules:function(element){var rules={},$element=$(element);for(var method in $.validator.methods){var value;"required"===method?(value=$element.get(0).getAttribute(method),""===value&&(value=!0),value=!!value):value=$element.attr(method),value?rules[method]=value:$element[0].getAttribute("type")===method&&(rules[method]=!0)}return rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)&&delete rules.maxlength,rules},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,"validator").settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata()},staticRules:function(element){var rules={},validator=$.data(element.form,"validator");return validator.settings.rules&&(rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{}),rules},normalizeRules:function(rules,element){return $.each(rules,function(prop,val){if(val===!1)return void delete rules[prop];if(val.param||val.depends){var keepRule=!0;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element)}keepRule?rules[prop]=void 0!==val.param?val.param:!0:delete rules[prop]}}),$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter}),$.each(["minlength","maxlength","min","max"],function(){rules[this]&&(rules[this]=Number(rules[this]))}),$.each(["rangelength","range"],function(){var parts;rules[this]&&($.isArray(rules[this])?rules[this]=[Number(rules[this][0]),Number(rules[this][1])]:"string"==typeof rules[this]&&(parts=rules[this].replace(/[\[\]]/g,"").split(/[\s,]+/),rules[this]=[Number(parts[0]),Number(parts[1])]))}),$.validator.autoCreateRanges&&(rules.min&&rules.max&&(rules.range=[rules.min,rules.max],delete rules.min,delete rules.max),rules.minlength&&rules.maxlength&&(rules.rangelength=[rules.minlength,rules.maxlength],delete rules.minlength,delete rules.maxlength)),rules.messages&&delete rules.messages,rules},normalizeRule:function(data){if("string"==typeof data){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=!0}),data=transformed}return data},addMethod:function(name,method,message){$.validator.methods[name]=method,$.validator.messages[name]=void 0!==message?message:$.validator.messages[name],method.length<3&&$.validator.addClassRules(name,$.validator.normalizeRule(name))},methods:{required:function(value,element,param){if(!this.depend(param,element))return"dependency-mismatch";if("select"===element.nodeName.toLowerCase()){var val=$(element).val();return val&&val.length>0}return this.checkable(element)?this.getLength(value,element)>0:$.trim(value).length>0},remote:function(value,element,param){if(this.optional(element))return"dependency-mismatch";var previous=this.previousValue(element);if(this.settings.messages[element.name]||(this.settings.messages[element.name]={}),previous.originalMessage=this.settings.messages[element.name].remote,this.settings.messages[element.name].remote=previous.message,param="string"==typeof param&&{url:param}||param,this.pending[element.name])return"pending";if(previous.old===value)return previous.valid;previous.old=value;var validator=this;this.startRequest(element);var data={};return data[element.name]=value,$.ajax($.extend(!0,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){validator.settings.messages[element.name].remote=previous.originalMessage;var valid=response===!0||"true"===response;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element),validator.formSubmitted=submitted,validator.successList.push(element),delete validator.invalid[element.name],validator.showErrors()}else{var errors={},message=response||validator.defaultMessage(element,"remote");errors[element.name]=previous.message=$.isFunction(message)?message(value):message,validator.invalid[element.name]=!0,validator.showErrors(errors)}previous.valid=valid,validator.stopRequest(element,valid)}},param)),"pending"},minlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||length>=param},maxlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||param>=length},rangelength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||length>=param[0]&&length<=param[1]},min:function(value,element,param){return this.optional(element)||value>=param},max:function(value,element,param){return this.optional(element)||param>=value},range:function(value,element,param){return this.optional(element)||value>=param[0]&&value<=param[1]},email:function(value,element){return this.optional(element)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value)},url:function(value,element){return this.optional(element)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value)},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value))},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value)},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value)},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value)},creditcard:function(value,element){if(this.optional(element))return"dependency-mismatch";if(/[^0-9 \-]+/.test(value))return!1;var nCheck=0,nDigit=0,bEven=!1;value=value.replace(/\D/g,"");for(var n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);nDigit=parseInt(cDigit,10),bEven&&(nDigit*=2)>9&&(nDigit-=9),nCheck+=nDigit,bEven=!bEven}return nCheck%10===0},equalTo:function(value,element,param){var target=$(param);return this.settings.onfocusout&&target.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){$(element).valid()}),value===target.val()}}}),$.format=$.validator.format}(jQuery),function($){var pendingRequests={};if($.ajaxPrefilter)$.ajaxPrefilter(function(settings,_,xhr){var port=settings.port;"abort"===settings.mode&&(pendingRequests[port]&&pendingRequests[port].abort(),pendingRequests[port]=xhr)});else{var ajax=$.ajax;$.ajax=function(settings){var mode=("mode"in settings?settings:$.ajaxSettings).mode,port=("port"in settings?settings:$.ajaxSettings).port;return"abort"===mode?(pendingRequests[port]&&pendingRequests[port].abort(),pendingRequests[port]=ajax.apply(this,arguments)):ajax.apply(this,arguments)}}}(jQuery),function($){jQuery.event.special.focusin||jQuery.event.special.focusout||!document.addEventListener||$.each({focus:"focusin",blur:"focusout"},function(original,fix){function handler(e){return e=$.event.fix(e),e.type=fix,$.event.handle.call(this,e)}$.event.special[fix]={setup:function(){this.addEventListener(original,handler,!0)},teardown:function(){this.removeEventListener(original,handler,!0)},handler:function(e){var args=arguments;return args[0]=$.event.fix(e),args[0].type=fix,$.event.handle.apply(this,args)}}}),$.extend($.fn,{validateDelegate:function(delegate,type,handler){return this.bind(type,function(event){var target=$(event.target);return target.is(delegate)?handler.apply(target,arguments):void 0})}})}(jQuery),!function($){$.extend($.fn,{validate:function(options){if(!this.length)return void(options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing"));var validator=$.data(this[0],"validator");return validator?validator:(this.attr("novalidate","novalidate"),validator=new $.validator(options,this[0]),$.data(this[0],"validator",validator),validator.settings.onsubmit&&(this.validateDelegate(":submit","click",function(ev){validator.settings.submitHandler&&(validator.submitButton=ev.target),$(ev.target).hasClass("cancel")&&(validator.cancelSubmit=!0)}),this.submit(function(event){function handle(){var hidden;return validator.settings.submitHandler?(validator.submitButton&&(hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm)),validator.settings.submitHandler.call(validator,validator.currentForm,event),validator.submitButton&&hidden.remove(),!1):!0}return validator.settings.debug&&event.preventDefault(),validator.cancelSubmit?(validator.cancelSubmit=!1,handle()):validator.form()?validator.pendingRequest?(validator.formSubmitted=!0,!1):handle():(validator.focusInvalid(),!1)})),validator)},valid:function(){if($(this[0]).is("form"))return this.validate().form();var valid=!0,validator=$(this[0].form).validate();return this.each(function(){valid&=validator.element(this)}),valid},removeAttrs:function(attributes){var result={},$element=this;return $.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value),$element.removeAttr(value)}),result},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,"validator").settings,staticRules=settings.rules,existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument)),staticRules[element.name]=existingRules,argument.messages&&(settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages));break;case"remove":if(!argument)return delete staticRules[element.name],existingRules;var filtered={};return $.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method],delete existingRules[method]}),filtered}}var data=$.validator.normalizeRules($.extend({},$.validator.metadataRules(element),$.validator.classRules(element),$.validator.attributeRules(element),$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required,data=$.extend({required:param},data)}return data}}),$.extend($.expr[":"],{blank:function(a){return!$.trim(""+a.value)},filled:function(a){return!!$.trim(""+a.value)},unchecked:function(a){return!a.checked}}),$.validator=function(options,form){this.settings=$.extend(!0,{},$.validator.defaults,options),this.currentForm=form,this.init()},$.validator.format=function(source,params){return 1===arguments.length?function(){var args=$.makeArray(arguments);return args.unshift(source),$.validator.format.apply(this,args)}:(arguments.length>2&¶ms.constructor!==Array&&(params=$.makeArray(arguments).slice(1)),params.constructor!==Array&&(params=[params]),$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n)}),source)},$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(element,event){this.lastActive=element,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(element)).hide())},onfocusout:function(element,event){this.checkable(element)||!(element.name in this.submitted)&&this.optional(element)||this.element(element)},onkeyup:function(element,event){(9!==event.which||""!==this.elementValue(element))&&(element.name in this.submitted||element===this.lastActive)&&this.element(element)},onclick:function(element,event){element.name in this.submitted?this.element(element):element.parentNode.name in this.submitted&&this.element(element.parentNode)},highlight:function(element,errorClass,validClass){"radio"===element.type?this.findByName(element.name).addClass(errorClass).removeClass(validClass):$(element).addClass(errorClass).removeClass(validClass)},unhighlight:function(element,errorClass,validClass){"radio"===element.type?this.findByName(element.name).removeClass(errorClass).addClass(validClass):$(element).removeClass(errorClass).addClass(validClass)}},setDefaults:function(settings){$.extend($.validator.defaults,settings)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function delegate(event){var validator=$.data(this[0].form,"validator"),eventType="on"+event.type.replace(/^validate/,"");validator&&validator.settings[eventType]&&validator.settings[eventType].call(validator,this[0],event)}this.labelContainer=$(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm),this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var groups=this.groups={};$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key})});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value)}),$(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",delegate).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",delegate),this.settings.invalidHandler&&$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),$.extend(this.submitted,this.errorMap),this.invalid=$.extend({},this.errorMap),this.valid()||$(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var i=0,elements=this.currentElements=this.elements();elements[i];i++)this.check(elements[i]);return this.valid()},element:function(element){element=this.validationTargetFor(this.clean(element)),this.lastElement=element,this.prepareElement(element),this.currentElements=$(element);var result=this.check(element)!==!1;return result?delete this.invalid[element.name]:this.invalid[element.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),result},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors),this.errorList=[];for(var name in errors)this.errorList.push({message:errors[name],element:this.findByName(name)[0]});this.successList=$.grep(this.successList,function(element){return!(element.name in errors)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){$.fn.resetForm&&$(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(obj){var count=0;for(var i in obj)count++;return count},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&1===$.grep(this.errorList,function(n){return n.element.name===lastActive.name}).length&&lastActive},elements:function(){var validator=this,rulesCache={};return $(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in rulesCache||!validator.objectLength($(this).rules())?!1:(rulesCache[this.name]=!0,!0)})},clean:function(selector){return $(selector)[0]},errors:function(){var errorClass=this.settings.errorClass.replace(" ",".");return $(this.settings.errorElement+"."+errorClass,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=$([]),this.toHide=$([]),this.currentElements=$([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(element){this.reset(),this.toHide=this.errorsFor(element)},elementValue:function(element){var type=$(element).attr("type"),val=$(element).val();return"radio"===type||"checkbox"===type?$('input[name="'+$(element).attr("name")+'"]:checked').val():"string"==typeof val?val.replace(/\r/g,""):val},check:function(element){element=this.validationTargetFor(this.clean(element));var result,rules=$(element).rules(),dependencyMismatch=!1,val=this.elementValue(element);for(var method in rules){var rule={method:method,parameters:rules[method]};try{if(result=$.validator.methods[method].call(this,val,element,rule.parameters),"dependency-mismatch"===result){dependencyMismatch=!0;continue}if(dependencyMismatch=!1,"pending"===result)return void(this.toHide=this.toHide.not(this.errorsFor(element)));if(!result)return this.formatAndAdd(element,rule),!1}catch(e){throw this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id+", check the '"+rule.method+"' method",e),e}}return dependencyMismatch?void 0:(this.objectLength(rules)&&this.successList.push(element),!0)},customMetaMessage:function(element,method){if($.metadata){var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method]}},customDataMessage:function(element,method){return $(element).data("msg-"+method.toLowerCase())||element.attributes&&$(element).attr("data-msg-"+method.toLowerCase())},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor===String?m:m[method])},findDefined:function(){for(var i=0;i<arguments.length;i++)if(void 0!==arguments[i])return arguments[i];return void 0},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customDataMessage(element,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||void 0,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>")},formatAndAdd:function(element,rule){
var message=this.defaultMessage(element,rule.method),theregex=/\$?\{(\d+)\}/g;"function"==typeof message?message=message.call(this,rule.parameters,element):theregex.test(message)&&(message=$.validator.format(message.replace(theregex,"{$1}"),rule.parameters)),this.errorList.push({message:message,element:element}),this.errorMap[element.name]=message,this.submitted[element.name]=message},addWrapper:function(toToggle){return this.settings.wrapper&&(toToggle=toToggle.add(toToggle.parent(this.settings.wrapper))),toToggle},defaultShowErrors:function(){var i,elements;for(i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass),this.showLabel(error.element,error.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(i=0;this.successList[i];i++)this.showLabel(this.successList[i]);if(this.settings.unhighlight)for(i=0,elements=this.validElements();elements[i];i++)this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return $(this.errorList).map(function(){return this.element})},showLabel:function(element,message){var label=this.errorsFor(element);label.length?(label.removeClass(this.settings.validClass).addClass(this.settings.errorClass),label.attr("generated")&&label.html(message)):(label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:!0}).addClass(this.settings.errorClass).html(message||""),this.settings.wrapper&&(label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(label).length||(this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element))),!message&&this.settings.success&&(label.text(""),"string"==typeof this.settings.success?label.addClass(this.settings.success):this.settings.success(label,element)),this.toShow=this.toShow.add(label)},errorsFor:function(element){var name=this.idOrName(element);return this.errors().filter(function(){return $(this).attr("for")===name})},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name)},validationTargetFor:function(element){return this.checkable(element)&&(element=this.findByName(element.name).not(this.settings.ignore)[0]),element},checkable:function(element){return/radio|checkbox/i.test(element.type)},findByName:function(name){return $(this.currentForm).find('[name="'+name+'"]')},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case"select":return $("option:selected",element).length;case"input":if(this.checkable(element))return this.findByName(element.name).filter(":checked").length}return value.length},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):!0},dependTypes:{"boolean":function(param,element){return param},string:function(param,element){return!!$(param,element.form).length},"function":function(param,element){return param(element)}},optional:function(element){var val=this.elementValue(element);return!$.validator.methods.required.call(this,val,element)&&"dependency-mismatch"},startRequest:function(element){this.pending[element.name]||(this.pendingRequest++,this.pending[element.name]=!0)},stopRequest:function(element,valid){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[element.name],valid&&0===this.pendingRequest&&this.formSubmitted&&this.form()?($(this.currentForm).submit(),this.formSubmitted=!1):!valid&&0===this.pendingRequest&&this.formSubmitted&&($(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:!0,message:this.defaultMessage(element,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(className,rules){className.constructor===String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className)},classRules:function(element){var rules={},classes=$(element).attr("class");return classes&&$.each(classes.split(" "),function(){this in $.validator.classRuleSettings&&$.extend(rules,$.validator.classRuleSettings[this])}),rules},attributeRules:function(element){var rules={},$element=$(element);for(var method in $.validator.methods){var value;"required"===method?(value=$element.get(0).getAttribute(method),""===value&&(value=!0),value=!!value):value=$element.attr(method),value?rules[method]=value:$element[0].getAttribute("type")===method&&(rules[method]=!0)}return rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)&&delete rules.maxlength,rules},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,"validator").settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata()},staticRules:function(element){var rules={},validator=$.data(element.form,"validator");return validator.settings.rules&&(rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{}),rules},normalizeRules:function(rules,element){return $.each(rules,function(prop,val){if(val===!1)return void delete rules[prop];if(val.param||val.depends){var keepRule=!0;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element)}keepRule?rules[prop]=void 0!==val.param?val.param:!0:delete rules[prop]}}),$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter}),$.each(["minlength","maxlength","min","max"],function(){rules[this]&&(rules[this]=Number(rules[this]))}),$.each(["rangelength","range"],function(){var parts;rules[this]&&($.isArray(rules[this])?rules[this]=[Number(rules[this][0]),Number(rules[this][1])]:"string"==typeof rules[this]&&(parts=rules[this].replace(/[\[\]]/g,"").split(/[\s,]+/),rules[this]=[Number(parts[0]),Number(parts[1])]))}),$.validator.autoCreateRanges&&(rules.min&&rules.max&&(rules.range=[rules.min,rules.max],delete rules.min,delete rules.max),rules.minlength&&rules.maxlength&&(rules.rangelength=[rules.minlength,rules.maxlength],delete rules.minlength,delete rules.maxlength)),rules.messages&&delete rules.messages,rules},normalizeRule:function(data){if("string"==typeof data){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=!0}),data=transformed}return data},addMethod:function(name,method,message){$.validator.methods[name]=method,$.validator.messages[name]=void 0!==message?message:$.validator.messages[name],method.length<3&&$.validator.addClassRules(name,$.validator.normalizeRule(name))},methods:{required:function(value,element,param){if(!this.depend(param,element))return"dependency-mismatch";if("select"===element.nodeName.toLowerCase()){var val=$(element).val();return val&&val.length>0}return this.checkable(element)?this.getLength(value,element)>0:$.trim(value).length>0},remote:function(value,element,param){if(this.optional(element))return"dependency-mismatch";var previous=this.previousValue(element);if(this.settings.messages[element.name]||(this.settings.messages[element.name]={}),previous.originalMessage=this.settings.messages[element.name].remote,this.settings.messages[element.name].remote=previous.message,param="string"==typeof param&&{url:param}||param,this.pending[element.name])return"pending";if(previous.old===value)return previous.valid;previous.old=value;var validator=this;this.startRequest(element);var data={};return data[element.name]=value,$.ajax($.extend(!0,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){validator.settings.messages[element.name].remote=previous.originalMessage;var valid=response===!0||"true"===response;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element),validator.formSubmitted=submitted,validator.successList.push(element),delete validator.invalid[element.name],validator.showErrors()}else{var errors={},message=response||validator.defaultMessage(element,"remote");errors[element.name]=previous.message=$.isFunction(message)?message(value):message,validator.invalid[element.name]=!0,validator.showErrors(errors)}previous.valid=valid,validator.stopRequest(element,valid)}},param)),"pending"},minlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||length>=param},maxlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||param>=length},rangelength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||length>=param[0]&&length<=param[1]},min:function(value,element,param){return this.optional(element)||value>=param},max:function(value,element,param){return this.optional(element)||param>=value},range:function(value,element,param){return this.optional(element)||value>=param[0]&&value<=param[1]},email:function(value,element){return this.optional(element)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value)},url:function(value,element){return this.optional(element)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value)},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value))},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value)},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value)},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value)},creditcard:function(value,element){if(this.optional(element))return"dependency-mismatch";if(/[^0-9 \-]+/.test(value))return!1;var nCheck=0,nDigit=0,bEven=!1;value=value.replace(/\D/g,"");for(var n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);nDigit=parseInt(cDigit,10),bEven&&(nDigit*=2)>9&&(nDigit-=9),nCheck+=nDigit,bEven=!bEven}return nCheck%10===0},equalTo:function(value,element,param){var target=$(param);return this.settings.onfocusout&&target.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){$(element).valid()}),value===target.val()}}}),$.format=$.validator.format}(jQuery),function($){var pendingRequests={};if($.ajaxPrefilter)$.ajaxPrefilter(function(settings,_,xhr){var port=settings.port;"abort"===settings.mode&&(pendingRequests[port]&&pendingRequests[port].abort(),pendingRequests[port]=xhr)});else{var ajax=$.ajax;$.ajax=function(settings){var mode=("mode"in settings?settings:$.ajaxSettings).mode,port=("port"in settings?settings:$.ajaxSettings).port;return"abort"===mode?(pendingRequests[port]&&pendingRequests[port].abort(),pendingRequests[port]=ajax.apply(this,arguments)):ajax.apply(this,arguments)}}}(jQuery),function($){jQuery.event.special.focusin||jQuery.event.special.focusout||!document.addEventListener||$.each({focus:"focusin",blur:"focusout"},function(original,fix){function handler(e){return e=$.event.fix(e),e.type=fix,$.event.handle.call(this,e)}$.event.special[fix]={setup:function(){this.addEventListener(original,handler,!0)},teardown:function(){this.removeEventListener(original,handler,!0)},handler:function(e){var args=arguments;return args[0]=$.event.fix(e),args[0].type=fix,$.event.handle.apply(this,args)}}}),$.extend($.fn,{validateDelegate:function(delegate,type,handler){return this.bind(type,function(event){var target=$(event.target);return target.is(delegate)?handler.apply(target,arguments):void 0})}})}(jQuery),jQuery.extend(jQuery.validator.messages,{required:"必填内容",remote:"请勿输入非法字符与非法关键词",email:"请输入正确格式的电子邮件",url:"请输入合法的网址",date:"请输入合法的日期",dateISO:"请输入合法的日期 (ISO).",number:"请输入合法的数字",digits:"只能输入正整数",creditcard:"请输入合法的信用卡号",equalTo:"请再次输入相同的值",accept:"请输入拥有合法后缀名的字符串",money:"请输入正确的金额格式",maxlength:jQuery.validator.format("请输入一个长度最多是 {0} 的字符串"),minlength:jQuery.validator.format("请输入一个长度最少是 {0} 的字符串"),rangelength:jQuery.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"),range:jQuery.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),max:jQuery.validator.format("请输入一个最大为 {0} 的值"),min:jQuery.validator.format("请输入一个最小为 {0} 的值"),notIllegalCharacter:"请输入正确的内容",isPhone:"请输入正确的电话号码",isMultiPhone:"请输入正确的电话号码",isChar:"请填写正确的中文, 字母或者数字"}),$.validator.setDefaults({focusInvalid:!0,focusCleanup:!1}),$.validator.setDefaults({errorPlacement:function(error,element){try{element.parent().is("span")?error.addClass("new-error-placement").appendTo(element.parent().parent()):error.addClass("new-error-placement").appendTo(element.parent("td"))}catch(e){$(element).focus()}}}),jQuery.validator.addMethod("isIdCardNo",function(value,element){return this.optional(element)||isIdCardNo(value)},"请正确输入您的身份证号码"),jQuery.validator.addMethod("isMobile",function(value,element){var length=value.length;return this.optional(element)||11==length&&/^1[3-8]\d{9}$/.test(value)},"请填写正确的手机号码"),jQuery.validator.addMethod("isVerifCode",function(value,element){var length=value.length;return this.optional(element)||6==length&&/^\d{6}$/.test(value)},"请填写正确的验证码"),jQuery.validator.addMethod("isCompany",function(value,element){return value.length,this.optional(element)||/^[\u4E00-\u9FA5]+$/.test(value)},"请填写正确的企业名称"),jQuery.validator.addMethod("isChar",function(value,element){return value.length,this.optional(element)||/^[\u4E00-\u9FA50-9a-zA-Z]+$/.test(value)},"请填写正确的中文, 字母或者数字!"),jQuery.validator.addMethod("isConcat",function(value,element){return value.length,this.optional(element)||/^[\u4E00-\u9FA50-9a-zA-Z\-]+$/.test(value)},"输入中含有非法字符!"),jQuery.validator.addMethod("isRealName",function(value,element){return this.optional(element)||/^[\u4E00-\u9FA5+·]{2,10}$/.test(value)&&!/^[\u4E00-\u9FA5+·]{2,10}[·]$/.test(value)&&!/^[·][\u4E00-\u9FA5+.]{2,10}$/.test(value)},"请填写正确的名字"),jQuery.validator.addMethod("money",function(value,element){var money=/^([1-9][0-9]+|[0-9])(\.\d{1,2})?$/;return this.optional(element)||money.test(value)},"请输入正确的金额"),jQuery.validator.addMethod("isPhone",function(value,element){var phone=/((^\d{11}$)|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/;return this.optional(element)||phone.test(value)},"请输入正确的电话号码"),jQuery.validator.addMethod("isMultiPhone",function(value,element){var phone=/^(((\d{11})|((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))([;、;,、,]?))+$/;return this.optional(element)||phone.test(value)},"请输入正确的电话号码"),jQuery.validator.addMethod("isPlane",function(value,element){var tel=/^(\d{3,4}-)\d{7,9}$/g;return this.optional(element)||tel.test(value)},"请正确填写您的联系电话。"),jQuery.validator.addMethod("isTel",function(value,element){var length=value.length,mobile=/^1[3-8]\d{9}$/,tel=/^(\d{3,4}-)\d{7,9}$/g;return this.optional(element)||tel.test(value)||11==length&&mobile.test(value)},"请正确填写您的联系方式"),jQuery.validator.addMethod("notIllegalCharacter",function(value,element){var char=/^[^><\/\\;&]*$/;return this.optional(element)||char.test(value)},"请输入正确的内容"),jQuery.validator.addMethod("isBusinessReg",function(value,element){return this.optional(element)||reg(value)},"请填写正确的工商注册号码"),jQuery.validator.addMethod("diliMethod",function(value,element,param){var me=param,t=window[me].call(this,value,element);return 1!=t?($.validator.messages.diliMethod=t,!1):!0}),jQuery.validator.addMethod("diliPattern",function(value,element,param){var params=param.split("/,"),pa=eval(params[0]+"/"),msg=params[1],t=pa.test(value);return 0==t&&($.validator.messages.diliPattern=void 0!==msg?msg:$.validator.messages[msg]),t}),jQuery.validator.addMethod("isCarNo",function(value,element){var carNO=/^[\u4E00-\u9FA5]{1}[a-zA-Z]{1}[\da-zA-Z]{5}$/;return this.optional(element)||carNO.test(value)},"请输入正确的车牌号码!"),jQuery.validator.addMethod("isAddr",function(value,element){var reg=/[\#\<\>\=\'\"]+/g;return this.optional(element)||!reg.test(value)},"请输入正确的地址信息!"),jQuery.validator.addMethod("filterCharacter",function(value,element){var char=/^[0-9a-zA-Z\u4e00-\u9fa5\/()()&《》【】\+=\]\[]+$/g;return this.optional(element)||char.test(value)},"请输入正确的内容"),define(function(require,exports,module){function jcrop(){function select(c){updatePreview(c),$(".jcrop-holder").css("top",(300-$(".jcrop-holder").height())/2)}function updatePreview(c){if(parseInt(c.w)>0){var rx=xsize/c.w,ry=ysize/c.h;$pimg.css({width:Math.round(rx*boundx)+"px",height:Math.round(ry*boundy)+"px",marginLeft:"-"+Math.round(rx*c.x)+"px",marginTop:"-"+Math.round(ry*c.y)+"px"})}}$("#target").Jcrop({onSelect:select,onChange:updatePreview,allowResize:!0,dragEdges:!0,cornerHandles:!0,sideHandles:!0,handleSize:9,aspectRatio:1,boxWidth:300,minSize:[200,200],setSelect:[0,0,200,200]},function(){var bounds=this.getBounds();boundx=bounds[0],boundy=bounds[1],jcrop_api=this})}require("region");var _Jselect=require("jselect"),_SalesData=require("../sell/salesdata.js"),methods={unit:"",updateUnit:function(){$(".t-unit").html(this.unit)},specifications:function(view){$(view).html("按商品规格报价"),$(view).prev("span").html("商品规格不同,分别报价"),$(view).next(".tips").find("img").attr("src","../images/tip-1.png"),$(view).next(".tips").find("p").text("若您需要分商品规格分别报价,请点击“按商品规格报价”"),$("#purchases-2").show(),$("#interval-3").hide()},ladder:function(view){$(view).html("按销售量阶梯报价"),$(view).prev("span").html("销售量不同,可进行"),$(view).next(".tips").find("img").attr("src","../images/tip-2.png"),$(view).next(".tips").find("p").text("您可以针对销售量不同,给您的商品多个价格,买得越多,越便宜"),$("#purchases-2").hide(),$("#interval-3").show()},showMyImage:function(){$("#my-img").show(),$("#local-img").hide(),$(".img-list").hide()}};region.start(),$(".sea-select").each(function(){new _Jselect(this,{searchBar:!0})}),$(".sea-select").change(function(){methods.unit=$(this).val(),methods.updateUnit()}),$(".addbtn").click(function(){var leng=$("#purchases-2 tbody tr").length,view='<tr><td>起批量:<input type="text"><span ng-bind="name" class="t-unit">公斤</span>以上</td><td><input type="text">元/<span ng-bind="name" class="t-unit">公斤</span><span class="delete a-link">删除</span></td></tr>';2>=leng&&$("#purchases-2").append($(view)),leng>=2&&$("#purchases-2 tfoot").hide()}),$(".delete").live("click",function(){$(this).parent().parent().remove(),$("#purchases-2 tfoot").show()});var isshowimg=(new _SalesData({rootView:"#transaction-set-2",showView:"#interval-2",radioNmae:"#unit-view-2",res:[{"class":"price",dilipattern:"/^[0-9]+$/,可售量有误!",value:0}]}),!0);$(".s-ntab a").click(function(){return $(".s-ntab a").removeClass("current"),$(this).addClass("current"),isshowimg?(methods.showMyImage(),isshowimg=!1):($("#local-img").show(),$(".img-list").show(),$("#my-img").hide(),isshowimg=!0),!1});var iscat=!1;$(".title-right a").click(function(){return iscat?(methods.specifications(this),iscat=!1):(methods.ladder(this),iscat=!0),!1}),$(".switch-img").click(function(){return $(".s-ntab a").removeClass("current"),$(".s-ntab a").eq(1).addClass("current"),methods.showMyImage(),isshowimg=!1,!1}),$(".my-imgs input").change(function(){var imagesPage=0,muns=0;return $(".my-imgs input").each(function(){$(this).attr("checked")&&(imagesPage+=1)}),$(".img-list li").each(function(){$(this).find("img").attr("src")&&(muns+=1)}),imagesPage>6-muns?($(this).attr("checked",!1),!1):($(".mun-max").html(muns),void $(".iamges-val .sell-num").html(6-muns-imagesPage))}),$(".set-home-img").click(function(){var view1=$(".img-list li").eq(0).find("img"),view2=$(this).parent().parent().find("img"),p1=view1.attr("src"),p2=view2.attr("src");p1&&p2&&(view1.attr("src",p2),view2.attr("src",p1))}),$(".img-del").click(function(){var view=$(this).parent().parent().find("img");view.attr("src","")}),$(".img-list li").hover(function(){var view=$(this).find("img");view.attr("src")?$(this).find(".head").show():$(this).find(".head").hide(),$(this).index()||$(this).find(".set-home-img").hide()},function(){$(this).find(".head").hide()}),$(".time-nav li").click(function(){$(".time-nav li").removeClass("on"),$(this).addClass("on")}),$(".set-time").change(function(){var view=$(this).attr("cdata");view?$("#z-date").show():$("#z-date").hide()}),$(".selected a").fancybox({padding:30}),$("#p-myimages .cat-tab a").click(function(){return $("#p-myimages .cat-tab a").removeClass("on"),$(this).addClass("on"),"本地上传"==$(this).text()?($(".user-upload").show(),$(".user-image").hide()):($(".user-upload").hide(),$(".user-image").show()),!1}),$(".upload-btns .submitBtn").click(function(){return $(".photo-album").hide(),$(".upload-btns").hide(),$(".msg-remind-common").hide(),$(".loading").show(),setTimeout(function(){$(".loading").hide(),$(".tailoring").show(),setTimeout(function(){$("#target").attr("src","../images/_DSC6871.jpg"),$(".jcrop-preview").attr("src","../images/_DSC6871.jpg"),jcrop()},2e3)},3e3),!1}),$(".photo-album .ea7").click(function(){return $(".cat-view").show(),!1}),$(".cat-view .submitBtn").click(function(){return $(".cat-view").hide(),!1}),$("#p-myimages .iamges li").hover(function(){$(this).find("b").show()},function(){$(this).find("b").hide()});var jcrop_api,boundx,boundy,$pcnt=($("#preview-pane"),$("#preview-pane .preview-container")),$pimg=$("#preview-pane .preview-container img"),xsize=$pcnt.width(),ysize=$pcnt.height();$(".img-list ul").dragsort({dragSelector:"li",dragEnd:function(){},placeHolderTemplate:'<li class="selected"></li>'})});