Added login request

This commit is contained in:
Nedim Uka
2018-06-20 18:03:43 +02:00
parent 4e52521fae
commit 593b445a21
4716 changed files with 1218265 additions and 57 deletions

View File

@@ -0,0 +1,20 @@
/* global ajaxurl, storefrontNUX */
( function( wp, $ ) {
'use strict';
if ( ! wp ) {
return;
}
$( function() {
// Dismiss notice
$( document ).on( 'click', '.sf-notice-nux .notice-dismiss', function() {
$.ajax({
type: 'POST',
url: ajaxurl,
data: { nonce: storefrontNUX.nonce, action: 'storefront_dismiss_notice' },
dataType: 'json'
});
});
});
})( window.wp, jQuery );

View File

@@ -0,0 +1 @@
!function(a,b){"use strict";a&&b(function(){b(document).on("click",".sf-notice-nux .notice-dismiss",function(){b.ajax({type:"POST",url:ajaxurl,data:{nonce:storefrontNUX.nonce,action:"storefront_dismiss_notice"},dataType:"json"})})})}(window.wp,jQuery);

View File

@@ -0,0 +1,243 @@
/* global _wpCustomizeSFGuidedTourSteps */
( function( wp, $ ) {
'use strict';
if ( ! wp || ! wp.customize ) { return; }
// Set up our namespace.
var api = wp.customize;
api.SFGuidedTourSteps = [];
if ( 'undefined' !== typeof _wpCustomizeSFGuidedTourSteps ) {
$.extend( api.SFGuidedTourSteps, _wpCustomizeSFGuidedTourSteps );
}
/**
* wp.customize.SFGuidedTour
*
*/
api.SFGuidedTour = {
$container: null,
currentStep: -1,
init: function() {
this._setupUI();
},
_setupUI: function() {
var self = this,
$wpCustomize = $( 'body.wp-customizer .wp-full-overlay' );
this.$container = $( '<div/>' ).addClass( 'sf-guided-tour' );
// Add guided tour div
$wpCustomize.prepend( this.$container );
// Add listeners
this._addListeners();
// Initial position
this.$container.css( 'left', ( $( '#customize-controls' ).width() + 10 ) + 'px' ).on( 'transitionend', function() {
self.$container.addClass( 'sf-loaded' );
});
// Show first step
this._showNextStep();
$( document ).on( 'click', '.sf-guided-tour-step .sf-nux-button', function() {
self._showNextStep();
return false;
});
$( document ).on( 'click', '.sf-guided-tour-step .sf-guided-tour-skip', function() {
if ( 0 === self.currentStep ) {
self._hideTour( true );
} else {
self._showNextStep();
}
return false;
});
},
_addListeners: function() {
var self = this;
api.state( 'expandedSection' ).bind( function() {
self._adjustPosition();
});
api.state( 'expandedPanel' ).bind( function() {
self._adjustPosition();
});
},
_adjustPosition: function() {
var step = this._getCurrentStep(),
expandedSection = api.state( 'expandedSection' ).get(),
expandedPanel = api.state( 'expandedPanel' ).get();
if ( ! step ) {
return;
}
this.$container.removeClass( 'sf-inside-section' );
if ( expandedSection && step.section === expandedSection.id ) {
this._moveContainer( $( expandedSection.container[1] ).find( '.customize-section-title' ) );
this.$container.addClass( 'sf-inside-section' );
} else if ( false === expandedSection && false === expandedPanel ) {
if ( this._isTourHidden() ) {
this._revealTour();
} else {
var selector = this._getSelector( step.section );
this._moveContainer( selector );
}
} else {
this._hideTour();
}
},
_hideTour: function( remove ) {
var self = this;
// Already hidden?
if ( this._isTourHidden() ) {
return;
}
this.$container.css({
transform: '',
top: this.$container.offset().top
});
$( 'body' ).addClass( 'sf-exiting' ).on( 'animationend.storefront webkitAnimationEnd.storefront', function() {
$( this ).removeClass( 'sf-exiting' ).off( 'animationend.storefront webkitAnimationEnd.storefront' ).addClass( 'sf-hidden' );
self.$container.hide();
if ( ! _.isUndefined( remove ) && true === remove ) {
self._removeTour();
}
});
},
_revealTour: function() {
var self = this;
$( 'body' ).removeClass( 'sf-hidden' );
self.$container.show();
$( 'body' ).addClass( 'sf-entering' ).on( 'animationend.storefront webkitAnimationEnd.storefront', function() {
$( this ).removeClass( 'sf-entering' ).off( 'animationend.storefront webkitAnimationEnd.storefront' );
self.$container.css({
top: 'auto',
transform: 'translateY(' + parseInt( self.$container.offset().top, 10 ) + 'px)'
});
});
},
_removeTour: function() {
this.$container.remove();
},
_closeAllSections: function() {
api.section.each( function ( section ) {
section.collapse( { duration: 0 } );
});
api.panel.each( function ( panel ) {
panel.collapse( { duration: 0 } );
});
},
_showNextStep: function() {
var step, template;
if ( this._isLastStep() ) {
this._hideTour( true );
return;
}
this._closeAllSections();
// Get next step
step = this._getNextStep();
// Convert line breaks to paragraphs
step.message = this._lineBreaksToParagraphs( step.message );
// Load template
template = wp.template( 'sf-guided-tour-step' );
this.$container.removeClass( 'sf-first-step' );
if ( 0 === this.currentStep ) {
step.first_step = true;
this.$container.addClass( 'sf-first-step' );
}
if ( this._isLastStep() ) {
step.last_step = true;
this.$container.addClass( 'sf-last-step' );
}
this._moveContainer( this._getSelector( step.section ) );
this.$container.html( template( step ) );
},
_moveContainer: function( $selector ) {
var self = this, position;
if ( ! $selector ) {
return;
}
position = parseInt( $selector.offset().top, 10 ) + ( $selector.height() / 2 ) - 44;
this.$container.addClass( 'sf-moving' ).css({ 'transform': 'translateY(' + parseInt( position, 10 ) + 'px)' }).on( 'transitionend.storefront', function() {
self.$container.removeClass( 'sf-moving' );
self.$container.off( 'transitionend.storefront' );
} );
},
_getSelector: function( pointTo ) {
var sectionOrPanel = api.section( pointTo ) ? api.section( pointTo ) : api.panel( pointTo );
// Check whether this is a section, panel, or a regular selector
if ( ! _.isUndefined( sectionOrPanel ) ) {
return $( sectionOrPanel.container[0] );
}
return $( pointTo );
},
_getCurrentStep: function() {
return api.SFGuidedTourSteps[ this.currentStep ];
},
_getNextStep: function() {
this.currentStep = this.currentStep + 1;
return api.SFGuidedTourSteps[ this.currentStep ];
},
_isTourHidden: function() {
return ( ( $( 'body' ).hasClass( 'sf-hidden' ) ) ? true : false );
},
_isLastStep: function() {
return ( ( ( this.currentStep + 1 ) < api.SFGuidedTourSteps.length ) ? false : true );
},
_lineBreaksToParagraphs: function( message ) {
return '<p>' + message.replace( '\n\n', '</p><p>' ) + '</p>';
}
};
$( document ).ready( function() {
api.SFGuidedTour.init();
});
} )( window.wp, jQuery );

