jQuery( document ).ready( function( $ ) { "use strict"; var bfmBO = false; var latest_y = 0; /* Burnhambox - Buy For Me */ $( '.brnhmbx-hover-group .brnhmbx-bfm, .brnhmbx-hover-group-list .brnhmbx-bfm' ).click( function( e ) { e.preventDefault(); // Detect the latest scroll position for small screens if ( $( window ).height() < 760 || $( window ).width() < 968 ) { latest_y = $( window ).scrollTop(); } $( '.bfm-message' ).hide(); $( '.bfm-container' ).show(); $( '#brnhmbx-buy-for-me' ).addClass( 'open' ); $( '#bfm-product-id' ).val( $( this ).parent().find( '.brnhmbx-product-id' ).text() ); $( '#bfm-product-url-front a, #bfm-button-text-front-a' ).attr( 'href', $( 'li.product.post-' + $( '#bfm-product-id' ).val() ).find( '.brnhmbx-hover-group-container a:first' ).attr( 'href' ) ); $( '#bfm-product-url-front a img' ).attr( 'src', $( 'li.product.post-' + $( '#bfm-product-id' ).val() ).find( '.brnhmbx-hover-group-container a:nth-child(2) img:first' ).attr( 'src' ) ); $( '#bfm-title-text-front' ).html( $( 'li.product.post-' + $( '#bfm-product-id' ).val() + ':first' ).find( 'h3' ).text() ); $( '#bfm-price-text-front' ).html( $( 'li.product.post-' + $( '#bfm-product-id' ).val() + ':first' ).find( 'span.price' ).html() ); openingPriceColor(); brnhmbx_cws(); } ); $( 'div.summary.entry-summary .brnhmbx-bfm' ).click( function() { // Detect the latest scroll position for small screens if ( $( window ).height() < 760 || $( window ).width() < 968 ) { latest_y = $( window ).scrollTop(); } $( '.bfm-message' ).hide(); $( '.bfm-container' ).show(); $( '#brnhmbx-buy-for-me' ).addClass( 'open' ); $( '#bfm-product-id' ).val( $( 'input[name="add-to-cart"]' ).val() ); $( '#bfm-product-url-front a img' ).attr( 'src', $( 'img.product-slider-image.brnhmbx-zoomer' ).attr( 'src' ) ); $( '#bfm-title-text-front' ).html( $( '.brnhmbx-page-hdr-left h1' ).text() ); $( '#bfm-price-text-front' ).html( $( this ).parent().parent().parent().find( 'p.price' ).html() ); if ( $( '#bfm-price-text-front' ).html() == '' ) { $( '#bfm-price-text-front' ).html( $( this ).parent().parent().parent().parent().parent().find( 'p.price' ).html() ); } openingPriceColor(); brnhmbx_cws(); } ); $( '.brnhmbx-bfm-overlay, .bfm-close' ).click( function() { $( '#brnhmbx-buy-for-me' ).removeClass( 'open' ); bfmBO = false; // Scroll to the latest scroll position for small screens if ( $( window ).height() < 760 || $( window ).width() < 968 ) { $( 'html, body' ).animate( { scrollTop: latest_y }, 500 ); } } ); $( '#bfm-your-message' ).keyup( function( event ) { if ( event.which == 13 ) { //ENTER event.preventDefault(); } $( '#bfm-your-message-front' ).html( $( this ).val() ); } ); $( '#bfm-button-text' ).keyup( function( event ) { if ( event.which == 13 ) { //ENTER event.preventDefault(); } $( '#bfm-button-text-front-a' ).html( $( this ).val() ); if ( $( this ).val() == '' ){ $( '#bfm-button-text-front' ).hide(); } else { $( '#bfm-button-text-front' ).show(); } } ); $( '#bfm-hide-price' ).click( function() { $( '#bfm-price-text-front' ).toggle( !this.checked ); } ); $( '#bfm-color-scheme' ).on( 'change', function() { if ( $(this).val() == 'default' ) { $( '#bfm-bg-front' ).css( 'background-color', '#76b9bb' ); $( '#bfm-fg-front' ).css( 'background-color', '#FFFFFF' ); $( '#bfm-your-message-front' ).css( 'color', '#999999' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #3c2313 !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#3c2313' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#dedacc' ); } else if ( $(this).val() == 'lollipop' ) { $( '#bfm-bg-front' ).css( 'background-color', '#dba5c6' ); $( '#bfm-fg-front' ).css( 'background-color', '#FFFFFF' ); $( '#bfm-your-message-front' ).css( 'color', '#999999' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #bd448e !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#FFFFFF' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#c2c2c2' ); } else if ( $(this).val() == 'macaron' ) { $( '#bfm-bg-front' ).css( 'background-color', '#f9b9ad' ); $( '#bfm-fg-front' ).css( 'background-color', '#FFFFFF' ); $( '#bfm-your-message-front' ).css( 'color', '#a26256' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #999999 !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#FFFFFF' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#b64646' ); } else if ( $(this).val() == 'blueberry' ) { $( '#bfm-bg-front' ).css( 'background-color', '#8f8ead' ); $( '#bfm-fg-front' ).css( 'background-color', '#FFFFFF' ); $( '#bfm-your-message-front' ).css( 'color', '#262d70' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #6a556d !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#FFFFFF' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#a97baf' ); } else if ( $(this).val() == 'forest' ) { $( '#bfm-bg-front' ).css( 'background-color', '#003333' ); $( '#bfm-fg-front' ).css( 'background-color', '#81aaaa' ); $( '#bfm-your-message-front' ).css( 'color', '#FFFFFF' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #FFFFFF !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#716f36' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#d2d1b9' ); } else if ( $(this).val() == 'dark' ) { $( '#bfm-bg-front' ).css( 'background-color', '#999999' ); $( '#bfm-fg-front' ).css( 'background-color', '#333333' ); $( '#bfm-your-message-front' ).css( 'color', '#FFFFFF' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #c7c7c7 !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#999999' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#1c1c1c' ); } else if ( $(this).val() == 'lemonade' ) { $( '#bfm-bg-front' ).css( 'background-color', '#f5e4b2' ); $( '#bfm-fg-front' ).css( 'background-color', '#FFFFFF' ); $( '#bfm-your-message-front' ).css( 'color', '#b89b45' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #b89b45 !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#65924a' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#c4eaad' ); } else if ( $(this).val() == 'sailor' ) { $( '#bfm-bg-front' ).css( 'background-color', '#9c0e0e' ); $( '#bfm-fg-front' ).css( 'background-color', '#FFFFFF' ); $( '#bfm-your-message-front' ).css( 'color', '#555555' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #777777 !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#FFFFFF' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#212d64' ); } else if ( $(this).val() == 'gold' ) { $( '#bfm-bg-front' ).css( 'background-color', '#ac8051' ); $( '#bfm-fg-front' ).css( 'background-color', '#FFFFFF' ); $( '#bfm-your-message-front' ).css( 'color', '#caa976' ); $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #925e26 !important' ); $( '#bfm-button-text-front-a' ).css( 'color', '#FFFFFF' ); $( '#bfm-button-text-front-bg' ).css( 'background-color', '#3c2313' ); } } ); function openingPriceColor() { var currentScheme = $( '#bfm-color-scheme' ).val(); if( currentScheme == 'default' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #3c2313 !important' ); } else if( currentScheme == 'lollipop' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #bd448e !important' ); } else if( currentScheme == 'macaron' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #999999 !important' ); } else if( currentScheme == 'blueberry' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #6a556d !important' ); } else if( currentScheme == 'forest' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #FFFFFF !important' ); } else if( currentScheme == 'dark' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #c7c7c7 !important' ); } else if( currentScheme == 'lemonade' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #b89b45 !important' ); } else if( currentScheme == 'sailor' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #777777 !important' ); } else if( currentScheme == 'gold' ) { $( '#bfm-product-text-front, #bfm-price-text-front ins, #bfm-price-text-front span.amount' ).attr( 'style', 'color: #925e26 !important' ); } } /* Return Message */ $( '.bfm-message' ).hide(); if ( $( '#bfm_return' ).text() == 'sent' ) { prepareMessage(); $( '.bfm-message' ).text( $( '#bfm_sent' ).text() ); } else if ( $( '#bfm_return' ).text() == 'problem' ) { prepareMessage(); $( '.bfm-message' ).text( $( '#bfm_problem' ).text() ); } function prepareMessage() { $( '.bfm-message' ).show(); $( '.bfm-container' ).hide(); $( '#brnhmbx-buy-for-me' ).addClass( 'open' ); } /* */ /* Check Window Size */ function brnhmbx_cws() { bfmBO = true; if ( $( window ).height() < 760 || $( window ).width() < 968 ) { brnhmbx_sct(); } } // Scroll to top function brnhmbx_sct() { $( 'html, body' ).animate( { scrollTop: 0 }, 500 ); return false; } // Resize function brnhmbx_bfm_resize() { if ( ( $( window ).height() < 760 || $( window ).width() < 968 ) && bfmBO ) { $( 'html, body' ).scrollTop( 0 ); } } $( window ).resize( brnhmbx_bfm_resize ); /* */ } );