/** * @file * A JavaScript file for the theme. * * In order for this JavaScript to be loaded on pages, see the instructions in * the README.txt next to this file. */ // JavaScript should be made compatible with libraries other than jQuery by // wrapping it with an "anonymous closure". See: // - https://drupal.org/node/1446420 // - http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth (function ($, Drupal, window, document, undefined) { // To understand behaviors, see https://drupal.org/node/756722#behaviors Drupal.behaviors.AddClassTableTr = { attach: function(context, settings) { $(window).on('load', function(event) { var $el = $(".node-type-birell #page #main #content .box-bk table"); $el.find('tr').last().addClass('last'); $el.find('tr').first().addClass('first'); $el.find('tr').each(function(index, el) { $(this).children().last().addClass('last'); $(this).children().first().addClass('first'); }); var $icons = $("#block-views-birell-block-3"); $(".box-birell").children('img').after($icons); if( $icons.find("img").length === 0 ){ $icons.remove(); } if( $icons.find('img').length > 0){ $(".node-type-birell #page #main #content .box-bk .wrapper-birell .ingredient ul").addClass('paddingBottom'); } ////move table var $tb = $(".node-type-birell #page #main #content .box-bk table"); var $h2 = $(".node-type-birell #page #main #content .box-bk .wrapper-birell .ingredient ul").next(); var $ingredient = $(".node-type-birell #page #main #content .box-bk .wrapper-birell .ingredient"); var $BoxBirell = $(".node-type-birell #page #main #content .box-bk .wrapper-birell .box-birell"); $tb.wrap('
'); $tb.parent().prepend($h2); function moveTable(){ if( $(window).width() > 768 ){ $ingredient.append($tb.parent()); $tb.parent().css("padding-top",""); var PaddingBottom = ($BoxBirell.outerHeight(true) - $ingredient.outerHeight(true)); $ingredient.parent().css("padding-bottom",PaddingBottom+"px"); }else{ $ingredient.next().after($tb.parent()); $ingredient.parent().css("padding-bottom",""); var PaddingTop = ($BoxBirell.outerHeight(true) - $ingredient.outerHeight(true)); if( PaddingTop < 0 ){ PaddingTop = 0; } $tb.addClass('tableProducts').parent().css("padding-top",PaddingTop+"px"); } } $(window).on('resize', function(event) { moveTable(); }); moveTable(); }); } }; })(jQuery, Drupal, this, this.document);