/* 此js用来处理导航模板 */ Namespace.register("U.Office.N"); //导航模板命名空间 //导航模板功能。原名U.O.W.Navigation,缩写:U.O.W.NV Namespace.register("U.O.W.NV"); U.MD.O.Editable = false; //word打印 if (U.MD.O.W && U.MD.O.W.Edit) { U.MD.O.W.Edit() }; U.Office.N.Nav = 0; //初始化函数 window.onload = function () { U.Office.N.load(); } //初始化函数 初始化模板 U.Office.N.load = function () { if (window.location.host != "www.1473.cn" && $("#navg")[0]) { //通过office生成站点处理 $("div").addAttrArray({ "contentEditable": "false" }); $("#navg&i").remove(); } }; /** *函数作用:判断是否添加导航 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.isNavg = function () { if ($(".U_Boom_O_N_Navg_I").length > 0) { return }; var e = event || window.event; var FirstTop = $(".U_MD_O_H_body_main_text")[0].offsetTop; var SecTop = $("#U_MD_O_W_E_body")[0].offsetTop; var FirstLeft = $(".U_MD_O_H_body_main_text")[0].offsetLeft; var SecLeft = $(".U_MD_F_S")[0].offsetLeft; var top = e.clientY - FirstTop - SecTop; var left = e.clientX - FirstLeft - SecLeft; //var left = event.x, top = event.y; //获取鼠标点击的位置 U.UF.EV.stopBubble(); //阻止冒泡事件 var i, a, m, g, U_Boom_O_N_C_Navg; source = event.srcElement; //获取事件源 U_Boom_O_N_C_Navg = document.getElementsByClassName("U_Boom_O_N_C_Navg")[0]; //获取第一个导航栏 i = $$("div", { "class": "U_Boom_O_N_Navg_I", "id": "U_Boom_O_N_Navg_Ib", "source": source, "style": { "left": left + "px", "top": top + "px" } }, U_Boom_O_N_C_Navg); //"source":source 获取上一级的事件源 m = $$("div", { "class": "U_Boom_O_N_Navg_S", "innerHTML": "前面插入", "id": "U_Boom_O_N_Navg_S2", "onclick": function () { U.Office.N.AddNavg(1, source.parentElement); } }, i); //动态创建前面插入 n = $$("div", { "class": "U_Boom_O_N_Navg_S", "innerHTML": "后面插入", "id": "U_Boom_O_N_Navg_S4", "onclick": function () { U.Office.N.AddNavg(2, source.parentElement); } }, i); //动态创建后面插入 var U_Boom_O_N_Navg_I = $(".U_Boom_O_N_Navg_I")[0]; U_Boom_O_N_Navg_I.style.display = "block"; } /** *函数作用:移除插入导航 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.noNavg = function () { $("#U_Boom_O_N_Navg_Ib").remove(); //移除插入导航 $(".U_MD_O_H_body_main_text")[0].setAttribute('contenteditable', 'false'); //移除word编辑器自带的编辑效果 var FirstNav = event.srcElement; //获取点击元素 if (FirstNav.className == "U_Boom_O_N_C_Navg_Li_font") {//判断点击是否是导航栏 FirstNav.onkeydown = function () {//键盘事件 if (FirstNav.parentNode.parentNode.children[1]) {//判断点击元素是否有二级导航栏 FirstNav.parentNode.parentNode.children[1].children[0].innerHTML = FirstNav.innerHTML; //改变二级导航栏的标题 } } } } /** *函数作用:添加二级导航 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.secNavg = function () { var daohangli = $(".U_Boom_O_N_C_Navg_Li"); //获取一级导航栏的第一个li for (var k = 0; k < daohangli.length; k++) {//循环遍历所有的一级导航 var fontnav = event.srcElement.parentElement.parentElement.children[1].children[0].children[0].children; //获取每个导航的字体颜色 if (fontnav[k].children[0].children[0].style.color == "rgb(255, 255, 255)") {//通过颜色判断是哪个一级导航获得焦点 var navgbox1 = event.srcElement.parentElement.parentElement.children[1].children[0].children[0].children[k]; //判断有没有二级导航,没有就创建,有就不允许创建 if (navgbox1.children[1] == undefined) {//判断是否有二级导航 var numli = $(".U_Boom_O_N_C_Navg_Li"); //获取所有的一级导航li var nav = event.srcElement.parentElement.parentElement.children[0].children[0]; //通过点击事件的事件源获取一级导航栏第一个导航 var id2 = fontnav[k].id; //获取有焦点的一级导航的id var nav2html = fontnav[k].children[0].children[0].innerHTML; //获取取得的一级的内容 var box1 = id2.split("_")[1]; //截取id的下标1的字符串 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 var length = nav.parentNode.children.length + 1, //获取一级导航栏的长度,并且加一 idnav2 = id2 + "_" + 1, length2 = nav.parentNode.children.length, //获取一级导航栏的长度 cname = "U_Boom_O_N_C_Navg2_Li Navg_Li1_" + length, //给每一个导航的classname进行规律增加 dname = "U_Boom_O_N_C_C_O Sub_Li1_" + length; //给每一个内容页面的classname进行规律增加 //改变内容页距离顶部的高度 contant.style.cssText = "margin-top:45px!important"; var sub = $(".U_Boom_O_N_C_C_O"); //获取内容页面 for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; //隐藏所有内容页面 } //内容页面 //var contant = $("#U_Boom_O_N_C_Container"); //获取内容页面大的盒子 var c = $$("div",{"className": dname,"tebindex": "0","hidefocus": "true","contenteditable": "true","type": "1"},contant); //动态创建内容页面,并且把前面定义的classname:dname加在这里 var cont = $$("div",{"innerHTML": "请在此处添加内容..."},c); //动态创建内容页面 //动态创建二级导航 var Navgbox2, navg2, ul, ulnav, li, font, close, add, addnav, delnav, delimg, deltxt, daohang2; navg2 = $$("div",{"className": "U_Boom_O_N_C_Navg2"},navgbox1); //动态穿件二级导航栏第二个盒子 ulnav = $$("div",{"className": "U_Boom_O_N_C_Navg_Ul_Nav","innerHTML": nav2html},navg2); delnav = $$("div", { "className": "U_Boom_O_N_C_Navg_Ul_Nav_Del", "title": "删除整体子级导航栏", "onclick": [[U.Office.N.delsecNavg]] }, navg2); //U.Office.N.delsecNavg点击事件,删除所有子导航 delimg = $$("div",{"className": "U_Boom_O_N_C_Navg_Del_Img"},delnav); ul = $$("div",{"className": "U_Boom_O_N_C_Navg2_ul"},navg2); li = $$("div",{"className": cname,"id": idnav2},ul); //U.Office.N.ChangeNavg, [c]点击事件,切换导航,参数c为创建的内容页,便于切换 daohang2 = $$("div",{"className": "U_Boom_O_N_Navg_Ul_daohang2"},li); font = $$("div", { "className": "U_Boom_O_N_C_Navg_Li_font", "contenteditable": "true", "innerHTML": "二级导航一", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang2); close = $$("div", { "className": "U_Boom_O_N_C_N_Close", "title": "删除", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang2); //U.Office.N.DeleteNavg, [c]点击事件,删除一个导航和该导航对应的内容页 add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang2); //U.Office.N.isNavg点击事件,是否添加导航 addnav = $$("div", { "className": "U_Boom_O_N_C_Navg_Ul_Nav_Add", "title": "创建三级导航栏", "onclick": function () { U.Office.N.thirdNavg() } }, navg2); //U.Office.N.thirdNavg点击事件,添加三级导航 addtxt = $$("div",{"className": "U_Boom_O_N_C_Navg_Add_Txt","title": "创建三级导航栏", "innerHTML": "添加"},addnav); U.alert("添加成功"); } else { U.UF.UI.confirm("已创建二级导航,请勿多次创建!"); } } } } /** *函数作用:添加三级导航 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.thirdNavg = function () { var daohangli2 = event.srcElement.parentElement.parentElement.children[2].children; //通过点击事件的事件源获取二级导航的li for (var k = 0; k < daohangli2.length; k++) {//判断 var thirdbox = daohangli2[k]; var fontnav2 = thirdbox.children[0].children[0]; //获取字体 if (fontnav2.style.color == "rgb(255, 255, 255)") { var nav = event.srcElement.parentElement.parentElement.children[3].children[0]; var thirdnav = event.srcElement.parentElement.parentElement.children[2].children[k].children[1]; if (thirdnav == undefined) { var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 var id3 = fontnav2.parentNode.parentNode.id; //通过点击事件事件源获取二级导航的li的id var idnav3 = id3.substring(0, 7) + "_" + 1; var box1 = id3.substring(4, 6); //substring(开始点,终止点) 截取字符串 var length = nav.parentElement.parentElement.children[2].children.length + 1, cname = "U_Boom_O_N_C_Navg2_Li Navg_Li2_" + length, dname = "U_Boom_O_N_C_C_O Sub_Li2_" + length; //改变内容页距离顶部的高度 contant.style.cssText = "margin-top:90px!important"; //隐藏所有的内容页 var sub = $(".U_Boom_O_N_C_C_O"); for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; } //动态创建内容页面 //var contant = $("#U_Boom_O_N_C_Container")[0]; var c = $$("div", { "className": dname, "tebindex": "0", "hidefocus": "true", "contenteditable": "true", "type": "1" }, contant); var cont = $$("div",{"innerHTML": "请在此处添加内容..."},c); //动态创建三级导航 var Navg3, ul, li, font, close, add, daohang3; Navg3 = $$("div",{"className": "U_Boom_O_N_C_Navg3"},thirdbox); ul = $$("div",{"className": "U_Boom_O_N_C_Navg3_ul"},Navg3); li = $$("div",{"className": cname,"id": idnav3},ul); daohang3 = $$("div",{"className": "U_Boom_O_N_Navg_Ul_daohang2 U_Boom_O_N_Navg_Ul_daohang3"},li); font = $$("div", { "className": "U_Boom_O_N_C_Navg_Li_font", "contenteditable": "true", "innerHTML": "三级导航一", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang3); close = $$("div", { "className": "U_Boom_O_N_C_N_Close", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang3); add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang3); U.alert("添加成功"); } else { U.UF.UI.confirm("已创建三级导航,请勿多次创建!", null, null); } } } } /** *函数作用:添加导航 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.AddNavg = function (n, El) { var U_Boom_O_N_C_Navg_Ul = $("#U_Boom_O_N_C_Navg_Ul")[0]; //获取一级导航栏 var nav = $(".U_Boom_O_N_C_Navg_Li")[0]; var U_Boom_O_N_C_Navg_Ul2 = El.parentElement; //获取事件源的ul盒子 var nav2 = El.parentElement; //获取二级或三级的li var daohangli = $(".U_Boom_O_N_C_Navg_Li"); switch (n) { case 1: U.Office.N.beforeNavg(U_Boom_O_N_C_Navg_Ul, U_Boom_O_N_C_Navg_Ul2, nav, nav2, nav2.id); break; case 2: U.Office.N.belastNavg(U_Boom_O_N_C_Navg_Ul, U_Boom_O_N_C_Navg_Ul2, nav, nav2, nav2.id); break; } } /** *函数作用:添加导航————向前插入 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.beforeNavg = function (U_Boom_O_N_C_Navg_Ul, U_Boom_O_N_C_Navg_Ul2, nav, nav2, id2) { var ul2 = $(".U_Boom_O_N_C_Navg2_ul"); var ul3 = $(".U_Boom_O_N_C_Navg3_ul"); if (event.srcElement.parentNode.source.parentNode.parentNode.parentNode == U_Boom_O_N_C_Navg_Ul) {//判断点击的插入是否在一级导航栏 U.alert("插入成功"); var length = nav.parentNode.children.length + 1, cname = "U_Boom_O_N_C_Navg_Li Navg_Li_" + length, dname = "U_Boom_O_N_C_C_O Sub_Li_" + length, idnav = "Nav_" + length; //隐藏所有的内容页面 var sub = $(".U_Boom_O_N_C_C_O"); for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; } //内容页面 var contant = $("#U_Boom_O_N_C_Container")[0]; var c = $$("div",{"className": dname,"tebindex": "0","hidefocus": "true","contenteditable": "true","type": "1"},contant); var cont = $$("div",{"innerHTML": "请在此处添加内容..."},c); //清除所有字体颜色 var dh = $("#U_Boom_O_N_C_Navg_Ul")[0].children; for (var i = 0; i < dh.length; i++) { dh[i].children[0].children[0].style.color = "#000"; } //清除所有的背景颜色 for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#dadde2"; } //隐藏二级导航 var U_Boom_O_N_C_Navg2 = $(".U_Boom_O_N_C_Navg2"); for (var a = 0; a < U_Boom_O_N_C_Navg2.length; a++) { U_Boom_O_N_C_Navg2[a].style.display = "none"; } //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:-25px!important"; //导航创建 var li = $$("div",{"className": cname,"style":{"display": "block"},"id": idnav},U_Boom_O_N_C_Navg_Ul); var daohang = $$("div",{"className": "U_Boom_O_N_C_Navg_Ul_daohang"},li) var navg = $$("div", { "class": "U_Boom_O_N_C_Navg_Li_font", "contentEditable": "true", "innerHTML": "新增导航", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang); var i = $$("div", { "className": "U_Boom_O_N_C_N_Close", "title": "删除", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang); var add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang) var sou = event.srcElement.parentNode.source.parentNode.parentNode; //获取事件源 var event_source = sou; //获取事件源 nav.parentNode.insertBefore(li, event_source); //向点击的导航的前面新建一个导航 } for (var u = 0; u < ul2.length; u++) { if (event.srcElement.parentNode.source.parentNode.parentNode.parentNode == ul2[u]) {//判断是否为二级导航栏的ul U.alert("插入成功"); var length = nav2.parentNode.children.length + 1, cname = "U_Boom_O_N_C_Navg2_Li Navg_Li1_" + length, dname = "U_Boom_O_N_C_C_O Sub_Li1_" + length, idnav2 = id2.substring(0, 5) + "_" + length; //隐藏所有的内容页面 var sub = $(".U_Boom_O_N_C_C_O"); for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; } //内容页面 var contant = $("#U_Boom_O_N_C_Container")[0]; var c = $$("div", { "className": dname, "tebindex": "0", "hidefocus": "true", "contenteditable": "true", "type": "1" }, contant); var cont = $$("div",{"innerHTML": "请在此处添加内容..."},c); //清除所有字体颜色 var dh = ul2[u].children; for (var a = 0; a < dh.length; a++) { dh[a].children[0].children[0].style.color = "#656f83"; } //清除所有的背景颜色 for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#efefef"; } //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:45px!important"; //清除三级导航 var U_Boom_O_N_C_Navg3 = $(".U_Boom_O_N_C_Navg3"); for (var b = 0; b < U_Boom_O_N_C_Navg3.length; b++) { U_Boom_O_N_C_Navg3[b].style.display = "none"; } //导航创建 var li = $$("div",{"className": cname,"style": {"display": "block"},"id": idnav2},U_Boom_O_N_C_Navg_Ul2); var daohang2 = $$("div",{"className": "U_Boom_O_N_Navg_Ul_daohang2"},li) var navg = $$("div", { "class": "U_Boom_O_N_C_Navg_Li_font", "contentEditable": "true", "innerHTML": "新增子级导航", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang2); var i = $$("div", { "className": "U_Boom_O_N_C_N_Close", "title": "删除", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang2); var add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang2) var sou = event.srcElement.parentNode.source.parentNode.parentNode; //获取事件源 var event_source = sou; nav2.parentNode.insertBefore(li, event_source); //向点击的导航的前面新建一个导航 } } for (var l = 0; l < ul3.length; l++) { if (event.srcElement.parentNode.source.parentNode.parentNode.parentNode == ul3[l]) {//判断是否是三级导航的ul U.alert("插入成功"); var length = nav2.parentNode.children.length + 1, cname = "U_Boom_O_N_C_Navg2_Li Navg_Li2_" + length, dname = "U_Boom_O_N_C_C_O Sub_Li2_" + length, idnav3 = id2.substring(0, 7) + "_" + length; //隐藏所有的内容页面 var sub = $(".U_Boom_O_N_C_C_O"); for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; } //内容页面 var contant = $("#U_Boom_O_N_C_Container")[0]; var c = $$("div", { "className": dname, "tebindex": "0", "hidefocus": "true", "contenteditable": "true", "type": "1" }, contant); var cont = $$("div",{"innerHTML": "请在此处添加内容..."},c); //清除所有字体颜色 var dh = ul3[l].children; for (var a = 0; a < dh.length; a++) { dh[a].children[0].children[0].style.color = "#656f83"; } //清除所有的背景颜色 for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#efefef"; } //导航创建 var li = $$("div",{"className": cname,"style":{"display": "block"},"id": idnav3},U_Boom_O_N_C_Navg_Ul2); var daohang3 = $$("div",{"className": "U_Boom_O_N_Navg_Ul_daohang2 U_Boom_O_N_Navg_Ul_daohang3"},li) var navg = $$("div", { "class": "U_Boom_O_N_C_Navg_Li_font", "contentEditable": "true", "innerHTML": "新增子级导航", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang3); var i = $$("div", { "className": "U_Boom_O_N_C_N_Close", "title": "删除", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang3); var add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang3) var sou = event.srcElement.parentNode.source.parentNode.parentNode; //获取事件源 var event_source = sou; nav2.parentNode.insertBefore(li, event_source); //向点击的导航的前面新建一个导航 } } } /** *函数作用:添加导航————向后插入 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.belastNavg = function (U_Boom_O_N_C_Navg_Ul, U_Boom_O_N_C_Navg_Ul2, nav, nav2, id2) { var ul2 = $(".U_Boom_O_N_C_Navg2_ul"); var ul3 = $(".U_Boom_O_N_C_Navg3_ul"); if (event.srcElement.parentNode.source.parentNode.parentNode.parentNode == U_Boom_O_N_C_Navg_Ul) {//判断点击的插入是否在一级导航栏 U.alert("插入成功"); var length = nav.parentNode.children.length + 1, cname = "U_Boom_O_N_C_Navg_Li Navg_Li_" + length, dname = "U_Boom_O_N_C_C_O Sub_Li_" + length, idnav = "Nav_" + length; //隐藏所有的内容页 var sub = $(".U_Boom_O_N_C_C_O"); for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; } //内容页面 var contant = $("#U_Boom_O_N_C_Container")[0]; var c = $$("div", { "className": dname, "tebindex": "0", "hidefocus": "true", "contenteditable": "true", "type": "1" }, contant); var cont = $$("div", { "innerHTML": "请在此处添加内容..." }, c); //清除所有字体颜色 var dh = $("#U_Boom_O_N_C_Navg_Ul")[0].children; for (var i = 0; i < dh.length; i++) { dh[i].children[0].children[0].style.color = "#000"; } //清除所有的背景颜色 for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#dadde2"; } //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:-25px!important"; //清除二级导航 var U_Boom_O_N_C_Navg2 = $(".U_Boom_O_N_C_Navg2"); for (var a = 0; a < U_Boom_O_N_C_Navg2.length; a++) { U_Boom_O_N_C_Navg2[a].style.display = "none"; } //导航创建 var li = $$("div", { "className": cname, "style": { "display": "block" }, "id": idnav }, U_Boom_O_N_C_Navg_Ul); var daohang = $$("div", { "className": "U_Boom_O_N_C_Navg_Ul_daohang" }, li) var navg = $$("div", { "class": "U_Boom_O_N_C_Navg_Li_font", "contentEditable": "true", "innerHTML": "新增导航", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang); var i = $$("div", { "className": "U_Boom_O_N_C_N_Close", "title": "删除", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang); var add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang) var sou = event.srcElement.parentNode.source.parentNode.parentNode; //获取事件源 var event_source = sou; //获取事件源 nav.parentNode.insertBefore(li, event_source.nextSibling); //向点击的导航的前面新建一个导航 } for (var u = 0; u < ul2.length; u++) { if (event.srcElement.parentNode.source.parentNode.parentNode.parentNode == ul2[u]) {//判断是否为二级导航栏的ul U.alert("插入成功"); var length = nav2.parentNode.children.length + 1, cname = "U_Boom_O_N_C_Navg2_Li Navg_Li1_" + length, dname = "U_Boom_O_N_C_C_O Sub_Li1_" + length, idnav2 = id2.substring(0, 5) + "_" + length; var sub = $(".U_Boom_O_N_C_C_O"); for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; } //内容页面 var contant = $("#U_Boom_O_N_C_Container")[0]; var c = $$("div", { "className": dname, "tebindex": "0", "hidefocus": "true", "contenteditable": "true", "type": "1" }, contant); var cont = $$("div", { "innerHTML": "请在此处添加内容..." }, c); //清除所有字体颜色 var dh = ul2[u].children; for (var a = 0; a < dh.length; a++) { dh[a].children[0].children[0].style.color = "#656f83"; } //清除所有的背景颜色 for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#efefef"; } //清除三级导航 var U_Boom_O_N_C_Navg3 = $(".U_Boom_O_N_C_Navg3"); for (var b = 0; b < U_Boom_O_N_C_Navg3.length; b++) { U_Boom_O_N_C_Navg3[b].style.display = "none"; } //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:45px!important"; //导航创建 var li = $$("div", { "className": cname, "style": { "display": "block" }, "id": idnav2 }, U_Boom_O_N_C_Navg_Ul2); var daohang2 = $$("div", { "className": "U_Boom_O_N_Navg_Ul_daohang2" }, li) var navg = $$("div", { "class": "U_Boom_O_N_C_Navg_Li_font", "contentEditable": "true", "innerHTML": "新增子级导航", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang2); var i = $$("div", { "className": "U_Boom_O_N_C_N_Close", "title": "删除", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang2); var add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang2) var sou = event.srcElement.parentNode.source.parentNode.parentNode; //获取事件源 var event_source = sou; nav2.parentNode.insertBefore(li, event_source.nextSibling); //向点击的导航的前面新建一个导航 } } for (var l = 0; l < ul3.length; l++) { if (event.srcElement.parentNode.source.parentNode.parentNode.parentNode == ul3[l]) {//判断是否是三级导航的ul U.alert("插入成功"); var length = nav2.parentNode.children.length + 1, cname = "U_Boom_O_N_C_Navg2_Li Navg_Li2_" + length, dname = "U_Boom_O_N_C_C_O Sub_Li2_" + length, idnav3 = id2.substring(0, 7) + "_" + length; var sub = $(".U_Boom_O_N_C_C_O"); for (var j = 0; j < sub.length; j++) { sub[j].style.display = "none"; } //内容页面 var contant = $("#U_Boom_O_N_C_Container")[0]; var c = $$("div", { "className": dname, "tebindex": "0", "hidefocus": "true", "contenteditable": "true", "type": "1" }, contant); var cont = $$("div", { "innerHTML": "请在此处添加内容..." }, c); //清除所有字体颜色 var dh = ul3[l].children; for (var a = 0; a < dh.length; a++) { dh[a].children[0].children[0].style.color = "#656f83"; } //清除所有的背景颜色 for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#efefef"; } //导航创建 var li = $$("div", { "className": cname, "style": { "display": "block" }, "id": idnav3 }, U_Boom_O_N_C_Navg_Ul2); var daohang3 = $$("div", { "className": "U_Boom_O_N_Navg_Ul_daohang2 U_Boom_O_N_Navg_Ul_daohang3" }, li); var navg = $$("div", { "class": "U_Boom_O_N_C_Navg_Li_font", "contentEditable": "true", "innerHTML": "新增子级导航", "style": { "color": "#fff" }, "onclick": function () { U.Office.N.ChangeNavg(c); } }, daohang3); var i = $$("div", { "className": "U_Boom_O_N_C_N_Close", "title": "删除", "onclick": function () { U.Office.N.DeleteNavg(this, c); } }, daohang3); var add = $$("div", { "className": "U_Boom_O_N_C_N_AddNav", "title": "编辑", "onclick": function () { U.Office.N.isNavg() } }, daohang3) var sou = event.srcElement.parentNode.source.parentNode.parentNode; //获取事件源 var event_source = sou; nav2.parentNode.insertBefore(li, event_source.nextSibling); //向点击的导航的前面新建一个导航 } } } /** *函数作用:导航切换 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.ChangeNavg = function (Ele) { var sub = $(".U_Boom_O_N_C_C_O"); //获取内容页面 var del = event.srcElement; //获取事件源 var delnavg = del.parentNode; //获取点击事件的父级元素 //var dh = $(".U_Boom_O_N_C_Navg_Ul_daohang"); var dh1 = $(".U_Boom_O_N_Navg_Ul_daohang2"); var fontcolor = $(".U_Boom_O_N_C_Navg_Li_font"); var ifnavid = $("#U_Boom_O_N_C_Navg_Ul")[0].id; //获取一级导航栏的id type = 1; //隐藏所有的内容页 for (var i = 0; i < sub.length; i++) { sub[i].style.display = "none"; } $(Ele)[0].style.display = "block"; //点击的导航栏对应的页面显示 //一级导航切换 if (event.srcElement.parentElement.parentElement.parentElement.id == ifnavid) { var dh = $("#U_Boom_O_N_C_Navg_Ul")[0].children; for (var h = 0; h < dh1.length; h++) { dh1[h].style.backgroundColor = "#efefef"; dh1[h].children[0].style.color = "#656f83"; } for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#dadde2"; } delnavg.style.backgroundColor = "#000" for (var f = 0; f < dh.length; f++) { dh[f].children[0].children[0].style.color = "#000"; } del.style.color = "#fff"; var secnav = event.srcElement.parentElement.parentElement.children[1]; var Navg2 = $(".U_Boom_O_N_C_Navg2"); for (var n = 0; n < Navg2.length; n++) { Navg2[n].style.display = "none"; } //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 var type = contant.children; contant.style.cssText = "margin-top:-25px!important"; if (secnav != undefined) {//判断是否有二级导航栏 secnav.style.display = "block"; var secnav1 = secnav.children[2].children; for (var s = 0; s < secnav1.length; s++) { if (secnav1[s].children[1] != undefined) { secnav1[s].children[1].style.display = "none"; } } for (var c = 0; c < type.length; c++) { if (type[c].type == 1) { contant.style.cssText = "margin-top:45px!important"; } else if (type[c].type == 2) { contant.style.cssText = "margin-top:-25px!important"; } } } } //二级导航切换 var secid = $(".U_Boom_O_N_C_Navg2"); for (var s = 0; s < secid.length; s++) { if (event.srcElement.parentElement.parentElement.parentElement.parentElement.className == secid[s].className) { var dh = secid[s].children[2].children; for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#efefef"; } delnavg.style.backgroundColor = "#000" for (var f = 0; f < dh.length; f++) { dh[f].children[0].children[0].style.color = "#656f83"; } del.style.color = "#fff"; var thirdnav = event.srcElement.parentElement.parentElement.children[1]; var Navg3 = $(".U_Boom_O_N_C_Navg3"); for (var a = 0; a < Navg3.length; a++) { Navg3[a].style.display = "none"; } //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 var type = contant.children; for (var t = 0; t < type.length; t++) { if (type[t].type == 1) { contant.style.cssText = "margin-top:45px!important"; } else if (type[t].type == 2) { contant.style.cssText = "margin-top:-25px!important"; } } if (thirdnav != undefined) { thirdnav.style.display = "block"; for (var y = 0; y < type.length; y++) { if (type[y].type == 1) { contant.style.cssText = "margin-top:90px!important"; } else if (type[y].type == 2) { contant.style.cssText = "margin-top:-25px!important"; } } } var thili = $(".U_Boom_O_N_Navg_Ul_daohang3"); for (var j = 0; j < thili.length; j++) { thili[j].style.backgroundColor = "#efefef"; thili[j].children[0].style.color = "#656f83"; } var firli = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.children; var firli1 = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children; for (var i = 0; i < firli1.length; i++) { firli1[i].children[0].style.backgroundColor = "#dadde2"; firli1[i].children[0].children[0].style.color = "#000"; } firli[0].style.backgroundColor = "#000"; firli[0].children[0].style.color = "#fff"; } } //三级导航切换 var thirdid = $(".U_Boom_O_N_C_Navg3"); for (var t = 0; t < thirdid.length; t++) { if (event.srcElement.parentElement.parentElement.parentElement.parentElement.className == thirdid[t].className) { var dh = thirdid[t].children[0].children; for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#efefef"; } delnavg.style.backgroundColor = "#000" for (var f = 0; f < dh.length; f++) { dh[f].children[0].children[0].style.color = "#656f83"; } del.style.color = "#fff"; var secli = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.children; var secli1 = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children; for (var i = 0; i < secli1.length; i++) { secli1[i].children[0].style.backgroundColor = "#efefef"; secli1[i].children[0].children[0].style.color = "#656f83" } secli[0].style.backgroundColor = "#000"; secli[0].children[0].style.color = "#fff"; var thrli = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children; var thrli1 = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children; for (var j = 0; j < thrli1.length; j++) { thrli1[j].children[0].style.backgroundColor = "#dadde2"; thrli1[j].children[0].children[0].style.color = "#000"; } thrli[0].style.backgroundColor = "#000"; thrli[0].children[0].style.color = "#fff"; //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 var type = contant.children; for (var t = 0; t < type.length; t++) { if (type[t].type == 1) { contant.style.cssText = "margin-top:90px!important"; } else if (type[t].type == 2) { contant.style.cssText = "margin-top:-25px!important"; } } } } } /** *函数作用:删除导航 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.DeleteNavg = function (e, Ele) { U.UF.EV.stopBubble(); //组织冒泡事件 if (U.Office.N.DeleteNavg.Que.Q) { U.Office.N.DeleteNavg.Que(e, Ele); U.Office.N.DeleteNavg.Que.Q = false; } else { U.UF.UI.confirm("您确定要删除已编辑的导航吗?", function () { U.Office.N.DeleteNavg.Que(e, Ele); }); } } /** *函数作用:删除导航弹窗 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期:2017-10-24 */ U.Office.N.DeleteNavg.Que = function (e, Ele) { var length = e.parentElement.parentElement.parentElement.children.length; //获取点击删除按钮后获取的事件源的长度 var ul1 = e.parentElement.parentElement.parentElement.id; var ul2 = e.parentElement.parentElement.parentElement.parentElement.className; var ulnav1 = $("#U_Boom_O_N_C_Navg_Ul")[0].id; var delnavg = e.parentNode.parentNode; //判断一级导航 if (ul1 == ulnav1) { if (length > 1) {//判断是否是最后一个导航 var Navg_ul = $(delnavg.parentNode.children).last()[0]; if (Navg_ul == delnavg) { U.alert("删除成功"); $(Ele)[0].remove(); $(delnavg)[0].remove(); var Navg_ul_last = $("#U_Boom_O_N_C_Navg_Ul")[0]; var Navg_last = $(Navg_ul_last.children).last()[0].children[0]; Navg_last.click(); //重新执行一边点击事件 } else { var Navg_next = $(delnavg).next()[0].children[0]; U.alert("删除成功"); $(Ele)[0].remove(); $(delnavg)[0].remove(); Navg_next.click(); //重新执行 } } //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:-25px!important"; } else { var ulnav2 = $(".U_Boom_O_N_C_Navg2")[0].className; //判断二级导航 if (ul2 == ulnav2) { if (length > 1) {//判断是否是最后一个导航 var Navg_ul = $(delnavg.parentNode.children).last()[0]; //判断点击时是否是最后一个的导航 if (Navg_ul == delnavg) { U.alert("删除成功"); $(Ele)[0].remove(); $(delnavg)[0].remove(); var Navg_ul_last = $(".U_Boom_O_N_C_Navg2")[0].children[2]; var Navg_last = $(Navg_ul_last.children).last()[0].children[0]; Navg_last.click(); //重新执行一边点击事件 } else { U.alert("删除成功"); var Navg_next = $(delnavg).next()[0].children[0]; $(Ele)[0].remove(); $(delnavg)[0].remove(); Navg_next.click(); //重新执行 } } else { var nav2del = e.parentElement.parentElement.parentElement.parentElement; var nav1first = e.parentElement.parentElement.parentElement.parentElement.parentElement.children[0].children[0]; U.alert("删除成功"); $(Ele)[0].remove(); $(delnavg)[0].remove(); nav2del.remove(); nav1first.click(); //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:-25px!important"; } } else { if (length > 1) {//判断是否是最后一个导航 var Navg_ul = $(delnavg.parentNode.children).last()[0]; if (Navg_ul == delnavg) { U.alert("删除成功"); $(Ele)[0].remove(); $(delnavg)[0].remove(); var Navg_ul_last = $(".U_Boom_O_N_C_Navg3")[0].children[0]; var Navg_last = $(Navg_ul_last.children).last()[0].children[0]; Navg_last.click(); //重新执行一边点击事件 } else { U.alert("删除成功"); var Navg_next = $(delnavg).next()[0].children[0]; $(Ele)[0].remove(); $(delnavg)[0].remove(); Navg_next.click(); //重新执行 } } else { var nav3del = e.parentElement.parentElement.parentElement.parentElement; var nav2first = e.parentElement.parentElement.parentElement.parentElement.parentElement.children[0].children[0]; U.alert("删除成功"); $(Ele)[0].remove(); $(delnavg)[0].remove(); nav3del.remove(); nav2first.click(); //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:45px!important"; } } } } /** *函数作用:删除子导航 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.delsecNavg = function () { var delnavg = event.srcElement.parentElement.parentElement; var navfirst = delnavg.parentElement.children[0].children[0]; U.Que = function () { var deletenav1 = delnavg.children[2].children; for (var d = 0; d < deletenav1.length; d++) { var delthird = deletenav1[d].children[1]; if (delthird != undefined) { var deletenav2 = deletenav1[d].children[1].children[0].children; for (var i = 0; i < deletenav2.length; i++) { this.i = i; U.Office.N.DeleteNavg.Que.Q = true; deletenav2[this.i].children[0].children[1].click(); } } this.d = d; U.Office.N.DeleteNavg.Que.Q = true; deletenav1[this.d].children[0].children[1].click(); } U.alert("删除成功"); delnavg.remove(); navfirst.click(); }; U.UF.UI.confirm("您确定要删除所有已编辑的子导航吗?", function () { U.Que(); }); //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:7px!important"; } /** *函数作用:插入logo和二维码 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.Insertpic = function (n) { var input = event.srcElement; switch (n) { case 1: U.Office.N.Headlogo(input); break; case 2: U.Office.N.Footlogo(input); break; case 3: U.Office.N.Twocode(input); break; } } /** *函数作用:头部logo *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.Headlogo = function (input) { U.UF.UP.inputUpload([input], function (r) { U.alert("插入成功"); var headlogo = $(".U_Boom_O_N_C_H_C_D_Logo")[0]; headlogo.innerHTML = ""; headlogo.style.backgroundImage = "url(http://fs.1473.cn/" + r.value[1] + ")"; }, [], "http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor") } /** *函数作用:底部logo *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.Footlogo = function (input) { U.UF.UP.inputUpload([input], function (r) { U.alert("插入成功"); var footlogo = $(".U_Boom_O_N_F_Fitst_Logo")[0]; footlogo.innerHTML = ""; footlogo.style.backgroundImage = "url(http://fs.1473.cn/" + r.value[1] + ")"; }, [], "http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor") } /** *函数作用:二维码 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.Twocode = function (input) { U.UF.UP.inputUpload([input], function (r) { U.alert("插入成功"); var footcode = $(".U_Boom_O_N_F_Last_Logo")[0]; footcode.innerHTML = ""; footcode.style.backgroundImage = "url(http://fs.1473.cn/" + r.value[1] + ")"; }, [], "http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor") } /** *函数作用:预览按钮 *@姓名:廖志伟 *@班级:14互联网G5-2班 *@日期“2017-10-14 */ U.Office.N.Preview = function () { var element = $("*"); //获取所有标签 var elementclose = $(".U_Boom_O_N_C_N_Close"); //获取删除按钮 var elementadd = $(".U_Boom_O_N_C_N_AddNav"); //获取添加按钮 var delchange = $(".U_Boom_O_N_C_H_C_Input"); //获取插入头部logo var delinput = $(".U_Boom_O_N_C_H_C_F_Input"); //获取插入底部logo和二维码 var elementsec = $(".U_Boom_O_N_C_Navg_Two")[0]; //获取二级添加按钮 var elementfalse = $(".U_Boom_O_N_H_C_ceshi")[0]; //获取测试按钮 var elementsecadd = $(".U_Boom_O_N_C_Navg_Ul_Nav_Add"); //获取三级添加按钮 var elementsecdel = $(".U_Boom_O_N_C_Navg_Ul_Nav_Del"); //获取三级删除按钮 var type = $("#U_Boom_O_N_C_Container")[0].children; var cursor = $(".U_Boom_O_N_C_Navg_Li_font"); delchange[0].setAttribute("onchange", ""); //屏蔽onhange事件 delchange[0].type = "text"; //改变头部type的值 delchange[0].style.cursor = "default"; delinput[0].setAttribute("onchange", ""); delinput[0].type = "text"; //改变底部type的值 delinput[0].style.cursor = "default"; delinput[1].setAttribute("onchange", ""); delinput[1].type = "text"; //改变二维码type的值 delinput[1].style.cursor = "default"; elementsec.style.display = "none"; elementfalse.style.display = "none"; //改变内容页距离顶部的高度 var contant = $("#U_Boom_O_N_C_Container")[0]; //获取整个内容页 contant.style.cssText = "margin-top:7px!important"; var dh1 = $(".U_Boom_O_N_Navg_Ul_daohang2"); var dh = $("#U_Boom_O_N_C_Navg_Ul")[0].children; for (var h = 0; h < dh1.length; h++) { dh1[h].style.backgroundColor = "#efefef"; dh1[h].children[0].style.color = "#656f83"; } for (var d = 0; d < dh.length; d++) { dh[d].children[0].style.backgroundColor = "#dadde2"; } for (var f = 0; f < dh.length; f++) { dh[f].children[0].children[0].style.color = "#000"; } for (var t = 0; t < type.length; t++) { type[t].type = "2"; } for (var c = 0; c < cursor.length; c++) { cursor[c].style.cursor = "default"; } //预览模式下跳到第一个导航 var firstnavg = $("#U_Boom_O_N_C_Navg")[0].children[0].children[0].children[0].children[0]; firstnavg.click(); firstnavg.style.color = "#fff"; firstnavg.parentElement.style.backgroundColor = "#000"; //屏蔽三级添加按钮 for (var s = 0; s < elementsecadd.length; s++) { elementsecadd[s].style.display = "none"; } //屏蔽三级删除按钮 for (var s = 0; s < elementsecdel.length; s++) { elementsecdel[s].style.display = "none"; } //屏蔽所有按钮 for (var j = 0; j < elementclose.length; j++) { elementclose[j].style.display = "none"; //隐藏导航删除标签 elementadd[j].style.display = "none"; //隐藏所有添加标签 } //屏蔽所有编辑功能 for (var i = 0; i < element.length; i++) { element[i].contentEditable = false; //屏蔽所有编辑功能 element[i].style.cuosor = "default"; } } /** *函数作用:清除插入 *@姓名:李泉 */ // U.Office.QCDJ = function () { // U.MD.O.se = window.parent.document.getElementsByClassName("U_MD_O_H_head_features_ul_d_s"); // U.MD.O.cr = $("#U_Boom_O_N_Navg_Ib"); // for (var i = 0; i < U.MD.O.se.length; i++) { // U.MD.O.se[i].style.display = 'none'; // } // for (var i = 0; i < U.MD.O.cr.length; i++) { // U.MD.O.cr[i].style.display = 'none'; // } // }