mirror of
https://github.com/ZetaKebab/kesper.git
synced 2025-07-03 02:17:38 +00:00
Concatenated all JS into a single file (#624)
no issue - moved large inline JS from templates into separate JS files - floating header - gallery card support - use `gulp-concat` to concatenate all JS files into a single `built/casper.js` file - reduces external JS file requests from 3 (jquery, infinite-scroll.js, jquery.fitvids.js) down to 2 (jquery, casper.js) and reduces page size by removing repeated inline code
This commit is contained in:
24
assets/js/gallery-card.js
Normal file
24
assets/js/gallery-card.js
Normal file
@ -0,0 +1,24 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* Gallery card support
|
||||
* Used on any individual post/page
|
||||
*
|
||||
* Detects when a gallery card has been used and applies sizing to make sure
|
||||
* the display matches what is seen in the editor.
|
||||
*/
|
||||
|
||||
(function (window, document) {
|
||||
var resizeImagesInGalleries = function resizeImagesInGalleries() {
|
||||
var images = document.querySelectorAll('.kg-gallery-image img');
|
||||
images.forEach(function (image) {
|
||||
var container = image.closest('.kg-gallery-image');
|
||||
var width = image.attributes.width.value;
|
||||
var height = image.attributes.height.value;
|
||||
var ratio = width / height;
|
||||
container.style.flex = ratio + ' 1 0%';
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', resizeImagesInGalleries);
|
||||
})(window, document);
|
Reference in New Issue
Block a user