How Bitcoin Mining Is Heating Up the Climate | Ben & Jerry's .

Live News for Picoin

154 Views

        

'));

usingOverflowMenu = true;

dbpTooltipMenu = new cbpTooltipMenu(document.getElementById('cbp-tm-menu'));

}

}

//make sure the LIs fit into the nav

function checkNavForOverflow() {

iteration_counter++;

//console.log("starting checkNavForOverflow #" + iteration_counter);

var $nav = $(nav).find("ul").first();

var $logo = $(".logo").first();

var $rightnav = $(".cbp-tm-nav-right").first();

//console.log($logo);

var logo_width = $logo.outerWidth(true);

var rightnav_width = $rightnav.outerWidth(true);

//console.log("logo_width: " + logo_width);

var $overflowMenu = $("#mobile-menu-icon-responsive>ul.dropdown").first();

//console.log($overflowMenu);

var overflow_menu_width = $("#mobile-menu-icon-responsive").outerWidth(true);

//console.log("overflow_menu_width: " + overflow_menu_width);

var nav_width = $nav.width();

//console.log("nav_width: " + nav_width);

var available_space = nav_width - logo_width - rightnav_width;

//console.log("available_space: " + available_space);

var total_length = 0;

var $allMenuItems = $nav.children();

$allMenuItems.each(function() {

var $this = $(this), this_current_width = $this.outerWidth(true);

//console.log("this_current_width: " + this_current_width);

$this.data("default-width", this_current_width);

total_length += this_current_width;

});

//console.log("total_length: " + total_length);

var $overflowMenuItems = $overflowMenu.children('li:not(.skip-responsive, #mobile-menu-icon-responsive)');

var number_of_overflow_items = $overflowMenuItems.length;

//console.log("number_of_overflow_items: " + number_of_overflow_items);

var first_overflow_item_width = $overflowMenuItems.first().data("default-width");

//console.log("first_overflow_item_width: " + first_overflow_item_width);

//need a dropdown

if (total_length > available_space) {//add an element to dropdown

//console.log("should add item");

putItemInOverflowMenu();

} else if (number_of_overflow_items > 1 && total_length + first_overflow_item_width ul.dropdown").first().prepend($menuItem);

checkNavForOverflow();

$("#mobile-menu-icon-responsive .cbp-tm-submenu li").on('keydown', function(event) {

if(event.keyCode == 27) {

$('li.cbp-tm-show-below').removeClass('cbp-tm-show');

$('li.cbp-tm-show-below').attr('aria-expanded', 'false');

$('li.cbp-tm-show-below').removeClass('cbp-tm-show-below');

$(this.parentElement.parentElement).focus();

}

});

}

}

//move LIs to the extra dropdown from main nav

function takeItemOutOfOverflowMenu() {

var $overflowMenu = $("#mobile-menu-icon-responsive>ul.dropdown");

var $overflowMenuItems = $overflowMenu.children('li:not(.skip-responsive, #mobile-menu-icon-responsive)');

if ($overflowMenuItems.length) {

var $menuItem = $overflowMenuItems.first().detach();

if ($menuItem.hasClass('cbp-tm-submenu-removed')) {

$menuItem.removeClass('cbp-tm-submenu-removed');

$menuItem.addClass('cbp-tm-submenu');

}

var $nav = $(nav).find("ul").first();

var $menuItems = $nav.children('li:not(.skip-responsive, #mobile-menu-icon-responsive)');

$menuItems.last().after($menuItem);

checkNavForOverflow();

}

}

//move all LIs from extra dropdown back to the nav

function emptyAndRemoveOverflowMenu() {

var $overflowMenu = $("#mobile-menu-icon-responsive>ul.dropdown");

var $overflowMenuItems = $overflowMenu.children('li:not(.skip-responsive, #mobile-menu-icon-responsive)');

$overflowMenuItems.each(function() {

//console.log"returning element...");

var $menuItem = $(this).detach();

if ($menuItem.hasClass('cbp-tm-submenu-removed')) {

$menuItem.removeClass('cbp-tm-submenu-removed');

$menuItem.addClass('cbp-tm-submenu');

}

var $nav = $(nav).find("ul").first();

var $menuItems = $nav.children('li:not(.skip-responsive, #mobile-menu-icon-responsive)');

$menuItems.last().after($menuItem);

});

$("#mobile-menu-icon-responsive").remove();

usingOverflowMenu = false;

}

//check if to use mobile nav or not

function detectMobileWidth() {

if (window.matchMedia('(min-width: ' + breakPoint + 'px)').matches) {

checkNavForOverflow();

} else {

emptyAndRemoveOverflowMenu();

}

}

};

$('.nav').each(function() {

new ResponsiveNav($(this), 768);

dbpTooltipMenu = new cbpTooltipMenu(document.getElementById('cbp-tm-menu'));

});

$('#mobile-menu-icon-responsive').on('touch', function(event) {

$(this).toggleClass('cbp-tm-show');

$(this).toggleClass('cbp-tm-show-below');

});

if ( $(window).width() ');

});

}

});