12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424 |
- //查看指定文件,,判断是否保存或者覆盖,包括创建邀请协作人员,创建编辑历史,创建生成链接.创建热门模板。加载当前word文档的内容。创建光标,监控键盘输入等。这里是iframe中的word起始点。
- //监控输入输出,
- //添加成员,共同编辑。
- Namespace.register("U.MD.O.W.T.N");
- U.MD.O.W.T.N = {
- navInfo: [], //文件信息
- nowNavId: "", //当前操作的导航页面ID
- navcontent: {}
- };
- /**
- * 获取当前展示的页面的内容
- * @param navinfo {object} 导航信息
- *
- */
- U.MD.O.W.T.N.form = function (navinfo) {
- //简易版导航
- U.MD.O.W.T.N.Easy(navinfo);
- //判断导航窗体是否创建
- //if (false && !$('#U_MD_O_W_N')[0]) {
- if (!$('#U_MD_O_W_N')[0]) {
- //窗体创建的父级窗体
- var _coopwindow = $("#U_MD_O_R_Parent")[0];
- //内容区域盒子
- var _box = $$('div', { id: "U_MD_O_W_N" });
- //logo
- var _logo = $$('div', { "className": "U_MD_O_W_N_Logo", style: { "user-select": "none"} }, _box);
- 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);
- //存放本地上传、云盘上传两个按钮的div
- var _uploadbutton = $$('div', { "className": 'U_MD_O_W_N_uploadbutton', style: { "user-select": "none"} }, _box);
- //input file按钮(隐藏)
- 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);
- //本地上传按钮,调用了input file(隐藏)的点击事件
- var _localupload2 = $$('button', { "className": 'U_MD_O_W_N_localupload2', innerHTML: "本地上传", 'id': 'pic', 'onclick': function () { $('#U_MD_O_W_N_LocalUpload')[0].click(); } }, _uploadbutton);
- //云盘上传按钮
- var _cdupload = $$('button', { "className": "U_MD_O_W_N_CDupload", innerHTML: "云盘上传" }, _uploadbutton);
- //导航区域
- var _nav = $$('div', { "className": 'U_MD_O_W_N_NavBox', innerHTML: "", style: { "user-select": "none"} }, _box);
- //底部区域
- var _bottom = $$('div', { "className": 'U_MD_O_W_N_Bottom', style: { "user-select": "none"} }, _box);
- //新建页面按钮
- var _newpage = $$('button', { "className": 'U_MD_O_W_N_Button', innerHTML: "新建页面", 'onclick': function () { U.MD.O.W.T.N.addNewNav(navinfo.nav); } }, _bottom);
- //预览按钮
- var _newpage = $$('button', { "className": 'U_MD_O_W_N_Button', innerHTML: "预览" }, _bottom);
- //窗体
- 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);
- _form.form.style.display = "none";
- }
- // U.MD.O.W.T.N.getPageContent();
- //打印导航
- U.MD.O.W.T.N.printNav(navinfo);
- }
- /**
- * 打印导航
- * @param navinfo {object} 导航信息
- *
- */
- U.MD.O.W.T.N.printNav = function (navinfo) {
- U.MD.O.W.T.N.navInfo = navinfo; //记录导航信息
- U.MD.O.W.T.N.nowNavId = navinfo.nav[0].pageId; //设置默认页面展示页面ID
- var _nav = $('.U_MD_O_W_N_NavBox')[0]; //获取导航位置
- //打印处理
- U.MD.O.W.T.N.createFirstTree(navinfo.nav, _nav);
- //获取页面内容
- U.MD.O.W.T.N.getPageContent();
- }
- /**
- * 获取当前展示的页面的内容
- *
- */
- U.MD.O.W.T.N.getPageContent = function () {
- if (U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId]) {
- U.MD.O.W.T.N.getPageContentAsyn({ value: U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId] });
- }
- else if (U.MD.O.W.permission.web) {
- //发送获取内容请求
- parent.U.A.Request(US.SCOKET, ["getNavPageContent", U.MD.O.W.fileinfo.UserDirectoryID, U.MD.O.W.T.N.nowNavId], function (r) {
- U.MD.O.W.T.N.getPageContentAsyn(r); //异步处理
- }, [$('#U_MD_O_W_E_body')[0]]);
- }
- else {
- //发送获取内容请求
- parent.U.A.Request(US.CD, [US.DB, "UseStudio_Office", "GetNavPageContent", U.MD.O.W.T.N.nowNavId], function (r) {
- U.MD.O.W.T.N.getPageContentAsyn(r);
- }, [$('#U_MD_O_W_E_body')[0]]);
- }
- }
- /**
- * 获取当前展示的页面的内容异步处理
- *
- */
- U.MD.O.W.T.N.getPageContentAsyn = function (r) {
- //内容处理
- if (r.value && r.value.UsOffice !== undefined) {
- r = r.value.UsOffice;
- } else {
- r = r.value;
- if (U.UF.C.isObject(r)) {
- r = r[0] ? r[0].content : "";
- }
- }
- //设置当前展示导航的样式
- U.MD.O.W.T.N.setHoverClass();
- //设置内容属性
- U.MD.O.W.fileinfo.UsOffice = (r || "").unEscapeQuotes(); //word内容
- U.MD.O.W.E.initEditor(U.MD.O.W.permission.web); //加载编辑器和内容
- //设置切换页面全局状态为false 表示切换结束
- U.MD.O.W.T.N.switching = false;
- //清楚loading
- U.UF.DL.uploading($('#U_MD_O_W_E_body')[0]);
- }
- /**
- * 设置当前展示导航的样式
- *
- */
- U.MD.O.W.T.N.setHoverClass = function () {
- //去除已中样式
- $('.U_MD_O_H_Nav_Span').removeClass('U_MD_O_H_Nav_Span');
- //设置新的导航选中
- $('#Word_Nav_' + U.MD.O.W.T.N.nowNavId).addClass('U_MD_O_H_Nav_Span');
- $('.U_MD_O_W_T_N_easyDeleteBtn_show').removeClass('U_MD_O_W_T_N_easyDeleteBtn_show');
- $('.U_MD_O_W_T_N_easyDeleteBtn_show').removeClass('U_MD_O_W_T_N_easyDeleteBtn_show');
- $($('#Word_Nav_' + U.MD.O.W.T.N.nowNavId).next()).addClass('U_MD_O_W_T_N_easyDeleteBtn_show');
- }
- /**
- * 页面导航
- * @param callback {function} 回调函数
- *
- */
- U.MD.O.W.T.N.saveNav = function (callback, param) {
- //判断用户是否登录,只有登录用户才能保存信息
- if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; })) {
- var _isftp,
- _isgroupuser,
- _uid = U.MD.O.W.userInfo.userid,
- _el = $("#U_MD_O_H_wordEditor")[0], //word编辑区域
- _fileinfo = U.MD.O.W.fileinfo, //文件信息
- _name = top.$('#UD_Word' + _fileinfo.UserDirectoryID + ' .U_MD_O_H_head_navigation_Title')[0], //文件名
- _fileid = _fileinfo.UserDirectoryID, //文件ID
- _html = _el.innerHTML, //内容
- _data = null;
- //判断文档是否是已经保存到数据库的文档
- if (_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
- //保存到数据库
- top.U.A.Request(US.DISK, ["SaveFileContent", _uid, _fileid, JSON.stringify(U.MD.O.W.T.N.navInfo), _name.value, "un"], function (r) {
- U.UF.C.isFunction(callback) && callback.apply(this, param);
- }, (['', _el])); //保存到数据库
- }
- //如果文件没有保存,那么直接新建文件
- else {
- var _newfileid = Guid.newGuid();
- //调用word新建文档的处理
- top.U.MD.DK.VW.chosenSaveFile('un', _newfileid, _name.value, function (fileinfo) {
- U.MD.O.W.fileinfo = fileinfo //文档信息
- top.$('#UD_Word' + _fileid)[0].id = 'UD_Word' + _newfileid;
- _name.value = fileinfo.UserDirectoryName;
- _isgroup = U.Json.select(US.friend.group, {
- "GroupManageID": fileinfo.GroupID
- })[0];
- if (!U.MD.O.W.permission.edit) {
- U.MD.O.W.T.N.saveAllPage(function () {
- U.MD.O.W.T.N.saveNav.asyn(_isgroup, fileinfo, _el)
- }, 0, _isgroup, _html);
- } else {
- U.MD.O.W.T.N.saveNav.asyn(_isgroup, fileinfo, _el, _html);
- }
- });
- }
- }
- }
- U.MD.O.W.T.N.saveNav.asyn = function (isgroup, fileinfo, el, html) {
- if (isgroup) {
- 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) {
- //top.$('#UD_Word' + newfileid + ' .U_MD_O_H_head_navigation_Title')[0].value = fileinfo.UserDirectoryName;
- U.MD.O.W.fileinfo.UsOffice = el.innerHTML;
- $('#U_MD_O_H_wordEditor')[0].editor.operaNotice = U.MD.O.W.E.operationNotice;
- U.MD.O.W.permission.edit = true;
- U.MD.O.W.permission.web = true;
- U.Alert("保存成功");
- });
- } else {
- 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) {
- U.MD.O.W.T.N.savePage(function () {
- U.MD.O.W.permission.edit = true;
- }, true);
- }); //保存到数据库
- }
- }
- U.MD.O.W.T.N.saveAllPage = function (callback, i, group, html) {
- var _nowid, _nav = U.MD.O.W.T.N.navInfo.nav;
- _nowid = Guid.newGuid();
- if (_nav[i].pageId == U.MD.O.W.T.N.nowNavId) {
- _content = html;
- } else {
- _content = U.MD.O.W.T.N.navcontent[_nav[i].pageId] || "";
- }
- if (group) {
- 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]); //保存到数据库
- } else {
- 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]); //保存到数据库
- }
- }
- U.MD.O.W.T.N.saveAllPage.asyn = function (r) {
- if (r.value) {
- var i = r.context[1],
- _group = r.context[2],
- _nav = r.context[3],
- _nowid = r.context[4],
- _callback = r.context[5];
- _nav[i].pageId == U.MD.O.W.T.N.nowNavId && (U.MD.O.W.T.N.nowNavId = _nowid);
- $("#Word_Nav_" + _nav[i].pageId)[0].onclick = U.UF.C.closure(U.MD.O.W.T.N.switchPage, [_nowid]);
- $("#Word_Nav_" + _nav[i].pageId).attr({ pid: _nowid, id: "#Word_Nav_" + _nowid });
- _nav[i].pageId = _nowid;
- if (_nav.length == i + 1) {
- _callback();
- } else {
- U.MD.O.W.T.N.saveAllPage(_callback, ++i, _group);
- }
- }
- }
- /**
- * 新建建站文件
- * @param callback {function} 回调函数
- * @param alert {boole} 是否弹出弹出提示
- *
- */
- U.MD.O.W.T.N.savePage = function (callback, alert) {
- U.UF.DL.loading($('#U_MD_O_W_E_body')[0]);
- var _html = $("#U_MD_O_H_wordEditor")[0].innerHTML;
- top.U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SaveNavPageContent", U.MD.O.W.T.N.nowNavId, _html.escapeQuotes()], function (r) {
- U.MD.O.W.fileinfo.UsOffice = _html;
- alert && U.Alert('保存成功');
- U.UF.C.isFunction(callback) && callback();
- U.UF.DL.uploading($('#U_MD_O_W_E_body')[0]);
- }); //保存到数据库
- }
- /**
- * 修改logo 设置logo背景图
- * @param fileinput {object} 上传文本框
- * @param logoel {object} logo图片
- *
- */
- U.MD.O.W.T.N.changeLogo = function (fileinput, logoel) {
- if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; })) {
- U.UF.UP.HTML.upload(
- [fileinput],
- 'http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=' + US.userInfo.userid,
- function (r) {
- //上传之后的处理 r.value[0]上传之后的图片服务器名字 全路径 http://fs.1473.cn/ + r.value[0]
- U.MD.O.W.T.N.navInfo.logo = r.value[0];
- //logoel.style.backgroundImage = "url('http://fs.1473.cn/" + U.MD.O.W.T.N.navInfo.logo + "')";
- logoel.src = "http://fs.1473.cn/" + U.MD.O.W.T.N.navInfo.logo + "";
- }
- );
- }
- }
- /**
- * 切换页面
- * @param nav {object} 导航目录信息
- *
- */
- U.MD.O.W.T.N.switching = false; //设置记录切换中属性
- U.MD.O.W.T.N.switchPage = function (pageid) {
- if (this.contentEditable != "true") {
- var _fileinfo = U.MD.O.W.fileinfo; //文件信息
- if (!U.MD.O.W.T.N.switching) { // && _fileinfo.UserId && _fileinfo.UserallDirectoryName
- U.MD.O.W.T.N.switching = true;
- if (U.MD.O.W.permission.edit) {
- //先执行保存
- U.MD.O.W.T.N.savePage(function () {
- //修改记录的当前操作的导航页面ID
- U.MD.O.W.T.N.nowNavId = pageid;
- //执行切换
- U.MD.O.W.T.N.getPageContent();
- });
- } else {
- U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId] = $("#U_MD_O_H_wordEditor")[0].innerHTML;
- //修改记录的当前操作的导航页面ID
- U.MD.O.W.T.N.nowNavId = pageid;
- //执行切换
- U.MD.O.W.T.N.getPageContent();
- }
- }
- }
- }
- /**
- * 创建导航信息
- * @param name {string} 导航名称
- *
- */
- U.MD.O.W.T.N.navData = function (name) {
- return {
- pageId: Guid.newGuid(),
- name: name || "新的页面"
- };
- }
- /**
- * 根据NavId查找对应的导航信息
- */
- U.MD.O.W.T.N.selectByNavId = function (nowinfo, navid) {
- var i = 0;
- for (i = 0; i < nowinfo.length; i++) {
- object = nowinfo[i];
- if (object.pageId == navid) {
- return object;
- } else if (object.child) {
- return us.selectNav(object.child, navid);
- }
- }
- }
- /**
- * 简易版导航创建
- *
- */
- U.MD.O.W.T.N.Easy = function (navinfo) {
- $('.U_MD_O_H_Nav')[0].style.display = "block"; //显示导航
- U.MD.O.W.T.N.navInfo = navinfo; //记录导航信息
- U.MD.O.W.T.N.nowNavId = navinfo.nav[0].pageId; //设置默认页面展示页面ID
- var i, _navbox = $('.U_MD_O_H_Nav_Box')[0]; //导航区域
- _navbox.innerHTML = "";
- for (i = 0; i < navinfo.nav.length; i++) {
- if (i == 4) {
- U.MD.O.W.T.N.Easy.createMore();
- }
- U.MD.O.W.T.N.Easy.Print(navinfo.nav[i], navinfo.nav);
- }
- }
- /**
- * 打印导航
- * @param nav {object} 导航目录信息
- *
- */
- U.MD.O.W.T.N.Easy.Print = function (nav, data, index, isnew) {
- var _navbox = $('.U_MD_O_H_Nav_Box'); //导航区域
- var _div = $$('div', {}); //创建盒子
- var _beforeele = null;
- if (index) {
- _beforeele = _navbox.Child()[index + 1];
- }
- $(_div).appendTo(_navbox[0], 0, _beforeele); //添加元素
- //内容区域
- 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);
- //如果是新增导航的处理
- if (isnew) {
- _span.onblur = function () { U.MD.O.W.T.N.addNav(this, nav, data, top); };
- }
- else {
- _span.onblur = function () { U.MD.O.W.T.N.updateNav(this, nav); }
- }
- _span.ondblclick = U.MD.O.W.T.N.Easy.ondblclick;
- _span.onkeydown = U.UF.C.closure(U.MD.O.W.T.N.Easy.enter, [_span]);
- $$("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); //删除按钮
- return _span;
- }
- /**
- * 双击事件
- *
- */
- U.MD.O.W.T.N.Easy.ondblclick = function () {
- // if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userInfo = userinfo; })) {
- this.setAttribute("contenteditable", "true"); //设置可编辑
- this.focus(); //聚焦处理
- U.UF.E.getRangeAt().selectNodeContents(this); //全选处理
- // }
- }
- /**
- * 回车修改
- * @param nav {object} 导航目录信息
- *
- */
- U.MD.O.W.T.N.Easy.enter = function (navel, fun) {
- //获取event对象
- var e = U.UF.EV.getEventSource();
- //获取按下键值
- var _code = e.keyCode;
- //判断是否为回车键
- if (_code == 13) {
- if (navel.innerText !== "") { //判断文本内容是否为空
- navel.setAttribute("contenteditable", "false"); //设置导航不可编辑
- //执行修改导航名称函数
- // U.MD.O.W.T.N.updateNav(this, nav)
- // this.onblur();
- U.UF.EV.stopDefault();
- } else {
- navel.innerText = "标题不能为空(双击编辑)" //更改为空的内容
- U.UF.EV.stopDefault(); //阻止冒泡
- }
- U.UF.EV.stopBubble(); //阻止默认事件
- }
- }
- /**
- * 添加导航点击事件处理
- *
- */
- U.MD.O.W.T.N.Easy.add = function () {
- var _fileinfo = U.MD.O.W.fileinfo; //文件信息
- //多导航处理
- if (U.MD.O.W.T.N.navInfo.nav.length == 4) {
- //提示操作限制
- //return U.Alert('目前最多只支持4个页面。。。');
- U.MD.O.W.T.N.Easy.createMore();
- }
- if (U.MD.O.W.T.N.navInfo.nav.length >= 4) {
- $('.U_MD_O_H_Nav_Box_More_Hide').removeClass('U_MD_O_H_Nav_Box_More_Hide');
- }
- //判断文档是否是已经保存到数据库的文档
- // if (_fileinfo.UserDirectoryID && _fileinfo.UserId && _fileinfo.UserallDirectoryName) { //如果是已经保存到数据库的文档,那么直接保存内容
- if (!U.MD.O.W.permission.edit) {
- U.MD.O.W.T.N.navcontent[U.MD.O.W.T.N.nowNavId] = $("#U_MD_O_H_wordEditor")[0].innerHTML;
- U.MD.O.W.T.N.Easy.add.asyn();
- } else {
- if (U.MD.O.W.permission.web) {
- U.MD.O.W.T.N.Easy.add.asyn();
- } else {
- //执行保存页面内容函数
- U.MD.O.W.T.N.savePage(U.MD.O.W.T.N.Easy.add.asyn);
- }
- }
- // } else {
- // U.MD.O.W.save();
- // }
- }
- /**
- * 添加导航点击事件处理 异步
- *
- */
- U.MD.O.W.T.N.Easy.add.asyn = function () {
- //创建新的导航
- var _nav = U.MD.O.W.T.N.navData();
- //添加到导航信息数组里
- U.MD.O.W.T.N.navInfo.nav.push(_nav);
- //切换记录当前操作的页面ID
- U.MD.O.W.T.N.nowNavId = _nav.pageId;
- var _editor = $("#U_MD_O_H_wordEditor")[0]; //编辑器元素
- U.MD.O.W.fileinfo.UsOffice = "";
- U.MD.O.W.E.initEditor();
- // _editor.innerHTML = ""; //清空内容
- // U.UF.E.key.addDelLine(_editor); //默认添加第一行
- //打印导航
- var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav, null, true);
- //默认执行导航双击事件 触发修改
- _navel.ondblclick();
- //设置选中样式
- U.MD.O.W.T.N.setHoverClass();
- }
- U.MD.O.W.T.N.Easy.createMore = function () {
- $$('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]);
- $(".U_MD_O_H_Nav_Box").addClass("U_MD_O_H_Nav_Box_More");
- $(".U_MD_O_H_Nav_Box").addClass("U_MD_O_H_Nav_Box_More_Hide");
- }
- U.MD.O.W.T.N.Easy.removeMore = function () {
- $('.U_MD_O_H_Nav_More').remove();
- $(".U_MD_O_H_Nav_Box").removeClass("U_MD_O_H_Nav_Box_More");
- $(".U_MD_O_H_Nav_Box").removeClass("U_MD_O_H_Nav_Box_More_Hide");
- }
- U.MD.O.W.T.N.Easy.showOrHideNav = function (flag) {
- if (flag == true || $('.U_MD_O_H_Nav_Box_More_Hide')[0]) {
- $('.U_MD_O_H_Nav_Box_More_Hide').removeClass('U_MD_O_H_Nav_Box_More_Hide');
- var _close = function () {
- U.MD.O.W.T.N.Easy.showOrHideNav();
- $('body').unbind("click", _close);
- }
- $('body').bind("click", _close);
- } else {
- $('.U_MD_O_H_Nav_Box_More').addClass('U_MD_O_H_Nav_Box_More_Hide');
- }
- U.UF.EV.stopBubble();
- }
- /**
- * 添加导航
- *
- * @param navel {element} 导航标题元素
- * @param nav {object} 导航信息对象
- * @param data {object} 父级导航信息数组
- * @param top {boole} 是否为第一级导航
- */
- U.MD.O.W.T.N.addNav = function (navel, nav, data, top) {
- if (!U.MD.O.W.permission.edit) {
- nav.name = navel.innerHTML; //修改记录变量
- navel.setAttribute("contenteditable", "false"); //设置导航不可编辑
- } else {
- if (U.MD.O.W.permission.web) { //协同处理
- var _parent, _navinfo = U.MD.O.W.T.N.navInfo.nav;
- var _content = $("#U_MD_O_H_wordEditor")[0].innerHTML.escapeQuotes();
- nav.name = navel.innerHTML; //修改记录变量
- if (top) {
- U.MD.O.W.T.N.addNavMessage("", _navinfo.length, nav, _content, function () {
- navel.onblur = function () { //覆盖失焦事件
- U.MD.O.W.T.N.updateNav(navel, nav); //修改导航处理
- }
- });
- } else {
- var _child = data.child; //获取子级
- if (_child) { //如果存在子级 则执行删除
- _child.every(function (object, index) { //循环找到对应的导航
- if (object.pageId == nav.navId) { //如果导航id相等则为对应导航
- U.MD.O.W.T.N.addNavMessage(data.pageId, index, nav, _content, function () {
- navel.onblur = function () { //覆盖失焦事件
- U.MD.O.W.T.N.updateNav(navel, nav); //修改导航处理
- }
- });
- }
- });
- }
- }
- } else {
- U.MD.O.W.T.N.updateNav(navel, nav); //直接执行修改导航
- navel.onblur = function () { //覆盖失焦事件
- U.MD.O.W.T.N.updateNav(navel, nav);
- }
- }
- }
- }
- /**
- * 删除导航处理
- * nav {object} 当前操作导航信息
- * data {object} 父级导航信息
- * top {boole} 是否为顶级(第一级)
- *
- */
- U.MD.O.W.T.N.deleteNav = function (nav, data, top) {
- if (top && data.length <= 1) { return U.Alert('只剩下一个导航页面啦!'); } //最后一个页面不允许删除
- var _child = top ? data : data.child; //获取子级
- if (_child) { //如果存在子级 则执行删除
- _child.every(function (object, index) { //循环找到对应的导航
- if (object.pageId == nav.pageId) { //如果导航id相等则为对应导航
- if (U.MD.O.W.permission.web) { //协同处理
- 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]); //信息处理
- }
- else if (U.MD.O.W.permission.edit) {
- // U.MD.O.W.T.N.deleteNav.asyn(object, index, US.userInfo.userid, _child); //异步处理
- U.MD.O.W.T.N.saveNav(function () { //直接保存页面
- U.A.Request(US.CD, [US.DB, "UseStudio_Office", "DeletePage", nav.pageId], function (r) { //删除页面请求
- U.MD.O.W.T.N.deleteNav.asyn(object, index, US.userInfo.userid, _child); //异步处理
- });
- });
- }
- else {
- U.MD.O.W.T.N.deleteNav.asyn(object, index, US.userInfo.userid, _child); //异步处理
- }
- return false; //返回false终止循环
- }
- return true;
- });
- } else {
- U.Alert("删除有误");
- }
- }
- /**
- * 删除导航处理
- * object {object} 当前操作导航信息
- * index {int} 位于父级导航信息的位置
- * userid {uuid} 操作用户id
- * parent {object} 导航的父级信息
- *
- */
- U.MD.O.W.T.N.deleteNav.asyn = function (object, index, userid, parent) {
- if (!object.child) {
- //导航删除
- $('#U_MD_O_W_T_N_' + object.pageId).remove();
- $($('#Word_Nav_' + object.pageId).Parent()).remove();
- //执行切换
- if (U.MD.O.W.T.N.nowNavId == object.pageId) {
- if (userid != US.userInfo.userid) {
- var _user = U.Json.select(US.friend.groupusers, { UserId: userid })[0];
- U.Alert('该页面已被' + (_user ? _user.UserNickName || _user.UserName : "") + '删除');
- }
- //执行切换页面
- if (parent.length) {
- if (parent.length == 5) {
- U.MD.O.W.T.N.Easy.removeMore();
- }
- //删除后存在同级页面
- U.MD.O.W.T.N.switchPage(parent[index + 1] ? parent[index + 1].pageId : parent[index - 1].pageId);
- } else {
- //删除后 不存在同级页面
- U.MD.O.W.T.N.switchPage(parent.pageId);
- }
- }
- //数据删除
- parent && parent.splice(index, 1);
- }
- }
- /**
- * 修改导航名称
- * @param navel {Element} 导航元素
- * @param nav {object} 导航目录信息
- *
- */
- U.MD.O.W.T.N.updateNav = function (navel, nav) {
- navel.setAttribute("contenteditable", "false"); //设置导航不可编辑
- if (navel.innerText !== "") { //判断文本内容是否为空
- nav.name = navel.innerHTML; //修改记录的name
- if (U.MD.O.W.permission.edit) {
- if (U.MD.O.W.permission.web) { //协同处理
- U.MD.O.W.T.N.updateNavMessage(nav.pageId, nav.name, U.MD.O.W.T.N.updateNav.asyn); //协同更新导航处理
- } else {
- //执行保存导航函数
- U.MD.O.W.T.N.saveNav(U.MD.O.W.T.N.updateNav.asyn);
- }
- }
- } else {
- navel.innerText = "标题不能为空(双击编辑)"; //为空时的处理
- }
- }
- /**
- * 修改导航名称 异步处理
- * @param nav {object} 导航目录信息
- *
- */
- U.MD.O.W.T.N.updateNav.asyn = function (nav) {
- //默认聚到到编辑器区
- $("#U_MD_O_H_wordEditor")[0].focus();
- // var _fileinfo = U.MD.O.W.fileinfo; //文件信息
- // var _issave = true;
- // if (!_fileinfo.UserId && !_fileinfo.UserallDirectoryName) { //如果是已经保存到数据库的文档,那么直接保存内容
- // _issave = false;
- // }
- //提示修改成功
- //U.Alert('修改成功');
- // !_issave && U.MD.O.W.T.N.savePage(null, true);
- }
- /**
- *左目录导航
- *
- */
- U.MD.O.W.T.N.createFirstTree = function (data, parent) {//第一个参数是获取返回的数据,第二个是你要显示目录的位置
- var _data = data;
- if (parent == $('.U_MD_O_W_N_NavBox')[0] && $('.U_MD_O_W_N_NavBox')[0] != null) {
- parent.innerHTML = "";
- }
- for (var i = 0; i < _data.length; i++) { //循环创建目录
- $$("div", {
- 'className': 'U_MD_O_W_T_N_treeDiv',
- 'id': 'U_MD_O_W_T_N_' + _data[i].pageId
- },
- parent);
- var _treeDiv = $('#U_MD_O_W_T_N_' + _data[i].pageId)[0];
- if (parent == $('.U_MD_O_W_N_NavBox')[0]) {
- _treeDiv.deep = 1;
- } else {
- _treeDiv.deep = parent.deep + 1;
- }
- _treeDiv.i = i; //给目录添加属性
- _treeDiv.pageId = _data[i].pageId;
- _treeDiv.flag = true;
- $$('div', {
- 'className': 'U_MD_O_W_T_N_treeNav',
- 'id': 'U_MD_O_W_T_N_treenav' + _data[i].pageId,
- 'style': { 'padding-left': 12 + 20 * (_treeDiv.deep - 1) + 'px' }
- },
- _treeDiv);
- var _treeNav = $('#U_MD_O_W_T_N_treenav' + _data[i].pageId)[0];
- $$("span", { //创建span标签插入名字
- 'className': 'U_MD_O_W_T_N_treeSpan',
- 'innerHTML': _data[i].name,
- 'id': 'U_MD_O_W_T_N_span' + _data[i].pageId
- },
- _treeNav);
- $$("div", { //创建div标签添加删除按钮
- 'className': 'U_MD_O_W_T_N_deleteDiv',
- 'id': 'U_MD_O_W_T_N_delete' + _data[i].pageId
- },
- _treeNav);
- $$("div", {//创建div标签添加添加按钮
- 'className': 'U_MD_O_W_T_N_addDiv',
- 'id': 'U_MD_O_W_T_N_add' + _data[i].pageId
- },
- _treeNav);
- $$("div", { //创建div标签修改按钮
- 'className': 'U_MD_O_W_T_N_updateDiv',
- 'id': 'U_MD_O_W_T_N_update' + _data[i].pageId
- },
- _treeNav);
- if (_data[i].child) {
- if (_data[i].child.length == 0) {
- $('#U_MD_O_W_T_N_span' + _data[i].pageId)[0].style.cssText += "margin-left:20px";
- } else {
- $$('div', {
- 'className': 'U_MD_O_W_T_N_checkDiv',
- 'id': 'U_MD_O_W_T_N_checkDiv' + _data[i].pageId
- },
- _treeNav);
- }
- } else {
- $('#U_MD_O_W_T_N_span' + _data[i].pageId)[0].style.cssText += "margin-left:20px";
- }
- _treeDiv.onclick = function (e) { //点击目录查看子目录
- U.MD.O.W.T.N.checkNav(this, data);
- e.stopPropagation();
- }
- //删除按钮点击事件
- $('#U_MD_O_W_T_N_delete' + _data[i].pageId)[0].onclick = function (e) {
- var _parent = this.parentNode.parentNode.parentNode; //获取子目录的父级
- var _delele = this.parentNode.parentNode; //获取你要删除的目录
- //删除按钮点击事件函数,第一个参数是要删除的ele,第二个是数据,第三个是父级ele
- U.MD.O.W.T.N.deleteOnClick(_delele, data, _parent);
- e.stopPropagation();
- }
- $('#U_MD_O_W_T_N_add' + _data[i].pageId)[0].onclick = function (e) { //添加按钮点击事件
- var _addele = this.parentNode.parentNode; //获取你点击添加的目录
- var _treenav = this.parentNode;
- if ($('.U_MD_O_W_T_N_addCBox')[0]) { //判断添加选项框是否存在
- var _addParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
- _addParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]); //判断存在,删除选项框
- }
- $$("div", { //创建添加选项框
- 'className': 'U_MD_O_W_T_N_addCBox'
- },
- $('body')[0]);
- e.preventDefault();
- $$("div", { //添加选项
- 'className': 'U_MD_O_W_T_N_addCPage',
- 'innerHTML': '添加子页面'
- },
- $('.U_MD_O_W_T_N_addCBox')[0]);
- $$("div", {
- 'className': 'U_MD_O_W_T_N_addPAbove',
- 'innerHTML': '在上方添加页面'
- },
- $('.U_MD_O_W_T_N_addCBox')[0]);
- $$("div", {
- 'className': 'U_MD_O_W_T_N_addPBelow',
- 'innerHTML': '在下方添加页面'
- },
- $('.U_MD_O_W_T_N_addCBox')[0]);
- //添加子页面点击事件
- $(".U_MD_O_W_T_N_addCPage")[0].onclick = function (e) {
- U.MD.O.W.T.N.addChildOnClick(_addele, data, _treenav);
- }
- //在上方添加页面点击事件
- $('.U_MD_O_W_T_N_addPAbove')[0].onclick = function (e) {
- U.MD.O.W.T.N.addPAboveOnClick(_addele, data, _treenav);
- e.stopPropagation();
- }
- //在下面添加页面点击事件
- $('.U_MD_O_W_T_N_addPBelow')[0].onclick = function (e) {
- U.MD.O.W.T.N.addPBelowOnClick(_addele, data, _treenav);
- e.stopPropagation();
- }
- document.onclick = function (e) { //显示添加选项框后,点击别的空白地方会关闭选项框
- if ($('.U_MD_O_W_T_N_addCBox')[0]) {
- var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
- _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
- }
- }
- U.UF.C.rightClickMenuLocation($('.U_MD_O_W_T_N_addCBox')[0]);
- e.stopPropagation();
- }
- //修改按钮点击事件
- $('#U_MD_O_W_T_N_update' + _data[i].pageId)[0].onclick = function (e) {
- var _upele = this.parentNode.parentNode;
- U.MD.O.W.T.N.updateOnClick(_upele, data); //修改按钮点击事件函数,第一个参数是你要修改的ele,第二个是数据
- if (e) {
- e.stopPropagation();
- }
- }
- }
- }
- /**
- * 刷新目录名称
- * @param data {object} 目录信息
- *
- */
- U.MD.O.W.T.N.cleanInnerHTML = function (data) { //清除内容
- var _span = $('#U_MD_O_W_T_N_span' + data.pageId)[0];
- _span.innerHTML = data.name; //重新显示名字
- }
- /**
- * 删除页面点击事件
- * ele {element} 修改的元素
- * data [array] 数据数组
- */
- U.MD.O.W.T.N.deleteOnClick = function (ele, data, parent) {
- var _delele = ele;
- var _parent = parent;
- for (var i = 0; i < data.length; i++) { //循环找到你删除的子目录的信息
- if (data[i].pageId == _delele.pageId) {
- if (data[i].child && data[i].child.length > 0) {
- var _deleteId = _delele.pageId;
- for (var l = 0; l < data[i].child.length; l++) {
- _deleteId += "," + data[i].child[l].pageId;
- }
- U.UF.UI.confirm($$('div', { style: { padding: "25px 0 " }, innerHTML: "删除这些页面将会删除他们的子页面,是否删除?" }), U.UF.C.closure(function (i) {
- data.splice(i, 1); //从数据中删除信息
- //执行保存导航函数
- U.MD.O.W.T.N.saveNav(function () {
- U.A.Request(US.CD, [US.DB, "UseStudio_Office", "DeletePage", _deleteId], function (r) {
- _parent.removeChild(_delele); //页面上删除子目录
- if ($('#U_MD_O_W_T_N_' + _parent.id + ' .U_MD_O_W_T_N_treeNav').length == 0) {
- if (_parent != $('.U_MD_O_W_N_NavBox')[0]) {
- $('#U_MD_O_W_T_N_treenav' + _parent.pageId)[0].removeChild($('#U_MD_O_W_T_N_checkDiv' + _parent.pageId)[0]);
- $('#U_MD_O_W_T_N_span' + _parent.pageId)[0].style.cssText += "margin-left:20px";
- }
- }
- $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
- });
- });
- }, [i]));
- } else {
- data.splice(i, 1);
- //执行保存导航函数
- U.MD.O.W.T.N.saveNav(function () {
- U.A.Request(US.CD, [US.DB, "UseStudio_Office", "DeletePage", _delele.pageId], function (r) {
- console.log(1);
- _parent.removeChild(_delele); //页面上删除子目录
- if ($('#U_MD_O_W_T_N_' + _parent.id + ' .U_MD_O_W_T_N_treeNav').length == 0) {
- if (_parent != $('.U_MD_O_W_N_NavBox')[0]) {
- $('#U_MD_O_W_T_N_treenav' + _parent.pageId)[0].removeChild($('#U_MD_O_W_T_N_checkDiv' + _parent.pageId)[0]);
- $('#U_MD_O_W_T_N_span' + _parent.pageId)[0].style.cssText += "margin-left:20px";
- }
- }
- $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
- });
- });
- }
- }
- }
- }
- /**
- * 修改页面点击事件
- * ele {element} 修改的元素
- * data [array] 数据数组
- */
- U.MD.O.W.T.N.updateOnClick = function (ele, data) {
- var _upele = ele;
- if ($('.U_MD_O_W_T_N_updateInput')[0]) {//如果修改输入框已经存在,则移除输入框
- var _inputParent = $('.U_MD_O_W_T_N_updateInput')[0].parentNode;
- _inputParent.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
- }
- $$("input", { //创建输入框
- 'className': 'U_MD_O_W_T_N_updateInput',
- 'type': 'text',
- 'style': {
- 'left': 7 + 20 * _upele.deep + 'px'
- },
- 'value': $('#U_MD_O_W_T_N_span' + _upele.pageId)[0].innerHTML
- },
- _upele);
- //输入框阻止冒泡
- $('.U_MD_O_W_T_N_updateInput')[0].onclick = function (e) {
- e.stopPropagation();
- }
- document.onclick = function () { //点击空白处关闭输入框
- if ($('.U_MD_O_W_T_N_updateInput')[0]) {
- var _upvalue = $('.U_MD_O_W_T_N_updateInput')[0].value;
- //判断输入的内容是否为空
- if (_upvalue == "" || _upvalue == null) {
- return false;
- }
- _upele.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
- for (var i = 0; i < data.length; i++) {
- if (data[i].pageId == _upele.pageId) {
- data[i].name = _upvalue;
- U.MD.O.W.T.N.saveNav(function () {
- U.MD.O.W.T.N.cleanInnerHTML(data[i]);
- console.log(data);
- });
- return false;
- }
- }
- if ($('.U_MD_O_W_T_N_updateInput')[0]) {
- _upele.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
- }
- }
- }
- document.onkeydown = function () { //网页内按下回车触发
- if (event.keyCode == 13) { //点击回车修改目录信息
- var _upvalue = $('.U_MD_O_W_T_N_updateInput')[0].value;
- if (_upvalue == "" || _upvalue == null) {
- return false;
- }
- _upele.removeChild($('.U_MD_O_W_T_N_updateInput')[0]);
- for (var i = 0; i < data.length; i++) {
- if (data[i].pageId == _upele.pageId) {
- data[i].name = _upvalue;
- U.MD.O.W.T.N.saveNav(function () {
- U.MD.O.W.T.N.cleanInnerHTML(data[i]);
- console.log(data);
- });
- return false;
- }
- }
- }
- }
- }
- /**
- * 查看页面点击事件
- * @param data {object} 目录信息
- *
- */
- U.MD.O.W.T.N.checkNav = function (ele, data) {
- var _data = data; //获取返回的数据
- var _ele = ele;
- //清空其他选中样式,增删改按钮
- for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
- $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
- var _treeNavParent = $('.U_MD_O_W_T_N_treeNav')[i].parentNode;
- $('#U_MD_O_W_T_N_update' + _treeNavParent.pageId)[0].style.display = "none";
- $('#U_MD_O_W_T_N_add' + _treeNavParent.pageId)[0].style.display = "none";
- $('#U_MD_O_W_T_N_delete' + _treeNavParent.pageId)[0].style.display = "none";
- }
- var _treeNav = $('#U_MD_O_W_T_N_treenav' + _data[_ele.i].pageId)[0];
- _treeNav.style.background = "#ccebf8";
- //显示增删改按钮
- $('#U_MD_O_W_T_N_update' + _data[_ele.i].pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_add' + _data[_ele.i].pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_delete' + _data[_ele.i].pageId)[0].style.display = "block";
- U.MD.O.W.T.N.switching = false; //设置记录切换中属性
- U.MD.O.W.T.N.switchPage(_data[_ele.i].pageId);
- if (_data[_ele.i].child && _data[_ele.i].child.length > 0) { //如果目录有子目录则执行
- if (_ele.flag) { //根据flag判定子目录是否已经存在
- $('#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%;';
- U.MD.O.W.T.N.createFirstTree(data[_ele.i].child, _ele); //显示子目录
- _ele.flag = false;
- } else {
- for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
- $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
- var _treeNavParent = $('.U_MD_O_W_T_N_treeNav')[i].parentNode;
- }
- var _treeNav = $('#U_MD_O_W_T_N_treenav' + _data[_ele.i].pageId)[0];
- $('#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%;';
- _treeNav.style.background = "#ccebf8";
- if ($('.U_MD_O_W_T_N_addCBox')[0]) {
- var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
- _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
- }
- for (var l = 0; l < _data[_ele.i].child.length; l++) {//子目录已经存在,删除子目录
- _ele.removeChild($('#U_MD_O_W_T_N_' + _data[_ele.i].child[l].pageId)[0]);
- }
- // U.MD.O.W.T.N.cleanInnerHTML(this, _data[this.i]);
- _ele.flag = true;
- }
- }
- }
- /**
- * 新建页面点击事件
- * @param data {object} 目录信息
- *
- */
- U.MD.O.W.T.N.addNewNav = function (data) { //添加新页面的点击事件
- var _data = data; //获取返回的数据
- U.MD.O.W.T.N.saveNav(function () {
- U.MD.O.W.T.N.savePage(function () {
- //创建新的导航
- var _nav = U.MD.O.W.T.N.navData('新页面');
- //添加到导航信息数组里
- U.MD.O.W.T.N.navInfo.nav.push(_nav);
- //清空目录
- $('.U_MD_O_W_N_NavBox')[0].innerHTML = "";
- //重新从数据里获取最新的信息
- U.MD.O.W.T.N.createFirstTree(data, $('.U_MD_O_W_N_NavBox')[0]);
- //移除目录选中样式
- for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
- $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
- }
- var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
- //选中新添加的目录
- _treeNav.style.background = "#ccebf8";
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
- //打印导航
- var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
- //默认执行导航双击事件 触发修改
- _navel.ondblclick();
- //切换记录当前操作的页面ID
- U.MD.O.W.T.N.nowNavId = _nav.pageId;
- //情况页面内容
- $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
- //设置选中样式
- U.MD.O.W.T.N.setHoverClass();
- }, true);
- });
- if ($('.U_MD_O_W_T_N_addCBox')[0]) {
- var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
- _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
- }
- }
- /**
- * 添加子页面点击事件
- * ele {element} 获取你点击的元素
- * data {array} 数据信息
- *parent {element} 获取你点击的父级
- */
- U.MD.O.W.T.N.addChildOnClick = function (ele, data, parent) {
- var _addele = ele;
- var _treenav = parent;
- if (_addele.flag == false) {
- if ($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]) {
- _treenav.removeChild($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]);
- }
- for (var l = 0; l < data[_addele.i].child.length; l++) {//子目录已经存在,删除子目录
- _addele.removeChild($('#U_MD_O_W_T_N_' + data[_addele.i].child[l].pageId)[0]);
- }
- }
- U.MD.O.W.T.N.saveNav(function () {
- U.MD.O.W.T.N.savePage(function () {
- //创建新的导航
- var _nav = U.MD.O.W.T.N.navData('新页面');
- for (var i = 0; i < data.length; i++) { //循环找到你要添加子目录的目录
- if (data[i].pageId == _addele.pageId) {
- if ($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]) {//如果查看标签已经存在,则删除标签
- var _checkParent = $('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0].parentNode;
- _checkParent.removeChild($('#U_MD_O_W_T_N_checkDiv' + _addele.pageId)[0]);
- }
- $$('div', {//创建查看标签
- 'className': 'U_MD_O_W_T_N_checkDiv',
- 'style': {
- 'background': 'url(../../../img/U_MD_O_W_T_N_check.png) center no-repeat;',
- 'background-size': '100%;'
- },
- 'id': 'U_MD_O_W_T_N_checkDiv' + _addele.pageId
- },
- _treenav);
- _addele.flag = false;
- if (data[i].child) { //判断是否已经有child,有则直接插入,没有则创建数组再插入
- //添加到导航信息数组里
- data[i].child.push(_nav);
- U.MD.O.W.T.N.createFirstTree(data[i].child, _addele); //重新从数据里获取最新的信息
- } else {
- data[i].child = new Array();
- //添加到导航信息数组里
- data[i].child.push(_nav);
- U.MD.O.W.T.N.createFirstTree(data[i].child, _addele); //重新从数据里获取最新的信息
- }
- }
- }
- for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
- $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
- var _treeNavParent = $('.U_MD_O_W_T_N_treeNav')[i].parentNode;
- // 隐藏增删改按钮
- $('#U_MD_O_W_T_N_update' + _treeNavParent.pageId)[0].style.display = "none";
- $('#U_MD_O_W_T_N_add' + _treeNavParent.pageId)[0].style.display = "none";
- $('#U_MD_O_W_T_N_delete' + _treeNavParent.pageId)[0].style.display = "none";
- }
- $('#U_MD_O_W_T_N_span' + _addele.pageId)[0].style.cssText += "margin-left:5px";
- var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
- _treeNav.style.background = "#ccebf8";
- //执行修改按钮点击事件
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
- //打印导航
- var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
- //默认执行导航双击事件 触发修改
- _navel.ondblclick();
- //切换记录当前操作的页面ID
- U.MD.O.W.T.N.nowNavId = _nav.pageId;
- //情况页面内容
- $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
- //设置选中样式
- U.MD.O.W.T.N.setHoverClass();
- }, true);
- });
- //如果添加选项窗口还存在就移除窗口
- if ($('.U_MD_O_W_T_N_addCBox')[0]) {
- var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
- _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
- }
- }
- /**
- * 在下方添加页面点击事件
- * ele {element} 获取你点击的元素
- * data {array} 数据信息
- *parent {element} 获取你点击的父级
- */
- U.MD.O.W.T.N.addPBelowOnClick = function (ele, data, parent) {
- var _addele = ele;
- var _treenav = parent;
- U.MD.O.W.T.N.saveNav(function () {
- U.MD.O.W.T.N.savePage(function () {
- //创建新的导航
- var _nav = U.MD.O.W.T.N.navData("新页面");
- var _parentNode = _addele.parentNode;
- if (_parentNode.pageId == null) { //判断是否是一级目录
- data.splice(_addele.i + 1, 0, _nav);
- _parentNode.innerHTML = ""; //清空目录
- U.MD.O.W.T.N.createFirstTree(data, _parentNode);
- } else {
- for (var i = 0; i < data.length; i++) { //在数据里查询你要插入的目录
- if (data[i].pageId == _addele.pageId) {
- for (var l = 0; l < data.length; l++) { //如果找到该目录则删除父亲目录下所有子目录
- _parentNode.removeChild($('#U_MD_O_W_T_N_' + data[l].pageId)[0]);
- }
- _parentNode.flag = false;
- data.splice(i + 1, 0, _nav); //在数据里你添加页面的目录上方插入数据
- U.MD.O.W.T.N.createFirstTree(data, _parentNode);
- break;
- }
- }
- }
- //移除目录选中样式
- for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
- $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
- }
- var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
- //选中新添加的目录
- _treeNav.style.background = "#ccebf8";
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
- //打印导航
- var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
- //默认执行导航双击事件 触发修改
- _navel.ondblclick();
- //切换记录当前操作的页面ID
- U.MD.O.W.T.N.nowNavId = _nav.pageId;
- //情况页面内容
- $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
- //设置选中样式
- U.MD.O.W.T.N.setHoverClass();
- }, true);
- });
- if ($('.U_MD_O_W_T_N_addCBox')[0]) {
- var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
- _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
- }
- }
- /**
- * 在上方添加页面点击事件
- * ele {element} 获取你点击的元素
- * data {array} 数据信息
- *parent {element} 获取你点击的父级
- */
- U.MD.O.W.T.N.addPAboveOnClick = function (ele, data, parent) {
- var _addele = ele;
- var _treenav = parent;
- U.MD.O.W.T.N.saveNav(function () {
- U.MD.O.W.T.N.savePage(function () {
- //创建新的导航
- var _nav = U.MD.O.W.T.N.navData('新页面');
- var _parentNode = _addele.parentNode;
- if (_parentNode.pageId == null) { //判断是否是一级目录
- data.splice(_addele.i, 0, _nav);
- _parentNode.innerHTML = ""; //清空目录
- U.MD.O.W.T.N.createFirstTree(data, _parentNode);
- } else {
- for (var i = 0; i < data.length; i++) { //在数据里查询你要插入的目录
- if (data[i].pageId == _addele.pageId) {
- for (var l = 0; l < data.length; l++) { //如果找到该目录则删除父亲目录下所有子目录
- _parentNode.removeChild($('#U_MD_O_W_T_N_' + data[l].pageId)[0]);
- }
- _parentNode.flag = false;
- data.splice(i, 0, _nav); //在数据里你添加页面的目录上方插入数据
- U.MD.O.W.T.N.createFirstTree(data, _parentNode);
- break;
- }
- }
- }
- //清空选中样式
- for (var i = 0; i < $('.U_MD_O_W_N_NavBox .U_MD_O_W_T_N_treeNav').length; i++) {
- $('.U_MD_O_W_T_N_treeNav')[i].style.background = '#fff';
- }
- var _treeNav = $('#U_MD_O_W_T_N_treenav' + _nav.pageId)[0];
- _treeNav.style.background = "#ccebf8";
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].onclick();
- //显示三个按钮
- $('#U_MD_O_W_T_N_update' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_add' + _nav.pageId)[0].style.display = "block";
- $('#U_MD_O_W_T_N_delete' + _nav.pageId)[0].style.display = "block";
- //打印导航
- var _navel = U.MD.O.W.T.N.Easy.Print(_nav, U.MD.O.W.T.N.navInfo.nav);
- //默认执行导航双击事件 触发修改
- _navel.ondblclick();
- //切换记录当前操作的页面ID
- U.MD.O.W.T.N.nowNavId = _nav.pageId;
- //情况页面内容
- $("#U_MD_O_H_wordEditor")[0].innerHTML = "";
- //设置选中样式
- U.MD.O.W.T.N.setHoverClass();
- }, true);
- });
- //如果添加选项窗口还存在就移除窗口
- if ($('.U_MD_O_W_T_N_addCBox')[0]) {
- var _cBoxParent = $('.U_MD_O_W_T_N_addCBox')[0].parentNode;
- _cBoxParent.removeChild($('.U_MD_O_W_T_N_addCBox')[0]);
- }
- }
- //#region 导航文档互联区域
- /**
- * 修改导航
- * @param navid {guid} 操作导航ID
- * @param name {string} 导航名称
- * @param cb {string} 回调函数
- * @param param {string} 回调函数参数
- */
- U.MD.O.W.T.N.updateNavMessage = function (navid, name, cb, param) {
- var _message = U.MD.O.W.T.N.navMessage('updateNav', { navId: navid, name: name }); //生成修改导航信息
- U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
- "us.nav": [_message]
- })], function (r) {
- if (U.UF.C.isFunction(cb)) {
- cb.apply(this, param);
- } else {
- console.log(r);
- }
- });
- }
- /**
- * 添加导航
- * @param parentid {guid} 父级导航ID
- * @param index {string} 添加位置
- * @param navinfo {object} 导航信息
- */
- U.MD.O.W.T.N.addNavMessage = function (parentid, index, navinfo, content, cb, param) {
- var _message = U.MD.O.W.T.N.navMessage('addNav', { parentId: parentid, index: index, addNav: navinfo, content: content }); //生成添加导航信息
- U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
- "us.nav": [_message]
- })], function (r) {
- if (U.UF.C.isFunction(cb)) {
- cb.apply(this, param);
- } else {
- console.log(r);
- }
- });
- }
- /**
- * 修改导航
- * navid {guid} 操作导航ID
- * parentid {guid} 父级导航ID
- */
- U.MD.O.W.T.N.deleteNavMessage = function (navid, parentid, cb, param) {
- var _message = U.MD.O.W.T.N.navMessage('deleteNav', { navId: navid, parentId: parentid, userId: US.userInfo.userid }); //生成删除导航信息
- U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
- "us.nav": [_message]
- })], function (r) {
- if (U.UF.C.isFunction(cb)) {
- cb.apply(this, param);
- } else {
- console.log(r);
- }
- });
- }
- /**
- * 更新logo
- * logo {url} logo路径
- */
- U.MD.O.W.T.N.updateLogoMessage = function (logo) {
- var _message = U.MD.O.W.T.N.navMessage('updateLogo', { logo: logo }); //生成删除导航信息
- U.A.Request(US.SCOKET, ["send", JSON.stringify({ //发送send请求
- "us.nav": [_message]
- })], function (r) { });
- }
- /**
- * 导航文档 消息类
- * type {string} 操作类型
- * message {object} 自定义参数
- */
- U.MD.O.W.T.N.navMessage = function (type, message) {
- var _data = {
- sendId: U.MD.O.W.userInfo.userid, //发送人id
- receiveId: U.MD.O.W.fileinfo.UserDirectoryID, //文件id
- // type: navid ? 'us.nav' : 'us.word', //消息类型 后台已判断 目前该参数无作用 因为前台传递时已往上扩展一级 其中已说明类型
- messageInfo: {
- type: type, //类型
- docId: U.MD.O.W.fileinfo.UserDirectoryID, //文档id
- pageId: US.pageId //当前页面id
- }
- };
- //如果存在自定义参数
- if (typeof message == 'object') {
- var _key; //定义变量
- for (_key in message) { //循环追加自定义参数
- _data.messageInfo[_key] = message[_key];
- }
- }
- //返回消息类
- return _data;
- };
- //#endregion
- //#region 轮训跟新
- Namespace.register("U.MD.O.W.T.N.Poll");
- /**
- * 跟新导航
- * ele {element} 获取你点击的元素
- * data {array} 数据信息
- * parent {element} 获取你点击的父级
- */
- U.MD.O.W.T.N.Poll.updateNav = function (message) {
- var _navinfo = U.MD.O.W.T.N.navInfo.nav;
- var _nav = U.MD.O.W.T.N.selectByNavId(_navinfo, message.navId);
- if (_nav) { //判断是否存在
- _nav.name = message.name; //替换名字
- $('#U_MD_O_W_T_N_span' + message.navId)[0] && ($('#U_MD_O_W_T_N_span' + message.navId)[0].innerHTML = _nav.name); //修改名字
- $('#Word_Nav_' + message.navId)[0].innerHTML = _nav.name; //修改名字
- }
- }
- /**
- * 添加导航
- * ele {element} 获取你点击的元素
- * data {array} 数据信息
- * parent {element} 获取你点击的父级
- */
- U.MD.O.W.T.N.Poll.addNav = function (message) {
- var _parent, _navinfo = U.MD.O.W.T.N.navInfo.nav;
- if (message.parentId) {
- _parent = U.MD.O.W.T.N.selectByNavId(_navinfo, message.parentId);
- //如果已存在子级处理
- if (_parent.child) {
- //插入指定位置
- _parent.child.splice(message.index, 0, message.addNav);
- } else {
- // 为存在子级则新建子级
- _parent.child = [message.addNav];
- }
- } else {
- _parent = _navinfo;
- _parent.splice(message.index, 0, message.addNav);
- U.MD.O.W.T.N.Easy.Print(message.addNav, _parent, message.index);
- }
- //执行打印 复杂版本
- }
- /**
- * 删除导航
- * ele {element} 获取你点击的元素
- * data {array} 数据信息
- * parent {element} 获取你点击的父级
- */
- U.MD.O.W.T.N.Poll.deleteNav = function (message) {
- // 寻找父级
- var _child;
- if (message.parentId) {
- var _navinfo = U.MD.O.W.T.N.navInfo.nav;
- var _parent = U.MD.O.W.T.N.selectByNavId(_navinfo, message.parentId);
- _child = _parent.child;
- } else {
- _child = U.MD.O.W.T.N.navInfo.nav;
- }
- if (_child) {
- _child.every(function (object, index) {
- if (object.pageId == message.navId) {
- U.MD.O.W.T.N.deleteNav.asyn(object, index, message.userId, _child);
- return false;
- }
- return true;
- });
- }
- }
- /**
- * 更新logo信息
- * ele {element} 获取你点击的元素
- * data {array} 数据信息
- * parent {element} 获取你点击的父级
- */
- U.MD.O.W.T.N.Poll.updateLogo = function (message) {
- U.MD.O.W.T.N.navInfo.logo = message.logo;
- //修改logo元素src
- }
- //#endregion
|