Changeset 21


Ignore:
Timestamp:
09/21/12 23:04:27 (6 years ago)
Author:
nhoyt
Message:

Moved updateView function from ainspector to ainspectorSidebar namespace; added use of viewChangeCallback, which the sidebar registers and unregisters (i.e. sets to either updateView or null) on load and unload events, respectively; modified selectView function to call viewChangeCallback when necessary.

Location:
trunk/proto-03
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/proto-03/chrome/content/ai-sidebar.js

    r17 r21  
    99 */ 
    1010var ainspector = ainspector || {}; 
    11  
    12 ainspector.updateView = function () { 
    13   if (ainspector.currentView === null) return; 
    14   ainspector.setToolbarState(true); 
    15   ainspectorSidebar.viewTitle.value = ainspector.getViewTitle(); 
    16 }; 
    1711 
    1812/** 
     
    4943    ainspectorSidebar.updateContext); 
    5044 
     45ainspectorSidebar.updateView = function () { 
     46  if (ainspector.currentView === null) return; 
     47  ainspector.logger.log.debug("updateView: " + ainspector.getViewName(ainspector.currentView)); 
     48 
     49  ainspector.setToolbarState(true); 
     50  ainspectorSidebar.viewTitle.value = ainspector.getViewTitle(); 
     51}; 
     52 
    5153ainspectorSidebar.onLoad = function () { 
    5254  // add required listeners 
     
    5456  ainspector.mainWindow.gBrowser.tabContainer.addEventListener( 
    5557    "TabSelect", ainspectorSidebar.onTabSelect, false); 
     58 
     59  // register callback in shared namespace 
     60  ainspector.viewChangeCallback = ainspectorSidebar.updateView; 
    5661 
    5762  // initialize user interface components 
     
    6166  ainspectorSidebar.viewTitle     = document.getElementById("ai-view-title"); 
    6267 
    63   ainspector.setToolbarState(true); 
    6468  ainspectorSidebar.updateContext(); 
    65   ainspector.updateView(); 
     69  ainspectorSidebar.updateView(); 
    6670}; 
    6771 
     
    7175  ainspector.mainWindow.gBrowser.tabContainer.removeEventListener( 
    7276    "TabSelect", ainspectorSidebar.onTabSelect, false); 
     77  ainspector.viewChangeCallback = null; 
    7378}; 
    7479 
  • trunk/proto-03/chrome/content/ff-overlay.js

    r19 r21  
    4949}; 
    5050 
    51 ainspector.selectView = function (viewConst) { 
    52   ainspector.currentView = viewConst; 
    53   ainspector.logViewInfo(ainspector.currentView); 
    54   toggleSidebar('view-ai-sidebar', true); 
    55   ainspector.updateView(); 
     51ainspector.getViewName = function (index) { 
     52  return ainspector.viewStrings[index]; 
    5653}; 
    5754 
    58 ainspector.logViewInfo = function (index) { 
    59   var viewName = ainspector.viewStrings[index]; 
    60   ainspector.logger.log.debug("view: " + viewName); 
     55ainspector.selectView = function (viewConst) { 
     56  ainspector.logger.log.debug("selectView: " + ainspector.getViewName(viewConst)); 
     57 
     58  var isNewView = (ainspector.currentView !== viewConst); 
     59  ainspector.currentView = viewConst; 
     60 
     61  if (ainspector.viewChangeCallback === null) { 
     62    toggleSidebar('view-ai-sidebar', true); 
     63  } 
     64  else if (isNewView) { 
     65    ainspector.viewChangeCallback(); 
     66  } 
    6167}; 
    6268 
     
    113119 
    114120ainspector.getViewTitle = function () { 
    115   if (ainspector.currentView === null) return; 
     121  if (ainspector.currentView === null) return ''; 
    116122 
    117123  var nls = ainspector.nlsProperties; 
     
    160166  ainspector.logger.enabled = true; 
    161167  ainspector.logger.level = ainspector.LOG_LEVEL.DEBUG; 
     168  ainspector.logger.log.info("load event: AInspector for Firefox") 
    162169 
    163170  // get NLS stringbundle 
     
    166173 
    167174window.addEventListener("load", ainspector.onLoad, false); 
    168 // window.addEventListener("unload", function () { alert("ainspector unload event"); }, false); 
  • trunk/proto-03/modules/ainspector-common.js

    r17 r21  
    1313var ainspector = { 
    1414  currentView: null, 
    15   nlsProperties: null 
     15  nlsProperties: null, 
     16  viewChangeCallback: null 
    1617}; 
Note: See TracChangeset for help on using the changeset viewer.