blob: c760176404c5c7b7c6195ef5c890fc28b0a88edb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
//context menu for links
//largely mimics click_a.js
//we will also bind a listener here to notify the activity not to deal with viewpager scrolls
//since the long press is also associated witho
if (!window.hasOwnProperty('frost_context_a')) {
console.log('frost_context_a frost_click_a');
window.frost_context_a = true;
var longClick = false;
var _frostAContext = function(e) {
if (typeof Frost !== 'undefined') Frost.longClick(true);
longClick = true;
/*
* Commonality; check for valid target
*/
var element = e.target || e.currentTarget || e.srcElement;
if (!element) return;
if (element.tagName !== 'A') element = element.parentNode;
//Notifications is two layers under
if (element.tagName !== 'A') element = element.parentNode;
if (element.tagName === 'A' && element.getAttribute('href') !== '#') {
var url = element.getAttribute('href');
if (!url) return;
var text = element.parentNode.innerText;
//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();
}
}
document.addEventListener('contextmenu', _frostAContext, true);
document.addEventListener('touchend', function _frostEnd(e) {
if (longClick) {
if (typeof Frost !== 'undefined') Frost.longClick(false);
longClick = false;
}
}, true);
}
|