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

Commit

Permalink
Merge pull request #3599 from adobe/randy/issue-3581
Browse files Browse the repository at this point in the history
Quick View: handle subsequent images in url()
  • Loading branch information
RaymondLim committed Apr 24, 2013
2 parents c2deabe + b904630 commit 8fb5c9a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/extensions/default/QuickView/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,21 @@ define(function (require, exports, module) {
var cm = editor._codeMirror;

// Check for image name
var urlRegEx = /url\(([^\)]*)\)/,
var urlRegEx = /url\(([^\)]*)\)/gi,
tokenString,
urlMatch = line.match(urlRegEx);

if (urlMatch && pos.ch >= urlMatch.index && pos.ch <= urlMatch.index + urlMatch[0].length) {
tokenString = urlMatch[1];
} else if (token.className === "string") {
urlMatch;

if (token.className === "string") {
tokenString = token.string;
} else {
urlMatch = urlRegEx.exec(line);
while (urlMatch) {
if (pos.ch >= urlMatch.index && pos.ch <= urlMatch.index + urlMatch[0].length) {
tokenString = urlMatch[1];
break;
}
urlMatch = urlRegEx.exec(line);
}
}

if (tokenString) {
Expand Down
7 changes: 6 additions & 1 deletion src/extensions/default/QuickView/unittest-files/test.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,9 @@ background: -ms-linear-gradient(top, #d2dfed 0%,#c8d7eb 26%,#bed0ea 51%,#a6c0e3
background: 'img/Gradient.png';
background: 'img/Lake_mapourika_NZ.jpeg';
}


.foo {
background: -webkit-image-set(url("img/Lake_mapourika_NZ.jpeg") 1x, url("img/Gradient.png") 2x);
background: -webkit-image-set(url(img/Lake_mapourika_NZ.jpeg) 1x, url(img/Gradient.png) 2x);
background: -webkit-image-set("img/Lake_mapourika_NZ.jpeg" 1x, "img/Gradient.png" 2x);
}
8 changes: 8 additions & 0 deletions src/extensions/default/QuickView/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ define(function (require, exports, module) {
checkImagePathAtPos("img/Gradient.png", 148, 26);
checkImagePathAtPos("Lake_mapourika_NZ.jpeg", 149, 26);
});
});

it("Should show image preview for subsequent images in a line", function () {
runs(function () {
checkImagePathAtPos("img/Gradient.png", 146, 84); // url("")
checkImagePathAtPos("img/Gradient.png", 147, 84); // url()
checkImagePathAtPos("img/Gradient.png", 148, 84); // ""
});

// This must be in the last spec in the suite.
runs(function () {
Expand Down

0 comments on commit 8fb5c9a

Please sign in to comment.