Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVG icons #213

Merged
merged 1 commit into from
Oct 6, 2017
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
44 changes: 44 additions & 0 deletions dist/origin-web-common-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,50 @@ angular.module('openshiftCommonUI')
});
;'use strict';

angular.module('openshiftCommonUI')
// Returns an image URL for an icon class if available. Some icons we have
// color SVG images for. Depends on window.OPENSHIFT_CONSTANTS.LOGOS and
// window.OPENSHIFT_CONSTANTS.LOGO_BASE_URL, which is set by origin-web-console
// (or an extension).
.filter('imageForIconClass', function(isAbsoluteURLFilter) {
return function(iconClass) {
if (!iconClass) {
return '';
}

var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
if (!logoImage) {
return '';
}

// Make sure the logo base has a trailing slash.
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
return logoImage;
}

if (!logoBaseUrl.endsWith('/')) {
logoBaseUrl += '/';
}

return logoBaseUrl + logoImage;
};
});
;'use strict';

angular.module('openshiftCommonUI')
.filter('isAbsoluteURL', function() {
return function(url) {
if (!url) {
return false;
}
var uri = new URI(url);
var protocol = uri.protocol();
return uri.is('absolute') && (protocol === 'http' || protocol === 'https');
};
});
;'use strict';

angular.module('openshiftCommonUI')
// Usage: <span ng-bind-html="text | linkify : '_blank'"></span>
//
Expand Down
44 changes: 44 additions & 0 deletions dist/origin-web-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,50 @@ angular.module('openshiftCommonUI')
}]);
;'use strict';

angular.module('openshiftCommonUI')
// Returns an image URL for an icon class if available. Some icons we have
// color SVG images for. Depends on window.OPENSHIFT_CONSTANTS.LOGOS and
// window.OPENSHIFT_CONSTANTS.LOGO_BASE_URL, which is set by origin-web-console
// (or an extension).
.filter('imageForIconClass', ["isAbsoluteURLFilter", function(isAbsoluteURLFilter) {
return function(iconClass) {
if (!iconClass) {
return '';
}

var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
if (!logoImage) {
return '';
}

// Make sure the logo base has a trailing slash.
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
return logoImage;
}

if (!logoBaseUrl.endsWith('/')) {
logoBaseUrl += '/';
}

return logoBaseUrl + logoImage;
};
}]);
;'use strict';

angular.module('openshiftCommonUI')
.filter('isAbsoluteURL', function() {
return function(url) {
if (!url) {
return false;
}
var uri = new URI(url);
var protocol = uri.protocol();
return uri.is('absolute') && (protocol === 'http' || protocol === 'https');
};
});
;'use strict';

angular.module('openshiftCommonUI')
// Usage: <span ng-bind-html="text | linkify : '_blank'"></span>
//
Expand Down
16 changes: 15 additions & 1 deletion dist/origin-web-common.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,21 @@ return _.isRegExp(keyword) ? keyword.source :_.escapeRegExp(keyword);
}).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;
return lastIndex < str.length && (result += _.escape(str.substring(lastIndex))), result;
};
} ]), angular.module("openshiftCommonUI").filter("linkify", [ "HTMLService", function(HTMLService) {
} ]), angular.module("openshiftCommonUI").filter("imageForIconClass", [ "isAbsoluteURLFilter", function(isAbsoluteURLFilter) {
return function(iconClass) {
if (!iconClass) return "";
var logoImage = _.get(window, [ "OPENSHIFT_CONSTANTS", "LOGOS", iconClass ]);
if (!logoImage) return "";
var logoBaseUrl = _.get(window, "OPENSHIFT_CONSTANTS.LOGO_BASE_URL");
return !logoBaseUrl || isAbsoluteURLFilter(logoImage) ? logoImage :(logoBaseUrl.endsWith("/") || (logoBaseUrl += "/"), logoBaseUrl + logoImage);
};
} ]), angular.module("openshiftCommonUI").filter("isAbsoluteURL", function() {
return function(url) {
if (!url) return !1;
var uri = new URI(url), protocol = uri.protocol();
return uri.is("absolute") && ("http" === protocol || "https" === protocol);
};
}), angular.module("openshiftCommonUI").filter("linkify", [ "HTMLService", function(HTMLService) {
return function(text, target, alreadyEscaped) {
return HTMLService.linkify(text, target, alreadyEscaped);
};
Expand Down
31 changes: 31 additions & 0 deletions src/filters/imageForIconClass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

angular.module('openshiftCommonUI')
// Returns an image URL for an icon class if available. Some icons we have
// color SVG images for. Depends on window.OPENSHIFT_CONSTANTS.LOGOS and
// window.OPENSHIFT_CONSTANTS.LOGO_BASE_URL, which is set by origin-web-console
// (or an extension).
.filter('imageForIconClass', function(isAbsoluteURLFilter) {
return function(iconClass) {
if (!iconClass) {
return '';
}

var logoImage = _.get(window, ['OPENSHIFT_CONSTANTS', 'LOGOS', iconClass]);
if (!logoImage) {
return '';
}

// Make sure the logo base has a trailing slash.
var logoBaseUrl = _.get(window, 'OPENSHIFT_CONSTANTS.LOGO_BASE_URL');
if (!logoBaseUrl || isAbsoluteURLFilter(logoImage)) {
return logoImage;
}

if (!logoBaseUrl.endsWith('/')) {
logoBaseUrl += '/';
}

return logoBaseUrl + logoImage;
};
});
13 changes: 13 additions & 0 deletions src/filters/isAbsoluteURL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

angular.module('openshiftCommonUI')
.filter('isAbsoluteURL', function() {
return function(url) {
if (!url) {
return false;
}
var uri = new URI(url);
var protocol = uri.protocol();
return uri.is('absolute') && (protocol === 'http' || protocol === 'https');
};
});