aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/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
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')
-rw-r--r--app/src/main/assets/js/click_a.js2
-rw-r--r--app/src/main/assets/js/click_a.min.js4
-rw-r--r--app/src/main/assets/js/context_a.js20
-rw-r--r--app/src/main/assets/js/context_a.min.js32
4 files changed, 36 insertions, 22 deletions
diff --git a/app/src/main/assets/js/click_a.js b/app/src/main/assets/js/click_a.js
index 81b12fd7..9f4ddc38 100644
--- a/app/src/main/assets/js/click_a.js
+++ b/app/src/main/assets/js/click_a.js
@@ -22,7 +22,7 @@ if (!window.hasOwnProperty('frost_click_a')) {
if (!prevented) {
console.log('Click Intercept', url);
- Frost.loadUrl(url);
+ if (typeof Frost !== 'undefined') Frost.loadUrl(url);
}
e.stopPropagation();
e.preventDefault();
diff --git a/app/src/main/assets/js/click_a.min.js b/app/src/main/assets/js/click_a.min.js
index 059c1183..c7870e2f 100644
--- a/app/src/main/assets/js/click_a.min.js
+++ b/app/src/main/assets/js/click_a.min.js
@@ -8,8 +8,8 @@ var t=e.target||e.srcElement
var n=t.getAttribute("href")
;if(n.includes("photoset_token"))return
;prevented||(console.log("Click Intercept",n),
-Frost.loadUrl(n)),e.stopPropagation(),
-e.preventDefault()
+"undefined"!=typeof Frost&&Frost.loadUrl(n)),
+e.stopPropagation(),e.preventDefault()
}
},_frostPreventClick=function(){
console.log("Click prevented"),prevented=!0
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);
diff --git a/app/src/main/assets/js/context_a.min.js b/app/src/main/assets/js/context_a.min.js
index 82f89e8b..5c5f033a 100644
--- a/app/src/main/assets/js/context_a.min.js
+++ b/app/src/main/assets/js/context_a.min.js
@@ -1,20 +1,28 @@
if(!window.hasOwnProperty("frost_context_a")){
console.log("frost_context_a frost_click_a"),
window.frost_context_a=!0
-;var longClick=!1,_frostAContext=function(t){
-Frost.longClick(!0),longClick=!0
-;var e=t.target||t.currentTarget||t.srcElement
-;if(e&&("A"!==e.tagName&&(e=e.parentNode),
-"A"!==e.tagName&&(e=e.parentNode),"A"===e.tagName&&"#"!==e.getAttribute("href"))){
-var o=e.getAttribute("href")
-;if(o.includes("photoset_token"))return
-;var n=e.parentNode.innerText
-;console.log("Context Content",o,n),Frost.contextMenu(o,n),
-t.stopPropagation(),t.preventDefault()
+;var longClick=!1,_frostAContext=function(e){
+"undefined"!=typeof Frost&&Frost.longClick(!0),
+longClick=!0
+;var t=e.target||e.currentTarget||e.srcElement
+;if(t&&("A"!==t.tagName&&(t=t.parentNode),
+"A"!==t.tagName&&(t=t.parentNode),"A"===t.tagName&&"#"!==t.getAttribute("href"))){
+var o=t.getAttribute("href")
+;if(!o)return
+;var n=t.parentNode.innerText,r=t.parentNode.querySelector('[style*="background-image: url("]')
+;if(r){
+var a=window.getComputedStyle(r,null).backgroundImage.slice(5,-2)
+;console.log("Context image",a),
+"undefined"!=typeof Frost&&Frost.loadImage(a,n)
+}else{
+if(o.includes("photoset_token"))return
+;console.log("Context Content",o,n),"undefined"!=typeof Frost&&Frost.contextMenu(o,n)
}
+e.stopPropagation(),e.preventDefault()
}
-;document.addEventListener("contextmenu",_frostAContext,!0),document.addEventListener("touchend",function(t){
-longClick&&(Frost.longClick(!1),
+}
+;document.addEventListener("contextmenu",_frostAContext,!0),document.addEventListener("touchend",function(e){
+longClick&&("undefined"!=typeof Frost&&Frost.longClick(!1),
longClick=!1)
},!0)
} \ No newline at end of file