diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-06 19:26:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-06 19:26:38 -0400 |
commit | bb70ed737d98abbd6164b66ac5bd667553b312bd (patch) | |
tree | 1899d7adefe3fbf67e6fd26a4da0837898bd6d7a /app/src/main/assets/js/menu.js | |
parent | 2586e947f769740dd8cb8bf8b1dd0473b51e50e4 (diff) | |
download | frost-bb70ed737d98abbd6164b66ac5bd667553b312bd.tar.gz frost-bb70ed737d98abbd6164b66ac5bd667553b312bd.tar.bz2 frost-bb70ed737d98abbd6164b66ac5bd667553b312bd.zip |
Dev 1.1.5 - JS fixes & sharing intents (#32)v1.1.5
* Add sharing intents
* Fix up multiple js instances
Diffstat (limited to 'app/src/main/assets/js/menu.js')
-rw-r--r-- | app/src/main/assets/js/menu.js | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/app/src/main/assets/js/menu.js b/app/src/main/assets/js/menu.js index 458d9edf..f8cd03c9 100644 --- a/app/src/main/assets/js/menu.js +++ b/app/src/main/assets/js/menu.js @@ -1,36 +1,39 @@ //click menu and move contents to main view -console.log('Fetching menu'); -var viewport = document.querySelector('#viewport'); -var root = document.querySelector('#root'); -var 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'); - if (menu !== null) { - x.disconnect(); - console.log('Found side menu'); - while (root.firstChild) - root.removeChild(root.firstChild); - while (menu.childNodes.length) - root.appendChild(menu.childNodes[0]); - Frost.emit(0); - setTimeout(function() { - y.disconnect(); - console.log('Unhook styler'); - Frost.handleHtml(document.documentElement.outerHTML); - }, 500); - } -}); -x.observe(document.querySelector('#mJewelNav'), { - childList: true, - subtree: true -}); -document.querySelector('#bookmarks_jewel').querySelector('a').click(); +if (!window.hasOwnProperty('frost_menu')) { + console.log('Registering frost_menu'); + window.frost_menu = true; + var viewport = document.querySelector('#viewport'); + var root = document.querySelector('#root'); + var 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'); + if (menu !== null) { + x.disconnect(); + console.log('Found side menu'); + while (root.firstChild) + root.removeChild(root.firstChild); + while (menu.childNodes.length) + root.appendChild(menu.childNodes[0]); + Frost.emit(0); + setTimeout(function() { + y.disconnect(); + console.log('Unhook styler'); + Frost.handleHtml(document.documentElement.outerHTML); + }, 500); + } + }); + x.observe(document.querySelector('#mJewelNav'), { + childList: true, + subtree: true + }); + document.querySelector('#bookmarks_jewel').querySelector('a').click(); +} |