Skip to content

Commit a0400d5

Browse files
committed
Add SVG icons
1 parent 63afba8 commit a0400d5

File tree

5 files changed

+147
-1
lines changed

5 files changed

+147
-1
lines changed

dist/origin-web-common-ui.js

+44
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,50 @@ angular.module('openshiftCommonUI')
15321532
});
15331533
;'use strict';
15341534

1535+
angular.module('openshiftCommonUI')
1536+
// Returns an image URL for an icon class if available. Some icons we have
1537+
// color SVG images for. Depends on window.OPENSHIFT_CONSTANTS.LOGOS and
1538+
// window.OPENSHIFT_CONSTANTS.LOGO_BASE_URL, which is set by origin-web-console
1539+
// (or an extension).
1540+
.filter('imageForIconClass', function(isAbsoluteURLFilter) {
1541+
return function(iconClass) {
1542+
if (!iconClass) {
1543+
return '';
1544+
}
1545+
1546+
var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
1547+
if (!logoImage) {
1548+
return '';
1549+
}
1550+
1551+
// Make sure the logo base has a trailing slash.
1552+
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
1553+
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
1554+
return logoImage;
1555+
}
1556+
1557+
if (!logoBaseUrl.endsWith('/')) {
1558+
logoBaseUrl += '/';
1559+
}
1560+
1561+
return logoBaseUrl + logoImage;
1562+
};
1563+
});
1564+
;'use strict';
1565+
1566+
angular.module('openshiftCommonUI')
1567+
.filter('isAbsoluteURL', function() {
1568+
return function(url) {
1569+
if (!url) {
1570+
return false;
1571+
}
1572+
var uri = new URI(url);
1573+
var protocol = uri.protocol();
1574+
return uri.is('absolute') && (protocol === 'http' || protocol === 'https');
1575+
};
1576+
});
1577+
;'use strict';
1578+
15351579
angular.module('openshiftCommonUI')
15361580
// Usage: <span ng-bind-html="text | linkify : '_blank'"></span>
15371581
//

dist/origin-web-common.js

+44
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,50 @@ angular.module('openshiftCommonUI')
17421742
}]);
17431743
;'use strict';
17441744

1745+
angular.module('openshiftCommonUI')
1746+
// Returns an image URL for an icon class if available. Some icons we have
1747+
// color SVG images for. Depends on window.OPENSHIFT_CONSTANTS.LOGOS and
1748+
// window.OPENSHIFT_CONSTANTS.LOGO_BASE_URL, which is set by origin-web-console
1749+
// (or an extension).
1750+
.filter('imageForIconClass', ["isAbsoluteURLFilter", function(isAbsoluteURLFilter) {
1751+
return function(iconClass) {
1752+
if (!iconClass) {
1753+
return '';
1754+
}
1755+
1756+
var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
1757+
if (!logoImage) {
1758+
return '';
1759+
}
1760+
1761+
// Make sure the logo base has a trailing slash.
1762+
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
1763+
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
1764+
return logoImage;
1765+
}
1766+
1767+
if (!logoBaseUrl.endsWith('/')) {
1768+
logoBaseUrl += '/';
1769+
}
1770+
1771+
return logoBaseUrl + logoImage;
1772+
};
1773+
}]);
1774+
;'use strict';
1775+
1776+
angular.module('openshiftCommonUI')
1777+
.filter('isAbsoluteURL', function() {
1778+
return function(url) {
1779+
if (!url) {
1780+
return false;
1781+
}
1782+
var uri = new URI(url);
1783+
var protocol = uri.protocol();
1784+
return uri.is('absolute') && (protocol === 'http' || protocol === 'https');
1785+
};
1786+
});
1787+
;'use strict';
1788+
17451789
angular.module('openshiftCommonUI')
17461790
// Usage: <span ng-bind-html="text | linkify : '_blank'"></span>
17471791
//

dist/origin-web-common.min.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,21 @@ return _.isRegExp(keyword) ? keyword.source :_.escapeRegExp(keyword);
780780
}).join("|"), result = "", lastIndex = 0, flags = caseSensitive ? "g" :"ig", regex = new RegExp(source, flags); null !== (match = regex.exec(str)); ) lastIndex < match.index && (result += _.escape(str.substring(lastIndex, match.index))), result += "<mark>" + _.escape(match[0]) + "</mark>", lastIndex = regex.lastIndex;
781781
return lastIndex < str.length && (result += _.escape(str.substring(lastIndex))), result;
782782
};
783-
} ]), angular.module("openshiftCommonUI").filter("linkify", [ "HTMLService", function(HTMLService) {
783+
} ]), angular.module("openshiftCommonUI").filter("imageForIconClass", [ "isAbsoluteURLFilter", function(isAbsoluteURLFilter) {
784+
return function(iconClass) {
785+
if (!iconClass) return "";
786+
var logoImage = _.get(window, [ "OPENSHIFT_CONSTANTS", "LOGOS", iconClass ]);
787+
if (!logoImage) return "";
788+
var logoBaseUrl = _.get(window, "OPENSHIFT_CONSTANTS.LOGO_BASE_URL");
789+
return !logoBaseUrl || isAbsoluteURLFilter(logoImage) ? logoImage :(logoBaseUrl.endsWith("/") || (logoBaseUrl += "/"), logoBaseUrl + logoImage);
790+
};
791+
} ]), angular.module("openshiftCommonUI").filter("isAbsoluteURL", function() {
792+
return function(url) {
793+
if (!url) return !1;
794+
var uri = new URI(url), protocol = uri.protocol();
795+
return uri.is("absolute") && ("http" === protocol || "https" === protocol);
796+
};
797+
}), angular.module("openshiftCommonUI").filter("linkify", [ "HTMLService", function(HTMLService) {
784798
return function(text, target, alreadyEscaped) {
785799
return HTMLService.linkify(text, target, alreadyEscaped);
786800
};

src/filters/imageForIconClass.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
angular.module('openshiftCommonUI')
4+
// Returns an image URL for an icon class if available. Some icons we have
5+
// color SVG images for. Depends on window.OPENSHIFT_CONSTANTS.LOGOS and
6+
// window.OPENSHIFT_CONSTANTS.LOGO_BASE_URL, which is set by origin-web-console
7+
// (or an extension).
8+
.filter('imageForIconClass', function(isAbsoluteURLFilter) {
9+
return function(iconClass) {
10+
if (!iconClass) {
11+
return '';
12+
}
13+
14+
var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
15+
if (!logoImage) {
16+
return '';
17+
}
18+
19+
// Make sure the logo base has a trailing slash.
20+
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
21+
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
22+
return logoImage;
23+
}
24+
25+
if (!logoBaseUrl.endsWith('/')) {
26+
logoBaseUrl += '/';
27+
}
28+
29+
return logoBaseUrl + logoImage;
30+
};
31+
});

src/filters/isAbsoluteURL.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
angular.module('openshiftCommonUI')
4+
.filter('isAbsoluteURL', function() {
5+
return function(url) {
6+
if (!url) {
7+
return false;
8+
}
9+
var uri = new URI(url);
10+
var protocol = uri.protocol();
11+
return uri.is('absolute') && (protocol === 'http' || protocol === 'https');
12+
};
13+
});

0 commit comments

Comments
 (0)