problems with mobile navigation (max mega menu) - css

i am developing a new website with a max mega menu as main navigation. it's all working, except if i go to a subpage on my mobile device (iphone), i can't access the navigation anymore. it works perfect on the main (first) page, but not on the subpages.
the main page is: http://new.4progress.ch/
an example of a subpage is: http://new.4progress.ch/course/kompetenztraining-2016/
can anyone help me with this?
initial code:
(function($){
if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/Windows Phone/i) ){
var gdlr_touch_device = true;
}else{
var gdlr_touch_device = false;
}
// retrieve GET variable from url
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});
// blog - port nav
function gdlr_set_item_outer_nav(){
$('.blog-item-wrapper > .gdlr-nav-container').each(function(){
var container = $(this).siblings('.blog-item-holder');
var child = $(this).children();
child.css({ 'top':container.position().top, 'bottom':'auto', height: container.height() - 50 });
});
$('.portfolio-item-wrapper > .gdlr-nav-container').each(function(){
var container = $(this).siblings('.portfolio-item-holder');
var child = $(this).children();
child.css({ 'top':container.position().top, 'bottom':'auto', height: container.height() - 40 });
});
}
// runs flex slider function
$.fn.gdlr_flexslider = function(){
if(typeof($.fn.flexslider) == 'function'){
$(this).each(function(){
var flex_attr = {
animation: 'fade',
animationLoop: true,
prevText: '<i class="icon-angle-left" ></i>',
nextText: '<i class="icon-angle-right" ></i>',
useCSS: false
};
// slide duration
if( $(this).attr('data-pausetime') ){
flex_attr.slideshowSpeed = parseInt($(this).attr('data-pausetime'));
}
if( $(this).attr('data-slidespeed') ){
flex_attr.animationSpeed = parseInt($(this).attr('data-slidespeed'));
}
// set the attribute for carousel type
if( $(this).attr('data-type') == 'carousel' ){
flex_attr.move = 1;
flex_attr.animation = 'slide';
if( $(this).closest('.gdlr-item-no-space').length > 0 ){
flex_attr.itemWidth = $(this).width() / parseInt($(this).attr('data-columns'));
flex_attr.itemMargin = 0;
}else{
flex_attr.itemWidth = (($(this).width() + 30) / parseInt($(this).attr('data-columns'))) - 30;
flex_attr.itemMargin = 30;
}
// if( $(this).attr('data-columns') == "1" ){ flex_attr.smoothHeight = true; }
}else{
if( $(this).attr('data-effect') ){
flex_attr.animation = $(this).attr('data-effect');
}
}
if( $(this).attr('data-columns') ){
flex_attr.minItems = parseInt($(this).attr('data-columns'));
flex_attr.maxItems = parseInt($(this).attr('data-columns'));
}
// set the navigation to different area
if( $(this).attr('data-nav-container') ){
var flex_parent = $(this).parents('.' + $(this).attr('data-nav-container')).prev('.gdlr-nav-container');
if( flex_parent.find('.gdlr-flex-prev').length > 0 || flex_parent.find('.gdlr-flex-next').length > 0 ){
flex_attr.controlNav = false;
flex_attr.directionNav = false;
flex_attr.start = function(slider){
flex_parent.find('.gdlr-flex-next').click(function(){
slider.flexAnimate(slider.getTarget("next"), true);
});
flex_parent.find('.gdlr-flex-prev').click(function(){
slider.flexAnimate(slider.getTarget("prev"), true);
});
gdlr_set_item_outer_nav();
$(window).resize(function(){ gdlr_set_item_outer_nav(); });
}
}else{
flex_attr.controlNav = false;
flex_attr.controlsContainer = flex_parent.find('.nav-container');
}
}
$(this).flexslider(flex_attr);
});
}
}
// runs nivo slider function
$.fn.gdlr_nivoslider = function(){
if(typeof($.fn.nivoSlider) == 'function'){
$(this).each(function(){
var nivo_attr = {};
if( $(this).attr('data-pausetime') ){
nivo_attr.pauseTime = parseInt($(this).attr('data-pausetime'));
}
if( $(this).attr('data-slidespeed') ){
nivo_attr.animSpeed = parseInt($(this).attr('data-slidespeed'));
}
if( $(this).attr('data-effect') ){
nivo_attr.effect = $(this).attr('data-effect');
}
$(this).nivoSlider(nivo_attr);
});
}
}
// runs isotope function
$.fn.gdlr_isotope = function(){
if(typeof($.fn.isotope) == 'function'){
$(this).each(function(){
var layout = ($(this).attr('data-layout'))? $(this).attr('data-layout'): 'fitRows';
if( layout == 'fitRows' ) return;
// execute isotope
var isotope_element = $(this);
isotope_element.children('.clear').remove();
isotope_element.isotope({
layoutMode: layout
});
// resize event
$(window).resize(function(){
isotope_element.isotope();
});
});
}
}
// runs fancybox function
$.fn.gdlr_fancybox = function(){
if(typeof($.fn.fancybox) == 'function'){
var fancybox_attr = {
nextMethod : 'resizeIn',
nextSpeed : 250,
prevMethod : false,
prevSpeed : 250,
helpers : { media : {} }
};
if( typeof($.fancybox.helpers.thumbs) == 'object' ){
fancybox_attr.helpers.thumbs = { width: 50, height: 50 };
}
$(this).fancybox(fancybox_attr);
}
}
// responsive video
$.fn.gdlr_fluid_video = function(){
$(this).find('iframe[src^="http://www.youtube.com"], iframe[src^="//www.youtube.com"],' +
'iframe[src^="http://player.vimeo.com"], iframe[src^="//player.vimeo.com"]').each(function(){
if( ($(this).is('embed') && $(this).parent('object').length) || $(this).parent('.fluid-width-video-wrapper').length ){ return; }
if( !$(this).attr('id') ){ $(this).attr('id', 'gdlr-video-' + Math.floor(Math.random()*999999)); }
// ignore if inside layerslider
if( $(this).closest('.ls-container').length <= 0 ){
var ratio = $(this).height() / $(this).width();
$(this).removeAttr('height').removeAttr('width');
$(this).wrap('<div class="gdlr-fluid-video-wrapper"></div>').parent().css('padding-top', (ratio * 100)+"%");
}
});
}
// pie chart
$.fn.gdlr_pie_chart = function(){
if(typeof($.fn.easyPieChart) == 'function'){
$(this).each(function(){
var gdlr_chart = $(this);
$(this).easyPieChart({
animate: 1200,
lineWidth: gdlr_chart.attr('data-linewidth')? parseInt(gdlr_chart.attr('data-linewidth')): 8,
size: gdlr_chart.attr('data-size')? parseInt(gdlr_chart.attr('data-size')): 155,
barColor: gdlr_chart.attr('data-color')? gdlr_chart.attr('data-color'): '#a9e16e',
trackColor: gdlr_chart.attr('data-bg-color')? gdlr_chart.attr('data-bg-color'): '#f2f2f2',
backgroundColor: gdlr_chart.attr('data-background'),
scaleColor: false,
lineCap: 'square'
});
// for responsive purpose
if($.browser.msie && (parseInt($.browser.version) <= 8)) return;
function limit_gdlr_chart_size(){
if( gdlr_chart.parent().width() < parseInt(gdlr_chart.attr('data-size')) ){
var max_width = gdlr_chart.parent().width() + 'px';
gdlr_chart.css({'max-width': max_width, 'max-height': max_width});
}
}
limit_gdlr_chart_size();
$(window).resize(function(){ limit_gdlr_chart_size(); });
});
}
}
$(document).ready(function(){
// top woocommerce button
$('.gdlr-top-woocommerce-wrapper').hover(function(){
$(this).children('.gdlr-top-woocommerce').fadeIn(200);
}, function(){
$(this).children('.gdlr-top-woocommerce').fadeOut(200);
});
// script for accordion item
$('.gdlr-accordion-item').each(function(){
var multiple_tab = $(this).hasClass('gdlr-multiple-tab');
$(this).children('.accordion-tab').children('.accordion-title').click(function(){
var current_tab = $(this).parent();
if( current_tab.hasClass('active') ){
current_tab.removeClass('pre-active');
$(this).children('i').removeClass('icon-minus').addClass('icon-plus');
$(this).siblings('.accordion-content').slideUp(function(){ current_tab.removeClass('active'); });
}else{
current_tab.addClass('pre-active');
$(this).children('i').removeClass('icon-plus').addClass('icon-minus');
$(this).siblings('.accordion-content').slideDown(function(){ current_tab.addClass('active'); });
}
// close another tab if multiple tab is not allowed ( accordion )
if( !multiple_tab ){
current_tab.siblings().removeClass('pre-active');
current_tab.siblings().children('.accordion-title').children('i').removeClass('icon-minus').addClass('icon-plus');
current_tab.siblings().children('.accordion-content').slideUp(function(){ $(this).parent().removeClass('active'); });
}
});
});
// script for tab item
$('.tab-title-wrapper').children().click(function(){
$(this).addClass('active');
$(this).siblings().removeClass('active');
var selected_index = $(this).index() + 1;
$(this).parent().siblings('.tab-content-wrapper').children(':nth-child(' + selected_index + ')').each(function(){
$(this).siblings().removeClass('active').hide();
$(this).fadeIn(function(){ $(this).addClass('active'); });
})
});
// initiate the tab when the get tab variable is sent
var inital_tab = $.getUrlVar('tab');
if( inital_tab ){ $('#' + inital_tab.replace(',', ', #')).each(function(){ $(this).trigger('click'); }); }
// script for code item
$('.gdlr-code-item .gdlr-code-title').click(function(){
var parent = $(this).parent();
if( parent.hasClass('active') ){
$(this).children('i').removeClass('icon-minus').addClass('icon-plus');
$(this).siblings('.gdlr-code-content').slideUp(function(){
parent.removeClass('active');
});
}else{
$(this).children('i').removeClass('icon-plus').addClass('icon-minus');
$(this).siblings('.gdlr-code-content').slideDown(function(){
parent.addClass('active');
});
}
});
// script for parallax background
$('.gdlr-parallax-wrapper').each(function(){
if( $(this).hasClass('gdlr-background-image') ){
var parallax_section = $(this);
var parallax_speed = parseFloat(parallax_section.attr('data-bgspeed'));
if( parallax_speed == 0 || gdlr_touch_device ) return;
if( parallax_speed == -1 ){
parallax_section.css('background-attachment', 'fixed');
parallax_section.css('background-position', 'center center');
return;
}
$(window).scroll(function(){
// if in area of interest
if( ( $(window).scrollTop() + $(window).height() > parallax_section.offset().top ) &&
( $(window).scrollTop() < parallax_section.offset().top + parallax_section.outerHeight() ) ){
var scroll_pos = 0;
if( $(window).height() > parallax_section.offset().top ){
scroll_pos = $(window).scrollTop();
}else{
scroll_pos = $(window).scrollTop() + $(window).height() - parallax_section.offset().top;
}
parallax_section.css('background-position', 'center ' + (-scroll_pos * parallax_speed) + 'px');
}
});
}else if( $(this).hasClass('gdlr-background-video') ){
if(typeof($.fn.mb_YTPlayer) == 'function'){
$(this).children('.gdlr-bg-player').mb_YTPlayer();
}
}else{
return;
}
});
// video responsive
$('body').gdlr_fluid_video();
// runs superfish menu
if(typeof($.fn.superfish) == 'function'){
// create the mega menu script
$('#gdlr-main-navigation .sf-mega > ul').each(function(){
$(this).children('li').each(function(){
var current_item = $(this);
current_item.replaceWith(
$('<div />').addClass('sf-mega-section')
.addClass(current_item.attr('data-column'))
.attr('data-size', current_item.attr('data-size'))
.html( $('<div />').addClass('sf-mega-section-inner')
.addClass(current_item.attr('class'))
.attr('id', current_item.attr('id'))
.html(current_item.html())
)
);
});
$(this).replaceWith(this.innerHTML);
});
// make every menu same height
$('#gdlr-main-navigation .sf-mega').each(function(){
var sf_mega = $(this); $(this).show();
var row = 0; var column = 0; var max_height = 0;
sf_mega.children('.sf-mega-section').each(function(){
if( column % 60 == 0 ){
if( row != 0 ){
sf_mega.children('[data-row="' + row + '"]').children('.sf-mega-section-inner').height( max_height - 50 );
max_height = 0;
}
row++; $(this).addClass('first-column');
}
$(this).attr('data-row', row);
column += eval('60*' + $(this).attr('data-size'));
if( $(this).height() > max_height ){
max_height = $(this).height();
}
});
sf_mega.children('[data-row="' + row + '"]').children('.sf-mega-section-inner').height( max_height - 50 );
});
$('#gdlr-main-navigation').superfish({
delay: 100,
speed: 'fast',
animation: {opacity:'show', height:'show'}
});
}
// responsive menu
if(typeof($.fn.dlmenu) == 'function'){
$('#gdlr-responsive-navigation').each(function(){
$(this).find('.dl-submenu').each(function(){
if( $(this).siblings('a').attr('href') && $(this).siblings('a').attr('href') != '#' ){
var parent_nav = $('<li class="menu-item gdlr-parent-menu"></li>');
parent_nav.append($(this).siblings('a').clone());
$(this).prepend(parent_nav);
}
});
$(this).dlmenu();
});
}
// gallery thumbnail type
$('.gdlr-gallery-thumbnail').each(function(){
var thumbnail_container = $(this).children('.gdlr-gallery-thumbnail-container');
$(this).find('.gallery-item').click(function(){
var selected_slide = thumbnail_container.children('[data-id="' + $(this).attr('data-id') + '"]');
if(selected_slide.css('display') == 'block') return false;
// check the gallery height
var image_width = selected_slide.children('img').attr('width');
var image_ratio = selected_slide.children('img').attr('height') / image_width;
var temp_height = image_ratio * Math.min(thumbnail_container.width(), image_width);
thumbnail_container.animate({'height': temp_height});
selected_slide.fadeIn().siblings().hide();
return false;
});
$(window).resize(function(){ thumbnail_container.css('height', 'auto') });
});
// fancybox
$('a[href$=".jpg"], a[href$=".png"], a[href$=".gif"]').not('[data-rel="fancybox"]').attr('data-rel', 'fancybox');
$('[data-rel="fancybox"]').gdlr_fancybox();
// image shortcode
$('.gdlr-image-link-shortcode').hover(function(){
$(this).find('.gdlr-image-link-overlay').animate({opacity: 0.8}, 150);
$(this).find('.gdlr-image-link-icon').animate({opacity: 1}, 150);
}, function(){
$(this).find('.gdlr-image-link-overlay').animate({opacity: 0}, 150);
$(this).find('.gdlr-image-link-icon').animate({opacity: 0}, 150);
});
// Personnel
$('.gdlr-personnel-item.round-style .personnel-item').each(function(){
var current_item = $(this);
function gdlr_set_round_personnel_height(){
current_item.find('.personnel-item-inner').each(function(){
$(this).css('margin-top', -($(this).height()/2));
});
}
gdlr_set_round_personnel_height();
$(window).resize(function(){
gdlr_set_round_personnel_height();
});
});
$('.gdlr-personnel-item.round-style .personnel-item').hover(function(){
$(this).find('.personnel-author-image').animate({'opacity':0.05}, 200);
$(this).find('.personnel-item-inner').animate({'opacity':1}, 200);
}, function(){
$(this).find('.personnel-author-image').animate({'opacity':1}, 200);
$(this).find('.personnel-item-inner').animate({'opacity':0}, 200);
});
// Price Table
$('.gdlr-price-table-item').each(function(){
var price_table = $(this);
function set_price_table_height(){
var max_height = 0;
var price_content = price_table.find('.price-content');
price_content.css('height', 'auto');
price_content.each(function(){
if( max_height < $(this).height() ){ max_height = $(this).height(); }
});
price_content.css('height', max_height);
}
set_price_table_height()
$(window).resize(function(){ set_price_table_height(); });
});
// Default text
$('form').submit(function(){
var has_default = false;
$(this).find('input[data-default]').each(function(){
if( $(this).is('#url') ){
if( $(this).val() == $(this).attr('data-default') ) $(this).val('');
}else{
if( $(this).val() == $(this).attr('data-default') ) has_default = true;
}
});
if(has_default) return false;
});
// Search option
$('#gdlr-nav-search-form-button').click(function(){
$('#gdlr-nav-search-form').slideToggle(200);
return false;
});
$('#gdlr-nav-search-form').click(function(event){
if(event.stopPropagation){
event.stopPropagation();
}else if(window.event){
window.event.cancelBubble=true;
}
});
$("html").click(function(){
$('#gdlr-nav-search-form').slideUp(200);
});
$('.search-text input[data-default], .gdlr-comments-area input[data-default]').each(function(){
var default_value = $(this).attr("data-default");
$(this).val(default_value);
$(this).live("blur", function(){
if ($(this).val() == ""){
$(this).val(default_value);
}
}).live("focus", function(){
if ($(this).val() == default_value){
$(this).val("");
}
});
});
// smooth anchor
if( window.location.hash ){
$('html, body').animate({
scrollTop: $(window.location.hash).offset().top - 68
}, 500);
}
$('.gdlr-navigation a[href^="#"], .gdlr-responsive-navigation a[href^="#"]').click(function(){
if( $(this).attr('href').length > 1 ){
var item_id = $($(this).attr('href'));
if( $('body').hasClass('home') ){
if( item_id.length > 0 ){
$('html, body').animate({
scrollTop: item_id.offset().top - 68
}, 500);
return false;
}
}else{
window.location.replace($('.body-wrapper').attr('data-home') + '/' + $(this).attr('href'));
}
}
});
// animate ux
if( !gdlr_touch_device && ( !$.browser.msie || (parseInt($.browser.version) > 8)) ){
// image ux
$('.content-wrapper img').each(function(){
if( $(this).closest('.gdlr-ux, .ls-wp-container, .product, .flexslider, .nivoSlider').length ) return;
var ux_item = $(this);
if( ux_item.offset().top > $(window).scrollTop() + $(window).height() ){
ux_item.css({ 'opacity':0 });
}else{ return; }
$(window).scroll(function(){
if( $(window).scrollTop() + $(window).height() > ux_item.offset().top + 100 ){
ux_item.animate({ 'opacity':1 }, 1200);
}
});
});
// item ux
$('.gdlr-ux').each(function(){
var ux_item = $(this);
if( ux_item.hasClass('gdlr-chart') || ux_item.hasClass('gdlr-skill-bar') ){
if( ux_item.offset().top < $(window).scrollTop() + $(window).height() ){
if( ux_item.hasClass('gdlr-chart') && (!$.browser.msie || (parseInt($.browser.version) > 8)) ){
ux_item.gdlr_pie_chart();
}else if( ux_item.hasClass('gdlr-skill-bar') ){
ux_item.children('.gdlr-skill-bar-progress').each(function(){
if($(this).attr('data-percent')){
$(this).animate({width: $(this).attr('data-percent') + '%'}, 1200, 'easeOutQuart');
}
});
}
return;
}
}else if( ux_item.offset().top > $(window).scrollTop() + $(window).height() ){
ux_item.css({ 'opacity':0, 'padding-top':20, 'margin-bottom':-20 });
}else{ return; }
$(window).scroll(function(){
if( $(window).scrollTop() + $(window).height() > ux_item.offset().top + 100 ){
if( ux_item.hasClass('gdlr-chart') && (!$.browser.msie || (parseInt($.browser.version) > 8)) ){
ux_item.gdlr_pie_chart();
}else if( ux_item.hasClass('gdlr-skill-bar') ){
ux_item.children('.gdlr-skill-bar-progress').each(function(){
if($(this).attr('data-percent')){
$(this).animate({width: $(this).attr('data-percent') + '%'}, 1200, 'easeOutQuart');
}
});
}else{
ux_item.animate({ 'opacity':1, 'padding-top':0, 'margin-bottom':0 }, 1200);
}
}
});
});
// do not animate on scroll in mobile
}else{
// Pie chart
if(!$.browser.msie || (parseInt($.browser.version) > 8)){
$('.gdlr-chart').gdlr_pie_chart();
}
// skill bar
$('.gdlr-skill-bar-progress').each(function(){
if($(this).attr('data-percent')){
$(this).animate({width: $(this).attr('data-percent') + '%'}, 1200, 'easeOutQuart');
}
});
}
// runs nivoslider when available
$('.nivoSlider').gdlr_nivoslider();
// runs flexslider when available
$('.flexslider').gdlr_flexslider();
});
$(window).load(function(){
// run isotope when available
$('.gdlr-isotope').gdlr_isotope();
// run pie chart for ie8 and below
if($.browser.msie && (parseInt($.browser.version) <= 8)){
$('.gdlr-chart').gdlr_pie_chart();
}
// float menu
$('.body-wrapper.float-menu').each(function(){
var sub_area = $('#gdlr-header-substitute');
var main_area = sub_area.siblings('.gdlr-header-wrapper');
var logo = main_area.find('.gdlr-logo');
var logo_img = main_area.find('.gdlr-logo img');
var navigation = main_area.find('.gdlr-navigation-wrapper');
var original = {
logo_top: logo.css('margin-top'),
logo_bottom: logo.css('margin-bottom'),
nav_top: navigation.css('margin-top')
};
$(window).scroll(function(){
if( main_area.hasClass('gdlr-fixed-header') && ($(this).scrollTop() == 0 || $(this).width() < 959)){
main_area.children('.top-navigation-wrapper').slideDown(100);
logo.animate({'margin-top': original.logo_top, 'margin-bottom': original.logo_bottom}, {duration: 100, queue: false});
logo_img.animate({'width': '100%'}, {duration: 100, queue: false});
navigation.animate({'margin-top': original.nav_top}, {duration: 100, queue: false,
complete: function(){
sub_area.css('height', 'auto');
main_area.removeClass('gdlr-fixed-header');
navigation.removeAttr("style");
logo.removeAttr("style");
}
});
}else if( !main_area.hasClass('gdlr-fixed-header') && $(this).width() > 959 &&
$(this).scrollTop() > main_area.children('.gdlr-header-inner').offset().top - parseInt($('html').css('margin-top')) ){
sub_area.css('height', main_area.height());
main_area.addClass('gdlr-fixed-header');
main_area.children('.top-navigation-wrapper').hide();
logo.animate({'margin-top': '20', 'margin-bottom': '23'}, {duration: 100, queue: false});
logo_img.animate({'width': '80%'}, {duration: 100, queue: false});
navigation.animate({'margin-top': '25'}, {duration: 100, queue: false});
}
});
});
$(window).trigger('resize');
$(window).trigger('scroll');
});
})(jQuery);

