U.SB.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //#region 窗体放大缩小
  2. Namespace.register("U.D")
  3. // 窗体全局变量
  4. U.D.isTop = false;
  5. U.D._closes = [];
  6. U.D._index = [];
  7. U.D.closefun = function (UDOD) {
  8. U.D._closes.splice(U.D._closes.indexOf(UDOD), 1);
  9. };
  10. /**
  11. * 放大窗体
  12. *
  13. * @param {number} 数字1
  14. * @param {number} 数字2
  15. * @param {boolean} 返回数字1是否大于数字2
  16. * @param {number} 数字2
  17. * @param {boolean} 返回数字1是否大于数字2
  18. */
  19. U.D.Windowmaximize = function (UDOD, UDTD, UCB, UDOM, UST) {
  20. var _USE, _UCE, _UTE, _UTF = true,
  21. _UDTD = $(UDOD),
  22. _UST = UDOD.style,
  23. _UED = U.M.GetPDWH(UDOD),
  24. _UW = US.Width,
  25. _UH = US.Height;
  26. UDTD = UDTD || (event && event.srcElement); //U.M.GetElementInfo(UDOD)
  27. if (_UED["OW"] >= _UW && _UED["OH"] >= _UH) {
  28. _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%"} };
  29. _UTF = false;
  30. }
  31. else {
  32. _UTE = UDOD["style"];
  33. _USE = { "onmousedown": UDOM ? UDOM.onmousedown : null,
  34. "style": { "cssText": _UTE["cssText"] + ";", "width": _UTE.width, "height": _UTE.height, "top": _UTE.top, "left": _UTE.left, "display": "block" }, "width": _UED["CW"], "height": _UED["CH"]
  35. };
  36. _UCE = { "title": "缩小",
  37. "onmousedown": UDOM ? (U.M.apply(UDOM, [[UDOM.onmousedown], [U.D.DragElement, [UDOD, UDTD, UCB, UDOM, _USE]]])) : null,
  38. "style": { "top": "0px", "left": "0px", "width": (_UW - _UED["PD"][1] - _UED["PD"][3] - _UED["BD"][1] - _UED["BD"][3]) + "px",
  39. "height": (_UH - _UED["PD"][0] - _UED["PD"][2] - _UED["BD"][0] - _UED["BD"][2]) + "px"
  40. }
  41. }; //_UED["PXT"] + _UED["PXL"] +
  42. }
  43. (UDOM) && (UDOM.onmousedown = _UCE.onmousedown);
  44. (UDTD) && ($(UDTD).addAttrArray({ "onclick": [[U.D.Windowmaximize, [UDOD, UDTD, UCB, UDOM, _USE]]], "title": _UCE["title"] })); //拖动 //全屏或者恢复调用
  45. UDOD.style.display = "block";
  46. $(UDOD).animate(_UCE.style, 150, function () {
  47. var _UED = U.M.GetPDWH(UDOD); U.D.withf(UCB, [_UED["CW"], UDOD["CH"], _UTF]);
  48. }); //窗体大小设置 //回调大小设置
  49. }
  50. //最大化移动窗体
  51. /**
  52. * 放大窗体
  53. *
  54. * @param {number} 数字1
  55. * @param {number} 数字2
  56. * @param {boolean} 返回数字1是否大于数字2
  57. * @param {number} 数字2
  58. * @param {boolean} 返回数字1是否大于数字2
  59. */
  60. U.D.DragElement = function (UDOD, UDTD, UCB, UDOM, UST) {
  61. if (U.D.DragMouseDown.ST) {
  62. U.D.DragMouseDown.ST.set({ move: function (UTE) { //缩小使用
  63. var _UW = US.Width,
  64. _UE = U.M.GetMousep(UDOD);
  65. (!UST.width) && (UST.width = US.Width * 0.8);
  66. (!UST.height) && (UST.height = US.Height * 0.8);
  67. U.Ut.AddObj(UST["style"], {
  68. "top": "0px", "left": Math.min(Math.max((_UE["X"] - UST.width / 2), 0), (_UW - UST.width)) + "px"
  69. }); //设置位置大小
  70. U.D.Windowmaximize(UDOD, UDTD, UCB, UDOM, UST);
  71. (UTE && UTE.move) && (UTE.move = null); //设置大小
  72. }
  73. });
  74. }
  75. }
  76. //窗体最小化
  77. U.D.WindowMin = function (UDOD) {
  78. UDOD = $(UDOD);
  79. var i, _UCE, _UW = US.Width,
  80. _UH = US.Height,
  81. _UGE = UDOD.GetElementInfo();
  82. _UDE = { "cssText": UDOD[0].style.cssText, "display": "none" };
  83. 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]]]));
  84. (parent.U.D.G) && (setTimeout(function () { parent.U.D.G.UrlWrite([], ""); }, 0));
  85. }
  86. //关闭窗口
  87. U.D.CloseWindow = function (UDOD, UTF) {
  88. var _UDTD = $(UDOD);
  89. (_UDTD.css("display") != "none") && (_UDTD.fadeIn(150, UTF == "remove" ? function () {
  90. _UDTD.remove(); _UDTD = null;
  91. } : "")); //移除
  92. (parent.U.D.G && UTF !== true) && (parent.U.D.G.UrlWrite([], ""));
  93. (U.D && U.D.Tb && U.D.Tb.taskbars) && (U.D.Tb.taskbars.close(UDOD)); //异步url重写
  94. (U.D._closes.indexOf(UDOD) == -1) && (U.D._closes.push(UDOD));
  95. setTimeout(U.M.apply(this, [[U.D.closefun, [UDOD]]]), 0); //删除处理区
  96. }
  97. //窗口居中
  98. U.D.PopupWindow = function (UDOD, UCB) {
  99. var i, _UL, _UT, _UW, _UH,
  100. _UTF = $(UDOD).css("display") == "none",
  101. _UDE = $(UDOD).addAttrArray({ "style": { "display": "block"} })[0],
  102. _UDPD = U.M.TOSP(UDOD), _UW = _UDPD.offsetWidth || US.Width,
  103. _UH = _UDPD.offsetHeight || US.Height;
  104. _UL = (_UW - _UDE["offsetWidth"]) / 2 + _UDPD["scrollLeft"];
  105. _UT = (_UH - _UDE["offsetHeight"]) / 2 + _UDPD["scrollTop"];
  106. 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; }
  107. U.D._index[2] = UDOD;
  108. U.D.SetDTop($(UDOD).addAttrArray({ "style": { "cssText": "left:" + _UL + "px;top:" + _UT + "px;z-index:" + ((parent.US.ZV++) + 1)} })[0]);
  109. (U.Ut.isFunction(UCB)) && (UCB());
  110. (_UTF && UDOD.onresize) && (UDOD.onresize()); //定位
  111. }
  112. //窗体置顶
  113. U.D.SetDTop = function (UDOD, UTF) {
  114. (U.Ut.isEvent(UDOD)) && (UDOD = null);
  115. UDOD = UDOD || U.D.GetEE();
  116. var i, _UDPD,
  117. _UDE = U.D.GetPD(UDOD);
  118. if (UTF !== true) {
  119. setTimeout(U.M.apply(null, [[U.D.SetDTop, [UDOD || _UDE[0], true]]]), 0);
  120. }
  121. else {
  122. if (_UDE && _UDE.length) {
  123. for (i = 0; i < _UDE.length; i++) {
  124. 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)) { //置顶判断
  125. $(_UDE[i]).addAttrArray({ "style": { "cssText": "z-index:" + (((US || parent.US).ZV++) + 1) + ";display:block"} })
  126. }
  127. };
  128. }
  129. return parent.US.ZV;
  130. }
  131. }
  132. //获取置顶元素
  133. U.D.GetEE = function () {
  134. var _UE = window.event;
  135. if (!_UE) { return document.activeElement; }
  136. return _UE.srcElement;
  137. }
  138. //获取顶层窗体
  139. U.D.GetPD = function (UDOD) {
  140. var i, _UCE = [],
  141. _UDTD = UDOD,
  142. _UDBD = document.body,
  143. _UDSD = $("#UD_SY")[0] || $("#usestudio-server")[0] || _UDBD;
  144. if (_UDSD) {
  145. while ((_UDTD = U.M.TOSP(_UDTD, true, "absolute")) && (_UDTD && (_UDTD != _UDSD && _UDTD != _UDBD))) {
  146. _UCE.push(_UDTD);
  147. _UDTD = _UDTD.parentNode;
  148. }
  149. return _UCE; //.slice(0, -1);
  150. }
  151. }
  152. //桌面窗体自动分层次处理
  153. U.D.TopForm = function (UCB, UTF, UDOD) {
  154. UDOD = UDOD || document.body;
  155. var _UCF = U.M.apply(null, [[U.D.TopForm._UFN, [UCB, UTF]], [U.D.displayM]]);
  156. $(UDOD).bind({ mousedown: _UCF });
  157. }
  158. //主处理分层次系统
  159. U.D.TopForm._UFN = function (UCB, UTF) { //处理函数
  160. //页面置顶处理
  161. // try { this.focus(); } catch (e) { }
  162. if (U.D.isTop) { clearTimeout(U.D.isTop); }
  163. else {
  164. if (UTF && !U.D.isTop) {
  165. U.D.isTop = setTimeout(function () {
  166. (UCB || top.U.D.SetDTop)(null, true);
  167. U.D.isTop = false;
  168. }, 0); return;
  169. }
  170. else if (!U.D.isTop) {
  171. (UCB || top.U.D.SetDTop)(null, true);
  172. (event && event.type == "mousedown") && (U.D.isTop = true);
  173. }
  174. else if (U.D.isTop == true) { U.D.isTop = false; }
  175. }
  176. U.D.isTop = setTimeout(function () {
  177. U.D.isTop = false;
  178. }, 0);
  179. }
  180. //页面右键菜单取消
  181. U.D.displayM = function () {
  182. }
  183. //#endregion