dhtmlxWindows:
链接 Samples:http://www.dhtmlx.com/docs/products/docsExplorer/samples.shtml
链接 Docs:http://docs.dhtmlx.com/doku.php
dhxWins初始化及创建操作:
//Step 1:初始化dhxWins对象 var dhxWins = new dhtmlXWindows(); dhxWins.enableAutoViewport(false);//if true - allows an object to adjust the viewport automatically to document.body dhxWins.attachViewportTo("winDiv");//窗体所能活动的区域Div dhxWins.setImagePath("../../codebase/imgs/"); //Step 2:创建窗体 w1 = dhxWins.createWindow("w1", 20, 30, 520, 440); //id,position_x,position_y,size_width,size_height[(x,y)为窗口左上角顶点位置,width为宽度,height为高度] w1.setText("dhtmlxWindow"); w1.button("close").disable();//关闭按钮 w1.button("help").show(); //显示帮助按钮 w1.button("stick").show();//显示固定按钮:永远置顶层 w1.button("minmax1").hide();//隐藏最小化 按钮 w1.button("park").hide();//隐藏最大化按钮 w1.denyResize();//禁用拖动边界 w1.denyPark();//禁用最大化 w1.showHeader();//header w1.hideHeader(); w1.button("park").attachEvent("onClick", function() { alert("button \"Park\" was clicked"); }); //Step 3:attach绑定其他组件: w1.attachURL("../common/testpage.html");//绑定新的jsp页面 var form=w1.attachForm(formData);//绑定Form表单 /* menu = w1.attachMenu(); menu.setImagePath("../../../dhtmlxMenu/codebase/imgs/"); menu.setIconsPath("../../../dhtmlxMenu/samples/common/imgs/"); menu.loadXML("../../../dhtmlxMenu/samples/common/dhxmenu.xml?" + new Date().getTime()); toolbar = w1.attachToolbar(); toolbar.setIconsPath("../../../dhtmlxToolbar/samples/common/imgs/"); toolbar.loadXML("../../../dhtmlxToolbar/samples/common/dhxtoolbar_button.xml?" + new Date().getTime()); sb = w1.attachStatusBar(); sb.setText("Simple Status Bar"); */
dhxWins对象操作窗体:
//dhxWins对象操作窗体 dhxWins.window(id).setModal(true/false);//模糊背景,突显窗口 dhxWins.window(id).setPosition(w, h); dhxWins.window(id).allowMove();//允许移动 dhxWins.window(id).denyMove();//禁止拖动 dhxWins.window(getId()).center();//居中 dhxWins.window("w1").attachEvent("onHelp", function() { alert("button \"Help\" was clicked"); });
关闭窗体:
dhxWins.window("w1").close();//关闭窗口 parent.dhxWins.window("w2").close();//关闭父级窗口
其他:
/**mgmt页面弹出框:修改密码*/ function changePwd(userID){ var formData=[ {type:"block", list:[ {type:"settings",position:"label-left",labelWidth:90,inputWidth: 150, labelAlign: "right",offsetTop:10}, {type:"input",name:"password1",label:"设置密码:",value:"",required:true, validate: "NotEmpty"}, {type:"input",name:"password2",label:"重复密码:",value:"",required:true, validate: "NotEmpty"} ]}, {type:"block",list:[ {type:"settings",offsetTop:15}, {type:"button",name:"save",value:"确定",position:"absolute", inputLeft:40}, {type: "newcolumn", offset:20}, {type:"button",name:"cancle",value:"取消",position:"absolute", inputLeft:120} ]} ]; var pwdWin=dhxWins.createWindow("pwdWin", 0, 0, 290, 160); pwdWin.setText("设置密码"); pwdWin.center(); pwdWin.button("minmax1").hide(); pwdWin.button("minmax2").hide(); pwdWin.button("park").hide(); pwdWin.denyResize(); pwdWin.setModal(true); var form=pwdWin.attachForm(formData); form.attachEvent("onButtonClick",function(id){ switch(id){ case "save": console.log(form.getFormData(true)); form.send("user/changePwd.do?userID="+userID, "get", function(loader,str){ if(str=="OK"){ dhtmlx.alert({title:"提示",ok:"确定",text:"密码设置成功!", callback:function(){ dhxWins.window("pwdWin").close(); }}); }else{ dhtmlx.alert({title:"提示",ok:"确定",text:str, callback:function(){ form.clear(); }}); } }); break; case "cancle": dhxWins.window("pwdWin").close(); break; } }) }