Show More
@@ -1,45 +1,43 | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | define([ |
|
4 | define([ | |
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'base/js/utils', |
|
6 | 'base/js/utils', | |
7 | 'jquery', |
|
7 | 'jquery', | |
8 | ], function(IPython, utils, $){ |
|
8 | ], function(IPython, utils, $){ | |
9 | "use strict"; |
|
9 | "use strict"; | |
10 |
|
10 | |||
11 | var LoginWidget = function (selector, options) { |
|
11 | var LoginWidget = function (selector, options) { | |
12 | options = options || {}; |
|
12 | options = options || {}; | |
13 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); |
|
13 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); | |
14 | this.selector = selector; |
|
14 | this.selector = selector; | |
15 | if (this.selector !== undefined) { |
|
15 | if (this.selector !== undefined) { | |
16 | this.element = $(selector); |
|
16 | this.element = $(selector); | |
17 | this.style(); |
|
|||
18 | this.bind_events(); |
|
17 | this.bind_events(); | |
19 | } |
|
18 | } | |
20 | }; |
|
19 | }; | |
21 |
|
20 | |||
22 | LoginWidget.prototype.style = function () {}; |
|
|||
23 |
|
21 | |||
24 |
|
22 | |||
25 | LoginWidget.prototype.bind_events = function () { |
|
23 | LoginWidget.prototype.bind_events = function () { | |
26 | var that = this; |
|
24 | var that = this; | |
27 | this.element.find("button#logout").click(function () { |
|
25 | this.element.find("button#logout").click(function () { | |
28 | window.location = utils.url_join_encode( |
|
26 | window.location = utils.url_join_encode( | |
29 | that.base_url, |
|
27 | that.base_url, | |
30 | "logout" |
|
28 | "logout" | |
31 | ); |
|
29 | ); | |
32 | }); |
|
30 | }); | |
33 | this.element.find("button#login").click(function () { |
|
31 | this.element.find("button#login").click(function () { | |
34 | window.location = utils.url_join_encode( |
|
32 | window.location = utils.url_join_encode( | |
35 | that.base_url, |
|
33 | that.base_url, | |
36 | "login" |
|
34 | "login" | |
37 | ); |
|
35 | ); | |
38 | }); |
|
36 | }); | |
39 | }; |
|
37 | }; | |
40 |
|
38 | |||
41 | // Set module variables |
|
39 | // Set module variables | |
42 | IPython.LoginWidget = LoginWidget; |
|
40 | IPython.LoginWidget = LoginWidget; | |
43 |
|
41 | |||
44 | return {'LoginWidget': LoginWidget}; |
|
42 | return {'LoginWidget': LoginWidget}; | |
45 | }); |
|
43 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now