//ds.base ;(function(global, document, undefined){ var rblock = /\{([^\}]*)\}/g, ds = global.ds = { noop: function(){}, //object mix: function(target, source, cover){ if(typeof source !== 'object'){ cover = source; source = target; target = this; } for(var k in source){ if(cover || target[k] === undefined){ target[k] = source[k]; } } return target; }, //string mixstr: function(sstr){ var args = array.prototype.slice.call(arguments, 1); return string(sstr).replace(rblock, function(a, i){ return args[i] != null ? args[i] : a; }); }, trim: function(str){ return string(str).replace(/^\s*/, '').replace(/\s*$/, ''); }, //number getrndnum: function(max, min){ min = isfinite(min) ? min : 0; return math.random() * ((isfinite(max) ? max : 1000) - min) + min; }, //bom scrollto: (function(){ var duration = 480, view = $(global), settop = function(top){ global.scrollto(0, top);}, fxease = function(t){return (t*=2)<1?.5*t*t:.5*(1-(--t)*(t-2));}; return function(top, callback){ top = math.max(0, ~~top); var tmark = new date(), currtop = view.scrolltop(), height = top - currtop, fx = function(){ var tmap = new date() - tmark; if(tmap >= duration){ settop(top); return (callback || ds.noop).call(ds, top); } settop(currtop + height * fxease(tmap/duration)); settimeout(fx, 16); }; fx(); }; })(), //dom loadscriptcache: {}, loadscript: function(url, callback, args){ var cache = this.loadscriptcache[url]; if(!cache){ cache = this.loadscriptcache[url] = { callbacks: [], url: url }; var firstscript = document.getelementsbytagname('script')[0], script = document.createelement('script'); if(typeof args === 'object'){ for(var k in args){ script[k] = args[k]; } } script.src = url; script.onload = script.onreadystatechange = script.onerror = function(){ if(/undefined|loaded|complete/.test(this.readystate)){ script = script.onreadystatechange = script.onload = script.onerror = null; cache.loaded = true; for(var i=0,len=cache.callbacks.length; i= duration){ style[name] = to + 'px'; return (callback || ds.noop).call(elem); } style[name] = (from + size * easing(elapsed/duration)) + 'px'; ds.requestanimationframe(fx); }; to = parsefloat(to) || 0; duration = ~~duration || 200; easing = easing || easeout; size = to - from; fx(); return this; }; })(), //cookies getcookie: function(name){ var ret = new regexp('(?:^|[^;])' + name + '=([^;]+)').exec(document.cookie); return ret ? decodeuricomponent(ret[1]) : ''; }, setcookie: function(name, value, expir){ var cookie = name + '=' + encodeuricomponent(value); if(expir !== void 0){ var now = new date(); now.setdate(now.getdate() + ~~expir); cookie += '; expires=' + now.togmtstring(); } document.cookie = cookie; }, //hacker transitionsupport: (function(){ var name = '', prefixs = ['', 'webkit', 'moz', 'ms', 'o'], docstyle = (document.documentelement || document.body).style; for(var i=0,len=prefixs.length; i/g,rbrhash={'10':'n','13':'r'},helpers={'=':{render:'__.push($1);'}};ds.tmpl=function(tmpl,data){var render=new function('_data','var __=[];__.data=_data;'+'with(_data){__.push("'+tmpl.replace(rchars,'\\$1').replace(rfuns,function(a,key,body){body=body.replace(rbr,';').replace(rgquote,'"').replace(rdbgstrich,'\\');var helper=helpers[key],tmp=!helper?key+body:typeof helper.render==='function'?helper.render.call(ds,body,data):helper.render.replace(rarg1,body);return'");'+tmp+'__.push("';}).replace(rbr,function(a,b){return'\\'+(rbrhash[b.charcodeat(0)]||b);})+'");}return __.join("");');return data?render.call(data,data):render;};ds.tmpl.helper=helpers;})(this); /** * jquery.mask.js * create: 2012.12.04 * update: 2012.12.13 * admin@laoshu133.com */ ;(function(global,document,$,undefined){var doc=$(document),_noop=function(){},ds=global.ds||(global.ds={});var _uuid=0,_ops={id:null,anim:true,animduration:320,zindex:999,opacity:0.8,background:'#000',onshow:_noop,onhide:_noop,onclick:_noop},mask=ds.mask=function(ops){return this.init(ops);};mask._cache={};mask.prototype={constructor:mask,init:function(ops){this.ops=ops=ops||{};$.each(_ops,function(k,val){typeof ops[k]==='undefined'&&(ops[k]=val);});var id=ops.id;if(typeof id!=='string'){id='ds_mask_'+(++_uuid);}this.id=id;if(mask._cache[id]){var _mask=mask._cache[id];_mask.ops=ops;return _mask;}mask._cache[id]=this;return this;},_getelem:function(){var elem=this.elem,self=this;if(!elem){var ops=this.ops,css='border:0;margin:0;padding:0;height:100%;width:100%;left:0;top:0;opacity:0;';elem=this.elem=$(document.createelement('div'));elem.bind('click.jquery_mask',function(){self.ops.onclick.call(self);});elem[0].style.csstext=css+'display:none;position:fixed;background:'+ops.background+';z-index:'+ops.zindex;if(!mask.fixedpositionsupport()){elem[0].style.position='absolute';css+='position:absolute;filter:alpha(opacity=0);';elem[0].innerhtml='
';}elem[0].id=this.id;elem.appendto('body');}return elem;},show:function(opacity){var self=this,ops=this.ops,elem=this._getelem();opacity=typeof opacity==='number'?opacity:ops.opacity;if(!mask.fixedpositionsupport()){elem.css('height',doc.height());}this.elem.css('background',ops.background).show();if(ops.anim){elem.stop().animate({opacity:opacity},ops.animduration,function(){ops.onshow.call(self,opacity);});}else{elem.stop().css('opacity',opacity);ops.onshow.call(this,opacity);}return this;},hide:function(){var self=this,ops=this.ops,elem=this._getelem();if(ops.onhide.call(this)!==false){if(ops.anim){elem.stop().animate({opacity:0},ops.animduration,function(){this.style.display='none';});}else{elem[0].style.display='none';}}return this;},destory:function(){if(this.elem){this.elem.remove();this.elem=null;}delete mask._cache[this.id];}};mask.fixedpositionsupport=function(){if(typeof $.support.fixedposition==='boolean'){return $.support.fixedposition;}var div,ret=false,body=document.body,css='border:0;margin:0;padding:0;position:fixed;left:0;top:20px;';if(body){div=document.createelement('div');div.style.csstext=css+'position:absolute;top:0;';div.innerhtml='
';body.insertbefore(div,body.firstchild);ret=$.support.fixedposition=div.firstchild.offsettop===20;body.removechild(div);}return ret;};ds.mask=$.mask=function(opacity,background){var ops=typeof opacity==='object'?opacity:{opacity:opacity,background:background};ops.id='ds_global_mask';return new mask(ops).show();};})(this,this.document,jquery); /** * ds.dialog.js * create: 2012.12.05 * update: 2012.12.14 * admin@laoshu133.com */ ;(function(global,document,$,undefined){var view=$(global),doc=$(document),ds=global.ds||(global.ds={});var _guid=0,_noop=function(){},_tmpl='',_ops={id:null,title:null,content:'',classname:null,padding:'20px 25px',height:'auto',width:'auto',left:'50%',top:'40%',zindex:1990,icon:null,iconbasepath:global.iconbasepath||'images/',buttons:null,follow:null,followoffset:null,autoopen:true,esc:true,lock:true,lockopacity:0.6,lockcolor:'#000',showclosebutton:true,drag:true,fixed:true,anim:true,animduration:320,timeout:0,oninit:_noop,onopen:_noop,onfocus:_noop,onmaskclick:_noop,onhide:_noop,onclose:_noop,yestext:'\u786e\u5b9a',notext:'\u53d6\u6d88',onyes:null,onno:null},dialog=ds.dialog=function(ops){return this.init(ops||{});};$.extend(dialog,{items:{},defaults:_ops,currindex:1990,defaulttmpl:_tmpl,activedialog:null,dialogqueue:[],adddialog:function(dialog){var queue=this.dialogqueue;this.removedialog(dialog);queue.push(dialog);dialog.inqueue=true;dialog.queueindex=queue.length-1;},removedialog:function(dialog){var i=dialog.queueindex,queue=this.dialogqueue;if(dialog.inqueue){queue.splice(i,1);for(var len=queue.length;i=1?this.position(left||ops.left,top||ops.top):this.follow(ops.follow,ops.followoffset[0],ops.followoffset[1]);ops.anim?shell.stop().animate({opacity:1},ops.animduration):shell.stop().css('opacity',1);shell.css('display','block');this.isopen=true;ops.onopen.call(this);}return this.focus();},hide:function(){var ops=this.ops;if(this.isopen){this.isopen=false;if(ops.onhide.call(this)!==false){this.blur().unlock();ops.anim?this.shell.stop().animate({opacity:0},ops.animduration,function(){this.style.display='none';}):this.shell.stop().hide();dialog.removedialog(this);}else{this.isopen=true;}}return this;},focus:function(){var ops=this.ops;if(this.isopen&&!this.hasfocus&&ops.onfocus.call(this)!==false){dialog.activedialog&&dialog.activedialog._blur();dialog.adddialog(this);var shell=this.shell;this.zindex=dialog.currzindex=math.max(++dialog.currzindex,this.ops.zindex);shell.addclass('ds_dialog_active').css('zindex',this.zindex);if('focus'in shell[0]){shell[0].focus();this.focusbutton&&this.focusbutton.focus();}dialog.activedialog=this;this.hasfocus=true;}return this;},_blur:function(){this.hasfocus=false;this.shell.removeclass('ds_dialog_active');},blur:function(){if(this.hasfocus){this._blur();var queue=dialog.dialogqueue,len=queue.length;if(len>1){queue[len-2].focus();}else{dialog.activedialog=null;}}return this;},close:function(){var self=this,ops=this.ops;if(this.shell&&ops.onclose.call(this)!==false){if(ops.anim){this.hide();settimeout(function(){self.destory();},ops.animduration);}else{this.hide().destory();}}},timeout:function(delay){var self=this;cleartimeout(this.timer);if(~~delay>0){this.timer=settimeout(function(){self.close();},~~delay*1000);}return this;},destory:function(){delete dialog.items[this.id];if(this.shell){this.shell.hide().remove();}this.shell=this.contentshell=this.buttonshell=this.titleshell=this.closeshell=this.iconshell=this.focusbutton=null;},_getpositionlimit:function(){var ops=this.ops,shell=this.shell,offset=shell.offset(),viewscrollleft=view.scrollleft(),viewscrolltop=view.scrolltop(),shellwidth=shell.outerwidth(),shellheight=shell.outerheight(),viewwidth=view.width(),viewheight=view.height(),mintop=ops.fixed?0:viewscrolltop,minleft=ops.fixed?0:viewscrollleft,maxtop=mintop+viewheight-shellheight,maxleft=minleft+viewwidth-shellwidth;return{mintop:mintop,minleft:minleft,maxtop:maxtop,maxleft:maxleft,viewheight:viewheight,viewwidth:viewwidth,height:shellheight,width:shellwidth,top:offset.top,left:offset.left,viewscrolltop:viewscrolltop,viewscrollleft:viewscrollleft};},_position:function(left,top){var ops=this.ops,style=this.shell[0].style;style.left=left+'px';style.top=top+'px';},position:function(left,top){if(arguments.length<1){return this.shell.offset();}var ops=this.ops,rper=/(\d+\.?\d+)%/,limit=this._getpositionlimit();if(rper.test(left)){left=(limit.viewwidth-limit.width)*parsefloat(regexp.$1)/100;left+=ops.fixed?0:limit.viewscrollleft;}if(rper.test(top)){top=(limit.viewheight-limit.height)*parsefloat(regexp.$1)/100;top+=ops.fixed?0:limit.viewscrolltop;}left=math.max(limit.minleft,math.min(limit.maxleft,left));top=math.max(limit.mintop,math.min(limit.maxtop,top));this._position(left,top);return this;},size:function(width,height){this.contentshell.css('width',width).css('height',height);return this;},padding:function(padding){this.contentshell.css('padding',padding);return this;},follow:(function(){var _offsetmaps={left:function(){return 0;},right:function(shell,target){return target.outerwidth()-shell.outerwidth();},top:function(shell,target){return-shell.outerheight();},bottom:function(shell,target){return target.outerheight();}},_getoffset=function(shell,target,_offset){if(_offsetmaps[_offset[0]]){_offset[0]=_offsetmaps[_offset[0]](shell,target);}if(_offsetmaps[_offset[1]]){_offset[1]=_offsetmaps[_offset[1]](shell,target);}return[~~_offset[0],~~_offset[1]];};return function(target,left,top){target=$(target);var pos=$(target).offset(),offset=_getoffset(this.shell,target,[left,top]);if(this.ops.fixed){pos.left-=view.scrollleft();pos.top-=view.scrolltop();}return this.position(pos.left+offset[0],pos.top+offset[1]);};})(),title:function(title){if(!title){this.titleshell.hide();}else{this.titleshell.html('

