user-panel.js 827 B

123456789101112131415161718192021222324
  1. /*global Backbone, _, window */
  2. const UserPanel = Backbone.NativeView.extend({
  3. el: '.controlbox-pane',
  4. initialize () {
  5. this.render();
  6. },
  7. render () {
  8. const xhr = new XMLHttpRequest();
  9. xhr.open('GET', 'user-panel.html', true);
  10. xhr.onload = () => {
  11. this.el.innerHTML = xhr.responseText;
  12. this.modals = _.map(this.el.querySelectorAll('[data-toggle="modal"]'), (modal_el) =>
  13. new window.Modal(modal_el, {
  14. backdrop: 'static', // we don't want to dismiss Modal when Modal or backdrop is the click event target
  15. keyboard: true // we want to dismiss Modal on pressing Esc key
  16. }));
  17. window.renderAvatars();
  18. window.initSpoilers();
  19. }
  20. xhr.send();
  21. }
  22. });