下载:SDialog_1.0.rar
1 (function($){
2 $.SDialog={
3 show:function(o){
4 var set ={
5 obj:null,
6 mask:true
7 };
8 set =$.extend(set,o||{});
9 this.pos(set.obj);
10 if(set.mask) this.maskShow();
11 },
12 hide:function(o){
13 o.hide();
14 if(!$(\'.SDialog:visible\').length) this.maskHide();
15 },
16 hideAll:function(){
17 this.maskHide();
18 $(".SDialog").hide();
19 },
20 open:function(o){
21 var set={
22 title:"",
23 html:"",
24 url:"",
25 width:500,
26 height:null,
27 mask:true,
28 cap:true
29 };
30 set =$.extend(set,o||{});
31 if(set.url)
32 {
33 set.html=\'<iframe src="\'+set.url+\'" width="100%" height="\'+set.height+\'px" frameborder="0" scrolling="auto"></iframe>\';
34 set.height=null;
35 }
36 var $win=$(\'<div class="SWindow">\');
37 $(\'body\').append($win.append(\'<div class="SCap"><b></b><span class="SClose"></span></div><div class="SBox"></div>\'));
38 $win.css({"width":(set.width+"px"),"height":(set.height+"px")}).find(".SCap b").html(set.title);
39 if(set.cap)$win.show().find(".SBox").html(set.html); else $win.html(set.html).attr("class","SWindow2");
40 this.pos($win).find(\'.SClose\').click(function(){$.SDialog.hide($win);});
41 if(set.mask) this.maskShow();
42 },
43 load:function(){
44 this.open({
45 html:\'<div class="SLoad"></div>\',
46 width:58,
47 height:10,
48 cap:false
49 });
50 },
51 loadHode:function(){
52 this.hide($(".SLoad").parent());
53 },
54 maskShow:function(){
55 var s=this;
56 var $mask = $(\'.SDMask\');
57 if(!$mask.length){
58 $mask = $(\'<div class="SDMask"></div>\');
59 $(\'body\').append($mask);
60 }
61 if(this.isIe6()) $(\'select\').not($(".SDialog").find("select")).hide();
62 $mask.height(this.docHeight).show().dblclick(function(){
63 s.hideAll();
64 });
65 },
66 maskHide:function(){
67 if($(\'.SDMask\').is(":visible")){
68 $(\'.SDMask\').hide()
69 if(this.isIe6()) $(\'select\').show();
70 }
71 },
72 pos:function(o){
73 o.addClass("SDialog").css({\'position\':\'fixed\',\'top\':\'50%\',\'left\':\'50%\',\'marginTop\':(-Math.floor(o.height()/2)-10),\'marginLeft\':-Math.floor(o.width())/2}).show();
74 if(this.isIe6())o.css({\'position\':\'absolute\',\'top\':($(window).scrollTop()+$(window).height()/2)});
75 return o;
76 },
77 docHeight: function () {
78 var scrollHeight,
79 offsetHeight;
80 if ($.browser.msie) {
81 scrollHeight = Math.max(
82 document.documentElement.scrollHeight,
83 document.body.scrollHeight
84 );
85 offsetHeight = Math.max(
86 document.documentElement.offsetHeight,
87 document.body.offsetHeight
88 );
89
90 if (scrollHeight < offsetHeight) {
91 return $(window).height() + \'px\';
92 } else {
93 return scrollHeight + \'px\';
94 }
95 } else {
96 return $(document).height() + \'px\';
97 }
98 },
99 isIe6:function(){
100 return (typeof document.body.style.maxHeight == "undefined");
101 }
102 }
103 })(jQuery)