var Grav; /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 40535: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "default": () => (/* binding */ main) }); // EXTERNAL MODULE: ./node_modules/@babel/polyfill/lib/index.js var lib = __webpack_require__(26981); // EXTERNAL MODULE: external "jQuery" var external_jQuery_ = __webpack_require__(73609); var external_jQuery_default = /*#__PURE__*/__webpack_require__.n(external_jQuery_); ;// CONCATENATED MODULE: ./app/utils/remodal.js /* Remodal from https://github.com/vodkabears/Remodal * With Stackable option from https://github.com/antstorm/Remodal patch */ !function (root, factory) { return factory(root, (external_jQuery_default())); }(undefined, function (global, $) { 'use strict'; /** * Name of the plugin * @private * @const * @type {String} */ var PLUGIN_NAME = 'remodal'; /** * Namespace for CSS and events * @private * @const * @type {String} */ var NAMESPACE = window.REMODAL_GLOBALS && window.REMODAL_GLOBALS.NAMESPACE || PLUGIN_NAME; /** * Animationstart event with vendor prefixes * @private * @const * @type {String} */ var ANIMATIONSTART_EVENTS = $.map(['animationstart', 'webkitAnimationStart', 'MSAnimationStart', 'oAnimationStart'], function (eventName) { return eventName + '.' + NAMESPACE; }).join(' '); /** * Animationend event with vendor prefixes * @private * @const * @type {String} */ var ANIMATIONEND_EVENTS = $.map(['animationend', 'webkitAnimationEnd', 'MSAnimationEnd', 'oAnimationEnd'], function (eventName) { return eventName + '.' + NAMESPACE; }).join(' '); /** * Default settings * @private * @const * @type {Object} */ var DEFAULTS = $.extend({ hashTracking: true, closeOnConfirm: true, closeOnCancel: true, closeOnEscape: true, closeOnOutsideClick: true, modifier: '', stack: false, appendTo: null }, window.REMODAL_GLOBALS && window.REMODAL_GLOBALS.DEFAULTS); /** * States of the Remodal * @private * @const * @enum {String} */ var STATES = { CLOSING: 'closing', CLOSED: 'closed', OPENING: 'opening', OPENED: 'opened' }; /** * Reasons of the state change. * @private * @const * @enum {String} */ var STATE_CHANGE_REASONS = { CONFIRMATION: 'confirmation', CANCELLATION: 'cancellation' }; /** * Is animation supported? * @private * @const * @type {Boolean} */ var IS_ANIMATION = function () { var style = document.createElement('div').style; return style.animationName !== undefined || style.WebkitAnimationName !== undefined || style.MozAnimationName !== undefined || style.msAnimationName !== undefined || style.OAnimationName !== undefined; }(); /** * Is iOS? * @private * @const * @type {Boolean} */ var IS_IOS = /iPad|iPhone|iPod/.test(navigator.platform); /** * Current modal * @private * @type {Remodal} */ var openModals = []; /** * Scrollbar position * @private * @type {Number} */ var scrollTop; /** * Returns an animation duration * @private * @param {jQuery} $elem * @returns {Number} */ function getAnimationDuration($elem) { if (IS_ANIMATION && $elem.css('animation-name') === 'none' && $elem.css('-webkit-animation-name') === 'none' && $elem.css('-moz-animation-name') === 'none' && $elem.css('-o-animation-name') === 'none' && $elem.css('-ms-animation-name') === 'none') { return 0; } var duration = $elem.css('animation-duration') || $elem.css('-webkit-animation-duration') || $elem.css('-moz-animation-duration') || $elem.css('-o-animation-duration') || $elem.css('-ms-animation-duration') || '0s'; var delay = $elem.css('animation-delay') || $elem.css('-webkit-animation-delay') || $elem.css('-moz-animation-delay') || $elem.css('-o-animation-delay') || $elem.css('-ms-animation-delay') || '0s'; var iterationCount = $elem.css('animation-iteration-count') || $elem.css('-webkit-animation-iteration-count') || $elem.css('-moz-animation-iteration-count') || $elem.css('-o-animation-iteration-count') || $elem.css('-ms-animation-iteration-count') || '1'; var max; var len; var num; var i; duration = duration.split(', '); delay = delay.split(', '); iterationCount = iterationCount.split(', '); // The 'duration' size is the same as the 'delay' size for (i = 0, len = duration.length, max = Number.NEGATIVE_INFINITY; i < len; i++) { num = parseFloat(duration[i]) * parseInt(iterationCount[i], 10) + parseFloat(delay[i]); if (num > max) { max = num; } } return max; } /** * Returns a scrollbar width * @private * @returns {Number} */ function getScrollbarWidth() { if ($(document).height() <= $(window).height()) { return 0; } var outer = document.createElement('div'); var inner = document.createElement('div'); var widthNoScroll; var widthWithScroll; outer.style.visibility = 'hidden'; outer.style.width = '100px'; document.body.appendChild(outer); widthNoScroll = outer.offsetWidth; // Force scrollbars outer.style.overflow = 'scroll'; // Add inner div inner.style.width = '100%'; outer.appendChild(inner); widthWithScroll = inner.offsetWidth; // Remove divs outer.parentNode.removeChild(outer); return widthNoScroll - widthWithScroll; } /** * Locks the screen * @private */ function lockScreen() { if (IS_IOS) { return; } var $html = $('html'); var lockedClass = namespacify('is-locked'); var paddingRight; var $body; if (!$html.hasClass(lockedClass)) { $body = $(document.body); // Zepto does not support '-=', '+=' in the `css` method paddingRight = parseInt($body.css('padding-right'), 10) + getScrollbarWidth(); $body.css('padding-right', paddingRight + 'px'); $html.addClass(lockedClass); } } /** * Unlocks the screen * @private */ function unlockScreen() { if (IS_IOS) { return; } var $html = $('html'); var lockedClass = namespacify('is-locked'); var paddingRight; var $body; if ($html.hasClass(lockedClass)) { $body = $(document.body); // Zepto does not support '-=', '+=' in the `css` method paddingRight = parseInt($body.css('padding-right'), 10) - getScrollbarWidth(); $body.css('padding-right', paddingRight + 'px'); $html.removeClass(lockedClass); } } /** * Sets a state for an instance * @private * @param {Remodal} instance * @param {STATES} state * @param {Boolean} isSilent If true, Remodal does not trigger events * @param {String} Reason of a state change. */ function setState(instance, state, isSilent, reason) { var newState = namespacify('is', state); var allStates = [namespacify('is', STATES.CLOSING), namespacify('is', STATES.OPENING), namespacify('is', STATES.CLOSED), namespacify('is', STATES.OPENED)].join(' '); instance.$bg.removeClass(allStates).addClass(newState); instance.$overlay.removeClass(allStates).addClass(newState); instance.$wrapper.removeClass(allStates).addClass(newState); instance.$modal.removeClass(allStates).addClass(newState); instance.state = state; !isSilent && instance.$modal.trigger({ type: state, reason: reason }, [{ reason: reason }]); } /** * Synchronizes with the animation * @param {Function} doBeforeAnimation * @param {Function} doAfterAnimation * @param {Remodal} instance */ function syncWithAnimation(doBeforeAnimation, doAfterAnimation, instance) { var runningAnimationsCount = 0; var handleAnimationStart = function handleAnimationStart(e) { if (e.target !== this) { return; } runningAnimationsCount++; }; var handleAnimationEnd = function handleAnimationEnd(e) { if (e.target !== this) { return; } if (--runningAnimationsCount === 0) { // Remove event listeners $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) { instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS); }); doAfterAnimation(); } }; $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) { instance[elemName].on(ANIMATIONSTART_EVENTS, handleAnimationStart).on(ANIMATIONEND_EVENTS, handleAnimationEnd); }); doBeforeAnimation(); // If the animation is not supported by a browser or its duration is 0 if (getAnimationDuration(instance.$bg) === 0 && getAnimationDuration(instance.$overlay) === 0 && getAnimationDuration(instance.$wrapper) === 0 && getAnimationDuration(instance.$modal) === 0) { // Remove event listeners $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) { instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS); }); doAfterAnimation(); } } /** * Closes immediately * @private * @param {Remodal} instance */ function halt(instance) { if (instance.state === STATES.CLOSED) { return; } $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) { instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS); }); removeModal(instance); instance.$bg.removeClass(instance.settings.modifier); instance.$overlay.removeClass(instance.settings.modifier).hide(); instance.$wrapper.hide(); if (openModals.length === 0) { unlockScreen(); } setState(instance, STATES.CLOSED, true); } /** * Parses a string with options * @private * @param str * @returns {Object} */ function parseOptions(str) { var obj = {}; var arr; var len; var val; var i; // Remove spaces before and after delimiters str = str.replace(/\s*:\s*/g, ':').replace(/\s*,\s*/g, ','); // Parse a string arr = str.split(','); for (i = 0, len = arr.length; i < len; i++) { arr[i] = arr[i].split(':'); val = arr[i][1]; // Convert a string value if it is like a boolean if (typeof val === 'string' || val instanceof String) { val = val === 'true' || (val === 'false' ? false : val); } // Convert a string value if it is like a number if (typeof val === 'string' || val instanceof String) { val = !isNaN(val) ? +val : val; } obj[arr[i][0]] = val; } return obj; } /** * Generates a string separated by dashes and prefixed with NAMESPACE * @private * @param {...String} * @returns {String} */ function namespacify() { var result = NAMESPACE; for (var i = 0; i < arguments.length; ++i) { result += '-' + arguments[i]; } return result; } /** * Handles the hashchange event * @private * @listens hashchange */ function handleHashChangeEvent() { var id = location.hash.replace('#', ''); var instance; var $elem; var current = currentModal(); if (!id) { // Check if we have currently opened modal and animation was completed if (current && current.state === STATES.OPENED && current.settings.hashTracking) { current.close(); } } else { if (!current || current.id !== id) { // Catch syntax error if your hash is bad try { $elem = $('[data-' + PLUGIN_NAME + '-id="' + id + '"]'); } catch (err) {} if ($elem && $elem.length) { instance = $[PLUGIN_NAME].lookup[$elem.data(PLUGIN_NAME)]; if (instance && instance.settings.hashTracking) { instance.open(); } } } } } function currentModal() { return openModals[openModals.length - 1]; } function removeModal(remodal) { var index = openModals.indexOf(remodal); if (index >= 0) { openModals.slice(index, 1); } } /** * Remodal constructor * @constructor * @param {jQuery} $modal * @param {Object} options */ function Remodal($modal, options) { var $body = $(document.body); var $appendTo = $body; var remodal = this; remodal.id = $modal.attr('data-' + PLUGIN_NAME + '-id'); remodal.settings = $.extend({}, DEFAULTS, options); remodal.index = $[PLUGIN_NAME].lookup.push(remodal) - 1; remodal.state = STATES.CLOSED; // remodal.$overlay = $('.' + namespacify('overlay')); if (remodal.settings.appendTo !== null && remodal.settings.appendTo.length) { $appendTo = $(remodal.settings.appendTo); } if (!remodal.$overlay) { remodal.$overlay = $('
').addClass(namespacify('overlay') + ' ' + namespacify('is', STATES.CLOSED)).hide(); $appendTo.append(remodal.$overlay); } remodal.$bg = $('.' + namespacify('bg')).addClass(namespacify('is', STATES.CLOSED)); remodal.$modal = $modal.addClass(NAMESPACE + ' ' + namespacify('is-initialized') + ' ' + remodal.settings.modifier + ' ' + namespacify('is', STATES.CLOSED)).attr('tabindex', '-1'); remodal.$wrapper = $('
').addClass(namespacify('wrapper') + ' ' + remodal.settings.modifier + ' ' + namespacify('is', STATES.CLOSED)).hide().append(remodal.$modal); $appendTo.append(remodal.$wrapper); // Add the event listener for the close button remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="close"]', function (e) { e.preventDefault(); remodal.close(); }); // Add the event listener for the cancel button remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="cancel"]', function (e) { e.preventDefault(); remodal.$modal.trigger(STATE_CHANGE_REASONS.CANCELLATION); if (remodal.settings.closeOnCancel) { remodal.close(STATE_CHANGE_REASONS.CANCELLATION); } }); // Add the event listener for the confirm button remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="confirm"]', function (e) { e.preventDefault(); remodal.$modal.trigger(STATE_CHANGE_REASONS.CONFIRMATION); if (remodal.settings.closeOnConfirm) { remodal.close(STATE_CHANGE_REASONS.CONFIRMATION); } }); // Add the event listener for the overlay remodal.$wrapper.on('click.' + NAMESPACE, function (e) { var $target = $(e.target); var isWrapper = $target.hasClass(namespacify('wrapper')); var isWithin = $target.closest('.' + namespacify('is', STATES.OPENED)).length; if (!isWrapper && isWithin) { return; } if (remodal.settings.closeOnOutsideClick) { remodal.close(); } }); } /** * Opens a modal window * @public */ Remodal.prototype.open = function () { var remodal = this; var current; var modalCount; // Check if the animation was completed if (remodal.state === STATES.OPENING || remodal.state === STATES.CLOSING) { return; } // id = remodal.$modal.attr('data-' + PLUGIN_NAME + '-id'); if (remodal.id && remodal.settings.hashTracking) { scrollTop = $(window).scrollTop(); location.hash = remodal.id; } if (!remodal.settings.stack) { current = currentModal(); if (current && current !== remodal) { halt(current); } } modalCount = openModals.push(remodal); remodal.$overlay.css('z-index', function (_, value) { return parseInt(value, 10) + modalCount; }); remodal.$wrapper.css('z-index', function (_, value) { return parseInt(value, 10) + modalCount; }); lockScreen(); remodal.$bg.addClass(remodal.settings.modifier); remodal.$overlay.addClass(remodal.settings.modifier).show(); remodal.$wrapper.show().scrollTop(0); remodal.$modal.focus(); syncWithAnimation(function () { setState(remodal, STATES.OPENING); }, function () { setState(remodal, STATES.OPENED); }, remodal); }; /** * Closes a modal window * @public * @param {String} reason */ Remodal.prototype.close = function (reason) { var remodal = this; var current; // Check if the animation was completed if (remodal.state === STATES.OPENING || remodal.state === STATES.CLOSING || remodal.state === STATES.CLOSED) { return; } removeModal(remodal); if (remodal.settings.hashTracking && remodal.id === location.hash.substr(1)) { current = currentModal(); if (current) { location.hash = current.id; } else { location.hash = ''; $(window).scrollTop(scrollTop); } } syncWithAnimation(function () { setState(remodal, STATES.CLOSING, false, reason); }, function () { remodal.$bg.removeClass(remodal.settings.modifier); remodal.$overlay.removeClass(remodal.settings.modifier).hide(); remodal.$wrapper.hide(); if (openModals.length === 0) { unlockScreen(); } setState(remodal, STATES.CLOSED, false, reason); }, remodal); }; /** * Returns a current state of a modal * @public * @returns {STATES} */ Remodal.prototype.getState = function () { return this.state; }; /** * Destroys a modal * @public */ Remodal.prototype.destroy = function () { var lookup = $[PLUGIN_NAME].lookup; var instanceCount; halt(this); this.$wrapper.remove(); delete lookup[this.index]; instanceCount = $.grep(lookup, function (instance) { return !!instance; }).length; if (instanceCount === 0) { this.$overlay.remove(); this.$bg.removeClass(namespacify('is', STATES.CLOSING) + ' ' + namespacify('is', STATES.OPENING) + ' ' + namespacify('is', STATES.CLOSED) + ' ' + namespacify('is', STATES.OPENED)); } }; /** * Special plugin object for instances * @public * @type {Object} */ $[PLUGIN_NAME] = { lookup: [] }; /** * Plugin constructor * @constructor * @param {Object} options * @returns {JQuery} */ $.fn[PLUGIN_NAME] = function (opts) { var instance; var $elem; this.each(function (index, elem) { $elem = $(elem); if ($elem.data(PLUGIN_NAME) == null) { instance = new Remodal($elem, opts); $elem.data(PLUGIN_NAME, instance.index); if (instance.settings.hashTracking && instance.id === location.hash.substr(1)) { instance.open(); } } else { instance = $[PLUGIN_NAME].lookup[$elem.data(PLUGIN_NAME)]; } }); return instance; }; $(document).ready(function () { // data-remodal-target opens a modal window with the special Id $(document).on('click', '[data-' + PLUGIN_NAME + '-target]', function (e) { e.preventDefault(); var elem = e.currentTarget; var id = elem.getAttribute('data-' + PLUGIN_NAME + '-target'); var $target = $('[data-' + PLUGIN_NAME + '-id="' + id + '"]'); $[PLUGIN_NAME].lookup[$target.data(PLUGIN_NAME)].open(); }); // Auto initialization of modal windows // They should have the 'remodal' class attribute // Also you can write the `data-remodal-options` attribute to pass params into the modal $(document).find('.' + NAMESPACE).each(function (i, container) { var $container = $(container); var options = $container.data(PLUGIN_NAME + '-options'); if (!options) { options = {}; } else if (typeof options === 'string' || options instanceof String) { options = parseOptions(options); } $container[PLUGIN_NAME](options); }); // Handles the keydown event $(document).on('keydown.' + NAMESPACE, function (e) { var current = currentModal(); if (current && current.settings.closeOnEscape && current.state === STATES.OPENED && e.keyCode === 27) { current.close(); } }); // Handles the hashchange event $(window).on('hashchange.' + NAMESPACE, handleHashChangeEvent); }); }); // EXTERNAL MODULE: ./node_modules/simplebar/dist/simplebar.esm.js + 1 modules var simplebar_esm = __webpack_require__(56884); // EXTERNAL MODULE: ./node_modules/toastr/toastr.js var toastr = __webpack_require__(8901); var toastr_default = /*#__PURE__*/__webpack_require__.n(toastr); ;// CONCATENATED MODULE: ./app/utils/toastr.js (toastr_default()).options.positionClass = 'toast-top-right'; (toastr_default()).options.preventDuplicates = true; /* harmony default export */ const utils_toastr = ((toastr_default())); ;// CONCATENATED MODULE: ./app/utils/offline.js var offlineElement = external_jQuery_default()('#offline-status'); external_jQuery_default()(window).on('offline', function () { offlineElement.slideDown(); }); external_jQuery_default()(window).on('online', function () { offlineElement.slideUp(); }); external_jQuery_default()(document).ready(function () { if (!offline) { offlineElement.slideDown(); } }); // assume online if can't check /* harmony default export */ const offline = (typeof __webpack_require__.g.navigator.onLine !== 'undefined' ? __webpack_require__.g.navigator.onLine : true); ;// CONCATENATED MODULE: external "GravAdmin" const external_GravAdmin_namespaceObject = GravAdmin; // EXTERNAL MODULE: ./node_modules/mout/string/trim.js var trim = __webpack_require__(78579); var trim_default = /*#__PURE__*/__webpack_require__.n(trim); ;// CONCATENATED MODULE: ./app/utils/response.js var UNLOADING = false; var error = function error(response) { var error = new Error(response.statusText || response || ''); error.response = response; return error; }; function parseStatus(response) { return response; /* Whoops can handle JSON responses so we don't need this for now. if (response.status >= 200 && response.status < 300) { return response; } else { throw error(response); } */ } function parseJSON(response) { return response.text().then(function (text) { var parsed = text; try { parsed = JSON.parse(text); } catch (error) { var content = document.createElement('div'); content.innerHTML = text; var the_error = new Error(); the_error.stack = trim_default()(content.innerText); throw the_error; } return parsed; }); } function userFeedback(response) { if (UNLOADING) { return true; } var status = response.status || (response.error ? 'error' : ''); var message = response.message || (response.error ? response.error.message : null); var settings = response.toastr || null; var backup; switch (status) { case 'unauthenticated': document.location.href = external_GravAdmin_namespaceObject.config.base_url_relative; throw error('Logged out'); case 'unauthorized': status = 'error'; message = message || 'Unauthorized.'; break; case 'error': status = 'error'; message = message || 'Unknown error.'; break; case 'success': status = 'success'; message = message || ''; break; default: status = 'error'; message = message || 'Invalid AJAX response.'; break; } if (settings) { backup = Object.assign({}, utils_toastr.options); Object.keys(settings).forEach(function (key) { utils_toastr.options[key] = settings[key]; }); } if (message && (offline || !offline && status !== 'error')) { utils_toastr[status === 'success' ? 'success' : 'error'](message); } if (settings) { utils_toastr.options = backup; } return response; } function userFeedbackError(error) { if (UNLOADING) { return true; } var stack = error.stack ? "
".concat(error.stack, "
") : ''; utils_toastr.error("Fetch Failed:
".concat(error.message, " ").concat(stack)); console.error("".concat(error.message, " at ").concat(error.stack)); } external_jQuery_default()(__webpack_require__.g).on('beforeunload._ajax', function () { UNLOADING = true; }); // EXTERNAL MODULE: ./node_modules/events/events.js var events = __webpack_require__(17187); var events_default = /*#__PURE__*/__webpack_require__.n(events); ;// CONCATENATED MODULE: ./app/utils/gpm.js function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var GPM = /*#__PURE__*/function (_EventEmitter) { _inherits(GPM, _EventEmitter); var _super = _createSuper(GPM); function GPM() { var _this; var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates'; _classCallCheck(this, GPM); _this = _super.call(this); _this.payload = {}; _this.raw = {}; _this.action = action; return _this; } _createClass(GPM, [{ key: "setPayload", value: function setPayload() { var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.payload = payload; this.emit('payload', payload); return this; } }, { key: "setAction", value: function setAction() { var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates'; this.action = action; this.emit('action', action); return this; } }, { key: "fetch", value: function (_fetch) { function fetch() { return _fetch.apply(this, arguments); } fetch.toString = function () { return _fetch.toString(); }; return fetch; }(function () { var _this2 = this; var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () { return true; }; var flush = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var data = new FormData(); data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce); if (flush) { data.append('flush', true); } this.emit('fetching', this); fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/update.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getUpdates"), { credentials: 'same-origin', method: 'post', body: data }).then(function (response) { _this2.raw = response; return response; }).then(parseStatus).then(parseJSON).then(function (response) { return _this2.response(response); }).then(function (response) { return callback(response, _this2.raw); }).then(function (response) { return _this2.emit('fetched', _this2.payload, _this2.raw, _this2); })["catch"](userFeedbackError); }) }, { key: "response", value: function response(_response) { this.payload = _response; return _response; } }]); return GPM; }((events_default())); var Instance = new GPM(); ;// CONCATENATED MODULE: ./app/utils/keepalive.js function keepalive_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function keepalive_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function keepalive_createClass(Constructor, protoProps, staticProps) { if (protoProps) keepalive_defineProperties(Constructor.prototype, protoProps); if (staticProps) keepalive_defineProperties(Constructor, staticProps); return Constructor; } var MAX_SAFE_DELAY = 2147483647; var KeepAlive = /*#__PURE__*/function () { function KeepAlive() { keepalive_classCallCheck(this, KeepAlive); this.active = false; } keepalive_createClass(KeepAlive, [{ key: "start", value: function start() { var _this = this; var timeout = external_GravAdmin_namespaceObject.config.admin_timeout / 1.5 * 1000; this.timer = setInterval(function () { return _this.fetch(); }, Math.min(timeout, MAX_SAFE_DELAY)); this.active = true; } }, { key: "stop", value: function stop() { clearInterval(this.timer); this.active = false; } }, { key: "fetch", value: function (_fetch) { function fetch() { return _fetch.apply(this, arguments); } fetch.toString = function () { return _fetch.toString(); }; return fetch; }(function () { var data = new FormData(); data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce); fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "keepAlive"), { credentials: 'same-origin', method: 'post', body: data })["catch"](userFeedbackError); }) }]); return KeepAlive; }(); /* harmony default export */ const keepalive = (new KeepAlive()); // EXTERNAL MODULE: ./node_modules/mout/array/unique.js var unique = __webpack_require__(79863); var unique_default = /*#__PURE__*/__webpack_require__.n(unique); ;// CONCATENATED MODULE: ./app/utils/request.js var raw; var request = function request(url) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () { return true; }; if (typeof options === 'function') { callback = options; options = {}; } if (options.method && options.method === 'post') { var data = new FormData(); options.body = Object.assign({ 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce }, options.body || {}); Object.keys(options.body).map(function (key) { return data.append(key, options.body[key]); }); options.body = data; } options = Object.assign({ credentials: 'same-origin', headers: { 'Accept': 'application/json' } }, options); return fetch(url, options).then(function (response) { raw = response; return response; }).then(parseStatus).then(parseJSON).then(userFeedback).then(function (response) { return callback(response, raw); })["catch"](userFeedbackError); }; /* harmony default export */ const utils_request = (request); ;// CONCATENATED MODULE: ./app/updates/notifications.js function notifications_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function notifications_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function notifications_createClass(Constructor, protoProps, staticProps) { if (protoProps) notifications_defineProperties(Constructor.prototype, protoProps); if (staticProps) notifications_defineProperties(Constructor, staticProps); return Constructor; } var canFetchNotifications = function canFetchNotifications() { return external_GravAdmin_namespaceObject.config.notifications.enabled; }; var notificationsFilters = function notificationsFilters() { return external_GravAdmin_namespaceObject.config.notifications.filters; }; var Notifications = /*#__PURE__*/function () { function Notifications() { notifications_classCallCheck(this, Notifications); } notifications_createClass(Notifications, [{ key: "fetch", value: // Grav.default.Notifications.fetch() function fetch() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref$filter = _ref.filter, filter = _ref$filter === void 0 ? notificationsFilters() : _ref$filter, _ref$refresh = _ref.refresh, refresh = _ref$refresh === void 0 ? false : _ref$refresh; if (!canFetchNotifications()) { return false; } var feed = external_jQuery_default()('#notifications'); var loader = feed.find('.widget-loader'); var content = feed.find('.widget-content > ul'); loader.find('div').remove(); loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin'); loader.show(); content.hide(); var processNotifications = function processNotifications(response) { var notifications = response.notifications; external_jQuery_default()('#notifications').find('.widget-content > ul').empty(); if (notifications) { Object.keys(notifications).forEach(function (location) { return Notifications.processLocation(location, notifications[location]); }); } }; utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNotifications"), { method: 'post', body: { refresh: refresh, filter: filter } }, function (response) { processNotifications(response); })["catch"](function () { var widget = external_jQuery_default()('#notifications .widget-content'); widget.find('.widget-loader').find('div').remove(); widget.find('.widget-loader').append('
Failed to retrieve notifications
').find('.fa-spin').removeClass('fa-spin fa-refresh').addClass('fa-warning'); }); } }], [{ key: "addShowAllInFeed", value: function addShowAllInFeed() { external_jQuery_default()('#notifications ul').append('
  • Show all
  • '); } }, { key: "showNotificationInFeed", value: function showNotificationInFeed(notification) { var notifications = external_jQuery_default()('#notifications').removeClass('hidden'); var loader = notifications.find('.widget-loader').hide(); var content = notifications.find('.widget-content > ul').show(); loader.find('div').remove(); loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin'); content.append(notification).find('li:nth-child(n+11)').addClass('hidden'); // hide all items > 10 if (content.find('li.hidden').length) { Notifications.addShowAllInFeed(); } } }, { key: "showNotificationInTop", value: function showNotificationInTop(notification) { var container = external_jQuery_default()('.top-notifications-container'); var dummy = external_jQuery_default()('
    ').html(notification); container.removeClass('hidden').append(dummy.children()); dummy.children().slideDown(150); } }, { key: "showNotificationInDashboard", value: function showNotificationInDashboard(notification) { var container = external_jQuery_default()('.dashboard-notifications-container'); var dummy = external_jQuery_default()('
    ').html(notification); container.removeClass('hidden').append(dummy.children()); dummy.children().slideDown(150); } }, { key: "showNotificationInPlugins", value: function showNotificationInPlugins(notification) { var container = external_jQuery_default()('.plugins-notifications-container'); var dummy = external_jQuery_default()('
    ').html(notification); container.removeClass('hidden').append(dummy.children()); dummy.children().slideDown(150); } }, { key: "showNotificationInThemes", value: function showNotificationInThemes(notification) { var container = external_jQuery_default()('.themes-notifications-container'); var dummy = external_jQuery_default()('
    ').html(notification); container.removeClass('hidden').append(dummy.children()); dummy.children().slideDown(150); } }, { key: "processLocation", value: function processLocation(location, notification) { switch (location) { case 'feed': Notifications.showNotificationInFeed(notification); break; case 'top': if (!notification.read) { Notifications.showNotificationInTop(notification); } break; case 'dashboard': if (!notification.read) { Notifications.showNotificationInDashboard(notification); } break; case 'plugins': if (!notification.read) { Notifications.showNotificationInPlugins(notification); } break; case 'themes': if (!notification.read) { Notifications.showNotificationInThemes(notification); } break; } } }]); return Notifications; }(); var notifications = new Notifications(); /* harmony default export */ const updates_notifications = (notifications); if (canFetchNotifications()) { notifications.fetch(); /* Hide a notification and store it hidden */ // external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) { var notification_id = external_jQuery_default()(event.target).parents('.hide-notification').data('notification-id'); var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/notifications.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "hideNotification/notification_id").concat(external_GravAdmin_namespaceObject.config.param_sep).concat(notification_id); utils_request(url, { method: 'post' }, function () {}); external_jQuery_default()(event.target).parents('.single-notification').hide(); }); external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) { var target = external_jQuery_default()(event.currentTarget); var notification = target.parent(); notification.slideUp(function () { return notification.remove(); }); }); external_jQuery_default()(document).on('click', '[data-notification-action="show-all-notifications"]', function (event) { external_jQuery_default()('#notifications .show-all').hide(); external_jQuery_default()('#notifications .hidden').removeClass('hidden'); }); external_jQuery_default()(document).on('click', '[data-refresh="notifications"]', function (event) { event.preventDefault(); notifications.fetch({ filter: ['feed'], refresh: true }); }); } ;// CONCATENATED MODULE: ./app/updates/feed.js function feed_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function feed_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function feed_createClass(Constructor, protoProps, staticProps) { if (protoProps) feed_defineProperties(Constructor.prototype, protoProps); if (staticProps) feed_defineProperties(Constructor, staticProps); return Constructor; } var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNewsFeed"); var Feed = /*#__PURE__*/function () { function Feed() { feed_classCallCheck(this, Feed); this.data = null; } feed_createClass(Feed, [{ key: "fetch", value: function fetch() { var _this = this; var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; utils_request(URI, { method: 'post', body: { refresh: refresh } }, function (response) { _this.data = response; callback(response); }); } }, { key: "refresh", value: function refresh() { var _refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var feed = external_jQuery_default()('#news-feed .widget-content'); if (!feed.length) { return; } var loader = feed.find('.widget-loader'); loader.find('div').remove(); loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin'); loader.show(); feed.find('> ul').hide(); if (!this.data || this.data.error || _refresh) { this.fetch(_refresh, this.updateContent.bind(this)); } else { this.updateContent(); } } }, { key: "updateContent", value: function updateContent() { var feed = external_jQuery_default()('#news-feed .widget-content'); if (!feed.length) { return; } var loader = feed.find('.widget-loader').hide(); var content = feed.find('> ul').empty().show(); if (this.data.error || this.data.status === 'error') { loader.show().find('div').remove(); loader.find('.fa-refresh').removeClass('fa-refresh fa-spin').addClass('fa-warning'); loader.append("
    ".concat(this.data.error ? this.data.error.message : this.data.message || 'Unable to download news feed', "
    ")); return; } if (this.data && this.data.feed_data) { content.append(this.data.feed_data); } } }]); return Feed; }(); var feed = new Feed(); external_jQuery_default()(document).ready(function () { return feed.refresh(); }); external_jQuery_default()(document).on('click', '[data-refresh="feed"]', function (event) { event.preventDefault(); feed.refresh(true); }); /* harmony default export */ const updates_feed = (feed); ;// CONCATENATED MODULE: ./app/updates/check.js // Check for updates trigger external_jQuery_default()('[data-gpm-checkupdates]').on('click', function () { var element = external_jQuery_default()(this); element.find('i').addClass('fa-spin'); Instance.fetch(function (response) { element.find('i').removeClass('fa-spin'); var payload = response.payload; if (!payload) { return; } if (!payload.grav.isUpdatable && !payload.resources.total) { utils_toastr.success(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EVERYTHING_UP_TO_DATE); } else { var grav = payload.grav.isUpdatable ? 'Grav v' + payload.grav.available : ''; var resources = payload.resources.total ? payload.resources.total + ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATES_ARE_AVAILABLE : ''; if (!resources) { grav += ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_AVAILABLE_FOR_UPDATE; } utils_toastr.info(grav + (grav && resources ? ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.AND + ' ' : '') + resources); } }, true); }); ;// CONCATENATED MODULE: ./app/utils/formatbytes.js var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; function formatBytes(bytes, decimals) { if (bytes === 0) return '0 Byte'; var k = 1000; var value = Math.floor(Math.log(bytes) / Math.log(k)); var decimal = decimals + 1 || 3; return (bytes / Math.pow(k, value)).toPrecision(decimal) + ' ' + sizes[value]; } ;// CONCATENATED MODULE: ./app/updates/update.js // Dashboard update and Grav update external_jQuery_default()(document).on('click.remodal', '[data-remodal-id="update-grav"] [data-remodal-action="confirm"]', function () { var element = external_jQuery_default()('#grav-update-button'); element.html("".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATING_PLEASE_WAIT, " ").concat(formatBytes(updates_Instance.payload.grav.assets["grav-update"].size), "..")); element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-cloud-download').addClass('fa-refresh fa-spin'); utils_request(updates_Instance.updateURL, function (response) { if (response.type === 'updategrav') { external_jQuery_default()('[data-gpm-grav]').remove(); external_jQuery_default()('#footer .grav-version').html(response.version); } element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin').addClass('fa-cloud-download'); }); }); ;// CONCATENATED MODULE: ./app/updates/channel-switcher.js var switcher = external_jQuery_default()('input[type="radio"][name="channel-switch"]'); if (switcher) { switcher.on('change', function (event) { var radio = external_jQuery_default()(event.target); var url = "".concat(radio.parent('[data-url]').data('url')); utils_request(url, { method: 'post', body: { task: 'gpmRelease', release: radio.val() } }, function (response) { if (response.reload) { __webpack_require__.g.location.reload(); } }); }); } ;// CONCATENATED MODULE: ./app/updates/index.js function updates_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function updates_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function updates_createClass(Constructor, protoProps, staticProps) { if (protoProps) updates_defineProperties(Constructor.prototype, protoProps); if (staticProps) updates_defineProperties(Constructor, staticProps); return Constructor; } var Updates = /*#__PURE__*/function () { function Updates() { var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; updates_classCallCheck(this, Updates); this.setPayload(payload); this.task = "task".concat(external_GravAdmin_namespaceObject.config.param_sep); this.updateURL = ''; } updates_createClass(Updates, [{ key: "setPayload", value: function setPayload() { var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.payload = payload; return this; } }, { key: "fetch", value: function fetch() { var _this = this; var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; Instance.fetch(function (response) { return _this.setPayload(response); }, force); return this; } }, { key: "maintenance", value: function maintenance() { var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'hide'; var element = external_jQuery_default()('#updates [data-update-packages]'); element[mode === 'show' ? 'fadeIn' : 'fadeOut'](); if (mode === 'hide') { external_jQuery_default()('.badges.with-updates').removeClass('with-updates').find('.badge.updates').remove(); } return this; } }, { key: "grav", value: function grav() { var payload = this.payload.grav; if (payload && payload.isUpdatable) { var task = this.task; var bar = ''; if (!payload.isSymlink) { this.updateURL = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/update.json/").concat(task, "updategrav/admin-nonce").concat(external_GravAdmin_namespaceObject.config.param_sep).concat(external_GravAdmin_namespaceObject.config.admin_nonce); bar += ""); } else { bar += ""); } bar += "\n Grav v".concat(payload.available, " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_NOW_AVAILABLE, "! (").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.CURRENT, " v").concat(payload.version, ")\n "); var element = external_jQuery_default()('[data-gpm-grav]').removeClass('hidden'); if (element.is(':empty')) { element.hide(); } element.addClass('grav').html("".concat(bar)).slideDown(150, function () { var c = 5; var x = setInterval(function () { c -= 1; element.find('.pointer-events-none .cnt-down').text('(' + c + 's)'); }, 1000); setTimeout(function () { clearInterval(x); element.find('.pointer-events-none .cnt-down').remove(); element.find('.pointer-events-none').removeClass('pointer-events-none'); }, 5000); }).parent('#messages').addClass('default-box-shadow'); } return this; } }, { key: "resources", value: function resources() { if (!this.payload || !this.payload.resources || !this.payload.resources.total) { return this.maintenance('hide'); } var is_current_package_latest = true; var map = ['plugins', 'themes']; var singles = ['plugin', 'theme']; var _this$payload$resourc = this.payload.resources, plugins = _this$payload$resourc.plugins, themes = _this$payload$resourc.themes; if (!this.payload.resources.total) { return this; } [plugins, themes].forEach(function (resources, index) { if (!resources || Array.isArray(resources)) { return; } var length = Object.keys(resources).length; var type = map[index]; // sidebar external_jQuery_default()("#admin-menu a[href$=\"/".concat(map[index], "\"]")).find('.badges').addClass('with-updates').find('.badge.updates').text(length); var type_translation = ''; // update all if (type === 'plugins') { type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PLUGINS; } else { type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.THEMES; } var updateAll = external_jQuery_default()(".grav-update.".concat(type)); updateAll.css('display', 'block').html("\n

    \n ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE, " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ALL, " ").concat(type_translation, "\n \n ").concat(length, " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.OF_YOUR, " ").concat(type_translation.toLowerCase(), " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.HAVE_AN_UPDATE_AVAILABLE, "\n

    \n ")); var existing_slugs = external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs') || ''; if (existing_slugs) { existing_slugs = existing_slugs.split(','); } else { existing_slugs = []; } var slugs = unique_default()(existing_slugs.concat(Object.keys(resources))).join(); external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs', "".concat(slugs)); Object.keys(resources).forEach(function (item) { // listing page var container = external_jQuery_default()("[data-gpm-".concat(singles[index], "=\"").concat(item, "\"]")); var element = container.find('.gpm-name'); var url = element.find('a'); var content_wrapper = container.parents('.content-wrapper'); if (type === 'plugins' && !element.find('.badge.update').length) { element.append("").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE_AVAILABLE, "!")); content_wrapper.addClass('has-updates'); } else if (type === 'themes') { element.append("")); content_wrapper.addClass('has-updates'); } // details page if (container.length) { var details = external_jQuery_default()(".grav-update.".concat(singles[index])); if (details.length) { var releaseType = resources[item].type === 'testing' ? 'test release' : ''; details.html("\n

    \n ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE, " ").concat(singles[index].charAt(0).toUpperCase() + singles[index].substr(1).toLowerCase(), "\n \n v").concat(resources[item].available, " ").concat(releaseType, " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.OF_THIS, " ").concat(singles[index], " ").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_NOW_AVAILABLE, "!\n

    \n ")).css('display', 'block'); is_current_package_latest = false; } } }); external_jQuery_default()('[data-update-packages]').removeClass('hidden'); }); external_jQuery_default()('.content-wrapper').addClass('updates-checked'); if (!is_current_package_latest) { external_jQuery_default()('.warning-reinstall-not-latest-release').removeClass('hidden'); } } }]); return Updates; }(); var updates_Instance = new Updates(); // automatically refresh UI for updates (graph, sidebar, plugin/themes pages) after every fetch Instance.on('fetched', function (response, raw) { updates_Instance.setPayload(response.payload || {}); updates_Instance.grav().resources(); }); if (external_GravAdmin_namespaceObject.config.enable_auto_updates_check === '1') { Instance.fetch(); } // EXTERNAL MODULE: ./node_modules/chartist/dist/chartist.js var chartist = __webpack_require__(69259); var chartist_default = /*#__PURE__*/__webpack_require__.n(chartist); ;// CONCATENATED MODULE: ./app/dashboard/chart.js function chart_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { chart_typeof = function _typeof(obj) { return typeof obj; }; } else { chart_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return chart_typeof(obj); } function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = chart_getPrototypeOf(object); if (object === null) break; } return object; } function chart_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) chart_setPrototypeOf(subClass, superClass); } function chart_setPrototypeOf(o, p) { chart_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return chart_setPrototypeOf(o, p); } function chart_createSuper(Derived) { var hasNativeReflectConstruct = chart_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = chart_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = chart_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return chart_possibleConstructorReturn(this, result); }; } function chart_possibleConstructorReturn(self, call) { if (call && (chart_typeof(call) === "object" || typeof call === "function")) { return call; } return chart_assertThisInitialized(self); } function chart_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function chart_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function chart_getPrototypeOf(o) { chart_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return chart_getPrototypeOf(o); } function chart_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function chart_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function chart_createClass(Constructor, protoProps, staticProps) { if (protoProps) chart_defineProperties(Constructor.prototype, protoProps); if (staticProps) chart_defineProperties(Constructor, staticProps); return Constructor; } // let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; var defaults = { data: { series: [100, 0] }, options: { Pie: { donut: true, donutWidth: 10, startAngle: 0, total: 100, showLabel: false, height: 150, // chartPadding: !isFirefox ? 10 : 25 // workaround for older versions of firefox chartPadding: 5 }, Bar: { height: 164, chartPadding: 20, // workaround for older versions of firefox axisX: { showGrid: false, labelOffset: { x: 0, y: 0 } }, axisY: { offset: 15, showLabel: true, showGrid: true, labelOffset: { x: 5, y: 5 }, scaleMinSpace: 25 } } } }; var Chart = /*#__PURE__*/function () { function Chart(element) { var _this = this; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; chart_classCallCheck(this, Chart); this.element = external_jQuery_default()(element) || []; if (!this.element[0]) { return; } var type = (this.element.data('chart-type') || 'pie').toLowerCase(); this.type = type.charAt(0).toUpperCase() + type.substr(1).toLowerCase(); options = Object.assign({}, defaults.options[this.type], options); data = Object.assign({}, defaults.data, data); Object.assign(this, { options: options, data: data }); this.chart = (chartist_default())[this.type](this.element.find('.ct-chart').empty()[0], this.data, this.options); this.chart.on('created', function () { _this.element.find('.hidden').removeClass('hidden'); // FIX: workaround for chartist issue not allowing HTML in labels anymore // https://github.com/gionkunz/chartist-js/issues/937 _this.element.find('.ct-label').each(function (index, label) { label = external_jQuery_default()(label); var text = label.html().replace('<', '<').replace('>', '>'); label.html(text); }); }); } chart_createClass(Chart, [{ key: "updateData", value: function updateData(data) { Object.assign(this.data, data); this.chart.update(this.data); } }]); return Chart; }(); ; var UpdatesChart = /*#__PURE__*/function (_Chart) { chart_inherits(UpdatesChart, _Chart); var _super = chart_createSuper(UpdatesChart); function UpdatesChart(element) { var _this2; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; chart_classCallCheck(this, UpdatesChart); _this2 = _super.call(this, element, options, data); _this2.chart.on('draw', function (data) { return _this2.draw(data); }); Instance.on('fetched', function (response) { if (!response.payload) { return; } var payload = response.payload.grav; var missing = (response.payload.resources.total + (payload.isUpdatable ? 1 : 0)) * 100 / (response.payload.installed + (payload.isUpdatable ? 1 : 0)); var updated = 100 - missing; _this2.updateData({ series: [updated, missing] }); if (response.payload.resources.total) { updates_Instance.maintenance('show'); } }); return _this2; } chart_createClass(UpdatesChart, [{ key: "draw", value: function draw(data) { if (data.index) { return; } var notice = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN[data.value === 100 ? 'FULLY_UPDATED' : 'UPDATES_AVAILABLE']; this.element.find('.numeric span').text("".concat(Math.round(data.value), "%")); this.element.find('.js__updates-available-description').html(notice); this.element.find('.hidden').removeClass('hidden'); } }, { key: "updateData", value: function updateData(data) { _get(chart_getPrototypeOf(UpdatesChart.prototype), "updateData", this).call(this, data); // missing updates if (this.data.series[0] < 100) { this.element.closest('#updates').find('[data-update-packages]').fadeIn(); } } }]); return UpdatesChart; }(Chart); var charts = {}; external_jQuery_default()('[data-chart-name]').each(function () { var element = external_jQuery_default()(this); var name = element.data('chart-name') || ''; var options = element.data('chart-options') || {}; var data = element.data('chart-data') || {}; if (name === 'updates') { charts[name] = new UpdatesChart(element, options, data); } else { charts[name] = new Chart(element, options, data); } }); var Instances = charts; ;// CONCATENATED MODULE: ./app/dashboard/cache.js function cache_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function cache_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function cache_createClass(Constructor, protoProps, staticProps) { if (protoProps) cache_defineProperties(Constructor.prototype, protoProps); if (staticProps) cache_defineProperties(Constructor, staticProps); return Constructor; } var getUrl = function getUrl() { var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; if (type) { type = "cleartype:".concat(type, "/"); } return "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/cache.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "clearCache/").concat(type, "admin-nonce").concat(external_GravAdmin_namespaceObject.config.param_sep).concat(external_GravAdmin_namespaceObject.config.admin_nonce); }; var Cache = /*#__PURE__*/function () { function Cache() { var _this = this; cache_classCallCheck(this, Cache); this.element = external_jQuery_default()('[data-clear-cache]'); external_jQuery_default()('body').on('click', '[data-clear-cache]', function (event) { return _this.clear(event, event.target); }); } cache_createClass(Cache, [{ key: "clear", value: function clear(event, element) { var _this2 = this; var type = ''; if (event && event.preventDefault) { event.preventDefault(); } if (typeof event === 'string') { type = event; } element = element ? external_jQuery_default()(element) : external_jQuery_default()("[data-clear-cache-type=\"".concat(type, "\"]")); type = type || external_jQuery_default()(element).data('clear-cache-type') || ''; var url = element.data('clearCache') || getUrl(type); this.disable(); utils_request(url, function () { return _this2.enable(); }); } }, { key: "enable", value: function enable() { this.element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin fa-retweet').addClass('fa-retweet'); } }, { key: "disable", value: function disable() { this.element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-retweet').addClass('fa-refresh fa-spin'); } }]); return Cache; }(); var cache_Instance = new Cache(); ;// CONCATENATED MODULE: ./app/dashboard/backup.js external_jQuery_default()('[data-backup][data-ajax*="backup/"]').on('click', function () { var element = external_jQuery_default()(this); var url = element.data('ajax'); var inDropdown = element.closest('.dropdown-menu'); (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').attr('disabled', 'disabled').find('> .fa').removeClass('fa-life-ring').addClass('fa-spin fa-refresh'); utils_request(url, function () /* response */ { if (Instances && Instances.backups) { Instances.backups.updateData({ series: [0, 100] }); Instances.backups.element.find('.numeric').html("0 ".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DAYS.toLowerCase(), "")); } (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').removeAttr('disabled').find('> .fa').removeClass('fa-spin fa-refresh').addClass('fa-life-ring'); }); }); external_jQuery_default()('[data-backup][data-ajax*="backupDelete"]').on('click', function () { var element = external_jQuery_default()(this); var url = element.data('ajax'); var tr = element.closest('tr'); tr.addClass('deleting'); utils_request(url, function (response) { if (response.status === 'success') { tr.remove(); } else { tr.removeClass('deleting'); } }); }); ;// CONCATENATED MODULE: ./app/dashboard/index.js /* harmony default export */ const dashboard = ({ Chart: { Chart: Chart, UpdatesChart: UpdatesChart, Instances: Instances }, Cache: cache_Instance }); // EXTERNAL MODULE: ./node_modules/sortablejs/modular/sortable.esm.js var sortable_esm = __webpack_require__(51474); // EXTERNAL MODULE: ./node_modules/debounce/index.js var debounce = __webpack_require__(20296); var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce); // EXTERNAL MODULE: ./app/utils/storage.js var storage = __webpack_require__(92511); ;// CONCATENATED MODULE: ./app/pages/tree.js function tree_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function tree_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function tree_createClass(Constructor, protoProps, staticProps) { if (protoProps) tree_defineProperties(Constructor.prototype, protoProps); if (staticProps) tree_defineProperties(Constructor, staticProps); return Constructor; } var sessionKey = 'grav:admin:pages'; if (!sessionStorage.getItem(sessionKey)) { sessionStorage.setItem(sessionKey, '{}'); } var PagesTree = /*#__PURE__*/function () { function PagesTree(query) { var _this = this; var elements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; tree_classCallCheck(this, PagesTree); this.query = query; this.elements = external_jQuery_default()(elements !== undefined ? elements : this.query); this.session = JSON.parse(sessionStorage.getItem(sessionKey) || '{}'); if (!this.elements.length) { return; } this.restore(); this.elements.find('.page-icon').on('click', function (event) { return _this.toggle(event.target); }); this.elements.data('tree_init', 1); external_jQuery_default()('[data-page-toggleall]').on('click', function (event) { var element = external_jQuery_default()(event.target).closest('[data-page-toggleall]'); var action = element.data('page-toggleall'); _this[action](); }); } tree_createClass(PagesTree, [{ key: "reload", value: function reload() { var elements = external_jQuery_default()(this.query).filter(function (index, element) { return !external_jQuery_default()(element).data('tree_init'); }); if (!elements.length) { return; } this.constructor(this.query, elements); } }, { key: "toggle", value: function toggle(elements) { var _this2 = this; var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (typeof elements === 'string') { elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]'); } elements = external_jQuery_default()(elements || this.elements); elements.each(function (index, element) { element = external_jQuery_default()(element); var state = _this2.getState(element.closest('[data-toggle="children"]')); _this2[state.isOpen ? 'collapse' : 'expand'](state.id, dontStore); }); } }, { key: "collapse", value: function collapse(elements) { var _this3 = this; var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (typeof elements === 'string') { elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]'); } elements = external_jQuery_default()(elements || this.elements); elements.each(function (index, element) { element = external_jQuery_default()(element); var state = _this3.getState(element); if (state.isOpen) { state.children.hide(); state.icon.removeClass('children-open').addClass('children-closed'); if (!dontStore) { delete _this3.session[state.id]; } } }); if (!dontStore) { this.save(); } } }, { key: "expand", value: function expand(elements) { var _this4 = this; var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (typeof elements === 'string') { var element = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")); var parents = element.parents('[data-nav-id]'); // loop back through parents, we don't want to expand an hidden child if (parents.length) { parents = parents.find('[data-toggle="children"]:first'); parents = parents.add(element.find('[data-toggle="children"]:first')); return this.expand(parents, dontStore); } elements = element.find('[data-toggle="children"]:first'); } elements = external_jQuery_default()(elements || this.elements); elements.each(function (index, element) { element = external_jQuery_default()(element); var state = _this4.getState(element); if (!state.isOpen) { state.children.show(); state.icon.removeClass('children-closed').addClass('children-open'); if (!dontStore) { _this4.session[state.id] = 1; } } }); if (!dontStore) { this.save(); } } }, { key: "restore", value: function restore() { var _this5 = this; this.collapse(null, true); Object.keys(this.session).forEach(function (key) { _this5.expand(key, 'no-store'); }); } }, { key: "save", value: function save() { return sessionStorage.setItem(sessionKey, JSON.stringify(this.session)); } }, { key: "getState", value: function getState(element) { element = external_jQuery_default()(element); return { id: element.closest('[data-nav-id]').data('nav-id'), children: element.closest('li.page-item').find('ul:first'), icon: element.find('.page-icon'), get isOpen() { return this.icon.hasClass('children-open'); } }; } }]); return PagesTree; }(); var tree_Instance = new PagesTree('[data-toggle="children"]'); // EXTERNAL MODULE: ./node_modules/selectize/dist/js/selectize.js var selectize = __webpack_require__(25703); var selectize_default = /*#__PURE__*/__webpack_require__.n(selectize); ;// CONCATENATED MODULE: ./app/utils/selectize-required-fix.js /** * This is a plugin to override the `.refreshValidityState` method of * the Selectize library (https://selectize.github.io/selectize.js/). * The library is not maintained anymore (as of 2017-09-13) and contains * a bug which causes Microsoft Edge to not work with selectized [required] * form fields. This plugin should be removed if * https://github.com/selectize/selectize.js/pull/1320 is ever merged * and a new version of Selectize gets released. */ selectize_default().define('required-fix', function (options) { var _this = this; this.refreshValidityState = function () { if (!_this.isRequired) return false; var invalid = !_this.items.length; _this.isInvalid = invalid; if (invalid) { _this.$control_input.attr('required', ''); _this.$input.removeAttr('required'); } else { _this.$control_input.removeAttr('required'); _this.$input.attr('required'); } }; }); ;// CONCATENATED MODULE: ./app/pages/filter.js function filter_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { filter_typeof = function _typeof(obj) { return typeof obj; }; } else { filter_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return filter_typeof(obj); } function filter_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function filter_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function filter_createClass(Constructor, protoProps, staticProps) { if (protoProps) filter_defineProperties(Constructor.prototype, protoProps); if (staticProps) filter_defineProperties(Constructor, staticProps); return Constructor; } /* @formatter:off */ /* eslint-disable */ var options = [{ flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.MODULE, key: 'Module', cat: 'mode' }, { flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VISIBLE, key: 'Visible', cat: 'mode' }, { flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ROUTABLE, key: 'Routable', cat: 'mode' }, { flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PUBLISHED, key: 'Published', cat: 'mode' }, { flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_MODULE, key: 'NonModule', cat: 'mode' }, { flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_VISIBLE, key: 'NonVisible', cat: 'mode' }, { flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_ROUTABLE, key: 'NonRoutable', cat: 'mode' }, { flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_PUBLISHED, key: 'NonPublished', cat: 'mode' }]; /* @formatter:on */ /* eslint-enable */ var PagesFilter = /*#__PURE__*/function () { function PagesFilter(filters, search) { var _this = this; filter_classCallCheck(this, PagesFilter); this.filters = external_jQuery_default()(filters); this.search = external_jQuery_default()(search); this.options = options; this.tree = tree_Instance; var storage = JSON.parse(localStorage.getItem('grav:admin:pages:filter') || '{}'); if (!this.filters.length || !this.search.length) { return; } this.labels = this.filters.data('filter-labels'); this.search.on('input', debounce_default()(function () { return _this.filter(); }, 250)); this.filters.on('change', function () { return _this.filter(); }); // restore state if (storage.flags || storage.query) { this.setValues(storage); this.filter(); } this._initSelectize(); } filter_createClass(PagesFilter, [{ key: "filter", value: function filter(value) { var _this2 = this; var data = { flags: '', query: '' }; if (filter_typeof(value) === 'object') { Object.assign(data, value); } if (typeof value === 'string') { data.query = value; } if (typeof value === 'undefined') { data.flags = this.filters.val(); data.query = this.search.val(); } if (!Object.keys(data).filter(function (key) { return data[key] !== ''; }).length) { this.resetValues(); return; } data.flags = data.flags.replace(/(\s{1,})?,(\s{1,})?/g, ','); this.setValues({ flags: data.flags, query: data.query }, 'silent'); utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/pages-filter.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "filterPages"), { method: 'post', body: data }, function (response) { _this2.refreshDOM(response); }); } }, { key: "refreshDOM", value: function refreshDOM(response) { var _this3 = this; var items = external_jQuery_default()('[data-nav-id]'); if (!response) { items.removeClass('search-match').show(); this.tree.restore(); return; } items.removeClass('search-match').hide(); response.results.forEach(function (page) { var match = items.filter("[data-nav-id=\"".concat(page, "\"]")).addClass('search-match').show(); match.parents('[data-nav-id]').addClass('search-match').show(); _this3.tree.expand(page, 'no-store'); }); } }, { key: "setValues", value: function setValues(_ref, silent) { var _ref$flags = _ref.flags, flags = _ref$flags === void 0 ? '' : _ref$flags, _ref$query = _ref.query, query = _ref$query === void 0 ? '' : _ref$query; var flagsArray = flags.replace(/(\s{1,})?,(\s{1,})?/g, ',').split(','); if (this.filters.val() !== flags) { var selectize = this.filters.data('selectize'); this.filters[selectize ? 'setValue' : 'val'](flagsArray, silent); } if (this.search.val() !== query) { this.search.val(query); } localStorage.setItem('grav:admin:pages:filter', JSON.stringify({ flags: flags, query: query })); } }, { key: "resetValues", value: function resetValues() { this.setValues('', 'silent'); this.refreshDOM(); } }, { key: "_initSelectize", value: function _initSelectize() { var _this4 = this; var extras = { type: this.filters.data('filter-types') || {}, access: this.filters.data('filter-access-levels') || {} }; Object.keys(extras).forEach(function (cat) { Object.keys(extras[cat]).forEach(function (key) { _this4.options.push({ cat: cat, key: key, flag: extras[cat][key] }); }); }); this.filters.selectize({ maxItems: null, valueField: 'key', labelField: 'flag', searchField: ['flag', 'key'], options: this.options, optgroups: this.labels, optgroupField: 'cat', optgroupLabelField: 'name', optgroupValueField: 'id', optgroupOrder: this.labels.map(function (item) { return item.id; }), plugins: ['optgroup_columns', 'required-fix'] }); } }]); return PagesFilter; }(); var filter_Instance = new PagesFilter('input[name="page-filter"]', 'input[name="page-search"]'); // EXTERNAL MODULE: ./node_modules/speakingurl/index.js var speakingurl = __webpack_require__(989); var speakingurl_default = /*#__PURE__*/__webpack_require__.n(speakingurl); ;// CONCATENATED MODULE: ./app/utils/jquery-utils.js var _this = undefined; // jQuery no parents filter (external_jQuery_default()).expr[":"].noparents = external_jQuery_default().expr.createPseudo(function (text) { return function (element) { return external_jQuery_default()(element).parents(text).length < 1; }; }); // Slugify // CommonJS and ES6 version of https://github.com/madflow/jquery-slugify (external_jQuery_default()).fn.slugify = function (source, options) { return _this.each(function (element) { var target = external_jQuery_default()(element); var source = external_jQuery_default()(source); target.on('keyup change', function () { target.data('locked', target.val() !== '' && target.val() !== undefined); }); source.on('keyup change', function () { if (target.data('locked') === true) { return true; } var isInput = target.is('input') || target.is('textarea'); target[isInput ? 'val' : 'text'](external_jQuery_default().slugify(source.val(), options)); }); }); }; // Static method. (external_jQuery_default()).slugify = function (sourceString, options) { options = external_jQuery_default().extend({}, (external_jQuery_default()).slugify.options, options); options.lang = options.lang || external_jQuery_default()('html').prop('lang'); if (typeof options.preSlug === 'function') { sourceString = options.preSlug(sourceString); } sourceString = options.slugFunc(sourceString, options); if (typeof options.postSlug === 'function') { sourceString = options.postSlug(sourceString); } return sourceString; }; // Default plugin options (external_jQuery_default()).slugify.options = { preSlug: null, postSlug: null, slugFunc: function slugFunc(input, opts) { return speakingurl_default()(input, opts); } }; ;// CONCATENATED MODULE: ./app/pages/page/add.js var custom = false; var folder = external_jQuery_default()('[data-remodal-id="modal"] input[name="data[folder]"], [data-remodal-id="module"] input[name="data[folder]"], [data-remodal-id="modal-page-copy"] input[name="data[folder]"]'); var title = external_jQuery_default()('[data-remodal-id="modal"] input[name="data[title]"], [data-remodal-id="module"] input[name="data[title]"], [data-remodal-id="modal-page-copy"] input[name="data[title]"]'); var getFields = function getFields(type, target) { target = external_jQuery_default()(target); var query = "[data-remodal-id=\"".concat(target.closest('[data-remodal-id]').data('remodal-id'), "\"]"); return { title: type === 'title' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[title]\"]")), folder: type === 'folder' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[folder]\"]")) }; }; title.on('input focus blur', function (event) { if (custom) { return true; } var elements = getFields('title', event.currentTarget); var slug = external_jQuery_default().slugify(elements.title.val(), { custom: { "'": '', '‘': '', '’': '' } }); elements.folder.val(slug); }); folder.on('input', function (event) { var elements = getFields('folder', event.currentTarget); var input = elements.folder.get(0); var value = elements.folder.val(); var selection = { start: input.selectionStart, end: input.selectionEnd }; value = value.toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, ''); elements.folder.val(value); custom = !!value; // restore cursor position input.setSelectionRange(selection.start, selection.end); }); folder.on('focus blur', function (event) { return getFields('title', event.currentTarget).title.trigger('input'); }); external_jQuery_default()(document).on('change', '[name="data[route]"]', function (event) { var rawroute = external_jQuery_default()(event.currentTarget).val(); var pageTemplate = external_jQuery_default()('[name="data[name]"]'); var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getChildTypes"); if (pageTemplate.length === 0) { return; } utils_request(URI, { method: 'post', body: { rawroute: rawroute } }, function (response) { var type = response.child_type; if (type !== '' && type !== 'default') { pageTemplate.val(type); pageTemplate.data('selectize').setValue(type); } }); }); ;// CONCATENATED MODULE: ./app/pages/page/move.js external_jQuery_default()(document).on('click', '[data-page-move] button[name="task"][value="save"]', function (event) { /* let route = $('form#blueprints:first select[name="data[route]"]'); let moveTo = $('[data-page-move] select').val(); if (route.length && route.val() !== moveTo) { let selectize = route.data('selectize'); route.val(moveTo); if (selectize) selectize.setValue(moveTo); }*/ var modal = external_jQuery_default()(event.currentTarget).closest('[data-remodal-id]'); var parents = modal.data('parents') || {}; var finder = parents.finder; if (!parents || !finder) { return true; } var field = parents.field; var parentLabel = parents.parentLabel; var parentName = parents.parentName; var selection = finder.findLastActive().item[0]; var value = selection._item[finder.config.valueKey]; var name = selection._item[finder.config.labelKey]; field.val(value); parentLabel.text(value); parentName.text(name); finder.config.defaultPath = value; external_jQuery_default()('
    ').css({ backgroundColor: 'rgba(255, 255, 255, 0.1)', position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh', zIndex: 15000 }).appendTo(external_jQuery_default()('body')); }); /* $(document).on('click', '[data-remodal-id="parents"] [data-parents-select]', (event) => { const modal = $(event.currentTarget).closest('[data-remodal-id]'); const parents = modal.data('parents'); const finder = parents.finder; const field = parents.field; const parentLabel = parents.parentLabel; const parentName = parents.parentName; const selection = finder.findLastActive().item[0]; const value = selection._item[finder.config.valueKey]; const name = selection._item[finder.config.labelKey]; field.val(value); parentLabel.text(value); parentName.text(name); finder.config.defaultPath = value; const remodal = $.remodal.lookup[$(`[data-remodal-id="${modal.data('remodalId')}"]`).data('remodal')]; remodal.close(); }); */ ;// CONCATENATED MODULE: ./app/pages/page/delete.js external_jQuery_default()(document).on('click', '[data-remodal-target="delete"]', function () { var confirm = external_jQuery_default()('[data-remodal-id="delete"] [data-delete-action]'); var link = external_jQuery_default()(this).data('delete-url'); confirm.data('delete-action', link); }); external_jQuery_default()(document).on('click', '[data-delete-action]', function () { var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id="delete"]').data('remodal')]; __webpack_require__.g.location.href = external_jQuery_default()(this).data('delete-action'); remodal.close(); }); ;// CONCATENATED MODULE: ./app/pages/page/unset.js external_jQuery_default()(document).on('click', '.dz-unset', function () { var file_upload = external_jQuery_default()(this).closest('.files-upload'); external_jQuery_default()(this).closest('.dz-image-preview').remove(); var unset_image = external_jQuery_default()(this).closest('.dz-image-preview').find('[data-dz-name]').text().trim(); var images = JSON.parse(file_upload.find('input[data-grav-field="hidden"]').val()) || {}; var image_array = {}; external_jQuery_default().each(images, function (ind, obj) { if (!ind.endsWith(unset_image)) { image_array[ind] = obj; } }); file_upload.find('input[data-grav-field="hidden"]').val(JSON.stringify(image_array)); }); ;// CONCATENATED MODULE: ./app/pages/page/disable-buttons.js external_jQuery_default()('.disable-after-click').on('click', function () { external_jQuery_default()(this).addClass('pointer-events-disabled'); }); // EXTERNAL MODULE: ./node_modules/dropzone/dist/dropzone.js var dist_dropzone = __webpack_require__(32025); var dropzone_default = /*#__PURE__*/__webpack_require__.n(dist_dropzone); ;// CONCATENATED MODULE: ./app/forms/fields/files.js function files_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function files_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function files_createClass(Constructor, protoProps, staticProps) { if (protoProps) files_defineProperties(Constructor.prototype, protoProps); if (staticProps) files_defineProperties(Constructor, staticProps); return Constructor; } // import EXIF from 'exif-js'; // translations var Dictionary = { dictCancelUpload: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD, dictCancelUploadConfirmation: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD_CONFIRMATION, dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_DEFAULT_MESSAGE, dictFallbackMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_MESSAGE, dictFallbackText: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_TEXT, dictFileTooBig: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FILE_TOO_BIG, dictInvalidFileType: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_INVALID_FILE_TYPE, dictMaxFilesExceeded: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_MAX_FILES_EXCEEDED, dictRemoveFile: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_REMOVE_FILE, dictResponseError: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_RESPONSE_ERROR }; (dropzone_default()).autoDiscover = false; (dropzone_default()).options.gravPageDropzone = {}; (dropzone_default()).confirm = function (question, accepted, rejected) { var doc = external_jQuery_default()(document); var modalSelector = '[data-remodal-id="delete-media"]'; var removeEvents = function removeEvents() { doc.off('confirmation', modalSelector, accept); doc.off('cancellation', modalSelector, reject); external_jQuery_default()(modalSelector).find('.remodal-confirm').removeClass('pointer-events-disabled'); }; var accept = function accept() { accepted && accepted(); removeEvents(); }; var reject = function reject() { rejected && rejected(); removeEvents(); }; (external_jQuery_default()).remodal.lookup[external_jQuery_default()(modalSelector).data('remodal')].open(); doc.on('confirmation', modalSelector, accept); doc.on('cancellation', modalSelector, reject); }; var DropzoneMediaConfig = { timeout: 0, thumbnailWidth: 200, thumbnailHeight: 150, addRemoveLinks: false, dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROP_FILES_HERE_TO_UPLOAD.replace(/</g, '<').replace(/>/g, '>'), dictRemoveFileConfirmation: '[placeholder]', previewTemplate: "\n ").trim() }; // global.EXIF = EXIF; var ACCEPT_FUNC = function ACCEPT_FUNC(file, done, settings) { var resolution = settings.resolution; if (!resolution) return done(); var reader = new FileReader(); var error = ''; var hasMin = resolution.min && (resolution.min.width || resolution.min.height); var hasMax = resolution.max && (resolution.max.width || resolution.max.height); if (hasMin || !(settings.resizeWidth || settings.resizeHeight) && hasMax) { reader.onload = function (event) { var image = new Image(); image.src = event.target.result; image.onerror = function () { done(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD); }; image.onload = function () { var _this = this; if (resolution.min) { Object.keys(resolution.min).forEach(function (attr) { if (resolution.min[attr] && _this[attr] < resolution.min[attr]) { error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MIN.replace(/{{attr}}/g, attr).replace(/{{min}}/g, resolution.min[attr]); } }); } if (!(settings.resizeWidth || settings.resizeHeight)) { if (resolution.max) { Object.keys(resolution.max).forEach(function (attr) { if (resolution.max[attr] && _this[attr] > resolution.max[attr]) { error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MAX.replace(/{{attr}}/g, attr).replace(/{{max}}/g, resolution.max[attr]); } }); } } URL.revokeObjectURL(image.src); // release memory return error ? done(error) : done(); }; }; reader.readAsDataURL(file); } else { return error ? done(error) : done(); } }; var FilesField = /*#__PURE__*/function () { function FilesField() { var _this2 = this; var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref$container = _ref.container, container = _ref$container === void 0 ? '.dropzone.files-upload' : _ref$container, _ref$options = _ref.options, options = _ref$options === void 0 ? {} : _ref$options; files_classCallCheck(this, FilesField); this.container = external_jQuery_default()(container); if (!this.container.length) { return; } this.urls = {}; this.customPost = this.container.data('filePostAdd') || {}; this.options = Object.assign({}, Dictionary, DropzoneMediaConfig, { klass: this, url: this.container.data('file-url-add') || external_GravAdmin_namespaceObject.config.current_url, acceptedFiles: this.container.data('media-types'), init: this.initDropzone }, this.container.data('dropzone-options'), options); this.options = Object.assign({}, this.options, { accept: function accept(file, done) { ACCEPT_FUNC(file, done, this.options); } }); this.dropzone = new (dropzone_default())(container, this.options); this.dropzone.on('complete', this.onDropzoneComplete.bind(this)); this.dropzone.on('success', this.onDropzoneSuccess.bind(this)); this.dropzone.on('removedfile', this.onDropzoneRemovedFile.bind(this)); this.dropzone.on('sending', this.onDropzoneSending.bind(this)); this.dropzone.on('error', this.onDropzoneError.bind(this)); this.container.on('mouseenter', '[data-dz-view]', function (e) { var value = JSON.parse(_this2.container.find('[name][type="hidden"]').val() || '{}'); var target = external_jQuery_default()(e.currentTarget); var file = target.parent('.dz-preview').find('.dz-filename'); var filename = encodeURI(file.text()); var URL = Object.keys(value).filter(function (key) { return value[key].name === filename; }).shift(); target.attr('href', "".concat(external_GravAdmin_namespaceObject.config.base_url_simple, "/").concat(URL)); }); } files_createClass(FilesField, [{ key: "initDropzone", value: function initDropzone() { var _this3 = this; var files = this.options.klass.container.find('[data-file]'); var dropzone = this; if (!files.length) { return; } files.each(function (index, file) { file = external_jQuery_default()(file); var data = file.data('file'); var mock = { name: data.name, size: data.size, type: data.type, status: (dropzone_default()).ADDED, accepted: true, url: _this3.options.url, removeUrl: data.remove }; dropzone.files.push(mock); dropzone.options.addedfile.call(dropzone, mock); if (mock.type.match(/^image\//)) { dropzone.options.thumbnail.call(dropzone, mock, data.path); dropzone.createThumbnailFromUrl(mock, data.path); } file.remove(); }); } }, { key: "getURI", value: function getURI() { return this.container.data('mediaUri') || ''; } }, { key: "onDropzoneSending", value: function onDropzoneSending(file, xhr, formData) { var _this4 = this; if (Object.keys(this.customPost).length) { Object.keys(this.customPost).forEach(function (key) { formData.append(key, _this4.customPost[key]); }); } else { formData.append('name', this.options.dotNotation); formData.append('task', 'filesupload'); formData.append('uri', this.getURI()); } formData.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce); } }, { key: "onDropzoneSuccess", value: function onDropzoneSuccess(file, response, xhr) { response = typeof response === 'string' ? JSON.parse(response) : response; if (this.options.reloadPage) { __webpack_require__.g.location.reload(); } // store params for removing file from session before it gets saved if (response.session) { file.sessionParams = response.session; file.removeUrl = this.options.url; // Touch field value to force a mutation detection var input = this.container.find('[name][type="hidden"]'); var value = input.val(); input.val(value + ' '); } return this.handleError({ file: file, data: response, mode: 'removeFile', msg: "

    ".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD, " ").concat(file.name, "

    \n
    ").concat(response.message, "
    ") }); } }, { key: "onDropzoneComplete", value: function onDropzoneComplete(file) { if (!file.accepted && !file.rejected) { var data = { status: 'error', message: "".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_UNSUPPORTED, ": ").concat(file.name.match(/\..+/).join('')) }; return this.handleError({ file: file, data: data, mode: 'removeFile', msg: "

    ".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_ADD, " ").concat(file.name, "

    \n
    ").concat(data.message, "
    ") }); } if (this.options.reloadPage) { __webpack_require__.g.location.reload(); } } }, { key: "b64_to_utf8", value: function b64_to_utf8(str) { str = str.replace(/\s/g, ''); return decodeURIComponent(escape(window.atob(str))); } }, { key: "onDropzoneRemovedFile", value: function onDropzoneRemovedFile(file) { var _this5 = this; if (!file.accepted || file.rejected) { return; } var url = file.removeUrl || this.urls["delete"] || this.options.url; var path = (url || '').match(/path:(.*)\//); var body = { filename: file.name, uri: this.getURI() }; if (file.sessionParams) { body.task = 'filessessionremove'; body.session = file.sessionParams; } var customPost = this.container.data('filePostRemove') || {}; if (Object.keys(customPost).length) { body = {}; Object.keys(customPost).forEach(function (key) { body[key] = customPost[key]; }); } body['filename'] = file.name; body['admin-nonce'] = external_GravAdmin_namespaceObject.config.admin_nonce; utils_request(url, { method: 'post', body: body }, function () { if (!path) { return; } path = _this5.b64_to_utf8(path[1]); var input = _this5.container.find('[name][type="hidden"]'); var data = JSON.parse(input.val() || '{}'); delete data[path]; input.val(JSON.stringify(data)); }); } }, { key: "onDropzoneError", value: function onDropzoneError(file, response, xhr) { var message = xhr ? response.error.message : response; external_jQuery_default()(file.previewElement).find('[data-dz-errormessage]').html(message); return this.handleError({ file: file, data: { status: 'error' }, msg: "
    ".concat(message, "
    ") }); } }, { key: "handleError", value: function handleError(options) { var file = options.file, data = options.data, mode = options.mode, msg = options.msg; if (data.status !== 'error' && data.status !== 'unauthorized') { return; } switch (mode) { case 'addBack': if (file instanceof File) { this.dropzone.addFile.call(this.dropzone, file); } else { this.dropzone.files.push(file); this.dropzone.options.addedfile.call(this.dropzone, file); this.dropzone.options.thumbnail.call(this.dropzone, file, file.extras.url); } break; case 'removeFile': default: if (~this.dropzone.files.indexOf(file)) { file.rejected = true; this.dropzone.removeFile.call(this.dropzone, file, { silent: true }); } break; } var modal = external_jQuery_default()('[data-remodal-id="generic"]'); modal.find('.error-content').html(msg); (external_jQuery_default()).remodal.lookup[modal.data('remodal')].open(); } }]); return FilesField; }(); function UriToMarkdown(uri) { uri = uri.replace(/@3x|@2x|@1x/, ''); uri = uri.replace(/\(/g, '%28'); uri = uri.replace(/\)/g, '%29'); var title = uri.split('.').slice(0, -1).join('.'); return uri.match(/\.(jpe?g|png|gif|svg|webp|mp4|webm|ogv|mov)$/i) ? "![".concat(title, "](").concat(uri, " \"").concat(title, "\")") : "[".concat(decodeURI(uri), "](").concat(uri, ")"); } var instances = []; var cache = external_jQuery_default()(); var onAddedNodes = function onAddedNodes(event, target /* , record, instance */ ) { var files = external_jQuery_default()(target).find('.dropzone.files-upload'); if (!files.length) { return; } files.each(function (index, file) { file = external_jQuery_default()(file); if (!~cache.index(file)) { addNode(file); } }); }; var addNode = function addNode(container) { container = external_jQuery_default()(container); var input = container.find('input[type="file"]'); var settings = container.data('grav-file-settings') || {}; if (settings.accept && ~settings.accept.indexOf('*')) { settings.accept = ['']; } var options = { url: container.data('file-url-add') || (container.closest('form').attr('action') || external_GravAdmin_namespaceObject.config.current_url) + '.json', paramName: settings.paramName || 'file', dotNotation: settings.name || 'file', acceptedFiles: settings.accept ? settings.accept.join(',') : input.attr('accept') || container.data('media-types'), maxFilesize: typeof settings.filesize !== 'undefined' ? settings.filesize : 256, maxFiles: settings.limit || null, resizeWidth: settings.resizeWidth || null, resizeHeight: settings.resizeHeight || null, resizeQuality: settings.resizeQuality || null, resolution: settings.resolution || null, accept: function accept(file, done) { ACCEPT_FUNC(file, done, settings); } }; cache = cache.add(container); container = container[0]; instances.push(new FilesField({ container: container, options: options })); }; var files_Instance = function () { external_jQuery_default()('.dropzone.files-upload').each(function (i, container) { return addNode(container); }); external_jQuery_default()('body').on('mutation._grav', onAddedNodes); return instances; }(); ;// CONCATENATED MODULE: ./app/forms/fields/editor/buttons.js var replacer = function replacer(_ref) { var name = _ref.name, replace = _ref.replace, codemirror = _ref.codemirror, button = _ref.button, _ref$mode = _ref.mode, mode = _ref$mode === void 0 ? 'replaceSelections' : _ref$mode, runner = _ref.runner; button.on("click.editor.".concat(name), function () { strategies[mode]({ token: '$1', template: replace, codemirror: codemirror, runner: runner }); }); }; var strategies = { replaceSelections: function replaceSelections(_ref2) { var template = _ref2.template, token = _ref2.token, codemirror = _ref2.codemirror, runner = _ref2.runner; var replacements = []; var ranges = []; var selections = codemirror.getSelections(); var list = codemirror.listSelections(); var accumulator = {}; selections.forEach(function (selection, index) { var markup = template.replace(token, selection); var cursor = markup.indexOf('$cur'); var _list$index$anchor = list[index].anchor, line = _list$index$anchor.line, ch = _list$index$anchor.ch; markup = markup.replace('$cur', ''); markup = runner ? runner(selection, markup, list) : markup; replacements.push(markup); if (!accumulator[line]) { accumulator[line] = 0; } ch += accumulator[line] + (cursor === -1 ? markup.length : cursor); var range = { ch: ch, line: line }; ranges.push({ anchor: range, head: range }); accumulator[line] += markup.length - selection.length; }); codemirror.replaceSelections(replacements); codemirror.setSelections(ranges); codemirror.focus(); }, replaceLine: function replaceLine(_ref3) { var template = _ref3.template, token = _ref3.token, codemirror = _ref3.codemirror, runner = _ref3.runner; var list = codemirror.listSelections(); var range; list.forEach(function (selection) { var lines = { min: Math.min(selection.anchor.line, selection.head.line), max: Math.max(selection.anchor.line, selection.head.line) }; codemirror.eachLine(lines.min, lines.max + 1, function (handler) { var markup = template.replace(token, handler.text); var line = codemirror.getLineNumber(handler); markup = runner ? runner(handler, markup) : markup; codemirror.replaceRange(markup, { line: line, ch: 0 }, { line: line, ch: markup.length }); range = { line: line, ch: markup.length }; }); }); codemirror.setSelection(range, range, 'end'); codemirror.focus(); }, replaceRange: function replaceRange() {} }; var flipDisabled = function flipDisabled(codemirror, button, type) { var hasHistory = codemirror.historySize()[type]; var element = button.find('a'); button[hasHistory ? 'removeClass' : 'addClass']('button-disabled'); if (!hasHistory) { element.attr('title-disabled', element.attr('title')); element.attr('data-hint-disabled', element.attr('data-hint')); element.removeAttr('title').removeAttr('data-hint'); } else { element.attr('title', element.attr('title-disabled')); element.attr('data-hint', element.attr('data-hint-disabled')); element.removeAttr('title-disabled').removeAttr('data-hint-disabled'); } }; /* harmony default export */ const buttons = ({ navigation: [{ undo: { identifier: 'undo', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNDO, label: '', modes: [], action: function action(_ref4) { var codemirror = _ref4.codemirror, button = _ref4.button, textarea = _ref4.textarea; button.addClass('button-disabled'); codemirror.on('change', function () { return flipDisabled(codemirror, button, 'undo'); }); button.on('click.editor.undo', function () { codemirror.undo(); }); } } }, { redo: { identifier: 'redo', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.REDO, label: '', modes: [], action: function action(_ref5) { var codemirror = _ref5.codemirror, button = _ref5.button, textarea = _ref5.textarea; button.addClass('button-disabled'); codemirror.on('change', function () { return flipDisabled(codemirror, button, 'redo'); }); button.on('click.editor.redo', function () { codemirror.redo(); }); } } }, { headers: { identifier: 'headers', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.HEADERS, label: '', modes: ['gfm', 'markdown'], children: [{ h1: { identifier: 'h1', label: '1', modes: ['gfm', 'markdown'], action: function action(_ref6) { var codemirror = _ref6.codemirror, button = _ref6.button, textarea = _ref6.textarea; replacer({ name: 'h1', replace: '# $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { h2: { identifier: 'h2', label: '2', modes: ['gfm', 'markdown'], action: function action(_ref7) { var codemirror = _ref7.codemirror, button = _ref7.button, textarea = _ref7.textarea; replacer({ name: 'h2', replace: '## $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { h3: { identifier: 'h3', label: '3', modes: ['gfm', 'markdown'], action: function action(_ref8) { var codemirror = _ref8.codemirror, button = _ref8.button, textarea = _ref8.textarea; replacer({ name: 'h3', replace: '### $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { h4: { identifier: 'h4', label: '4', modes: ['gfm', 'markdown'], action: function action(_ref9) { var codemirror = _ref9.codemirror, button = _ref9.button, textarea = _ref9.textarea; replacer({ name: 'h4', replace: '#### $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { h5: { identifier: 'h5', label: '5', modes: ['gfm', 'markdown'], action: function action(_ref10) { var codemirror = _ref10.codemirror, button = _ref10.button, textarea = _ref10.textarea; replacer({ name: 'h5', replace: '##### $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { h6: { identifier: 'h6', label: '6', modes: ['gfm', 'markdown'], action: function action(_ref11) { var codemirror = _ref11.codemirror, button = _ref11.button, textarea = _ref11.textarea; replacer({ name: 'h6', replace: '###### $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }] } }, { bold: { identifier: 'bold', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BOLD, label: '', modes: ['gfm', 'markdown'], shortcut: ['Ctrl-B', 'Cmd-B'], action: function action(_ref12) { var codemirror = _ref12.codemirror, button = _ref12.button, textarea = _ref12.textarea; replacer({ name: 'bold', replace: '**$1$cur**', codemirror: codemirror, button: button }); } } }, { italic: { identifier: 'italic', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ITALIC, label: '', modes: ['gfm', 'markdown'], shortcut: ['Ctrl-I', 'Cmd-I'], action: function action(_ref13) { var codemirror = _ref13.codemirror, button = _ref13.button, textarea = _ref13.textarea; replacer({ name: 'italic', replace: '_$1$cur_', codemirror: codemirror, button: button }); } } }, { strike: { identifier: 'strike', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.STRIKETHROUGH, label: '', modes: ['gfm', 'markdown'], action: function action(_ref14) { var codemirror = _ref14.codemirror, button = _ref14.button, textarea = _ref14.textarea; replacer({ name: 'strike', replace: '~~$1$cur~~', codemirror: codemirror, button: button }); } } }, { delimiter: { identifier: 'delimiter', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.SUMMARY_DELIMITER, label: '', modes: ['gfm', 'markdown'], action: function action(_ref15) { var codemirror = _ref15.codemirror, button = _ref15.button, textarea = _ref15.textarea; replacer({ name: 'delimiter', replace: "".concat(external_GravAdmin_namespaceObject.config.site.delimiter, "$1"), codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { link: { identifier: 'link', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.LINK, label: '', modes: ['gfm', 'markdown'], shortcut: ['Ctrl-K', 'Cmd-K'], action: function action(_ref16) { var codemirror = _ref16.codemirror, button = _ref16.button, textarea = _ref16.textarea; replacer({ name: 'link', replace: '[$1]($cur)', codemirror: codemirror, button: button }); } } }, { image: { identifier: 'image', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IMAGE, label: '', modes: ['gfm', 'markdown'], action: function action(_ref17) { var codemirror = _ref17.codemirror, button = _ref17.button, textarea = _ref17.textarea; replacer({ name: 'image', replace: '![$1]($cur)', codemirror: codemirror, button: button }); } } }, { blockquote: { identifier: 'blockquote', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BLOCKQUOTE, label: '', modes: ['gfm', 'markdown'], action: function action(_ref18) { var codemirror = _ref18.codemirror, button = _ref18.button, textarea = _ref18.textarea; replacer({ name: 'blockquote', replace: '> $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { listUl: { identifier: 'listUl', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNORDERED_LIST, label: '', modes: ['gfm', 'markdown'], action: function action(_ref19) { var codemirror = _ref19.codemirror, button = _ref19.button, textarea = _ref19.textarea; replacer({ name: 'listUl', replace: '* $1', codemirror: codemirror, button: button, mode: 'replaceLine' }); } } }, { listOl: { identifier: 'listOl', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ORDERED_LIST, label: '', modes: ['gfm', 'markdown'], action: function action(_ref20) { var codemirror = _ref20.codemirror, button = _ref20.button, textarea = _ref20.textarea; replacer({ name: 'listOl', replace: '. $1', codemirror: codemirror, button: button, mode: 'replaceLine', runner: function runner(line, markup) { var lineNo = codemirror.getLineNumber(line); var previousLine = codemirror.getLine(lineNo - 1) || ''; var match = previousLine.match(/^(\d+)\./); var prefix = 1 + (match ? Number(match[1]) : 0); return "".concat(prefix).concat(markup); } }); } } }], states: [{ code: { identifier: 'editor', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EDITOR, label: '', action: function action(_ref21) { var codemirror = _ref21.codemirror, button = _ref21.button, textarea = _ref21.textarea, ui = _ref21.ui; if (textarea.data('grav-editor-mode') === 'editor') { button.addClass('editor-active'); } button.on('click.states.editor', function () { button.siblings().removeClass('editor-active'); button.addClass('editor-active'); textarea.data('grav-editor-mode', 'editor'); var previewContainer = textarea.data('grav-editor-preview-container'); var content = textarea.parent('.grav-editor-content'); content.addClass('is-active'); ui.navigation.find('.grav-editor-actions').css('visibility', 'visible'); if (previewContainer) { previewContainer.removeClass('is-active'); } }); } } }, { preview: { identifier: 'preview', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PREVIEW, label: '', modes: ['gfm', 'markdown'], action: function action(_ref22) { var codemirror = _ref22.codemirror, button = _ref22.button, textarea = _ref22.textarea, ui = _ref22.ui; if (textarea.data('grav-editor-mode') === 'preview') { button.addClass('editor-active'); } button.on('click.states.preview', function () { var previewContainer = textarea.data('grav-editor-preview-container'); var content = textarea.parent('.grav-editor-content'); button.siblings().removeClass('editor-active'); button.addClass('editor-active'); textarea.data('grav-editor-mode', 'preview'); if (!previewContainer) { previewContainer = external_jQuery_default()('
    '); content.after(previewContainer); textarea.data('grav-editor-preview-container', previewContainer); } previewContainer.css({ height: content.height() }); previewContainer.addClass('is-active'); content.removeClass('is-active'); ui.navigation.find('.grav-editor-actions').css('visibility', 'hidden'); var url = "".concat(textarea.data('grav-urlpreview'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "processmarkdown"); var params = textarea.closest('form').serializeArray(); var body = {}; params.map(function (obj) { body[obj.name] = obj.value; }); utils_request(url, { method: 'post', body: body }, function (response) { return previewContainer.html(response.preview); }); }); } } }, { fullscreen: { identifier: 'fullscreen', title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FULLSCREEN, label: '', action: function action(_ref23) { var codemirror = _ref23.codemirror, button = _ref23.button, textarea = _ref23.textarea; button.on('click.editor.fullscreen', function () { var container = textarea.closest('.grav-editor'); var wrapper = codemirror.getWrapperElement(); var contentWrapper = external_jQuery_default()('.content-wrapper'); if (!container.hasClass('grav-editor-fullscreen')) { textarea.data('fullScreenRestore', { scrollTop: __webpack_require__.g.pageYOffset, scrollLeft: __webpack_require__.g.pageXOffset, width: wrapper.style.width, height: wrapper.style.height }); wrapper.style.width = ''; wrapper.style.height = textarea.parent('.grav-editor-content').height() + 'px'; __webpack_require__.g.document.documentElement.style.overflow = 'hidden'; var hints = container.find('.grav-editor-toolbar .hint--top'); if (hints) { hints.removeClass('hint--top').addClass('hint--bottom'); external_jQuery_default()(hints[hints.length - 1]).addClass('hint--bottom-left'); } if (contentWrapper) { contentWrapper.css('overflow', 'visible'); } } else { __webpack_require__.g.document.documentElement.style.overflow = ''; var state = textarea.data('fullScreenRestore'); wrapper.style.width = state.width; wrapper.style.height = state.height; __webpack_require__.g.scrollTo(state.scrollLeft, state.scrollTop); var _hints = container.find('.grav-editor-toolbar .hint--bottom'); if (_hints) { _hints.removeClass('hint--bottom').addClass('hint--top'); external_jQuery_default()(_hints[_hints.length - 1]).removeClass('hint--bottom-left'); } if (contentWrapper) { contentWrapper.css('overflow', 'auto'); } } container.toggleClass('grav-editor-fullscreen'); setTimeout(function () { codemirror.refresh(); // this.preview.parent().css('height', this.code.height()); external_jQuery_default()(__webpack_require__.g).trigger('resize'); }, 5); }); } } }] }); // EXTERNAL MODULE: ./node_modules/codemirror/lib/codemirror.js var codemirror = __webpack_require__(4631); var codemirror_default = /*#__PURE__*/__webpack_require__.n(codemirror); // EXTERNAL MODULE: ./node_modules/watchjs/src/watch.js var watch = __webpack_require__(29950); // EXTERNAL MODULE: ./node_modules/js-yaml/dist/js-yaml.mjs var js_yaml = __webpack_require__(47180); // EXTERNAL MODULE: ./node_modules/codemirror/mode/css/css.js var css = __webpack_require__(36629); // EXTERNAL MODULE: ./node_modules/codemirror/mode/gfm/gfm.js var gfm = __webpack_require__(42425); // EXTERNAL MODULE: ./node_modules/codemirror/mode/htmlmixed/htmlmixed.js var htmlmixed = __webpack_require__(16531); // EXTERNAL MODULE: ./node_modules/codemirror/mode/javascript/javascript.js var javascript = __webpack_require__(96876); // EXTERNAL MODULE: ./node_modules/codemirror/mode/markdown/markdown.js var markdown = __webpack_require__(49047); // EXTERNAL MODULE: ./node_modules/codemirror/mode/php/php.js var php = __webpack_require__(36702); // EXTERNAL MODULE: ./node_modules/codemirror/mode/sass/sass.js var sass = __webpack_require__(81201); // EXTERNAL MODULE: ./node_modules/codemirror/mode/twig/twig.js var twig = __webpack_require__(54702); // EXTERNAL MODULE: ./node_modules/codemirror/mode/xml/xml.js var xml = __webpack_require__(29589); // EXTERNAL MODULE: ./node_modules/codemirror/mode/yaml/yaml.js var yaml = __webpack_require__(53631); // EXTERNAL MODULE: ./node_modules/codemirror/addon/edit/continuelist.js var continuelist = __webpack_require__(23350); // EXTERNAL MODULE: ./node_modules/codemirror/addon/mode/overlay.js var overlay = __webpack_require__(14146); // EXTERNAL MODULE: ./node_modules/codemirror/addon/selection/active-line.js var active_line = __webpack_require__(20017); // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.js var lint = __webpack_require__(3256); // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.css var lint_lint = __webpack_require__(46226); // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/css-lint.js var css_lint = __webpack_require__(41423); // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/javascript-lint.js var javascript_lint = __webpack_require__(96477); // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/json-lint.js var json_lint = __webpack_require__(62193); // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/yaml-lint.js var yaml_lint = __webpack_require__(82783); ;// CONCATENATED MODULE: ./app/forms/fields/editor.js function editor_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function editor_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function editor_createClass(Constructor, protoProps, staticProps) { if (protoProps) editor_defineProperties(Constructor.prototype, protoProps); if (staticProps) editor_defineProperties(Constructor, staticProps); return Constructor; } __webpack_require__.g.jsyaml = js_yaml/* default */.ZP; // Modes // Add-ons var IS_MOUSEDOWN = false; var ThemesMap = ['paper']; var Defaults = { codemirror: { mode: 'htmlmixed', theme: 'paper', lineWrapping: true, dragDrop: true, autoCloseTags: true, matchTags: true, autoCloseBrackets: true, matchBrackets: true, indentUnit: 4, indentWithTabs: false, tabSize: 4, hintOptions: { completionSingle: false }, extraKeys: { 'Enter': 'newlineAndIndentContinueMarkdownList' } } }; var EditorField = /*#__PURE__*/function () { function EditorField(options) { var _this = this; editor_classCallCheck(this, EditorField); var body = external_jQuery_default()('body'); this.editors = external_jQuery_default()(); this.options = Object.assign({}, Defaults, options); this.buttons = buttons; this.buttonStrategies = strategies; (0,watch.watch)(buttons, function () /* key, modifier, prev, next */ { _this.editors.each(function (index, editor) { return external_jQuery_default()(editor).data('toolbar').renderButtons(); }); }); external_jQuery_default()('[data-grav-editor]').each(function (index, editor) { return _this.addEditor(editor); }); external_jQuery_default()(function () { body.trigger('grav-editor-ready'); }); body.on('mutation._grav', this._onAddedNodes.bind(this)); body.on('mouseup._grav', function () { if (!IS_MOUSEDOWN) { return true; } body.unbind('mousemove._grav'); IS_MOUSEDOWN = false; }); body.on('mousedown._grav', '.grav-editor-resizer', function (event) { event && event.preventDefault(); IS_MOUSEDOWN = true; var target = external_jQuery_default()(event.currentTarget); var container = target.siblings('.grav-editor-content'); var editor = container.find('.CodeMirror'); var codemirror = container.find('textarea').data('codemirror'); body.on('mousemove._grav', function (event) { editor.css('height', Math.max(100, event.pageY - container.offset().top)); codemirror.refresh(); }); }); } editor_createClass(EditorField, [{ key: "addButton", value: function addButton(button, options) { if (options && (options.before || options.after)) { var index = this.buttons.navigation.findIndex(function (obj) { var key = Object.keys(obj).shift(); return obj[key].identifier === (options.before || options.after); }); if (!~index) { options = 'end'; } else { this.buttons.navigation.splice(options.before ? index : index + 1, 0, button); } } if (options === 'start') { this.buttons.navigation.splice(0, 0, button); } if (!options || options === 'end') { this.buttons.navigation.push(button); } } }, { key: "addEditor", value: function addEditor(textarea) { textarea = external_jQuery_default()(textarea); var options = Object.assign({}, this.options.codemirror, textarea.data('grav-editor').codemirror); var theme = options.theme || 'paper'; this.editors = this.editors.add(textarea); if (theme && !~ThemesMap.indexOf(theme)) { ThemesMap.push(theme); // let themeCSS = `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.12.0/theme/${theme}.min.css`; // $('head').append($('').attr('href', themeCSS)); } if (options.mode === 'yaml') { Object.assign(options.extraKeys, { Tab: function Tab(cm) { cm.replaceSelection(' ', 'end'); } }); } var editor = codemirror_default().fromTextArea(textarea.get(0), options); textarea.data('codemirror', editor); textarea.data('toolbar', new Toolbar(textarea)); textarea.addClass('code-mirrored'); if (options.toolbar === false) { textarea.data('toolbar').ui.navigation.addClass('grav-editor-hide-toolbar'); } editor.on('change', function () { return editor.save(); }); } }, { key: "_onAddedNodes", value: function _onAddedNodes(event, target /* , record, instance */ ) { var _this2 = this; var editors = external_jQuery_default()(target).find('[data-grav-editor]'); if (!editors.length) { return; } editors.each(function (index, editor) { editor = external_jQuery_default()(editor); if (!~_this2.editors.index(editor)) { _this2.addEditor(editor); } }); } }]); return EditorField; }(); var Toolbar = /*#__PURE__*/function () { function Toolbar(editor) { editor_classCallCheck(this, Toolbar); this.editor = external_jQuery_default()(editor); this.codemirror = this.editor.data('codemirror'); this.buttons = buttons.navigation; this.ui = { navigation: external_jQuery_default()(Toolbar.templates().navigation) }; this.editor.parent('.grav-editor-content').before(this.ui.navigation).after(this.ui.states); this.renderButtons(); } editor_createClass(Toolbar, [{ key: "renderButtons", value: function renderButtons() { var _this3 = this; var map = { 'actions': 'navigation', 'modes': 'states' }; ['actions', 'modes'].forEach(function (type) { _this3.ui.navigation.find(".grav-editor-".concat(type)).empty().append('