//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); /** */ ;(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); /** */ ;(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);