37 lines
945 B
JavaScript
37 lines
945 B
JavaScript
/**
|
|
* Service which provides helper methods for performing some simple UI operations.
|
|
*/
|
|
angular.module('quay').factory('UIService', [function() {
|
|
var uiService = {};
|
|
|
|
uiService.hidePopover = function(elem) {
|
|
var popover = $(elem).data('bs.popover');
|
|
if (popover) {
|
|
popover.hide();
|
|
}
|
|
};
|
|
|
|
uiService.showPopover = function(elem, content) {
|
|
var popover = $(elem).data('bs.popover');
|
|
if (!popover) {
|
|
$(elem).popover({'content': '-', 'placement': 'left'});
|
|
}
|
|
|
|
setTimeout(function() {
|
|
var popover = $(elem).data('bs.popover');
|
|
popover.options.content = content;
|
|
popover.show();
|
|
}, 500);
|
|
};
|
|
|
|
uiService.showFormError = function(elem, result) {
|
|
var message = result.data['message'] || result.data['error_description'] || '';
|
|
if (message) {
|
|
uiService.showPopover(elem, message);
|
|
} else {
|
|
uiService.hidePopover(elem);
|
|
}
|
|
};
|
|
|
|
return uiService;
|
|
}]);
|