U.CD.Layout.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. Namespace.register("U.CD.LO"); //注册布局
  2. //此js虽然简单,但要整理一个逻辑还是比较费力,暂时如此了
  3. //太多地方需要做宽高控制了,定义一些全局变量。
  4. /*由于html设计原理的时效性,导致宽高不能auto,用js代码补齐*/
  5. U.CD.LO.SetWH = function () {
  6. if (!document.body.clientHeight) { location.href = location.hef; } //如果没有客户端信息,则再次刷新本页
  7. //在项目开始时全部用100%,保证用户能看到全貌,然后在此处最终定义宽高。
  8. //纵向
  9. $("#UCD_TOP")[0].style.height = "52px";
  10. //下部内容,横向
  11. $("#UCD_TT")[0].style.width = "160px"; //左边工具栏宽度
  12. $("#UCD_CT")[0].style.width = document.body.offsetWidth - $("#UCD_TT")[0].offsetWidth - $('#UCD_RTree')[0].offsetWidth - 1 + "px"; //右边代码区域宽度
  13. $("#UCD_Bottom")[0].style.height = $("#UCD_CT")[0].style.height = document.body.offsetHeight - $("#UCD_TOP")[0].offsetHeight + 'px'; //下部内容显示框高度
  14. $("#UCD_CT_Top_Tab")[0].style.height = "30px"; //中间头部切换栏
  15. $("#UCD_CT_BT")[0].style.height = "30px"; //中间底部命令行
  16. $("#UCD_CT_CT")[0].style.height = $("#UCD_CT")[0].offsetHeight - $("#UCD_CT_BT")[0].offsetHeight - $("#UCD_CT_Top_Tab")[0].offsetHeight + 'px';
  17. //$("#UCD_Bottom")[0].style.width = document.body.offsetWidth + 'px';
  18. //视图
  19. $("#UCD_CT_SM_IF")[0].style.height = document.body.offsetHeight + 'px';
  20. // $("#UCD_CT_SM_IF")[0].style.width = document.body.offsetWidth + 'px';
  21. //代码
  22. $("#UCD_CT_HH_Code")[0].style.height = "40%";
  23. //$("#UCD_CT_Code").css("width", $("#UCD_CT_HH_Code")[0].offsetWidth - $("#UCD_CT_HH_CT")[0].offsetWidth - 100 + "px");
  24. /*
  25. //设置高度,高度无法100%;使用document.body.clientHeight必须CSS放前面?保证html body的值为100%,得不到,需要判断//window.screen.availWidth//document.documentElement.clientWidth //document.documentElement.innerWidth
  26. //$("#UCD_Bottom")[0].style.height = document.body.clientHeight -dfghdfhdfgdf
  27. //中间代码,代码结果窗口高度
  28. var _ch = $("#UCD_Bottom")[0].clientHeight - $("#UCD_CT_Top_Tab")[0].clientHeight - $("#UCD_CT_BT")[0].clientHeight;
  29. if (_ch > 0) $("#UCD_CT_CT")[0].style.height = _ch - 4 + "px";
  30. //代码窗口宽度,有可能小于0,判断一下
  31. //var _cw = $("#UCD_CT_CT")[0].clientWidth - $("#UCD_CT_IF")[0].clientWidth - 2;
  32. //if (_cw > 0) $("#UCD_CT_HH_Code")[0].style.width = _cw + "px";
  33. //工具栏控件区域高度
  34. // $("#UCD_TT_Z")[0].style.height = $("#UCD_TT")[0].clientHeight - 37 + "px";
  35. //$("#UCD_TT_Z")[0].style.height = $("#UCD_Bottom")[0].clientHeight - 26 -60 + "px";
  36. //如果资源窗口没有显示,则扩大代码区域,_tt是左边工具栏宽度 _ct是中间区域宽度 _rt是右边区域宽度 6是分割线宽度
  37. var _tt = $("#UCD_TT")[0], _ct = $("#UCD_CT")[0], _rt = $("#UCD_RTree")[0], _aw = document.body.clientWidth, _bk = 4;
  38. //如果资源管理器和工具栏都不可显示,则
  39. if (_aw != 0) {
  40. //if (_tt.style.display == "none" && _rt.style.display == "none") { _ct.style.width = _aw - _bk + "px"; }
  41. // if (_tt.style.display == "none" && _rt.style.display == "block") { _ct.style.width = _aw - _rt.clientWidth - _bk + "px"; }
  42. // if (_tt.style.display == "block" && _rt.style.di8979splay == "none") { _ct.style.width = _aw - _tt.clientWidth - _bk + "px"; }
  43. // if (_tt.style.display == "block" && _rt.style.display == "block") { _ct.style.width = _aw - _tt.clientWidth - _rt.clientWidth - _bk + "px"; }
  44. }
  45. //结果显示窗口给固定宽高才能有滚动条。
  46. var _if = $("#UCD_CT_SM_IF")[0], _ifct = $("#UCD_CT_IF")[0];
  47. _if.width = _if.parentNode.clientWidth + "px"; //必须设置宽度才有效? //iframe的100%不起作用啊。
  48. if (_ifct.clientHeight - 20 > 0) { _if.style.height = _ifct.clientHeight - 20 + "px"; }
  49. */
  50. /* 暂时去掉::迭代
  51. //代码区域宽度等于 包容器减去行号宽度
  52. var _code = $("#UCD_CT_Code")[0], _hh = $("#UCD_CT_HH_CT")[0], _rq = $("#UCD_CT_HH_Code")[0]
  53. _code.style.width = _rq.clientWidth - _hh.clientWidth + "px";
  54. */
  55. }
  56. //单击左边分割线时,隐藏工具栏窗口?o为传递进来的控件类型
  57. U.CD.LO.HEToolbar = function (o) {
  58. $("#UCD_TT")[0].style.display = $("#UCD_TT")[0].style.display == "none" ? "block" : "none";
  59. U.CD.LO.SetWH();
  60. }
  61. //关闭资源管理器影响的布局//关闭资源管理器
  62. U.CD.LO.CloseZY = function () { $("#UCD_RTree")[0].style.display = "none"; U.CD.LO.SetWH(); }
  63. //打开资源管理器
  64. U.CD.LO.OpenZY = function () {
  65. $("#UCD_RTree")[0].style.display = "block";
  66. U.CD.LO.SetWH();
  67. }
  68. //打开或者关闭资源管理器,在顶部菜单使用
  69. U.CD.LO.OCZY = function () {
  70. // if (U.CD.U.IsUSelf() == false) { U.CD.U.LoginApply(); return; }
  71. $("#UCD_RTree")[0].style.display = $("#UCD_RTree")[0].style.display == "none" ? "block" : "none";
  72. //$("#UCD_RTree")[0].style.display = "block";
  73. U.CD.LO.SetWH();
  74. }
  75. //视图全屏模式,
  76. U.CD.LO.View = function (div) {
  77. U.CD.LO.A();
  78. var _a = $(".UCD_CT_BT_Com")
  79. for (var i = 0; i < _a.length; i++) {
  80. _a[i].style.background = " -webkit-linear-gradient(#fffffff, #d8d8d8)";
  81. _a[i].style.color = "#020202";
  82. }
  83. var _v = $("#UCD_CT_IF")[0], _c = $("#UCD_CT_HH_CT")[0], _if = $("#UCD_CT_SM_IF")[0]
  84. _c.style.display = "none";
  85. _v.style.display = "block"; _v.style.height = "100%";
  86. for (var i in $('.UCD_CT_BT_Com').length - 2) { $('.UCD_CT_BT_Com').css({ 'background': '-webkit-linear-gradient(#ffffff, #d8d8d8);', 'color': '#000' }) }
  87. $(div).css({
  88. 'background': '-webkit-linear-gradient(top, rgb(81, 154, 251), rgb(21, 119, 230))',
  89. 'color': '#fff'
  90. })
  91. U.CD.LO.SetWH();
  92. test();
  93. }
  94. //代码模式
  95. U.CD.LO.Code = function (div) {
  96. U.CD.LO.A();
  97. var _a = $(".UCD_CT_BT_Com")
  98. for (var i = 0; i < _a.length; i++) {
  99. _a[i].style.background = " -webkit-linear-gradient(#ffffff, #d8d8d8)";
  100. _a[i].style.color = "#020202";
  101. }
  102. var _v = $("#UCD_CT_IF")[0], _c = $("#UCD_CT_HH_Code")[0];
  103. _v.style.display = "none";
  104. _c.style.display = "block"; _c.style.height = "100%";
  105. _c = $("#UCD_CT_HH_Code").Child();
  106. for (var i = 0; i < _c.length; i++) {
  107. _c[i].style.height = "100%";
  108. }
  109. for (var i in $('.UCD_CT_BT_Com').length - 2) { $('.UCD_CT_BT_Com').css({ 'background': '-webkit-linear-gradient(#ffffff, #d8d8d8);', 'color': '#000' }) }
  110. $(div).css({
  111. 'background': '-webkit-linear-gradient(top, rgb(81, 154, 251), rgb(21, 119, 230))',
  112. 'color': '#fff'
  113. })
  114. U.CD.LO.SetWH();
  115. $("#UCD_CT_HH_Code")[0].style.height = "100%";
  116. $("#UCD_CT_HH_CT")[0].style.height = "200%";
  117. test();
  118. }
  119. //拆分模式
  120. U.CD.LO.Split = function (div) {
  121. U.CD.LO.A();
  122. var _a = $(".UCD_CT_BT_Com")
  123. _a.css({
  124. "-webkit-linear-gradient": "#ffffff, #d8d8d8",
  125. "color": "#020202"
  126. });
  127. $(div).css({
  128. "-webkit-linear-gradient": "#519afb, #1577e6",
  129. "color": "white"
  130. });
  131. var _v = $("#UCD_CT_IF"), _c = $("#UCD_CT_HH_CT");
  132. _v.css({
  133. "height": "60%",
  134. "display": "block"
  135. });
  136. _c.css({
  137. "height": "40%",
  138. "display": "block"
  139. });
  140. $('#UCD_CT_SM_IF').css({ 'margin-top': '0', 'width': '100%', 'height': '100%', 'border': '0' })
  141. for (var i in $('.UCD_CT_BT_Com').length - 2) { $('.UCD_CT_BT_Com').css({ 'background': '-webkit-linear-gradient(#ffffff, #d8d8d8);', 'color': '#000' }) }
  142. $(div).css({
  143. 'background': '-webkit-linear-gradient(top, rgb(81, 154, 251), rgb(21, 119, 230))',
  144. 'color': '#fff'
  145. })
  146. test();
  147. }
  148. //手机模式
  149. U.CD.LO.Jude = true;
  150. U.CD.LO.Phone = function (_event) {
  151. var _a = $(".UCD_CT_BT_Com"), _f = $("#UCD_CT_SM_IF"),
  152. _Arr = { //手机模式的种类
  153. "Galaxy S5": { w: 360, h: 640 },
  154. "Nexus 5X": { w: 412, h: 732 },
  155. "Iphone 5": { w: 320, h: 568 },
  156. "Iphone 6": { w: 375, h: 667 },
  157. "Iphone 6 Plus": { w: 414, h: 736 }
  158. }, i;
  159. $('#UCD_CT_IF')[0].style.display = 'block';
  160. $("#UCD_CT_IF").css({ textAlign: "center", height: "100%", "border-right": "8px solid#7d7d7d", "min-width": "0px", "width": "40%" });
  161. $("#UCD_CT_HH_Code").css({ "min-width": "0px", "height": "100%", "width": "calc(100% - 40.9%)" });
  162. for (var i in $('.UCD_CT_BT_Com').length - 2) { $('.UCD_CT_BT_Com').css({ 'background': '-webkit-linear-gradient(#ffffff, #d8d8d8);', 'color': '#000' }) }
  163. _a[3].style.background = "-webkit-linear-gradient(#519afb, #1577e6)";
  164. _a[3].style.color = "white";
  165. $("#U_CD_LO_Window")[0].style = "display:block;width:65px;background:-webkit-linear-gradient(#ffffff, #d8d8d8);color:#020202";
  166. $("#U_CD_LO_Window2")[0].style = "display:none;";
  167. for (i in _Arr) { //判断是哪一个手机类型 改变样式大小
  168. if (_event.srcElement.innerText == i) {
  169. _f.css({
  170. "width": _Arr[i].w + "px",
  171. "height": _Arr[i].h + "px",
  172. "margin": "10% 2% 0 2%"
  173. });
  174. document.getElementById('UCD_CT_SM_IF').contentWindow.document.body.style.zoom = 0.6;
  175. break;
  176. }
  177. }
  178. for (var i = 0; i < 5; i++) { _a[3].children[0].children[1].children[i].style = " background : -webkit-linear-gradient(#ffffff, #2d8d8d8)"; }
  179. _event.srcElement.style.background = "-webkit-linear-gradient(#519afb, #1577e6)";
  180. _event.srcElement.style.color = 'white';
  181. U.CD.LO.Jude = true;
  182. event.stopPropagation();
  183. }
  184. U.CD.LO.judge = function () {
  185. if (U.CD.LO.Jude == false && $('.UCD_CT_BT_Com')[3].style.background == '-webkit-linear-gradient(top, rgb(81, 154, 251), rgb(21, 119, 230))') {
  186. U.CD.LO.Jude = false;
  187. event.stopPropagation();
  188. } else { //取消手机模式
  189. $('#UCD_CT_SM_IF').css({ "width": "100%", "height": "100%", "margin": "0%" })
  190. $("#UCD_CT_IF").css({ "width": "100%", "height": "60%" })
  191. $("#UCD_CT_HH_Code").css({ "width": "100%", "height": "40%" })
  192. U.CD.LO.Jude = true;
  193. event.stopPropagation();
  194. }
  195. if ($("#UCD_CT_BT div")[3].style.background == "-webkit-linear-gradient(top, rgb(81, 154, 251), rgb(21, 119, 230))" && event.srcElement.innerText.substr(0, 4) == "手机模式") {
  196. var _a = $(".UCD_CT_BT_Com"), _f = $("#UCD_CT_SM_IF");
  197. _f.css({
  198. "width": "100%",
  199. "height": "100%",
  200. "border": "0px"
  201. })
  202. for (i = 0; i < _a.length; i++) { //改变按钮样式
  203. _a[i].style.background = " -webkit-linear-gradient(#ffffff, #d8d8d8)";
  204. _a[i].style.color = "#020202";
  205. }
  206. for (var a = 0; a < $(".UCD_CT_BT_Com_Phone_List")[0].children.length; a++) {
  207. $(".UCD_CT_BT_Com_Phone_List")[0].children[a].style.background = "#fff";
  208. $(".UCD_CT_BT_Com_Phone_List")[0].children[a].style.color = "#000"
  209. }
  210. document.getElementById('UCD_CT_SM_IF').contentWindow.document.body.style.zoom = 1;
  211. }
  212. test();
  213. }
  214. U.CD.LO.Window = function () { //窗口模式
  215. $('#UCD_CT_SM_IF').css({ "width": "100%", "height": "100%", "margin": "0%" })
  216. $("#UCD_CT_IF").css({ "width": "100%", "height": "60%" })
  217. $("#UCD_CT_HH_Code").css({ "width": "100%", "height": "40%" })
  218. U.CD.LO.Jude = true;
  219. event.stopPropagation();
  220. var _a = $(".UCD_CT_BT_Com"), _d = $("#U_CD_LO_Window")[0];
  221. for (var i = 0; i < _a.length; i++) {
  222. _a[i].style.background = " -webkit-linear-gradient(#ffffff, #d8d8d8)";
  223. _a[i].style.color = "#020202";
  224. }
  225. document.getElementById('UCD_CT_SM_IF').contentWindow.document.body.style.zoom = "1";
  226. _d.style = "background:-webkit-linear-gradient(#519afb, #1577e6);color:white;display:none";
  227. document.getElementById('UCD_CT_SM_IF').style = "width:700px;border:1px solid ";
  228. $("#U_CD_LO_Window2")[0].style = "display:block;background:-webkit-linear-gradient(#519afb, #1577e6);color:white";
  229. }
  230. //取消窗口模式
  231. test = function () {
  232. // document.getElementById('UCD_CT_SM_IF').style = "width:100%;border:0px;";
  233. // $("#U_CD_LO_Window")[0].style = "display:block;width:65px;background:-webkit-linear-gradient(#ffffff, #d8d8d8);color:#020202";
  234. // $("#U_CD_LO_Window2")[0].style = "display:none;";
  235. // document.getElementById('UCD_CT_SM_IF').contentWindow.document.body.style.zoom = "1";
  236. }
  237. //取消对展示框 代码框的更改
  238. U.CD.LO.A = function () {
  239. $("#UCD_CT_IF").css({ "height": "100%", "min-height": "400px", "width": "100%" });
  240. $("#UCD_CT_HH_Code").css({ "height": "40%", "min-height": "1100px", "width": "100%" });
  241. $("#UCD_CT_SM_IF").css({ "width": "", "height": "", "margin": "" });
  242. }