Skip to content

Commit ff6ccfa

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

File tree

5 files changed

+146
-1
lines changed

5 files changed

+146
-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+
// Make sure the logo base has a trailing slash.
1542+
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
1543+
if (logoBaseUrl && !logoBaseUrl.endsWith('/')) {
1544+
logoBaseUrl += '/';
1545+
}
1546+
1547+
return function(iconClass) {
1548+
if (!iconClass) {
1549+
return '';
1550+
}
1551+
1552+
var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
1553+
if (!logoImage) {
1554+
return '';
1555+
}
1556+
1557+
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
1558+
return logoImage;
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+
// Make sure the logo base has a trailing slash.
1752+
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
1753+
if (logoBaseUrl && !logoBaseUrl.endsWith('/')) {
1754+
logoBaseUrl += '/';
1755+
}
1756+
1757+
return function(iconClass) {
1758+
if (!iconClass) {
1759+
return '';
1760+
}
1761+
1762+
var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
1763+
if (!logoImage) {
1764+
return '';
1765+
}
1766+
1767+
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
1768+
return logoImage;
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

+14-1
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,20 @@ 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+
var logoBaseUrl = _.get(window, "OPENSHIFT_CONSTANTS.LOGO_BASE_URL");
785+
return logoBaseUrl && !logoBaseUrl.endsWith("/") && (logoBaseUrl += "/"), function(iconClass) {
786+
if (!iconClass) return "";
787+
var logoImage = _.get(window, [ "OPENSHIFT_CONSTANTS", "LOGOS", iconClass ]);
788+
return logoImage ? !logoBaseUrl || isAbsoluteURLFilter(logoImage) ? logoImage :logoBaseUrl + logoImage :"";
789+
};
790+
} ]), angular.module("openshiftCommonUI").filter("isAbsoluteURL", function() {
791+
return function(url) {
792+
if (!url) return !1;
793+
var uri = new URI(url), protocol = uri.protocol();
794+
return uri.is("absolute") && ("http" === protocol || "https" === protocol);
795+
};
796+
}), angular.module("openshiftCommonUI").filter("linkify", [ "HTMLService", function(HTMLService) {
784797
return function(text, target, alreadyEscaped) {
785798
return HTMLService.linkify(text, target, alreadyEscaped);
786799
};

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+
// Make sure the logo base has a trailing slash.
10+
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
11+
if (logoBaseUrl && !logoBaseUrl.endsWith('/')) {
12+
logoBaseUrl += '/';
13+
}
14+
15+
return function(iconClass) {
16+
if (!iconClass) {
17+
return '';
18+
}
19+
20+
var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
21+
if (!logoImage) {
22+
return '';
23+
}
24+
25+
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
26+
return logoImage;
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)