liebling/assets/js/page.js
2021-02-15 19:56:34 +01:00

133 lines
5.7 KiB
JavaScript

(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["/js/page"],{
/***/ "./js/helpers.js":
/*!***********************!*\
!*** ./js/helpers.js ***!
\***********************/
/*! exports provided: isRTL, isMobile, isDarkMode, formatDate, getParameterByName, adjustImageGallery, managePostImages, makeImagesZoomable */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isRTL", function() { return isRTL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isMobile", function() { return isMobile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isDarkMode", function() { return isDarkMode; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatDate", function() { return formatDate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getParameterByName", function() { return getParameterByName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjustImageGallery", function() { return adjustImageGallery; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "managePostImages", function() { return managePostImages; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeImagesZoomable", function() { return makeImagesZoomable; });
var isRTL = function isRTL() {
var $html = document.querySelector('html');
return ['ar', 'he', 'fa'].includes($html.getAttribute('lang'));
};
var isMobile = function isMobile() {
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '768px';
return window.matchMedia("(max-width: ".concat(width, ")")).matches;
};
var isDarkMode = function isDarkMode() {
var darkModeMatcher = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');
return darkModeMatcher && darkModeMatcher.matches;
};
var formatDate = function formatDate(date) {
if (date) {
return new Date(date).toLocaleDateString(document.documentElement.lang, {
year: 'numeric',
month: 'long',
day: 'numeric'
});
}
return '';
};
var getParameterByName = function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp("[?&]".concat(name, "(=([^&#]*)|&|#|$)"));
var results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
};
var adjustImageGallery = function adjustImageGallery() {
var images = document.querySelectorAll('.kg-gallery-image img');
for (var i = 0, len = images.length; i < len; i++) {
var container = images[i].closest('.kg-gallery-image');
var width = images[i].attributes.width.value;
var height = images[i].attributes.height.value;
var ratio = width / height;
container.style.flex = "".concat(ratio, " 1 0%");
}
};
var managePostImages = function managePostImages($) {
$('.js-post-content').find('img').each(function () {
if (!$(this).closest('figure').hasClass('kg-bookmark-card') && !$(this).parent().is('a')) {
$(this).addClass('js-zoomable');
}
var $figcaption = $(this).parent().find('figcaption');
if ($figcaption) {
$(this).attr('alt', $figcaption.text());
} else {
$(this).attr('alt', '');
}
});
};
var makeImagesZoomable = function makeImagesZoomable($, mediumZoom) {
var zoom = mediumZoom('.js-zoomable');
zoom.on('opened', function () {
setTimeout(function () {
var $mediumZoomImages = $('.medium-zoom-image--opened');
if ($mediumZoomImages.length > 1) {
$mediumZoomImages.last().hide();
}
}, 10);
});
};
/***/ }),
/***/ "./js/page.js":
/*!********************!*\
!*** ./js/page.js ***!
\********************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var fitvids__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fitvids */ "./node_modules/fitvids/index.js");
/* harmony import */ var fitvids__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fitvids__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var medium_zoom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! medium-zoom */ "./node_modules/medium-zoom/dist/medium-zoom.esm.js");
/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helpers */ "./js/helpers.js");
jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).ready(function () {
fitvids__WEBPACK_IMPORTED_MODULE_1___default()('.js-post-content');
Object(_helpers__WEBPACK_IMPORTED_MODULE_3__["adjustImageGallery"])();
Object(_helpers__WEBPACK_IMPORTED_MODULE_3__["managePostImages"])(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
Object(_helpers__WEBPACK_IMPORTED_MODULE_3__["makeImagesZoomable"])(jquery__WEBPACK_IMPORTED_MODULE_0___default.a, medium_zoom__WEBPACK_IMPORTED_MODULE_2__["default"]);
});
/***/ }),
/***/ 4:
/*!**************************!*\
!*** multi ./js/page.js ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! /Users/eddie/Code/own/liebling/src/js/page.js */"./js/page.js");
/***/ })
},[[4,"/js/manifest","/js/vendor"]]]);