U.Word.Tools.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. Namespace.register("U.Word.Tools");
  2. /**
  3. * 功能创建
  4. *
  5. * @param {object} 登录用户信息
  6. * @param {str} 类型
  7. * @param {object} 文档信息数组 或 null
  8. * @return {object} 头部信息和顶部工具栏的整体元素
  9. */
  10. U.Word.Tools.Wordtools = function (UIF, UTF, UDE, UDOD) {
  11. //如果是word,excel共用的区域,则需要改写此部分,让word,excel分离。
  12. var _UDE = [],
  13. _UDOD = $(UDOD), // $("#UD_Word_Tool").clone(true), //整体克隆功能区域元素,克隆的工具栏+菜单,要拆分
  14. _UDAD = _UDOD.Child(), //获取子级
  15. _UDKD = $(_UDAD[1]).Child();
  16. //设置所有的按钮和元素不可以选择,这里为了兼容ie,ie设置了该属性后,光标在点击设置的元素后光标不会失焦
  17. $("&*", _UDOD[0]).addAttrArray({
  18. "unselectable": "on"
  19. });
  20. //上述设置了所有元素不可以设置焦点,但是input是必须设置焦点使用的,这是设置后input才能聚焦,否则练文件名都输入不了
  21. $("input", _UDOD[0]).addAttrArray({
  22. "unselectable": "off"
  23. }); //创建指定的功能
  24. U.D.Office.WUIF(UIF, _UDAD[0], UDE); //设置头部信息
  25. //循环word菜单区4个菜单,包括字体,字号,背景色,前景色。
  26. var allmenu = $(_UDKD); //所有菜单
  27. var fontmenu = $(allmenu[6]).Child()[0]; //得到字体菜单,
  28. var wordsize = $(allmenu[7]).Child()[0]; //字体大小菜单
  29. var backgroundmenu = $(allmenu[9]).Child()[1]; ; //背景颜色菜单
  30. var forground = $(allmenu[10]).Child()[1]; ; //前景色菜单
  31. U.OU.CreateFont(fontmenu); //创建字体
  32. U.OU.CreateWordSize(wordsize); //创建字号
  33. U.OU.ColorSelect(backgroundmenu); //创建背景色
  34. U.OU.ColorSelect(forground); //创建前景色
  35. //显示工具栏
  36. _UDOD.css("display", "block");
  37. return _UDOD; //头部信息和顶部工具栏的整体元素
  38. }
  39. /**
  40. * Word Excel大小处理
  41. *
  42. * @param {element} office的容器元素(主体区域)
  43. * @param {object} 文档信息数组
  44. */
  45. U.Word.Tools.WETZ = function (UDOD, UTF) {
  46. var _UDTD, _UTH,
  47. _UDAD = $(UDOD).Child(),
  48. _UW = UDOD.offsetWidth,
  49. _UH = UDOD.offsetHeight;
  50. _UTH = _UH - _UDAD[0].offsetHeight;
  51. }
  52. /**
  53. * 弹出视图切换
  54. *
  55. * @param {int} 切换的
  56. */
  57. U.Word.Tools.ViewDisplay = function () {//视图窗体
  58. var y, b, l, r; //创建变量
  59. var UDVD = $(".U_Boom_CO_Editor_head_navigation_two_l");
  60. var UDWD = $("iframe", UDVD.Parent(4))[0].contentWindow.$("#U_Boom_CO_Editor_body_left .UD_SYF_S"); //获取功能区域
  61. var UDAA = $("iframe", UDVD.Parent(4))[0].contentWindow.$("#U_Boom_CO_Editor_body_left")[0].childNodes; //获取功能区域的关闭按钮
  62. var UDOD_yq_colse = $("iframe", UDVD.Parent(4))[0].contentWindow.$(".UD_SYF_SS"); //获取获取功能区域的关闭按钮
  63. var aaa = $("iframe", UDVD.Parent(4))[0].contentWindow.$("#UD_SYQXR")[0]
  64. var UDOD_aa = $$("div", { "style": {} });
  65. var UDOD_yq = $$("div", { "id": "UDOD_yq" }, UDOD_aa);
  66. var UDOD_yq_im = $$("div", { "id": "UDOD_yq_im" }, UDOD_yq)
  67. var UDOD_yq_img = $$("div", { "id": "UDOD_yq_img" }, UDOD_yq_im)
  68. var UDOD_yq_a = $$("div", { "id": "UDOD_yq_a", "innerHTML": "邀请协助" }, UDOD_yq);
  69. var UDOD_bj = $$("div", { "id": "UDOD_bj" }, UDOD_aa);
  70. var UDOD_bj_im = $$("div", { "id": "UDOD_bj_im" }, UDOD_bj)
  71. var UDOD_bj_img = $$("div", { "id": "UDOD_bj_img" }, UDOD_bj_im)
  72. var UDOD_bj_a = $$("div", { "id": "UDOD_bj_a", "innerHTML": "编辑历史记录" }, UDOD_bj);
  73. var UDOD_lj = $$("div", { "id": "UDOD_lj" }, UDOD_aa);
  74. var UDOD_lj_im = $$("div", { "id": "UDOD_lj_im" }, UDOD_lj)
  75. var UDOD_lj_img = $$("div", { "id": "UDOD_lj_img" }, UDOD_lj_im)
  76. var UDOD_lj_a = $$("div", { "id": "UDOD_lj_a", "innerHTML": "建立链接" }, UDOD_lj);
  77. var UDOD_rm = $$("div", { "id": "UDOD_rm" }, UDOD_aa);
  78. var UDOD_rm_im = $$("div", { "id": "UDOD_rm_im" }, UDOD_rm)
  79. var UDOD_rm_img = $$("div", { "id": "UDOD_rm_img" }, UDOD_rm_im)
  80. var UDOD_rm_a = $$("div", { "id": "UDOD_rm_a", "innerHTML": "热门模板" }, UDOD_rm);
  81. U.UI.From({ id: "ViewDisplaya",
  82. style: { "width": "390px" },
  83. content: UDOD_aa,
  84. title: "视图",
  85. hst: {},
  86. bst: {},
  87. max: {},
  88. SO: false
  89. });
  90. UDOD_yq_img.style.display = "block"; //重新点击后恢复原样
  91. UDWD[0].style.display = "block";
  92. UDOD_bj_img.style.display = "block";
  93. UDWD[1].style.display = "block";
  94. UDOD_lj_img.style.display = "block";
  95. UDWD[2].style.display = "block";
  96. UDOD_rm_img.style.display = "block";
  97. UDWD[3].style.display = "block";
  98. UDAA[1].style.top = 30 + "px";
  99. UDAA[2].style.top = 300 + "px";
  100. UDAA[3].style.top = 570 + "px";
  101. UDAA[4].style.top = 840 + "px";
  102. UDAA[1].style.left = UDAA[2].style.left = UDAA[3].style.left = UDAA[4].style.left = aaa.clientWidth + 50 + "px";
  103. UDOD_yq.onclick = function () {
  104. if (y == 0) {
  105. UDOD_yq_img.style.display = "block";
  106. UDWD[0].style.display = "block";
  107. UDAA[2].style.top = UDAA[2].offsetTop + 270 + "px";
  108. UDAA[3].style.top = UDAA[3].offsetTop + 270 + "px";
  109. UDAA[4].style.top = UDAA[4].offsetTop + 270 + "px";
  110. y = 1;
  111. } else {
  112. $("iframe", UDVD.Parent(4))[0].contentWindow.U.D.CloseWindow(UDWD[0]);
  113. UDOD_yq_img.style.display = "none";
  114. UDAA[2].style.top = UDAA[2].offsetTop - 270 + "px";
  115. UDAA[3].style.top = UDAA[3].offsetTop - 270 + "px";
  116. UDAA[4].style.top = UDAA[4].offsetTop - 270 + "px";
  117. y = 0;
  118. }
  119. }
  120. UDOD_bj.onclick = function () {
  121. if (b == 0) {
  122. UDOD_bj_img.style.display = "block";
  123. UDWD[1].style.display = "block";
  124. UDAA[3].style.top = UDAA[3].offsetTop + 270 + "px";
  125. UDAA[4].style.top = UDAA[4].offsetTop + 270 + "px";
  126. if (UDAA[2].style.top == "270px") {
  127. UDAA[2].style.top = 300 + "px";
  128. }
  129. if (UDAA[2].style.top == "-270px") {
  130. UDAA[2].style.top = 30 + "px";
  131. }
  132. b = 1;
  133. } else {
  134. $("iframe", UDVD.Parent(4))[0].contentWindow.U.D.CloseWindow(UDWD[1]);
  135. UDOD_bj_img.style.display = "none";
  136. UDAA[3].style.top = UDAA[3].offsetTop - 270 + "px";
  137. UDAA[4].style.top = UDAA[4].offsetTop - 270 + "px";
  138. b = 0;
  139. }
  140. }
  141. UDOD_lj.onclick = function () {
  142. if (l == 0) {
  143. UDOD_lj_img.style.display = "block";
  144. UDWD[2].style.display = "block";
  145. UDAA[4].style.top = UDAA[4].offsetTop + 270 + "px";
  146. if (UDAA[3].style.top == "270px") {
  147. UDAA[3].style.top = 570 + "px";
  148. }
  149. if (UDAA[3].style.top == "-270px") {
  150. UDAA[3].style.top = 300 + "px";
  151. }
  152. l = 1;
  153. } else {
  154. $("iframe", UDVD.Parent(4))[0].contentWindow.U.D.CloseWindow(UDWD[2]);
  155. UDOD_lj_img.style.display = "none";
  156. UDAA[4].style.top = UDAA[4].offsetTop - 270 + "px";
  157. l = 0;
  158. }
  159. }
  160. UDOD_rm.onclick = UDOD_yq_colse[3].onclick = function () {
  161. if (r == 0) {
  162. UDOD_rm_img.style.display = "block";
  163. UDWD[3].style.display = "block";
  164. if (UDAA[4].style.top == "270px") {
  165. UDAA[4].style.top = 840 + "px";
  166. }
  167. if (UDAA[4].style.top == "-270px") {
  168. UDAA[4].style.top = 30 + "px";
  169. }
  170. r = 1;
  171. } else {
  172. $("iframe", UDVD.Parent(4))[0].contentWindow.U.D.CloseWindow(UDWD[3]);
  173. UDOD_rm_img.style.display = "none";
  174. r = 0;
  175. }
  176. }
  177. }
  178. /**
  179. * 模板选择
  180. *
  181. */
  182. U.Word.Tools.STemp = function () {//更多
  183. // var i; //循环初始化
  184. // _UDTD, //设置变量
  185. // _UDW = U.D.Office.WI(), //设置windows操作层 获取方法类
  186. // _UDE = ["word空模板", "web空模板", "导航模板", "企业模式", "会议模式", "大纲模式"], //设置数据
  187. // _UDOD = $$("div", { "className": "UD_TempA" }); //创建外部div
  188. // var _UDTD = $$("div", { "className": "UD_TempAC" }, _UDOD); //主体区域
  189. // for (i = 0; i < _UDE.length; i++) {
  190. // $$("div", { "className": "UD_TempACL", title: _UDE[i], "innerHTML": _UDE[i], "onclick": [[U.D.Office.GSTemp, ([_UDOD, _UDW, i])]] }, _UDTD);
  191. // }
  192. var UDGD = $$("div", {});
  193. var UDGD_xz = $$("div", { "className": "UDGD_xz", "innerHTML": "下载" }, UDGD);
  194. var UDGD_yj = $$("div", { "className": "UDGD_xz", "innerHTML": "意见反馈" }, UDGD);
  195. U.UI.Form({//创建更多窗体
  196. draw: false,
  197. max: false,
  198. min: false,
  199. isTop: true,
  200. id: "UD_Temp",
  201. style: {
  202. width: "350px"
  203. },
  204. content: UDGD,
  205. title: "更多",
  206. hst: {}
  207. }); //创建窗体
  208. }
  209. U.Word.Tools.XTemp = function (UIE) {
  210. var i, //循环初始化
  211. UDTD, //设置变量
  212. UDW = U.D.Office.WI(); //设置windows操作层 获取方法类
  213. var UTF = ["Word", "Web", "US_O_Navigation", "US_O_Website", "US_O_Meeting", "US_O_Outline", "US_O_Novel"][UIE]; //类型
  214. if (UTF) { //是否存在
  215. (UDW.U.Word || UDW.U.Excel)["GetTemp"](UTF); //获取office模板
  216. } else {
  217. U.Alert("此模板暂不开放");
  218. } //不存在提示
  219. var UDOD = $("#UD_SYQXR")[0];
  220. if (!UDOD.innerText.length || UDOD.innerText == $$("div", { "innerHTML": "&#8203;" }).innerText) {
  221. U.Word.XTemp(UTF);
  222. }
  223. else {
  224. top.U.UI.Confirm("是否覆盖内容", [U.Word.Tools.XTemp, ([UTF])]);
  225. }
  226. }
  227. /**
  228. * word模式切换
  229. *
  230. * @param {element} 换页元素
  231. * @param {int} 切换的
  232. */
  233. U.Word.Tools.ModeSwitch = function (UDOD, UTF) {
  234. var i,
  235. _UDCD = $(UDOD).parentg().Child();
  236. //修改切换
  237. for (i = 0; i < _UDCD.length; i++) {
  238. if (_UDCD[i] != UDOD) {
  239. _UDCD[i].className = "";
  240. }
  241. }
  242. // 目录模式 显示目录功能
  243. if (UDOD.textContent.trim() == "目录模式") {
  244. $(".U_Boom_CO_Editor_head_features #U_Boom_Catalog", $(UDOD).Parent(4)).css("display", "block");
  245. } else {
  246. $(".U_Boom_CO_Editor_head_features #U_Boom_Catalog", $(UDOD).Parent(4)).css("display", "none");
  247. }
  248. UDOD.className = "U_Boom_CO_Editor_head_navigation_color_789CD5";
  249. U.Word.Tools.ModeDisplay(UTF); //展示模板
  250. }
  251. /**
  252. * 模式展示
  253. *
  254. * @param {int} 切换的
  255. */
  256. U.Word.Tools.ModeDisplay = function (UTF) {
  257. }
  258. U.Word.Tools.IploadImg = function () {
  259. U.UP.uploading([$("#files")[0]],
  260. function (r) {
  261. U.Alert("上传成功");
  262. }, ([]), "http://disk.1473.cn/USupfile.ashx?iframename=UseStudioEditor");
  263. }