ginebra/chrome/bedrockchrome/contextmenu.snippet/contextmenu.js
branchGCC_SURGE
changeset 8 2e16851ffecd
parent 2 bf4420e9fa4d
parent 6 1c3b8676e58c
equal deleted inserted replaced
2:bf4420e9fa4d 8:2e16851ffecd
     1 function printProp(x) {
       
     2     window.chrome.alert(x + ":");
       
     3     for (property in x) {
       
     4         window.chrome.alert(property + ": " + x[property]);
       
     5     }
       
     6 }
       
     7 
       
     8 window.webView.contextEvent.connect(
       
     9     function(e) {
       
    10         window.chrome.alert("web context22222222222: " + e + " " + e.pos.x);
       
    11         window.snippets.ContextMenuId.show();
       
    12     }
       
    13 );
       
    14 
       
    15 window.historyView.contextEvent.connect(
       
    16     function(e) {
       
    17         window.chrome.alert("history context: " + e + " " + e.itemIndex + 
       
    18                             " x=" + e.pos.x + " y=" + e.pos.y);
       
    19         printProp(e);
       
    20     }
       
    21 );
       
    22 
       
    23 window.chrome.loadComplete.connect(
       
    24     
       
    25 );
       
    26 
       
    27 function ContextMenu()
       
    28 {
       
    29     // attach internal funcs
       
    30     this.write = writeContextMenu;
       
    31 
       
    32     // do setup
       
    33     this.write();
       
    34 }
       
    35 
       
    36 function goToRecentUrlView () {
       
    37          window.viewStack.switchView("bookmarkHistoryView", "webView");
       
    38     }
       
    39 
       
    40 function goToBookmarkView () {
       
    41          window.viewStack.switchView("bookmarkTreeView", "webView");
       
    42     }
       
    43 
       
    44 // "Private" methods
       
    45 function writeContextMenu() {
       
    46     var html =
       
    47     '<div class="box">' +
       
    48         
       
    49        
       
    50         '<div class="boxBody">' +
       
    51 
       
    52           '<div id="Settings" class="show">' +
       
    53             '<ul>' +
       
    54               '<li onmouseup="goToBookmarkView();">' + window.localeDelegate.translateText("bookmarks_bookmarks") + '</li>' +
       
    55               '<li onmouseup="goToRecentUrlView();">'+ window.localeDelegate.translateText("content_view_menu_history") + '</li>' +     
       
    56 //              '<li onmouseup="window.chrome.clearCache(); window.chrome.clearCookies();window.chrome.clearHistory();">' + window.localeDelegate.translateText("settings_clear_all") + '</li>' +
       
    57             '</ul>' +
       
    58           '</div>' +
       
    59         '</div>' +
       
    60     '</div>'; 
       
    61   document.write(html);
       
    62 }
       
    63