define([ "../session", "./LoginDialogWrapper", "dijit/MenuBarItem", "dojo/_base/declare", "dojo/_base/event", "dojo/_base/lang", "dojo/on" ], function(session, LoginDialogWrapper, MenuBarItem, declare, event, lang, on) { return declare([MenuBarItem], { info: null, postCreate: function() { return this.set('label', "Login"); }, startup: function() { if (this._started) { return; } this.inherited(arguments); this._update(session.get()); this.own(on(session, 'change', lang.hitch(this,function(info) { return this._update(info); }))); }, _update: function(info) { this.info = info; if (info) { return this.set('label', "Logout, " + info.username); } else { return this.set('label', "Login"); } }, onClick: function(evt) { if (this.info) { session.logout(); } else { LoginDialogWrapper.show(); } if (evt) { event.stop(evt); } return false; } }); });