Skip to content

Commit

Permalink
Version 1.43.15 - Updated from Woody-Library PRO
Browse files Browse the repository at this point in the history
  • Loading branch information
Woody Wordpress committed Feb 9, 2023
1 parent fa1483c commit 17ded17
Show file tree
Hide file tree
Showing 355 changed files with 3,107 additions and 1,930 deletions.
40 changes: 23 additions & 17 deletions WoodyLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

use Symfony\Component\Finder\Finder;
use JsonException;

/**
*
Expand All @@ -32,18 +33,17 @@ public static function getTemplatesDirname()
if (function_exists('apply_filters')) {
$dirs = apply_filters('woody_library_templates_directories', $dirs); // Filter to add directory
}

return $dirs;
}

public static function getTemplatesByAcfGroup($components, $id)
{
$return = [];
foreach ($components as $component => $val) {
if (!empty($val['acf_groups'])) {
if (in_array($id, $val['acf_groups'])) {
unset($val['acf_groups']);
$return[$component] = $val;
}
if (!empty($val['acf_groups']) && in_array($id, $val['acf_groups'])) {
unset($val['acf_groups']);
$return[$component] = $val;
}
}

Expand Down Expand Up @@ -78,8 +78,7 @@ public static function getComponents()
public static function getComponentsData($finder)
{
$components = [];
foreach ($finder as $key => $folder) {

foreach ($finder as $folder) {
// Foreach folder, get full and relative path
$folder_path = $folder->getRealPath();
$folder_name = $folder->getRelativePathname();
Expand All @@ -90,25 +89,30 @@ public static function getComponentsData($finder)

$jsonsFinder = new Finder();
$jsonsFinder->files()->name('*.json')->in($folder_path);
foreach ($jsonsFinder as $key => $json) {
$json_data = file_get_contents($json);
$php_data = json_decode($json_data, true);
foreach ($jsonsFinder as $json) {
try {
$json_data = file_get_contents($json);
$php_data = json_decode($json_data, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $jsonException) {
wd(sprintf('%s : %s', $jsonException->getMessage(), $json), 'emergency');
}

if (empty($php_data['approved']) || $php_data['approved'] == false) {
continue;
}

if (!empty($php_data['acf_groups'])) {
foreach ($php_data['acf_groups'] as $key => $acf_group) {
foreach ($php_data['acf_groups'] as $acf_group) {
$components[$name]['acf_groups'][] = $acf_group;
}
} else {
$components[$name]['acf_groups'][] = '';
}

$components[$name]['name'] = (!empty($php_data['name'])) ? $php_data['name'] : '';
$components[$name]['description'] = (!empty($php_data['description'])) ? $php_data['description'] : '';
$components[$name]['display'] = (!empty($php_data['display'])) ? $php_data['display'] : '';
$components[$name]['creation'] = (!empty($php_data['creation'])) ? $php_data['creation'] : '';
$components[$name]['name'] = (empty($php_data['name'])) ? '' : $php_data['name'];
$components[$name]['description'] = (empty($php_data['description'])) ? '' : $php_data['description'];
$components[$name]['display'] = (empty($php_data['display'])) ? '' : $php_data['display'];
$components[$name]['creation'] = (empty($php_data['creation'])) ? '' : $php_data['creation'];
}

// Get all images files (.png) in the targeted folder
Expand All @@ -124,10 +128,12 @@ public static function getComponentsData($finder)
if ($keep == true) {
$url[] = $path_part;
}
if ($path_part == 'views') {

if ($path_part == 'views' || $path_part == 'Views') {
$keep = true;
}
}

$components[$name]['thumbnails']['small'] = implode('/', $url);
}

Expand All @@ -144,4 +150,4 @@ public static function getComponentsData($finder)

return $components;
}
}
}
2 changes: 2 additions & 0 deletions assets/js/_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import './mobile_menu';
import './page_teaser';
import './parallax';
import './phone_click';
import './profiles';
import './responsive_focus';
import './reveals';
import './search';
Expand All @@ -34,4 +35,5 @@ import './tables';
import './tabs';
import './testimonials';
import './custom_text';
import './woodyFairguestBadge';
import './woodyGallery';
10 changes: 0 additions & 10 deletions assets/js/headnavs.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ $('.woody-component-headnavs').each(function () {
'height': '100%',
'overflow': 'hidden'
});
visualPageTop.find('.imageObject:not(.thumb) .imageObject-img').css({
'position': 'absolute',
'left': '50%',
'top': '50%',
'transform': 'translateX(-50%) translateY(-50%)',
'min-height': '100%',
'min-width': '100%',
'width': 'auto',
'max-width': 'none'
});
visualPageTop.find('.videoObject').css({
'height': '100%',
'overflow': 'hidden'
Expand Down
18 changes: 10 additions & 8 deletions assets/js/hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ if(!!toggleHeroMoreImgs){
}

updateHeight() {
var teaserHeight = this.teaser.getBoundingClientRect().height,
teaserOverflow = this.rootStyle.getPropertyValue('--hero-gradient-teaser-overflow'),
heroGradientSize = this.rootStyle.getPropertyValue('--hero-gradient-size');

if (teaserOverflow == 'true') {
this.heroMedia.style.setProperty('height', 'calc(100vh + ' + heroGradientSize + ' + ' + teaserHeight + 'px)');
} else {
this.heroMedia.style.setProperty('height', 'calc(100vh + ' + heroGradientSize);
if(!!this.teaser && !!this.heroMedia){
var teaserHeight = this.teaser.getBoundingClientRect().height,
teaserOverflow = this.rootStyle.getPropertyValue('--hero-gradient-teaser-overflow'),
heroGradientSize = this.rootStyle.getPropertyValue('--hero-gradient-size');

if (teaserOverflow == 'true') {
this.heroMedia.style.setProperty('height', 'calc(100vh + ' + heroGradientSize + ' + ' + teaserHeight + 'px)');
} else {
this.heroMedia.style.setProperty('height', 'calc(100vh + ' + heroGradientSize);
}
}
}
}
Expand Down
32 changes: 17 additions & 15 deletions assets/js/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function getAndFitBounds() {
$(document).on('lazybeforeunveil', function () {
if (window.innerWidth < 1024) {
$('.focus-map-basicCard, .focus-map-overlayedCard').each(function () {
const focusMapSwiperResp = $(this).find('.swResp');
var focusMapSwiperResp = $(this).find('.swResp');
var markers = $(this).find('.focus-map-pane-element-toggler');

// Update slide on click
Expand All @@ -271,22 +271,24 @@ $(document).on('lazybeforeunveil', function () {
var swIndex = focusMapSwiperResp.find('[data-toggle-id="' + panId + '"]').index();
focusMapSwiperResp.data().swiper.slideTo(swIndex);
});

// Update marker with slide
focusMapSwiperResp.data().swiper.on('slideChangeTransitionStart', function () {
var slideActive = focusMapSwiperResp.find('.swiper-slide-active');
slideActive.addClass('is-active');
slideActive.siblings('.focus-map-pane-element').removeClass('is-active');
var slideIndex = slideActive.data('toggle-id');

markers.removeClass('activePane');
markers.each(function () {
var linkID = $(this).data('toggle');
if (linkID == slideIndex) {
$(this).addClass('activePane');
}
var slides = focusMapSwiperResp.find('.focus-map-pane-element');
if(slides.length > 1) {
focusMapSwiperResp.data().swiper.on('slideChangeTransitionStart', function () {
var slideActive = focusMapSwiperResp.find('.swiper-slide-active');
slideActive.addClass('is-active');
slideActive.siblings('.focus-map-pane-element').removeClass('is-active');
var slideIndex = slideActive.data('toggle-id');

markers.removeClass('activePane');
markers.each(function () {
var linkID = $(this).data('toggle');
if (linkID == slideIndex) {
$(this).addClass('activePane');
}
});
});
});
}
});
}
});
34 changes: 34 additions & 0 deletions assets/js/medias.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,41 @@ class Medias {
this.components.push(player);
});
this.playPauseMultiple();

// Initialize sound control
Array.from(document.querySelectorAll('.videoObject-video.sound-control')).forEach(video => {
this.appendSoundControl(video);
});
}

appendSoundControl(video){
if(!!video){

let checkBox = document.createElement('input');
checkBox.setAttribute('type', 'checkbox');

let slider = document.createElement('span');
slider.setAttribute('class', 'slider');

let soundSwitch = document.createElement('label');
soundSwitch.setAttribute('class', 'sound-switch');

soundSwitch.append(checkBox);
soundSwitch.append(slider);

video.parentElement.append(soundSwitch);

checkBox.addEventListener('change', function(){
if(this.checked){
video.muted = false;
} else {
video.muted = true;
}
});

}
}

// On Play, force others videos to be paused
playPauseMultiple() {
let self = this;
Expand Down
7 changes: 3 additions & 4 deletions assets/js/menus_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ if (body.classList.contains('menus-v2')) {
});
}

let headerHeight = headnavs.offsetHeight;
let headerHeightFull = headerHeight + 30 + 'px';
let headerHeight = headnavs.offsetHeight + 'px';

if (document.querySelectorAll('.submenu-wrapper').length > 0) {
document.querySelectorAll('.submenu-wrapper').forEach(item => {
Expand All @@ -30,13 +29,13 @@ if (body.classList.contains('menus-v2')) {
});

if (slidingMenu !== null) {
item.style.setProperty('height', `calc(100vh - ${headerHeightFull})`);
item.style.setProperty('height', `calc(100vh - ${headerHeight})`);
}
});
}

if (slidingMenu !== null) {
let slidingMenuPosition = headerHeight + 'px';
let slidingMenuPosition = headerHeight;

slidingMenu.style.setProperty('top', `${slidingMenuPosition}`);
slidingMenu.style.setProperty('height', `calc(100vh - ${slidingMenuPosition})`);
Expand Down
107 changes: 107 additions & 0 deletions assets/js/modules/interactiveMap/interactiveMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
export function interactiveMap (inputOptions = {}) {
const defaultOptions = {
maps: '.interactive-map',
pins: '.map-pin',
card: '.card'
}

const options = Object.assign({}, defaultOptions, inputOptions);

const maps = document.querySelectorAll(options.maps);

if (maps.length > 0) {
maps.forEach(map => {
let mapPins = map.querySelectorAll(options.pins);

mapPins.forEach(pin => {
pin.addEventListener('click', () => {
let activePin = map.querySelector('.active')
activePin ? activePin.classList.remove('active') : '';
pin.classList.add('active');

let id = pin.getAttribute('data-id') || pin.getAttribute('data-post-id');
let card = map.querySelector(options.card);

if (id && card) {
card.classList.remove('card-loaded');
card.classList.add('skeleton-card');

fetch(`/wp-json/woody/page/preview?post=${id}`).then((response) => response.json()).then((post) => {
updateCard(post, card);
}).catch((err) => {
console.warn('Interactive map error : ', err);
});
}
});
})
});
}
}

export function updateCard (post, card) {
let page_type = post.page_type;
let postId = post.post_id;
let url = (post.link.url) ? post.link.url : '';
let img = post.img;
let icon = post.woody_icon;
let pretitle = post.pretitle;
let title = post.title;
let subtitle = post.subtitle;
let description = post.description;
description = (description && description.length > 180) ? description.slice(0, 180) + '...' : description;
let linkLabel = (post.link.link_label) ? post.link.link_label : '';

card.setAttribute('data-postid', postId);
card.querySelector('.card-link') ? card.querySelector('.card-link').setAttribute('href', url) : '';
card.querySelector('.card-pretitle') ? card.querySelector('.card-pretitle').innerHTML = pretitle : '';
card.querySelector('.card-title') ? card.querySelector('.card-title').innerHTML = title : '';
card.querySelector('.card-subtitle') ? card.querySelector('.card-subtitle').innerHTML = subtitle : '';
card.querySelector('.card-description') ? card.querySelector('.card-description').innerHTML = description : '';
card.querySelector('.card-button') ? card.querySelector('.card-button').innerHTML = linkLabel : '';

if (card.querySelector('.card-wicon')) {
if (icon) {
card.querySelector('.card-wicon').setAttribute('class', `card-wicon wicon wicon-woody-icons ${icon}`);
} else {
card.querySelector('.card-wicon').setAttribute('class', `card-wicon wicon wicon-woody-icons`);
}
}

let imgRatio = card.getAttribute('class').match(/\bratio[^\s]*/)[0];

