foundation.offcanvas.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ;(function ($, window, document, undefined) {
  2. 'use strict';
  3. Foundation.libs.offcanvas = {
  4. name : 'offcanvas',
  5. version : '5.2.2',
  6. settings : {},
  7. init : function (scope, method, options) {
  8. this.events();
  9. },
  10. events : function () {
  11. var self = this,
  12. S = self.S;
  13. S(this.scope).off('.offcanvas')
  14. .on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
  15. self.click_toggle_class(e, 'move-right');
  16. })
  17. .on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
  18. S(".off-canvas-wrap").removeClass("move-right");
  19. })
  20. .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
  21. self.click_toggle_class(e, 'move-left');
  22. })
  23. .on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
  24. S(".off-canvas-wrap").removeClass("move-left");
  25. })
  26. .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
  27. self.click_remove_class(e, 'move-left');
  28. self.click_remove_class(e, 'move-right');
  29. })
  30. },
  31. click_toggle_class: function(e, class_name) {
  32. e.preventDefault();
  33. this.S(e.target).closest('.off-canvas-wrap').toggleClass(class_name);
  34. },
  35. click_remove_class: function(e, class_name) {
  36. e.preventDefault();
  37. this.S('.off-canvas-wrap').removeClass(class_name);
  38. },
  39. reflow : function () {}
  40. };
  41. }(jQuery, this, this.document));