| 1 |
(function($){ |
| 2 |
$(document).on('click', '.eel-offcanvas-toggle', function(e){ |
| 3 |
e.stopPropagation(); |
| 4 |
var target = $(this).data('target'); |
| 5 |
var $offcanvas = $(target); |
| 6 |
if (!$offcanvas.data('initialized')) { |
| 7 |
$offcanvas.data('initialized', true); |
| 8 |
if (!$offcanvas.hasClass('modern')) { |
| 9 |
if ($offcanvas.hasClass('eel-offcanvas-left')) { |
| 10 |
$offcanvas.css('transform', 'translateX(-100%)'); |
| 11 |
} else { |
| 12 |
$offcanvas.css('transform', 'translateX(100%)'); |
| 13 |
} |
| 14 |
} else { |
| 15 |
$offcanvas.css({'visibility':'hidden','opacity':'0'}); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
// toggle active |
| 20 |
if ($offcanvas.hasClass('active')) { |
| 21 |
$offcanvas.removeClass('active'); |
| 22 |
$('body').removeClass('eel-offcanvas-active'); |
| 23 |
|
| 24 |
if (!$offcanvas.hasClass('modern')) { |
| 25 |
if ($offcanvas.hasClass('eel-offcanvas-left')) { |
| 26 |
$offcanvas.css('transform', 'translateX(-100%)'); |
| 27 |
} else { |
| 28 |
$offcanvas.css('transform', 'translateX(100%)'); |
| 29 |
} |
| 30 |
} else { |
| 31 |
$offcanvas.css({'visibility':'hidden','opacity':'0'}); |
| 32 |
} |
| 33 |
} else { |
| 34 |
$('.eel-offcanvas').each(function(){ |
| 35 |
var $other = $(this); |
| 36 |
if ($other[0] !== $offcanvas[0]) { |
| 37 |
$other.removeClass('active'); |
| 38 |
if (!$other.hasClass('modern')) { |
| 39 |
if ($other.hasClass('eel-offcanvas-left')) { |
| 40 |
$other.css('transform','translateX(-100%)'); |
| 41 |
} else { |
| 42 |
$other.css('transform','translateX(100%)'); |
| 43 |
} |
| 44 |
} else { |
| 45 |
$other.css({'visibility':'hidden','opacity':'0'}); |
| 46 |
} |
| 47 |
} |
| 48 |
}); |
| 49 |
|
| 50 |
$offcanvas.addClass('active'); |
| 51 |
$('body').addClass('eel-offcanvas-active'); |
| 52 |
|
| 53 |
if (!$offcanvas.hasClass('modern')) { |
| 54 |
$offcanvas.css('transform','translateX(0)'); |
| 55 |
} else { |
| 56 |
$offcanvas.css({'visibility':'visible','opacity':'1'}); |
| 57 |
} |
| 58 |
} |
| 59 |
}); |
| 60 |
|
| 61 |
$(document).on('click', function(){ |
| 62 |
var $active = $('.eel-offcanvas.active'); |
| 63 |
if ($active.length) { |
| 64 |
$active.removeClass('active'); |
| 65 |
$('body').removeClass('eel-offcanvas-active'); |
| 66 |
|
| 67 |
if (!$active.hasClass('modern')) { |
| 68 |
if ($active.hasClass('eel-offcanvas-left')) { |
| 69 |
$active.css('transform','translateX(-100%)'); |
| 70 |
} else { |
| 71 |
$active.css('transform','translateX(100%)'); |
| 72 |
} |
| 73 |
} else { |
| 74 |
$active.css({'visibility':'hidden','opacity':'0'}); |
| 75 |
} |
| 76 |
} |
| 77 |
}); |
| 78 |
|
| 79 |
$(document).on('click', '.eel-offcanvas', function(e){ |
| 80 |
e.stopPropagation(); |
| 81 |
}); |
| 82 |
|
| 83 |
})(jQuery); |
| 84 |
|