if (!imgRatio) {
imgRatio = 'ratio_square';
}

if (!img.sizes) {
if (card.querySelector('.cardMediaWrapper img')) {
let currentImgHeight = card.querySelector('.cardMediaWrapper img').offsetHeight;
let currentImgWidth = card.querySelector('.cardMediaWrapper img').offsetWidth;
img.cleanImgUrl = img.url.replace('%width%/%height%', `${currentImgWidth}/${currentImgHeight}`);
}
}

if (img) {
card.querySelector('.cardMediaWrapper') ? card.querySelector('.cardMediaWrapper').style.opacity = '1' : '';

if (card.querySelector('.cardMediaWrapper img')) {
let ratioSmall = `${imgRatio}_small`;
let ratioMedium = `${imgRatio}_medium`;
let ratioLarge = `${imgRatio}`;
card.querySelector('.cardMediaWrapper img').classList.remove('lazyloaded');
if(img.sizes) {
card.querySelector('.cardMediaWrapper img').setAttribute('data-srcset', `${img.sizes[ratioSmall]} 360w, ${img.sizes[ratioMedium]} 640w, ${img.sizes[ratioLarge]} 1200w`);
card.querySelector('.cardMediaWrapper img').setAttribute('data-src', img.sizes[ratioLarge]);
} else {
card.querySelector('.cardMediaWrapper img').setAttribute('data-srcset', `${img.cleanImgUrl} 360w, ${img.cleanImgUrl} 640w, ${img.cleanImgUrl} 1200w`);
card.querySelector('.cardMediaWrapper img').setAttribute('data-src', img.cleanImgUrl);
}
card.querySelector('.cardMediaWrapper img').classList.add('lazyload');
img.alt ? card.querySelector('.cardMediaWrapper img').setAttribute('alt', img.alt) : '';
}
} else {
card.querySelector('.cardMediaWrapper') ? card.querySelector('.cardMediaWrapper').style.opacity = '0' : '';
}

card.classList.add('card-loaded');
}
3 changes: 2 additions & 1 deletion assets/js/modules/woodyGallery/wgContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ export function wgContent(medias, wG) {

let wrapper = document.querySelector('.wg-swiper-top .wg-swiper-wrapper');
medias.forEach((media) => {
let copyright = media.querySelector('.imageObject-caption') != null ? media.querySelector('.imageObject-caption').outerHTML : '';
if (media.dataset.wgtype === "video" || media.dataset.wgtype === "video-embed") {
pluginwgVideo.wgVideo(media, wrapper);
}
else {
pluginwgImage.wgImage(media, wrapper);
pluginwgImage.wgImage(media, copyright, wrapper);
}
});
}
Expand Down
Loading

0 comments on commit 17ded17

Please sign in to comment.