loginwidget.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. define([
  4. 'jquery',
  5. 'base/js/utils',
  6. ], function($, utils){
  7. "use strict";
  8. var LoginWidget = function (selector, options) {
  9. options = options || {};
  10. this.base_url = options.base_url || utils.get_body_data("baseUrl");
  11. this.selector = selector;
  12. if (this.selector !== undefined) {
  13. this.element = $(selector);
  14. this.bind_events();
  15. }
  16. };
  17. LoginWidget.prototype.bind_events = function () {
  18. var that = this;
  19. this.element.find("button#logout").click(function () {
  20. window.location = utils.url_path_join(
  21. that.base_url,
  22. "logout"
  23. );
  24. });
  25. this.element.find("button#login").click(function () {
  26. window.location = utils.url_path_join(
  27. that.base_url,
  28. "login"
  29. );
  30. });
  31. };
  32. return {'LoginWidget': LoginWidget};
  33. });