Skip to content

Commit

Permalink
some changes related to updating css rules names and a little other c…
Browse files Browse the repository at this point in the history
…hanges
  • Loading branch information
farshidbeheshti committed Sep 20, 2012
1 parent 01e3cd3 commit 771d1c1
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions extension/content/firebug/css/cssPanel.js
Expand Up @@ -78,7 +78,7 @@ var CSSPropTag = domplate(CSSDomplateBase,
// Use a space here, so that "copy to clipboard" has it (issue 3266).
SPAN({"class": "cssColon"}, ": "),
SPAN({"class": "cssPropValue", $editable: "$rule|isEditable",
_repObject: "$prop.value"},"$prop|getPropertyValue$prop.important"
_repObject: "$prop.value$prop.important"},"$prop|getPropertyValue$prop.important"
),
SPAN({"class": "cssSemi"}, ";"
)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
var propName = propNameNode.textContent.toLowerCase();
var priority = styleRule.style.getPropertyPriority(propName);
var text = styleRule.style.getPropertyValue(propName) +
(priority ? "!" + priority : "");
(priority ? " !" + priority : "");

if (text != "")
{
Expand All @@ -1320,12 +1320,11 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
if (disabledProps[i].name == propName)
{
priority = disabledProps[i].important;
text = disabledProps[i].value + (priority ? " "+priority : "");
text = disabledProps[i].value + (priority ? " !" + priority : "");
break;
}
}
}
FBTrace.sysout("disabledProps", {disabledProps:disabledProps, propName: propName, text: text});
}
var cssValue;

Expand Down Expand Up @@ -1742,6 +1741,7 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,

CSSModule.setProperty(rule, value, parsedValue.value,
parsedValue.priority);
propName = value;
}

Events.dispatch(CSSModule.fbListeners, "onCSSPropertyNameChanged", [rule, value,
Expand Down Expand Up @@ -1773,7 +1773,7 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
parsedValue = parsePriority(value);
CSSModule.setProperty(rule, propName, parsedValue.value,
parsedValue.priority);
// save in rep object.
// Save in rep object.
Dom.getAncestorByClass(target, "cssPropValue").repObject = value;
}
else if (previousValue && previousValue != "null")
Expand Down Expand Up @@ -1884,11 +1884,6 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
{
var row = Dom.getAncestorByClass(target, "cssProp");
value = Firebug.getRepObject(propValue);

if (Options.get("colorDisplay") == "hex")
value = Css.rgbToHex(value);
else if (Options.get("colorDisplay") == "hsl")
value = Css.rgbToHSL(value);
}
return value;
},
Expand Down Expand Up @@ -2293,13 +2288,13 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
"'", target);

target.innerHTML = Str.escapeForCss(value);

if (value === previousValue)
return;

var row = Dom.getAncestorByClass(target, "cssRule");

var rule = Firebug.getRepObject(target);

var searchRule = rule || Firebug.getRepObject(row.nextSibling);
var oldRule, ruleIndex;

Expand Down Expand Up @@ -2348,12 +2343,6 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
ruleIndex = cssRules.length;
}

// Delete in all cases except for new add
// We want to do this before the insert to ease change tracking
if (oldRule)
{
CSSModule.deleteRule(styleSheet, ruleIndex);
}

// Firefox does not follow the spec for the update selector text case.
// When attempting to update the value, firefox will silently fail.
Expand All @@ -2367,25 +2356,35 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
var props = row.getElementsByClassName("cssProp");
for (var i = 0; i < props.length; i++)
{

var propEl = props[i];
if (!Css.hasClass(propEl, "disabledStyle"))
{
var propName = Dom.getChildByClass(propEl, "cssPropName").textContent;
cssText.push(propName);
cssText.push(":");
cssText.push(rule.style.getPropertyValue(propName) +
rule.style.getPropertyPriority(propName) ? "!important" : "");
(rule.style.getPropertyPriority(propName) ? " !important" : ""));
cssText.push(";");
}
}

cssText.push("}");
cssText = cssText.join("");

// Delete in all cases except for new add
// We want to do this before the insert to ease change tracking
if (oldRule)
{
CSSModule.deleteRule(styleSheet, ruleIndex);
}

try
{
var insertLoc = CSSModule.insertRule(styleSheet, cssText, ruleIndex);

rule = cssRules[insertLoc];

ruleIndex++;

var saveSuccess = (this.panel.name != "css");
Expand Down Expand Up @@ -2416,6 +2415,10 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
}
else
{
if (oldRule)
{
CSSModule.deleteRule(styleSheet, ruleIndex);
}
rule = undefined;
}

Expand All @@ -2427,6 +2430,7 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
this.panel.markChange(this.panel.name == "stylesheet");
},


getAutoCompleteRange: function(value, offset)
{
if (!Css.hasClass(this.target, "cssSelector"))
Expand Down

0 comments on commit 771d1c1

Please sign in to comment.