创建Dialog js代码
$("#").createDialog({
autoOpen: false,
zIndex: 3999,
width: 680,
height: 600,
buttons:{
"保存" : function() {
$("#monthPlanForm").submit();
$("#monthlyPlanGrid").trigger("reloadGrid");
},
"取消" : function() {
$(this).dialog("close");
}
},
open: function (event, ui) {
var $dialog = $(this);
var atext = $(".ui-dialog-titlebar-close").replaceWith(
'<p class="ui-xlgwr"> '+
'<span class="ui-icon ui-icon-maxthick" title="最大化">max</span>'+
'<span class="ui-icon ui-icon-resetthick" title="还原">reset</span>'+
'<span class="ui-icon ui-icon-closethick" title="关闭">close</span>'+
'</p>'
);
var myw = document.body.clientWidth; //定义一个myw,接受到当前全屏的宽
var myh = document.body.clientHeight; //定义一个myw,接受到当前全屏的高
var initwidth = $dialog[0].parentNode.clientWidth;
var initheight = $dialog[0].parentNode.clientHeight;
var initTop = $dialog[0].parentNode.style.top;
var initLeft = $dialog[0].parentNode.style.left;
$(".ui-xlgwr>span")["1"].style.display = "none";
$(".ui-xlgwr>span").click(function () {
var spantext = $(this).text();
if (spantext == "max") { //最大化
$dialog.dialog({
position: ['left', 'top'],
width: myw,
height: myh
});
$(".ui-xlgwr>span")["0"].style.display = "none";
$(".ui-xlgwr>span")["1"].style.display = "block";
} else if (spantext == "reset") {
$dialog.dialog({
width: initwidth,
height: initheight
});
$dialog[0].parentNode.style.top = initTop;
$dialog[0].parentNode.style.left = initLeft;
$(".ui-xlgwr>span")["0"].style.display = "block";
$(".ui-xlgwr>span")["1"].style.display = "none";
} else if (spantext == "close") {
$dialog.dialog("close");
} else {
alert("请选择正确的图标,谢谢.");
}
});
},
close: function () {
$(".loadmessage").hide();
}
});
样式
<style>
p.ui-xlgwr .ui-icon{ position:relative; float: left; margin:1.5em 0.5em 0 0.5em; cursor: pointer; z-index:999;}
p.ui-xlgwr{ position:absolute; top:-10px; padding:0; right:0; display:inline;}
</style>