diff options
author | Allan Wang <me@allanwang.ca> | 2017-12-10 14:25:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-10 14:25:29 -0500 |
commit | 1d4380cee77fc049a54d280a27dcefa3fa6ff1fd (patch) | |
tree | 6aa222b3f88862a46c8ffd0e46bfb94755d54729 /app/src/main/assets/js/menu.js | |
parent | 30eb51a44a271512e27c97aecc02f3a339f572bf (diff) | |
download | frost-1d4380cee77fc049a54d280a27dcefa3fa6ff1fd.tar.gz frost-1d4380cee77fc049a54d280a27dcefa3fa6ff1fd.tar.bz2 frost-1d4380cee77fc049a54d280a27dcefa3fa6ff1fd.zip |
theme (#546)
* Update to coffee and use webstorm
* Add chrome as well
* Update all
* Reinstall android 27
Diffstat (limited to 'app/src/main/assets/js/menu.js')
-rw-r--r-- | app/src/main/assets/js/menu.js | 75 |
1 files changed, 51 insertions, 24 deletions
diff --git a/app/src/main/assets/js/menu.js b/app/src/main/assets/js/menu.js index a43b1820..49534c7e 100644 --- a/app/src/main/assets/js/menu.js +++ b/app/src/main/assets/js/menu.js @@ -1,46 +1,73 @@ -//click menu and move contents to main view -if (!window.hasOwnProperty('frost_menu')) { - console.log('Registering frost_menu'); - window.frost_menu = true; - var viewport = document.querySelector('#viewport'); - var root = document.querySelector('#root'); - if (!viewport) console.log('Menu.js: viewport is null'); - if (!root) console.log('Menu.js: root is null'); - var y = new MutationObserver(function(mutations) { - viewport.removeAttribute('style'); - root.removeAttribute('style'); +"use strict"; + +(function () { + // click menu and move contents to main view + var jewel, menuA, root, viewport, x, y; + + viewport = document.querySelector("#viewport"); + + root = document.querySelector("#root"); + + if (!viewport) { + console.log("Menu.js: viewport is null"); + } + + if (!root) { + console.log("Menu.js: root is null"); + } + + y = new MutationObserver(function (mutations) { + viewport.removeAttribute("style"); + root.removeAttribute("style"); }); + y.observe(viewport, { attributes: true }); + y.observe(root, { attributes: true }); - var x = new MutationObserver(function(mutations) { - var menu = document.querySelector('.mSideMenu'); + + x = new MutationObserver(function (mutations) { + var menu; + menu = document.querySelector(".mSideMenu"); if (menu !== null) { x.disconnect(); - console.log('Found side menu'); - while (root.firstChild) + console.log("Found side menu"); + while (root.firstChild) { root.removeChild(root.firstChild); + } while (menu.childNodes.length) { - console.log('append'); + console.log("append"); viewport.appendChild(menu.childNodes[0]); } - if (typeof Frost !== 'undefined') Frost.emit(0); - setTimeout(function() { + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.emit(0); + } + setTimeout(function () { y.disconnect(); - console.log('Unhook styler'); + console.log("Unhook styler"); }, 500); } }); - var jewel = document.querySelector('#mJewelNav'); - if (!jewel) console.log('Menu.js: jewel is null'); + + jewel = document.querySelector("#mJewelNav"); + + if (!jewel) { + console.log("Menu.js: jewel is null"); + } + x.observe(jewel, { childList: true, subtree: true }); - var menuA = document.querySelector('#bookmarks_jewel').querySelector('a'); - if (!menuA) console.log('Menu.js: jewel is null') + + menuA = document.querySelector("#bookmarks_jewel").querySelector("a"); + + if (!menuA) { + console.log("Menu.js: jewel is null"); + } + menuA.click(); -} +}).call(undefined);
\ No newline at end of file |