Seems you have a typo in your JS code. Check your console, these errors appears on the subpage, but not the main page.
$(...).live is not a function
Uncaught TypeError: Cannot read property 'msie' of undefined

Related

Uncaught SyntaxError: expected expression, got keyword 'var' on she-header.js

I'm new to this forum and am currently receiving the error Uncaught SyntaxError: expected expression, got keyword 'var' on my she-header.js beginning at console.log and ending at header height shrink. Any help would be much appreciated. I have not tried much, and the support available is not very informative about this problem.
var $j = jQuery.noConflict();
$j( document ).ready( function() {
"use strict";
// She header
sheHeader();
} );
/* ==============================================
HEADER EFFECTS
============================================== */
function sheHeader() {
var header = $j('.she-header-yes'),
container = $j('.she-header-yes .elementor-container, .she-header-yes.e-container'),
header_elementor = $j('.elementor-edit-mode .she-header-yes'),
header_logo = $j('.she-header-yes .elementor-widget-theme-site-logo .elementor-image, .she-header-yes .elementor-widget-image .elementor-image'),
data_settings = header.data('settings');
if ( typeof data_settings != 'undefined' ) {
var responsive_settings = data_settings["transparent_on"];
var width = $j(window).width(),
header_height= header.height(),
logo_width = header_logo.width(),
logo_height = header_logo.height() ;
}
// Check responsive is enabled
if( typeof width != 'undefined' && width) {
if( width >= 1025 ) {
var enabled = "desktop";
}else if (width > 767 && width < 1025 ) {
var enabled = "tablet";
}else if (width <= 767 ) {
var enabled = "mobile";
}
}
console.log($j.inArray(enabled, responsive_settings));
if ($j.inArray(enabled, responsive_settings)!='-1') {
var scroll_distance = data_settings["scroll_distance"];
var transparent_header = data_settings["transparent_header_show"];
var background = data_settings["background"];
var bottom_border_color = data_settings["custom_bottom_border_color"],
bottom_border_view = data_settings["bottom_border"],
bottom_border_width = data_settings["custom_bottom_border_width"];
var shrink_header = data_settings["shrink_header"],
data_height = data_settings["custom_height_header"],
data_height_tablet = data_settings["custom_height_header_tablet"],
data_height_mobile = data_settings["custom_height_header_mobile"];
var shrink_logo = data_settings["shrink_header_logo"],
data_logo_height = data_settings["custom_height_header_logo"],
data_logo_height_tablet = data_settings["custom_height_header_logo_tablet"],
data_logo_height_mobile = data_settings["custom_height_header_logo_mobile"];
var change_logo_color = data_settings["change_logo_color"];
var blur_bg = data_settings["blur_bg"];
var scroll_distance_hide_header = data_settings["scroll_distance_hide_header"];**
// add transparent class
if(transparent_header == "yes" ){
header.addClass('she-header-transparent-yes');
}
// header height shrink
if( typeof data_height != 'undefined' && data_height) {
if( width >= 1025 ) {
var shrink_height = data_height["size"];
}else if (width > 767 && width < 1025 ) {
var shrink_height = data_height_tablet["size"];
if(shrink_height == ''){
shrink_height = data_height["size"];
}
}else if (width <= 767 ) {
var shrink_height = data_height_mobile["size"];
if(shrink_height == ''){
shrink_height = data_height["size"];
}
}
}
// border bottom
if( typeof bottom_border_width != 'undefined' && bottom_border_width) {
var bottom_border = bottom_border_width["size"] + "px solid " + bottom_border_color;
}
// hide header on scroll
if( typeof scroll_distance_hide_header != 'undefined' && scroll_distance_hide_header) {
var mywindow = $j(window);
var mypos = mywindow.scrollTop();
mywindow.scroll(function() {
if (mypos > scroll_distance_hide_header["size"]) {
if(mywindow.scrollTop() > mypos)
{
header.addClass('headerup');
}else{
header.removeClass('headerup');
}
}
mypos = mywindow.scrollTop();
});
}
// scroll function
$j(window).on("load scroll",function(e){
var scroll = $j(window).scrollTop();
if (header_elementor) {
header_elementor.css("position", "relative");
}
if (scroll >= scroll_distance["size"]) {
header.removeClass('header').addClass("she-header");
header.css("background-color", background);
header.css("border-bottom", bottom_border);
header.removeClass('she-header-transparent-yes');
if( shrink_header == "yes" ) {
header.css({"padding-top":"0", "padding-bottom":"0", "margin-top":"0", "margin-bottom":"0"});
container.css({"min-height": shrink_height, "transition": "all 0.4s ease-in-out", "-webkit-transition": "all 0.4s ease-in-out", "-moz-transition": "all 0.4s ease-in-out"});
}
if( change_logo_color == "yes" ) {
header_logo.addClass("change-logo-color");
}
if( blur_bg == "yes" ) {
header.css({"backdrop-filter": "saturate(180%) blur(20px)", "-webkit-backdrop-filter": "saturate(180%) blur(20px)"});
}
} else {
header.removeClass("she-header").addClass('header');
header.css("background-color", "");
header.css("border-bottom", "");
if(transparent_header == "yes" ){
header.addClass('she-header-transparent-yes');
}
if( shrink_header == "yes" ) {
header.css({"padding-top":"", "padding-bottom":"", "margin-top":"", "margin-bottom":""});
container.css("min-height", "");
}
if( change_logo_color == "yes" ) {
header_logo.removeClass("change-logo-color");
}
if( blur_bg == "yes" ) {
header.css({"backdrop-filter": "", "-webkit-backdrop-filter": ""});
}
}
});
}
};

