Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

David Browne wplit

💭
I may be slow to respond.
View GitHub Profile
@wplit
wplit / code-block.js
Last active Jul 21, 2022
animate code added on appending posts by WPGB
View code-block.js
window.WP_Grid_Builder && WP_Grid_Builder.on( 'init', onInit );
function onInit( wpgb ) {
wpgb.facets.on( 'appended', onAppended );
}
function onAppended( posts ) {
posts.forEach( animate );
}
@wplit
wplit / code-block.js
Created Jul 20, 2022
trigger click on burger when other element clicked
View code-block.js
jQuery(document).ready(function($) {
const clickElement = '.click-element';
const burgerElement = '.oxy-burger-trigger';
$(clickElement).on('click', function(e) {
$(burgerElement).trigger('click');
});
});
@wplit
wplit / code-block.js
Created Jul 20, 2022
force video to pause when lightbox closed
View code-block.js
jQuery(document).on('beforeClose.fb', function( e, instance, slide ) {
slide.$slide.find("vime-player")[0].pause();
});
@wplit
wplit / code-block.js
Created Jul 11, 2022
reapply lightbox functionality to page after lightbox closes
View code-block.js
jQuery(document).ready(function($) {
$('.oxy-lightbox').on('extras_lightbox:close', function(){
setTimeout(function() {
if ( typeof doExtrasLightbox == 'function' ) {
doExtrasLightbox(jQuery('body'));
}
@wplit
wplit / style.css
Created Jul 11, 2022
remove transforms if reduced motion
View style.css
@media (prefers-reduced-motion: reduce) {
[data-rellax-speed] {
transform: none!important;
}
}
@wplit
wplit / nestable-element.php
Last active Jul 8, 2022
example code for a nestable element, showing the need for the vue component to be able to use render_builder()
View nestable-element.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class X_Element_Nestable extends \Bricks\Element {
// Element properties
public $category = 'extras';
public $name = 'xelementnestable';
public $icon = 'ti-view-list-alt';
View nestable.php
/*
Trying to add links above and below nested content, echoing all seperately.
Links are shown inside builder, but they always appear above the nested content. The order of the markup not respected.
*/
public function render() {
echo "<div {$this->render_attributes( '_root' )}>";
@wplit
wplit / nestable.php
Last active Jul 8, 2022
won't see links in correct place builder, also gives console error
View nestable.php
/*
Trying to add links above and below nested content.
console error..
"iframe.min.js?ver=1656975795:1 Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at http://brick.local/wp-content/themes/bricks/assets/js/iframe.min.js?ver=1656975795:1:489015
at NodeList.forEach (<anonymous>)
at Proxy.<anonymous> (http://brick.local/wp-content/themes/bricks/assets/js/iframe.min.js?ver=1656975795:1:488977)"
@wplit
wplit / code-block.js
Last active Jun 30, 2022
Prevent scrollbar removal from moving content when lightbox opens (code for testing across different browsers)
View code-block.js
jQuery(document).ready(function($) {
let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
$(document).on('afterLoad.fb', function( e, instance, slide ) {
$('head').append('<style id="extras-style-noscroll" type="text/css">.compensate-for-scrollbar{margin-right:' + scrollbarWidth + 'px!important;}</style>')
});
$(document).on('afterClose.fb', function( e, instance, slide ) {
$('head #extras-style-noscroll').remove();
@wplit
wplit / horizontal-scroll.json
Created Jun 27, 2022
horizontal scroll bricks template
View horizontal-scroll.json
{"id":159,"name":"horizontal-scroll","title":"Horizontal Scroll","date":"2022-06-27 05:00:18","date_formatted":"June 27, 2022","author":{"name":"david","avatar":"https:\/\/secure.gravatar.com\/avatar\/72f0b6e1ba2e1dfaabcc9a3d3d5708ae?s=60&d=mm&r=g","url":"https:\/\/lib.wplit.com"},"permalink":"https:\/\/lib.wplit.com\/horizontal-scroll-bricks\/template\/horizontal-scroll\/","thumbnail":false,"bundles":[],"tags":[],"type":"section","content":[{"id":"eloddv","name":"container","parent":0,"children":["oypjux"],"settings":{"tag":"section","_alignSelf":"stretch","_alignItems":"center"},"label":"Section"},{"id":"rjnzeo","name":"container","parent":0,"children":["tptemj","ycnffq"],"settings":{"tag":"section","_alignItems":"center","_background":{"color":{"hex":"#e0e0e0","id":"2b4bea"}},"_cssGlobalClasses":["dwwhjb"],"_direction":"row","_direction:tablet_portrait":"column","_cssCustom":"#brxe-rjnzeo.horizontal-scroll-container.brx-container {\n display:flex;\n flex-wrap:nowrap;\n will-change: transform;\n