View File

@@ -0,0 +1 @@
!function(a,b){"use strict";if(a&&a.customize){var c=a.customize;c.SFGuidedTourSteps=[],"undefined"!=typeof _wpCustomizeSFGuidedTourSteps&&b.extend(c.SFGuidedTourSteps,_wpCustomizeSFGuidedTourSteps),c.SFGuidedTour={$container:null,currentStep:-1,init:function(){this._setupUI()},_setupUI:function(){var a=this,c=b("body.wp-customizer .wp-full-overlay");this.$container=b("<div/>").addClass("sf-guided-tour"),c.prepend(this.$container),this._addListeners(),this.$container.css("left",b("#customize-controls").width()+10+"px").on("transitionend",function(){a.$container.addClass("sf-loaded")}),this._showNextStep(),b(document).on("click",".sf-guided-tour-step .sf-nux-button",function(){return a._showNextStep(),!1}),b(document).on("click",".sf-guided-tour-step .sf-guided-tour-skip",function(){return 0===a.currentStep?a._hideTour(!0):a._showNextStep(),!1})},_addListeners:function(){var a=this;c.state("expandedSection").bind(function(){a._adjustPosition()}),c.state("expandedPanel").bind(function(){a._adjustPosition()})},_adjustPosition:function(){var a=this._getCurrentStep(),d=c.state("expandedSection").get(),e=c.state("expandedPanel").get();if(a)if(this.$container.removeClass("sf-inside-section"),d&&a.section===d.id)this._moveContainer(b(d.container[1]).find(".customize-section-title")),this.$container.addClass("sf-inside-section");else if(!1===d&&!1===e)if(this._isTourHidden())this._revealTour();else{var f=this._getSelector(a.section);this._moveContainer(f)}else this._hideTour()},_hideTour:function(a){var c=this;this._isTourHidden()||(this.$container.css({transform:"",top:this.$container.offset().top}),b("body").addClass("sf-exiting").on("animationend.storefront webkitAnimationEnd.storefront",function(){b(this).removeClass("sf-exiting").off("animationend.storefront webkitAnimationEnd.storefront").addClass("sf-hidden"),c.$container.hide(),_.isUndefined(a)||!0!==a||c._removeTour()}))},_revealTour:function(){var a=this;b("body").removeClass("sf-hidden"),a.$container.show(),b("body").addClass("sf-entering").on("animationend.storefront webkitAnimationEnd.storefront",function(){b(this).removeClass("sf-entering").off("animationend.storefront webkitAnimationEnd.storefront"),a.$container.css({top:"auto",transform:"translateY("+parseInt(a.$container.offset().top,10)+"px)"})})},_removeTour:function(){this.$container.remove()},_closeAllSections:function(){c.section.each(function(a){a.collapse({duration:0})}),c.panel.each(function(a){a.collapse({duration:0})})},_showNextStep:function(){var b,c;if(this._isLastStep())return void this._hideTour(!0);this._closeAllSections(),b=this._getNextStep(),b.message=this._lineBreaksToParagraphs(b.message),c=a.template("sf-guided-tour-step"),this.$container.removeClass("sf-first-step"),0===this.currentStep&&(b.first_step=!0,this.$container.addClass("sf-first-step")),this._isLastStep()&&(b.last_step=!0,this.$container.addClass("sf-last-step")),this._moveContainer(this._getSelector(b.section)),this.$container.html(c(b))},_moveContainer:function(a){var b,c=this;a&&(b=parseInt(a.offset().top,10)+a.height()/2-44,this.$container.addClass("sf-moving").css({transform:"translateY("+parseInt(b,10)+"px)"}).on("transitionend.storefront",function(){c.$container.removeClass("sf-moving"),c.$container.off("transitionend.storefront")}))},_getSelector:function(a){var d=c.section(a)?c.section(a):c.panel(a);return b(_.isUndefined(d)?a:d.container[0])},_getCurrentStep:function(){return c.SFGuidedTourSteps[this.currentStep]},_getNextStep:function(){return this.currentStep=this.currentStep+1,c.SFGuidedTourSteps[this.currentStep]},_isTourHidden:function(){return!!b("body").hasClass("sf-hidden")},_isLastStep:function(){return!(this.currentStep+1<c.SFGuidedTourSteps.length)},_lineBreaksToParagraphs:function(a){return"<p>"+a.replace("\n\n","</p><p>")+"</p>"}},b(document).ready(function(){c.SFGuidedTour.init()})}}(window.wp,jQuery);

