Changeset 257


Ignore:
Timestamp:
12/07/13 17:36:41 (5 years ago)
Author:
nhoyt
Message:

Overview: Improved event handling in Element Results tree: When tree is sorted, update state of Inspect Element button and Inspector; when tree row dblclick or keypress of return key is detected, open Firefox Inspector for selected element.

element-results.js

  • Added script loader call to load handleTreeEvent fn. in ainspectorSidebar namespace.
  • Added value for updateCallback (updateSelectedElement) in sortElementResults so that state of Inspector and Inspect Element button are set properly after tree sort.
  • In updateSelectedElement added call to closePageInspector when no row is selected.

tree-event.js

  • New file with implementation of handleTreeEvent function (most of the code moved here from view-category.js) that can handle events from more than one tree.

view-category.js

  • Added script loader call to load handleTreeEvent fn. in ainspectorSidebar namespace.
  • Deleted handleRCTreeEvent fn. (moved its main logic to tree-event.js).

view-category.xul

  • Changed rule category tree ondblclick and onkeypress attrib. values to call handleTreeEvent with flag value 1.

view-details.xul

  • Added element result tree ondblclick and onkeypress attrib. values to call handleTreeEvent with flag value 2.
  • Added references to ai-button.label.inspect and ai-button.tooltip.inspect entities.

ai-sidebar.dtd

  • Added ai-button.label.inspect and ai-button.tooltip.inspect entity definitions.

install.rdf

  • Updated version to 0.15.1 and Firefox version compatibility to 26.*.
