Skip to content

Commit

Permalink
Issue 5862 (Crop long CSS values in Style side panel)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianZ committed Sep 6, 2012
1 parent 90cb487 commit cbc142e
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions extension/content/firebug/css/cssPanel.js
Expand Up @@ -50,6 +50,14 @@ var CSSDomplateBase =
isSelectorEditable: function(rule) isSelectorEditable: function(rule)
{ {
return rule.isSelectorEditable && this.isEditable(rule); return rule.isSelectorEditable && this.isEditable(rule);
},

getPropertyValue: function(prop)
{
var limit = Options.get("stringCropLength");
if (limit > 0)
return Str.cropString(prop.value, limit);
return prop.value;
} }
}; };


Expand All @@ -70,7 +78,7 @@ var CSSPropTag = domplate(CSSDomplateBase,
// Use a space here, so that "copy to clipboard" has it (issue 3266). // Use a space here, so that "copy to clipboard" has it (issue 3266).
SPAN({"class": "cssColon"}, ": "), SPAN({"class": "cssColon"}, ": "),
SPAN({"class": "cssPropValue", $editable: "$rule|isEditable"}, SPAN({"class": "cssPropValue", $editable: "$rule|isEditable"},
"$prop.value$prop.important" "$prop|getPropertyValue$prop.important"
), ),
SPAN({"class": "cssSemi"}, ";" SPAN({"class": "cssSemi"}, ";"
) )
Expand Down Expand Up @@ -1286,10 +1294,11 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
var propValue = Dom.getAncestorByClass(target, "cssPropValue"); var propValue = Dom.getAncestorByClass(target, "cssPropValue");
if (propValue) if (propValue)
{ {
var text = propValue.textContent; var styleRule = Firebug.getRepObject(propValue);
var prop = Dom.getAncestorByClass(target, "cssProp"); var prop = Dom.getAncestorByClass(target, "cssProp");
var propNameNode = prop.getElementsByClassName("cssPropName").item(0); var propNameNode = prop.getElementsByClassName("cssPropName").item(0);
var propName = propNameNode.textContent.toLowerCase(); var propName = propNameNode.textContent.toLowerCase();
var text = styleRule.style.getPropertyValue(propName);
var cssValue; var cssValue;


if (propName == "font" || propName == "font-family") if (propName == "font" || propName == "font-family")
Expand Down Expand Up @@ -1672,12 +1681,11 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
this.panel.removeDisabledProperty(rule, propName); this.panel.removeDisabledProperty(rule, propName);
} }


target.textContent = value;

if (rule instanceof window.CSSStyleRule || rule instanceof window.Element) if (rule instanceof window.CSSStyleRule || rule instanceof window.Element)
{ {
if (Css.hasClass(target, "cssPropName")) if (Css.hasClass(target, "cssPropName"))
{ {
target.textContent = value;


if (value && previousValue != value) // name of property has changed. if (value && previousValue != value) // name of property has changed.
{ {
Expand Down Expand Up @@ -1716,6 +1724,9 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
} }
else if (Dom.getAncestorByClass(target, "cssPropValue")) else if (Dom.getAncestorByClass(target, "cssPropValue"))
{ {
var limit = Options.get("stringCropLength");
target.textContent = limit > 0 ? Str.cropString(value, limit) : value;

propName = Dom.getChildByClass(row, "cssPropName").textContent; propName = Dom.getChildByClass(row, "cssPropName").textContent;
propValue = Dom.getChildByClass(row, "cssPropValue").textContent; propValue = Dom.getChildByClass(row, "cssPropValue").textContent;


Expand Down Expand Up @@ -1761,6 +1772,8 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
} }
else if (rule instanceof window.CSSImportRule && Css.hasClass(target, "cssMediaQuery")) else if (rule instanceof window.CSSImportRule && Css.hasClass(target, "cssMediaQuery"))
{ {
target.textContent = value;

if (FBTrace.DBG_CSS) if (FBTrace.DBG_CSS)
{ {
FBTrace.sysout("CSSEditor.saveEdit: @import media query: " + FBTrace.sysout("CSSEditor.saveEdit: @import media query: " +
Expand All @@ -1779,6 +1792,8 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
} }
else if (rule instanceof window.CSSCharsetRule) else if (rule instanceof window.CSSCharsetRule)
{ {
target.textContent = value;

if (FBTrace.DBG_CSS) if (FBTrace.DBG_CSS)
FBTrace.sysout("CSSEditor.saveEdit: @charset: " + previousValue + "->" + value); FBTrace.sysout("CSSEditor.saveEdit: @charset: " + previousValue + "->" + value);


Expand Down Expand Up @@ -1826,6 +1841,23 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
} }
}, },


getInitialValue: function(target, value)
{
if (value == "")
return value;

var propValue = Dom.getAncestorByClass(target, "cssPropValue");
if (propValue)
{
var styleRule = Firebug.getRepObject(propValue);
var prop = Dom.getAncestorByClass(target, "cssProp");
var propNameNode = prop.getElementsByClassName("cssPropName").item(0);
var propName = propNameNode.textContent.toLowerCase();
value = styleRule.style.getPropertyValue(propName);
}
return value;
},

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


getAutoCompleteRange: function(value, offset) getAutoCompleteRange: function(value, offset)
Expand Down

0 comments on commit cbc142e

Please sign in to comment.