aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/context_a.js
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-16 17:26:58 -0700
committerGitHub <noreply@github.com>2017-07-16 17:26:58 -0700
commitd90cb9b61cd2e033b46f4780ad1340c5f35b7751 (patch)
tree0294ce22bacb463c9cc95de8dc5581c1bd59a108 /app/src/main/assets/js/context_a.js
parentc3f1fc6a8b3216442a018bb04843dfa68d738918 (diff)
downloadfrost-d90cb9b61cd2e033b46f4780ad1340c5f35b7751.tar.gz
frost-d90cb9b61cd2e033b46f4780ad1340c5f35b7751.tar.bz2
frost-d90cb9b61cd2e033b46f4780ad1340c5f35b7751.zip
Add image viewing and downloading (#63)v1.3
* Commence aggressive image caching * Add glide toggle and css url parsing * Add image hook and refractor activities * Update version analytics * Implemented imageactivity but glide will not load * Create working image loader * Finalize image view * Finalize image view logic * Remove custom cache experiment
Diffstat (limited to 'app/src/main/assets/js/context_a.js')
-rw-r--r--app/src/main/assets/js/context_a.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/app/src/main/assets/js/context_a.js b/app/src/main/assets/js/context_a.js
index 395dfca1..c7601764 100644
--- a/app/src/main/assets/js/context_a.js
+++ b/app/src/main/assets/js/context_a.js
@@ -9,7 +9,7 @@ if (!window.hasOwnProperty('frost_context_a')) {
var longClick = false;
var _frostAContext = function(e) {
- Frost.longClick(true);
+ if (typeof Frost !== 'undefined') Frost.longClick(true);
longClick = true;
/*
@@ -23,13 +23,19 @@ if (!window.hasOwnProperty('frost_context_a')) {
if (element.tagName === 'A' && element.getAttribute('href') !== '#') {
var url = element.getAttribute('href');
if (!url) return;
- if (url.includes('photoset_token')) return;
-
var text = element.parentNode.innerText;
- // console.log('Context Intercept', element.tagName, element.id, element.className)
- console.log('Context Content', url, text);
- Frost.contextMenu(url, text);
+ //check if image item exists
+ var image = element.parentNode.querySelector('[style*="background-image: url("]');
+ if (image) {
+ var imageUrl = window.getComputedStyle(image, null).backgroundImage.slice(5, -2);
+ console.log('Context image', imageUrl);
+ if (typeof Frost !== 'undefined') Frost.loadImage(imageUrl, text);
+ } else {
+ if (url.includes('photoset_token')) return;
+ console.log('Context Content', url, text);
+ if (typeof Frost !== 'undefined') Frost.contextMenu(url, text);
+ }
e.stopPropagation();
e.preventDefault();
}
@@ -39,7 +45,7 @@ if (!window.hasOwnProperty('frost_context_a')) {
document.addEventListener('touchend', function _frostEnd(e) {
if (longClick) {
- Frost.longClick(false);
+ if (typeof Frost !== 'undefined') Frost.longClick(false);
longClick = false;
}
}, true);