Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/blocks.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/blocks.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/blocks.min.js

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions assets/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

$caxton-width: 1060px;

.components-base-control__field .components-flex {
height: auto;
}

.caxton-notification {
padding: 50px;
padding: 25px;
text-align: center;
max-width: 430px;
margin: auto;
Expand Down Expand Up @@ -152,6 +156,14 @@ div, h1, h2, h3, h4, h5, h6, p, blockquote, header, footer, section {
}

.caxton-icon-picker-panel {
margin: 0 -16px 16px;

.caxton-icon-picker-preview svg {
height: 1.6em;
margin: -.25em 0;width: auto;
float: right;
}

.caxton-icon-picker {
border: 1px solid #ccc;
position: relative;
Expand All @@ -161,6 +173,7 @@ div, h1, h2, h3, h4, h5, h6, p, blockquote, header, footer, section {
.caxton-matching-icons {
display: flex;
flex-wrap: wrap;
justify-content: center;
max-height: 200px;
overflow: auto;
}
Expand All @@ -185,13 +198,17 @@ div, h1, h2, h3, h4, h5, h6, p, blockquote, header, footer, section {
}

.icon-choice {
margin: 0.4em;
width: 1.25em;
margin: 0.5em;
width: 1.4em;
transform: scale(.7);
line-height: 1.25;
font-size: 20px;
text-align: center;
box-sizing: content-box;
cursor: pointer;
&:hover svg{
transform: scale(1.4);
}
}

p {
Expand Down
55 changes: 29 additions & 26 deletions assets/caxton-utils.js → assets/caxton-utils.es6
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
*/

// region UX Utilities
var CaxtonUtils = {
const CaxtonUtils = {
closest : function ( el, predicate ) {
return predicate( el ) ? el : (
el && CaxtonUtils.closest( el.parentNode, predicate )
);
},
watchMouse: function ( selector ) {
var monitorMouse = document.querySelectorAll( selector );
let monitorMouse = document.querySelectorAll( selector );

if ( 0 < monitorMouse.length ) {

document.body.style.setProperty( '--cxp-msx', 0 );
document.body.style.setProperty( '--cxp-msy', 0 );
document.addEventListener( 'mousemove', function ( e ) {
var
let
x = ( 2 * e.pageX / window.innerWidth ) - 1,
y = ( 2 * e.pageY / window.innerHeight ) - 1,
el = e.target;
Expand All @@ -32,14 +32,14 @@ var CaxtonUtils = {
watchScrollSetup: function () {
if ( this.setupDone ) return;
console.log( 'scroll setup' );
var ticking = false;
let ticking = false;
this.setupDone = true;
CaxtonUtils.watchScrollSetup
var watchScroll = function () {
var docHeight = window.innerHeight;
for ( var i = 0; i < CaxtonUtils.watchScrollSetup.targets.length; ++ i ) {
var el = CaxtonUtils.watchScrollSetup.targets[i];
var
let watchScroll = function () {
let docHeight = window.innerHeight;
for ( let i = 0; i < CaxtonUtils.watchScrollSetup.targets.length; ++ i ) {
let el = CaxtonUtils.watchScrollSetup.targets[i];
let
boundingBox = el.getBoundingClientRect(),
height = boundingBox.height,
top = boundingBox.top;
Expand Down Expand Up @@ -76,15 +76,15 @@ var CaxtonUtils = {
}
},
each: function( selector, callback ) {
var els = document.querySelectorAll( selector );
for ( var i = 0; i < els.length; i ++ ) {
let els = document.querySelectorAll( selector );
for ( let i = 0; i < els.length; i ++ ) {
callback.apply( els[i], [ els[i], i ] );
}
},
delegate: function( eventName, elementSelector, handler ) {
document.addEventListener( eventName, function ( e ) {
// loop parent nodes from the target to the delegation node
for ( var target = e.target; target && target != this; target = target.parentNode ) {
for ( let target = e.target; target && target != this; target = target.parentNode ) {
if ( target.matches( elementSelector ) ) {
handler.call( target, e );
break;
Expand All @@ -93,23 +93,24 @@ var CaxtonUtils = {
}, false );
},
loadFonts: function() {
var caxtonFontsToLoad = [];
let caxtonFontsToLoad = [];
CaxtonUtils.each( '[style*="font-family"]', function () {
var font = this.style.fontFamily;
let font = this.style.fontFamily;
if ( font && -1 === font.indexOf( ',' ) && caxtonFontsToLoad.indexOf( font ) === - 1 ) {
caxtonFontsToLoad.push( font );
}
} );
if ( caxtonFontsToLoad.length ) {
var gfUrl = 'https://fonts.googleapis.com/css?family=' + caxtonFontsToLoad.join( '|' ) + '#.css';
let gfUrl = 'https://fonts.googleapis.com/css?family=' + caxtonFontsToLoad.join( '|' ) + '#.css';
CaxtonUtils.asset( gfUrl );
}
},
loadedAssets: {}, // Loaded assets record
asset: function ( _url, callback ) {
var head = document.head, el;
let el;
const head = document.head;

url = _url.indexOf( '//' ) > - 1 ? _url : caxtonUtilProps.assetsUrl + _url;
const url = _url.indexOf( '//' ) > - 1 ? _url : caxtonUtilProps.assetsUrl + _url;


if ( ! callback ) {
Expand Down Expand Up @@ -184,7 +185,7 @@ var CaxtonUtils = {
if ( document.querySelector( '.caxton-carousel-pending-setup' ) ) {
CaxtonUtils.addFlexslider( function () {
CaxtonUtils.each( '.caxton-carousel-pending-setup', function () {
var $t = jQuery( this );
let $t = jQuery( this );
$t.flexslider( {
move : 1,
animation : "slide",
Expand All @@ -207,11 +208,11 @@ var CaxtonUtils = {
return;
}

var styles = {},
let styles = {},
attributes = css.split( ';' );

for ( var i = 0; i < attributes.length; i ++ ) {
var entry = attributes[i].split( ':' );
for ( let i = 0; i < attributes.length; i ++ ) {
let entry = attributes[i].split( ':' );
styles[entry.splice( 0, 1 )[0]] = entry.join( ':' );
}
if ( this ) {
Expand All @@ -220,7 +221,7 @@ var CaxtonUtils = {
that.setAttribute( 'data-default-css', that.getAttribute( 'style' ) );
}
}
for ( var prop in styles ) {
for ( let prop in styles ) {
if ( prop && styles.hasOwnProperty( prop ) ) {
that.style[prop]=styles[prop];
}
Expand All @@ -231,7 +232,7 @@ var CaxtonUtils = {
},
responsiveStyling: function ( width ) {
width = isNaN( width ) ? window.innerWidth : width;
var body = document.querySelector( 'body' );
let body = document.querySelector( 'body' );
if ( width > 1024 ) {
// Desktop
body.setAttribute( 'data-rwd', 'desktop' );
Expand Down Expand Up @@ -269,15 +270,15 @@ var CaxtonUtils = {
if ( ! selector ) {
return el.parentElement;
}
var target = el.parentElement.querySelector( selector );
let target = el.parentElement.querySelector( selector );
if ( ! target ) {
target = document.querySelector( selector );
}
return target;
}

CaxtonUtils.delegate( 'click', '[data-toggle-class]', function( e ) {
var el = this,
let el = this,
target = findTarget( el, el.getAttribute( 'data-toggle-class' ) ),
toggleClass = el.getAttribute( 'data-toggle-classname' ) || 'toggle';

Expand All @@ -300,4 +301,6 @@ var CaxtonUtils = {

CaxtonUtils._stylesManager();
CaxtonUtils._interactionsManager();
CaxtonUtils.ready( CaxtonUtils.newContentManager );
CaxtonUtils.ready( CaxtonUtils.newContentManager );

window.CaxtonUtils = CaxtonUtils;
Loading