'+title+'

');this.titleshell.show();}return this;},content:function(content){this.contentshell.html(content);return this.position(this.ops.left,this.ops.top);},button:function(buttons){var self=this,ops=this.ops,shell=this.buttonshell.hide();if($.isarray(buttons)&&buttons.length>0){$.each(buttons,function(i){var btn=document.createelement('button');btn.disabled=this.disabled;btn.innerhtml=''+this.text+'';btn.classname=this.classname+(this.disabled?' disabled':'');btn=$(btn);var onclick=this.onclick;btn.bind('click',function(e){e.stoppropagation();typeof onclick==='function'&&onclick.call(self,this,e);});if(this.autofocus){self.focusbutton=btn;}shell.append(btn);});shell.show();}return this;},icon:function(iconurl){var shell=this.iconshell;if(!!iconurl){shell.find('div')[0].style.backgroundimage='url('+this.ops.iconbasepath+iconurl+')';shell.show();}else{shell.hide();}return this;},lock:function(opacity,lockcolor){var ops=this.ops,mask=dialog.mask;if(!mask){mask=dialog.mask=new ds.mask({opacity:_ops.lockopacity,background:_ops.lockcolor,onclick:function(){var dialog=dialog.activedialog;dialog&&dialog.ops.onmaskclick.call(dialog);}});}dialog.addmask(this);lockcolor=lockcolor||ops.lockcolor;if(mask._lastbackground!==lockcolor){mask._lastbackground=lockcolor;mask._getelem().css('background',lockcolor);}mask.show(opacity||ops.opacity);this.locked=true;return this;},unlock:function(){if(this.locked){dialog.removemask(this);var maskqueue=dialog.maskqueue;if(maskqueue.length>0){maskqueue[maskqueue.length-1].lock();}else{dialog.mask.hide();}this.locked=false;}return this;}};(function(){var rinput=/input|textarea/i;doc.bind('keydown',function(e){var dialog=dialog.activedialog;if(dialog&&dialog.ops.esc&&e.keycode===27&&!rinput.test(e.target.nodename)){dialog.hide();}});})();$.extend(dialog.prototype,(function(){var supportfixed;return{initfixed:function(){if(typeof supportfixed!=='boolean'){supportfixed=ds.mask.fixedpositionsupport();}if(!this._initfixed){var shell=this.shell;shell[0].style.position=supportfixed?'fixed':'absolute';this.ops.fixed=true;if(!supportfixed){this.ops.fixed=false;}this._initfixed=true;}return this;},releasefixed:function(){if(this._initfixed){var pos=this.position(),scrollleft=view.scrollleft(),scrolltop=view.scrolltop();this.position(pos.left+scrollleft,pos.top+scrolltop);this.shell[0].style.position='absolute';this.ops.fixed=false;}return this;}};})());$.extend(dialog.prototype,(function(){var html=document.documentelement,hascapture='setcapture'in html,hascaptureevt='onlosecapture'in html,clearranges='getselection'in global?function(){global.getselection().removeallranges();}:function(){document.selection&&document.selection.empty();},isnotdragarea=function(dialog,target){var content=dialog.contentshell[0],close=dialog.closeshell[0];if(target==content||$.contains(content,target)||target===close||$.contains(close,target)||$.contains(dialog.buttonshell[0],target)){return true;}return false;};return{initdrag:function(){if(!this._draghandler){var self=this;this._draghandler=function(e){if(e.button!==0&&e.button!==1||isnotdragarea(self,e.target)){return;}var ops=self.ops,shell=self.shell,limit=self._getpositionlimit(),currdrag=dialog._currdrag={limit:limit,dialog:self,offsettop:e.pagey-limit.top,offsetleft:e.pagex-limit.left,onmousemove:function(e){var top=e.pagey-currdrag.offsettop,left=e.pagex-currdrag.offsetleft;top-=ops.fixed?limit.viewscrolltop:0;left-=ops.fixed?limit.viewscrollleft:0;top=math.min(limit.maxtop,top);left=math.min(limit.maxleft,left);ops.top=math.max(limit.mintop,top);ops.left=math.max(limit.minleft,left);self._position(ops.left,ops.top);clearranges();},onmouseup:function(){hascapture&&shell[0].releasecapture();hascaptureevt?shell.unbind('losecapture',currdrag.onmouseup):view.unbind('blur',currdrag.onmouseup);doc.unbind('mousemove',currdrag.onmousemove).unbind('mouseup',currdrag.onmouseup);shell.removeclass('ds_dialog_drag');dialog._currdrag=null;}};hascaptureevt?shell.bind('losecapture',currdrag.onmouseup):view.bind('blur',currdrag.onmouseup);hascapture&&shell[0].setcapture();doc.bind('mousemove',currdrag.onmousemove).bind('mouseup',currdrag.onmouseup);shell.addclass('ds_dialog_drag');return false;};this.shell.bind('mousedown',this._draghandler);}return this;},releasedrag:function(){if(this._draghandler){this.shell.unbind('mousedown',this._draghandler);this._draghandler=null;}return this;}};})());ds.dialog=function(ops,onyes,onno){if(typeof ops==='string'){ops={content:ops,title:arguments[1]||'\u6d88\u606f\u63d0\u793a',onyes:onyes,onno:onno};}return new dialog(ops||{});};$.extend(ds.dialog,{items:dialog.items,alert:function(content,onhide,icon){if(typeof onhide==='string'){icon=onhide;}return new dialog({id:'ds_dialog_alert',fixed:true,left:'50%',top:'40%',icon:icon?icon:'info.png',title:'\u6d88\u606f\u63d0\u793a',content:content,buttons:[{text:'\u786e\u5b9a',autofocus:true,classname:'ds_dialog_yes',onclick:function(){this.close();}}],onhide:typeof onhide==='function'?onhide:function(){}});},confirm:function(content,onyes,onno,onhide){return new dialog({id:'ds_dialog_confirm',fixed:true,left:'50%',top:'40%',icon:'confirm.png',title:'\u6d88\u606f\u786e\u8ba4',content:content,onyes:onyes||true,onhide:onhide,onno:onno||true});},prompt:function(content,onyes,defaultvalue){return new dialog({id:'ds_dialog_prompt',fixed:true,left:'50%',top:'40%',icon:'confirm.png',title:'\u6d88\u606f\u786e\u8ba4',content:'

'+content+'

',onopen:function(){var self=this,input=this._input;if(!input){input=this._input=this.contentshell.find('input');input.bind('keydown',function(e){if(e.keycode===13&&self.focusbutton){self.focusbutton.trigger('click');return false;}});}input.val(defaultvalue||'');},onfocus:function(){var input=this._input[0];settimeout(function(){input.select();input.focus();},32);},onclose:function(){this._input=null;},onyes:function(){var input=this._input[0];return typeof onyes==='function'?onyes.call(this,input.value,input):void 0;},onno:true});},tips:function(content,timeout,follow,lock){if(typeof follow==='boolean'){lock=follow;follow=null;}return new dialog({id:'ds_dialog_tips',fixed:true,esc:false,lock:!!lock,follow:follow,followoffset:[0,'bottom'],drag:false,content:content,padding:'12px 50px',showclosebutton:false,timeout:timeout||0});}});})(this,this.document,jquery);