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('<h3>'+title+'</h3>');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='<span>'+this.text+'</span>';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]||'娑堟伅鎻愮ず',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:'娑堟伅鎻愮ず',content:content,buttons:[{text:'纭畾',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.
Back to home |
File page
Subscribe |
Register |
Login
| N