Construct () {
setting={
ID: ' Window ID ',
TitleText: ',
Content: ' Content Text ',//
Parent:null,//window's parent handle is added to the body by default
Boxcss: ' Class03_tank ',
Titlecss: ' Class03_tank_top ',//title CSS
Contentcss: ' PADTB10 ',//content CSS
width:280,
Height: ' Auto ',
Button: ' Submit,cancel ',//button type, submit: Commit, Cancel: Cancel
submitcall:null,//Click OK button callback
cancelcall:null//Click the Cancel button callback
}
function _createwindow (opt) {
var windowid=opt.id,top,left;
if (windowid==null)
return null;
if ($ (' # ' +opt.id). length>0) {
$ (' # ' +opt.id). Remove ();
}
if (!opt.left)
Opt.left= ($ (window). Width ()-opt.width)/2;
if (!opt.top)
Opt.top = ($ (window). Height ())/3+$ (document). ScrollTop ()
var parent= (opt. Parent==null | | opt.parent.length==0)? $ (' Body '): $ (opt. Parent);
var box=$ (' <div> '). attr (' id ', windowid). addclass (OPT.BOXCSS). Width (opt.width). Height (opt.height). css ({' Left ': opt.left, ' top ': opt.top, ' z-index ': 1111, ' position ': ' absolute '};
Parent.append (Box)
return $ (' # ' +opt.id);
}
function _setwindowconstruct (w,opt) {//Create form internal structure
W.subobj=w.obj;
Create a title
W.subobj.append (' <div> '). addclass (' Class03_tank_top '). Append (
$ (' <div> '). addclass (' Class03_tank_topc '). Append (
w.close=$ (' <a> '). attr (' title ', ' Close '). AddClass (' Btnax fr bgcfff mart04 '). html (' x ')
). Append (
$ (' <span> '). addclass (' Disin_bl lineh30 marl10 '). html (OPT. TitleText)
)
)
)
Create content
W.subobj.append (
$ (' <div> '). addclass (' Class03_tank_con bgcfff '). css ({' text-align ': ' Center '}). Append (
$ (' <div> '). attr (' id ', ' content_ui_ ' +opt.id). addclass (opt. CONTENTCSS)
)
);
Create Bottom
W.subobj.append (' <div class= "" style= "margin-top:0;" ><b class= "yz_b01" ></b><b class= "yz_b02" ></b><b class= "yz_b03 yz_b00" ></b> </div> ')
Return w;
}
function _setwindowsubmitbutton (w,opt) {//Set button
var p=$ (' <p> '). addclass (' class03_tank_p ');
var submit=$ (' <a> '), cancel=$ (' <a> ');
Btn=opt.button.split (', ');
if (ST. Base.inarray (BTN, ' submit ') >-1) {
P.append (Submit.addclass (' btnqx01 '). html (' OK '). bind (' click ', function () {
if ((Opt.submitcall&&opt.submitcall ()!==false) | | Opt.submitcall==null) {
$ (' # ' +opt.id). Remove ();
$ (' #MW_BACKOVER '). Hide ();
}
if (ST. Ui.timeid!=null)
Window.cleartimeout (ST. Ui.timeid);
}))
}
if (ST. Base.inarray (btn, ' Cancel ') >-1) {
P.append (Cancel.addclass (' btnqx01 marlr06 '). HTML (' Close '). Bind (' click ', function () {
if ((Opt.cancelcall&&opt.cancelcall ()!==false) | | Opt.cancelcall==null) {
$ (' # ' +opt.id). Remove ();
$ (' #MW_BACKOVER '). Hide ();
}
if (ST. Ui.timeid!=null)
Window.cleartimeout (ST. Ui.timeid);
}))
}
W.close.bind (' click ', function () {
$ (' # ' +opt.id). Remove ();
$ (' #MW_BACKOVER '). Hide ();
})
W.obj.children ('. Class03_tank_con '). Append (P)
}
function _setbackover (w) {//Create masking layer
if ($ (' #MW_BACKOVER '). length>0) {
$ (' #MW_BACKOVER '). Show ();
Return
}
$ ("Body"). Append (
$ ("<div>")
. attr ("id", "mw_backover")
. css ({
"Background-color": "#ddd",
"Position": "Fixed",
"Top": "0",
"Left": "0",
"width": "100%",
"Height": "100%",
"Display": "Block",
"Opacity": 0.5,
' Z-index ': 10
})
);
}
return function (opt) {
Opt=st.extend (setting,opt);
Create a Form container object
var w=_createwindow (opt);
if (!w) {
return false;
}
windowobj={' obj ': w, ' subobj ': null};
Windowobj=_setwindowconstruct (windowobj,opt);
_setbackover (windowobj,opt)
_setwindowsubmitbutton (windowobj,opt);
return {
Getobject:function () {
return windowobj;
},
Close:function () {
$ (windowobj[' obj ']). Remove ();
$ (' #MW_BACKOVER '). Hide ();
return this;
},
Setcontent:function (content) {
$ (' #content_ui_ ' +opt.id). HTML (content);
return this;
},
Load:function (Url,callback) {
$ (' #content_ui_ ' +opt.id). Load (url+ ' &r= ' +math.random (), callback);
return this;
}
}
}
}
return function (option) {
Controller=construct ();
return Controller (option)
}
})(),
Static dialog box
Staticwindow: (function () {
var controller=null;
function _construct (opt) {
setting={
ID: ',
left:0,
top:0,
WIDTH:200,
HEIGHT:100,
CSS: ' Bgcfff ',
Parent: ',
Buttoncss: ' Class03_tank_p ',
Buttoncssrep:null,//button additional parameters
Button: ' Sure,cancle ',
Buttontext:null,//button Append text
Layer:null
}
function _createwindow (opt) {
if ($ (' # ' +opt.id). length>0)
$ (' # ' +opt.id). Remove ();
if (opt.layer!=null) {
Opt.left= (Opt.layer.pageX);
Opt.top= (opt.layer.pagey+$ (opt.layer.target). Height ());
}
var box=$ (' <div> '). addclass (OPT.CSS). css ({' position ': ' absolute ', ' height ': opt.height, ' width ': opt.width, ' Border ': ' 1px solid #ccc ', ' Z-index ': $, ' left ': opt.left, ' top ': opt.top}. attr (' id ', opt.id),
Parent=opt.parent!= '? $ (opt.parent): $ (' body ');
Parent.append (box);
return $ (' # ' +opt.id);
};
function _setwindowconstruct (obj,opt) {
Obj.html (")"
Obj.append (' <div> '). attr (' id ', ' static_content_ ' +opt.id))
}
function _setbutton (obj,opt) {
Btn=opt.button.split (', ');
p=$ (' <p> '). addclass (OPT.BUTTONCSS). css ({' position ': ' absolute ', ' bottom ': 0, ' width ':(opt.width-13)})
if (opt.buttoncssrep!=null)
P.css (OPT.BUTTONCSSREP);
if (ST. Base.inarray (btn, ' sure ') >-1) {
var sure=$ (' <a> '). addclass (' btnqx01 '). HTML (' confirmation '). Click (function (e) {
if ((Opt.surebtn&&opt.surebtn (e)!==false) | | Opt.surebtn==null) {
Obj.remove ();
}
})
P.append (sure)
}
if (ST. Base.inarray (btn, ' cancle ') >-1) {
cancel=$ (' <a> '). addclass (' btnqx01 marlr06 '). html (' Cancel '). Click (function (e) {
if ((Opt.cancelbtn&&opt.cancelbtn (e)!==false) | | Opt.cancelbtn==null) {
Obj.remove ();
}
})
P.append (cancel);
}
if (opt.buttontext!=null)
P.append (Opt.buttontext)
Obj.append (P)
}
return function (opt) {
Opt=st.extend (setting,opt);
var w=_createwindow (opt);
if (!w) return false;
_setwindowconstruct (w,opt);
_setbutton (w,opt);
return{
Close:function () {
W.remove ()
},
Setcontent:function (content) {
$ (' #static_content_ ' +opt.id). HTML (content);
},
Append:function (obj) {
$ (' #static_content_ ' +opt.id). append (obj);
},
Load:function (Url,callback) {
$ (' #static_content_ ' +opt.id). Load (Url,callback)
}
}
}
}
return function (option) {
Controller=_construct ();
return Controller (option);
}
})()
}
} |