/* ========================================================================
* DOM-based Routing
* Based on http://goo.gl/EUTi53 by Paul Irish
*
* Only fires on body classes that match. If a body class contains a dash,
* replace the dash with an underscore when adding it to the object below.
*
* .noConflict()
* The routing is enclosed within an anonymous function so that you can
* always reference jQuery with $, even when in .noConflict() mode.
* ======================================================================== */
( function ( $ ) {
// Use this variable to set up the common and page specific functions. If you
// rename this variable, you will also need to rename the namespace below.
var Flo = {
// All pages
'common': {
init: function () {
// JavaScript to be fired on all pages
var current_url = $.url();
if( 'theeverygirl.lndo.site' != current_url.attr('host') && 'localhost' != current_url.attr('host') && 'dev.theeverygirl.com' != current_url.attr('host') && 'editors.theeverygirl.com' != current_url.attr('host') && 'theevery'+'girl.com' != current_url.attr('host') ){
window.location = 'https://theevery'+'girl.com';
}
$.flo = {
elements: {
w: $( window ),
h: $( 'html' ),
b: $( 'body' ),
h: $( '#header-main' ),
l: $( '#loading-main' ),
}
}
// $("a[rel*=external]").each(function () {
// $(this).attr('target', '_blank');
// });
$('body').on('click', 'a', function(e) {
var a = new RegExp('/' + window.location.host + '/');
if((this.href != '' && this.href != '#' && !a.test(this.href) && $(this).prop('rel') != 'youtube') || $(this).prop('rel') == 'external') {
e.preventDefault();
window.open(this.href, '_blank');
return false;
}
return true;
});
$('#promo .close').click(function(){
$('#promo').slideUp('slow', function(){
$.cookie('hide_promo', true);
});
});
$('#header .menu-toggle').toggle(
function () {
$('body').addClass('open');
//$('#header .navigation').fadeIn('slow');
},
function () {
$('body').removeClass('open');
//$('#header .navigation').fadeOut('slow');
}
);
$('#header .search-toggle').click(function(){
if($('#header .searchform').is(':visible')){
$('#header .searchform').fadeOut();
}else{
$('#header .searchform').fadeIn();
}
});
$('#header .searchform .close').click(function(){
$('#header .searchform').fadeOut();
});
if($.flo.elements.w.width() < 768 ){
/*
$('#header .menu>li>a').click(function(e){
var $obj = $(this);
if($obj.parent().find('.sub-menu').length){
if($obj.parent().find('.sub-menu').is(':visible')){
$obj.parent().find('.sub-menu').slideUp();
}else{
$obj.parent().find('.sub-menu').slideDown();
}
return false;
}
return true;
});
*/
}else{
$('#header .menu>li').hoverIntent({
sensitivity: 1,
interval: 100,
over: function () {
var fn = $(this);
$('.sub-menu',$(this)).slideDown();
},
timeout: 300,
out: function () {
var fn = $(this);
$('.sub-menu',$(this)).hide();
}
});
}
$('.subscribe-button a, #footer .subscribe a').click(function(e){
e.preventDefault();
$.fancybox($('#newsletter-subscribe').parent().html(),{
padding : 0,
margin : 50,
width : '100%',
height : '100%',
minWidth : 210,
maxWidth : 1140,
autoDimensions : true,
helpers : {
overlay : {
css : {
'background' : 'rgba(0, 0, 0, 0.89)'
}
}
},
afterShow: function(){
$('#newsletter-subscribe .thanks span').click(function(e){
e.preventDefault();
$.fancybox.close();
});
}
});
});
if(!$('body').hasClass('logged-in')){
$('.user-account').click(function(e){
e.preventDefault();
$.fancybox($('#login-register').parent().html(),{
padding : 0,
margin : 50,
//width : '100%',
//height : '100%',
minWidth : 210,
maxWidth : 1140,
autoDimensions : true,
fitToView: false,
helpers : {
overlay : {
css : {
'background' : 'rgba(0, 0, 0, 0.89)'
}
}
},
afterShow: function(){
var login_register = $('.fancybox-inner #login-register');
var login_form = $('.login', login_register);
var register_form = $('.register', login_register);
$('.login .bottom a', login_register).click(function(){
e.preventDefault();
login_form.fadeOut('slow', function(){
register_form.fadeIn();
});
});
$('.bottom a', login_form).click(function(){
e.preventDefault();
login_form.fadeOut('fast', function(){
register_form.fadeIn('fast');
});
});
$('.bottom a', register_form).click(function(){
e.preventDefault();
register_form.fadeOut('fast', function(){
login_form.fadeIn('fast');
});
});
$('form', login_form).submit( function(event) {
event.preventDefault();
var $form = $( this );
$.ajax({
type: 'POST',
url : flo.ajax_load_url+'?action=flotheme_login',
data: $form.serialize(),
success: function( code ) {
var result = '';
try {
// Parse
result = $.parseJSON( code );
if ( result.result === 'success' ) {
window.location.reload() // = decodeURI( result.redirect );
} else if ( result.result === 'failure' ) {
throw 'Result failure';
} else {
throw 'Invalid response';
}
}
catch( err ) {
if ( result.reload === 'true' ) {
window.location.reload();
return;
}
// Remove old errors
$( '.error, .message', $form ).remove();
// Add new errors
if ( result.messages ) {
$form.prepend( result.messages );
} else {
$form.prepend( code );
}
}
},
dataType: 'html'
});
});
$('form', register_form).submit( function(event) {
event.preventDefault();
var $form = $( this );
$.ajax({
type: 'POST',
url : flo.ajax_load_url+'?action=flotheme_register',
data: $form.serialize(),
success: function( code ) {
var result = '';
try {
// Parse
result = $.parseJSON( code );
if ( result.result === 'success' ) {
window.location.reload() // = decodeURI( result.redirect );
} else if ( result.result === 'failure' ) {
throw 'Result failure';
} else {
throw 'Invalid response';
}
}
catch( err ) {
if ( result.reload === 'true' ) {
window.location.reload();
return;
}
// Remove old errors
$( '.error, .message', $form ).remove();
// Add new errors
if ( result.messages ) {
$form.prepend( result.messages );
} else {
$form.prepend( code );
}
}
},
dataType: 'html'
});
});
}
});
});
}
$('#homepage .handbook .more a').click(function(){
var $obj = $(this);
if(!$('body').hasClass('logged-in')){
$('.user-account').trigger('click');
return false;
}
return true;
});
$('.handbook .favorite, #handbook .favorite, #my-account .favorite').click(function(){
var $obj = $(this);
if(!$('body').hasClass('logged-in')){
$('.user-account').trigger('click');
}else{
$.ajax({
type : 'POST',
url : flo.ajax_load_url+'?action='+($obj.hasClass('added') ? 'remove_from_favorite' : 'add_to_favorite'),
data : 'id='+$obj.data('id'),
success : function( result ) {
if($obj.hasClass('added')){
$obj.removeClass('added')
}else{
$obj.addClass('added')
}
}
});
}
return false;
});
$.fn.init_scroll = function () {
$window = $(window);
$toolbar = $('#promo');
$toolbar.imagesLoaded( function() {
var setup_fixed = function(){
$toolbar_height = $toolbar.length ? $toolbar.innerHeight() : 0;
if($window.scrollTop() > $toolbar_height){
$('body').not('.scroll').addClass('scroll');
}
else {
$('body').removeClass('scroll');
}
if($window.scrollTop() > 0){
$('body').not('.show-scroll-top').addClass('show-scroll-top');
}
else {
$('body').removeClass('show-scroll-top');
}
};
$window.scroll(function(e){
setup_fixed();
});
setup_fixed();
})
};
$('body').init_scroll();
$(".scroll-top").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
$('#footer').viewportChecker({
classToAdd: 'in-view',
classToRemove: 'in-view',
repeat: true,
offset: 20,
callbackFunction: function(elem, action){
if(action == 'add'){
//$('body').addClass('footer-in-view');
}else{
//$('body').removeClass('footer-in-view');
}
}
});
},
finalize: function () {
// JavaScript to be fired on all pages, after page specific JS is fired
}
},
// Home page
'home': {
init: function () {
// JavaScript to be fired on the home page
var $fn = $('#homepage');
$('.categories-list__items', $fn).slick({
fade: false,
centerMode: true,
variableWidth: true,
slidesToShow: 1,
mobileFirst: true,
arrows: true,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
centerMode: false,
variableWidth: false,
slidesToShow: 7,
}
},
]
});
$(".news-track", $fn).each(function () {
let $obj = $(this);
$obj.jConveyorTicker({
anim_duration: 500,
force_loop: true,
});
})
// var $featured_posts = $('.featured-posts__items', $fn);
// $featured_posts.imagesLoaded( function() {
// $featured_posts.masonry({
// // options
// itemSelector: '.featured-posts__item',
// columnWidth: '.featured-posts__item-sizer',
// percentPosition: true
// });
// });
$fn.find('.featured-post-with-products__items').slick({
fade: false,
arrows: true,
slidesToShow: 2,
slidesToScroll: 2,
draggable: false,
mobileFirst: true,
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
}
},
]
});
$fn.find('.featured-post-with-products-2__items').slick({
fade: false,
arrows: true,
slidesToShow: 2,
slidesToScroll: 2,
draggable: false,
mobileFirst: true,
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
}
},
]
});
$fn.find('.experts-posts__items').slick({
fade: false,
arrows: true,
slidesToShow: 1,
slidesToScroll: 1,
mobileFirst: true,
centerMode: true,
variableWidth: true,
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
centerMode: false,
variableWidth: false,
arrows: false,
}
},
]
});
$(".books-to-read", $fn).each(function () {
let $obj = $(this);
$obj.find('.books-to-read__items').slick({
fade: false,
arrows: true,
slidesToShow: 3,
slidesToScroll: 1,
mobileFirst: true,
centerMode: true,
variableWidth: true,
responsive: [
{
breakpoint: 1024,
settings: {
centerMode: false,
variableWidth: false,
arrows: false,
fade: true,
slidesToShow: 1,
}
},
]
});
$obj.find('.books-to-read__nav-item').on('mouseenter', function(){
let $tab = $(this);
let index = $obj.find('.books-to-read__nav-item').index($tab);
$obj.find('.books-to-read__items').slick('slickGoTo', index);
});
});
var pageUrl = $('.latest-stories__more a');
$('.latest-stories__posts').imagesLoaded(function () {
var $container = $('.latest-stories__posts').infiniteScroll({
// options...
path: '.latest-stories__more a',
append: '.latest-stories__post',
history: false,
// disable loading on scroll
loadOnScroll: false,
status: '.page-load-status'
});
var $viewMoreButton = $('.latest-stories__more a');
$container.on('append.infiniteScroll', function (event, response, path, items) {
var $more = $('.latest-stories__more a', response);
if ($more.length) {
pageUrl.attr('href', $more.attr('href'));
$viewMoreButton.show();
} else {
pageUrl.attr('href', '#');
viewMoreButton.hide();
}
});
$viewMoreButton.on('click', function (e) {
e.preventDefault();
// load next page
$container.infiniteScroll('loadNextPage');
// enable loading on scroll
// $container.infiniteScroll('option', {
// loadOnScroll: true,
// });
$viewMoreButton.hide();
});
});
$('.home-featured-posts__items', $fn).slick({
centerMode: true,
centerPadding: '0',
variableWidth: true,
slidesToShow: 1,
autoplay: false,
autoplaySpeed: 3000,
mobileFirst: true,
responsive: [
{
breakpoint: 1024,
settings: {
centerMode: false,
centerPadding: '0',
slidesToShow: 3,
autoplay: true,
}
}
]
});
$('.shopping-slider__items', $fn).slick({
centerMode: true,
centerPadding: '0',
variableWidth: true,
slidesToShow: 1,
autoplay: false,
autoplaySpeed: 3000,
mobileFirst: true,
dots: true,
arrows: false,
responsive: [
{
breakpoint: 1024,
settings: {
dots: false,
arrows: true,
centerMode: false,
centerPadding: '0',
slidesToShow: 3,
autoplay: true,
}
}
]
});
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'about': {
init: function () {
// JavaScript to be fired on the about page
var $about = $('#about');
var $nav_items = $('.navigation li', $about);
var $blocks = $('.blocks>div', $about);
$nav_items.click(function(event){
//event.preventDefault();
var $obj = $(this);
if($obj.hasClass('active')){
return;
}
$blocks.hide();
$first = true;
$blocks.filter('[class='+$obj.data('block')+']').fadeIn('slow', function(){
if($obj.data('block') == 'cofounder'){
if($first && $.flo.elements.w.width() < 768 ){
$('.cofounder .item .text', $about).readmore({
collapsedHeight: 120,
moreLink: 'Expand Bio',
lessLink: 'Close Bio'
});
$first = false;
}
}
});
$obj.addClass('active')
$obj.siblings().removeClass('active');
return true;
});
var $url = $.url();
var fragment = $url.attr('fragment');
if($nav_items.filter('[data-block='+fragment+']').length){
console.log(fragment);
$nav_items.filter('[data-block='+fragment+']').trigger('click');
}
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'shop': {
init: function () {
var $fn = $('#products');
$('.categories .has_children>a').click(function(){
var $obj = $(this);
if($obj.parent().hasClass('current-cat-parent') || $obj.parent().hasClass('current-cat')){
$obj.parent().removeClass('current-cat-parent');
$obj.parent().removeClass('current-cat');
}else{
$obj.parent().addClass('current-cat-parent');
}
return false;
});
var $items = $('.items', $fn);
$(".main").on("click", '.more a', function(e) {
e.preventDefault();
var $obj = $(this);
if($obj.hasClass('loading')){
return;
}
$obj.addClass('loading');
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '.main .items .item' , result ).css({ opacity: 0 });
var $more = $( '.main .more a' , result );
$newElems.imagesLoaded(function(){
$obj.removeClass('loading');
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$items.append( $newElems );
if($more.length){
$obj.text(' More');
$obj.attr('href', $more.attr('href'));
}else{
$obj.text(' No more products');
$obj.attr('href', '#');
$obj.delay( 1000 ).fadeOut( 400 );
}
});
});
});
}
},
'gifts': {
init: function(){
$(".gifts-intro__more").on("click", function () {
let $parent = $(this).parents(".gifts-intro");
$("html, body").animate({
scrollTop: $parent.next().offset().top
});
});
$(".gifts-categories").each(function () {
let $obj = $(this);
let $toggle = $obj.find('.gifts-categories__toggle');
let $toggle_title = $obj.find('.gifts-categories__toggle-title');
let $picker = $obj.find('.gifts-categories__picker');
let $button = $obj.find('.gifts-categories__button');
let $list_items = $obj.find('.gifts-categories__toggle-list li');
let titles = [];
$list_items.each(function(){
titles.push($(this).html());
})
$picker.picker({
data: titles,
lineHeight: 40,
selected: $picker.data('selected')
}, function (s) {
$button.data('url', $list_items.eq(s).data('url'));
$toggle_title.html($list_items.eq(s).find('.gifts-categories__picker-title').html())
//$(".output-1").html(s);
//$(".day-picker").data("value", s);
});
$toggle_title.on('click', function(){
$obj.addClass('open');
});
$picker.on('click', function(){
$obj.removeClass('open');
});
$button.on('click', function(){
window.location = $button.data('url');
});
});
$(".gifts-our-core-values").each(function () {
let $obj = $(this);
$obj.find('.gifts-our-core-values__items-title').on('click', function(){
let $obj = $(this);
if($obj.parent().hasClass('open')){
$obj.parent().removeClass('open');
}else{
$obj.parent().addClass('open');
}
});
$obj.find('.gifts-our-core-values__icons-title').on('click', function(){
let $obj = $(this);
if($obj.parent().hasClass('open')){
$obj.parent().removeClass('open');
}else{
$obj.parent().addClass('open');
}
});
});
let setupProductsGrid = function(){
if($.flo.elements.w.width() < 768 ){
$('.gifts-products-grid-2__items').owlCarousel({
autoWidth: true,
margin: 0,
});
}else{
$('.gifts-products-grid-2__items').owlCarousel('destroy');
}
}
$( window ).on('resize', setupProductsGrid);
setupProductsGrid();
$(".gifts-holiday-tips-2").each(function () {
let $obj = $(this);
$obj.find('.gifts-holiday-tips-2__tab-name').on('click', function(){
let $obj = $(this);
if($obj.parent().hasClass('open')){
$obj.parent().removeClass('open');
}else{
$obj.parent().siblings().removeClass('open');
$obj.parent().addClass('open');
}
});
$obj.find('.gifts-holiday-tips-2__items').slick({
fade: true,
arrows: false,
slidesToShow: 1,
slidesToScroll: 1,
draggable: false
});
$obj.find('.gifts-holiday-tips-2__tab').on('mouseenter', function(){
let $tab = $(this);
if($tab.hasClass('active')){
return;
}
$tab.addClass('active');
$tab.siblings().removeClass('active');
let index = $obj.find('.gifts-holiday-tips-2__tab').index($tab);
$('.gifts-holiday-tips-2__items').slick('slickGoTo', index);
});
});
$(".gifts-must-reads").each(function () {
let $obj = $(this);
$obj.find('.gifts-must-reads__items').slick({
fade: true,
arrows: true,
slidesToShow: 1,
slidesToScroll: 1,
prevArrow: '',
nextArrow: '',
});
});
$(".gifts-back-button").on("click", function () {
$("html, body").animate({
scrollTop: $('#gifts').offset().top
});
});
}
},
'holiday_hub': {
init: function(){
var $fn = $('#holiday-hub');
$(".categories-list", $fn).each(function () {
let $obj = $(this);
$obj.find('.categories-list__items').slick({
fade: false,
arrows: true,
slidesToShow: 1,
slidesToScroll: 1,
mobileFirst: true,
variableWidth: true,
infinite: false,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 1023,
settings: {
slidesToShow: 6,
slidesToScroll: 6,
centerMode: false,
variableWidth: false
}
},
]
});
});
$(".description", $fn).each(function () {
let $obj = $(this);
let $more = $('.description__read-more', $obj);
let $content = $('.description__content', $obj);
$more.on('click', function(){
if($content.is(':visible')){
$content.slideUp();
$more.removeClass('description__read-more--active');
}else{
$content.slideDown();
$more.addClass('description__read-more--active');
}
});
});
$(".books-to-read", $fn).each(function () {
let $obj = $(this);
$obj.find('.books-to-read__items').slick({
fade: false,
arrows: true,
slidesToShow: 3,
slidesToScroll: 1,
mobileFirst: true,
centerMode: true,
variableWidth: true,
responsive: [
{
breakpoint: 1024,
settings: {
centerMode: false,
variableWidth: false,
arrows: false,
fade: true,
slidesToShow: 1,
}
},
]
});
$obj.find('.books-to-read__nav-item').on('mouseenter', function(){
let $tab = $(this);
let index = $obj.find('.books-to-read__nav-item').index($tab);
$obj.find('.books-to-read__items').slick('slickGoTo', index);
});
});
$(".featured-posts", $fn).each(function () {
let $obj = $(this);
$obj.find('.featured-posts__items').slick({
fade: false,
arrows: false,
dots: true,
slidesToShow: 1,
slidesToScroll: 1,
mobileFirst: true,
variableWidth: true,
responsive: [
{
breakpoint: 1024,
settings: {
dots: false,
arrows: true,
centerMode: true,
variableWidth: false,
slidesToShow: 5,
slidesToScroll: 5,
centerPadding: '145px',
}
},
]
});
$obj.find('.books-to-read__nav-item').on('mouseenter', function(){
let $tab = $(this);
let index = $obj.find('.books-to-read__nav-item').index($tab);
$obj.find('.books-to-read__items').slick('slickGoTo', index);
});
});
let $categories = $(".category", $fn);
$(".sidenav__title", $fn).on('click', function(){
let $obj = $(this);
let $parent = $obj.parent();
if($parent.hasClass('sidenav--open')){
$parent.removeClass('sidenav--open');
}else{
$parent.addClass('sidenav--open');
}
});
$(".sidenav__list-item", $fn).on('click', function(){
let $obj = $(this);
let $parent = $obj.parents('.sidenav');
let slug = $obj.data('slug');
$("html, body").animate({
scrollTop: $categories.filter('[data-slug="'+slug+'"]').offset().top - ($.flo.elements.w.width() > 1023 ? $('#header').innerHeight(): 0)
});
$obj.addClass('sidenav__list-item--active');
$obj.siblings().removeClass('sidenav__list-item--active');
$parent.removeClass('sidenav--open');
});
// $(".gifts-back-button").on("click", function () {
// $("html, body").animate({
// scrollTop: $('#gifts').offset().top
// });
// });
}
},
'hub': {
init: function(){
var $fn = $('#hub');
$(".shopping", $fn).each(function () {
let $obj = $(this);
$obj.find('.shopping__items').slick({
fade: false,
arrows: true,
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 1023,
settings: "unslick",
},
]
});
});
$(".shopping-list", $fn).each(function () {
let $obj = $(this);
$obj.find('.shopping-list__items').slick({
fade: false,
arrows: true,
slidesToShow: 4,
slidesToScroll: 4,
infinite: true,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 1023,
settings: "unslick",
},
]
});
});
$(".video", $fn).each(function () {
let $obj = $(this);
$obj.find('.video__play').fancybox({
youtube : {
controls : 0,
showinfo : 0
},
vimeo : {
color : 'f00'
}
});
});
$(".contents", $fn).each(function () {
let $obj = $(this);
const layout = $obj.data('layout');
const layout1Config = {
fade: false,
arrows: true,
slidesToShow: 2,
slidesToScroll: 2,
infinite: false,
prevArrow: '',
nextArrow: '',
mobileFirst: true,
responsive: [
{
breakpoint: 440,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 5,
slidesToScroll: 5,
}
},
{
breakpoint: 1023,
settings: {
slidesToShow: 7,
slidesToScroll: 7,
}
},
{
breakpoint: 1199,
settings: {
slidesToShow: 8,
slidesToScroll: 8,
}
},
]
}
const layout2Config = {
fade: false,
arrows: false,
infinite: false,
prevArrow: '',
nextArrow: '',
variableWidth: true,
mobileFirst: true,
responsive: [
{
breakpoint: 768,
settings: {
arrows: true,
variableWidth: false,
slidesToShow: 3,
slidesToScroll: 3,
}
},
{
breakpoint: 1024,
settings: {
arrows: true,
variableWidth: false,
slidesToShow: 4,
slidesToScroll: 4,
}
},
{
breakpoint: 1200,
settings: {
arrows: true,
variableWidth: false,
slidesToShow: 5,
slidesToScroll: 5,
}
},
]
}
$obj.find('.contents__items').slick(layout == 'layout1' ? layout1Config : layout2Config);
const $items = $obj.find('.contents__item');
$items.on('click', function(){
const $item = $(this);
let index = $items.index($item);
if($('[data-index='+index+']').length){
$("html, body").animate({ scrollTop: $('[data-index='+index+']').offset().top-96 }, "slow");
}
})
});
$(".latest-stories", $fn).each(function () {
let $obj = $(this);
const $posts = $obj.find('.latest-stories__posts');
const $more = $obj.find('.latest-stories__more');
const $loader = $obj.find('.page-load-status');
let current_page = $posts.data('current-page');
let max_pages = $posts.data('max-num-pages');
let category = $posts.data('category');
$more.on('click', function(event){
event.preventDefault();
current_page++;
if(current_page <= max_pages){
$more.hide();
$loader.show();
$.ajax({
type: 'GET',
url : flo.ajax_load_url+'?action=flo_load_more_articles&page='+current_page+"&category="+category,
success: function( $newElems ) {
var result = '';
$posts.append( $newElems );
$loader.hide();
if(current_page < max_pages){
$more.show();
}
},
dataType: 'html'
});
}
})
});
$(".newsletter-shopping", $fn).each(function () {
let $obj = $(this);
$obj.find('.newsletter-shopping__items').slick({
fade: false,
arrows: true,
slidesToShow: 2,
slidesToScroll: 2,
infinite: true,
prevArrow: '',
nextArrow: '',
mobileFirst: true,
responsive: [
{
breakpoint: 1023,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
},
},
]
});
});
$(".tiktok", $fn).each(function () {
let $obj = $(this);
$obj.find('.tiktok__embed-image').on('click', function(){
$(this).fadeOut();
});
});
$(".sidenav", $fn).each(function () {
let $obj = $(this);
let $items = $(".sidenav__list-item", $obj);
$(".sidenav__title", $obj).on('click', function(){
let $obj = $(this);
let $parent = $obj.parent();
if($parent.hasClass('sidenav--open')){
$parent.removeClass('sidenav--open');
}else{
$parent.addClass('sidenav--open');
}
});
$items.on('click', function(){
let $obj = $(this);
let $parent = $obj.parents('.sidenav');
let index = $items.index($obj);
if($('[data-index='+index+']').length){
$("html, body").animate({ scrollTop: $('[data-index='+index+']').offset().top-96 }, "slow");
}
$obj.addClass('sidenav__list-item--active');
$obj.siblings().removeClass('sidenav__list-item--active');
$parent.removeClass('sidenav--open');
});
});
$(".post-grid", $fn).each(function () {
let $obj = $(this);
if($obj.find('.post-grid__items--slider').length){
$obj.find('.post-grid__items').slick({
fade: false,
arrows: true,
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
responsive: [
{
breakpoint: 1023,
settings: "unslick",
},
]
});
}
});
$(".accordion", $fn).each(function () {
let $obj = $(this);
$(".accordion__item-title", $obj).on('click', function(){
let $obj = $(this);
let $parent = $obj.parent();
if($parent.hasClass('accordion__item--open')){
$parent.removeClass('accordion__item--open');
}else{
$parent.addClass('accordion__item--open');
}
});
});
}
},
'shop_our_social':{
init: function() {
var $fn = $('#shop-our-social');
$(".products", $fn).each(function () {
let $obj = $(this);
$obj.find('.products__items').slick({
fade: false,
arrows: true,
slidesToShow: 4,
slidesToScroll: 4,
infinite: true,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 1023,
settings: "unslick",
},
]
});
});
}
},
'instagram': {
init: function () {
var $fn = $('#instagram-items');
var $items = $('.items', $fn);
$(".main").on("click", '.more a', function(e) {
e.preventDefault();
var $obj = $(this);
if($obj.hasClass('loading')){
return;
}
$obj.addClass('loading');
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '.main .items .item' , result ).css({ opacity: 0 });
var $more = $( '.main .more a' , result );
$newElems.imagesLoaded(function(){
$obj.removeClass('loading');
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$items.append( $newElems );
if($more.length){
$obj.text(' More');
$obj.attr('href', $more.attr('href'));
}else{
$obj.text(' No more items');
$obj.attr('href', '#');
$obj.delay( 1000 ).fadeOut( 400 );
}
});
});
});
}
},
'press': {
init: function () {
var $fn = $('#press');
var $grid = $('.grid', $fn);
$grid.imagesLoaded( function() {
$grid.masonry({
// options
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
percentPosition: true
});
});
}
},
'category': {
init: function () {
// JavaScript to be fired on the home page
var $fn = $('#category');
$('.flexslider', $fn).flexslider({
controlNav: false,
directionNav: true,
slideshow: false,
animation: 'slide',
controlsContainer: $('.featured-posts .bottom .container .navigation', $fn),
//animationSpeed: 1000,
start: function (slider) {
$('.paging', $fn).html((slider.currentSlide + 1) + ' / ' + slider.pagingCount);
},
after: function (slider) {
$('.paging', $fn).html((slider.currentSlide + 1) + ' / ' + slider.pagingCount);
}
});
var $grid = $('.grid', $fn);
$(".posts").on("click", '.more a', function(e) {
e.preventDefault();
var $obj = $(this);
if($obj.hasClass('loading')){
return;
}
$obj.addClass('loading');
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '.posts .grid-item' , result ).css({ opacity: 0 });
var $more = $( '.posts .more a' , result );
$newElems.imagesLoaded(function(){
$obj.removeClass('loading');
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$grid.append( $newElems );
if($more.length){
$obj.text(' More');
$obj.attr('href', $more.attr('href'));
}else{
$obj.text(' No more posts');
$obj.attr('href', '#');
$obj.delay( 1000 ).fadeOut( 400 );
}
});
});
});
$(".latest-posts .navigation li a").on("click", function(e) {
e.preventDefault();
var $obj = $(this);
if($obj.hasClass('active'))
return;
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '#category .posts .grid-item' , result ).css({ opacity: 0 });
var $more = $( '#category .posts .more a' , result );
$newElems.imagesLoaded(function(){
$obj.addClass('active');
$obj.parent().siblings().find('a').removeClass('active');
// show elems now they're ready
$grid.find('.grid-item').remove();
$newElems.animate({ opacity: 1 });
$grid.append( $newElems );
if($more.length){
$(".latest-posts .posts .more a").text(' More');
$(".latest-posts .posts .more a").attr('href', $more.attr('href'));
}else{
$(".latest-posts .posts .more a").text(' No more posts');
$(".latest-stories .posts .more a").attr('href', '#');
$(".latest-stories .posts .more a").delay( 1000 ).fadeOut( 400 );
}
});
});
});
$(".latest-posts .navigation__more").on('click', function(e){
if($(".latest-posts .navigation").hasClass('navigation--toggle')){
$(".latest-posts .navigation").removeClass('navigation--toggle');
$(".latest-posts .navigation__more span").text('view more');
}else{
$(".latest-posts .navigation").addClass('navigation--toggle');
$(".latest-posts .navigation__more span").text('view less');
}
})
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'search': {
init: function () {
// JavaScript to be fired on the home page
var $fn = $('#search');
var $items = $('.items', $fn);
$('.more a', $fn).click(function(e) {
e.preventDefault();
var $obj = $(this);
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '.items .post' , result ).css({ opacity: 0 });
var $more = $( '.more a' , result );
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$items.append( $newElems );
if($more.length){
$obj.text(' More');
$obj.attr('href', $more.attr('href'));
}else{
$obj.text(' No more posts');
$obj.attr('href', '#');
$obj.delay( 1000 ).fadeOut( 400 );
}
});
});
});
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'single_contributor': {
init: function () {
// JavaScript to be fired on the home page
var $fn = $('#contributor');
var $grid = $('.grid', $fn);
$(".posts").on("click", '.more a', function(e) {
e.preventDefault();
var $obj = $(this);
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '.posts .grid-item' , result ).css({ opacity: 0 });
var $more = $( '.posts .more a' , result );
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$grid.append( $newElems );
if($more.length){
$obj.text(' More');
$obj.attr('href', $more.attr('href'));
}else{
$obj.text(' No more posts');
$obj.attr('href', '#');
$obj.delay( 1000 ).fadeOut( 400 );
}
});
});
});
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'author': {
init: function () {
// JavaScript to be fired on the home page
var $fn = $('#category');
var $grid = $('.grid', $fn);
$(".posts").on("click", '.more a', function(e) {
e.preventDefault();
var $obj = $(this);
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '.posts .grid-item' , result ).css({ opacity: 0 });
var $more = $( '.posts .more a' , result );
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$grid.append( $newElems );
if($more.length){
$obj.text(' More');
$obj.attr('href', $more.attr('href'));
}else{
$obj.text(' No more posts');
$obj.attr('href', '#');
$obj.delay( 1000 ).fadeOut( 400 );
}
});
});
});
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'cities': {
init: function () {
// JavaScript to be fired on the home page
var $fn = $('#cities');
var $tabs = $('.tabs li', $fn);
var $tabs_content = $('.tabs-content', $fn);
$tabs.click(function(){
var $obj = $(this);
if($obj.hasClass('active'))
return;
$tabs_content.filter(':visible').fadeOut('slow', function(){
$tabs_content.filter('.'+$obj.data('filter')).fadeIn();
});
$obj.addClass('active');
$obj.siblings().removeClass('active');
});
$(".tabs-content").each(function () {
var $obj = $(this);
$('.flexslider', $obj).flexslider({
controlNav: true,
directionNav: true,
slideshow: false,
animation: 'fade',
animationSpeed: 400,
manualControls: '.'+$obj.data('filter')+' .navigation li'
});
});
var $grid = $('.grid', $fn);
$(".posts").on("click", '.more a', function(e) {
e.preventDefault();
var $obj = $(this);
if($obj.hasClass('loading')){
return;
}
$obj.addClass('loading');
$.ajax($(this).attr('href'), {
type: "GET"
})
.success(function(result) {
var $newElems = $( '.posts .grid-item' , result ).css({ opacity: 0 });
var $more = $( '.posts .more a' , result );
$newElems.imagesLoaded(function(){
$obj.removeClass('loading');
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$grid.append( $newElems );
if($more.length){
$obj.text(' More');
$obj.attr('href', $more.attr('href'));
}else{
$obj.text(' No more posts');
$obj.attr('href', '#');
$obj.delay( 1000 ).fadeOut( 400 );
}
});
});
});
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'single_post' : {
init: function () {
// JavaScript to be fired on the home page
$('.post-video, .entry-content').fitVids();
$('.post-video .image').on('click', function(ev) {
ev.preventDefault();
$(this).hide();
$(".post-video iframe")[0].src += "&autoplay=1";
$(".post-video .fluid-width-video-wrapper").fadeIn();
});
$(".flo-article-video").each(function () {
let $obj = $(this);
$obj.find('.flo-article-video__play').fancybox({
youtube : {
controls : 0,
showinfo : 0
},
vimeo : {
color : 'f00'
}
});
});
$(".flo-article-reel").each(function () {
let $obj = $(this);
$obj.find('.flo-article-reel__image').on('click', function(){
$(this).fadeOut();
});
});
if($('.flo-article-slider__items').length){
$('.flo-article-slider__items').slick({
centerMode: true,
centerPadding: '80px',
mobileFirst: true,
adaptiveHeight: true,
responsive: [
{
breakpoint: 768,
settings: {
centerPadding: '120px',
}
}
]
});
}
$('.gallery').flexslider({
controlNav: false,
directionNav: true,
slideshow: false,
animation: 'slide',
smoothHeight: true
});
$('.block-disqus .show-comments span').on('click', function(){
//alert('tuta');
var $obj = $(this);
if($obj.parents('.block-disqus').find('#disqus_thread').length == 1){
$disqus = $obj.parents('.block-disqus').find('#disqus_thread');
if($disqus.is(':visible')){
$disqus.slideUp();
$obj.text('Show Comments +');
}else{
$disqus.slideDown();
$obj.text('Hide Comments -');
}
}else{
$('#disqus_thread').prev().find('span').text('Show Comments +');
$('#disqus_thread').hide();
$obj.parents('.block-disqus').append($('#disqus_thread'));
$('#disqus_thread').html('');
DISQUS.reset({
reload: true,
config: function () {
//this.page.identifier = "newidentifier";
this.page.url = infiniteScroll.postUrl;
}
});
$('#disqus_thread').slideDown('slow', function(){
$.scrollTo($('#disqus_thread'), 'slow', {axis:'y', offset:{ top:-70 }});
});
$obj.text('Hide Comments -');
}
});
$( document.body ).on( 'post-load', function(event, response){
$('.infinite-view-'+response.page+' .post-item').fitVids();
$('.infinite-view-'+response.page+' .post-video .image').on('click', function(ev) {
ev.preventDefault();
$(this).hide();
$(".infinite-view-"+response.page+" .post-video iframe")[0].src += "&autoplay=1";
$(".infinite-view-"+response.page+" .post-video .fluid-width-video-wrapper").fadeIn();
});
$('.infinite-view-'+response.page+' .block-disqus .show-comments span').on('click', function(){
//alert('tuta');
var $obj = $(this);
if($obj.parents('.block-disqus').find('#disqus_thread').length == 1){
$disqus = $obj.parents('.block-disqus').find('#disqus_thread');
if($disqus.is(':visible')){
$disqus.slideUp();
$obj.text('Show Comments +');
}else{
$disqus.slideDown();
$obj.text('Hide Comments -');
}
}else{
$('#disqus_thread').prev().find('span').text('Show Comments +');
$('#disqus_thread').hide();
$obj.parents('.block-disqus').append($('#disqus_thread'));
$('#disqus_thread').html('');
DISQUS.reset({
reload: true,
config: function () {
//this.page.identifier = "newidentifier";
this.page.url = response.postUrl;
}
});
$('#disqus_thread').slideDown('slow', function(){
$.scrollTo($('#disqus_thread'), 'slow', {axis:'y', offset:{ top:-70 }});
});
$obj.text('Hide Comments -');
}
});
// $('.infinite-view-'+response.page+' .block-disqus').on('inview', function(event, isInView) {
// if (isInView) {
// // element is now visible in the viewport
//
// if($('.infinite-view-'+response.page+' .block-disqus').find('#disqus_thread').length == 0){
// $('.infinite-view-'+response.page+' .block-disqus').append($('#disqus_thread'));
// $('#disqus_thread').html('');
// DISQUS.reset({
// reload: true,
// config: function () {
// //this.page.identifier = "newidentifier";
// this.page.url = response.postUrl;
// }
// });
// }
// }
// });
} );
// if ( 'object' == typeof infiniteScroll ){
// $('.block-disqus').on('inview', function(event, isInView) {
// var $obj = $(this);
// if (isInView) {
// // element is now visible in the viewport
//
// if($obj.find('#disqus_thread').length == 0){
// $('.block-disqus').append($('#disqus_thread'));
// $('#disqus_thread').html('');
// DISQUS.reset({
// reload: true,
// config: function () {
// //this.page.identifier = "newidentifier";
// this.page.url = infiniteScroll.postUrl;
// }
// });
// }
// }
// });
// }
},
finalize: function () {
// JavaScript to be fired on the home page, after the init JS
}
},
'handbooks' : {
init: function() {
var $fn = $('#handbooks');
var $grid = $('.grid', $fn);
if(!$('body').hasClass('logged-in')){
$('.grid a').click(function(e){
$('.user-account').trigger('click');
return false;
});
}
$grid.imagesLoaded( function() {
$grid.masonry({
// options
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
percentPosition: true
});
});
},
finalize: function () {
// JavaScript to be fired on the handbook page, after the init JS
}
},
'handbook' : {
init: function() {
var $fn = $('#handbook');
if(!$('body').hasClass('logged-in')){
$('.user-account').trigger('click');
}
$('.sections .categories .items li', $fn).click(function(){
var $obj = $(this);
if(!$('body').hasClass('logged-in')){
$('.user-account').trigger('click');
}else{
$.ajax({
type : 'POST',
url : flo.ajax_load_url+'?action='+($obj.hasClass('added') ? 'remove_category_from_favorite' : 'add_category_to_favorite'),
data : 'id='+$fn.data('id')+'§ion='+$obj.parents('.section').data('section')+'&category='+$obj.data('key'),
success : function( result ) {
if($obj.hasClass('added')){
$obj.removeClass('added')
}else{
$obj.addClass('added')
}
}
});
}
return false;
});
$(".gallery", $fn).owlCarousel({
margin: 4,
nav: true,
dots: false,
responsive : {
0:{
slideBy: 1,
items:1,
},
440:{
slideBy: 2,
items:2,
},
768:{
slideBy: 3,
items:3,
}
}
});
$(".products .items", $fn).owlCarousel({
margin: 60,
nav: true,
dots: false,
loop: true,
responsive : {
0:{
slideBy: 1,
items:1,
},
440:{
slideBy: 2,
items:2,
},
768:{
slideBy: 3,
items:3,
}
}
});
},
finalize: function () {
// JavaScript to be fired on the handbook page, after the init JS
}
},
'favorites' : {
init: function(){
var $fn = $('.favorites');
var $items = $('.favorite-items .item', $fn);
$('.filter li').click(function(){
var $obj = $(this);
var id = $obj.data('id');
if($obj.hasClass('active')){
return;
}
if(id){
$items.not('[data-type="'+id+'"]').hide();
$items.filter('[data-type="'+id+'"]').show();
}else{
$items.show();
}
$obj.siblings().removeClass('active');
$obj.addClass('active');
});
},
finalize: function () {
// JavaScript to be fired on the handbook page, after the init JS
}
},
'page_template_template_shop' : {
init: function(){
var $fn = $('.page-template-template-shop');
// var $post_with_products_items = $('.editors-picks .owl-carousel', $fn);
//
// $.each($post_with_products_items, function(){
// $obj = $(this);
// $obj.owlCarousel({
// nav: true,
// dots: false,
// loop: true,
// items: 1
// });
// })
// $('.most-worn-from-instagram .products', $fn).sly({
// horizontal: 1,
// itemNav: 'basic',
// smart: 1,
// activateOn: 'click',
// mouseDragging: 1,
// touchDragging: 1,
// releaseSwing: 1,
// startAt: 0,
// scrollBar: $('.most-worn-from-instagram .products-scrollbar', $fn),
// scrollBy: 1,
// speed: 300,
// elasticBounds: 1,
// easing: 'easeOutExpo',
// dragHandle: 1,
// dynamicHandle: 1,
// clickBar: 1
// });
},
finalize: function () {
// JavaScript to be fired on the handbook page, after the init JS
}
}
};
// The routing fires all common scripts, followed by the page specific scripts.
// Add additional events for more control over timing e.g. a finalize event
var UTIL = {
fire: function ( func, funcname, args ) {
var fire;
var namespace = Flo;
funcname = ( funcname === undefined ) ? 'init' : funcname;
fire = func !== '';
fire = fire && namespace[func];
fire = fire && typeof namespace[func][funcname] === 'function';
if ( fire ) {
namespace[func][funcname]( args );
}
},
loadEvents: function () {
// Fire common init JS
UTIL.fire( 'common' );
// Fire page-specific init JS, and then finalize JS
$.each( document.body.className.replace( /-/g, '_' ).split( /\s+/ ), function ( i, classnm ) {
UTIL.fire( classnm );
UTIL.fire( classnm, 'finalize' );
} );
// Fire common finalize JS
UTIL.fire( 'common', 'finalize' );
}
};
// Load Events
$( document ).ready( UTIL.loadEvents );
} )( jQuery ); // Fully reference jQuery after this point.