ginebra2/chrome/bedrockchrome/chrome.js
changeset 12 afcd8e6d025b
parent 9 b39122337a00
child 16 3c88a81ff781
equal deleted inserted replaced
11:786160610b4d 12:afcd8e6d025b
    29 
    29 
    30     if (window.views.WebView[pageName] == undefined) {
    30     if (window.views.WebView[pageName] == undefined) {
    31         window.views.WebView.createSuperPage(pageName, true);
    31         window.views.WebView.createSuperPage(pageName, true);
    32     		window.views.WebView[pageName].load(chrome.baseDirectory + path);
    32     		window.views.WebView[pageName].load(chrome.baseDirectory + path);
    33     }
    33     }
    34 	
    34     if (!window.views.WebView.bedrockTiledBackingStoreEnabled()){
    35     if (!window.views.WebView.bedrockTiledBackingStoreEnabled())
    35         window.views.WebView.setSavedZoomValueInView(window.views.WebView.zoomFactor);
    36         window.views.WebView.zoomFactor = 1.0;
    36 		window.views.WebView.zoomFactor = 1.0;
       
    37     }
    37     //window.views.WebView.showSuperPage(pageName);
    38     //window.views.WebView.showSuperPage(pageName);
    38     window.ViewStack.switchView(pageName, "WebView");
    39     window.ViewStack.switchView(pageName, "WebView");
    39     if (!window.views.WebView.bedrockTiledBackingStoreEnabled())
    40     if (!window.views.WebView.bedrockTiledBackingStoreEnabled())
    40         window.views.WebView.touchNav.doubleClickEnabled = false;
    41         window.views.WebView.touchNav.doubleClickEnabled = false;
    41 }
    42 }
    63     cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData());
    64     cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData());
    64 
    65 
    65 }
    66 }
    66 
    67 
    67 function chrome_addBookmark() {
    68 function chrome_addBookmark() {
    68     launchBookmarkDialog(window.pageController.currentDocTitle,window.pageController.currentDocUrl,0);
    69     launchBookmarkDialog(window.pageController.currentDocTitle,window.pageController.currentDocUrl,-1,0);
    69 }
    70 }
    70 
    71 
    71 function chrome_cancelMenu() {
    72 function chrome_cancelMenu() {
    72 
    73 
    73     cm_TheContextMenu.cancel();
    74     cm_TheContextMenu.cancel();
    89     }
    90     }
    90     return undefined;
    91     return undefined;
    91 }
    92 }
    92 
    93 
    93 function onActivateBookmarkView() {
    94 function onActivateBookmarkView() {
    94     window.bookmarksManager.launchBookmarkEditDailog.connect(showBookmarkEditDialog);
    95     window.bookmarksController.launchBookmarkEditDailog.connect(showBookmarkEditDialog);
    95 }
    96 }
    96 function preLoad()
    97 function preLoad()
    97 {   
    98 {   
    98     preloadSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html");
    99     preloadSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html");
    99     preloadSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); 
   100     preloadSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); 
   116 
   117 
   117 // Called when a PopupChromeItem is displayed.
   118 // Called when a PopupChromeItem is displayed.
   118 function onPopupShown(id) {
   119 function onPopupShown(id) {
   119     if(chrome_popupShownCount == 0) {
   120     if(chrome_popupShownCount == 0) {
   120         // Disable snippets etc. that should be greyed-out while the popup is shown. 
   121         // Disable snippets etc. that should be greyed-out while the popup is shown. 
   121         snippets.UrlSearchChromeId.enabled = false;
   122         if (app.layoutType() == "tenone") {
       
   123             snippets.TitleUrlId.enabled = false;
       
   124         }
       
   125         else {
       
   126             snippets.UrlSearchChromeId.enabled = false;    
       
   127         }    
   122         views.WebView.enabled = false;
   128         views.WebView.enabled = false;
   123         views.WebView.freeze();
   129         views.WebView.freeze();
   124         
   130         
   125         // Note: this can be expanded as needed.  We may want to disable all snippets except
   131         // Note: this can be expanded as needed.  We may want to disable all snippets except
   126         // for the status bar and the one who's id was passed in.
   132         // for the status bar and the one who's id was passed in.
   136 // Called when a PopupChromeItem is hidden.
   142 // Called when a PopupChromeItem is hidden.
   137 function onPopupHidden(id) {
   143 function onPopupHidden(id) {
   138     chrome_popupShownCount--;
   144     chrome_popupShownCount--;
   139     if(chrome_popupShownCount == 0) {
   145     if(chrome_popupShownCount == 0) {
   140         // Re-enable snippets etc. that were greyed-out while popups were being shown.
   146         // Re-enable snippets etc. that were greyed-out while popups were being shown.
   141         snippets.UrlSearchChromeId.enabled = true;
   147         if (app.layoutType() == "tenone") {
       
   148             snippets.TitleUrlId.enabled = true;
       
   149         }
       
   150         else {
       
   151             snippets.UrlSearchChromeId.enabled = true;
       
   152         }
   142         views.WebView.enabled = true;
   153         views.WebView.enabled = true;
   143         views.WebView.unfreeze();
   154         views.WebView.unfreeze();
   144     }
   155     }
   145     if(chrome_popupShownCount < 0) app.debug("onPopupHidden: error, chrome_popupShownCount invalid");
   156     if(chrome_popupShownCount < 0) app.debug("onPopupHidden: error, chrome_popupShownCount invalid");
   146 }
   157 }
   154 
   165 
   155 function onChromeComplete(){
   166 function onChromeComplete(){
   156     if (app.ui() == "orbit_ui") {
   167     if (app.ui() == "orbit_ui") {
   157         snippets.StatusBarChromeId.hide();
   168         snippets.StatusBarChromeId.hide();
   158     }
   169     }
       
   170     if (app.layoutType() == "tenone") {
       
   171         window.snippets.TitleUrlId.anchorToView("top");
       
   172 
       
   173     }
       
   174     else {
       
   175         window.snippets.UrlSearchChromeId.anchorToView("top");
       
   176     }
   159 
   177 
   160     window.snippets.WebViewToolbarId.menuButtonSelected.connect(chrome_showBasicMenu);
   178     window.snippets.WebViewToolbarId.menuButtonSelected.connect(chrome_showBasicMenu);
   161     window.snippets.BookmarkViewToolbarId.addBookmarkSelected.connect(chrome_addBookmark);
   179     window.snippets.BookmarkViewToolbarId.addBookmarkSelected.connect(chrome_addBookmark);
   162     window.snippets.UrlSearchChromeId.anchorToView("top");
       
   163     window.snippets.WebViewToolbarId.menuButtonCanceled.connect(chrome_cancelMenu);
   180     window.snippets.WebViewToolbarId.menuButtonCanceled.connect(chrome_cancelMenu);
   164 
   181 
   165     //window.snippets.ButtonContainer.setVisibilityAnimator("G_VISIBILITY_FADE_ANIMATOR");
   182     //window.snippets.ButtonContainer.setVisibilityAnimator("G_VISIBILITY_FADE_ANIMATOR");
   166 
   183 
   167     result = new Array;
   184     result = new Array;
   176 
   193 
   177     chrome.popupShown.connect(onPopupShown);
   194     chrome.popupShown.connect(onPopupShown);
   178     chrome.popupHidden.connect(onPopupHidden);
   195     chrome.popupHidden.connect(onPopupHidden);
   179     window.pageController.loadFinished.connect(_updateHistory);
   196     window.pageController.loadFinished.connect(_updateHistory);
   180     window.pageController.loadFinishedForBackgroundWindow.connect(_updateHistory);
   197     window.pageController.loadFinishedForBackgroundWindow.connect(_updateHistory);
   181     window.bookmarksManager.bookmarksCleared.connect(_updateBookmarks);
   198     window.bookmarksController.bookmarksCleared.connect(_updateBookmarks);
   182     window.bookmarksManager.historyCleared.connect(_updateHistory);
   199     window.historyManager.historyCleared.connect(_updateHistory);
   183 }
   200 }
   184 
   201 
   185 // For debugging: prints all properties and functions attached to a given object.
   202 // For debugging: prints all properties and functions attached to a given object.
   186 function printProp(x) {
   203 function printProp(x) {
   187     var str = "-------------\n" + x + " properties:\n";
   204     var str = "-------------\n" + x + " properties:\n";