123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- //#region 窗体放大缩小
- Namespace.register("U.D")
- // 窗体全局变量
- U.D.isTop = false;
- U.D._closes = [];
- U.D._index = [];
- U.D.closefun = function (UDOD) {
- U.D._closes.splice(U.D._closes.indexOf(UDOD), 1);
- };
- /**
- * 放大窗体
- *
- * @param {number} 数字1
- * @param {number} 数字2
- * @param {boolean} 返回数字1是否大于数字2
- * @param {number} 数字2
- * @param {boolean} 返回数字1是否大于数字2
- */
- U.D.Windowmaximize = function (UDOD, UDTD, UCB, UDOM, UST) {
- var _USE, _UCE, _UTE, _UTF = true,
- _UDTD = $(UDOD),
- _UST = UDOD.style,
- _UED = U.M.GetPDWH(UDOD),
- _UW = US.Width,
- _UH = US.Height;
- UDTD = UDTD || (event && event.srcElement); //U.M.GetElementInfo(UDOD)
- if (_UED["OW"] >= _UW && _UED["OH"] >= _UH) {
- _UCE = { "title": "全屏", "onmousedown": UST ? (UST.onmousedown || (UDOM ? UDOM.onmousedown : null)) : null, "style": UST ? UST["style"] || { "width": "80%", "height": "80%", "left": "10%", "top": "10%"} : { "width": "80%", "height": "80%", "left": "10%", "top": "10%"} };
- _UTF = false;
- }
- else {
- _UTE = UDOD["style"];
- _USE = { "onmousedown": UDOM ? UDOM.onmousedown : null,
- "style": { "cssText": _UTE["cssText"] + ";", "width": _UTE.width, "height": _UTE.height, "top": _UTE.top, "left": _UTE.left, "display": "block" }, "width": _UED["CW"], "height": _UED["CH"]
- };
- _UCE = { "title": "缩小",
- "onmousedown": UDOM ? (U.M.apply(UDOM, [[UDOM.onmousedown], [U.D.DragElement, [UDOD, UDTD, UCB, UDOM, _USE]]])) : null,
- "style": { "top": "0px", "left": "0px", "width": (_UW - _UED["PD"][1] - _UED["PD"][3] - _UED["BD"][1] - _UED["BD"][3]) + "px",
- "height": (_UH - _UED["PD"][0] - _UED["PD"][2] - _UED["BD"][0] - _UED["BD"][2]) + "px"
- }
- }; //_UED["PXT"] + _UED["PXL"] +
- }
- (UDOM) && (UDOM.onmousedown = _UCE.onmousedown);
- (UDTD) && ($(UDTD).addAttrArray({ "onclick": [[U.D.Windowmaximize, [UDOD, UDTD, UCB, UDOM, _USE]]], "title": _UCE["title"] })); //拖动 //全屏或者恢复调用
- UDOD.style.display = "block";
- $(UDOD).animate(_UCE.style, 150, function () {
- var _UED = U.M.GetPDWH(UDOD); U.D.withf(UCB, [_UED["CW"], UDOD["CH"], _UTF]);
- }); //窗体大小设置 //回调大小设置
- }
- //最大化移动窗体
- /**
- * 放大窗体
- *
- * @param {number} 数字1
- * @param {number} 数字2
- * @param {boolean} 返回数字1是否大于数字2
- * @param {number} 数字2
- * @param {boolean} 返回数字1是否大于数字2
- */
- U.D.DragElement = function (UDOD, UDTD, UCB, UDOM, UST) {
- if (U.D.DragMouseDown.ST) {
- U.D.DragMouseDown.ST.set({ move: function (UTE) { //缩小使用
- var _UW = US.Width,
- _UE = U.M.GetMousep(UDOD);
- (!UST.width) && (UST.width = US.Width * 0.8);
- (!UST.height) && (UST.height = US.Height * 0.8);
- U.Ut.AddObj(UST["style"], {
- "top": "0px", "left": Math.min(Math.max((_UE["X"] - UST.width / 2), 0), (_UW - UST.width)) + "px"
- }); //设置位置大小
- U.D.Windowmaximize(UDOD, UDTD, UCB, UDOM, UST);
- (UTE && UTE.move) && (UTE.move = null); //设置大小
- }
- });
- }
- }
- //窗体最小化
- U.D.WindowMin = function (UDOD) {
- UDOD = $(UDOD);
- var i, _UCE, _UW = US.Width,
- _UH = US.Height,
- _UGE = UDOD.GetElementInfo();
- _UDE = { "cssText": UDOD[0].style.cssText, "display": "none" };
- UDOD.animate({ "cssText": "overflow:hidden;left:0px;top:" + ((_UH - _UGE["OH"] + 100) / 2) + "px;width:" + (Math.min(_UGE["OW"] / 3, 100)) + "px;height:" + (Math.min(_UGE["OH"] / 3, 100)) + "px;opacity:0.8" }, 200, U.M.apply(UDOD, [[UDOD.css, ["cssText", _UDE.cssText]], [UDOD.css, ["display", _UDE.display]]]));
- (parent.U.D.G) && (setTimeout(function () { parent.U.D.G.UrlWrite([], ""); }, 0));
- }
- //关闭窗口
- U.D.CloseWindow = function (UDOD, UTF) {
- var _UDTD = $(UDOD);
- (_UDTD.css("display") != "none") && (_UDTD.fadeIn(150, UTF == "remove" ? function () {
- _UDTD.remove(); _UDTD = null;
- } : "")); //移除
- (parent.U.D.G && UTF !== true) && (parent.U.D.G.UrlWrite([], ""));
- (U.D && U.D.Tb && U.D.Tb.taskbars) && (U.D.Tb.taskbars.close(UDOD)); //异步url重写
- (U.D._closes.indexOf(UDOD) == -1) && (U.D._closes.push(UDOD));
- setTimeout(U.M.apply(this, [[U.D.closefun, [UDOD]]]), 0); //删除处理区
- }
- //窗口居中
- U.D.PopupWindow = function (UDOD, UCB) {
- var i, _UL, _UT, _UW, _UH,
- _UTF = $(UDOD).css("display") == "none",
- _UDE = $(UDOD).addAttrArray({ "style": { "display": "block"} })[0],
- _UDPD = U.M.TOSP(UDOD), _UW = _UDPD.offsetWidth || US.Width,
- _UH = _UDPD.offsetHeight || US.Height;
- _UL = (_UW - _UDE["offsetWidth"]) / 2 + _UDPD["scrollLeft"];
- _UT = (_UH - _UDE["offsetHeight"]) / 2 + _UDPD["scrollTop"];
- if (U.D._index[2] && U.D._index[2] !== UDOD && Math.floor(_UL) == U.D._index[2].offsetLeft && Math.ceil(_UT) == U.D._index[2].offsetTop) { _UL += 20; _UT += 20; }
- U.D._index[2] = UDOD;
- U.D.SetDTop($(UDOD).addAttrArray({ "style": { "cssText": "left:" + _UL + "px;top:" + _UT + "px;z-index:" + ((parent.US.ZV++) + 1)} })[0]);
- (U.Ut.isFunction(UCB)) && (UCB());
- (_UTF && UDOD.onresize) && (UDOD.onresize()); //定位
- }
- //窗体置顶
- U.D.SetDTop = function (UDOD, UTF) {
- (U.Ut.isEvent(UDOD)) && (UDOD = null);
- UDOD = UDOD || U.D.GetEE();
- var i, _UDPD,
- _UDE = U.D.GetPD(UDOD);
- if (UTF !== true) {
- setTimeout(U.M.apply(null, [[U.D.SetDTop, [UDOD || _UDE[0], true]]]), 0);
- }
- else {
- if (_UDE && _UDE.length) {
- for (i = 0; i < _UDE.length; i++) {
- if (((_UDPD = $(_UDE[i]).Parent()) && (_UDPD == document.body || _UDPD.id == "usestudio-server" || _UDPD.id == "UD_SY")) && $(_UDE[i]).attr("__top__") != "false" && (!UTF == true || U.D._closes.indexOf(_UDE[i]) == -1)) { //置顶判断
- $(_UDE[i]).addAttrArray({ "style": { "cssText": "z-index:" + (((US || parent.US).ZV++) + 1) + ";display:block"} })
- }
- };
- }
- return parent.US.ZV;
- }
- }
- //获取置顶元素
- U.D.GetEE = function () {
- var _UE = window.event;
- if (!_UE) { return document.activeElement; }
- return _UE.srcElement;
- }
- //获取顶层窗体
- U.D.GetPD = function (UDOD) {
- var i, _UCE = [],
- _UDTD = UDOD,
- _UDBD = document.body,
- _UDSD = $("#UD_SY")[0] || $("#usestudio-server")[0] || _UDBD;
- if (_UDSD) {
- while ((_UDTD = U.M.TOSP(_UDTD, true, "absolute")) && (_UDTD && (_UDTD != _UDSD && _UDTD != _UDBD))) {
- _UCE.push(_UDTD);
- _UDTD = _UDTD.parentNode;
- }
- return _UCE; //.slice(0, -1);
- }
- }
- //桌面窗体自动分层次处理
- U.D.TopForm = function (UCB, UTF, UDOD) {
- UDOD = UDOD || document.body;
- var _UCF = U.M.apply(null, [[U.D.TopForm._UFN, [UCB, UTF]], [U.D.displayM]]);
- $(UDOD).bind({ mousedown: _UCF });
- }
- //主处理分层次系统
- U.D.TopForm._UFN = function (UCB, UTF) { //处理函数
- //页面置顶处理
- // try { this.focus(); } catch (e) { }
- if (U.D.isTop) { clearTimeout(U.D.isTop); }
- else {
- if (UTF && !U.D.isTop) {
- U.D.isTop = setTimeout(function () {
- (UCB || top.U.D.SetDTop)(null, true);
- U.D.isTop = false;
- }, 0); return;
- }
- else if (!U.D.isTop) {
- (UCB || top.U.D.SetDTop)(null, true);
- (event && event.type == "mousedown") && (U.D.isTop = true);
- }
- else if (U.D.isTop == true) { U.D.isTop = false; }
- }
- U.D.isTop = setTimeout(function () {
- U.D.isTop = false;
- }, 0);
- }
- //页面右键菜单取消
- U.D.displayM = function () {
- }
- //#endregion
|