Leaflet-markercluster default icons missing

Default icons not showing for MarkerCluster plugin after using IconCreateFunction.
I want to use the default icons for the plugin but when using attached code I loose all the icons functions, I only get the numbers with no icons and if I activate the "childCount" I get one type of circle with the numbers offcenter within the icon. The markers has already been clustered and I want to add this value to the markercluster that is why I'm using the IconCreateFuncton so the numbers on the map shows correctly but I have lost all the icons and its beautiful functions... what is missing?
Result below using "var childCount"
$.getJSON("../test/test.geojson", function(json) {
geoLayer = L.geoJson(json, {
pointToLayer: function(feature, latlng) {
var log_p = feature.properties.log_p;
var marker;
if (log_p > 0){
marker = new L.shapeMarker(latlng, {radius: log_p*25, fillColor: '#2b83ba', fillOpacity: 0.5, color: '#000000', weight: 1, shape: 'circle'});
}
else {
marker = null
}
return marker;
},
onEachFeature: function(feature, layer) {
var popupText = "Amount per day: " + '<b>' + feature.properties.total + '</b>';
layer.bindPopup(popupText, {
closeButton: true,
offset: L.point(0, -20)
});
layer.on('click', function() {
layer.openPopup();
});
},
});
var markers = new L.MarkerClusterGroup({
iconCreateFunction: function(cluster) {
var children = cluster.getAllChildMarkers();
var sum = 0;
for (var i = 0; i < children.length; i++) {
sum += children[i].feature.properties.total;
}
/*
var childCount = cluster.getAllChildMarkers();
var c = ' marker-cluster-';
if (childCount < 10) {
c += 'small';
} else if (childCount < 500) {
c += 'medium';
} else {
c += 'large';
}
*/
return new L.DivIcon({ html: '<b>' + sum + '</b>', className: 'marker-cluster'/* + c */, iconSize: new L.Point(40, 40) });
}
});
markers.addLayer(geoLayer)
map.addLayer(markers);
});
Markercluster icons, styles and functions are lost
I manage to solve the problem, a few lines of code was missing. I added them to the original JavaScript code as follows.
$.getJSON("../test/test.geojson", function(json) {
geoLayer = L.geoJson(json, {
pointToLayer: function(feature, latlng) {
var log_p = feature.properties.log_p;
var marker;
if (log_p > 0) {
marker = new L.shapeMarker(latlng, {
radius: log_p * 25,
fillColor: '#2b83ba',
fillOpacity: 0.5,
color: '#000000',
weight: 1,
shape: 'circle'
});
} else {
marker = null
}
return marker;
},
onEachFeature: function(feature, layer) {
var popupText = "Amount per day: " + '<b>' + feature.properties.total + '</b>';
layer.bindPopup(popupText, {
closeButton: true,
offset: L.point(0, -20)
});
layer.on('click', function() {
layer.openPopup();
});
},
});
var clusters = new L.MarkerClusterGroup({
maxClusterRadius: 125,
iconCreateFunction: function(cluster) {
var children = cluster.getAllChildMarkers();
var sum = 0;
for (var i = 0; i < children.length; i++) {
sum += children[i].feature.properties.total;
}
var childCount = cluster.getChildCount()
var c = ' marker-cluster-';
if (childCount + sum <= 50) {
c += 'small';
} else if (childCount + sum <= 250) {
c += 'medium';
} else {
c += 'large';
}
return new L.DivIcon({
html: '<div><span>' + sum + '</span></div>',
className: 'marker-cluster marker-cluster-' + c,
iconSize: new L.Point(40, 40)
});
},
});
clusters.addLayer(geoLayer)
map.addLayer(clusters);
});

