popup.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Popup.template.events({
  2. 'click .js-back-view'() {
  3. Popup.back();
  4. },
  5. 'click .js-close-pop-over'() {
  6. Popup.close();
  7. },
  8. 'click .js-confirm'() {
  9. this.__afterConfirmAction.call(this);
  10. },
  11. // This handler intends to solve a pretty tricky bug with our popup
  12. // transition. The transition is implemented using a large container
  13. // (.content-container) that is moved on the x-axis (from 0 to n*PopupSize)
  14. // inside a wrapper (.container-wrapper) with a hidden overflow. The problem
  15. // is that sometimes the wrapper is scrolled -- even if there are no
  16. // scrollbars. This happen for instance when the newly opened popup has some
  17. // focused field, the browser will automatically scroll the wrapper, resulting
  18. // in moving the whole popup container outside of the popup wrapper. To
  19. // disable this behavior we have to manually reset the scrollLeft position
  20. // whenever it is modified.
  21. 'scroll .content-wrapper'(evt) {
  22. evt.currentTarget.scrollLeft = 0;
  23. },
  24. });
  25. // When a popup content is removed (ie, when the user press the "back" button),
  26. // we need to wait for the container translation to end before removing the
  27. // actual DOM element. For that purpose we use the undocumented `_uihooks` API.
  28. Popup.template.onRendered(() => {
  29. const container = this.find('.content-container');
  30. container._uihooks = {
  31. removeElement(node) {
  32. $(node).addClass('no-height');
  33. $(container).one(CSSEvents.transitionend, () => {
  34. node.parentNode.removeChild(node);
  35. });
  36. },
  37. };
  38. });