modals.js 841 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Modals
  3. * @param {type} $
  4. * @param {type} window
  5. * @param {type} document
  6. * @param {type} name
  7. * @returns {undefined}
  8. */
  9. (function($, window, document, name) {
  10. var CLASS_MODAL = $.className('modal');
  11. var handle = function(event, target) {
  12. if (target.tagName === 'A' && target.hash) {
  13. var modal = document.getElementById(target.hash.replace('#', ''));
  14. if (modal && modal.classList.contains(CLASS_MODAL)) {
  15. return modal;
  16. }
  17. }
  18. return false;
  19. };
  20. $.registerTarget({
  21. name: name,
  22. index: 50,
  23. handle: handle,
  24. target: false,
  25. isReset: false,
  26. isContinue: true
  27. });
  28. window.addEventListener('tap', function(event) {
  29. if ($.targets.modal) {
  30. event.detail.gesture.preventDefault(); //fixed hashchange
  31. $.targets.modal.classList.toggle($.className('active'));
  32. }
  33. });
  34. })(mui, window, document, 'modal');