ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.js
changeset 6 1c3b8676e58c
parent 5 0f2326c2a325
equal deleted inserted replaced
5:0f2326c2a325 6:1c3b8676e58c
    63         this.handleCurrentViewChange = function()
    63         this.handleCurrentViewChange = function()
    64         {
    64         {
    65             if (window.views.WebView.currentPageIsSuperPage()) {
    65             if (window.views.WebView.currentPageIsSuperPage()) {
    66                    //alert(window.views.WebView.currentSuperPageName());
    66                    //alert(window.views.WebView.currentSuperPageName());
    67                  if (window.views.WebView.currentSuperPageName() == "BookmarkTreeView") {
    67                  if (window.views.WebView.currentSuperPageName() == "BookmarkTreeView") {
    68                     setTitle(window.localeDelegate.translateText("txt_browser_content_view_menu_nav_bookmarks"), false);
    68                     setTitle(window.localeDelegate.translateText("txt_browser_bookmarks_bookmarks"), false);
    69                   }
    69                   }
    70                 else if (window.views.WebView.currentSuperPageName() == "BookmarkHistoryView") {
    70                 else if (window.views.WebView.currentSuperPageName() == "BookmarkHistoryView") {
    71                          setTitle(window.localeDelegate.translateText("txt_browser_content_view_menu_nav_history"), false);
    71                          setTitle(window.localeDelegate.translateText("txt_browser_history_history"), false);
    72                        }
    72                        }
    73                 else if (window.views.WebView.currentSuperPageName() == "SettingsView") {
    73                 else if (window.views.WebView.currentSuperPageName() == "SettingsView") {
    74                          setTitle(window.localeDelegate.translateText("txt_browser_settings_settings"), false);
    74                          setTitle(window.localeDelegate.translateText("txt_browser_settings_settings"), false);
    75                 }
    75                 }
    76            }
    76            }
    77            else {
    77            else {
    78                  if (window.views.current().type == "webView")  {
    78                  if (window.views.current().type == "webView")  {
       
    79                   
       
    80                  //enable the double click for the content view page
       
    81                  if (!window.views.WebView.bedrockTiledBackingStoreEnabled())
       
    82                      window.views.WebView.touchNav.doubleClickEnabled = true;                 
       
    83                    
    79                       /* For new windows, show title as 'New Window' */
    84                       /* For new windows, show title as 'New Window' */
    80                     if ((window.pageController.currentDocTitle == "") && (window.pageController.currentRequestedUrl == "")) {
    85                     if ((window.pageController.currentDocTitle == "") && (window.pageController.currentRequestedUrl == "")) {
    81                         setTitle(window.localeDelegate.translateText("txt_browser_windows_new_window"), false);
    86                         setTitle(window.localeDelegate.translateText("txt_browser_content_view_new_window"), false);
    82                     }
    87                     }
    83                     else if (window.pageController.currentDocTitle == "") {
    88                     else if (window.pageController.currentDocTitle == "") {
    84                         if (window.pageController.currentDocUrl == "")  {
    89                         if (window.pageController.currentDocUrl == "")  {
    85                             setTitle(window.pageController.currentPartialReqUrl, false);
    90                             setTitle(window.pageController.currentPartialReqUrl, false);
    86                         }
    91                         }
   266                 networkName = networkName.substring(0, NetworkStatus.MAX_NAME_LEN);
   271                 networkName = networkName.substring(0, NetworkStatus.MAX_NAME_LEN);
   267             // set field width to the appropriate width and change the name
   272             // set field width to the appropriate width and change the name
   268             updateFieldWidth(htmlEncode(networkName));
   273             updateFieldWidth(htmlEncode(networkName));
   269             document.getElementById('provider').innerHTML = htmlEncode(networkName);
   274             document.getElementById('provider').innerHTML = htmlEncode(networkName);
   270 
   275 
   271             // repaint if status bar exists (first call to this function, it doesn't)
   276             // repaint if status bar exists
   272             if (window.snippets.StatusBarChromeId)
   277             if (window.snippets.StatusBarChromeId)
   273                 window.snippets.StatusBarChromeId.repaint();
   278                 window.snippets.StatusBarChromeId.repaint();
   274         }
   279         }
   275 
   280 
   276         //! Gets the appropriate image tag HTML string for the current network
   281         //! Gets the appropriate image tag HTML string for the current network
   306                 lastState = currentState; // save former state
   311                 lastState = currentState; // save former state
   307                 // update current state and network icon
   312                 // update current state and network icon
   308                 currentState = state;
   313                 currentState = state;
   309                 document.getElementById('strength').innerHTML =
   314                 document.getElementById('strength').innerHTML =
   310                     networkIconSrc[currentState];
   315                     networkIconSrc[currentState];
   311                 window.snippets.StatusBarChromeId.repaint();
       
   312 
   316 
   313                 // if we went offline, change the provider name to "offline"
   317                 // if we went offline, change the provider name to "offline"
   314                 if (currentState == enumNetworkStrengths.state.Offline)
   318                 if (currentState == enumNetworkStrengths.state.Offline)
   315                     changeName(window.localeDelegate.translateText("txt_browser_offline"));
   319                     changeName(window.localeDelegate.translateText("txt_browser_offline"));
   316                 // if we just came online, get and update provider name
   320                 // if we just came online, get and update provider name
   409         */
   413         */
   410         this.handleLevelChange = function(level)
   414         this.handleLevelChange = function(level)
   411         {
   415         {
   412             document.getElementById('battery').innerHTML =
   416             document.getElementById('battery').innerHTML =
   413                 batteryIconSrc[convertLevelToState(level)];
   417                 batteryIconSrc[convertLevelToState(level)];
   414             window.snippets.StatusBarChromeId.repaint();
       
   415         }
   418         }
   416     }
   419     }
   417 
   420 
   418     /*!
   421     /*!
   419       Class to handle updating the download indicator.
   422       Class to handle updating the download indicator.
   473               '<td class="centeralign" id="clock">time: &nbsp;</td>' +
   476               '<td class="centeralign" id="clock">time: &nbsp;</td>' +
   474               '<td class="rightalign" id="battery">' + sbBatteryStatus.getInitialLevelImgTag() + '</td>'+
   477               '<td class="rightalign" id="battery">' + sbBatteryStatus.getInitialLevelImgTag() + '</td>'+
   475             '</tr>'+
   478             '</tr>'+
   476             '</table>'+
   479             '</table>'+
   477             // ruler span used for getting the width of network name
   480             // ruler span used for getting the width of network name
   478             // style included here because style sheet not applied early
   481             '<span id="sbruler"></span>';
   479             // enough for sbNetworkStatus.showInitialNetworkName call below
       
   480             // which needs text width which depends on font
       
   481             '<span id="sbruler" style="font-size:12px;font-weight:bold;visibility:hidden;"></span>';
       
   482         document.write(html);
   482         document.write(html);
   483 
       
   484         sbNetworkStatus.showInitialNetworkName();
       
   485     }
   483     }
   486 
   484 
   487     // StatusBar Constructor
   485     // StatusBar Constructor
   488     _statusbar_write(); // write status bar HTML code to document
   486     _statusbar_write(); // write status bar HTML code to document
   489     sbClock.showtime(); // display current time on status bar
   487     sbClock.showtime(); // display current time on status bar
   492 
   490 
   493     // Note that in the slots below the "this" object is never used directly.
   491     // Note that in the slots below the "this" object is never used directly.
   494     // This is because they don't have access to "this" as they are invoked
   492     // This is because they don't have access to "this" as they are invoked
   495     // as functions rather than as methods.
   493     // as functions rather than as methods.
   496 
   494 
       
   495     // On chromeComplete signal, show initial network name.
       
   496     window.chrome.chromeComplete.connect(
       
   497         function() {sbNetworkStatus.showInitialNetworkName();});
       
   498     
   497     // Connect page controller signals to slots.
   499     // Connect page controller signals to slots.
   498     window.pageController.titleChanged.connect(
   500     window.pageController.titleChanged.connect(
   499         function(title) {sbTitle.handleTitleChange(title);});
   501         function(title) {sbTitle.handleTitleChange(title);});
   500     window.pageController.partialUrlChanged.connect(
   502     window.pageController.partialUrlChanged.connect(
   501         function(partialUrl) {sbTitle.handlePartialUrlChange(partialUrl);});
   503         function(partialUrl) {sbTitle.handlePartialUrlChange(partialUrl);});
   510             sbTitle.handleCurrentViewChange();
   512             sbTitle.handleCurrentViewChange();
   511             sbLockStatus.handleCurrentViewChange();
   513             sbLockStatus.handleCurrentViewChange();
   512         }
   514         }
   513     );
   515     );
   514 
   516 
   515     window.ViewStack.currentViewChanged.connect(
       
   516         function() {
       
   517             sbTitle.handleCurrentViewChange();
       
   518             sbLockStatus.handleCurrentViewChange();
       
   519         }
       
   520     );
       
   521 
       
   522     // Connect device delegate signals to slots.
   517     // Connect device delegate signals to slots.
   523     window.deviceDelegate.batteryLevelChanged.connect(
   518     window.deviceDelegate.batteryLevelChanged.connect(
   524        function(level) {sbBatteryStatus.handleLevelChange(level);});
   519        function(level) {sbBatteryStatus.handleLevelChange(level);});
   525     window.networkDelegate.networkSignalStrengthChanged.connect(
   520     window.networkDelegate.networkSignalStrengthChanged.connect(
   526         function(strength) {sbNetworkStatus.handleSignalStrengthChange(strength);});
   521         function(strength) {sbNetworkStatus.handleSignalStrengthChange(strength);});