
www.js.services.h2o.menuService.js Maven / Gradle / Ivy
// Generated by CoffeeScript 1.5.0
(function() {
var module;
module = angular.module('h2o.services');
module.service('MenuService', function($http, $log, $rootScope) {
var _this = this;
this.menus = {};
this.groupNameFromID = function(id) {
var components;
components = id.split(".");
if (components.length > 1) {
return components[0];
} else {
return null;
}
};
this.belongsToGroup = function(id, group) {
return _this.groupNameFromID(id) === group;
};
this.IDsInGroup = function(group) {
var id, isOpen, result, _ref;
result = [];
_ref = _this.menus;
for (id in _ref) {
isOpen = _ref[id];
if (_this.belongsToGroup(id, group)) {
result.push(id);
}
}
return result;
};
this.isOpen = function(id) {
var _ref;
return (_ref = _this.menus[id]) != null ? _ref : false;
};
this.toggleOpen = function(id) {
if (_this.isOpen(id)) {
return _this.close(id);
} else {
return _this.open(id);
}
};
this.open = function(id) {
var group, otherInSameGroupID, _i, _len, _ref;
group = _this.groupNameFromID(id);
_ref = _this.IDsInGroup(group);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
otherInSameGroupID = _ref[_i];
_this.close(otherInSameGroupID);
}
return _this.menus[id] = true;
};
return this.close = function(id) {
return _this.menus[id] = false;
};
});
}).call(this);
© 2015 - 2025 Weber Informatics LLC | Privacy Policy