View File

@@ -0,0 +1,41 @@
( function( wp, $ ) {
'use strict';
if ( ! wp ) {
return;
}
$( function() {
$( document ).on( 'click', '.sf-install-now', function( event ) {
var $button = $( event.target );
if ( $button.hasClass( 'activate-now' ) ) {
return true;
}
event.preventDefault();
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
return;
}
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
wp.updates.requestFilesystemCredentials( event );
$( document ).on( 'credential-modal-cancel', function() {
var $message = $( '.sf-install-now.updating-message' );
$message
.removeClass( 'updating-message' )
.text( wp.updates.l10n.installNow );
wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
} );
}
wp.updates.installPlugin( {
slug: $button.data( 'slug' )
} );
});
});
})( window.wp, jQuery );

View File

@@ -0,0 +1 @@
!function(a,b){"use strict";a&&b(function(){b(document).on("click",".sf-install-now",function(c){var d=b(c.target);if(d.hasClass("activate-now"))return!0;c.preventDefault(),d.hasClass("updating-message")||d.hasClass("button-disabled")||(a.updates.shouldRequestFilesystemCredentials&&!a.updates.ajaxLocked&&(a.updates.requestFilesystemCredentials(c),b(document).on("credential-modal-cancel",function(){b(".sf-install-now.updating-message").removeClass("updating-message").text(a.updates.l10n.installNow),a.a11y.speak(a.updates.l10n.updateCancel,"polite")})),a.updates.installPlugin({slug:d.data("slug")}))})})}(window.wp,jQuery);