flot plots interfering with each other

and thank you once again for your expert support. I have a rather nice implementation of flot, that has one very unfortunate bug. The plot routine works in a loop, so it creates as many plots as there are data files, that pass muster, in the directory. If there is only one data file, then only one plot, the resulting flot plot works fine and the check boxes turn the lines on and off as expected. If I have more than one data file and hence more than one flot plot.. only the bottom one seems to work correctly, the remainder lock up after either one toggle or none.
Can someone give me an idea how to create the flot plots so they do not interfere? I have read elsewhere that the function name does not need to be different, but have not verified this, and I did change the labels, but this added additional weirdness.
Quite a long code.. but it gives you most of what I know...
The first section here actually builds the data sets for flot... then the rest creates the plot...
<script type='text/javascript'>//<![CDATA[
$(function(){
var results = [
<?php
$downsample = 5;
for($k=0;$k<2; $k++){
//$k =0 is Left, $k = 1 is right
if ($k==0){
$side = "L";
$offset = 1;
} elseif ($k==1) {
$side = "R";
$offset = 0;
}
for ($m = 1; $m <= count($trackdata)-1; $m++){
echo "\n{\n\"label\": \"".$m.$side."\",\n"; //echo "\n{\n\"label\": \"".$m." ".$side."\",\n";
echo "\"data\": [";
for ($n=1;$n<=count($PSD[$m*3-2]);$n=$n+$downsample){
$tmp = "[".$PSD[$m*3-2][$n].",".$PSD[$m*3-$offset][$n]."]";
echo $tmp;
if ($n > count($PSD[$m*3-2])-$downsample){
echo "]}";
} else {
echo ",";
}
}
if ($m <> count($trackdata)-1){
echo ",";
} else if ($k<1){
echo ",";
}
}
}
echo "];";
?>
var options = {
legend: {
show: true
},
series: {
points: {
show: false
},
lines: {
show: true
}
},
grid: {
hoverable: true
},
xaxis: {
},
yaxis: {
}
};
var i = 0;
var track = 0;
choiceContainer = $("#labeler<?php echo $i ?>");
var table = $('<table />');
var row = $('<tr/>');
var cell = $('<td width=\"100\"/>');
var temp = $(table);
$.each(results, function(key, val) {
track = track + 1;
val.color = i;
++i;
l = val.label;
if (track == 1){
temp.append(row);
row.append(cell);
cell.append('Left Channel');
} else if(track == <?php echo $tracks ?>){
row = $('<tr/>');
temp.append(row);
cell = $('<td width=\"100\">');
row.append(cell);
cell.append('Right Channel');
} //else if ((track == 7) or (track == 14) or (track == 21) or (track == 28) or (track == 35)){
//}
cell = $('<td width=\"60\"/>');
row.append(cell);
var bar = $('<div style=\"width:18px; white-space:nowrap; float:left\"><bar />');
cell.append(bar);
var inp = $('<input name="' + l + '" id="' + l + '" type="checkbox" checked="checked">');
cell.append(inp);
var bits = $('<label>', {
text: l,
'for': l
});
cell.append(bits);
choiceContainer.append(temp);
});
function plotAccordingToChoices() {
var data = [];
choiceContainer.find("input:checked").each(function() {
var key = this.name;
for (var i = 0; i < results.length; i++) {
if (results[i].label === key) {
data.push(results[i]);
return true;
}
}
});
$.plot($("#placeholder<?php echo $i ?>"), data, options);
}
var previousPoint = null;
$("#placeholder<?php echo $i ?>").bind("plothover", function(event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
if (previousPoint != item.datapoint) {
previousPoint = item.datapoint;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, item.series.label + " $" + y);
}
} else {
$("#tooltip").remove();
previousPoint = null;
}
});
function showTooltip(x, y, contents) {
$('<div id="tooltip">' + contents + '</div>').css({
position: 'absolute',
display: 'none',
top: y + 5,
left: x + 15,
border: '1px solid #fdd',
padding: '2px',
backgroundColor: '#fee',
opacity: 0.80
}).appendTo("body").fadeIn(200);
}
plotAccordingToChoices();
choiceContainer.find("input").change(plotAccordingToChoices);
$('.legendColorBox > div').each(function(i){
$(this).clone().prependTo(choiceContainer.find("bar").eq(i));
});
});//]]>
</script>
Okay.. so the dust settled and I did sort out my issue, along with cleaning up a few things. First of all, I created a function for the plot routine. This uncovered the issue I was having, where I was reusing the same variables for the divs into which the data was going, hence the mixed up results. By creating the function, and then driving the function with custom variables for each iteration, the plots operate independently as they should. – Mark
function flotplot(results, choiceContainer, plotholder, numtracks, legendcontainer){
// pass in results, choicecontainer, plotholder
// results = data
// choiceContainer = $("#labeler1");
// plotholder = $("#placeholder0");
var options = {
legend: {
show: true,
container: legendcontainer,
noColumns: 2,
sorted: false
},
series: {
points: {
show: false
},
lines: {
show: true
}
},
grid: {
hoverable: true
},
xaxes: [{
axisLabel: 'Frequency (Hz)',
}],
yaxes: [{
axisLabel: 'Power (dB)',
}],
crosshair: {
mode: "xy",
color: 001,
lineWidth: .5
}
};
var i = 0;
var track = 0;
var table = $('<table />');
var row = $('<tr/>');
var cell = $('<td width=\"100\"/>');
var temp = $(table);
$.each(results, function(key, val) {
track = track + 1;
val.color = i;
++i;
l = val.label;
if (track == 1){
temp.append(row);
row.append(cell);
cell.append('Left Channel');
} else if(track == numtracks){
row = $('<tr/>');
temp.append(row);
cell = $('<td width=\"100\">');
row.append(cell);
cell.append('Right Channel');
} //else if ((track == 7) or (track == 14) or (track == 21) or (track == 28) or (track == 35)){
//}
cell = $('<td width=\"70\"/>');
row.append(cell);
var bar = $('<div style=\"width:18px; white-space:nowrap; float:left\"><bar />');
cell.append(bar);
var inp = $('<input name="' + l + '" id="' + l + '" type="checkbox" checked="checked">');
cell.append(inp);
var bits = $('<label>', {
text: l,
'for': l
});
cell.append(bits);
choiceContainer.append(temp);
});
function plotAccordingToChoices() {
var data = [];
choiceContainer.find("input:checked").each(function() {
var key = this.name;
for (var i = 0; i < results.length; i++) {
if (results[i].label === key) {
data.push(results[i]);
return true;
}
}
});
$.plot(plotholder, data, options);
}
var previousPoint = null;
plotholder.bind("plothover", function(event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
if (previousPoint != item.datapoint) {
previousPoint = item.datapoint;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, item.series.label + " " + y + "dB");
}
} else {
$("#tooltip").remove();
previousPoint = null;
}
});
function showTooltip(x, y, contents) {
$('<div id="tooltip">' + contents + '</div>').css({
position: 'absolute',
display: 'none',
top: y + 5,
left: x + 15,
border: '1px solid #fdd',
padding: '2px',
backgroundColor: '#fee',
opacity: 0.80
}).appendTo("body").fadeIn(200);
}
plotAccordingToChoices();
choiceContainer.find("input").change(plotAccordingToChoices);
$('.legendColorBox > div').each(function(i){
$(this).clone().prependTo(choiceContainer.find("bar").eq(i));
});
};//]]>
Here is the structure into which it writes:
echo "<div id=\"placeholder".$i."\" class=\"loading\" style=\"width:600px;height:300px;display: inline; position: relative; float: left\"></div>";
echo "<div id=\"legendholder".$i."\" class=\"loading\" style=\"width:200px; height:300px; display: inline; position: relative; float: left\"></div>";
echo "<div id=\"picker1\" style=\"clear: both\"><p id=\"choices".$i."\">Show the following Tracks:</p></div>";
echo "<div id=\"labeler".$i."\"></div>";

