Nav.js 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  1. //查看指定文件,,判断是否保存或者覆盖,包括创建邀请协作人员,创建编辑历史,创建生成链接.创建热门模板。加载当前word文档的内容。创建光标,监控键盘输入等。这里是iframe中的word起始点。
  2. //监控输入输出,
  3. //添加成员,共同编辑。
  4. Namespace.register("U.MD.O.W.T.N");
  5. U.MD.O.W.T.N = {
  6. navInfo: [], //文件信息
  7. nowNavId: "", //当前操作的导航页面ID
  8. navcontent: {}
  9. };
  10. /**
  11. * 获取当前展示的页面的内容
  12. * @param navinfo {object} 导航信息
  13. *
  14. */
  15. U.MD.O.W.T.N.form = function (navinfo) {
  16. //简易版导航
  17. U.MD.O.W.T.N.Easy(navinfo);
  18. //判断导航窗体是否创建
  19. //if (false && !$('#U_MD_O_W_N')[0]) {
  20. if (!$('#U_MD_O_W_N')[0]) {
  21. //窗体创建的父级窗体
  22. var _coopwindow = $("#U_MD_O_R_Parent")[0];
  23. //内容区域盒子
  24. var _box = $$('div', { id: "U_MD_O_W_N" });
  25. //logo
  26. var _logo = $$('div', { "className": "U_MD_O_W_N_Logo", style: { "user-select": "none"} }, _box);
  27. var _logoImg = $$('img', { "onerror": U.MD.C.imgError, "src": "http://www.1473.cn/img/Logo_.png", "className": "U_MD_O_W_N_LogoImg", 'id': 'U_MD_O_W_N_LOGO' }, _logo);
  28. //存放本地上传、云盘上传两个按钮的div
  29. var _uploadbutton = $$('div', { "className": 'U_MD_O_W_N_uploadbutton', style: { "user-select": "none"} }, _box);
  30. //input file按钮(隐藏)
  31. var _localupload = $$('input', { type: "file", "className": "U_MD_O_W_N_localupload", innerHTML: "本地上传", 'id': 'U_MD_O_W_N_LocalUpload', 'onchange': function () { U.MD.O.W.T.N.changeLogo($('#U_MD_O_W_N_LocalUpload')[0], $('#U_MD_O_W_N_LOGO')[0]) } }, _uploadbutton);
  32. //本地上传按钮,调用了input file(隐藏)的点击事件
  33. var _localupload2 = $$('button', { "className": 'U_MD_O_W_N_localupload2', innerHTML: "本地上传", 'id': 'pic', 'onclick': function () { $('#U_MD_O_W_N_LocalUpload')[0].click(); } }, _uploadbutton);
  34. //云盘上传按钮
  35. var _cdupload = $$('button', { "className": "U_MD_O_W_N_CDupload", innerHTML: "云盘上传" }, _uploadbutton);
  36. //导航区域
  37. var _nav = $$('div', { "className": 'U_MD_O_W_N_NavBox', innerHTML: "", style: { "user-select": "none"} }, _box);
  38. //底部区域
  39. var _bottom = $$('div', { "className": 'U_MD_O_W_N_Bottom', style: { "user-select": "none"} }, _box);
  40. //新建页面按钮
  41. var _newpage = $$('button', { "className": 'U_MD_O_W_N_Button', innerHTML: "新建页面", 'onclick': function () { U.MD.O.W.T.N.addNewNav(navinfo.nav); } }, _bottom);
  42. //预览按钮
  43. var _newpage = $$('button', { "className": 'U_MD_O_W_N_Button', innerHTML: "预览" }, _bottom);
  44. //窗体
  45. var _form = new U.UF.UI.form("导航管理", _box, { style: { "display": "none", border: "none", position: "absolute", width: "300px", height: "700px", top: "60px", left: "15px", "box-shadow": "3px 3px 10px #888888"} }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff", "user-select": "none"} }, null, null, _coopwindow);
  46. _form.form.style.display = "none";
  47. }
  48. // U.MD.O.W.T.N.getPageContent();
  49. //打印导航
  50. U.MD.O.W.T.N.printNav(navinfo);
  51. }
  52. /**
  53. * 打印导航
  54. * @param navinfo {object} 导航信息
  55. *
  56. */
  57. U.MD.O.W.T.N.printNav = function (navinfo) {
  58. U.MD.O.W.T.N.navInfo = navinfo; //记录导航信息
  59. U.MD.O.W.T.N.nowNavId = navinfo.nav[0].pageId; //设置默认页面展示页面ID
  60. var _nav = $('.U_MD_O_W_N_NavBox')[0]; //获取导航位置
  61. //打印处理
  62. U.MD.O.W.T.N.createFirstTree(navinfo.nav, _nav);
  63. //获取页面内容
  64. U.MD.O.W.T.N.getPageContent();
  65. }
  66. /**
  67. * 获取当前展示的页面的内容
  68. *
  69. */
  70. U.MD.O.W.T.N.getPageContent = function () {
  71. if (U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId]) {
  72. U.MD.O.W.T.N.getPageContentAsyn({ value: U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId] });
  73. }
  74. else if (U.MD.O.W.permission.web) {
  75. //发送获取内容请求
  76. parent.U.A.Request(US.SCOKET, ["getNavPageContent", U.MD.O.W.fileinfo.UserDirectoryID, U.MD.O.W.T.N.nowNavId], function (r) {
  77. U.MD.O.W.T.N.getPageContentAsyn(r); //异步处理
  78. }, [$('#U_MD_O_W_E_body')[0]]);
  79. }
  80. else {
  81. //发送获取内容请求
  82. parent.U.A.Request(US.CD, [US.DB, "UseStudio_Office", "GetNavPageContent", U.MD.O.W.T.N.nowNavId], function (r) {
  83. U.MD.O.W.T.N.getPageContentAsyn(r);
  84. }, [$('#U_MD_O_W_E_body')[0]]);
  85. }
  86. }
  87. /**
  88. * 获取当前展示的页面的内容异步处理
  89. *
  90. */
  91. U.MD.O.W.T.N.getPageContentAsyn = function (r) {
  92. //内容处理
  93. if (r.value && r.value.UsOffice !== undefined) {
  94. r = r.value.UsOffice;
  95. } else {
  96. r = r.value;
  97. if (U.UF.C.isObject(r)) {
  98. r = r[0] ? r[0].content : "";
  99. }
  100. }
  101. //设置当前展示导航的样式
  102. U.MD.O.W.T.N.setHoverClass();
  103. //设置内容属性
  104. U.MD.O.W.fileinfo.UsOffice = (r || "").unEscapeQuotes(); //word内容
  105. U.MD.O.W.E.initEditor(U.MD.O.W.permission.web); //加载编辑器和内容
  106. //设置切换页面全局状态为false 表示切换结束
  107. U.MD.O.W.T.N.switching = false;
  108. //清楚loading
  109. U.UF.DL.uploading($('#U_MD_O_W_E_body')[0]);
  110. }
  111. /**
  112. * 设置当前展示导航的样式
  113. *
  114. */
  115. U.MD.O.W.T.N.setHoverClass = function () {
  116. //去除已中样式
  117. $('.U_MD_O_H_Nav_Span').removeClass('U_MD_O_H_Nav_Span');
  118. //设置新的导航选中
  119. $('#Word_Nav_' + U.MD.O.W.T.N.nowNavId).addClass('U_MD_O_H_Nav_Span');
  120. $('.U_MD_O_W_T_N_easyDeleteBtn_show').removeClass('U_MD_O_W_T_N_easyDeleteBtn_show');
  121. $('.U_MD_O_W_T_N_easyDeleteBtn_show').removeClass('U_MD_O_W_T_N_easyDeleteBtn_show');
  122. $($('#Word_Nav_' + U.MD.O.W.T.N.nowNavId).next()).addClass('U_MD_O_W_T_N_easyDeleteBtn_show');
  123. }
  124. /**
  125. * 页面导航
  126. * @param callback {function} 回调函数
  127. *
  128. */
  129. U.MD.O.W.T.N.saveNav = function (callback, param) {
  130. //判断用户是否登录,只有登录用户才能保存信息
  131. if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; })) {
  132. var _isftp,
  133. _isgroupuser,
  134. _uid = U.MD.O.W.userInfo.userid,
  135. _el = $("#U_MD_O_H_wordEditor")[0], //word编辑区域
  136. _fileinfo = U.MD.O.W.fileinfo, //文件信息
  137. _name = top.$('#UD_Word' + _fileinfo.UserDirectoryID + ' .U_MD_O_H_head_navigation_Title')[0], //文件名
  138. _fileid = _fileinfo.UserDirectoryID, //文件ID
  139. _html = _el.innerHTML, //内容
  140. _data = null;
  141. //判断文档是否是已经保存到数据库的文档
  142. if (_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
  143. //保存到数据库
  144. top.U.A.Request(US.DISK, ["SaveFileContent", _uid, _fileid, JSON.stringify(U.MD.O.W.T.N.navInfo), _name.value, "un"], function (r) {
  145. U.UF.C.isFunction(callback) && callback.apply(this, param);
  146. }, (['', _el])); //保存到数据库
  147. }
  148. //如果文件没有保存,那么直接新建文件
  149. else {
  150. var _newfileid = Guid.newGuid();
  151. //调用word新建文档的处理
  152. top.U.MD.DK.VW.chosenSaveFile('un', _newfileid, _name.value, function (fileinfo) {
  153. U.MD.O.W.fileinfo = fileinfo //文档信息
  154. top.$('#UD_Word' + _fileid)[0].id = 'UD_Word' + _newfileid;
  155. _name.value = fileinfo.UserDirectoryName;
  156. _isgroup = U.Json.select(US.friend.group, {
  157. "GroupManageID": fileinfo.GroupID
  158. })[0];
  159. if (!U.MD.O.W.permission.edit) {
  160. U.MD.O.W.T.N.saveAllPage(function () {
  161. U.MD.O.W.T.N.saveNav.asyn(_isgroup, fileinfo, _el)
  162. }, 0, _isgroup, _html);
  163. } else {
  164. U.MD.O.W.T.N.saveNav.asyn(_isgroup, fileinfo, _el, _html);
  165. }
  166. });
  167. }
  168. }
  169. }
  170. U.MD.O.W.T.N.saveNav.asyn = function (isgroup, fileinfo, el, html) {
  171. if (isgroup) {
  172. U.A.Request(US.SCOKET, ["newNavSave", fileinfo.UserDirectoryID, JSON.stringify(U.MD.O.W.T.N.navInfo), fileinfo.UserDirectoryName, html ? U.MD.O.W.T.N.nowNavId : "", html || "", US.userInfo.userid, US.pageId], function (r) {
  173. //top.$('#UD_Word' + newfileid + ' .U_MD_O_H_head_navigation_Title')[0].value = fileinfo.UserDirectoryName;
  174. U.MD.O.W.fileinfo.UsOffice = el.innerHTML;
  175. $('#U_MD_O_H_wordEditor')[0].editor.operaNotice = U.MD.O.W.E.operationNotice;
  176. U.MD.O.W.permission.edit = true;
  177. U.MD.O.W.permission.web = true;
  178. U.Alert("保存成功");
  179. });
  180. } else {
  181. top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.userid, fileinfo.UserDirectoryID, JSON.stringify(U.MD.O.W.T.N.navInfo), fileinfo.UserDirectoryName, "un"], function (r) {
  182. U.MD.O.W.T.N.savePage(function () {
  183. U.MD.O.W.permission.edit = true;
  184. }, true);
  185. }); //保存到数据库
  186. }
  187. }
  188. U.MD.O.W.T.N.saveAllPage = function (callback, i, group, html) {
  189. var _nowid, _nav = U.MD.O.W.T.N.navInfo.nav;
  190. _nowid = Guid.newGuid();
  191. if (_nav[i].pageId == U.MD.O.W.T.N.nowNavId) {
  192. _content = html;
  193. } else {
  194. _content = U.MD.O.W.T.N.navcontent[_nav[i].pageId] || "";
  195. }
  196. if (group) {
  197. top.U.A.Request(US.SCOKET, ["copyPageContent", U.MD.O.W.fileinfo.UserDirectoryID, _nowid, _content.escapeQuotes(), _nav[i].pageId], U.MD.O.W.T.N.saveAllPage.asyn, [null, i, group, _nav, _nowid, callback]); //保存到数据库
  198. } else {
  199. top.U.A.Request(US.CD, [US.DB, "UseStudio_Office", "CopyPageContent", _nowid, (_content || U.MD.O.W.T.N.navcontent[_nav[i].pageId] || "").escapeQuotes(), _nav[i].pageId], U.MD.O.W.T.N.saveAllPage.asyn, [null, i, group, _nav, _nowid, callback]); //保存到数据库
  200. }
  201. }
  202. U.MD.O.W.T.N.saveAllPage.asyn = function (r) {
  203. if (r.value) {
  204. var i = r.context[1],
  205. _group = r.context[2],
  206. _nav = r.context[3],
  207. _nowid = r.context[4],
  208. _callback = r.context[5];
  209. _nav[i].pageId == U.MD.O.W.T.N.nowNavId && (U.MD.O.W.T.N.nowNavId = _nowid);
  210. $("#Word_Nav_" + _nav[i].pageId)[0].onclick = U.UF.C.closure(U.MD.O.W.T.N.switchPage, [_nowid]);
  211. $("#Word_Nav_" + _nav[i].pageId).attr({ pid: _nowid, id: "#Word_Nav_" + _nowid });
  212. _nav[i].pageId = _nowid;
  213. if (_nav.length == i + 1) {
  214. _callback();
  215. } else {
  216. U.MD.O.W.T.N.saveAllPage(_callback, ++i, _group);
  217. }
  218. }
  219. }
  220. /**
  221. * 新建建站文件
  222. * @param callback {function} 回调函数
  223. * @param alert {boole} 是否弹出弹出提示
  224. *
  225. */
  226. U.MD.O.W.T.N.savePage = function (callback, alert) {
  227. U.UF.DL.loading($('#U_MD_O_W_E_body')[0]);
  228. var _html = $("#U_MD_O_H_wordEditor")[0].innerHTML;
  229. top.U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SaveNavPageContent", U.MD.O.W.T.N.nowNavId, _html.escapeQuotes()], function (r) {
  230. U.MD.O.W.fileinfo.UsOffice = _html;
  231. alert && U.Alert('保存成功');
  232. U.UF.C.isFunction(callback) && callback();
  233. U.UF.DL.uploading($('#U_MD_O_W_E_body')[0]);
  234. }); //保存到数据库
  235. }
  236. /**
  237. * 修改logo 设置logo背景图
  238. * @param fileinput {object} 上传文本框
  239. * @param logoel {object} logo图片
  240. *
  241. */
  242. U.MD.O.W.T.N.changeLogo = function (fileinput, logoel) {
  243. if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; })) {
  244. U.UF.UP.HTML.upload(
  245. [fileinput],
  246. 'http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=' + US.userInfo.userid,
  247. function (r) {
  248. //上传之后的处理 r.value[0]上传之后的图片服务器名字 全路径 http://fs.1473.cn/ + r.value[0]
  249. U.MD.O.W.T.N.navInfo.logo = r.value[0];
  250. //logoel.style.backgroundImage = "url('http://fs.1473.cn/" + U.MD.O.W.T.N.navInfo.logo + "')";
  251. logoel.src = "http://fs.1473.cn/" + U.MD.O.W.T.N.navInfo.logo + "";
  252. }
  253. );
  254. }
  255. }
  256. /**
  257. * 切换页面
  258. * @param nav {object} 导航目录信息
  259. *
  260. */
  261. U.MD.O.W.T.N.switching = false; //设置记录切换中属性
  262. U.MD.O.W.T.N.switchPage = function (pageid) {
  263. if (this.contentEditable != "true") {
  264. var _fileinfo = U.MD.O.W.fileinfo; //文件信息
  265. if (!U.MD.O.W.T.N.switching) { // && _fileinfo.UserId && _fileinfo.UserallDirectoryName
  266. U.MD.O.W.T.N.switching = true;
  267. if (U.MD.O.W.permission.edit) {
  268. //先执行保存
  269. U.MD.O.W.T.N.savePage(function () {
  270. //修改记录的当前操作的导航页面ID
  271. U.MD.O.W.T.N.nowNavId = pageid;
  272. //执行切换
  273. U.MD.O.W.T.N.getPageContent();
  274. });
  275. } else {
  276. U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId] = $("#U_MD_O_H_wordEditor")[0].innerHTML;
  277. //修改记录的当前操作的导航页面ID
  278. U.MD.O.W.T.N.nowNavId = pageid;
  279. //执行切换
  280. U.MD.O.W.T.N.getPageContent();
  281. }
  282. }
  283. }
  284. }
  285. /**
  286. * 创建导航信息
  287. * @param name {string} 导航名称
  288. *
  289. */
  290. U.MD.O.W.T.N.navData = function (name) {
  291. return {
  292. pageId: Guid.newGuid(),
  293. name: name || "新的页面"
  294. };
  295. }
  296. /**
  297. * 根据NavId查找对应的导航信息
  298. */
  299. U.MD.O.W.T.N.selectByNavId = function (nowinfo, navid) {
  300. var i = 0;
  301. for (i = 0; i < nowinfo.length; i++) {
  302. object = nowinfo[i];
  303. if (object.pageId == navid) {
  304. return object;
  305. } else if (object.child) {
  306. return us.selectNav(object.child, navid);
  307. }
  308. }
  309. }
  310. /**
  311. * 简易版导航创建
  312. *
  313. */
  314. U.MD.O.W.T.N.Easy = function (navinfo) {
  315. $('.U_MD_O_H_Nav')[0].style.display = "block"; //显示导航
  316. U.MD.O.W.T.N.navInfo = navinfo; //记录导航信息
  317. U.MD.O.W.T.N.nowNavId = navinfo.nav[0].pageId; //设置默认页面展示页面ID
  318. var i, _navbox = $('.U_MD_O_H_Nav_Box')[0]; //导航区域
  319. _navbox.innerHTML = "";
  320. for (i = 0; i < navinfo.nav.length; i++) {
  321. if (i == 4) {
  322. U.MD.O.W.T.N.Easy.createMore();
  323. }
  324. U.MD.O.W.T.N.Easy.Print(navinfo.nav[i], navinfo.nav);
  325. }
  326. }
  327. /**
  328. * 打印导航
  329. * @param nav {object} 导航目录信息
  330. *
  331. */
  332. U.MD.O.W.T.N.Easy.Print = function (nav, data, index, isnew) {
  333. var _navbox = $('.U_MD_O_H_Nav_Box'); //导航区域
  334. var _div = $$('div', {}); //创建盒子
  335. var _beforeele = null;
  336. if (index) {
  337. _beforeele = _navbox.Child()[index + 1];
  338. }
  339. $(_div).appendTo(_navbox[0], 0, _beforeele); //添加元素
  340. //内容区域
  341. var _span = $$('span', { id: "Word_Nav_" + nav.pageId, innerHTML: nav.name, pid: nav.pageId, onclick: U.UF.C.closure(U.MD.O.W.T.N.switchPage, [nav.pageId]) }, _div);
  342. //如果是新增导航的处理
  343. if (isnew) {
  344. _span.onblur = function () { U.MD.O.W.T.N.addNav(this, nav, data, top); };
  345. }
  346. else {
  347. _span.onblur = function () { U.MD.O.W.T.N.updateNav(this, nav); }
  348. }
  349. _span.ondblclick = U.MD.O.W.T.N.Easy.ondblclick;
  350. _span.onkeydown = U.UF.C.closure(U.MD.O.W.T.N.Easy.enter, [_span]);
  351. $$("div", { 'className': 'U_MD_O_W_T_N_easyDeleteBtn', onclick: function () { U.UF.UI.Confirm('删除当前页面后内容将不可恢复,确认删除?', function () { U.MD.O.W.T.N.deleteNav(nav, data, true); }); } }, _div); //删除按钮
  352. return _span;
  353. }
  354. /**
  355. * 双击事件
  356. *
  357. */
  358. U.MD.O.W.T.N.Easy.ondblclick = function () {
  359. // if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; })) {
  360. this.setAttribute("contenteditable", "true"); //设置可编辑
  361. this.focus(); //聚焦处理
  362. U.UF.E.getRangeAt().selectNodeContents(this); //全选处理
  363. // }
  364. }
  365. /**
  366. * 回车修改
  367. * @param nav {object} 导航目录信息
  368. *
  369. */
  370. U.MD.O.W.T.N.Easy.enter = function (navel, fun) {
  371. //获取event对象
  372. var e = U.UF.EV.getEventSource();
  373. //获取按下键值
  374. var _code = e.keyCode;
  375. //判断是否为回车键
  376. if (_code == 13) {
  377. if (navel.innerText !== "") { //判断文本内容是否为空
  378. navel.setAttribute("contenteditable", "false"); //设置导航不可编辑
  379. //执行修改导航名称函数
  380. // U.MD.O.W.T.N.updateNav(this, nav)
  381. // this.onblur();
  382. U.UF.EV.stopDefault();
  383. } else {
  384. navel.innerText = "标题不能为空(双击编辑)" //更改为空的内容
  385. U.UF.EV.stopDefault(); //阻止冒泡
  386. }
  387. U.UF.EV.stopBubble(); //阻止默认事件
  388. }
  389. }
  390. /**
  391. * 添加导航点击事件处理
  392. *
  393. */
  394. U.MD.O.W.T.N.Easy.add = function () {
  395. var _fileinfo = U.MD.O.W.fileinfo; //文件信息
  396. //多导航处理
  397. if (U.MD.O.W.T.N.navInfo.nav.length == 4) {
  398. //提示操作限制
  399. //return U.Alert('目前最多只支持4个页面。。。');
  400. U.MD.O.W.T.N.Easy.createMore();
  401. }
  402. if (U.MD.O.W.T.N.navInfo.nav.length >= 4) {
  403. $('.U_MD_O_H_Nav_Box_More_Hide').removeClass('U_MD_O_H_Nav_Box_More_Hide');
  404. }
  405. //判断文档是否是已经保存到数据库的文档
  406. // if (_fileinfo.UserDirectoryID && _fileinfo.UserId && _fileinfo.UserallDirectoryName) { //如果是已经保存到数据库的文档,那么直接保存内容
  407. if (!U.MD.O.W.permission.edit) {
  408. U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId] = $("#U_MD_O_H_wordEditor")[0].innerHTML;
  409. U.MD.O.W.T.N.Easy.add.asyn();
  410. } else {
  411. if (U.MD.O.W.permission.web) {
  412. U.MD.O.W.T.N.Easy.add.asyn();
  413. } else {
  414. //执行保存页面内容函数
  415. U.MD.O.W.T.N.savePage(U.MD.O.W.T.N.Easy.add.asyn);
  416. }
  417. }
  418. // } else {
  419. // U.MD.O.W.save();
  420. // }
  421. }
  422. /**
  423. * 添加导航点击事件处理 异步
  424. *
  425. */
  426. U.MD.O.W.T.N.Easy.add.asyn = function () {
  427. //创建新的导航
  428. var _nav = U.MD.O.W.T.N.navData();
  429. //添加到导航信息数组里
  430. U.MD.O.W.T.N.navInfo.nav.push(_nav);
  431. //切换记录当前操作的页面ID
  432. U.MD.O.W.T.N.nowNavId = _nav.pageId;
  433. var _editor = $("#U_MD_O_H_wordEditor")[0]; //编辑器元素
  434. U.MD.O.W.fileinfo.UsOffice = "";
  435. U.MD.O.W.E.initEditor();
  436. // _editor.innerHTML = ""; //清空内容
  437. // U.UF.E.key.addDelLine(_editor); //默认添加第一行
  438. //打印导航
  439. var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav, null, true);
  440. //默认执行导航双击事件 触发修改
  441. _navel.ondblclick();
  442. //设置选中样式
  443. U.MD.O.W.T.N.setHoverClass();
  444. }
  445. U.MD.O.W.T.N.Easy.createMore = function () {
  446. $$('div', { className: "U_Img U_MD_O_H_Nav_More ", onclick: U.MD.O.W.T.N.Easy.showOrHideNav }, $('.U_MD_O_H_Nav_Box')[0]);
  447. $(".U_MD_O_H_Nav_Box").addClass("U_MD_O_H_Nav_Box_More");
  448. $(".U_MD_O_H_Nav_Box").addClass("U_MD_O_H_Nav_Box_More_Hide");
  449. }
  450. U.MD.O.W.T.N.Easy.removeMore = function () {
  451. $('.U_MD_O_H_Nav_More').remove();
  452. $(".U_MD_O_H_Nav_Box").removeClass("U_MD_O_H_Nav_Box_More");
  453. $(".U_MD_O_H_Nav_Box").removeClass("U_MD_O_H_Nav_Box_More_Hide");
  454. }
  455. U.MD.O.W.T.N.Easy.showOrHideNav = function (flag) {
  456. if (flag == true || $('.U_MD_O_H_Nav_Box_More_Hide')[0]) {
  457. $('.U_MD_O_H_Nav_Box_More_Hide').removeClass('U_MD_O_H_Nav_Box_More_Hide');
  458. var _close = function () {
  459. U.MD.O.W.T.N.Easy.showOrHideNav();
  460. $('body').unbind("click", _close);
  461. }
  462. $('body').bind("click", _close);
  463. } else {
  464. $('.U_MD_O_H_Nav_Box_More').addClass('U_MD_O_H_Nav_Box_More_Hide');
  465. }
  466. U.UF.EV.stopBubble();
  467. }
  468. /**
  469. * 添加导航
  470. *
  471. * @param navel {element} 导航标题元素
  472. * @param nav {object} 导航信息对象
  473. * @param data {object} 父级导航信息数组
  474. * @param top {boole} 是否为第一级导航
  475. */
  476. U.MD.O.W.T.N.addNav = function (navel, nav, data, top) {
  477. if (!U.MD.O.W.permission.edit) {
  478. nav.name = navel.innerHTML; //修改记录变量
  479. navel.setAttribute("contenteditable", "false"); //设置导航不可编辑
  480. } else {
  481. if (U.MD.O.W.permission.web) { //协同处理
  482. var _parent, _navinfo = U.MD.O.W.T.N.navInfo.nav;
  483. var _content = $("#U_MD_O_H_wordEditor")[0].innerHTML.escapeQuotes();
  484. nav.name = navel.innerHTML; //修改记录变量
  485. if (top) {
  486. U.MD.O.W.T.N.addNavMessage("", _navinfo.length, nav, _content, function () {
  487. navel.onblur = function () { //覆盖失焦事件
  488. U.MD.O.W.T.N.updateNav(navel, nav); //修改导航处理
  489. }
  490. });
  491. } else {
  492. var _child = data.child; //获取子级
  493. if (_child) { //如果存在子级 则执行删除
  494. _child.every(function (object, index) { //循环找到对应的导航
  495. if (object.pageId == nav.navId) { //如果导航id相等则为对应导航
  496. U.MD.O.W.T.N.addNavMessage(data.pageId, index, nav, _content, function () {
  497. navel.onblur = function () { //覆盖失焦事件
  498. U.MD.O.W.T.N.updateNav(navel, nav); //修改导航处理
  499. }
  500. });
  501. }
  502. });
  503. }
  504. }
  505. } else {
  506. U.MD.O.W.T.N.updateNav(navel, nav); //直接执行修改导航
  507. navel.onblur = function () { //覆盖失焦事件
  508. U.MD.O.W.T.N.updateNav(navel, nav);
  509. }
  510. }
  511. }
  512. }
  513. /**
  514. * 删除导航处理
  515. * nav {object} 当前操作导航信息
  516. * data {object} 父级导航信息
  517. * top {boole} 是否为顶级(第一级)
  518. *
  519. */
  520. U.MD.O.W.T.N.deleteNav = function (nav, data, top) {
  521. if (top && data.length <= 1) { return U.Alert('只剩下一个导航页面啦!'); } //最后一个页面不允许删除
  522. var _child = top ? data : data.child; //获取子级
  523. if (_child) { //如果存在子级 则执行删除
  524. _child.every(function (object, index) { //循环找到对应的导航
  525. if (object.pageId == nav.pageId) { //如果导航id相等则为对应导航
  526. if (U.MD.O.W.permission.web) { //协同处理
  527. U.MD.O.W.T.N.deleteNavMessage(nav.pageId, _child.pageId || "", U.MD.O.W.T.N.deleteNav.asyn, [object, index, US.userInfo.userid, _child]); //信息处理
  528. }
  529. else if (U.MD.O.W.permission.edit) {
  530. // U.MD.O.W.T.N.deleteNav.asyn(object, index, US.userInfo.userid, _child); //异步处理
  531. U.MD.O.W.T.N.saveNav(function () { //直接保存页面
  532. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "DeletePage", nav.pageId], function (r) { //删除页面请求
  533. U.MD.O.W.T.N.deleteNav.asyn(object, index, US.userInfo.userid, _child); //异步处理
  534. });
  535. });
  536. }
  537. else {
  538. U.MD.O.W.T.N.deleteNav.asyn(object, index, US.userInfo.userid, _child); //异步处理
  539. }
  540. return false; //返回false终止循环
  541. }
  542. return true;
  543. });
  544. } else {
  545. U.Alert("删除有误");
  546. }
  547. }
  548. /**
  549. * 删除导航处理
  550. * object {object} 当前操作导航信息
  551. * index {int} 位于父级导航信息的位置
  552. * userid {uuid} 操作用户id
  553. * parent {object} 导航的父级信息
  554. *
  555. */
  556. U.MD.O.W.T.N.deleteNav.asyn = function (object, index, userid, parent) {
  557. if (!object.child) {
  558. //导航删除
  559. $('#U_MD_O_W_T_N_' + object.pageId).remove();
  560. $($('#Word_Nav_' + object.pageId).Parent()).remove();
  561. //执行切换
  562. if (U.MD.O.W.T.N.nowNavId == object.pageId) {
  563. if (userid != US.userInfo.userid) {
  564. var _user = U.Json.select(US.friend.groupusers, { UserId: userid })[0];
  565. U.Alert('该页面已被' + (_user ? _user.UserNickName || _user.UserName : "") + '删除');
  566. }
  567. //执行切换页面
  568. if (parent.length) {
  569. if (parent.length == 5) {
  570. U.MD.O.W.T.N.Easy.removeMore();
  571. }
  572. //删除后存在同级页面
  573. U.MD.O.W.T.N.switchPage(parent[index + 1] ? parent[index + 1].pageId : parent[index - 1].pageId);
  574. } else {
  575. //删除后 不存在同级页面
  576. U.MD.O.W.T.N.switchPage(parent.pageId);
  577. }
  578. }
  579. //数据删除
  580. parent && parent.splice(index, 1);
  581. }
  582. }
  583. /**
  584. * 修改导航名称
  585. * @param navel {Element} 导航元素
  586. * @param nav {object} 导航目录信息
  587. *
  588. */
  589. U.MD.O.W.T.N.updateNav = function (navel, nav) {
  590. navel.setAttribute("contenteditable", "false"); //设置导航不可编辑
  591. if (navel.innerText !== "") { //判断文本内容是否为空
  592. nav.name = navel.innerHTML; //修改记录的name
  593. if (U.MD.O.W.permission.edit) {
  594. if (U.MD.O.W.permission.web) { //协同处理
  595. U.MD.O.W.T.N.updateNavMessage(nav.pageId, nav.name, U.MD.O.W.T.N.updateNav.asyn); //协同更新导航处理
  596. } else {
  597. //执行保存导航函数
  598. U.MD.O.W.T.N.saveNav(U.MD.O.W.T.N.updateNav.asyn);
  599. }
  600. }
  601. } else {
  602. navel.innerText = "标题不能为空(双击编辑)"; //为空时的处理
  603. }
  604. }
  605. /**
  606. * 修改导航名称 异步处理
  607. * @param nav {object} 导航目录信息
  608. *
  609. */
  610. U.MD.O.W.T.N.updateNav.asyn = function (nav) {
  611. //默认聚到到编辑器区
  612. $("#U_MD_O_H_wordEditor")[0].focus();
  613. // var _fileinfo = U.MD.O.W.fileinfo; //文件信息
  614. // var _issave = true;
  615. // if (!_fileinfo.UserId && !_fileinfo.UserallDirectoryName) { //如果是已经保存到数据库的文档,那么直接保存内容
  616. // _issave = false;
  617. // }
  618. //提示修改成功
  619. //U.Alert('修改成功');
  620. // !_issave && U.MD.O.W.T.N.savePage(null, true);
  621. }
  622. /**
  623. *左目录导航
  624. *
  625. */
  626. U.MD.O.W.T.N.createFirstTree = function (data, parent) {//第一个参数是获取返回的数据,第二个是你要显示目录的位置
  627. var _data = data;
  628. if (parent == $('.U_MD_O_W_N_NavBox')[0] && $('.U_MD_O_W_N_NavBox')[0] != null) {
  629. parent.innerHTML = "";
  630. }
  631. for (var i = 0; i < _data.length; i++) { //循环创建目录
  632. $$("div", {
  633. 'className': 'U_MD_O_W_T_N_treeDiv',
  634. 'id': 'U_MD_O_W_T_N_' + _data[i].pageId
  635. },
  636. parent);
  637. var _treeDiv = $('#U_MD_O_W_T_N_' + _data[i].pageId)[0];
  638. if (parent == $('.U_MD_O_W_N_NavBox')[0]) {
  639. _treeDiv.deep = 1;
  640. } else {
  641. _treeDiv.deep = parent.deep + 1;
  642. }
  643. _treeDiv.i = i; //给目录添加属性
  644. _treeDiv.pageId = _data[i].pageId;
  645. _treeDiv.flag = true;
  646. $$('div', {
  647. 'className': 'U_MD_O_W_T_N_treeNav',
  648. 'id': 'U_MD_O_W_T_N_treenav' + _data[i].pageId,
  649. 'style': { 'padding-left': 12 + 20 * (_treeDiv.deep - 1) + 'px' }
  650. },
  651. _treeDiv);
  652. var _treeNav = $('#U_MD_O_W_T_N_treenav' + _data[i].pageId)[0];
  653. $$("span", { //创建span标签插入名字
  654. 'className': 'U_MD_O_W_T_N_treeSpan',
  655. 'innerHTML': _data[i].name,
  656. 'id': 'U_MD_O_W_T_N_span' + _data[i].pageId
  657. },
  658. _treeNav);
  659. $$("div", { //创建div标签添加删除按钮
  660. 'className': 'U_MD_O_W_T_N_deleteDiv',
  661. 'id': 'U_MD_O_W_T_N_delete' + _data[i].pageId
  662. },
  663. _treeNav);
  664. $$("div", {//创建div标签添加添加按钮
  665. 'className': 'U_MD_O_W_T_N_addDiv',
  666. 'id': 'U_MD_O_W_T_N_add' + _data[i].pageId
  667. },
  668. _treeNav);
  669. $$("div", { //创建div标签修改按钮
  670. 'className': 'U_MD_O_W_T_N_updateDiv',
  671. 'id': 'U_MD_O_W_T_N_update' + _data[i].pageId
  672. },
  673. _treeNav);
  674. if (_data[i].child) {
  675. if (_data[i].child.length == 0) {
  676. $('#U_MD_O_W_T_N_span' + _data[i].pageId)[0].style.cssText += "margin-left:20px";
  677. } else {
  678. $$('div', {
  679. 'className': 'U_MD_O_W_T_N_checkDiv',
  680. 'id': 'U_MD_O_W_T_N_checkDiv' + _data[i].pageId
  681. },
  682. _treeNav);
  683. }
  684. } else {
  685. $('#U_MD_O_W_T_N_span' + _data[i].pageId)[0].style.cssText += "margin-left:20px";
  686. }
  687. _treeDiv.onclick = function (e) { //点击目录查看子目录
  688. U.MD.O.W.T.N.checkNav(this, data);
  689. e.stopPropagation();
  690. }
  691. //删除按钮点击事件
  692. $('#U_MD_O_W_T_N_delete' + _data[i].pageId)[0].onclick = function (e) {
  693. var _parent = this.parentNode.parentNode.parentNode; //获取子目录的父级
  694. var _delele = this.parentNode.parentNode; //获取你要删除的目录
  695. //删除按钮点击事件函数,第一个参数是要删除的ele,第二个是数据,第三个是父级ele
  696. U.MD.O.W.T.N.deleteOnClick(_delele, data, _parent);
  697. e.stopPropagation();
  698. }
  699. $('#U_MD_O_W_T_N_add' + _data[i].pageId)[0].onclick = function (e) { //添加按钮点击事件
  700. var _addele = this.parentNode.parentNode; //获取你点击添加的目录
  701. var _treenav = this.parentNode;
  702. if ($('.U_MD_O_W_T_N_addCBox')[0]) { //判断添加选项框是否存在
  703. var _addParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
  704. _addParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]); //判断存在,删除选项框
  705. }
  706. $$("div", { //创建添加选项框
  707. 'className': 'U_MD_O_W_T_N_addCBox'
  708. },
  709. $('body')[0]);
  710. e.preventDefault();
  711. $$("div", { //添加选项
  712. 'className': 'U_MD_O_W_T_N_addCPage',
  713. 'innerHTML': '添加子页面'
  714. },
  715. $('.U_MD_O_W_T_N_addCBox')[0]);
  716. $$("div", {
  717. 'className': 'U_MD_O_W_T_N_addPAbove',
  718. 'innerHTML': '在上方添加页面'
  719. },
  720. $('.U_MD_O_W_T_N_addCBox')[0]);
  721. $$("div", {
  722. 'className': 'U_MD_O_W_T_N_addPBelow',
  723. 'innerHTML': '在下方添加页面'
  724. },
  725. $('.U_MD_O_W_T_N_addCBox')[0]);
  726. //添加子页面点击事件
  727. $(".U_MD_O_W_T_N_addCPage")[0].onclick = function (e) {
  728. U.MD.O.W.T.N.addChildOnClick(_addele, data, _treenav);
  729. }
  730. //在上方添加页面点击事件
  731. $('.U_MD_O_W_T_N_addPAbove')[0].onclick = function (e) {
  732. U.MD.O.W.T.N.addPAboveOnClick(_addele, data, _treenav);
  733. e.stopPropagation();
  734. }
  735. //在下面添加页面点击事件
  736. $('.U_MD_O_W_T_N_addPBelow')[0].onclick = function (e) {
  737. U.MD.O.W.T.N.addPBelowOnClick(_addele, data, _treenav);
  738. e.stopPropagation();
  739. }
  740. document.onclick = function (e) { //显示添加选项框后,点击别的空白地方会关闭选项框
  741. if ($('.U_MD_O_W_T_N_addCBox')[0]) {
  742. var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
  743. _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
  744. }
  745. }
  746. U.UF.C.rightClickMenuLocation($('.U_MD_O_W_T_N_addCBox')[0]);
  747. e.stopPropagation();
  748. }
  749. //修改按钮点击事件
  750. $('#U_MD_O_W_T_N_update' + _data[i].pageId)[0].onclick = function (e) {
  751. var _upele = this.parentNode.parentNode;
  752. U.MD.O.W.T.N.updateOnClick(_upele, data); //修改按钮点击事件函数,第一个参数是你要修改的ele,第二个是数据
  753. if (e) {
  754. e.stopPropagation();
  755. }
  756. }
  757. }
  758. }
  759. /**
  760. * 刷新目录名称
  761. * @param data {object} 目录信息
  762. *
  763. */
  764. U.MD.O.W.T.N.cleanInnerHTML = function (data) { //清除内容
  765. var _span = $('#U_MD_O_W_T_N_span' + data.pageId)[0];
  766. _span.innerHTML = data.name; //重新显示名字
  767. }
  768. /**
  769. * 删除页面点击事件
  770. * ele {element} 修改的元素
  771. * data [array] 数据数组
  772. */
  773. U.MD.O.W.T.N.deleteOnClick = function (ele, data, parent) {
  774. var _delele = ele;
  775. var _parent = parent;
  776. for (var i = 0; i < data.length; i++) { //循环找到你删除的子目录的信息
  777. if (data[i].pageId == _delele.pageId) {
  778. if (data[i].child && data[i].child.length > 0) {
  779. var _deleteId = _delele.pageId;
  780. for (var l = 0; l < data[i].child.length; l++) {
  781. _deleteId += "," + data[i].child[l].pageId;
  782. }
  783. U.UF.UI.confirm($$('div', { style: { padding: "25px 0 " }, innerHTML: "删除这些页面将会删除他们的子页面,是否删除?" }), U.UF.C.closure(function (i) {
  784. data.splice(i, 1); //从数据中删除信息
  785. //执行保存导航函数
  786. U.MD.O.W.T.N.saveNav(function () {
  787. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "DeletePage", _deleteId], function (r) {
  788. _parent.removeChild(_delele); //页面上删除子目录
  789. if ($('#U_MD_O_W_T_N_' + _parent.id + ' .U_MD_O_W_T_N_treeNav').length == 0) {
  790. if (_parent != $('.U_MD_O_W_N_NavBox')[0]) {
  791. $('#U_MD_O_W_T_N_treenav' + _parent.pageId)[0].removeChild($('#U_MD_O_W_T_N_checkDiv' + _parent.pageId)[0]);
  792. $('#U_MD_O_W_T_N_span' + _parent.pageId)[0].style.cssText += "margin-left:20px";
  793. }
  794. }
  795. $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
  796. });
  797. });
  798. }, [i]));
  799. } else {
  800. data.splice(i, 1);
  801. //执行保存导航函数
  802. U.MD.O.W.T.N.saveNav(function () {
  803. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "DeletePage", _delele.pageId], function (r) {
  804. console.log(1);
  805. _parent.removeChild(_delele); //页面上删除子目录
  806. if ($('#U_MD_O_W_T_N_' + _parent.id + ' .U_MD_O_W_T_N_treeNav').length == 0) {
  807. if (_parent != $('.U_MD_O_W_N_NavBox')[0]) {
  808. $('#U_MD_O_W_T_N_treenav' + _parent.pageId)[0].removeChild($('#U_MD_O_W_T_N_checkDiv' + _parent.pageId)[0]);
  809. $('#U_MD_O_W_T_N_span' + _parent.pageId)[0].style.cssText += "margin-left:20px";
  810. }
  811. }
  812. $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
  813. });
  814. });
  815. }
  816. }
  817. }
  818. }
  819. /**
  820. * 修改页面点击事件
  821. * ele {element} 修改的元素
  822. * data [array] 数据数组
  823. */
  824. U.MD.O.W.T.N.updateOnClick = function (ele, data) {
  825. var _upele = ele;
  826. if ($('.U_MD_O_W_T_N_updateInput')[0]) {//如果修改输入框已经存在,则移除输入框
  827. var _inputParent = $('.U_MD_O_W_T_N_updateInput')[0].parentNode;
  828. _inputParent.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
  829. }
  830. $$("input", { //创建输入框
  831. 'className': 'U_MD_O_W_T_N_updateInput',
  832. 'type': 'text',
  833. 'style': {
  834. 'left': 7 + 20 * _upele.deep + 'px'
  835. },
  836. 'value': $('#U_MD_O_W_T_N_span' + _upele.pageId)[0].innerHTML
  837. },
  838. _upele);
  839. //输入框阻止冒泡
  840. $('.U_MD_O_W_T_N_updateInput')[0].onclick = function (e) {
  841. e.stopPropagation();
  842. }
  843. document.onclick = function () { //点击空白处关闭输入框
  844. if ($('.U_MD_O_W_T_N_updateInput')[0]) {
  845. var _upvalue = $('.U_MD_O_W_T_N_updateInput')[0].value;
  846. //判断输入的内容是否为空
  847. if (_upvalue == "" || _upvalue == null) {
  848. return false;
  849. }
  850. _upele.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
  851. for (var i = 0; i < data.length; i++) {
  852. if (data[i].pageId == _upele.pageId) {
  853. data[i].name = _upvalue;
  854. U.MD.O.W.T.N.saveNav(function () {
  855. U.MD.O.W.T.N.cleanInnerHTML(data[i]);
  856. console.log(data);
  857. });
  858. return false;
  859. }
  860. }
  861. if ($('.U_MD_O_W_T_N_updateInput')[0]) {
  862. _upele.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
  863. }
  864. }
  865. }
  866. document.onkeydown = function () { //网页内按下回车触发
  867. if (event.keyCode == 13) { //点击回车修改目录信息
  868. var _upvalue = $('.U_MD_O_W_T_N_updateInput')[0].value;
  869. if (_upvalue == "" || _upvalue == null) {
  870. return false;
  871. }
  872. _upele.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
  873. for (var i = 0; i < data.length; i++) {
  874. if (data[i].pageId == _upele.pageId) {
  875. data[i].name = _upvalue;
  876. U.MD.O.W.T.N.saveNav(function () {
  877. U.MD.O.W.T.N.cleanInnerHTML(data[i]);
  878. console.log(data);
  879. });
  880. return false;
  881. }
  882. }
  883. }
  884. }
  885. }
  886. /**
  887. * 查看页面点击事件
  888. * @param data {object} 目录信息
  889. *
  890. */
  891. U.MD.O.W.T.N.checkNav = function (ele, data) {
  892. var _data = data; //获取返回的数据
  893. var _ele = ele;
  894. //清空其他选中样式,增删改按钮
  895. for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
  896. $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
  897. var _treeNavParent = $('.U_MD_O_W_T_N_treeNav')[i].parentNode;
  898. $('#U_MD_O_W_T_N_update' + _treeNavParent.pageId)[0].style.display = "none";
  899. $('#U_MD_O_W_T_N_add' + _treeNavParent.pageId)[0].style.display = "none";
  900. $('#U_MD_O_W_T_N_delete' + _treeNavParent.pageId)[0].style.display = "none";
  901. }
  902. var _treeNav = $('#U_MD_O_W_T_N_treenav' + _data[_ele.i].pageId)[0];
  903. _treeNav.style.background = "#ccebf8";
  904. //显示增删改按钮
  905. $('#U_MD_O_W_T_N_update' + _data[_ele.i].pageId)[0].style.display = "block";
  906. $('#U_MD_O_W_T_N_add' + _data[_ele.i].pageId)[0].style.display = "block";
  907. $('#U_MD_O_W_T_N_delete' + _data[_ele.i].pageId)[0].style.display = "block";
  908. U.MD.O.W.T.N.switching = false; //设置记录切换中属性
  909. U.MD.O.W.T.N.switchPage(_data[_ele.i].pageId);
  910. if (_data[_ele.i].child && _data[_ele.i].child.length > 0) { //如果目录有子目录则执行
  911. if (_ele.flag) { //根据flag判定子目录是否已经存在
  912. $('#U_MD_O_W_T_N_checkDiv' + _data[_ele.i].pageId)[0].style.cssText += 'background: url(http://www.1473.cn/img/U_MD_O_W_T_N_check.png) center no-repeat;background-size:100%;';
  913. U.MD.O.W.T.N.createFirstTree(data[_ele.i].child, _ele); //显示子目录
  914. _ele.flag = false;
  915. } else {
  916. for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
  917. $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
  918. var _treeNavParent = $('.U_MD_O_W_T_N_treeNav')[i].parentNode;
  919. }
  920. var _treeNav = $('#U_MD_O_W_T_N_treenav' + _data[_ele.i].pageId)[0];
  921. $('#U_MD_O_W_T_N_checkDiv' + _data[_ele.i].pageId)[0].style.cssText += 'background: url(http://www.1473.cn/img/U_MD_O_W_T_N_check2.png) center no-repeat;background-size:100%;';
  922. _treeNav.style.background = "#ccebf8";
  923. if ($('.U_MD_O_W_T_N_addCBox')[0]) {
  924. var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
  925. _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
  926. }
  927. for (var l = 0; l < _data[_ele.i].child.length; l++) {//子目录已经存在,删除子目录
  928. _ele.removeChild($('#U_MD_O_W_T_N_' + _data[_ele.i].child[l].pageId)[0]);
  929. }
  930. // U.MD.O.W.T.N.cleanInnerHTML(this, _data[this.i]);
  931. _ele.flag = true;
  932. }
  933. }
  934. }
  935. /**
  936. * 新建页面点击事件
  937. * @param data {object} 目录信息
  938. *
  939. */
  940. U.MD.O.W.T.N.addNewNav = function (data) { //添加新页面的点击事件
  941. var _data = data; //获取返回的数据
  942. U.MD.O.W.T.N.saveNav(function () {
  943. U.MD.O.W.T.N.savePage(function () {
  944. //创建新的导航
  945. var _nav = U.MD.O.W.T.N.navData('新页面');
  946. //添加到导航信息数组里
  947. U.MD.O.W.T.N.navInfo.nav.push(_nav);
  948. //清空目录
  949. $('.U_MD_O_W_N_NavBox')[0].innerHTML = "";
  950. //重新从数据里获取最新的信息
  951. U.MD.O.W.T.N.createFirstTree(data, $('.U_MD_O_W_N_NavBox')[0]);
  952. //移除目录选中样式
  953. for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
  954. $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
  955. }
  956. var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
  957. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
  958. $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
  959. $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
  960. //选中新添加的目录
  961. _treeNav.style.background = "#ccebf8";
  962. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
  963. //打印导航
  964. var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
  965. //默认执行导航双击事件 触发修改
  966. _navel.ondblclick();
  967. //切换记录当前操作的页面ID
  968. U.MD.O.W.T.N.nowNavId = _nav.pageId;
  969. //情况页面内容
  970. $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
  971. //设置选中样式
  972. U.MD.O.W.T.N.setHoverClass();
  973. }, true);
  974. });
  975. if ($('.U_MD_O_W_T_N_addCBox')[0]) {
  976. var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
  977. _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
  978. }
  979. }
  980. /**
  981. * 添加子页面点击事件
  982. * ele {element} 获取你点击的元素
  983. * data {array} 数据信息
  984. *parent {element} 获取你点击的父级
  985. */
  986. U.MD.O.W.T.N.addChildOnClick = function (ele, data, parent) {
  987. var _addele = ele;
  988. var _treenav = parent;
  989. if (_addele.flag == false) {
  990. if ($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]) {
  991. _treenav.removeChild($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]);
  992. }
  993. for (var l = 0; l < data[_addele.i].child.length; l++) {//子目录已经存在,删除子目录
  994. _addele.removeChild($('#U_MD_O_W_T_N_' + data[_addele.i].child[l].pageId)[0]);
  995. }
  996. }
  997. U.MD.O.W.T.N.saveNav(function () {
  998. U.MD.O.W.T.N.savePage(function () {
  999. //创建新的导航
  1000. var _nav = U.MD.O.W.T.N.navData('新页面');
  1001. for (var i = 0; i < data.length; i++) { //循环找到你要添加子目录的目录
  1002. if (data[i].pageId == _addele.pageId) {
  1003. if ($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]) {//如果查看标签已经存在,则删除标签
  1004. var _checkParent = $('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0].parentNode;
  1005. _checkParent.removeChild($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]);
  1006. }
  1007. $$('div', {//创建查看标签
  1008. 'className': 'U_MD_O_W_T_N_checkDiv',
  1009. 'style': {
  1010. 'background': 'url(../../../img/U_MD_O_W_T_N_check.png) center no-repeat;',
  1011. 'background-size': '100%;'
  1012. },
  1013. 'id': 'U_MD_O_W_T_N_checkDiv' + _addele.pageId
  1014. },
  1015. _treenav);
  1016. _addele.flag = false;
  1017. if (data[i].child) { //判断是否已经有child,有则直接插入,没有则创建数组再插入
  1018. //添加到导航信息数组里
  1019. data[i].child.push(_nav);
  1020. U.MD.O.W.T.N.createFirstTree(data[i].child, _addele); //重新从数据里获取最新的信息
  1021. } else {
  1022. data[i].child = new Array();
  1023. //添加到导航信息数组里
  1024. data[i].child.push(_nav);
  1025. U.MD.O.W.T.N.createFirstTree(data[i].child, _addele); //重新从数据里获取最新的信息
  1026. }
  1027. }
  1028. }
  1029. for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
  1030. $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
  1031. var _treeNavParent = $('.U_MD_O_W_T_N_treeNav')[i].parentNode;
  1032. // 隐藏增删改按钮
  1033. $('#U_MD_O_W_T_N_update' + _treeNavParent.pageId)[0].style.display = "none";
  1034. $('#U_MD_O_W_T_N_add' + _treeNavParent.pageId)[0].style.display = "none";
  1035. $('#U_MD_O_W_T_N_delete' + _treeNavParent.pageId)[0].style.display = "none";
  1036. }
  1037. $('#U_MD_O_W_T_N_span' + _addele.pageId)[0].style.cssText += "margin-left:5px";
  1038. var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
  1039. _treeNav.style.background = "#ccebf8";
  1040. //执行修改按钮点击事件
  1041. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
  1042. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
  1043. $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
  1044. $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
  1045. //打印导航
  1046. var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
  1047. //默认执行导航双击事件 触发修改
  1048. _navel.ondblclick();
  1049. //切换记录当前操作的页面ID
  1050. U.MD.O.W.T.N.nowNavId = _nav.pageId;
  1051. //情况页面内容
  1052. $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
  1053. //设置选中样式
  1054. U.MD.O.W.T.N.setHoverClass();
  1055. }, true);
  1056. });
  1057. //如果添加选项窗口还存在就移除窗口
  1058. if ($('.U_MD_O_W_T_N_addCBox')[0]) {
  1059. var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
  1060. _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
  1061. }
  1062. }
  1063. /**
  1064. * 在下方添加页面点击事件
  1065. * ele {element} 获取你点击的元素
  1066. * data {array} 数据信息
  1067. *parent {element} 获取你点击的父级
  1068. */
  1069. U.MD.O.W.T.N.addPBelowOnClick = function (ele, data, parent) {
  1070. var _addele = ele;
  1071. var _treenav = parent;
  1072. U.MD.O.W.T.N.saveNav(function () {
  1073. U.MD.O.W.T.N.savePage(function () {
  1074. //创建新的导航
  1075. var _nav = U.MD.O.W.T.N.navData("新页面");
  1076. var _parentNode = _addele.parentNode;
  1077. if (_parentNode.pageId == null) { //判断是否是一级目录
  1078. data.splice(_addele.i + 1, 0, _nav);
  1079. _parentNode.innerHTML = ""; //清空目录
  1080. U.MD.O.W.T.N.createFirstTree(data, _parentNode);
  1081. } else {
  1082. for (var i = 0; i < data.length; i++) { //在数据里查询你要插入的目录
  1083. if (data[i].pageId == _addele.pageId) {
  1084. for (var l = 0; l < data.length; l++) { //如果找到该目录则删除父亲目录下所有子目录
  1085. _parentNode.removeChild($('#U_MD_O_W_T_N_' + data[l].pageId)[0]);
  1086. }
  1087. _parentNode.flag = false;
  1088. data.splice(i + 1, 0, _nav); //在数据里你添加页面的目录上方插入数据
  1089. U.MD.O.W.T.N.createFirstTree(data, _parentNode);
  1090. break;
  1091. }
  1092. }
  1093. }
  1094. //移除目录选中样式
  1095. for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
  1096. $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
  1097. }
  1098. var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
  1099. //选中新添加的目录
  1100. _treeNav.style.background = "#ccebf8";
  1101. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
  1102. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
  1103. $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
  1104. $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
  1105. //打印导航
  1106. var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
  1107. //默认执行导航双击事件 触发修改
  1108. _navel.ondblclick();
  1109. //切换记录当前操作的页面ID
  1110. U.MD.O.W.T.N.nowNavId = _nav.pageId;
  1111. //情况页面内容
  1112. $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
  1113. //设置选中样式
  1114. U.MD.O.W.T.N.setHoverClass();
  1115. }, true);
  1116. });
  1117. if ($('.U_MD_O_W_T_N_addCBox')[0]) {
  1118. var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
  1119. _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
  1120. }
  1121. }
  1122. /**
  1123. * 在上方添加页面点击事件
  1124. * ele {element} 获取你点击的元素
  1125. * data {array} 数据信息
  1126. *parent {element} 获取你点击的父级
  1127. */
  1128. U.MD.O.W.T.N.addPAboveOnClick = function (ele, data, parent) {
  1129. var _addele = ele;
  1130. var _treenav = parent;
  1131. U.MD.O.W.T.N.saveNav(function () {
  1132. U.MD.O.W.T.N.savePage(function () {
  1133. //创建新的导航
  1134. var _nav = U.MD.O.W.T.N.navData('新页面');
  1135. var _parentNode = _addele.parentNode;
  1136. if (_parentNode.pageId == null) { //判断是否是一级目录
  1137. data.splice(_addele.i, 0, _nav);
  1138. _parentNode.innerHTML = ""; //清空目录
  1139. U.MD.O.W.T.N.createFirstTree(data, _parentNode);
  1140. } else {
  1141. for (var i = 0; i < data.length; i++) { //在数据里查询你要插入的目录
  1142. if (data[i].pageId == _addele.pageId) {
  1143. for (var l = 0; l < data.length; l++) { //如果找到该目录则删除父亲目录下所有子目录
  1144. _parentNode.removeChild($('#U_MD_O_W_T_N_' + data[l].pageId)[0]);
  1145. }
  1146. _parentNode.flag = false;
  1147. data.splice(i, 0, _nav); //在数据里你添加页面的目录上方插入数据
  1148. U.MD.O.W.T.N.createFirstTree(data, _parentNode);
  1149. break;
  1150. }
  1151. }
  1152. }
  1153. //清空选中样式
  1154. for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
  1155. $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
  1156. }
  1157. var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
  1158. _treeNav.style.background = "#ccebf8";
  1159. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
  1160. //显示三个按钮
  1161. $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
  1162. $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
  1163. $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
  1164. //打印导航
  1165. var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
  1166. //默认执行导航双击事件 触发修改
  1167. _navel.ondblclick();
  1168. //切换记录当前操作的页面ID
  1169. U.MD.O.W.T.N.nowNavId = _nav.pageId;
  1170. //情况页面内容
  1171. $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
  1172. //设置选中样式
  1173. U.MD.O.W.T.N.setHoverClass();
  1174. }, true);
  1175. });
  1176. //如果添加选项窗口还存在就移除窗口
  1177. if ($('.U_MD_O_W_T_N_addCBox')[0]) {
  1178. var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
  1179. _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
  1180. }
  1181. }
  1182. //#region 导航文档互联区域
  1183. /**
  1184. * 修改导航
  1185. * @param navid {guid} 操作导航ID
  1186. * @param name {string} 导航名称
  1187. * @param cb {string} 回调函数
  1188. * @param param {string} 回调函数参数
  1189. */
  1190. U.MD.O.W.T.N.updateNavMessage = function (navid, name, cb, param) {
  1191. var _message = U.MD.O.W.T.N.navMessage('updateNav', { navId: navid, name: name }); //生成修改导航信息
  1192. U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
  1193. "us.nav": [_message]
  1194. })], function (r) {
  1195. if (U.UF.C.isFunction(cb)) {
  1196. cb.apply(this, param);
  1197. } else {
  1198. console.log(r);
  1199. }
  1200. });
  1201. }
  1202. /**
  1203. * 添加导航
  1204. * @param parentid {guid} 父级导航ID
  1205. * @param index {string} 添加位置
  1206. * @param navinfo {object} 导航信息
  1207. */
  1208. U.MD.O.W.T.N.addNavMessage = function (parentid, index, navinfo, content, cb, param) {
  1209. var _message = U.MD.O.W.T.N.navMessage('addNav', { parentId: parentid, index: index, addNav: navinfo, content: content }); //生成添加导航信息
  1210. U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
  1211. "us.nav": [_message]
  1212. })], function (r) {
  1213. if (U.UF.C.isFunction(cb)) {
  1214. cb.apply(this, param);
  1215. } else {
  1216. console.log(r);
  1217. }
  1218. });
  1219. }
  1220. /**
  1221. * 修改导航
  1222. * navid {guid} 操作导航ID
  1223. * parentid {guid} 父级导航ID
  1224. */
  1225. U.MD.O.W.T.N.deleteNavMessage = function (navid, parentid, cb, param) {
  1226. var _message = U.MD.O.W.T.N.navMessage('deleteNav', { navId: navid, parentId: parentid, userId: US.userInfo.userid }); //生成删除导航信息
  1227. U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
  1228. "us.nav": [_message]
  1229. })], function (r) {
  1230. if (U.UF.C.isFunction(cb)) {
  1231. cb.apply(this, param);
  1232. } else {
  1233. console.log(r);
  1234. }
  1235. });
  1236. }
  1237. /**
  1238. * 更新logo
  1239. * logo {url} logo路径
  1240. */
  1241. U.MD.O.W.T.N.updateLogoMessage = function (logo) {
  1242. var _message = U.MD.O.W.T.N.navMessage('updateLogo', { logo: logo }); //生成删除导航信息
  1243. U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
  1244. "us.nav": [_message]
  1245. })], function (r) { });
  1246. }
  1247. /**
  1248. * 导航文档 消息类
  1249. * type {string} 操作类型
  1250. * message {object} 自定义参数
  1251. */
  1252. U.MD.O.W.T.N.navMessage = function (type, message) {
  1253. var _data = {
  1254. sendId: U.MD.O.W.userInfo.userid, //发送人id
  1255. receiveId: U.MD.O.W.fileinfo.UserDirectoryID, //文件id
  1256. // type: navid ? 'us.nav' : 'us.word', //消息类型 后台已判断 目前该参数无作用 因为前台传递时已往上扩展一级 其中已说明类型
  1257. messageInfo: {
  1258. type: type, //类型
  1259. docId: U.MD.O.W.fileinfo.UserDirectoryID, //文档id
  1260. pageId: US.pageId //当前页面id
  1261. }
  1262. };
  1263. //如果存在自定义参数
  1264. if (typeof message == 'object') {
  1265. var _key; //定义变量
  1266. for (_key in message) { //循环追加自定义参数
  1267. _data.messageInfo[_key] = message[_key];
  1268. }
  1269. }
  1270. //返回消息类
  1271. return _data;
  1272. };
  1273. //#endregion
  1274. //#region 轮训跟新
  1275. Namespace.register("U.MD.O.W.T.N.Poll");
  1276. /**
  1277. * 跟新导航
  1278. * ele {element} 获取你点击的元素
  1279. * data {array} 数据信息
  1280. * parent {element} 获取你点击的父级
  1281. */
  1282. U.MD.O.W.T.N.Poll.updateNav = function (message) {
  1283. var _navinfo = U.MD.O.W.T.N.navInfo.nav;
  1284. var _nav = U.MD.O.W.T.N.selectByNavId(_navinfo, message.navId);
  1285. if (_nav) { //判断是否存在
  1286. _nav.name = message.name; //替换名字
  1287. $('#U_MD_O_W_T_N_span' + message.navId)[0] && ($('#U_MD_O_W_T_N_span' + message.navId)[0].innerHTML = _nav.name); //修改名字
  1288. $('#Word_Nav_' + message.navId)[0].innerHTML = _nav.name; //修改名字
  1289. }
  1290. }
  1291. /**
  1292. * 添加导航
  1293. * ele {element} 获取你点击的元素
  1294. * data {array} 数据信息
  1295. * parent {element} 获取你点击的父级
  1296. */
  1297. U.MD.O.W.T.N.Poll.addNav = function (message) {
  1298. var _parent, _navinfo = U.MD.O.W.T.N.navInfo.nav;
  1299. if (message.parentId) {
  1300. _parent = U.MD.O.W.T.N.selectByNavId(_navinfo, message.parentId);
  1301. //如果已存在子级处理
  1302. if (_parent.child) {
  1303. //插入指定位置
  1304. _parent.child.splice(message.index, 0, message.addNav);
  1305. } else {
  1306. // 为存在子级则新建子级
  1307. _parent.child = [message.addNav];
  1308. }
  1309. } else {
  1310. _parent = _navinfo;
  1311. _parent.splice(message.index, 0, message.addNav);
  1312. U.MD.O.W.T.N.Easy.Print(message.addNav, _parent, message.index);
  1313. }
  1314. //执行打印 复杂版本
  1315. }
  1316. /**
  1317. * 删除导航
  1318. * ele {element} 获取你点击的元素
  1319. * data {array} 数据信息
  1320. * parent {element} 获取你点击的父级
  1321. */
  1322. U.MD.O.W.T.N.Poll.deleteNav = function (message) {
  1323. // 寻找父级
  1324. var _child;
  1325. if (message.parentId) {
  1326. var _navinfo = U.MD.O.W.T.N.navInfo.nav;
  1327. var _parent = U.MD.O.W.T.N.selectByNavId(_navinfo, message.parentId);
  1328. _child = _parent.child;
  1329. } else {
  1330. _child = U.MD.O.W.T.N.navInfo.nav;
  1331. }
  1332. if (_child) {
  1333. _child.every(function (object, index) {
  1334. if (object.pageId == message.navId) {
  1335. U.MD.O.W.T.N.deleteNav.asyn(object, index, message.userId, _child);
  1336. return false;
  1337. }
  1338. return true;
  1339. });
  1340. }
  1341. }
  1342. /**
  1343. * 更新logo信息
  1344. * ele {element} 获取你点击的元素
  1345. * data {array} 数据信息
  1346. * parent {element} 获取你点击的父级
  1347. */
  1348. U.MD.O.W.T.N.Poll.updateLogo = function (message) {
  1349. U.MD.O.W.T.N.navInfo.logo = message.logo;
  1350. //修改logo元素src
  1351. }
  1352. //#endregion