View File

@@ -0,0 +1,51 @@
/**
* homepage.js
*
* Handles behaviour of the homepage featured image
*/
( function() {
/**
* Set hero content dimensions / layout
* Run adaptive backgrounds and set colors
*/
document.addEventListener( 'DOMContentLoaded', function() {
var homepageContent = document.querySelector( '.page-template-template-homepage .type-page.has-post-thumbnail' );
if ( ! homepageContent ) {
// Only apply layout to the homepage content component if it exists on the page
return;
}
for ( var i = 0; i < homepageContent.querySelectorAll( '.entry-title, .entry-content' ).length; i++ ) {
homepageContent.querySelectorAll( '.entry-title, .entry-content' )[ i ].classList.add( 'loaded' );
}
var siteMain = document.querySelector( '.site-main' );
var htmlDirValue = document.documentElement.getAttribute( 'dir' );
var updateDimensions = function() {
if ( updateDimensions._tick ) {
cancelAnimationFrame( updateDimensions._tick );
}
updateDimensions._tick = requestAnimationFrame( function() {
updateDimensions._tick = null;
// Make the homepage content full width and centrally aligned.
homepageContent.style.width = window.innerWidth + 'px';
if ( htmlDirValue !== 'rtl' ) {
homepageContent.style.marginLeft = -siteMain.getBoundingClientRect().left + 'px';
} else {
homepageContent.style.marginRight = -siteMain.getBoundingClientRect().left + 'px';
}
} );
};
// On window resize, set hero content dimensions / layout.
window.addEventListener( 'resize', updateDimensions );
updateDimensions();
} );
} )();

View File

@@ -0,0 +1 @@
!function(){document.addEventListener("DOMContentLoaded",function(){var a=document.querySelector(".page-template-template-homepage .type-page.has-post-thumbnail");if(a){for(var b=0;b<a.querySelectorAll(".entry-title, .entry-content").length;b++)a.querySelectorAll(".entry-title, .entry-content")[b].classList.add("loaded");var c=document.querySelector(".site-main"),d=document.documentElement.getAttribute("dir"),e=function(){e._tick&&cancelAnimationFrame(e._tick),e._tick=requestAnimationFrame(function(){e._tick=null,a.style.width=window.innerWidth+"px","rtl"!==d?a.style.marginLeft=-c.getBoundingClientRect().left+"px":a.style.marginRight=-c.getBoundingClientRect().left+"px"})};window.addEventListener("resize",e),e()}})}();

