/usr/share/hotot/js/ui.context_menu.js is in hotot-common 1:0.9.8.14-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | ui = ui || {};
ui.ContextMenu = {
is_hide: true,
editable_element: null,
event_element: null,
init:
function init() {
$('#context_menuitem_copy').click(
function (event) {
if (!util.is_native_platform()) {
if (conf.vars.platform === 'Chrome') {
toast.set('Copied!').show(-1);
var sandbox = $('#sandbox').val(ui.ContextMenu.selected_string).select();
document.execCommand('copy');
sandbox.val('');
} else {
// pass
}
} else {
hotot_action('action/set_clipboard_text/' + ui.ContextMenu.selected_string);
}
if (ui.ContextMenu.event_element) {
$(ui.ContextMenu.event_element).focus();
}
});
$('#context_menuitem_paste').click(
function (event) {
var element = ui.ContextMenu.editable_element;
if (element) {
element.focus();
hotot_action('action/paste_clipboard_text');
}
});
$('#context_menuitem_web_search').click(
function (event) {
navigate_action('http://www.google.com/search?sourceid=chrome&ie=UTF-8&q='+ui.ContextMenu.selected_string);
});
$('#context_menuitem_twitter_search').click(
function (event) {
ui.SearchView.do_search(ui.Main.views.search, $.trim(ui.ContextMenu.selected_string));
});
$('body').get(0).oncontextmenu = function (event) {
ui.ContextMenu.event_element = event.target;
ui.ContextMenu.selected_string
= $.trim(document.getSelection().toString());
$('#context_menu').css(
{'left':event.clientX, 'top':event.clientY}
);
$('#context_menu li').hide();
var all_hide_flag = true;
$('#context_menu a').each(
function (idx, item) {
if ($(item).hasClass('native_only')) {
if (!util.is_native_platform()) {
return;
}
}
if ($(item).hasClass('select_only')) {
var display_str = ui.ContextMenu.selected_string;
if (display_str.length != 0) {
if (display_str.length > 24) {
display_str = display_str.substring(0, 24) + ' ... ';
}
if (!$(item).attr("text-template")) {
$(item).attr("text-template", $(item).text());
}
var content = $(item).attr("text-template").split("@");
if (content.length > 1) {
$(item).text(content[0]).append($('<strong></strong>').text("'" + display_str + "'"));
if (content[1]) {
$(item).append(document.createTextNode(content[1]));
}
}
} else {
return;
}
}
if ($(item).hasClass('editable_only')) {
var element = event.target;
ui.ContextMenu.editable_element = null;
if (element.tagName != "INPUT" && element.tagName != "TEXTAREA") {
return;
} else if (element.tagName == "INPUT" && element.type != 'text') {
return;
} else if (element.readOnly) {
return;
}
ui.ContextMenu.editable_element = element;
}
$(item).parent().show();
all_hide_flag = false;
});
if (all_hide_flag) {
$('#context_menu').hide();
} else {
$('#context_menu').show();
}
event.preventDefault()
return ;
}
},
show:
function show() {
$('#context_menu').show();
ui.ContextMenu.is_hide = false;
},
hide:
function hide() {
$('#context_menu').hide();
ui.ContextMenu.is_hide = true;
}
};
|