U.Word.Tools.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. for (var k = 0; k < $("iframe", UDVD.Parent(4)).length; k++) { }
  61. var UDWD = $("iframe", UDVD.Parent(4))[k - 1].contentWindow.$("#U_Boom_CO_Editor_body_left .UD_SYF_S"); //获取功能区域
  62. var UDAA = $("iframe", UDVD.Parent(4))[k - 1].contentWindow.$("#U_Boom_CO_Editor_body_left")[0].childNodes; //获取功能区域的关闭按钮
  63. var UDOD_yq_colse = $("iframe", UDVD.Parent(4))[k - 1].contentWindow.$(".UD_SYF_SS"); //获取获取功能区域的关闭按钮
  64. var aaa = $("iframe", UDVD.Parent(4))[k - 1].contentWindow.$("#UD_SYQXR")[0];
  65. var UDOD_aa = $$("div", { "style": {} });
  66. var UDOD_yq = $$("div", { "id": "UDOD_yq" }, UDOD_aa);
  67. var UDOD_yq_im = $$("div", { "id": "UDOD_yq_im" }, UDOD_yq)
  68. var UDOD_yq_img = $$("div", { "id": "UDOD_yq_img" }, UDOD_yq_im)
  69. var UDOD_yq_a = $$("div", { "id": "UDOD_yq_a", "innerHTML": "邀请协助" }, UDOD_yq);
  70. var UDOD_bj = $$("div", { "id": "UDOD_bj" }, UDOD_aa);
  71. var UDOD_bj_im = $$("div", { "id": "UDOD_bj_im" }, UDOD_bj)
  72. var UDOD_bj_img = $$("div", { "id": "UDOD_bj_img" }, UDOD_bj_im)
  73. var UDOD_bj_a = $$("div", { "id": "UDOD_bj_a", "innerHTML": "编辑历史记录" }, UDOD_bj);
  74. var UDOD_lj = $$("div", { "id": "UDOD_lj" }, UDOD_aa);
  75. var UDOD_lj_im = $$("div", { "id": "UDOD_lj_im" }, UDOD_lj)
  76. var UDOD_lj_img = $$("div", { "id": "UDOD_lj_img" }, UDOD_lj_im)
  77. var UDOD_lj_a = $$("div", { "id": "UDOD_lj_a", "innerHTML": "建立链接" }, UDOD_lj);
  78. var UDOD_rm = $$("div", { "id": "UDOD_rm" }, UDOD_aa);
  79. var UDOD_rm_im = $$("div", { "id": "UDOD_rm_im" }, UDOD_rm)
  80. var UDOD_rm_img = $$("div", { "id": "UDOD_rm_img" }, UDOD_rm_im)
  81. var UDOD_rm_a = $$("div", { "id": "UDOD_rm_a", "innerHTML": "热门模板" }, UDOD_rm);
  82. if (UDWD[0].style.display == "none") {
  83. UDOD_yq_img.style.display = "none";
  84. y = 0;
  85. }
  86. if (UDWD[3].style.display == "none") {
  87. UDOD_bj_img.style.display = "none";
  88. b = 0;
  89. }
  90. if (UDWD[1].style.display == "none") {
  91. UDOD_lj_img.style.display = "none";
  92. l = 0;
  93. }
  94. if (UDWD[2].style.display == "none") {
  95. UDOD_rm_img.style.display = "none";
  96. r = 0;
  97. }
  98. U.UI.From({ id: "ViewDisplaya",
  99. style: { "width": "390px" },
  100. content: UDOD_aa,
  101. title: "视图",
  102. hst: {},
  103. bst: {},
  104. max: {},
  105. SO: false
  106. });
  107. for (var c = 0; c < UDAA.length; c++) {
  108. if (c > 0) {
  109. if (UDAA[c].style.top < 0) {
  110. console.log(c)
  111. UDAA[c].style.top = 0;
  112. }
  113. }
  114. }
  115. // UDOD_yq_img.style.display = "block"; //重新点击后恢复原样 ------------------按照要求说这功能用不着
  116. // UDWD[0].style.display = "block";
  117. // UDOD_bj_img.style.display = "block";
  118. // UDWD[1].style.display = "block";
  119. // UDOD_lj_img.style.display = "block";
  120. // UDWD[2].style.display = "block";
  121. // UDOD_rm_img.style.display = "block";
  122. // UDWD[3].style.display = "block";
  123. // UDAA[1].style.top = 30 + "px"; //邀请协作
  124. // UDAA[4].style.top = 300 + "px"; //编辑历史记录
  125. // UDAA[2].style.top = 570 + "px"; //建立链接
  126. // UDAA[3].style.top = 840 + "px"; //热门模板
  127. UDAA[1].style.left = UDAA[2].style.left = UDAA[3].style.left = UDAA[4].style.left = aaa.clientWidth + 50 + "px";
  128. UDOD_yq.onclick = function () {
  129. if (y == 0) {
  130. UDOD_yq_img.style.display = "block";
  131. UDWD[0].style.display = "block";
  132. UDAA[4].style.top = UDAA[4].offsetTop + 270 + "px";
  133. UDAA[2].style.top = UDAA[2].offsetTop + 270 + "px";
  134. UDAA[3].style.top = UDAA[3].offsetTop + 270 + "px";
  135. y = 1;
  136. } else {
  137. $("iframe", UDVD.Parent(4))[k - 1].contentWindow.U.D.CloseWindow(UDWD[0]);
  138. UDOD_yq_img.style.display = "none";
  139. UDAA[4].style.top = UDAA[4].offsetTop - 270 + "px";
  140. UDAA[2].style.top = UDAA[2].offsetTop - 270 + "px";
  141. UDAA[3].style.top = UDAA[3].offsetTop - 270 + "px";
  142. y = 0;
  143. }
  144. }
  145. UDOD_bj.onclick = function () {
  146. if (b == 0) {
  147. UDOD_bj_img.style.display = "block";
  148. UDWD[3].style.display = "block";
  149. UDAA[2].style.top = UDAA[2].offsetTop + 270 + "px";
  150. UDAA[3].style.top = UDAA[3].offsetTop + 270 + "px";
  151. if (UDAA[4].style.top == "270px") {
  152. UDAA[4].style.top = 300 + "px";
  153. }
  154. if (UDAA[4].style.top == "-270px") {
  155. UDAA[4].style.top = 30 + "px";
  156. }
  157. b = 1;
  158. } else {
  159. $("iframe", UDVD.Parent(4))[k - 1].contentWindow.U.D.CloseWindow(UDWD[3]);
  160. UDOD_bj_img.style.display = "none";
  161. UDAA[2].style.top = UDAA[2].offsetTop - 270 + "px";
  162. UDAA[3].style.top = UDAA[3].offsetTop - 270 + "px";
  163. b = 0;
  164. }
  165. }
  166. UDOD_lj.onclick = function () {
  167. if (l == 0) {
  168. UDOD_lj_img.style.display = "block";
  169. UDWD[1].style.display = "block";
  170. UDAA[3].style.top = UDAA[3].offsetTop + 270 + "px";
  171. if (UDAA[2].style.top == "270px") {
  172. UDAA[2].style.top = 570 + "px";
  173. }
  174. if (UDAA[2].style.top == "-270px") {
  175. UDAA[2].style.top = 300 + "px";
  176. }
  177. l = 1;
  178. } else {
  179. $("iframe", UDVD.Parent(4))[k - 1].contentWindow.U.D.CloseWindow(UDWD[1]);
  180. UDOD_lj_img.style.display = "none";
  181. UDAA[3].style.top = UDAA[3].offsetTop - 270 + "px";
  182. l = 0;
  183. }
  184. }
  185. UDOD_rm.onclick = UDOD_yq_colse[3].onclick = function () {
  186. if (r == 0) {
  187. UDOD_rm_img.style.display = "block";
  188. UDWD[2].style.display = "block";
  189. if (UDAA[3].style.top == "270px") {
  190. UDAA[3].style.top = 840 + "px";
  191. }
  192. if (UDAA[3].style.top == "-270px") {
  193. UDAA[3].style.top = 30 + "px";
  194. }
  195. r = 1;
  196. } else {
  197. $("iframe", UDVD.Parent(4))[k - 1].contentWindow.U.D.CloseWindow(UDWD[2]);
  198. UDOD_rm_img.style.display = "none";
  199. r = 0;
  200. }
  201. }
  202. }
  203. /**
  204. * 模板选择
  205. *
  206. */
  207. U.Word.Tools.STemp = function (DD) {//更多
  208. // var xz = U.Word.TF;
  209. // var i; //循环初始化
  210. // _UDTD, //设置变量
  211. var _UDW = $("iframe", $(".U_Boom_CO_Editor_head_navigation_two_l").Parent(4))[0].contentWindow.$("#U_Boom_CO_Editor_body_left .UD_SYF_S")[3];
  212. var UDWW = _UDW.childNodes[2].childNodes[0].childNodes[0].childNodes[0]
  213. //console.log(UDWW);
  214. // _UDE = ["word空模板", "web空模板", "导航模板", "企业模式", "会议模式", "大纲模式"], //设置数据
  215. // _UDOD = $$("div", { "className": "UD_TempA" }); //创建外部div
  216. // var _UDTD = $$("div", { "className": "UD_TempAC" }, _UDOD); //主体区域
  217. // for (i = 0; i < _UDE.length; i++) {
  218. // $$("div", { "className": "UD_TempACL", title: _UDE[i], "innerHTML": _UDE[i], "onclick": [[U.D.Office.GSTemp, [_UDOD, _UDW, i]]] }, _UDTD);
  219. // }
  220. var UDGD = $$("div", {});
  221. var UDGD_xz = $$("div", { "className": "UDGD_xz", "innerHTML": "下载", "onclick": [[U.Dk.RE.WPXZWJZJO, [UDWW["id"], "file"]]] }, UDGD);
  222. var UDGD_yj = $$("div", { "className": "UDGD_xz", "innerHTML": "意见反馈" }, UDGD);
  223. U.UI.Form({//创建更多窗体
  224. draw: false,
  225. max: false,
  226. min: false,
  227. isTop: true,
  228. id: "UD_Temp",
  229. style: {
  230. width: "350px"
  231. },
  232. content: UDGD,
  233. title: "更多",
  234. hst: {}
  235. }); //创建窗体
  236. }
  237. U.Word.Tools.XTemp = function (UIE) {
  238. var i, //循环初始化
  239. UDTD, //设置变量
  240. UDW = U.D.Office.WI(); //设置windows操作层 获取方法类
  241. //模板类型,包含导航模板,会议模板,目录模式。
  242. var UTF = ["US_O_Navigation", "US_O_Meeting", "US_O_Outline", "US_O_Novel"][UIE]; //类型
  243. if (UTF) { //是否存在
  244. (UDW.U.Word || UDW.U.Excel)["GetTemp"](UTF); //获取office模板
  245. } else {
  246. U.Alert("此模板暂不开放");
  247. } //不存在提示
  248. var UDOD = $("#UD_SYQXR")[0];
  249. // if (!UDOD.innerText.length || UDOD.innerText == $$("div", { "innerHTML": "&#8203;" }).innerText) {
  250. // U.Word.XTemp(UTF);
  251. // }
  252. // else {
  253. // top.U.UI.Confirm("是否覆盖内容", [U.Word.Tools.XTemp, [UTF]]);
  254. // }
  255. }
  256. /**
  257. * word模式切换,只切换样式,U.D.Office.XTemp是加载模板
  258. *
  259. * @param {element} 单击模式时选择的html元素。
  260. *
  261. */
  262. U.Word.Tools.ModeSwitch = function (el) {
  263. // var i;
  264. // var _UDCD = $(el).parentg().Child();
  265. // //修改切换
  266. // for (i = 0; i < _UDCD.length; i++) {
  267. // if (_UDCD[i] != el) {
  268. // _UDCD[i].className = "";
  269. // }
  270. // }
  271. // 目录模式 显示目录功能
  272. // if (el.textContent.trim() == "目录模式") {
  273. // $(".U_Boom_CO_Editor_head_features #U_Boom_Catalog", $(el).Parent(4)).css("display", "block");
  274. // } else {
  275. // $(".U_Boom_CO_Editor_head_features #U_Boom_Catalog", $(el).Parent(4)).css("display", "none");
  276. // }
  277. // el.className = "U_Boom_CO_Editor_head_navigation_color_789CD5";
  278. $(".U_Boom_CO_Editor_head_features #U_Boom_Catalog").last()[0].style.display = "block"
  279. }
  280. /**
  281. * 模式展示
  282. *
  283. * @param {int} 切换的
  284. */
  285. /**
  286. * 模式展示
  287. *
  288. * @param {int} 切换的
  289. */
  290. U.Word.Tools.IploadImg = function () {
  291. U.UP.uploading([$("#files")[0]],
  292. function (r) {
  293. U.Alert("上传成功");
  294. }, [], "http://disk.1473.cn/USupfile.ashx?iframename=UseStudioEditor");
  295. }
  296. /**
  297. * 点击关闭编辑区域时 视图窗体&&更多窗体&&纸张大小窗体 关闭
  298. *
  299. * @param {int} 切换的
  300. */
  301. U.Word.Tools.ViewDisplayc = function () {
  302. for (var a = 0; a < $(".UD_SYF_SS").length; a++) {
  303. if (a >= 3) {
  304. $(".UD_SYF_SS")[a].parentNode.parentNode.style.display = "none";
  305. $("#ViewDisplaya").hide();
  306. $("#UD_Temp").hide();
  307. $("#U_COF").hide();
  308. $("#Bjls").hide();
  309. $("#UD_Temp_CK").hide();
  310. $("#Bjlsall").hide();
  311. $("#U_Boom_CO_Popup_18").hide();
  312. }
  313. }
  314. }
  315. /**
  316. *
  317. * 新建文档
  318. *
  319. * @param
  320. */
  321. U.Word.Tools.Newcreate = function () {
  322. var U_Boom_directory_box = $$("div", { "class": "U_Boom_directory_box" });
  323. //var U_Boom_directory = $$("div", { "class": "U_Boom_directory", "innerHTML": "互联办公", "onclick": "U.Word.Tools.ModeSwitch(this, 1); U.Word.Tools.XTemp(1);" }, U_Boom_directory_box);
  324. var hlbg = $$("div", { "class": "U_Boom_directory", "innerHTML": "互联办公", "onclick": "U.Word.Tools.NewWindow();" }, U_Boom_directory_box);
  325. $$("img", { "src": "../../../img/U_Boom_HO_com.png" }, hlbg);
  326. var qytx = $$("div", { "class": "U_Boom_directory", "innerHTML": "企业体系", "onclick": "U.Word.Tools.NewWindow(0);" }, U_Boom_directory_box);
  327. $$("img", { "src": "../../../img/U_Boom_HO_qy.png" }, qytx);
  328. var hyl = $$("div", { "class": "U_Boom_directory", "innerHTML": "会议录", "onclick": "U.Word.Tools.NewWindow(1)" }, U_Boom_directory_box);
  329. $$("img", { "src": "../../../img/U_Boom_HO_Meeting.png" }, hyl);
  330. var mlms = $$("div", { "class": "U_Boom_directory", "innerHTML": "目录模式", "onclick": "U.Word.Tools.NewWindow(2);U.Word.Tools.ModeSwitch(this, 4);" }, U_Boom_directory_box);
  331. $$("img", { "src": "../../../img/U_Boom_HO_xixi.png" }, mlms);
  332. U.UI.From({ id: "Newcreate",
  333. style: { "width": "550px", "height": "240px" },
  334. content: U_Boom_directory_box,
  335. title: "新建文档",
  336. hst: {},
  337. bst: {},
  338. max: {},
  339. SO: false
  340. });
  341. for (x in $(".U_Boom_directory")) {
  342. $(".U_Boom_directory")[x].onmouseover = function () {
  343. switch (this.innerText) {
  344. case '互联办公':
  345. this.childNodes[1].src = '../../../img/U_Boom_HO_hcom.png';
  346. break;
  347. case '企业体系':
  348. this.childNodes[1].src = '../../../img/U_Boom_HO_hqy.png';
  349. break;
  350. case '会议录':
  351. this.childNodes[1].src = '../../../img/U_Boom_HO_hMeeting.png';
  352. break;
  353. case '目录模式':
  354. this.childNodes[1].src = '../../../img/U_Boom_HO_hxixi.png';
  355. break;
  356. }
  357. }
  358. $(".U_Boom_directory")[x].onmouseout = function () {
  359. switch (this.innerText) {
  360. case '互联办公':
  361. this.childNodes[1].src = '../../../img/U_Boom_HO_com.png';
  362. break;
  363. case '企业体系':
  364. this.childNodes[1].src = '../../../img/U_Boom_HO_qy.png';
  365. break;
  366. case '会议录':
  367. this.childNodes[1].src = '../../../img/U_Boom_HO_Meeting.png';
  368. break;
  369. case '目录模式':
  370. this.childNodes[1].src = '../../../img/U_Boom_HO_xixi.png';
  371. break;
  372. }
  373. }
  374. }
  375. }
  376. /**
  377. * 新建文件
  378. *
  379. * @param i模板类型
  380. */
  381. U.Word.Tools.NewWindow = function (i) {
  382. //新建窗口
  383. top.U.D.DT.YYDK("Word", null, U.M.apply(null, [[U.Word.Tools.model, [i]]]));
  384. // [top.US.userInfo, null, U.M.apply(null, [[U.Word.Tools.model, [i]]])]
  385. }
  386. /**
  387. * 回調模板
  388. *
  389. * @param
  390. */
  391. U.Word.Tools.model = function (i) {
  392. //如果不需要加载模板 就弹一个空的窗口
  393. if (i == null) {
  394. return;
  395. }
  396. U.Word.Tools.XTemp(i);
  397. }
  398. U.Word.Tools.DisplayInsertUser = function () {
  399. var UDVD = $(".U_Boom_CO_Editor_head_navigation_two_l");
  400. $("iframe", UDVD.Parent(4))[0].contentWindow.$("#U_Boom_CO_Editor_body_left .UD_SYF_S .UD_SYF_SC .U_Boom_CO_Editor_body_left_invite_user_a")[0].click()
  401. //var UDWD = $("iframe", UDVD.Parent(4))[0].contentWindow.$("#U_Boom_CO_Editor_body_left .UD_SYF_S"); //获取功能区域
  402. }