popup.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // XXX This event list must be abstracted somewhere else.
  2. function whichTransitionEvent() {
  3. var t;
  4. var el = document.createElement('fakeelement');
  5. var transitions = {
  6. transition:'transitionend',
  7. OTransition:'oTransitionEnd',
  8. MozTransition:'transitionend',
  9. WebkitTransition:'webkitTransitionEnd'
  10. };
  11. for (t in transitions) {
  12. if (el.style[t] !== undefined) {
  13. return transitions[t];
  14. }
  15. }
  16. }
  17. var transitionEvent = whichTransitionEvent();
  18. Popup.template.events({
  19. click: function(evt) {
  20. if (evt.originalEvent) {
  21. evt.originalEvent.clickInPopup = true;
  22. }
  23. },
  24. 'click .js-back-view': function() {
  25. Popup.back();
  26. },
  27. 'click .js-close-pop-over': function() {
  28. Popup.close();
  29. },
  30. 'click .js-confirm': function() {
  31. this.__afterConfirmAction.call(this);
  32. }
  33. });
  34. // When a popup content is removed (ie, when the user press the "back" button),
  35. // we need to wait for the container translation to end before removing the
  36. // actual DOM element. For that purpose we use the undocumented `_uihooks` API.
  37. Popup.template.onRendered(function() {
  38. var container = this.find('.content-container');
  39. container._uihooks = {
  40. removeElement: function(node) {
  41. $(node).addClass('no-height');
  42. $(container).one(transitionEvent, function() {
  43. node.parentNode.removeChild(node);
  44. });
  45. }
  46. };
  47. });