View File

@@ -0,0 +1,140 @@
/* global storefrontScreenReaderText */
/**
* navigation.js
*
* Handles toggling the navigation menu for small screens.
* Also adds a focus class to parent li's for accessibility.
* Finally adds a class required to reveal the search in the handheld footer bar.
*/
( function() {
// Wait for DOM to be ready.
document.addEventListener( 'DOMContentLoaded', function() {
var container = document.getElementById( 'site-navigation' );
if ( ! container ) {
return;
}
var button = container.querySelector( 'button' );
if ( ! button ) {
return;
}
var menu = container.querySelector( 'ul' );
// Hide menu toggle button if menu is empty and return early.
if ( ! menu ) {
button.style.display = 'none';
return;
}
button.setAttribute( 'aria-expanded', 'false' );
menu.setAttribute( 'aria-expanded', 'false' );
menu.classList.add( 'nav-menu' );
button.addEventListener( 'click', function() {
container.classList.toggle( 'toggled' );
var expanded = container.classList.contains( 'toggled' ) ? 'true' : 'false';
button.setAttribute( 'aria-expanded', expanded );
menu.setAttribute( 'aria-expanded', expanded );
} );
// Add dropdown toggle that displays child menu items.
var handheld = document.getElementsByClassName( 'handheld-navigation' );
if ( handheld.length > 0 ) {
[].forEach.call( handheld[0].querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' ), function( anchor ) {
// Add dropdown toggle that displays child menu items
var btn = document.createElement( 'button' );
btn.setAttribute( 'aria-expanded', 'false' );
btn.classList.add( 'dropdown-toggle' );
var btnSpan = document.createElement( 'span' );
btnSpan.classList.add( 'screen-reader-text' );
btnSpan.appendChild( document.createTextNode( storefrontScreenReaderText.expand ) );
btn.appendChild( btnSpan );
anchor.parentNode.insertBefore( btn, anchor.nextSibling );
// Set the active submenu dropdown toggle button initial state
if ( anchor.parentNode.classList.contains( 'current-menu-ancestor' ) ) {
btn.setAttribute( 'aria-expanded', 'true' );
btn.classList.add( 'toggled-on' );
btn.nextElementSibling.classList.add( 'toggled-on' );
}
// Add event listener
btn.addEventListener( 'click', function() {
btn.classList.toggle( 'toggled-on' );
// Remove text inside span
while ( btnSpan.firstChild ) {
btnSpan.removeChild( btnSpan.firstChild );
}
var expanded = btn.classList.contains( 'toggled-on' );
btn.setAttribute( 'aria-expanded', expanded );
btnSpan.appendChild( document.createTextNode( expanded ? storefrontScreenReaderText.collapse : storefrontScreenReaderText.expand ) );
btn.nextElementSibling.classList.toggle( 'toggled-on' );
} );
} );
}
// Add class to footer search when clicked.
[].forEach.call( document.querySelectorAll( '.storefront-handheld-footer-bar .search > a' ), function( anchor ) {
anchor.addEventListener( 'click', function( event ) {
anchor.parentElement.classList.toggle( 'active' );
event.preventDefault();
} );
} );
// Add focus class to body when an input field is focused.
// This is used to hide the Handheld Footer Bar when an input is focused.
var footer_bar = document.getElementsByClassName( 'storefront-handheld-footer-bar' );
var forms = document.forms;
var isFocused = function( focused ) {
return function() {
if ( !! focused ) {
document.body.classList.add( 'sf-input-focused' );
} else {
document.body.classList.remove( 'sf-input-focused' );
}
};
};
if ( footer_bar.length && forms.length ) {
for ( var i = 0; i < forms.length; i++ ) {
if ( footer_bar[0].contains( forms[ i ] ) ) {
continue;
}
forms[ i ].addEventListener( 'focus', isFocused( true ), true );
forms[ i ].addEventListener( 'blur', isFocused( false ), true );
}
}
// Add focus class to parents of sub-menu anchors.
[].forEach.call( document.querySelectorAll( '.site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a' ), function( anchor ) {
var li = anchor.parentNode;
anchor.addEventListener( 'focus', function() {
li.classList.add( 'focus' );
} );
anchor.addEventListener( 'blur', function() {
li.classList.remove( 'focus' );
} );
} );
// Add an identifying class to dropdowns when on a touch device
// This is required to switch the dropdown hiding method from a negative `left` value to `display: none`.
if ( ( 'ontouchstart' in window || navigator.maxTouchPoints ) && window.innerWidth > 767 ) {
[].forEach.call( document.querySelectorAll( '.site-header ul ul, .site-header-cart .widget_shopping_cart' ), function( element ) {
element.classList.add( 'sub-menu--is-touch-device' );
} );
}
} );
} )();

