Last change
on this file since 466 was
466,
checked in by hendrikvanantwerpen, 12 years ago
|
Added authentication (fixed user now).
|
File size:
1.0 KB
|
Line | |
---|
1 | define [ |
---|
2 | "../session", |
---|
3 | "dijit/DropDownMenu", |
---|
4 | "dijit/registry", |
---|
5 | "dijit/MenuBarItem", |
---|
6 | "dojo/_base/declare", |
---|
7 | "dojo/_base/event", |
---|
8 | "dojo/on" |
---|
9 | ], (session, DropDownMenu, registry, MenuBarItem, declare, event, _on) -> |
---|
10 | declare [MenuBarItem], |
---|
11 | info: null |
---|
12 | postCreate: () -> |
---|
13 | @loginDialog = registry.byId 'loginDialog' |
---|
14 | console.error "Cannot find loginDialog" if not @loginDialog |
---|
15 | @set 'label', "Login" |
---|
16 | startup: () -> |
---|
17 | if @_started then return |
---|
18 | @inherited arguments |
---|
19 | @_update session.get() |
---|
20 | _on session, 'change', (info) => @_update info |
---|
21 | _update: (info) -> |
---|
22 | @info = info |
---|
23 | if info |
---|
24 | @set 'label', "Logout, "+info.username |
---|
25 | else |
---|
26 | @set 'label', "Login" |
---|
27 | onClick: (evt) -> |
---|
28 | if @info |
---|
29 | session.logout() |
---|
30 | else |
---|
31 | @loginDialog.show() |
---|
32 | event.stop evt if evt |
---|
33 | false |
---|
Note: See
TracBrowser
for help on using the repository browser.