Location:
trunk/proto-15
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/proto-15/chrome/content/element-results.js

    r255 r257  
    1616  .getService(Components.interfaces.mozIJSSubScriptLoader) 
    1717  .loadSubScript("chrome://ai-sidebar/content/tree-sort.js", ainspectorSidebar); 
     18 
     19// Load the handleTreeEvent function 
     20Components.classes["@mozilla.org/moz/jssubscript-loader;1"] 
     21  .getService(Components.interfaces.mozIJSSubScriptLoader) 
     22  .loadSubScript("chrome://ai-sidebar/content/tree-event.js", ainspectorSidebar); 
    1823 
    1924/** 
     
    5055    ], 
    5156    defaultSortButton: null, 
    52     updateCallback:    null, 
     57    updateCallback:    ainspectorSidebar.updateSelectedElement, 
    5358    loggerCallback:    null 
    5459  }; 
     
    343348    var node = ainspectorSidebar.getDomElementNode(nodeResult); 
    344349    ainspectorSidebar.updatePageInspector(node); 
     350  } 
     351  else { 
     352    ainspectorSidebar.closePageInspector(); 
    345353  } 
    346354}; 
  • trunk/proto-15/chrome/content/view-category.js

    r250 r257  
    2121  .getService(Components.interfaces.mozIJSSubScriptLoader) 
    2222  .loadSubScript("chrome://ai-sidebar/content/tree-sort.js", ainspectorSidebar); 
     23 
     24// Load the handleTreeEvent function 
     25Components.classes["@mozilla.org/moz/jssubscript-loader;1"] 
     26  .getService(Components.interfaces.mozIJSSubScriptLoader) 
     27  .loadSubScript("chrome://ai-sidebar/content/tree-event.js", ainspectorSidebar); 
    2328 
    2429// Load the DOM functions 
     
    356361  } 
    357362}; 
    358  
    359 /** 
    360  * @function handleRCTreeEvent 
    361  * 
    362  * @memberOf ainspectorSidebar 
    363  * 
    364  * @desc Handle dblclick and keypress events when row is selected. If user 
    365  *       double-clicks a row, or presses return, enter or spacebar when a 
    366  *       row is selected, go to Rule Details view. 
    367  */ 
    368  
    369 ainspectorSidebar.handleRCTreeEvent = function (event) { 
    370   var tree = ainspectorSidebar.ruleCategoryTree; 
    371   var tbo = tree.treeBoxObject; 
    372   var index = tree.currentIndex; 
    373   var isRowSelected = tree.view.selection.isSelected(index); 
    374  
    375   // do nothing when no row is selected 
    376   if (!isRowSelected) return; 
    377  
    378   switch (event.type) { 
    379     case "dblclick": 
    380       // user must dblclick on an actual row 
    381       var row = { }, col = { }, child = { }; 
    382       tbo.getCellAt(event.clientX, event.clientY, row, col, child); 
    383       if (row.value !== -1) 
    384         ainspectorSidebar.selectView(ainspector.viewConst.DETAILS); 
    385       break; 
    386     case "keypress": 
    387       // handle return (13), enter (3) and spacebar (32) keypress 
    388       if (event.keyCode === 13  || event.keyCode === 3 || event.charCode === 32) 
    389         ainspectorSidebar.selectView(ainspector.viewConst.DETAILS); 
    390       break; 
    391   } 
    392 }; 
  • trunk/proto-15/chrome/content/view-category.xul

    r250 r257  
    4545      sortResource="ainspector-result-col" 
    4646      onselect="ainspectorSidebar.updateSelectedRuleInfo(this)" 
    47       ondblclick="ainspectorSidebar.handleRCTreeEvent(event)" 
    48       onkeypress="ainspectorSidebar.handleRCTreeEvent(event)"> 
     47      ondblclick="ainspectorSidebar.handleTreeEvent(event, 1)" 
     48      onkeypress="ainspectorSidebar.handleTreeEvent(event, 1)"> 
    4949      <treecols> 
    5050        <treecol id="ainspector-rule-col" 
  • trunk/proto-15/chrome/content/view-details.xul

    r255 r257  
    3737            sortResource="ainspector-elem-result-col" 
    3838            hidecolumnpicker="true" 
    39             onselect="ainspectorSidebar.updateSelectedElement(this)"> 
     39            onselect="ainspectorSidebar.updateSelectedElement(this)" 
     40            ondblclick="ainspectorSidebar.handleTreeEvent(event, 2)" 
     41            onkeypress="ainspectorSidebar.handleTreeEvent(event, 2)"> 
    4042            <treecols> 
    4143              <treecol id="ainspector-element-col" 
     
    115117        <button 
    116118          id="ainspector-inspect-element" 
    117           label="Inspect Element" 
     119          label="&ai-button.label.inspect;" 
     120          tooltiptext="&ai-button.tooltip.inspect;" 
    118121          style="margin-left: 2px; min-width: 0" 
    119122          oncommand="ainspectorSidebar.inspectSelectedElement()"/> 
  • trunk/proto-15/chrome/locale/en-US/ai-sidebar.dtd

    r252 r257  
    44<!ENTITY ai-button.label.back              "Back"> 
    55<!ENTITY ai-button.label.evaluate          "Rerun Evaluation"> 
     6<!ENTITY ai-button.label.inspect           "Inspect Element"> 
    67<!ENTITY ai-button.label.preferences       "Preferences"> 
    78<!ENTITY ai-button.label.reports           "Reports"> 
     
    1415<!ENTITY ai-button.tooltip.backToSummary   "Back to Summary view"> 
    1516<!ENTITY ai-button.tooltip.evaluate        "Re-evaluate current page"> 
     17<!ENTITY ai-button.tooltip.inspect         "View element details with the Inspector tool"> 
    1618<!ENTITY ai-button.tooltip.preferences     "Open Preferences dialog"> 
    1719<!ENTITY ai-button.tooltip.reports         "Generate HTML report"> 
  • trunk/proto-15/install.rdf

    r255 r257  
    1010        <em:name>AInspector Sidebar</em:name> 
    1111        <em:type>2</em:type> 
    12         <em:version>0.15.0</em:version> 
     12        <em:version>0.15.1</em:version> 
    1313 
    1414        <em:targetApplication> 
     
    1616                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> 
    1717                <em:minVersion>7.0</em:minVersion> 
    18                 <em:maxVersion>25.*</em:maxVersion> 
     18                <em:maxVersion>26.*</em:maxVersion> 
    1919            </Description> 
    2020        </em:targetApplication> 
Note: See TracChangeset for help on using the changeset viewer.