Sha256: 71eaaf7536fcee3641d4075584d39b04ad6d199aebcbabe2a2c2d43042844c8a

Contents?: true

Size: 1.88 KB

Versions: 6

Compression:

Stored size: 1.88 KB

Contents

(function(S, $) {
	var dom = S.Dom;
	var sharedUserAdmin = new Spontaneous.MetaView.UserAdmin();
	var RootMenuView = new JS.Class(S.PopoverView, {
		initialize: function(afterCloseCallback) {
			this.afterCloseCallback = afterCloseCallback;
			this.callSuper();
		},
		width: function() {
			return 250;
		},
		title: function() {
			return "Main Menu";
		},
		position_from_event: function(event) {
			var pos = this.callSuper();
			return {left: pos.left - 12, top: pos.top + 1};
		},
		view: function() {
			var outer = dom.div("#root-menu")
			outer.append(this.serviceMenu(), this.userActionMenu());
			return outer;
		},
		after_close: function() {
			console.log("root menu after close")
			if (this.afterCloseCallback && (typeof this.afterCloseCallback === "function")) {
				this.afterCloseCallback();
			}
		},
		userActionMenu: function() {
			var menu = dom.ul(".user-actions");
			menu.append(dom.li('.user.title').text(S.User.name()));
			if (S.User.is_admin()) {
				var manage = dom.a().text("User Administration").click(function() {
					Spontaneous.ContentArea.enterMeta(sharedUserAdmin);
					Spontaneous.Popover.close();
				});
				menu.append(dom.li('.user-administration').append(manage));
			}
			var logout = dom.a().text("Logout").click(function() {
				console.log("Logout");
				S.User.logout();
			});
			menu.append(dom.li('.logout').append(logout));
			return menu;
		},
		serviceMenu: function() {
			var menu = dom.ul(".external-services");
			var self = this;
			var services = S.Services.serviceList();
			if (services.length > 0) {
				menu.append(dom.li(".title").text("Services"));
				services.forEach(function(service) {
					var link = dom.a().text(service.title).click(function() {
						self.close();
						S.Services.open(service);
					});
					menu.append(dom.li().append(link))
				});
			}
			return menu;
		}
	});
	S.RootMenuView = RootMenuView;

}(Spontaneous, jQuery));

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta1 application/js/panel/root_menu.js
spontaneous-0.2.0.alpha7 application/js/panel/root_menu.js
spontaneous-0.2.0.alpha6 application/js/panel/root_menu.js
spontaneous-0.2.0.alpha5 application/js/panel/root_menu.js
spontaneous-0.2.0.alpha4 application/js/panel/root_menu.js
spontaneous-0.2.0.alpha3 application/js/panel/root_menu.js