Skip to content

Commit

Permalink
complete tryASelector
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjbarton committed Aug 24, 2010
1 parent 53b1ece commit 6b3c299
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
61 changes: 39 additions & 22 deletions content/selectbug.js
Expand Up @@ -173,17 +173,24 @@ SelectorPanel.prototype = extend(Firebug.Panel,
if (elements && elements.length) if (elements && elements.length)
{ {
SelectorTemplate.tag.replace({object: elements}, this.panelNode); SelectorTemplate.tag.replace({object: elements}, this.panelNode);
this.showTrialSelector(this.trialSelector);
return; return;
} }
} }
catch(e) catch(e)
{ {
WarningTemplate.selectErrorTag.replace({object: e}, this.panelNode); var table = SelectorTemplate.tag.replace({object: []}, this.panelNode);
var tbody = table.lastChild;
WarningTemplate.selectErrorTag.insertRows({object: e}, tbody.lastChild);
WarningTemplate.selectErrorTextTag.insertRows({object: e}, tbody.lastChild);
this.showTrialSelector(this.trialSelector);
return; return;
} }
} }

var table = SelectorTemplate.tag.replace({object: []}, this.panelNode);
WarningTemplate.noSelectionTag.replace({object: this.selection}, this.panelNode); var tbody = table.lastChild;
WarningTemplate.noSelectionTag.insertRows({object: this.selection}, tbody.lastChild);
this.showTrialSelector(this.trialSelector);
}, },


getObjectPath: function(object) getObjectPath: function(object)
Expand Down Expand Up @@ -216,7 +223,16 @@ SelectorPanel.prototype = extend(Firebug.Panel,
this.editor = new SelectorEditor(this); this.editor = new SelectorEditor(this);


return this.editor; return this.editor;
} },

showTrialSelector: function(trialSelector)
{
var show = trialSelector ? true : false;
collapse($('trialHint', this.document), show);
var trialSelectorDiv = $('trialSelector', this.document);
trialSelectorDiv.textContent = trialSelector;
collapse(trialSelectorDiv, !show);
},


}); });


Expand All @@ -241,11 +257,11 @@ var BaseRep = domplate(Firebug.Rep,
var TrialRow = var TrialRow =
TR({"class": "watchNewRow", level: 0, onclick: "$onClickEditor"}, TR({"class": "watchNewRow", level: 0, onclick: "$onClickEditor"},
TD({"class": "watchEditCell", colspan: 3}, TD({"class": "watchEditCell", colspan: 3},
DIV({"class": "watchEditBox a11yFocusNoTab", role: "button", 'tabindex' : '0', DIV({"class": "watchEditBox a11yFocusNoTab", "id":"trialHint", role: "button", 'tabindex' : '0',
'aria-label' : $STR('a11y.labels.press enter to add new selector')}, 'aria-label' : $STR('a11y.labels.press enter to add new selector')},
$STR("selectbug.TryASelector"), $STR("selectbug.TryASelector")
DIV({"class": "trialSelector", collapsed: "true"}, "") ),
) DIV({"class": "trialSelector", "id":"trialSelector"}, "")
) )
); );


Expand All @@ -260,7 +276,7 @@ var SelectorTemplate = domplate(BaseRep,
TBODY({"class": "cssSelectionTBody"}, TBODY({"class": "cssSelectionTBody"},
TrialRow, TrialRow,
FOR("element", "$object", FOR("element", "$object",
TR({"class": "elementRow", _repObject:"$element"}, TR({"class": "selectionElementRow", _repObject:"$element"},
TD({"class": "selectionElement"}, TD({"class": "selectionElement"},
TAG( "$element|getNaturalTag", {object: "$element"}) TAG( "$element|getNaturalTag", {object: "$element"})
) )
Expand Down Expand Up @@ -296,33 +312,34 @@ function SelectorEditor(panel)
SelectorEditor.prototype = domplate(Firebug.InlineEditor.prototype, SelectorEditor.prototype = domplate(Firebug.InlineEditor.prototype,
{ {
tag: tag:
INPUT({"class": "fixedWidthEditor a11yFocusNoTab", INPUT({"class": "fixedWidthEditor selectionElement a11yFocusNoTab",
type: "text", title:$STR("Selector"), type: "text", title:$STR("Selector"),
oninput: "$onInput", onkeypress: "$onKeyPress"}), oninput: "$onInput", onkeypress: "$onKeyPress"}),


endEditing: function(target, value, cancel) endEditing: function(target, value, cancel)
{ {
if (cancel || value == "") if (cancel || value == "")
return; return;
var trialSelector = target.getElementsByClassName('trialSelector')[0]; this.panel.trialSelector = value;
trialSelector.textContent = value; this.panel.selection = this.panel.trialSelector;
collapse(trialSelector, false);
this.panel.selection = value;
this.panel.rebuild(); this.panel.rebuild();
} }
}); });




var WarningTemplate = domplate(Firebug.Rep, var WarningTemplate = domplate(Firebug.Rep,
{ {
noSelectionTag: DIV({"class":"selectbugWarning "}, noSelectionTag: TR({"class":"selectbugWarning "},
SPAN($STR("selectbug.noSelection")) TD({"class": "selectionElement"}, $STR("selectbug.noSelection"))
), ),


selectErrorTag: DIV({"class":"selectbugWarning"}, selectErrorTag: TR({"class":"selectbugWarning"},
DIV($STR("selectbug.selectorError")), TD({"class": "selectionElement"}, $STR("selectbug.selectorError"))
DIV({"class":"selectionErrorText"}, SPAN("$object")) ),
), selectErrorTextTag:
TR({"class":"selectbugWarning"},
TD({"class":"selectionErrorText selectionElement"}, SPAN("$object"))
),
}); });


// ************************************************************************************************ // ************************************************************************************************
Expand Down
5 changes: 4 additions & 1 deletion skin/classic/selectbug.css
@@ -1,8 +1,10 @@
/* Rules for selectbug's Selector panel elements */ /* Rules for selectbug's Selector panel elements */
.cssSelectionTable { .cssSelectionTable {
padding: 2px 0 0 1ex;
width: 100%; width: 100%;
} }
.selectionElement {
padding: 0 0 0 1ex;
}


.selectbugWarning { .selectbugWarning {
font-size: 11px; font-size: 11px;
Expand All @@ -15,6 +17,7 @@
padding: 1em; padding: 1em;
background-color: #FFEBEB; background-color: #FFEBEB;
} }

/* Rules for selectbug's effect on CSS stylesheet panel */ /* Rules for selectbug's effect on CSS stylesheet panel */
.selectedSelectorRule { .selectedSelectorRule {
border-color: Highlight !important; border-color: Highlight !important;
Expand Down

0 comments on commit 6b3c299

Please sign in to comment.