1(function ($){ 2 var defaults={ 3 type:'pop',//pop||confirm:ç¡®è®¤æ¡ 4 title:'温馨æç¤º', 5 width:'auto', 6 height:'auto', 7 content:'', 8 iframesrc:'',//å¼å ¥iframeçurl 9 loadurl:'',//å è½½çurl 10 overlay:true,//æ¯å¦æ¾ç¤ºé®ç½©å± 11 complete:function (){},//å¼¹åºå±åæ§è¡å½æ° 12 defined:function (){return true;}//确认æ¡ç¡®è®¤å½æ° 13 }; 14 function Dialog(options){ 15 this.options=$.extend({},defaults,options); 16 $('.dialog').remove(); 17 this.el=$('<div class="dialog"><div class="dialog-title">'+this.options.title+'</div><a class="dialog-close"><i class="icon-close"></i></a><div class="dialog-content"></div></div>'); 18 } 19 Dialog.prototype.init=function (){ 20 if(this.options.type=='confirm'){ 21 this.el.append('<div class="dialog-footer"><button class="btn-defined btn-primary">ç¡®å®</button><button class="btn btn-cancel">åæ¶</button></div>'); 22 } 23 var content=this.el.children('.dialog-content'); 24 this.el.width(this.options.width); 25 content.height(this.options.height); 26 $(document.body).append(this.el); 27 if(this.options.iframesrc){ 28 content.append('<iframe class="dialog-iframe" src="'+this.options.iframesrc+'" frameborder="0"></iframe>'); 29 this.options.complete.call(this); 30 }else if(this.options.loadurl){ 31 var self=this; 32 content.load(this.options.loadurl,function (){ 33 self.center(); 34 this.options.complete.call(this); 35 }); 36 }else{ 37 content.html(this.options.content); 38 this.options.complete.call(this); 39 } 40 if(this.options.overlay){ 41 this.overlay(); 42 } 43 this.bindEvent(); 44 this.center(); 45 if($.placeholder){ 46 $.placeholder(this.el.find('input,textarea')); 47 } 48 } 49 Dialog.prototype.bindEvent=function (){ 50 var self=this; 51 this.el.on('click','.btn-cancel,.dialog-close,.dialog-close-trigger',function(e){ 52 e.stopPropagation(); 53 $.dialog.close(); 54 }); 55 this.el.on('click','.btn-defined',function (e){ 56 var ret=self.options.defined(e); 57 if(ret!==false){ 58 $.dialog.close(); 59 } 60 }); 61 } 62 Dialog.prototype.center=function (){ 63 this.el.show().css({ 64 marginLeft:'-'+this.el.width()/2+'px', 65 marginTop:'-'+this.el.height()/2+'px' 66 }); 67 if($.browser.msie&&parseInt($.browser.version)==6){ 68 this.el.show().css({ 69 top:$(document).scrollTop()+$(window).height()/2 70 }); 71 } 72 } 73 Dialog.prototype.overlay=function (){ 74 $(document.body).append('<div class="dialog-overlay"></div>'); 75 if($.browser.msie&&parseInt($.browser.version)==6){ 76 $('.dialog-overlay').height($(document).height()).append('<iframe frameborder="0"></iframe>'); 77 } 78 } 79 $.dialog=function (options){ 80 var dialog=new Dialog(options); 81 dialog.init(); 82 }; 83 $.dialog.close=function (){ 84 $('.dialog-overlay,.dialog').remove(); 85 } 86 $.dialog.RConfirm=function (options){ 87 options.overlay=false; 88 options.type='confirm'; 89 var dialog=new Dialog(options); 90 dialog.el.addClass('dialog-r-c').find('.dialog-title').remove(); 91 dialog.center=function (){ 92 this.el.show().css({ 93 left:this.options.target.offset().left-this.el.width()/2+this.options.target.width()/2, 94 top:this.options.target.offset().top+this.options.target.height(), 95 position:'absolute' 96 }); 97 } 98 dialog.init(); 99 setTimeout(function (){ 100 dialog.el.addClass('g-auto-hide'); 101 },400) 102 } 103 104 $.dialog.tips=function(options){ 105 var el=$('<div class="pop-tips"><div class="pop-tips-bg"></div><div class="pop-tips-inner"><i></i><span class="pop-tips-title"></span></div></div>'); 106 el.find('i').addClass($.dialog.tips.icons[options.type||'success']); 107 el.find('.pop-tips-title').html(options.title); 108 $('body').append(el); 109 el.show().css({ 110 left:($(window).width()-el.width())/2, 111 top:($(window).height()-el.height())/2-20 112 }); 113 setTimeout(function(){ 114 el.fadeOut(500,function(){ 115 el.remove(); 116 }); 117 },1500) 118 } 119 $.dialog.tips.icons={ 120 success:'icon-ajax-success', 121 error:'icon-ajax-error' 122 } 123 124})(jQuery)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.