Show More
@@ -1,52 +1,52 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | //---------------------------------------------------------------------------- | |
2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
2 | // Copyright (C) 2008-2011 The IPython Development Team | |
3 | // |
|
3 | // | |
4 | // Distributed under the terms of the BSD License. The full license is in |
|
4 | // Distributed under the terms of the BSD License. The full license is in | |
5 | // the file COPYING, distributed as part of this software. |
|
5 | // the file COPYING, distributed as part of this software. | |
6 | //---------------------------------------------------------------------------- |
|
6 | //---------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | //============================================================================ |
|
8 | //============================================================================ | |
9 | // Login button |
|
9 | // Login button | |
10 | //============================================================================ |
|
10 | //============================================================================ | |
11 |
|
11 | |||
12 | var IPython = (function (IPython) { |
|
12 | var IPython = (function (IPython) { | |
13 | "use strict"; |
|
13 | "use strict"; | |
14 |
|
14 | |||
15 | var LoginWidget = function (selector, options) { |
|
15 | var LoginWidget = function (selector, options) { | |
16 | options = options || {}; |
|
16 | options = options || {}; | |
17 | this.base_url = options.base_url || IPython.utils.get_body_data("baseUrl"); |
|
17 | this.base_url = options.base_url || IPython.utils.get_body_data("baseUrl"); | |
18 | this.selector = selector; |
|
18 | this.selector = selector; | |
19 | if (this.selector !== undefined) { |
|
19 | if (this.selector !== undefined) { | |
20 | this.element = $(selector); |
|
20 | this.element = $(selector); | |
21 | this.style(); |
|
21 | this.style(); | |
22 | this.bind_events(); |
|
22 | this.bind_events(); | |
23 | } |
|
23 | } | |
24 | }; |
|
24 | }; | |
25 |
|
25 | |||
26 | LoginWidget.prototype.style = function () { |
|
26 | LoginWidget.prototype.style = function () { | |
27 | this.element.find("button").addClass("btn btn-small"); |
|
27 | this.element.find("button").addClass("btn btn-small"); | |
28 | }; |
|
28 | }; | |
29 |
|
29 | |||
30 |
|
30 | |||
31 | LoginWidget.prototype.bind_events = function () { |
|
31 | LoginWidget.prototype.bind_events = function () { | |
32 | var that = this; |
|
32 | var that = this; | |
33 | this.element.find("button#logout").click(function () { |
|
33 | this.element.find("button#logout").click(function () { | |
34 |
window.location = IPyth |
|
34 | window.location = IPython.utils.url_join_encode( | |
35 | that.base_url, |
|
35 | that.base_url, | |
36 | "logout" |
|
36 | "logout" | |
37 | ); |
|
37 | ); | |
38 | }); |
|
38 | }); | |
39 | this.element.find("button#login").click(function () { |
|
39 | this.element.find("button#login").click(function () { | |
40 |
window.location = IPyth |
|
40 | window.location = IPython.utils.url_join_encode( | |
41 | that.base_url, |
|
41 | that.base_url, | |
42 | "login" |
|
42 | "login" | |
43 | ); |
|
43 | ); | |
44 | }); |
|
44 | }); | |
45 | }; |
|
45 | }; | |
46 |
|
46 | |||
47 | // Set module variables |
|
47 | // Set module variables | |
48 | IPython.LoginWidget = LoginWidget; |
|
48 | IPython.LoginWidget = LoginWidget; | |
49 |
|
49 | |||
50 | return IPython; |
|
50 | return IPython; | |
51 |
|
51 | |||
52 | }(IPython)); |
|
52 | }(IPython)); |
General Comments 0
You need to be logged in to leave comments.
Login now