Set fixed width to Nivo Slider

I've installed Nivo Slider using the code from the demo included in the free download.
All of the images I am including in the slider are 800 pixels wide.
However, they are being resized to 1440 pixels wide. Extra code is being inserted:
<img src="images/bar.jpg" data-thumb="images/bar.jpg" alt="" title="" style="display: none; width: 1440px;">
I have searched the CSS and JS and can find no mention of 1440.
Where is this width being set?
Nivo Slider is responsive by default, if you want to limit the sliders width, use the below class in your CSS
.slider-wrapper.theme-default {
width: 800px; /* Desired width */
}
The above will work if you are using default theme of nivo slider, if you are using some other theme, than simply change the .theme-default to theme specific class which is assigned to the slider wrapper.
Use my custom nivo script code
/*
* jQuery Nivo Slider v2.5.1
* http://nivo.dev7studios.com
*
* Copyright 2011, Gilbert Pellegrom
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* March 2010
*/
(function($) {
var NivoSlider = function(element, options) {
var settings = $.extend({}, $.fn.nivoSlider.defaults, options);
var vars = {
currentSlide : 0,
currentImage : '',
totalSlides : 0,
randAnim : '',
running : false,
paused : false,
stop : false
};
var slider = $(element);
slider.data('nivo:vars', vars);
slider.css('position', 'relative');
slider.addClass('nivoSlider');
var kids = slider.children();
kids.each(function() {
var child = $(this);
var link = '';
if (!child.is('img')) {
if (child.is('a')) {
child.addClass('nivo-imageLink');
link = child;
}
child = child.find('img:first');
}
var childWidth = child.width();
if (childWidth == 0)
childWidth = child.attr('width');
var childHeight = child.height();
if (childHeight == 0)
childHeight = child.attr('height');
if (childWidth > slider.width()) {
slider.width(childWidth);
}
if (childHeight > slider.height()) {
slider.height(childHeight);
}
if (link != '') {
link.css('display', 'none');
}
child.css('display', 'none');
vars.totalSlides++;
});
if (settings.startSlide > 0) {
if (settings.startSlide >= vars.totalSlides)
settings.startSlide = vars.totalSlides - 1;
vars.currentSlide = settings.startSlide;
}
if ($(kids[vars.currentSlide]).is('img')) {
vars.currentImage = $(kids[vars.currentSlide]);
} else {
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
}
if ($(kids[vars.currentSlide]).is('a')) {
$(kids[vars.currentSlide]).css('display', 'block');
}
slider.css({
'background' : 'url("' + vars.currentImage.attr('src') + '") no-repeat',
'background-size' : settings.backgroundSize
});
slider.append($('<div class="nivo-caption"><p></p></div>').css({
display : 'none',
opacity : settings.captionOpacity
}));
var processCaption = function(settings) {
var nivoCaption = $('.nivo-caption', slider);
if (vars.currentImage.attr('title') != '') {
var title = vars.currentImage.attr('title');
if (title.substr(0, 1) == '#')
title = $(title).html();
if (nivoCaption.css('display') == 'block') {
nivoCaption.find('p').fadeOut(settings.animSpeed, function() {
$(this).html(title);
$(this).fadeIn(settings.animSpeed);
});
} else {
nivoCaption.find('p').html(title);
}
nivoCaption.fadeIn(settings.animSpeed);
} else {
nivoCaption.fadeOut(settings.animSpeed);
}
}
processCaption(settings);
var timer = 0;
if (!settings.manualAdvance && kids.length > 1) {
timer = setInterval(function() {
nivoRun(slider, kids, settings, false);
}, settings.pauseTime);
}
if (settings.directionNav) {
slider.append('<div class="nivo-directionNav"><a class="nivo-prevNav">' + settings.prevText + '</a><a class="nivo-nextNav">' + settings.nextText + '</a></div>');
if (settings.directionNavHide) {
$('.nivo-directionNav', slider).hide();
slider.hover(function() {
$('.nivo-directionNav', slider).show();
}, function() {
$('.nivo-directionNav', slider).hide();
});
}
$('a.nivo-prevNav', slider).live('click', function() {
if (vars.running)
return false;
clearInterval(timer);
timer = '';
vars.currentSlide -= 2;
nivoRun(slider, kids, settings, 'prev');
});
$('a.nivo-nextNav', slider).live('click', function() {
if (vars.running)
return false;
clearInterval(timer);
timer = '';
nivoRun(slider, kids, settings, 'next');
});
}
if (settings.controlNav) {
var nivoControl = $('<div class="nivo-controlNav"></div>');
slider.append(nivoControl);
for (var i = 0; i < kids.length; i++) {
if (settings.controlNavThumbs) {
var child = kids.eq(i);
if (!child.is('img')) {
child = child.find('img:first');
}
if (settings.controlNavThumbsFromRel) {
nivoControl.append('<a class="nivo-control" rel="' + i + '"><img src="' + child.attr('rel') + '" alt="" /></a>');
} else {
nivoControl.append('<a class="nivo-control" rel="' + i + '"><img src="' + child.attr('src').replace(settings.controlNavThumbsSearch, settings.controlNavThumbsReplace) + '" alt="" /></a>');
}
} else {
nivoControl.append('<a class="nivo-control" rel="' + i + '">' + (i + 1) + '</a>');
}
}
$('.nivo-controlNav a:eq(' + vars.currentSlide + ')', slider).addClass('active');
$('.nivo-controlNav a', slider).live('click', function() {
if (vars.running)
return false;
if ($(this).hasClass('active'))
return false;
clearInterval(timer);
timer = '';
slider.css({
'background' : 'url("' + vars.currentImage.attr('src') + '") no-repeat',
'background-size' : settings.backgroundSize
});
vars.currentSlide = $(this).attr('rel') - 1;
nivoRun(slider, kids, settings, 'control');
});
}
if (settings.keyboardNav) {
$(window).keypress(function(event) {
if (event.keyCode == '37') {
if (vars.running)
return false;
clearInterval(timer);
timer = '';
vars.currentSlide -= 2;
nivoRun(slider, kids, settings, 'prev');
}
if (event.keyCode == '39') {
if (vars.running)
return false;
clearInterval(timer);
timer = '';
nivoRun(slider, kids, settings, 'next');
}
});
}
if (settings.pauseOnHover) {
slider.hover(function() {
vars.paused = true;
clearInterval(timer);
timer = '';
}, function() {
vars.paused = false;
if (timer == '' && !settings.manualAdvance) {
timer = setInterval(function() {
nivoRun(slider, kids, settings, false);
}, settings.pauseTime);
}
});
}
slider.bind('nivo:animFinished', function() {
vars.running = false;
$(kids).each(function() {
if ($(this).is('a')) {
$(this).css('display', 'none');
}
});
if ($(kids[vars.currentSlide]).is('a')) {
$(kids[vars.currentSlide]).css('display', 'block');
}
if (timer == '' && !vars.paused && !settings.manualAdvance) {
timer = setInterval(function() {
nivoRun(slider, kids, settings, false);
}, settings.pauseTime);
}
settings.afterChange.call(this);
});
var createSlices = function(slider, settings, vars) {
for (var i = 0; i < settings.slices; i++) {
var sliceWidth = Math.round(slider.width() / settings.slices);
if (i == settings.slices - 1) {
slider.append($('<div class="nivo-slice"></div>').css({
left : (sliceWidth * i) + 'px',
width : (slider.width() - (sliceWidth * i)) + 'px',
height : '0px',
opacity : '0',
background : 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((sliceWidth + (i * sliceWidth)) - sliceWidth) + 'px 0%',
'background-size': settings.backgroundSize
}));
} else {
slider.append($('<div class="nivo-slice"></div>').css({
left : (sliceWidth * i) + 'px',
width : sliceWidth + 'px',
height : '0px',
opacity : '0',
background : 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((sliceWidth + (i * sliceWidth)) - sliceWidth) + 'px 0%',
'background-size': settings.backgroundSize
}));
}
}
}
var createBoxes = function(slider, settings, vars) {
var boxWidth = Math.round(slider.width() / settings.boxCols);
var boxHeight = Math.round(slider.height() / settings.boxRows);
for (var rows = 0; rows < settings.boxRows; rows++) {
for (var cols = 0; cols < settings.boxCols; cols++) {
if (cols == settings.boxCols - 1) {
slider.append($('<div class="nivo-box"></div>').css({
opacity : 0,
left : (boxWidth * cols) + 'px',
top : (boxHeight * rows) + 'px',
width : (slider.width() - (boxWidth * cols)) + 'px',
height : boxHeight + 'px',
background : 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((boxWidth + (cols * boxWidth)) - boxWidth) + 'px -' + ((boxHeight + (rows * boxHeight)) - boxHeight) + 'px',
'background-size': settings.backgroundSize
}));
} else {
slider.append($('<div class="nivo-box"></div>').css({
opacity : 0,
left : (boxWidth * cols) + 'px',
top : (boxHeight * rows) + 'px',
width : boxWidth + 'px',
height : boxHeight + 'px',
background : 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((boxWidth + (cols * boxWidth)) - boxWidth) + 'px -' + ((boxHeight + (rows * boxHeight)) - boxHeight) + 'px',
'background-size': settings.backgroundSize
}));
}
}
}
}
var nivoRun = function(slider, kids, settings, nudge) {
var vars = slider.data('nivo:vars');
if (vars && (vars.currentSlide == vars.totalSlides - 1)) {
settings.lastSlide.call(this);
}
if ((!vars || vars.stop) && !nudge)
return false;
settings.beforeChange.call(this);
if (!nudge) {
slider.css({'background':'url("' + vars.currentImage.attr('src') + '") no-repeat','background-size': settings.backgroundSize });
} else {
if (nudge == 'prev') {
slider.css({'background':'url("' + vars.currentImage.attr('src') + '") no-repeat','background-size': settings.backgroundSize });
}
if (nudge == 'next') {
slider.css({'background':'url("' + vars.currentImage.attr('src') + '") no-repeat','background-size': settings.backgroundSize });
}
}
vars.currentSlide++;
if (vars.currentSlide == vars.totalSlides) {
vars.currentSlide = 0;
settings.slideshowEnd.call(this);
}
if (vars.currentSlide < 0)
vars.currentSlide = (vars.totalSlides - 1);
if ($(kids[vars.currentSlide]).is('img')) {
vars.currentImage = $(kids[vars.currentSlide]);
} else {
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
}
if (settings.controlNav) {
$('.nivo-controlNav a', slider).removeClass('active');
$('.nivo-controlNav a:eq(' + vars.currentSlide + ')', slider).addClass('active');
}
processCaption(settings);
$('.nivo-slice', slider).remove();
$('.nivo-box', slider).remove();
if (settings.effect == 'random') {
var anims = new Array('sliceDownRight', 'sliceDownLeft', 'sliceUpRight', 'sliceUpLeft', 'sliceUpDown', 'sliceUpDownLeft', 'fold', 'fade', 'boxRandom', 'boxRain', 'boxRainReverse', 'boxRainGrow', 'boxRainGrowReverse');
vars.randAnim = anims[Math.floor(Math.random() * (anims.length + 1))];
if (vars.randAnim == undefined)
vars.randAnim = 'fade';
}
if (settings.effect.indexOf(',') != -1) {
var anims = settings.effect.split(',');
vars.randAnim = anims[Math.floor(Math.random() * (anims.length))];
if (vars.randAnim == undefined)
vars.randAnim = 'fade';
}
vars.running = true;
if (settings.effect == 'sliceDown' || settings.effect == 'sliceDownRight' || vars.randAnim == 'sliceDownRight' || settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft') {
createSlices(slider, settings, vars);
var timeBuff = 0;
var i = 0;
var slices = $('.nivo-slice', slider);
if (settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft')
slices = $('.nivo-slice', slider)._reverse();
slices.each(function() {
var slice = $(this);
slice.css({
'top' : '0px'
});
if (i == settings.slices - 1) {
setTimeout(function() {
slice.animate({
height : '100%',
opacity : '1.0'
}, settings.animSpeed, '', function() {
slider.trigger('nivo:animFinished');
});
}, (100 + timeBuff));
} else {
setTimeout(function() {
slice.animate({
height : '100%',
opacity : '1.0'
}, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
i++;
});
} else if (settings.effect == 'sliceUp' || settings.effect == 'sliceUpRight' || vars.randAnim == 'sliceUpRight' || settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft') {
createSlices(slider, settings, vars);
var timeBuff = 0;
var i = 0;
var slices = $('.nivo-slice', slider);
if (settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft')
slices = $('.nivo-slice', slider)._reverse();
slices.each(function() {
var slice = $(this);
slice.css({
'bottom' : '0px'
});
if (i == settings.slices - 1) {
setTimeout(function() {
slice.animate({
height : '100%',
opacity : '1.0'
}, settings.animSpeed, '', function() {
slider.trigger('nivo:animFinished');
});
}, (100 + timeBuff));
} else {
setTimeout(function() {
slice.animate({
height : '100%',
opacity : '1.0'
}, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
i++;
});
} else if (settings.effect == 'sliceUpDown' || settings.effect == 'sliceUpDownRight' || vars.randAnim == 'sliceUpDown' || settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft') {
createSlices(slider, settings, vars);
var timeBuff = 0;
var i = 0;
var v = 0;
var slices = $('.nivo-slice', slider);
if (settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft')
slices = $('.nivo-slice', slider)._reverse();
slices.each(function() {
var slice = $(this);
if (i == 0) {
slice.css('top', '0px');
i++;
} else {
slice.css('bottom', '0px');
i = 0;
}
if (v == settings.slices - 1) {
setTimeout(function() {
slice.animate({
height : '100%',
opacity : '1.0'
}, settings.animSpeed, '', function() {
slider.trigger('nivo:animFinished');
});
}, (100 + timeBuff));
} else {
setTimeout(function() {
slice.animate({
height : '100%',
opacity : '1.0'
}, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
v++;
});
} else if (settings.effect == 'fold' || vars.randAnim == 'fold') {
createSlices(slider, settings, vars);
var timeBuff = 0;
var i = 0;
$('.nivo-slice', slider).each(function() {
var slice = $(this);
var origWidth = slice.width();
slice.css({
top : '0px',
height : '100%',
width : '0px'
});
if (i == settings.slices - 1) {
setTimeout(function() {
slice.animate({
width : origWidth,
opacity : '1.0'
}, settings.animSpeed, '', function() {
slider.trigger('nivo:animFinished');
});
}, (100 + timeBuff));
} else {
setTimeout(function() {
slice.animate({
width : origWidth,
opacity : '1.0'
}, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
i++;
});
} else if (settings.effect == 'fade' || vars.randAnim == 'fade') {
createSlices(slider, settings, vars);
var firstSlice = $('.nivo-slice:first', slider);
firstSlice.css({
'height' : '100%',
'width' : slider.width() + 'px'
});
firstSlice.animate({
opacity : '1.0'
}, (settings.animSpeed * 2), '', function() {
slider.trigger('nivo:animFinished');
});
} else if (settings.effect == 'slideInRight' || vars.randAnim == 'slideInRight') {
createSlices(slider, settings, vars);
var firstSlice = $('.nivo-slice:first', slider);
firstSlice.css({
'height' : '100%',
'width' : '0px',
'opacity' : '1'
});
firstSlice.animate({
width : slider.width() + 'px'
}, (settings.animSpeed * 2), '', function() {
slider.trigger('nivo:animFinished');
});
} else if (settings.effect == 'slideInLeft' || vars.randAnim == 'slideInLeft') {
createSlices(slider, settings, vars);
var firstSlice = $('.nivo-slice:first', slider);
firstSlice.css({
'height' : '100%',
'width' : '0px',
'opacity' : '1',
'left' : '',
'right' : '0px'
});
firstSlice.animate({
width : slider.width() + 'px'
}, (settings.animSpeed * 2), '', function() {
firstSlice.css({
'left' : '0px',
'right' : ''
});
slider.trigger('nivo:animFinished');
});
} else if (settings.effect == 'boxRandom' || vars.randAnim == 'boxRandom') {
createBoxes(slider, settings, vars);
var totalBoxes = settings.boxCols * settings.boxRows;
var i = 0;
var timeBuff = 0;
var boxes = shuffle($('.nivo-box', slider));
boxes.each(function() {
var box = $(this);
if (i == totalBoxes - 1) {
setTimeout(function() {
box.animate({
opacity : '1'
}, settings.animSpeed, '', function() {
slider.trigger('nivo:animFinished');
});
}, (100 + timeBuff));
} else {
setTimeout(function() {
box.animate({
opacity : '1'
}, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 20;
i++;
});
} else if (settings.effect == 'boxRain' || vars.randAnim == 'boxRain' || settings.effect == 'boxRainReverse' || vars.randAnim == 'boxRainReverse' || settings.effect == 'boxRainGrow' || vars.randAnim == 'boxRainGrow' || settings.effect == 'boxRainGrowReverse' || vars.randAnim == 'boxRainGrowReverse') {
createBoxes(slider, settings, vars);
var totalBoxes = settings.boxCols * settings.boxRows;
var i = 0;
var timeBuff = 0;
var rowIndex = 0;
var colIndex = 0;
var box2Darr = new Array();
box2Darr[rowIndex] = new Array();
var boxes = $('.nivo-box', slider);
if (settings.effect == 'boxRainReverse' || vars.randAnim == 'boxRainReverse' || settings.effect == 'boxRainGrowReverse' || vars.randAnim == 'boxRainGrowReverse') {
boxes = $('.nivo-box', slider)._reverse();
}
boxes.each(function() {
box2Darr[rowIndex][colIndex] = $(this);
colIndex++;
if (colIndex == settings.boxCols) {
rowIndex++;
colIndex = 0;
box2Darr[rowIndex] = new Array();
}
});
for (var cols = 0; cols < (settings.boxCols * 2); cols++) {
var prevCol = cols;
for (var rows = 0; rows < settings.boxRows; rows++) {
if (prevCol >= 0 && prevCol < settings.boxCols) {
(function(row, col, time, i, totalBoxes) {
var box = $(box2Darr[row][col]);
var w = box.width();
var h = box.height();
if (settings.effect == 'boxRainGrow' || vars.randAnim == 'boxRainGrow' || settings.effect == 'boxRainGrowReverse' || vars.randAnim == 'boxRainGrowReverse') {
box.width(0).height(0);
}
if (i == totalBoxes - 1) {
setTimeout(function() {
box.animate({
opacity : '1',
width : w,
height : h
}, settings.animSpeed / 1.3, '', function() {
slider.trigger('nivo:animFinished');
});
}, (100 + time));
} else {
setTimeout(function() {
box.animate({
opacity : '1',
width : w,
height : h
}, settings.animSpeed / 1.3);
}, (100 + time));
}
})(rows, prevCol, timeBuff, i, totalBoxes);
i++;
}
prevCol--;
}
timeBuff += 100;
}
}
}
var shuffle = function(arr) {
for (var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
}
var trace = function(msg) {
if (this.console && typeof console.log != "undefined")
console.log(msg);
}
this.stop = function() {
if (!$(element).data('nivo:vars').stop) {
$(element).data('nivo:vars').stop = true;
trace('Stop Slider');
}
}
this.start = function() {
if ($(element).data('nivo:vars').stop) {
$(element).data('nivo:vars').stop = false;
trace('Start Slider');
}
}
settings.afterLoad.call(this);
return this;
};
$.fn.nivoSlider = function(options) {
return this.each(function(key, value) {
var element = $(this);
if (element.data('nivoslider'))
return element.data('nivoslider');
var nivoslider = new NivoSlider(this, options);
element.data('nivoslider', nivoslider);
});
};
$.fn.nivoSlider.defaults = {
backgroundSize:'',
effect : 'random',
slices : 15,
boxCols : 8,
boxRows : 4,
animSpeed : 500,
pauseTime : 3000,
startSlide : 0,
directionNav : true,
directionNavHide : true,
controlNav : true,
controlNavThumbs : false,
controlNavThumbsFromRel : false,
controlNavThumbsSearch : '.jpg',
controlNavThumbsReplace : '_thumb.jpg',
keyboardNav : true,
pauseOnHover : true,
manualAdvance : false,
captionOpacity : 0.8,
prevText : 'Prev',
nextText : 'Next',
beforeChange : function() {
},
afterChange : function() {
},
slideshowEnd : function() {
},
lastSlide : function() {
},
afterLoad : function() {
}
};
$.fn._reverse = [].reverse;
})(jQuery);
When you initial nivoSlide pass my new parameter backgroundSize:'your width size px your height size px';
Example:
$('#slider').nivoSlider({
backgroundSize:'687px 400px',
effect: 'random',
animSpeed: 500,
pauseTime: 3000,
directionNav: true,
controlNav: true,
controlNavThumbs: false,
pauseOnHover: true});
});

Tumblr get Like Button status with Infinite Scroll

I would like to request the Like Button status of each post (by ID) that is appended by Infinite Scroll.
<li class="post text" id="{PostID}">
The Tumblr Documentation provides this method of checking the status of a Like Button for individual posts:
Tumblr.LikeButton.get_status_by_page(n)
Description: Call this function after requesting a new page of Posts. Takes the page number that was just loaded as an integer.
Finally, here is the Infinite Scroll script (Proto.jp modified by Cody Sherman):
$(document).ready(function() {
var tumblrAutoPager = {
url: "http://proto.jp/",
ver: "0.1.7",
rF: true,
gP: {},
pp: null,
ppId: "",
LN: location.hostname,
init: function() {
if ($("autopagerize_icon") || navigator.userAgent.indexOf('iPhone') != -1) return;
var tAP = tumblrAutoPager;
var p = 1;
var lh = location.href;
var lhp = lh.lastIndexOf("/page/");
var lht = lh.lastIndexOf("/tagged/");
if (lhp != -1) {
p = parseInt(lh.slice(lhp + 6));
tAP.LN = lh.slice(7, lhp);
} else if (lht != -1) {
tAP.LN = lh.slice(7);
if (tAP.LN.slice(tAP.LN.length - 1) == "/") tAP.LN = tAP.LN.slice(0, tAP.LN.length - 1);
} else if ("http://" + tAP.LN + "/" != lh) {
return;
};
var gPFncs = [];
gPFncs[0] = function(aE) {
var r = [];
for (var i = 0, l = aE.length; i < l; i++) {
if (aE[i].className == "autopagerize_page_element") {
r = gCE(aE[i]);
break;
}
}
return r;
};
gPFncs[1] = function(aE) {
var r = [];
for (var i = 0, l = aE.length; i < l; i++) {
var arr = aE[i].className ? aE[i].className.split(" ") : null;
if (arr) {
for (var j = 0; j < arr.length; j++) {
arr[j] == "post" ? r.push(aE[i]) : null;
}
}
}
return r;
};
gPFncs[2] = function(aE) {
var r = [];
var tmpId = tAP.ppId ? [tAP.ppId] : ["posts", "main", "container", "content", "apDiv2", "wrapper", "projects"];
for (var i = 0, l = aE.length; i < l; i++) {
for (var j = 0; j < tmpId.length; j++) {
if (aE[i].id == tmpId[j]) {
r = gCE(aE[i]);
tAP.ppId = aE[i].id;
break;
}
}
}
return r;
};
for (var i = 0; i < gPFncs.length; i++) {
var getElems = gPFncs[i](document.body.getElementsByTagName('*'));
if (getElems.length) {
tAP.gP = gPFncs[i];
tAP.pp = getElems[0].parentNode;
break;
}
}
function gCE(pElem) {
var r = [];
for (var i = 0, l = pElem.childNodes.length; i < l; i++) {
r.push(pElem.childNodes.item(i))
}
return r;
}
if (!tAP.pp) {
return;
}
sendRequest.README = {
license: 'Public Domain',
url: 'http://jsgt.org/lib/ajax/ref.htm',
version: 0.516,
author: 'Toshiro Takahashi'
};
function chkAjaBrowser() {
var A, B = navigator.userAgent;
this.bw = {
safari: ((A = B.split('AppleWebKit/')[1]) ? A.split('(')[0].split('.')[0] : 0) >= 124,
konqueror: ((A = B.split('Konqueror/')[1]) ? A.split(';')[0] : 0) >= 3.3,
mozes: ((A = B.split('Gecko/')[1]) ? A.split(' ')[0] : 0) >= 20011128,
opera: ( !! window.opera) && ((typeof XMLHttpRequest) == 'function'),
msie: ( !! window.ActiveXObject) ? ( !! createHttpRequest()) : false
};
return (this.bw.safari || this.bw.konqueror || this.bw.mozes || this.bw.opera || this.bw.msie)
}
function createHttpRequest() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest()
} else {
if (window.ActiveXObject) {
try {
return new ActiveXObject('Msxml2.XMLHTTP')
} catch (B) {
try {
return new ActiveXObject('Microsoft.XMLHTTP')
} catch (A) {
return null
}
}
} else {
return null
}
}
};
function sendRequest(E, R, C, D, F, G, S, A) {
var Q = C.toUpperCase() == 'GET',
H = createHttpRequest();
if (H == null) {
return null
}
if ((G) ? G : false) {
D += ((D.indexOf('?') == -1) ? '?' : '&') + 't=' + (new Date()).getTime()
}
var P = new chkAjaBrowser(),
L = P.bw.opera,
I = P.bw.safari,
N = P.bw.konqueror,
M = P.bw.mozes;
if (typeof E == 'object') {
var J = E.onload;
var O = E.onbeforsetheader
} else {
var J = E;
var O = null
}
if (L || I || M) {
H.onload = function() {
J(H);
H.abort()
}
} else {
H.onreadystatechange = function() {
if (H.readyState == 4) {
J(H);
H.abort()
}
}
}
R = K(R, D);
if (Q) {
D += ((D.indexOf('?') == -1) ? '?' : (R == '') ? '' : '&') + R
}
H.open(C, D, F, S, A);
if ( !! O) {
O(H)
}
B(H);
H.send(R);
function B(T) {
if (!L || typeof T.setRequestHeader == 'function') {
T.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
}
return T
}
function K(X, V) {
var Z = [];
if (typeof X == 'object') {
for (var W in X) {
Y(W, X[W])
}
} else {
if (typeof X == 'string') {
if (X == '') {
return ''
}
if (X.charAt(0) == '&') {
X = X.substring(1, X.length)
}
var T = X.split('&');
for (var W = 0; W < T.length; W++) {
var U = T[W].split('=');
Y(U[0], U[1])
}
}
}
function Y(b, a) {
Z.push(encodeURIComponent(b) + '=' + encodeURIComponent(a))
}
return Z.join('&')
}
return H
}
function addNextPage(oj) {
if (oj.status == 404) {
tAP.remainFlg = false;
return;
}
var d = document.createElement("div");
d.innerHTML = oj.responseText;
var posts = tAP.gP(d.getElementsByTagName("*"));
if (posts.length < 2) {
tAP.rF = false;
return;
}
d = document.createElement("div");
d.className = "tumblrAutoPager_page_info";
tAP.pp.appendChild(d);
for (var i = 0; i < posts.length; i++) {
tAP.pp.appendChild(posts[i]);
}
var footer = $("footer");
footer ? footer.parentNode.appendChild(footer) : null;
tAP.rF = true;
}
watch_scroll();
function watch_scroll() {
var d = document.compatMode == "BackCompat" ? document.body : document.documentElement;
var r = d.scrollHeight - d.clientHeight - (d.scrollTop || document.body.scrollTop);
if (r < d.clientHeight * 2 && tAP.rF) {
tAP.rF = false;
p++;
sendRequest(addNextPage, "", "GET", "http://" + tAP.LN + "/page/" + p, true);
}
setTimeout(arguments.callee, 200);
};
function $(id) {
return document.getElementById(id)
}
},
switchAutoPage: function() {
this.rF = !this.rF;
var aE = document.getElementsByTagName('*');
for (var i = 0, l = aE.length; i < l; i++) {
if (aE[i].className == "tAP_switch") {
aE[i].firstChild.nodeValue = this.rF ? "AutoPage[OFF]" : "AutoPage[ON]";
}
}
}
};
window.addEventListener ? window.addEventListener('load', tumblrAutoPager.init, false) : window.attachEvent ? window.attachEvent("onload", tumblrAutoPager.init) : window.onload = tumblrAutoPager.init;
});
Any insight is greatly appreciated. Thank you!
This seemed to do the trick!
function addNextPage(oj) {
if (oj.status == 404) {
tAP.remainFlg = false;
return;
}
var d = document.createElement("div");
d.innerHTML = oj.responseText;
var posts = tAP.gP(d.getElementsByTagName("*"));
if (posts.length < 2) {
tAP.rF = false;
return;
}
d = document.createElement("div");
d.className = "tumblrAutoPager_page_info";
tAP.pp.appendChild(d);
for (var i = 0; i < posts.length; i++) {
tAP.pp.appendChild(posts[i]);
}
var footer = $("footer");
footer ? footer.parentNode.appendChild(footer) : null;
tAP.rF = true;
//Get Like Button status of newly appended page
Tumblr.LikeButton.get_status_by_page(p);
}

Resources