Start on new tag view

This commit is contained in:
Joseph Schorr 2015-03-09 22:03:39 -07:00
parent 581a284744
commit afc8e95e19
103 changed files with 148505 additions and 458 deletions

View file

@ -2,6 +2,46 @@
* Service which provides helper methods for performing some simple UI operations.
*/
angular.module('quay').factory('UIService', [function() {
var CheckStateController = function(items) {
this.items = items;
this.checked = [];
};
CheckStateController.prototype.isChecked = function(item) {
return $.inArray(item, this.checked) >= 0;
};
CheckStateController.prototype.toggleItem = function(item) {
if (this.isChecked(item)) {
this.uncheckItem(item);
} else {
this.checkItem(item);
}
};
CheckStateController.prototype.toggleItems = function() {
if (this.checked.length) {
this.checked = [];
} else {
this.checked = this.items.slice();
}
};
CheckStateController.prototype.checkByFilter = function(filter) {
this.checked = $.grep(this.items, filter);
};
CheckStateController.prototype.checkItem = function(item) {
this.checked.push(item);
};
CheckStateController.prototype.uncheckItem = function(item) {
this.checked = $.grep(this.checked, function(cItem) {
return cItem != item;
});
};
var uiService = {};
uiService.hidePopover = function(elem) {
@ -33,5 +73,9 @@ angular.module('quay').factory('UIService', [function() {
}
};
uiService.createCheckStateController = function(items) {
return new CheckStateController(items);
};
return uiService;
}]);