After the page loads, execute $ (function () {//automatically activates the current menu according to the URL var page_id = getquerystring (' page_id '); If page_id is not specified, the page with the parent directory of 0 is determined, and the first if (!page_id) {page_id = $ (". Doc-left li") is opened by default. Children ("a"). attr ("Data-page-id") ); }; if (page_id!=null && page_id.tostring (). length>0) {var str = ' page_id= ' +page_id; $ (". Doc-left li"). each (function () {URL = $ (this). Children ("a"). attr ("href"); If the link contains information for the current URL, both match if (URL && url.indexof (str) >= 0) {//Activate menu $ (this). AddClass ("Active "); If the menu is a submenu, you also need to open the parent menu if ($ (this). Parent ('. Child-ul ')) {$ (this). Parent ('. Child-ul '). "Show (); $ (this). Parent ('. Child-ul '). Parent (' Li '). Children ("a"). Children (' I '). attr ("Class", "Icon-chevron-down"); }; Gets the corresponding page_id page_id = $ (this). Children ("a"). attr ("Data-page-id"); if (page_id! = ' && page_id! = ' # ') {change_page (page_id)}; }; })}//Respond to screen width (for mobile device access) if (IsMobile ()) {adapttomobile (); } $ (window). Resize (function () {if (IsMobile ()) {adapttomobile (); } else if ($ (window). Width () <) {Adapttomobile (); }else{window.location.reload (); } }); JS gets the URL parameter function getquerystring (name) {var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)"); var r = window.location.search.substr (1). Match (REG); if (r!=null) return unescape (r[2]); return null; } function Adapttomobile () {$ (". Doc-left"). Removeclass ("Span3"); $ (". Doc-left"). CSS ("width", ' 100% '); $ (". Doc-left"). CSS ("height", ' initial '); $ (". Doc-left"). CSS ("min-height", ' 0px '); $ (". Doc-right"). Removeclass ("Span12"); $ (". Doc-head. Right"). Hide (); $ (". Page-edit-link"). html ('); $ (". Doc-left-newbar"). html ('); $ (". Iframe_content"). CSS ("Padding-left", "30px"); $ (". Doc-left. Nav-list li a I"). CSS ("Margin-left", ' 10px '); $ (". Search-input-append"). CSS ("width", "100%"); $ (". Search-query-input"). CSS (" width "," 70% "); } function Mscroll (ID) {$ ("html,body"). Stop (true); $ ("Html,body"). Animate ({scrolltop: $ ("#" +id). Offset (). Top}, 2000); }//Click on the left menu event $ (". Doc-left li"). Click (function () {//) to cancel the activation status of all menus by $ (". Doc-left li"). each (function () {$ (this). Removeclass ("active"); }); First determine if there is a submenu if ($ (this). Children ('. Child-ul '). Length! = 0) {//If the submenu is hidden, it is displayed, or if it is displayed, hides if ($ (this).) Ren ('. Child-ul '). CSS ("display") = = "None") {$ (this). Children ('. Child-ul '). Show (); $ (this). Children ("a"). Children (' I '). attr ("Class", "Icon-chevron-down"); }else{$ (this). Children ('. Child-ul '). Hide (); $ (this). Children ("a"). Children (' I '). attr ("Class", "icon-chevron-right"); } }; Gets the corresponding page_id page_id = $ (this). Children ("a"). attr ("Data-page-id"); if (page_id! = ' && page_id! = NULL && page_id! = ' # ') {change_page (page_id); If it is a mobile device, scroll the page if (IsMobile ()) {MscrolL ("page-content"); } }; Return false;//prohibit the original href link}); Toggle page; function Change_page (page_id) {if (!page_id) return; var item_id = $ ("#item_id"). Val (); var Base_url = $ ("#base_url"). Val (); $ (". Page-edit-link"). Show (); $ ("#page-content"). attr ("src", base_url+ "/home/page/index?page_id=" +page_id); $ ("#edit-link"). attr ("href", base_url+ "/home/page/edit?page_id=" +page_id); $ ("#copy-link"). attr ("href", base_url+ "/home/page/edit?item_id=" +item_id+ "©_page_id=" +page_id); $ ("#share-page-link"). HTML ("http://" +window.location.host+base_url+ "/" +item_id+ "? page_id=" +page_id); $ ("#delete-link"). attr ("href", base_url+ "/home/page/delete?page_id=" +page_id); }//Share Item $ ("#share"). Click (function () {$ ("#share-modal"). Modal (); return false; }); Share page $ ("#share-page"). Click (function () {$ ("#share-page-modal"). Modal (); return false; }); var IFR = document.getElementById (' page-content ') ifr.onload = function () {var iDoc = Ifr.contentdocument | | ifr.document var height = calcpageheight (iDoc) ifr.style.height = height + ' px '}//Calculate the actual height of the page, IFRAME Adaptive will use F Unction Calcpageheight (doc) {var cheight = Math.max (doc.body.clientHeight, Doc.documentElement.clientHeight) VA R sheight = Math.max (Doc.body.scrollHeight, doc.documentElement.scrollHeight) var height = Math.max (cheight, Sheight return height} var keyMap = {//Edit "Ctrl+e": function () {Location.href = $ ("#edit-link"). attr (' href ‘); },//delete "Ctrl+d": function () {if (Confirm (' Confirm delete? ') Location.href = $ ("#delete-link"). attr (' href '); },//New Page "Ctrl+f1": function () {Location.href = $ ("#new-like"). attr (' href '); },//New directory "CTRL+F2": function () {Location.href = $ ("#dir-like"). attr (' href '); } }; if (!ismobile ()) Initkeys (); function Initkeys () {var $doc = $ (document); $.each (KeyMap, function (key, FN) {$doc. On (' KeyDown ', NULL, key, functIon (e) {e.preventdefault (); FN (); return false; }); }); } })
Showdoc.js Code