View File

@@ -0,0 +1 @@
!function(){document.addEventListener("DOMContentLoaded",function(){var a=document.getElementById("site-navigation");if(a){var b=a.querySelector("button");if(b){var c=a.querySelector("ul");if(!c)return void(b.style.display="none");b.setAttribute("aria-expanded","false"),c.setAttribute("aria-expanded","false"),c.classList.add("nav-menu"),b.addEventListener("click",function(){a.classList.toggle("toggled");var d=a.classList.contains("toggled")?"true":"false";b.setAttribute("aria-expanded",d),c.setAttribute("aria-expanded",d)});var d=document.getElementsByClassName("handheld-navigation");d.length>0&&[].forEach.call(d[0].querySelectorAll(".menu-item-has-children > a, .page_item_has_children > a"),function(a){var b=document.createElement("button");b.setAttribute("aria-expanded","false"),b.classList.add("dropdown-toggle");var c=document.createElement("span");c.classList.add("screen-reader-text"),c.appendChild(document.createTextNode(storefrontScreenReaderText.expand)),b.appendChild(c),a.parentNode.insertBefore(b,a.nextSibling),a.parentNode.classList.contains("current-menu-ancestor")&&(b.setAttribute("aria-expanded","true"),b.classList.add("toggled-on"),b.nextElementSibling.classList.add("toggled-on")),b.addEventListener("click",function(){for(b.classList.toggle("toggled-on");c.firstChild;)c.removeChild(c.firstChild);var a=b.classList.contains("toggled-on");b.setAttribute("aria-expanded",a),c.appendChild(document.createTextNode(a?storefrontScreenReaderText.collapse:storefrontScreenReaderText.expand)),b.nextElementSibling.classList.toggle("toggled-on")})}),[].forEach.call(document.querySelectorAll(".storefront-handheld-footer-bar .search > a"),function(a){a.addEventListener("click",function(b){a.parentElement.classList.toggle("active"),b.preventDefault()})});var e=document.getElementsByClassName("storefront-handheld-footer-bar"),f=document.forms,g=function(a){return function(){a?document.body.classList.add("sf-input-focused"):document.body.classList.remove("sf-input-focused")}};if(e.length&&f.length)for(var h=0;h<f.length;h++)e[0].contains(f[h])||(f[h].addEventListener("focus",g(!0),!0),f[h].addEventListener("blur",g(!1),!0));[].forEach.call(document.querySelectorAll(".site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a"),function(a){var b=a.parentNode;a.addEventListener("focus",function(){b.classList.add("focus")}),a.addEventListener("blur",function(){b.classList.remove("focus")})}),("ontouchstart"in window||navigator.maxTouchPoints)&&window.innerWidth>767&&[].forEach.call(document.querySelectorAll(".site-header ul ul, .site-header-cart .widget_shopping_cart"),function(a){a.classList.add("sub-menu--is-touch-device")})}}})}();

