/*! * 主 题:《页面弹出窗口》 * 说 明:用于子页面弹出时的窗口。 * 功能描述: * 1、生成弹出窗口,窗口内包括iframe控件,用于加载实际控制页面; * 2、窗口弹出时,生成背景遮罩; * 3、窗口最小为宽高100,小于等于100时,宽高值默认为浏览器窗口的百分比; * * * 作 者:宋雷鸣 * 开发时间: 2012年12月28日 */ //窗体Jquery对象 PageBox.prototype.WinBox = null; //窗口关闭时的事件 PageBox.prototype.CloseEvent = null; //弹出窗口的主类 //title:窗口标题 //page:打开的页面 //width:窗口宽度 //height:窗口高度 //widId:窗口id function PageBox(title, page, width, height, winId) { this.Init(title, page, width, height, winId); } //初始化参数 PageBox.prototype.Init = function (title, page, width, height, winId) { title = title != null && title != "" ? title : "newWinBox"; //如果为空,则为浏览器窗口一半宽高 width = width != null && width != 0 && width != "" ? Number(width) : $("body").width() / 2; height = height != null && height != 0 && height != "" ? Number(height) : $("body").height() / 2; //如果宽高小于100,则默认为浏览器窗口的百分比 width = width > 100 ? Number(width) : $("body").width() * Number(width) / 100; height = height > 100 ? Number(height) : $("body").height() * Number(height) / 100; //alert(winId); if (winId == null) { winId = new Date().ToString() + "_" + Math.floor(Math.random() * 1000 + 1); } // this.Title = title; this.Width = width; this.Height = height; this.Page = page; this.WinId = winId; } //创建窗口,并打开 PageBox.prototype.Open = function (title, page, width, height, winId) { //判断是否已经存在窗口 var WinBox = $(".PageBox[winId='" + this.WinId + "']"); if (WinBox.size() > 0) return; this.Close(); //生成窗口 this.Mask(); this.BuildFrame(); this.BuildTitle(); this.BuildIFrame(); if (this.CloseEvent != null) { var str = String(this.CloseEvent).replace(/[\r\n]/g, "").replace(/\{2,}/g, ""); str = str.replace(/'/g, "'").replace(/"/g, """); this.WinBox.attr("closeevent", str); } //设置拖动 $(".PageBox").easydrag(); $(".PageBox").setHandler("PageBoxTitle"); //开始拖动 $(".PageBox").ondrag(function () { $("#PageBoxIframeMask").show(); var frame = $("#PageBoxIframeTemp"); if (frame.size() > 0) { frame.hide(); } }); //停止拖动 $(".PageBox").ondrop(function () { $("#PageBoxIframeMask").hide(); var frame = $("#PageBoxIframeTemp"); if (frame.size() > 0) { var PageBox = $(".PageBox"); var offset = PageBox.offset(); frame.css("top", offset.top); frame.css("left", offset.left); frame.show(); } }); //完成后触发事件 this.OnComplete(); } //生成窗体外框 PageBox.prototype.BuildFrame = function () { //屏幕的宽高 var hg = $(window).height(); var wd = $(window).width(); // $("body").append("
"); var PageBox = $(".PageBox"); this.WinBox = PageBox; var border = parseInt(PageBox.css("border-width")); //窗体边线宽度 border = !isNaN(border) ? border : 0; //设置窗口的位置 PageBox.css("top", (hg - this.Height) / 2 - border); PageBox.css("left", (wd - this.Width) / 2 - border); PageBox.css("position", "absolute"); PageBox.css("z-index", "20001"); PageBox.css("width", this.Width); PageBox.css("height", this.Height); } //生成标题栏 PageBox.prototype.BuildTitle = function () { var box = this.WinBox; box.append(""); var titbox = $("#PageBoxTitle"); var tm = "| " tm += " | " + this.Title + " | ";
tm += "";
tm += "![]() | ";
tm += "