-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix advanced gallery component frontend scripts enqueuing
- Loading branch information
Showing
4 changed files
with
73 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/block-library/src/blocks/advanced-gallery/frontend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { AdvancedGallery } from "@novablocks/components"; | ||
|
||
const { GridItemCollection } = AdvancedGallery; | ||
const { getGalleryStyle, getGridStyle, safariHeightFix } = AdvancedGallery.utils; | ||
|
||
(function($, window, undefined) { | ||
|
||
$( '.novablocks-advanced-gallery' ).each( ( i, gallery ) => { | ||
|
||
let $gallery = $( gallery ), | ||
$grid = $gallery.find( '.novablocks-advanced-gallery__grid' ), | ||
images = $gallery.find( '.novablocks-advanced-gallery__image' ).toArray(); | ||
|
||
const attributes = { | ||
imageResizing: $gallery.data( 'imageresizing' ), | ||
containerHeight: $gallery.data( 'containerheight' ), | ||
positionShift: $gallery.data( 'positionshift' ), | ||
sizeContrast: $gallery.data( 'sizecontrast' ), | ||
imageRotation: $gallery.data( 'imagerotation' ), | ||
placementVariation: $gallery.data( 'placementvariation' ), | ||
elementsDistance: $gallery.data( 'elementsdistance' ), | ||
verticalSpacing: $gallery.data( 'verticalspacing' ), | ||
objectPosition: $gallery.data( 'objectposition' ), | ||
}; | ||
|
||
const gridItemsCollection = new GridItemCollection( images, attributes ); | ||
|
||
gridItemsCollection.gridItems.map( ( gridItem, index ) => { | ||
let $image = $( gridItem.image ), | ||
$item = $image.closest( '.novablocks-advanced-gallery__grid-item' ); | ||
|
||
$item.css( gridItem.getStyle() ); | ||
$image.css( gridItem.getImageStyle() ); | ||
} ); | ||
|
||
const galleryStyle = getGalleryStyle( attributes ); | ||
|
||
for ( let propertyName in galleryStyle ) { | ||
$gallery.css( galleryStyle ); | ||
|
||
if ( propertyName.indexOf( '--' ) === 0 ) { | ||
gallery.style.setProperty( propertyName, galleryStyle[ propertyName ] ); | ||
} | ||
} | ||
|
||
if ( $grid.length ) { | ||
|
||
const gridStyle = getGridStyle( attributes ); | ||
|
||
$grid.css( gridStyle ); | ||
|
||
for ( let propertyName in gridStyle ) { | ||
if ( propertyName.indexOf( '--' ) === 0 ) { | ||
$grid.get( 0 ).style.setProperty( propertyName, gridStyle[propertyName] ); | ||
} | ||
} | ||
} | ||
|
||
} ); | ||
|
||
$( '.novablocks-advanced-gallery__grid' ).each( function( i, obj ) { | ||
safariHeightFix( obj ); | ||
} ); | ||
|
||
})(jQuery, window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,3 @@ | ||
import { AdvancedGallery } from "@novablocks/components"; | ||
|
||
const { GridItemCollection } = AdvancedGallery; | ||
const { getGalleryStyle, getGridStyle } = AdvancedGallery.utils; | ||
|
||
(function($, window, undefined) { | ||
|
||
$( '.novablocks-advanced-gallery' ).each( ( i, gallery ) => { | ||
|
||
let $gallery = $( gallery ), | ||
$grid = $gallery.find( '.novablocks-advanced-gallery__grid' ), | ||
images = $gallery.find( '.novablocks-advanced-gallery__image' ).toArray(); | ||
|
||
const attributes = { | ||
imageResizing: $gallery.data( 'imageresizing' ), | ||
containerHeight: $gallery.data( 'containerheight' ), | ||
positionShift: $gallery.data( 'positionshift' ), | ||
sizeContrast: $gallery.data( 'sizecontrast' ), | ||
imageRotation: $gallery.data( 'imagerotation' ), | ||
placementVariation: $gallery.data( 'placementvariation' ), | ||
elementsDistance: $gallery.data( 'elementsdistance' ), | ||
verticalSpacing: $gallery.data( 'verticalspacing' ), | ||
objectPosition: $gallery.data( 'objectposition' ), | ||
}; | ||
|
||
const gridItemsCollection = new GridItemCollection( images, attributes ); | ||
|
||
gridItemsCollection.gridItems.map( ( gridItem, index ) => { | ||
let $image = $( gridItem.image ), | ||
$item = $image.closest( '.novablocks-advanced-gallery__grid-item' ); | ||
|
||
$item.css( gridItem.getStyle() ); | ||
$image.css( gridItem.getImageStyle() ); | ||
} ); | ||
|
||
const galleryStyle = getGalleryStyle( attributes ); | ||
|
||
for ( let propertyName in galleryStyle ) { | ||
$gallery.css( galleryStyle ); | ||
|
||
if ( propertyName.indexOf( '--' ) === 0 ) { | ||
gallery.style.setProperty( propertyName, galleryStyle[ propertyName ] ); | ||
} | ||
} | ||
|
||
if ( $grid.length ) { | ||
|
||
const gridStyle = getGridStyle( attributes ); | ||
|
||
$grid.css( gridStyle ); | ||
|
||
for ( let propertyName in gridStyle ) { | ||
if ( propertyName.indexOf( '--' ) === 0 ) { | ||
$grid.get( 0 ).style.setProperty( propertyName, gridStyle[propertyName] ); | ||
} | ||
} | ||
} | ||
} ); | ||
|
||
})(jQuery, window); |
This file was deleted.
Oops, something went wrong.