diff options
author | Allan Wang <me@allanwang.ca> | 2019-04-26 23:48:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-26 23:48:19 -0700 |
commit | 5139111a7f1f4b18e993b23d2a0b7bb5a260e905 (patch) | |
tree | b1007ac60f7f188b24999f756271430e341b7f37 /app/src/web/assets/js/context_a.ts | |
parent | 4e1a32bf33f7ee8cf9a125440ed11db61f884a88 (diff) | |
download | frost-5139111a7f1f4b18e993b23d2a0b7bb5a260e905.tar.gz frost-5139111a7f1f4b18e993b23d2a0b7bb5a260e905.tar.bz2 frost-5139111a7f1f4b18e993b23d2a0b7bb5a260e905.zip |
Docker (#1411)
* Add initial docker test
* Depend on java only
* Remove android part
* Move build stuff to docker
* Use shorter docker file
* Quiet docker build
* Move quiet flag forward
* Export android home
* Echo versions
* Try generic lang
* Copy project
* Group sdk manager runs
* Reorder sdkmanager
* Gitignore generated files
* Copy apk output out of docker
* Fail if no apks found
* Install packages
* Add caching
* Name container
* Update caching
* Add package lock file
* Update folder path
* Switch home dir
* Copy folder contents
* Disable caching
* Add back gradle caching
* Remove original files from asset folder
* Try generic docker
* Delete extra loader
* Try java
* Try android
* Use java
* Restrict caching
Diffstat (limited to 'app/src/web/assets/js/context_a.ts')
-rw-r--r-- | app/src/web/assets/js/context_a.ts | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/app/src/web/assets/js/context_a.ts b/app/src/web/assets/js/context_a.ts deleted file mode 100644 index 5eec7611..00000000 --- a/app/src/web/assets/js/context_a.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Context menu for links - * Largely mimics click_a.js - */ - -(function () { - let longClick = false; - - /** - * Given event and target, return true if handled and false otherwise. - */ - type EventHandler = (e: Event, target: HTMLElement) => Boolean - - const _frostCopyComment: EventHandler = (e, target) => { - if (!target.hasAttribute('data-commentid')) { - return false; - } - const text = target.innerText; - console.log(`Copy comment ${text}`); - Frost.contextMenu(null, text); - return true; - }; - - /** - * Posts should click a tag, with two parents up being div.story_body_container - */ - const _frostCopyPost: EventHandler = (e, target) => { - if (target.tagName !== 'A') { - return false; - } - const parent1 = target.parentElement; - if (!parent1 || parent1.tagName !== 'DIV') { - return false; - } - const parent2 = parent1.parentElement; - if (!parent2 || !parent2.classList.contains('story_body_container')) { - return false; - } - const url = target.getAttribute('href'); - const text = parent1.innerText; - console.log(`Copy post ${url} ${text}`); - Frost.contextMenu(url, text); - return true; - }; - - const _getImageStyleUrl = (el: Element): string | null => { - const img = el.querySelector("[style*=\"background-image: url(\"]"); - if (!img) { - return null - } - return (<String>window.getComputedStyle(img, null).backgroundImage).trim().slice(4, -1); - }; - - /** - * Opens image activity for posts with just one image - */ - const _frostImage: EventHandler = (e, target) => { - let element: Element = target; - // Notifications are two layers under - for (let i = 0; i < 2; i++) { - if (element.tagName !== 'A') { - element = <Element>element.parentElement; - } else { - break - } - } - if (element.tagName !== 'A') { - return false; - } - const url = element.getAttribute('href'); - if (!url || url === '#') { - return false; - } - const text = (<HTMLElement>element.parentElement).innerText; - // Check if image item exists, first in children and then in parent - const imageUrl = _getImageStyleUrl(element) || _getImageStyleUrl(<Element>element.parentElement); - if (imageUrl) { - console.log(`Context image: ${imageUrl}`); - Frost.loadImage(imageUrl, text); - return true; - } - // Check if true img exists - const img = element.querySelector("img[src*=scontent]"); - if (img instanceof HTMLMediaElement) { - const imgUrl = img.src; - console.log(`Context img: ${imgUrl}`); - Frost.loadImage(imgUrl, text); - return true; - } - console.log(`Context content ${url} ${text}`); - Frost.contextMenu(url, text); - return true; - }; - - const handlers = [_frostImage, _frostCopyComment, _frostCopyPost]; - - const _frostAContext = (e: Event) => { - Frost.longClick(true); - longClick = true; - - /* - * Commonality; check for valid target - */ - const target = e.target || e.currentTarget || e.srcElement; - if (!(target instanceof HTMLElement)) { - console.log("No element found"); - return - } - for (const h of handlers) { - if (h(e, target)) { - e.stopPropagation(); - e.preventDefault(); - return - } - } - }; - - document.addEventListener('contextmenu', _frostAContext, true); - document.addEventListener('touchend', () => { - if (longClick) { - Frost.longClick(false); - longClick = false - } - }, true); -}).call(undefined); |