View File

@@ -0,0 +1,19 @@
( function() {
var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1,
is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1,
is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1;
if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) {
window.addEventListener( 'hashchange', function() {
var element = document.getElementById( location.hash.substring( 1 ) );
if ( element ) {
if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
element.tabIndex = -1;
}
element.focus();
}
}, false );
}
})();

View File

@@ -0,0 +1 @@
!function(){var a=navigator.userAgent.toLowerCase().indexOf("webkit")>-1,b=navigator.userAgent.toLowerCase().indexOf("opera")>-1,c=navigator.userAgent.toLowerCase().indexOf("msie")>-1;(a||b||c)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var a=document.getElementById(location.hash.substring(1));a&&(/^(?:a|select|input|button|textarea)$/i.test(a.tagName)||(a.tabIndex=-1),a.focus())},!1)}();

View File

@@ -0,0 +1,58 @@
/*global storefront_sticky_add_to_cart_params */
( function() {
document.addEventListener( 'DOMContentLoaded', function() {
var stickyAddToCart = document.getElementsByClassName( 'storefront-sticky-add-to-cart' );
if ( ! stickyAddToCart.length ) {
return;
}
if ( typeof storefront_sticky_add_to_cart_params === 'undefined' ) {
return;
}
var trigger = document.getElementsByClassName( storefront_sticky_add_to_cart_params.trigger_class );
if ( trigger.length > 0 ) {
var stickyAddToCartToggle = function() {
if ( ( trigger[0].getBoundingClientRect().top + trigger[0].scrollHeight ) < 0 ) {
stickyAddToCart[0].classList.add( 'storefront-sticky-add-to-cart--slideInDown' );
stickyAddToCart[0].classList.remove( 'storefront-sticky-add-to-cart--slideOutUp' );
} else if ( stickyAddToCart[0].classList.contains( 'storefront-sticky-add-to-cart--slideInDown' ) ) {
stickyAddToCart[0].classList.add( 'storefront-sticky-add-to-cart--slideOutUp' );
stickyAddToCart[0].classList.remove( 'storefront-sticky-add-to-cart--slideInDown' );
}
};
stickyAddToCartToggle();
window.addEventListener( 'scroll', function() {
stickyAddToCartToggle();
} );
// Get product id
var product_id = null;
document.body.classList.forEach( function( item ){
if ( 'postid-' === item.substring( 0, 7 ) ) {
product_id = item.replace( /[^0-9]/g, '' );
}
} );
if ( product_id ) {
var product = document.getElementById( 'product-' + product_id );
if ( product ) {
if ( ! product.classList.contains( 'product-type-simple' ) && ! product.classList.contains( 'product-type-external' ) ) {
var selectOptions = document.getElementsByClassName( 'storefront-sticky-add-to-cart__content-button' );
selectOptions[0].addEventListener( 'click', function( event ) {
event.preventDefault();
document.getElementById( 'product-' + product_id ).scrollIntoView();
} );
}
}
}
}
} );
} )();

View File

@@ -0,0 +1 @@
!function(){document.addEventListener("DOMContentLoaded",function(){var a=document.getElementsByClassName("storefront-sticky-add-to-cart");if(a.length&&"undefined"!=typeof storefront_sticky_add_to_cart_params){var b=document.getElementsByClassName(storefront_sticky_add_to_cart_params.trigger_class);if(b.length>0){var c=function(){b[0].getBoundingClientRect().top+b[0].scrollHeight<0?(a[0].classList.add("storefront-sticky-add-to-cart--slideInDown"),a[0].classList.remove("storefront-sticky-add-to-cart--slideOutUp")):a[0].classList.contains("storefront-sticky-add-to-cart--slideInDown")&&(a[0].classList.add("storefront-sticky-add-to-cart--slideOutUp"),a[0].classList.remove("storefront-sticky-add-to-cart--slideInDown"))};c(),window.addEventListener("scroll",function(){c()});var d=null;if(document.body.classList.forEach(function(a){"postid-"===a.substring(0,7)&&(d=a.replace(/[^0-9]/g,""))}),d){var e=document.getElementById("product-"+d);if(e&&!e.classList.contains("product-type-simple")&&!e.classList.contains("product-type-external")){document.getElementsByClassName("storefront-sticky-add-to-cart__content-button")[0].addEventListener("click",function(a){a.preventDefault(),document.getElementById("product-"+d).scrollIntoView()})}}}}})}();

