wc-pg-blocks
2 months ago
admin.js
3 weeks ago
admin.min.js
3 weeks ago
dashboard.js
3 days ago
dashboard.min.js
3 days ago
gutenberg-jalali-calendar.build.js
3 weeks ago
index.php
3 weeks ago
jalalidatepicker.min.js
3 weeks ago
keen-slider.min.js
2 months ago
script.js
3 days ago
script.min.js
3 days ago
dashboard.js
32 lines
| 1 | /* |
| 2 | * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). |
| 3 | * This devtool is neither made for production nor for readable output files. |
| 4 | * It uses "eval()" calls to create a separate source file in the browser devtools. |
| 5 | * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) |
| 6 | * or disable the default devtool with "devtool: false". |
| 7 | * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). |
| 8 | */ |
| 9 | /******/ (() => { // webpackBootstrap |
| 10 | /******/ var __webpack_modules__ = ({ |
| 11 | |
| 12 | /***/ "./assets/js-admin-src/dashboard.js" |
| 13 | /*!******************************************!*\ |
| 14 | !*** ./assets/js-admin-src/dashboard.js ***! |
| 15 | \******************************************/ |
| 16 | () { |
| 17 | |
| 18 | eval("{/**\r\n * @output wp-admin/js/dashboard.js\r\n */\r\n\r\n/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true, ajaxWidgets */\r\n/* global ajaxPopulateWidgets, quickPressLoad, */\r\nwindow.wp = window.wp || {};\r\nwindow.communityEventsData = window.communityEventsData || {};\r\n\r\n/**\r\n * Initializes the dashboard widget functionality.\r\n *\r\n * @since 2.7.0\r\n */\r\njQuery(function ($) {\r\n /**\r\n * These widgets can be populated via ajax.\r\n *\r\n * @since 2.7.0\r\n *\r\n * @type {string[]}\r\n *\r\n * @global\r\n */\r\n window.ajaxWidgets = ['wpp_dashboard_primary'];\r\n\r\n /**\r\n * Triggers widget updates via Ajax.\r\n *\r\n * @since 2.7.0\r\n *\r\n * @global\r\n *\r\n * @param {string} el Optional. Widget to fetch or none to update all.\r\n *\r\n * @return {void}\r\n */\r\n window.ajaxPopulateWidgets = function (el) {\r\n /**\r\n * Fetch the latest representation of the widget via Ajax and show it.\r\n *\r\n * @param {number} i Number of half-seconds to use as the timeout.\r\n * @param {string} id ID of the element which is going to be checked for changes.\r\n *\r\n * @return {void}\r\n */\r\n function show(i, id) {\r\n var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');\r\n // If the element is found in the dom, queue to load latest representation.\r\n if (e.length) {\r\n p = e.parent();\r\n setTimeout(function () {\r\n // Request the widget content.\r\n p.load(ajaxurl + '?action=wpp-dashboard-widgets&widget=' + id + '&pagenow=' + pagenow, '', function () {\r\n // Hide the parent and slide it out for visual fanciness.\r\n p.hide().slideDown('normal', function () {\r\n $(this).css('display', '');\r\n });\r\n });\r\n }, i * 500);\r\n }\r\n }\r\n\r\n // If we have received a specific element to fetch, check if it is valid.\r\n if (el) {\r\n el = el.toString();\r\n // If the element is available as Ajax widget, show it.\r\n if ($.inArray(el, ajaxWidgets) !== -1) {\r\n // Show element without any delay.\r\n show(0, el);\r\n }\r\n } else {\r\n // Walk through all ajaxWidgets, loading them after each other.\r\n $.each(ajaxWidgets, show);\r\n }\r\n };\r\n\r\n // Initially populate ajax widgets.\r\n ajaxPopulateWidgets();\r\n\r\n // Register ajax widgets as postbox toggles.\r\n\r\n $(document).on('postbox-toggled', function (e, postbox) {\r\n if (ajaxWidgets.indexOf(postbox.id) !== -1) {\r\n if (wppDashboardSlider) {\r\n wppDashboardSlider.update();\r\n }\r\n ajaxPopulateWidgets();\r\n }\r\n });\r\n});\r\n\r\njQuery(function ($) {\r\n 'use strict';\r\n\r\n var communityEventsData = window.communityEventsData,\r\n dateI18n = wp.date.dateI18n,\r\n format = wp.date.format,\r\n sprintf = wp.i18n.sprintf,\r\n __ = wp.i18n.__,\r\n _x = wp.i18n._x,\r\n app;\r\n\r\n /**\r\n * Global Community Events namespace.\r\n *\r\n * @since 4.8.0\r\n *\r\n * @memberOf wp\r\n * @namespace wp.communityEvents\r\n */\r\n app = window.wp.communityEvents = /** @lends wp.communityEvents */{\r\n initialized: false,\r\n model: null,\r\n\r\n /**\r\n * Initializes the wp.communityEvents object.\r\n *\r\n * @since 4.8.0\r\n *\r\n * @return {void}\r\n */\r\n init: function () {\r\n if (app.initialized) {\r\n return;\r\n }\r\n\r\n var $container = $('#community-events');\r\n\r\n /*\r\n * When JavaScript is disabled, the errors container is shown, so\r\n * that \"This widget requires JavaScript\" message can be seen.\r\n *\r\n * When JS is enabled, the container is hidden at first, and then\r\n * revealed during the template rendering, if there actually are\r\n * errors to show.\r\n *\r\n * The display indicator switches from `hide-if-js` to `aria-hidden`\r\n * here in order to maintain consistency with all the other fields\r\n * that key off of `aria-hidden` to determine their visibility.\r\n * `aria-hidden` can't be used initially, because there would be no\r\n * way to set it to false when JavaScript is disabled, which would\r\n * prevent people from seeing the \"This widget requires JavaScript\"\r\n * message.\r\n */\r\n $('.community-events-errors')\r\n .attr('aria-hidden', 'true')\r\n .removeClass('hide-if-js');\r\n\r\n $container.on('click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm);\r\n\r\n /**\r\n * Filters events based on entered location.\r\n *\r\n * @return {void}\r\n */\r\n $container.on('submit', '.community-events-form', function (event) {\r\n var location = $('#community-events-location').val().trim();\r\n\r\n event.preventDefault();\r\n\r\n /*\r\n * Don't trigger a search if the search field is empty or the\r\n * search term was made of only spaces before being trimmed.\r\n */\r\n if (!location) {\r\n return;\r\n }\r\n\r\n app.getEvents({\r\n location: location\r\n });\r\n });\r\n\r\n if (communityEventsData && communityEventsData.cache && communityEventsData.cache.location && communityEventsData.cache.events) {\r\n app.renderEventsTemplate(communityEventsData.cache, 'app');\r\n } else {\r\n app.getEvents();\r\n }\r\n\r\n app.initialized = true;\r\n },\r\n\r\n /**\r\n * Toggles the visibility of the Edit Location form.\r\n *\r\n * @since 4.8.0\r\n *\r\n * @param {event|string} action 'show' or 'hide' to specify a state;\r\n * or an event object to flip between states.\r\n *\r\n * @return {void}\r\n */\r\n toggleLocationForm: function (action) {\r\n var $toggleButton = $('.community-events-toggle-location'),\r\n $cancelButton = $('.community-events-cancel'),\r\n $form = $('.community-events-form'),\r\n $target = $();\r\n\r\n if ('object' === typeof action) {\r\n // The action is the event object: get the clicked element.\r\n $target = $(action.target);\r\n /*\r\n * Strict comparison doesn't work in this case because sometimes\r\n * we explicitly pass a string as value of aria-expanded and\r\n * sometimes a boolean as the result of an evaluation.\r\n */\r\n action = 'true' === $toggleButton.attr('aria-expanded') ? 'hide' : 'show';\r\n }\r\n\r\n if ('hide' === action) {\r\n $toggleButton.attr('aria-expanded', 'false');\r\n $cancelButton.attr('aria-expanded', 'false');\r\n $form.attr('aria-hidden', 'true');\r\n /*\r\n * If the Cancel button has been clicked, bring the focus back\r\n * to the toggle button so users relying on screen readers don't\r\n * lose their place.\r\n */\r\n if ($target.hasClass('community-events-cancel')) {\r\n $toggleButton.trigger('focus');\r\n }\r\n } else {\r\n $toggleButton.attr('aria-expanded', 'true');\r\n $cancelButton.attr('aria-expanded', 'true');\r\n $form.attr('aria-hidden', 'false');\r\n }\r\n },\r\n\r\n /**\r\n * Sends REST API requests to fetch events for the widget.\r\n *\r\n * @since 4.8.0\r\n *\r\n * @param {Object} requestParams REST API Request parameters object.\r\n *\r\n * @return {void}\r\n */\r\n getEvents: function (requestParams) {\r\n var initiatedBy,\r\n app = this,\r\n $spinner = $('.community-events-form').children('.spinner');\r\n\r\n requestParams = requestParams || {};\r\n requestParams._wpnonce = communityEventsData.nonce;\r\n requestParams.timezone = window.Intl ? window.Intl.DateTimeFormat().resolvedOptions().timeZone : '';\r\n\r\n initiatedBy = requestParams.location ? 'user' : 'app';\r\n\r\n $spinner.addClass('is-active');\r\n\r\n wp.ajax.post('get-community-events', requestParams)\r\n .always(function () {\r\n $spinner.removeClass('is-active');\r\n })\r\n\r\n .done(function (response) {\r\n if ('no_location_available' === response.error) {\r\n if (requestParams.location) {\r\n response.unknownCity = requestParams.location;\r\n } else {\r\n /*\r\n * No location was passed, which means that this was an automatic query\r\n * based on IP, locale, and timezone. Since the user didn't initiate it,\r\n * it should fail silently. Otherwise, the error could confuse and/or\r\n * annoy them.\r\n */\r\n delete response.error;\r\n }\r\n }\r\n app.renderEventsTemplate(response, initiatedBy);\r\n })\r\n\r\n .fail(function () {\r\n app.renderEventsTemplate({\r\n 'location': false,\r\n 'events': [],\r\n 'error': true\r\n }, initiatedBy);\r\n });\r\n },\r\n\r\n /**\r\n * Renders the template for the Events section of the Events & News widget.\r\n *\r\n * @since 4.8.0\r\n *\r\n * @param {Object} templateParams The various parameters that will get passed to wp.template.\r\n * @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user;\r\n * 'app' to indicate it was triggered automatically by the app itself.\r\n *\r\n * @return {void}\r\n */\r\n renderEventsTemplate: function (templateParams, initiatedBy) {\r\n var template,\r\n elementVisibility,\r\n $toggleButton = $('.community-events-toggle-location'),\r\n $locationMessage = $('#community-events-location-message'),\r\n $results = $('.community-events-results');\r\n\r\n templateParams.events = app.populateDynamicEventFields(\r\n templateParams.events,\r\n communityEventsData.time_format\r\n );\r\n\r\n /*\r\n * Hide all toggleable elements by default, to keep the logic simple.\r\n * Otherwise, each block below would have to turn hide everything that\r\n * could have been shown at an earlier point.\r\n *\r\n * The exception to that is that the .community-events container is hidden\r\n * when the page is first loaded, because the content isn't ready yet,\r\n * but once we've reached this point, it should always be shown.\r\n */\r\n elementVisibility = {\r\n '.community-events': true,\r\n '.community-events-loading': false,\r\n '.community-events-errors': false,\r\n '.community-events-error-occurred': false,\r\n '.community-events-could-not-locate': false,\r\n '#community-events-location-message': false,\r\n '.community-events-toggle-location': false,\r\n '.community-events-results': false\r\n };\r\n\r\n /*\r\n * Determine which templates should be rendered and which elements\r\n * should be displayed.\r\n */\r\n if (templateParams.location.ip) {\r\n /*\r\n * If the API determined the location by geolocating an IP, it will\r\n * provide events, but not a specific location.\r\n */\r\n $locationMessage.text(__('Attend an upcoming event near you.'));\r\n\r\n if (templateParams.events.length) {\r\n template = wp.template('community-events-event-list');\r\n $results.html(template(templateParams));\r\n } else {\r\n template = wp.template('community-events-no-upcoming-events');\r\n $results.html(template(templateParams));\r\n }\r\n\r\n elementVisibility['#community-events-location-message'] = true;\r\n elementVisibility['.community-events-toggle-location'] = true;\r\n elementVisibility['.community-events-results'] = true;\r\n\r\n } else if (templateParams.location.description) {\r\n template = wp.template('community-events-attend-event-near');\r\n $locationMessage.html(template(templateParams));\r\n\r\n if (templateParams.events.length) {\r\n template = wp.template('community-events-event-list');\r\n $results.html(template(templateParams));\r\n } else {\r\n template = wp.template('community-events-no-upcoming-events');\r\n $results.html(template(templateParams));\r\n }\r\n\r\n if ('user' === initiatedBy) {\r\n wp.a11y.speak(\r\n sprintf(\r\n /* translators: %s: The name of a city. */\r\n __('City updated. Listing events near %s.'),\r\n templateParams.location.description\r\n ),\r\n 'assertive'\r\n );\r\n }\r\n\r\n elementVisibility['#community-events-location-message'] = true;\r\n elementVisibility['.community-events-toggle-location'] = true;\r\n elementVisibility['.community-events-results'] = true;\r\n\r\n } else if (templateParams.unknownCity) {\r\n template = wp.template('community-events-could-not-locate');\r\n $('.community-events-could-not-locate').html(template(templateParams));\r\n wp.a11y.speak(\r\n sprintf(\r\n /*\r\n * These specific examples were chosen to highlight the fact that a\r\n * state is not needed, even for cities whose name is not unique.\r\n * It would be too cumbersome to include that in the instructions\r\n * to the user, so it's left as an implication.\r\n */\r\n /*\r\n * translators: %s is the name of the city we couldn't locate.\r\n * Replace the examples with cities related to your locale. Test that\r\n * they match the expected location and have upcoming events before\r\n * including them. If no cities related to your locale have events,\r\n * then use cities related to your locale that would be recognizable\r\n * to most users. Use only the city name itself, without any region\r\n * or country. Use the endonym (native locale name) instead of the\r\n * English name if possible.\r\n */\r\n __('We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.'),\r\n templateParams.unknownCity\r\n )\r\n );\r\n\r\n elementVisibility['.community-events-errors'] = true;\r\n elementVisibility['.community-events-could-not-locate'] = true;\r\n\r\n } else if (templateParams.error && 'user' === initiatedBy) {\r\n /*\r\n * Errors messages are only shown for requests that were initiated\r\n * by the user, not for ones that were initiated by the app itself.\r\n * Showing error messages for an event that user isn't aware of\r\n * could be confusing or unnecessarily distracting.\r\n */\r\n wp.a11y.speak(__('An error occurred. Please try again.'));\r\n\r\n elementVisibility['.community-events-errors'] = true;\r\n elementVisibility['.community-events-error-occurred'] = true;\r\n } else {\r\n $locationMessage.text(__('Enter your closest city to find nearby events.'));\r\n\r\n elementVisibility['#community-events-location-message'] = true;\r\n elementVisibility['.community-events-toggle-location'] = true;\r\n }\r\n\r\n // Set the visibility of toggleable elements.\r\n _.each(elementVisibility, function (isVisible, element) {\r\n $(element).attr('aria-hidden', !isVisible);\r\n });\r\n\r\n $toggleButton.attr('aria-expanded', elementVisibility['.community-events-toggle-location']);\r\n\r\n if (templateParams.location && (templateParams.location.ip || templateParams.location.latitude)) {\r\n // Hide the form when there's a valid location.\r\n app.toggleLocationForm('hide');\r\n\r\n if ('user' === initiatedBy) {\r\n /*\r\n * When the form is programmatically hidden after a user search,\r\n * bring the focus back to the toggle button so users relying\r\n * on screen readers don't lose their place.\r\n */\r\n $toggleButton.trigger('focus');\r\n }\r\n } else {\r\n app.toggleLocationForm('show');\r\n }\r\n },\r\n\r\n /**\r\n * Populate event fields that have to be calculated on the fly.\r\n *\r\n * These can't be stored in the database, because they're dependent on\r\n * the user's current time zone, locale, etc.\r\n *\r\n * @since 5.5.2\r\n *\r\n * @param {Array} rawEvents The events that should have dynamic fields added to them.\r\n * @param {string} timeFormat A time format acceptable by `wp.date.dateI18n()`.\r\n *\r\n * @returns {Array}\r\n */\r\n populateDynamicEventFields: function (rawEvents, timeFormat) {\r\n // Clone the parameter to avoid mutating it, so that this can remain a pure function.\r\n var populatedEvents = JSON.parse(JSON.stringify(rawEvents));\r\n\r\n $.each(populatedEvents, function (index, event) {\r\n var timeZone = app.getTimeZone(event.start_unix_timestamp * 1000);\r\n\r\n event.user_formatted_date = app.getFormattedDate(\r\n event.start_unix_timestamp * 1000,\r\n event.end_unix_timestamp * 1000,\r\n timeZone\r\n );\r\n\r\n event.user_formatted_time = dateI18n(\r\n timeFormat,\r\n event.start_unix_timestamp * 1000,\r\n timeZone\r\n );\r\n\r\n event.timeZoneAbbreviation = app.getTimeZoneAbbreviation(event.start_unix_timestamp * 1000);\r\n });\r\n\r\n return populatedEvents;\r\n },\r\n\r\n /**\r\n * Returns the user's local/browser time zone, in a form suitable for `wp.date.i18n()`.\r\n *\r\n * @since 5.5.2\r\n *\r\n * @param startTimestamp\r\n *\r\n * @returns {string|number}\r\n */\r\n getTimeZone: function (startTimestamp) {\r\n /*\r\n * Prefer a name like `Europe/Helsinki`, since that automatically tracks daylight savings. This\r\n * doesn't need to take `startTimestamp` into account for that reason.\r\n */\r\n var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\r\n\r\n /*\r\n * Fall back to an offset for IE11, which declares the property but doesn't assign a value.\r\n */\r\n if ('undefined' === typeof timeZone) {\r\n /*\r\n * It's important to use the _event_ time, not the _current_\r\n * time, so that daylight savings time is accounted for.\r\n */\r\n timeZone = app.getFlippedTimeZoneOffset(startTimestamp);\r\n }\r\n\r\n return timeZone;\r\n },\r\n\r\n /**\r\n * Get intuitive time zone offset.\r\n *\r\n * `Data.prototype.getTimezoneOffset()` returns a positive value for time zones\r\n * that are _behind_ UTC, and a _negative_ value for ones that are ahead.\r\n *\r\n * See https://stackoverflow.com/questions/21102435/why-does-javascript-date-gettimezoneoffset-consider-0500-as-a-positive-off.\r\n *\r\n * @since 5.5.2\r\n *\r\n * @param {number} startTimestamp\r\n *\r\n * @returns {number}\r\n */\r\n getFlippedTimeZoneOffset: function (startTimestamp) {\r\n return new Date(startTimestamp).getTimezoneOffset() * -1;\r\n },\r\n\r\n /**\r\n * Get a short time zone name, like `PST`.\r\n *\r\n * @since 5.5.2\r\n *\r\n * @param {number} startTimestamp\r\n *\r\n * @returns {string}\r\n */\r\n getTimeZoneAbbreviation: function (startTimestamp) {\r\n var timeZoneAbbreviation,\r\n eventDateTime = new Date(startTimestamp);\r\n\r\n /*\r\n * Leaving the `locales` argument undefined is important, so that the browser\r\n * displays the abbreviation that's most appropriate for the current locale. For\r\n * some that will be `UTC{+|-}{n}`, and for others it will be a code like `PST`.\r\n *\r\n * This doesn't need to take `startTimestamp` into account, because a name like\r\n * `America/Chicago` automatically tracks daylight savings.\r\n */\r\n var shortTimeStringParts = eventDateTime.toLocaleTimeString(undefined, {timeZoneName: 'short'}).split(' ');\r\n\r\n if (3 === shortTimeStringParts.length) {\r\n timeZoneAbbreviation = shortTimeStringParts[2];\r\n }\r\n\r\n if ('undefined' === typeof timeZoneAbbreviation) {\r\n /*\r\n * It's important to use the _event_ time, not the _current_\r\n * time, so that daylight savings time is accounted for.\r\n */\r\n var timeZoneOffset = app.getFlippedTimeZoneOffset(startTimestamp),\r\n sign = -1 === Math.sign(timeZoneOffset) ? '' : '+';\r\n\r\n // translators: Used as part of a string like `GMT+5` in the Events Widget.\r\n timeZoneAbbreviation = _x('GMT', 'Events widget offset prefix') + sign + (timeZoneOffset / 60);\r\n }\r\n\r\n return timeZoneAbbreviation;\r\n },\r\n\r\n /**\r\n * Format a start/end date in the user's local time zone and locale.\r\n *\r\n * @since 5.5.2\r\n *\r\n * @param {int} startDate The Unix timestamp in milliseconds when the the event starts.\r\n * @param {int} endDate The Unix timestamp in milliseconds when the the event ends.\r\n * @param {string} timeZone A time zone string or offset which is parsable by `wp.date.i18n()`.\r\n *\r\n * @returns {string}\r\n */\r\n getFormattedDate: function (startDate, endDate, timeZone) {\r\n var formattedDate;\r\n\r\n /*\r\n * The `date_format` option is not used because it's important\r\n * in this context to keep the day of the week in the displayed date,\r\n * so that users can tell at a glance if the event is on a day they\r\n * are available, without having to open the link.\r\n *\r\n * The case of crossing a year boundary is intentionally not handled.\r\n * It's so rare in practice that it's not worth the complexity\r\n * tradeoff. The _ending_ year should be passed to\r\n * `multiple_month_event`, though, just in case.\r\n */\r\n /* translators: Date format for upcoming events on the dashboard. Include the day of the week. See https://www.php.net/manual/datetime.format.php */\r\n var singleDayEvent = __('l, M j, Y'),\r\n /* translators: Date string for upcoming events. 1: Month, 2: Starting day, 3: Ending day, 4: Year. */\r\n multipleDayEvent = __('%1$s %2$d–%3$d, %4$d'),\r\n /* translators: Date string for upcoming events. 1: Starting month, 2: Starting day, 3: Ending month, 4: Ending day, 5: Ending year. */\r\n multipleMonthEvent = __('%1$s %2$d – %3$s %4$d, %5$d');\r\n\r\n // Detect single-day events.\r\n if (!endDate || format('Y-m-d', startDate) === format('Y-m-d', endDate)) {\r\n formattedDate = dateI18n(singleDayEvent, startDate, timeZone);\r\n\r\n // Multiple day events.\r\n } else if (format('Y-m', startDate) === format('Y-m', endDate)) {\r\n formattedDate = sprintf(\r\n multipleDayEvent,\r\n dateI18n(_x('F', 'upcoming events month format'), startDate, timeZone),\r\n dateI18n(_x('j', 'upcoming events day format'), startDate, timeZone),\r\n dateI18n(_x('j', 'upcoming events day format'), endDate, timeZone),\r\n dateI18n(_x('Y', 'upcoming events year format'), endDate, timeZone)\r\n );\r\n\r\n // Multi-day events that cross a month boundary.\r\n } else {\r\n formattedDate = sprintf(\r\n multipleMonthEvent,\r\n dateI18n(_x('F', 'upcoming events month format'), startDate, timeZone),\r\n dateI18n(_x('j', 'upcoming events day format'), startDate, timeZone),\r\n dateI18n(_x('F', 'upcoming events month format'), endDate, timeZone),\r\n dateI18n(_x('j', 'upcoming events day format'), endDate, timeZone),\r\n dateI18n(_x('Y', 'upcoming events year format'), endDate, timeZone)\r\n );\r\n }\r\n\r\n return formattedDate;\r\n }\r\n };\r\n\r\n const wppWidget = $('#wpp_dashboard_primary');\r\n\r\n if (wppWidget.is(':visible')) {\r\n app.init();\r\n } else {\r\n $(document).on('postbox-toggled', function (event, postbox) {\r\n var $postbox = $(postbox);\r\n\r\n if ('wpp_dashboard_primary' === $postbox.attr('id') && $postbox.is(':visible')) {\r\n app.init();\r\n }\r\n });\r\n }\r\n});\r\n\r\nconst slidesContainer = document.getElementById('wpp_sponsorship');\r\nconst sponsorshipGuid = document.getElementById('wpp-sponsorship-guide');\r\nconst wppsPlaceholder = document.getElementById('wpp_sponsorship_placeholder');\r\nconst wppsQuestion = document.querySelector('#wpp-sponsorship-guide .question');\r\nconst sponsorshipUl = document.querySelector('#wpp-sponsorship-guide ul');\r\n\r\n\r\nfunction wppInitSponsors() {\r\n try {\r\n const sponsorsData = Object.values(wpp_dashboard.sponsors);\r\n if (sponsorsData.length > 0) {\r\n wppsPlaceholder.remove();\r\n const activeSponsor = sponsorsData[wppSponsorsIndex(sponsorsData.length)];\r\n console.log(activeSponsor)\r\n\r\n const sponsorElement = document.createElement('div');\r\n sponsorElement.innerHTML = '<a href=\"' + activeSponsor.link + '\" target=\"_blank\"><img src=\"' + activeSponsor.image + '\" alt=\"' + activeSponsor.image_alt + '\"></a>';\r\n slidesContainer.appendChild(sponsorElement);\r\n }\r\n\r\n //\r\n /*createSlides(slidesData);\r\n new KeenSlider(slidesContainer, {\r\n loop: true,\r\n duration: 5000,\r\n controls: true,\r\n indicators: true,\r\n });*/\r\n } catch (error) {\r\n console.error('Error fetching slides:', error);\r\n }\r\n}\r\n\r\nfunction wppSponsorsIndex(sponsorsCount) {\r\n if (sponsorsCount === 1) {\r\n return 0;\r\n }\r\n\r\n let sponsorsIndex = parseInt(localStorage.getItem(\"wpp_sponsor_index\"));\r\n\r\n if (isNaN(sponsorsIndex)) {\r\n sponsorsIndex = Math.floor(Math.random() * sponsorsCount);\r\n } else {\r\n if (sponsorsIndex + 1 >= sponsorsCount) {\r\n sponsorsIndex = 0;\r\n } else {\r\n sponsorsIndex++;\r\n }\r\n }\r\n\r\n localStorage.setItem(\"wpp_sponsor_index\", '' + sponsorsIndex);\r\n\r\n return sponsorsIndex;\r\n}\r\n\r\nfunction createSlides(slidesData) {\r\n slidesData.forEach((slide) => {\r\n const slideElement = document.createElement('div');\r\n slideElement.classList.add('keen-slider__slide');\r\n slideElement.innerHTML = '<a href=\"' + slide.link + '\" target=\"_blank\"><img src=\"' + slide.image_url + '\" alt=\"' + slide.image_alt + '\" loading=\"lazy\"></a>';\r\n slidesContainer.appendChild(slideElement);\r\n });\r\n\r\n if (slidesData.length > 1) {\r\n initWPPSSlider();\r\n }\r\n}\r\n\r\nfunction initWPPSSlider() {\r\n window.wppDashboardSlider = new KeenSlider(slidesContainer, {\r\n rtl: getComputedStyle(slidesContainer).direction,\r\n loop: true,\r\n duration: 3000,\r\n controls: true,\r\n indicators: true,\r\n }, [wppsNavigation, (slider) => {\r\n let timeout;\r\n let mouseOver = false;\r\n\r\n function clearNextTimeout() {\r\n clearTimeout(timeout);\r\n }\r\n\r\n function nextTimeout() {\r\n clearTimeout(timeout);\r\n if (mouseOver) {\r\n return;\r\n }\r\n timeout = setTimeout(() => {\r\n slider.next();\r\n }, 4000);\r\n }\r\n\r\n slider.on('created', () => {\r\n slider.container.addEventListener('mouseover', () => {\r\n mouseOver = true;\r\n clearNextTimeout();\r\n });\r\n slider.container.addEventListener('mouseout', () => {\r\n mouseOver = false;\r\n nextTimeout();\r\n });\r\n nextTimeout();\r\n });\r\n slider.on('dragStarted', clearNextTimeout);\r\n slider.on('animationEnded', nextTimeout);\r\n slider.on('updated', nextTimeout);\r\n },]);\r\n}\r\n\r\nfunction wppsNavigation(slider) {\r\n let wrapper, dots, arrowLeft, arrowRight;\r\n\r\n function markup(remove) {\r\n wrapperMarkup(remove);\r\n dotMarkup(remove);\r\n arrowMarkup(remove);\r\n }\r\n\r\n function removeElement(elment) {\r\n elment.parentNode.removeChild(elment);\r\n }\r\n\r\n function createDiv(className) {\r\n const div = document.createElement('div');\r\n let classNames = className.split(' ');\r\n classNames.forEach((name) => div.classList.add(name));\r\n return div;\r\n }\r\n\r\n function arrowMarkup(remove) {\r\n if (remove) {\r\n removeElement(arrowLeft);\r\n removeElement(arrowRight);\r\n return;\r\n }\r\n arrowLeft = createDiv('arrow arrow--left');\r\n arrowLeft.addEventListener('click', () => slider.prev());\r\n arrowRight = createDiv('arrow arrow--right');\r\n arrowRight.addEventListener('click', () => slider.next());\r\n\r\n wrapper.appendChild(arrowLeft);\r\n wrapper.appendChild(arrowRight);\r\n }\r\n\r\n function wrapperMarkup(remove) {\r\n if (remove) {\r\n const parent = wrapper.parentNode;\r\n while (wrapper.firstChild) {\r\n parent.insertBefore(wrapper.firstChild, wrapper);\r\n }\r\n removeElement(wrapper);\r\n return;\r\n }\r\n wrapper = createDiv('navigation-wrapper');\r\n slider.container.parentNode.prepend(wrapper);\r\n wrapper.appendChild(slider.container);\r\n }\r\n\r\n function dotMarkup(remove) {\r\n if (remove) {\r\n removeElement(dots);\r\n return;\r\n }\r\n dots = createDiv('dots');\r\n slider.track.details.slides.forEach((_e, idx) => {\r\n const dot = createDiv('dot');\r\n dot.addEventListener('click', () => slider.moveToIdx(idx));\r\n dots.appendChild(dot);\r\n });\r\n wrapper.appendChild(dots);\r\n }\r\n\r\n function updateClasses() {\r\n let slide = slider.track.details.rel;\r\n slide === 0 ? arrowLeft.classList.add('arrow--disabled') : arrowLeft.classList.remove('arrow--disabled');\r\n slide === slider.track.details.slides.length - 1 ? arrowRight.classList.add('arrow--disabled') : arrowRight.classList.remove('arrow--disabled');\r\n Array.from(dots.children).forEach(function (dot, idx) {\r\n idx === slide ? dot.classList.add('dot--active') : dot.classList.remove('dot--active');\r\n });\r\n }\r\n\r\n slider.on('created', () => {\r\n markup();\r\n updateClasses();\r\n });\r\n slider.on('optionsChanged', () => {\r\n console.log(2);\r\n markup(true);\r\n markup();\r\n updateClasses();\r\n });\r\n slider.on('slideChanged', () => {\r\n updateClasses();\r\n });\r\n slider.on('destroyed', () => {\r\n markup(true);\r\n });\r\n}\r\n\r\nwppInitSponsors();\r\n\r\nwppsQuestion.addEventListener('click', function (event) {\r\n sponsorshipUl.classList.toggle('show');\r\n event.stopPropagation();\r\n});\r\n\r\ndocument.addEventListener('click', function (event) {\r\n if (!sponsorshipGuid.contains(event.target)) {\r\n sponsorshipUl.classList.remove('show');\r\n }\r\n});\r\n\n\n//# sourceURL=webpack://wp-parsidate/./assets/js-admin-src/dashboard.js?\n}"); |
| 19 | |
| 20 | /***/ } |
| 21 | |
| 22 | /******/ }); |
| 23 | /************************************************************************/ |
| 24 | /******/ |
| 25 | /******/ // startup |
| 26 | /******/ // Load entry module and return exports |
| 27 | /******/ // This entry module can't be inlined because the eval devtool is used. |
| 28 | /******/ var __webpack_exports__ = {}; |
| 29 | /******/ __webpack_modules__["./assets/js-admin-src/dashboard.js"](); |
| 30 | /******/ |
| 31 | /******/ })() |
| 32 | ; |