Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix for issue #2227 #2446

Merged
merged 2 commits into from
Jan 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ define(function (require, exports, module) {
* rgb()/rgba() function format, or hsl()/hsla() function format.
* @const @type {RegExp}
*/
InlineColorEditor.COLOR_REGEX = /#[a-f0-9]{6}|#[a-f0-9]{3}|rgb\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?\)|rgba\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b(1|0|0\.[0-9]{1,3}) ?\)|hsl\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?\)|hsla\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b(1|0|0\.[0-9]{1,3}) ?\)/gi;
InlineColorEditor.COLOR_REGEX = /#[a-f0-9]{6}|#[a-f0-9]{3}|rgb\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?\)|rgba\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?(1|0|0?\.[0-9]{1,3}) ?\)|hsl\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?\)|hsla\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?, ?(1|0|0?\.[0-9]{1,3}) ?\)/gi;

InlineColorEditor.prototype = Object.create(InlineWidget.prototype);
InlineColorEditor.prototype.constructor = InlineColorEditor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@

.in-shorthand {
border: 1px solid #0f0f0f;
}
}

.rgba-leading-period {
background: rgba(100, 200, 150, .5);
}

.hsla-leading-period {
background: hsla(180, 50%, 50%, .5);
}
8 changes: 7 additions & 1 deletion src/extensions/default/InlineColorEditor/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ define(function (require, exports, module) {
it("should show the correct color when opened on a color in a shorthand property", function () {
testOpenColor({line: 41, ch: 27}, "#0f0f0f");
});
it("should show the correct color when opened on an rgba() color with a leading period in the alpha field", function () {
testOpenColor({line: 45, ch: 18}, "rgba(100, 200, 150, .5)");
});
it("should show the correct color when opened on an hsla() color with a leading period in the alpha field", function () {
testOpenColor({line: 49, ch: 18}, "hsla(180, 50%, 50%, .5)");
});

it("should not open when not on a color", function () {
makeColorEditor({line: 1, ch: 6});
Expand Down Expand Up @@ -1406,4 +1412,4 @@ define(function (require, exports, module) {
});
});
});
});
});