1;(function ($, window, document, undefined) { 2 'use strict'; 3 4 Foundation.libs.offcanvas = { 5 name : 'offcanvas', 6 7 version : '5.4.7', 8 9 settings : { 10 open_method: 'move', 11 close_on_click: false 12 }, 13 14 init : function (scope, method, options) { 15 this.bindings(method, options); 16 }, 17 18 events : function () { 19 var self = this, 20 S = self.S, 21 move_class = '', 22 right_postfix = '', 23 left_postfix = ''; 24 25 if (this.settings.open_method === 'move') { 26 move_class = 'move-'; 27 right_postfix = 'right'; 28 left_postfix = 'left'; 29 } else if (this.settings.open_method === 'overlap_single') { 30 move_class = 'offcanvas-overlap-'; 31 right_postfix = 'right'; 32 left_postfix = 'left'; 33 } else if (this.settings.open_method === 'overlap') { 34 move_class = 'offcanvas-overlap'; 35 } 36 37 S(this.scope).off('.offcanvas') 38 .on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) { 39 self.click_toggle_class(e, move_class + right_postfix); 40 if (self.settings.open_method !== 'overlap'){ 41 S(".left-submenu").removeClass(move_class + right_postfix); 42 } 43 $('.left-off-canvas-toggle').attr('aria-expanded', 'true'); 44 }) 45 .on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) { 46 var settings = self.get_settings(e); 47 var parent = S(this).parent(); 48 49 if(settings.close_on_click && !parent.hasClass("has-submenu") && !parent.hasClass("back")){ 50 self.hide.call(self, move_class + right_postfix, self.get_wrapper(e)); 51 parent.parent().removeClass(move_class + right_postfix); 52 }else if(S(this).parent().hasClass("has-submenu")){ 53 e.preventDefault(); 54 S(this).siblings(".left-submenu").toggleClass(move_class + right_postfix); 55 }else if(parent.hasClass("back")){ 56 e.preventDefault(); 57 parent.parent().removeClass(move_class + right_postfix); 58 } 59 $('.left-off-canvas-toggle').attr('aria-expanded', 'true'); 60 }) 61 .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) { 62 self.click_toggle_class(e, move_class + left_postfix); 63 if (self.settings.open_method !== 'overlap'){ 64 S(".right-submenu").removeClass(move_class + left_postfix); 65 } 66 $('.right-off-canvas-toggle').attr('aria-expanded', 'true'); 67 }) 68 .on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) { 69 var settings = self.get_settings(e); 70 var parent = S(this).parent(); 71 72 if(settings.close_on_click && !parent.hasClass("has-submenu") && !parent.hasClass("back")){ 73 self.hide.call(self, move_class + left_postfix, self.get_wrapper(e)); 74 parent.parent().removeClass(move_class + left_postfix); 75 }else if(S(this).parent().hasClass("has-submenu")){ 76 e.preventDefault(); 77 S(this).siblings(".right-submenu").toggleClass(move_class + left_postfix); 78 }else if(parent.hasClass("back")){ 79 e.preventDefault(); 80 parent.parent().removeClass(move_class + left_postfix); 81 } 82 $('.right-off-canvas-toggle').attr('aria-expanded', 'true'); 83 }) 84 .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) { 85 self.click_remove_class(e, move_class + left_postfix); 86 S(".right-submenu").removeClass(move_class + left_postfix); 87 if (right_postfix){ 88 self.click_remove_class(e, move_class + right_postfix); 89 S(".left-submenu").removeClass(move_class + left_postfix); 90 } 91 $('.right-off-canvas-toggle').attr('aria-expanded', 'true'); 92 }) 93 .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) { 94 self.click_remove_class(e, move_class + left_postfix); 95 $('.left-off-canvas-toggle').attr('aria-expanded', 'false'); 96 if (right_postfix) { 97 self.click_remove_class(e, move_class + right_postfix); 98 $('.right-off-canvas-toggle').attr('aria-expanded', "false"); 99 } 100 }); 101 }, 102 103 toggle: function(class_name, $off_canvas) { 104 $off_canvas = $off_canvas || this.get_wrapper(); 105 if ($off_canvas.is('.' + class_name)) { 106 this.hide(class_name, $off_canvas); 107 } else { 108 this.show(class_name, $off_canvas); 109 } 110 }, 111 112 show: function(class_name, $off_canvas) { 113 $off_canvas = $off_canvas || this.get_wrapper(); 114 $off_canvas.trigger('open').trigger('open.fndtn.offcanvas'); 115 $off_canvas.addClass(class_name); 116 }, 117 118 hide: function(class_name, $off_canvas) { 119 $off_canvas = $off_canvas || this.get_wrapper(); 120 $off_canvas.trigger('close').trigger('close.fndtn.offcanvas'); 121 $off_canvas.removeClass(class_name); 122 }, 123
124 click_toggle_class: function(e, class_name) { 125 e.preventDefault(); 126 var $off_canvas = this.get_wrapper(e); 127 this.toggle(class_name, $off_canvas); 128 }, 129 130 click_remove_class: function(e, class_name) { 131 e.preventDefault(); 132 var $off_canvas = this.get_wrapper(e); 133 this.hide(class_name, $off_canvas); 134 }, 135 136 get_settings: function(e) { 137 var offcanvas = this.S(e.target).closest('[' + this.attr_name() + ']'); 138 return offcanvas.data(this.attr_name(true) + '-init') || this.settings; 139 }, 140 141 get_wrapper: function(e) { 142 var $off_canvas = this.S(e ? e.target : this.scope).closest('.off-canvas-wrap'); 143 144 if ($off_canvas.length === 0) { 145 $off_canvas = this.S('.off-canvas-wrap'); 146 } 147 return $off_canvas; 148 }, 149 150 reflow : function () {} 151 }; 152}(jQuery, window, window.document));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.