View File

@@ -0,0 +1,32 @@
/**
* brands.js
*
* Adds sticky functionality to the brands index.
*/
( function() {
document.addEventListener( 'DOMContentLoaded', function() {
var brandsAZ = document.getElementsByClassName( 'brands_index' );
if ( ! brandsAZ.length ) {
return;
}
var adminBar = document.body.classList.contains( 'admin-bar' ) ? 32 : 0,
brandsContainerHeight = document.getElementById( 'brands_a_z' ).scrollHeight,
brandsAZHeight = brandsAZ[0].scrollHeight + 40;
var stickyBrandsAZ = function() {
if ( window.innerWidth > 768 && brandsAZ[0].getBoundingClientRect().top < 0 ) {
brandsAZ[0].style.paddingTop = Math.min( ( Math.abs( brandsAZ[0].getBoundingClientRect().top ) + 20 + adminBar ), brandsContainerHeight - brandsAZHeight ) + 'px';
} else {
brandsAZ[0].style.paddingTop = 0;
}
};
stickyBrandsAZ();
window.addEventListener( 'scroll', function() {
stickyBrandsAZ();
} );
} );
} )();

View File

@@ -0,0 +1 @@
!function(){document.addEventListener("DOMContentLoaded",function(){var a=document.getElementsByClassName("brands_index");if(a.length){var b=document.body.classList.contains("admin-bar")?32:0,c=document.getElementById("brands_a_z").scrollHeight,d=a[0].scrollHeight+40,e=function(){window.innerWidth>768&&a[0].getBoundingClientRect().top<0?a[0].style.paddingTop=Math.min(Math.abs(a[0].getBoundingClientRect().top)+20+b,c-d)+"px":a[0].style.paddingTop=0};e(),window.addEventListener("scroll",function(){e()})}})}();

View File

@@ -0,0 +1,24 @@
/**
* Makes the header cart content scrollable if the height of the dropdown exceeds the window height.
* Mouseover is used as items can be added to the cart via ajax and we'll need to recheck.
*/
( function() {
if ( document.body.classList.contains( 'woocommerce-cart' ) || document.body.classList.contains( 'woocommerce-checkout' ) || window.innerWidth < 768 || ! document.getElementById( 'site-header-cart' ) ) {
return;
}
window.addEventListener( 'load', function() {
var cart = document.querySelector( '.site-header-cart' );
cart.addEventListener( 'mouseover', function() {
var windowHeight = window.outerHeight,
cartBottomPos = this.querySelector( '.widget_shopping_cart_content' ).getBoundingClientRect().bottom + this.offsetHeight,
cartList = this.querySelector( '.cart_list' );
if ( cartBottomPos > windowHeight ) {
cartList.style.maxHeight = '15em';
cartList.style.overflowY = 'auto';
}
} );
} );
} )();

View File

@@ -0,0 +1 @@
!function(){document.body.classList.contains("woocommerce-cart")||document.body.classList.contains("woocommerce-checkout")||window.innerWidth<768||!document.getElementById("site-header-cart")||window.addEventListener("load",function(){document.querySelector(".site-header-cart").addEventListener("mouseover",function(){var a=window.outerHeight,b=this.querySelector(".widget_shopping_cart_content").getBoundingClientRect().bottom+this.offsetHeight,c=this.querySelector(".cart_list");b>a&&(c.style.maxHeight="15em",c.style.overflowY="auto")})})}();