Skip to content

Commit

Permalink
Issue 5956 (Allow copying single CSS properties)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianZ committed Jan 31, 2013
1 parent c25eb8a commit a234364
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
42 changes: 42 additions & 0 deletions extension/content/firebug/css/cssPanel.js
Expand Up @@ -1151,6 +1151,28 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
);
}

var prop = Dom.getAncestorByClass(target, "cssProp");
if (prop)
{
items.push(
{
label: "css.label.Copy_Property_Declaration",
tooltiptext: "css.tip.Copy_Property_Declaration",
command: Obj.bindFixed(this.copyPropertyDeclaration, this, prop)
},
{
label: "css.label.Copy_Property_Name",
tooltiptext: "css.tip.Copy_Property_Name",
command: Obj.bindFixed(this.copyPropertyName, this, prop)
},
{
label: "css.label.Copy_Property_Value",
tooltiptext: "css.tip.Copy_Property_Value",
command: Obj.bindFixed(this.copyPropertyValue, this, prop)
}
);
}

var propValue = Dom.getAncestorByClass(target, "cssPropValue");
if (propValue)
{
Expand Down Expand Up @@ -1663,6 +1685,26 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
{
var props = this.getStyleDeclaration(cssSelector);
System.copyToClipboard(props.join(Str.lineBreak()));
},

copyPropertyDeclaration: function(prop)
{
// xxxsz: repObject should be used instead
System.copyToClipboard(Str.trim(prop.textContent));
},

copyPropertyName: function(prop)
{
// xxxsz: repObject should be used instead
var propName = prop.getElementsByClassName("cssPropName")[0];
System.copyToClipboard(propName.textContent);
},

copyPropertyValue: function(prop)
{
// xxxsz: repObject should be used instead
var propValue = prop.getElementsByClassName("cssPropValue")[0];
System.copyToClipboard(propValue.textContent);
}
});

Expand Down
12 changes: 12 additions & 0 deletions extension/locale/en-US/firebug.properties
Expand Up @@ -969,6 +969,18 @@ css.tip.Copy_Rule_Declaration=Copy the rule including all its properties to the
# Allows copying the current CSS rule's properties to the clipboard.
Copy_Style_Declaration=Copy Style Declaration
css.tip.Copy_Style_Declaration=Copy the rule's properties to the clipboard
# LOCALIZATION NOTE (css.label.Copy_Property_Declaration, css.tip.Copy_Property_Declaration,
# css.label.Copy_Property_Name, css.tip.Copy_Property_Name, css.label.Copy_Property_Value,
# css.tip.Copy_Property_Value):
# Menu item labels and tooltips used in CSS panel/Style side panel context menu.
# Allow copying the current CSS property's declaration/name/value to the clipboard.
css.label.Copy_Property_Declaration=Copy Property Declaration
css.tip.Copy_Property_Declaration=Copy the property's declaration to the clipboard
css.label.Copy_Property_Name=Copy Property Name
css.tip.Copy_Property_Name=Copy the property's name to the clipboard
css.label.Copy_Property_Value=Copy Property Value
css.tip.Copy_Property_Value=Copy the property's value to the clipboard

# LOCALIZATION NOTE (plural.Error_Count2): Semicolon list of plural forms.
# A label used in for Firebug Start Button. Displays the number of JavaScript errors found by Firebug.
# %1 = Number of errors
Expand Down

0 comments on commit a234364

Please sign in to comment.