1/** 2 * @file 3 * Karhu Swipetable js. 4 */ 5(function($, Drupal, drupalSettings) { 6 "use strict"; 7 8 /** 9 * Swipeable Mobile Tables 10 * @type {Object} 11 */ 12 var MobileTables = { 13 init: function(context) { 14 this.applyWrappers(context); 15 $(window).on("resize load", context, MobileTables.applySlider); 16 }, 17 18 applyWrappers: function(context) { 19 var $tables = $(".responsive-table"); 20 21 var suffix = '<div class="touchable"><div class="icon">Swipe</div></div>'; 22 $tables.each(function(i) { 23 var $emt = $(this); 24 25 if (!$emt.hasClass("sticky-header")) { 26 $emt.wrap('<div class="mobiletable-wrapper"></div>'); 27 $emt.wrap('<div class="mobiletable"></div>'); 28 } 29 }); 30 $(".mobiletable").append(suffix); 31 }, 32 33 /** 34 * Apply sliding for table. 35 * 36 * @param {[type]} i [description] 37 * @param {[type]} e [description] 38 * @return {[type]} [description] 39 */ 40 applySlider: function(context) { 41 var $tables = $(".responsive-table"); 42 43 $tables.each(function(i) { 44 var $emt = $(this), 45 $parent = $emt.parent(); 46 47 if ($emt.hasClass("sticky-header")) { 48 return true; 49 } 50 51 if ($emt.get(0).scrollWidth <= $parent.get(0).clientWidth) { 52 if ($parent.hasClass("active")) { 53 $parent.removeClass("active touched").unbind("mouseleave scroll"); 54 $(".touchable", $parent).hide(); 55 } 56 return; 57 } 58 59 $parent.addClass("active"); 60 61 var table_height = $emt.height(); 62 63 $(".touchable", $parent) 64 .height(table_height) 65 .show(); 66 67 var icon_top = table_height / 2; 68 icon_top -= $(".icon", $parent).height() / 2; 69 70 $(".icon", $parent).css("top", icon_top + "px"); 71 }); 72 73 /** 74 * Hover events 75 * @return {[type]} [description] 76 */ 77 $tables.closest(".mobiletable.active").on("scroll", function() { 78 $tables.next(".touchable").fadeOut(500); 79 }); 80 81 $tables.closest(".mobiletable.active").on("mouseleave", function() { 82 $tables.next(".touchable").fadeIn(500); 83 }); 84 } 85 }; 86 87 MobileTables.init(); 88})(jQuery, Drupal, drupalSettings);
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.