Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: customize-widgets.js
open({
[2000] Fix | Delete
returnFocusWhenClose
[2001] Fix | Delete
} = {}) {
[2002] Fix | Delete
this.isOpen = true;
[2003] Fix | Delete
this.returnFocusWhenClose = returnFocusWhenClose;
[2004] Fix | Delete
this.expand({
[2005] Fix | Delete
allowMultiple: true
[2006] Fix | Delete
});
[2007] Fix | Delete
}
[2008] Fix | Delete
close() {
[2009] Fix | Delete
this.collapse({
[2010] Fix | Delete
allowMultiple: true
[2011] Fix | Delete
});
[2012] Fix | Delete
}
[2013] Fix | Delete
collapse(options) {
[2014] Fix | Delete
// Overridden collapse() function. Mostly call the parent collapse(), but also
[2015] Fix | Delete
// move our .isOpen to false.
[2016] Fix | Delete
// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work
[2017] Fix | Delete
// because the block settings sidebar is a layer "on top of" the G editor sidebar.
[2018] Fix | Delete
//
[2019] Fix | Delete
// For example, when closing the block settings sidebar, the G
[2020] Fix | Delete
// editor sidebar would display, and onChangeExpanded in
[2021] Fix | Delete
// inspector-section would run with expanded=true, but I want
[2022] Fix | Delete
// isOpen to be false when the block settings is closed.
[2023] Fix | Delete
this.isOpen = false;
[2024] Fix | Delete
super.collapse(options);
[2025] Fix | Delete
}
[2026] Fix | Delete
triggerActiveCallbacks() {
[2027] Fix | Delete
// Manually fire the callbacks associated with moving this.active
[2028] Fix | Delete
// from false to true. "active" is always true for this section,
[2029] Fix | Delete
// and "isContextuallyActive" reflects if the block settings
[2030] Fix | Delete
// sidebar is currently visible, that is, it has replaced the main
[2031] Fix | Delete
// Gutenberg view.
[2032] Fix | Delete
// The WP customizer only checks ".isContextuallyActive()" when
[2033] Fix | Delete
// ".active" changes values. But our ".active" never changes value.
[2034] Fix | Delete
// The WP customizer never foresaw a section being used a way we
[2035] Fix | Delete
// fit the block settings sidebar into a section. By manually
[2036] Fix | Delete
// triggering the "this.active" callbacks, we force the WP
[2037] Fix | Delete
// customizer to query our .isContextuallyActive() function and
[2038] Fix | Delete
// update its view of our status.
[2039] Fix | Delete
this.active.callbacks.fireWith(this.active, [false, true]);
[2040] Fix | Delete
}
[2041] Fix | Delete
};
[2042] Fix | Delete
}
[2043] Fix | Delete
[2044] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/sidebar-section.js
[2045] Fix | Delete
/**
[2046] Fix | Delete
* WordPress dependencies
[2047] Fix | Delete
*/
[2048] Fix | Delete
[2049] Fix | Delete
[2050] Fix | Delete
/**
[2051] Fix | Delete
* Internal dependencies
[2052] Fix | Delete
*/
[2053] Fix | Delete
[2054] Fix | Delete
const getInspectorSectionId = sidebarId => `widgets-inspector-${sidebarId}`;
[2055] Fix | Delete
function getSidebarSection() {
[2056] Fix | Delete
const {
[2057] Fix | Delete
wp: {
[2058] Fix | Delete
customize
[2059] Fix | Delete
}
[2060] Fix | Delete
} = window;
[2061] Fix | Delete
const reduceMotionMediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
[2062] Fix | Delete
let isReducedMotion = reduceMotionMediaQuery.matches;
[2063] Fix | Delete
reduceMotionMediaQuery.addEventListener('change', event => {
[2064] Fix | Delete
isReducedMotion = event.matches;
[2065] Fix | Delete
});
[2066] Fix | Delete
return class SidebarSection extends customize.Section {
[2067] Fix | Delete
ready() {
[2068] Fix | Delete
const InspectorSection = getInspectorSection();
[2069] Fix | Delete
this.inspector = new InspectorSection(getInspectorSectionId(this.id), {
[2070] Fix | Delete
title: (0,external_wp_i18n_namespaceObject.__)('Block Settings'),
[2071] Fix | Delete
parentSection: this,
[2072] Fix | Delete
customizeAction: [(0,external_wp_i18n_namespaceObject.__)('Customizing'), (0,external_wp_i18n_namespaceObject.__)('Widgets'), this.params.title].join(' ▸ ')
[2073] Fix | Delete
});
[2074] Fix | Delete
customize.section.add(this.inspector);
[2075] Fix | Delete
this.contentContainer[0].classList.add('customize-widgets__sidebar-section');
[2076] Fix | Delete
}
[2077] Fix | Delete
hasSubSectionOpened() {
[2078] Fix | Delete
return this.inspector.expanded();
[2079] Fix | Delete
}
[2080] Fix | Delete
onChangeExpanded(expanded, _args) {
[2081] Fix | Delete
const controls = this.controls();
[2082] Fix | Delete
const args = {
[2083] Fix | Delete
..._args,
[2084] Fix | Delete
completeCallback() {
[2085] Fix | Delete
controls.forEach(control => {
[2086] Fix | Delete
control.onChangeSectionExpanded?.(expanded, args);
[2087] Fix | Delete
});
[2088] Fix | Delete
_args.completeCallback?.();
[2089] Fix | Delete
}
[2090] Fix | Delete
};
[2091] Fix | Delete
if (args.manualTransition) {
[2092] Fix | Delete
if (expanded) {
[2093] Fix | Delete
this.contentContainer.addClass(['busy', 'open']);
[2094] Fix | Delete
this.contentContainer.removeClass('is-sub-section-open');
[2095] Fix | Delete
this.contentContainer.closest('.wp-full-overlay').addClass('section-open');
[2096] Fix | Delete
} else {
[2097] Fix | Delete
this.contentContainer.addClass(['busy', 'is-sub-section-open']);
[2098] Fix | Delete
this.contentContainer.closest('.wp-full-overlay').addClass('section-open');
[2099] Fix | Delete
this.contentContainer.removeClass('open');
[2100] Fix | Delete
}
[2101] Fix | Delete
const handleTransitionEnd = () => {
[2102] Fix | Delete
this.contentContainer.removeClass('busy');
[2103] Fix | Delete
args.completeCallback();
[2104] Fix | Delete
};
[2105] Fix | Delete
if (isReducedMotion) {
[2106] Fix | Delete
handleTransitionEnd();
[2107] Fix | Delete
} else {
[2108] Fix | Delete
this.contentContainer.one('transitionend', handleTransitionEnd);
[2109] Fix | Delete
}
[2110] Fix | Delete
} else {
[2111] Fix | Delete
super.onChangeExpanded(expanded, args);
[2112] Fix | Delete
}
[2113] Fix | Delete
}
[2114] Fix | Delete
};
[2115] Fix | Delete
}
[2116] Fix | Delete
[2117] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/sidebar-adapter.js
[2118] Fix | Delete
/**
[2119] Fix | Delete
* Internal dependencies
[2120] Fix | Delete
*/
[2121] Fix | Delete
[2122] Fix | Delete
const {
[2123] Fix | Delete
wp
[2124] Fix | Delete
} = window;
[2125] Fix | Delete
function parseWidgetId(widgetId) {
[2126] Fix | Delete
const matches = widgetId.match(/^(.+)-(\d+)$/);
[2127] Fix | Delete
if (matches) {
[2128] Fix | Delete
return {
[2129] Fix | Delete
idBase: matches[1],
[2130] Fix | Delete
number: parseInt(matches[2], 10)
[2131] Fix | Delete
};
[2132] Fix | Delete
}
[2133] Fix | Delete
[2134] Fix | Delete
// Likely an old single widget.
[2135] Fix | Delete
return {
[2136] Fix | Delete
idBase: widgetId
[2137] Fix | Delete
};
[2138] Fix | Delete
}
[2139] Fix | Delete
function widgetIdToSettingId(widgetId) {
[2140] Fix | Delete
const {
[2141] Fix | Delete
idBase,
[2142] Fix | Delete
number
[2143] Fix | Delete
} = parseWidgetId(widgetId);
[2144] Fix | Delete
if (number) {
[2145] Fix | Delete
return `widget_${idBase}[${number}]`;
[2146] Fix | Delete
}
[2147] Fix | Delete
return `widget_${idBase}`;
[2148] Fix | Delete
}
[2149] Fix | Delete
[2150] Fix | Delete
/**
[2151] Fix | Delete
* This is a custom debounce function to call different callbacks depending on
[2152] Fix | Delete
* whether it's the _leading_ call or not.
[2153] Fix | Delete
*
[2154] Fix | Delete
* @param {Function} leading The callback that gets called first.
[2155] Fix | Delete
* @param {Function} callback The callback that gets called after the first time.
[2156] Fix | Delete
* @param {number} timeout The debounced time in milliseconds.
[2157] Fix | Delete
* @return {Function} The debounced function.
[2158] Fix | Delete
*/
[2159] Fix | Delete
function debounce(leading, callback, timeout) {
[2160] Fix | Delete
let isLeading = false;
[2161] Fix | Delete
let timerID;
[2162] Fix | Delete
function debounced(...args) {
[2163] Fix | Delete
const result = (isLeading ? callback : leading).apply(this, args);
[2164] Fix | Delete
isLeading = true;
[2165] Fix | Delete
clearTimeout(timerID);
[2166] Fix | Delete
timerID = setTimeout(() => {
[2167] Fix | Delete
isLeading = false;
[2168] Fix | Delete
}, timeout);
[2169] Fix | Delete
return result;
[2170] Fix | Delete
}
[2171] Fix | Delete
debounced.cancel = () => {
[2172] Fix | Delete
isLeading = false;
[2173] Fix | Delete
clearTimeout(timerID);
[2174] Fix | Delete
};
[2175] Fix | Delete
return debounced;
[2176] Fix | Delete
}
[2177] Fix | Delete
class SidebarAdapter {
[2178] Fix | Delete
constructor(setting, api) {
[2179] Fix | Delete
this.setting = setting;
[2180] Fix | Delete
this.api = api;
[2181] Fix | Delete
this.locked = false;
[2182] Fix | Delete
this.widgetsCache = new WeakMap();
[2183] Fix | Delete
this.subscribers = new Set();
[2184] Fix | Delete
this.history = [this._getWidgetIds().map(widgetId => this.getWidget(widgetId))];
[2185] Fix | Delete
this.historyIndex = 0;
[2186] Fix | Delete
this.historySubscribers = new Set();
[2187] Fix | Delete
// Debounce the input for 1 second.
[2188] Fix | Delete
this._debounceSetHistory = debounce(this._pushHistory, this._replaceHistory, 1000);
[2189] Fix | Delete
this.setting.bind(this._handleSettingChange.bind(this));
[2190] Fix | Delete
this.api.bind('change', this._handleAllSettingsChange.bind(this));
[2191] Fix | Delete
this.undo = this.undo.bind(this);
[2192] Fix | Delete
this.redo = this.redo.bind(this);
[2193] Fix | Delete
this.save = this.save.bind(this);
[2194] Fix | Delete
}
[2195] Fix | Delete
subscribe(callback) {
[2196] Fix | Delete
this.subscribers.add(callback);
[2197] Fix | Delete
return () => {
[2198] Fix | Delete
this.subscribers.delete(callback);
[2199] Fix | Delete
};
[2200] Fix | Delete
}
[2201] Fix | Delete
getWidgets() {
[2202] Fix | Delete
return this.history[this.historyIndex];
[2203] Fix | Delete
}
[2204] Fix | Delete
_emit(...args) {
[2205] Fix | Delete
for (const callback of this.subscribers) {
[2206] Fix | Delete
callback(...args);
[2207] Fix | Delete
}
[2208] Fix | Delete
}
[2209] Fix | Delete
_getWidgetIds() {
[2210] Fix | Delete
return this.setting.get();
[2211] Fix | Delete
}
[2212] Fix | Delete
_pushHistory() {
[2213] Fix | Delete
this.history = [...this.history.slice(0, this.historyIndex + 1), this._getWidgetIds().map(widgetId => this.getWidget(widgetId))];
[2214] Fix | Delete
this.historyIndex += 1;
[2215] Fix | Delete
this.historySubscribers.forEach(listener => listener());
[2216] Fix | Delete
}
[2217] Fix | Delete
_replaceHistory() {
[2218] Fix | Delete
this.history[this.historyIndex] = this._getWidgetIds().map(widgetId => this.getWidget(widgetId));
[2219] Fix | Delete
}
[2220] Fix | Delete
_handleSettingChange() {
[2221] Fix | Delete
if (this.locked) {
[2222] Fix | Delete
return;
[2223] Fix | Delete
}
[2224] Fix | Delete
const prevWidgets = this.getWidgets();
[2225] Fix | Delete
this._pushHistory();
[2226] Fix | Delete
this._emit(prevWidgets, this.getWidgets());
[2227] Fix | Delete
}
[2228] Fix | Delete
_handleAllSettingsChange(setting) {
[2229] Fix | Delete
if (this.locked) {
[2230] Fix | Delete
return;
[2231] Fix | Delete
}
[2232] Fix | Delete
if (!setting.id.startsWith('widget_')) {
[2233] Fix | Delete
return;
[2234] Fix | Delete
}
[2235] Fix | Delete
const widgetId = settingIdToWidgetId(setting.id);
[2236] Fix | Delete
if (!this.setting.get().includes(widgetId)) {
[2237] Fix | Delete
return;
[2238] Fix | Delete
}
[2239] Fix | Delete
const prevWidgets = this.getWidgets();
[2240] Fix | Delete
this._pushHistory();
[2241] Fix | Delete
this._emit(prevWidgets, this.getWidgets());
[2242] Fix | Delete
}
[2243] Fix | Delete
_createWidget(widget) {
[2244] Fix | Delete
const widgetModel = wp.customize.Widgets.availableWidgets.findWhere({
[2245] Fix | Delete
id_base: widget.idBase
[2246] Fix | Delete
});
[2247] Fix | Delete
let number = widget.number;
[2248] Fix | Delete
if (widgetModel.get('is_multi') && !number) {
[2249] Fix | Delete
widgetModel.set('multi_number', widgetModel.get('multi_number') + 1);
[2250] Fix | Delete
number = widgetModel.get('multi_number');
[2251] Fix | Delete
}
[2252] Fix | Delete
const settingId = number ? `widget_${widget.idBase}[${number}]` : `widget_${widget.idBase}`;
[2253] Fix | Delete
const settingArgs = {
[2254] Fix | Delete
transport: wp.customize.Widgets.data.selectiveRefreshableWidgets[widgetModel.get('id_base')] ? 'postMessage' : 'refresh',
[2255] Fix | Delete
previewer: this.setting.previewer
[2256] Fix | Delete
};
[2257] Fix | Delete
const setting = this.api.create(settingId, settingId, '', settingArgs);
[2258] Fix | Delete
setting.set(widget.instance);
[2259] Fix | Delete
const widgetId = settingIdToWidgetId(settingId);
[2260] Fix | Delete
return widgetId;
[2261] Fix | Delete
}
[2262] Fix | Delete
_removeWidget(widget) {
[2263] Fix | Delete
const settingId = widgetIdToSettingId(widget.id);
[2264] Fix | Delete
const setting = this.api(settingId);
[2265] Fix | Delete
if (setting) {
[2266] Fix | Delete
const instance = setting.get();
[2267] Fix | Delete
this.widgetsCache.delete(instance);
[2268] Fix | Delete
}
[2269] Fix | Delete
this.api.remove(settingId);
[2270] Fix | Delete
}
[2271] Fix | Delete
_updateWidget(widget) {
[2272] Fix | Delete
const prevWidget = this.getWidget(widget.id);
[2273] Fix | Delete
[2274] Fix | Delete
// Bail out update if nothing changed.
[2275] Fix | Delete
if (prevWidget === widget) {
[2276] Fix | Delete
return widget.id;
[2277] Fix | Delete
}
[2278] Fix | Delete
[2279] Fix | Delete
// Update existing setting if only the widget's instance changed.
[2280] Fix | Delete
if (prevWidget.idBase && widget.idBase && prevWidget.idBase === widget.idBase) {
[2281] Fix | Delete
const settingId = widgetIdToSettingId(widget.id);
[2282] Fix | Delete
this.api(settingId).set(widget.instance);
[2283] Fix | Delete
return widget.id;
[2284] Fix | Delete
}
[2285] Fix | Delete
[2286] Fix | Delete
// Otherwise delete and re-create.
[2287] Fix | Delete
this._removeWidget(widget);
[2288] Fix | Delete
return this._createWidget(widget);
[2289] Fix | Delete
}
[2290] Fix | Delete
getWidget(widgetId) {
[2291] Fix | Delete
if (!widgetId) {
[2292] Fix | Delete
return null;
[2293] Fix | Delete
}
[2294] Fix | Delete
const {
[2295] Fix | Delete
idBase,
[2296] Fix | Delete
number
[2297] Fix | Delete
} = parseWidgetId(widgetId);
[2298] Fix | Delete
const settingId = widgetIdToSettingId(widgetId);
[2299] Fix | Delete
const setting = this.api(settingId);
[2300] Fix | Delete
if (!setting) {
[2301] Fix | Delete
return null;
[2302] Fix | Delete
}
[2303] Fix | Delete
const instance = setting.get();
[2304] Fix | Delete
if (this.widgetsCache.has(instance)) {
[2305] Fix | Delete
return this.widgetsCache.get(instance);
[2306] Fix | Delete
}
[2307] Fix | Delete
const widget = {
[2308] Fix | Delete
id: widgetId,
[2309] Fix | Delete
idBase,
[2310] Fix | Delete
number,
[2311] Fix | Delete
instance
[2312] Fix | Delete
};
[2313] Fix | Delete
this.widgetsCache.set(instance, widget);
[2314] Fix | Delete
return widget;
[2315] Fix | Delete
}
[2316] Fix | Delete
_updateWidgets(nextWidgets) {
[2317] Fix | Delete
this.locked = true;
[2318] Fix | Delete
const addedWidgetIds = [];
[2319] Fix | Delete
const nextWidgetIds = nextWidgets.map(nextWidget => {
[2320] Fix | Delete
if (nextWidget.id && this.getWidget(nextWidget.id)) {
[2321] Fix | Delete
addedWidgetIds.push(null);
[2322] Fix | Delete
return this._updateWidget(nextWidget);
[2323] Fix | Delete
}
[2324] Fix | Delete
const widgetId = this._createWidget(nextWidget);
[2325] Fix | Delete
addedWidgetIds.push(widgetId);
[2326] Fix | Delete
return widgetId;
[2327] Fix | Delete
});
[2328] Fix | Delete
const deletedWidgets = this.getWidgets().filter(widget => !nextWidgetIds.includes(widget.id));
[2329] Fix | Delete
deletedWidgets.forEach(widget => this._removeWidget(widget));
[2330] Fix | Delete
this.setting.set(nextWidgetIds);
[2331] Fix | Delete
this.locked = false;
[2332] Fix | Delete
return addedWidgetIds;
[2333] Fix | Delete
}
[2334] Fix | Delete
setWidgets(nextWidgets) {
[2335] Fix | Delete
const addedWidgetIds = this._updateWidgets(nextWidgets);
[2336] Fix | Delete
this._debounceSetHistory();
[2337] Fix | Delete
return addedWidgetIds;
[2338] Fix | Delete
}
[2339] Fix | Delete
[2340] Fix | Delete
/**
[2341] Fix | Delete
* Undo/Redo related features
[2342] Fix | Delete
*/
[2343] Fix | Delete
hasUndo() {
[2344] Fix | Delete
return this.historyIndex > 0;
[2345] Fix | Delete
}
[2346] Fix | Delete
hasRedo() {
[2347] Fix | Delete
return this.historyIndex < this.history.length - 1;
[2348] Fix | Delete
}
[2349] Fix | Delete
_seek(historyIndex) {
[2350] Fix | Delete
const currentWidgets = this.getWidgets();
[2351] Fix | Delete
this.historyIndex = historyIndex;
[2352] Fix | Delete
const widgets = this.history[this.historyIndex];
[2353] Fix | Delete
this._updateWidgets(widgets);
[2354] Fix | Delete
this._emit(currentWidgets, this.getWidgets());
[2355] Fix | Delete
this.historySubscribers.forEach(listener => listener());
[2356] Fix | Delete
this._debounceSetHistory.cancel();
[2357] Fix | Delete
}
[2358] Fix | Delete
undo() {
[2359] Fix | Delete
if (!this.hasUndo()) {
[2360] Fix | Delete
return;
[2361] Fix | Delete
}
[2362] Fix | Delete
this._seek(this.historyIndex - 1);
[2363] Fix | Delete
}
[2364] Fix | Delete
redo() {
[2365] Fix | Delete
if (!this.hasRedo()) {
[2366] Fix | Delete
return;
[2367] Fix | Delete
}
[2368] Fix | Delete
this._seek(this.historyIndex + 1);
[2369] Fix | Delete
}
[2370] Fix | Delete
subscribeHistory(listener) {
[2371] Fix | Delete
this.historySubscribers.add(listener);
[2372] Fix | Delete
return () => {
[2373] Fix | Delete
this.historySubscribers.delete(listener);
[2374] Fix | Delete
};
[2375] Fix | Delete
}
[2376] Fix | Delete
save() {
[2377] Fix | Delete
this.api.previewer.save();
[2378] Fix | Delete
}
[2379] Fix | Delete
}
[2380] Fix | Delete
[2381] Fix | Delete
;// CONCATENATED MODULE: external ["wp","dom"]
[2382] Fix | Delete
const external_wp_dom_namespaceObject = window["wp"]["dom"];
[2383] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/inserter-outer-section.js
[2384] Fix | Delete
/**
[2385] Fix | Delete
* WordPress dependencies
[2386] Fix | Delete
*/
[2387] Fix | Delete
[2388] Fix | Delete
[2389] Fix | Delete
[2390] Fix | Delete
[2391] Fix | Delete
/**
[2392] Fix | Delete
* Internal dependencies
[2393] Fix | Delete
*/
[2394] Fix | Delete
[2395] Fix | Delete
function getInserterOuterSection() {
[2396] Fix | Delete
const {
[2397] Fix | Delete
wp: {
[2398] Fix | Delete
customize
[2399] Fix | Delete
}
[2400] Fix | Delete
} = window;
[2401] Fix | Delete
const OuterSection = customize.OuterSection;
[2402] Fix | Delete
// Override the OuterSection class to handle multiple outer sections.
[2403] Fix | Delete
// It closes all the other outer sections whenever one is opened.
[2404] Fix | Delete
// The result is that at most one outer section can be opened at the same time.
[2405] Fix | Delete
customize.OuterSection = class extends OuterSection {
[2406] Fix | Delete
onChangeExpanded(expanded, args) {
[2407] Fix | Delete
if (expanded) {
[2408] Fix | Delete
customize.section.each(section => {
[2409] Fix | Delete
if (section.params.type === 'outer' && section.id !== this.id) {
[2410] Fix | Delete
if (section.expanded()) {
[2411] Fix | Delete
section.collapse();
[2412] Fix | Delete
}
[2413] Fix | Delete
}
[2414] Fix | Delete
});
[2415] Fix | Delete
}
[2416] Fix | Delete
return super.onChangeExpanded(expanded, args);
[2417] Fix | Delete
}
[2418] Fix | Delete
};
[2419] Fix | Delete
// Handle constructor so that "params.type" can be correctly pointed to "outer".
[2420] Fix | Delete
customize.sectionConstructor.outer = customize.OuterSection;
[2421] Fix | Delete
return class InserterOuterSection extends customize.OuterSection {
[2422] Fix | Delete
constructor(...args) {
[2423] Fix | Delete
super(...args);
[2424] Fix | Delete
[2425] Fix | Delete
// This is necessary since we're creating a new class which is not identical to the original OuterSection.
[2426] Fix | Delete
// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
[2427] Fix | Delete
this.params.type = 'outer';
[2428] Fix | Delete
this.activeElementBeforeExpanded = null;
[2429] Fix | Delete
const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
[2430] Fix | Delete
[2431] Fix | Delete
// Handle closing the inserter when pressing the Escape key.
[2432] Fix | Delete
ownerWindow.addEventListener('keydown', event => {
[2433] Fix | Delete
if (this.expanded() && (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE || event.code === 'Escape') && !event.defaultPrevented) {
[2434] Fix | Delete
event.preventDefault();
[2435] Fix | Delete
event.stopPropagation();
[2436] Fix | Delete
(0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(false);
[2437] Fix | Delete
}
[2438] Fix | Delete
},
[2439] Fix | Delete
// Use capture mode to make this run before other event listeners.
[2440] Fix | Delete
true);
[2441] Fix | Delete
this.contentContainer.addClass('widgets-inserter');
[2442] Fix | Delete
[2443] Fix | Delete
// Set a flag if the state is being changed from open() or close().
[2444] Fix | Delete
// Don't propagate the event if it's an internal action to prevent infinite loop.
[2445] Fix | Delete
this.isFromInternalAction = false;
[2446] Fix | Delete
this.expanded.bind(() => {
[2447] Fix | Delete
if (!this.isFromInternalAction) {
[2448] Fix | Delete
// Propagate the event to React to sync the state.
[2449] Fix | Delete
(0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(this.expanded());
[2450] Fix | Delete
}
[2451] Fix | Delete
this.isFromInternalAction = false;
[2452] Fix | Delete
});
[2453] Fix | Delete
}
[2454] Fix | Delete
open() {
[2455] Fix | Delete
if (!this.expanded()) {
[2456] Fix | Delete
const contentContainer = this.contentContainer[0];
[2457] Fix | Delete
this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement;
[2458] Fix | Delete
this.isFromInternalAction = true;
[2459] Fix | Delete
this.expand({
[2460] Fix | Delete
completeCallback() {
[2461] Fix | Delete
// We have to do this in a "completeCallback" or else the elements will not yet be visible/tabbable.
[2462] Fix | Delete
// The first one should be the close button,
[2463] Fix | Delete
// we want to skip it and choose the second one instead, which is the search box.
[2464] Fix | Delete
const searchBox = external_wp_dom_namespaceObject.focus.tabbable.find(contentContainer)[1];
[2465] Fix | Delete
if (searchBox) {
[2466] Fix | Delete
searchBox.focus();
[2467] Fix | Delete
}
[2468] Fix | Delete
}
[2469] Fix | Delete
});
[2470] Fix | Delete
}
[2471] Fix | Delete
}
[2472] Fix | Delete
close() {
[2473] Fix | Delete
if (this.expanded()) {
[2474] Fix | Delete
const contentContainer = this.contentContainer[0];
[2475] Fix | Delete
const activeElement = contentContainer.ownerDocument.activeElement;
[2476] Fix | Delete
this.isFromInternalAction = true;
[2477] Fix | Delete
this.collapse({
[2478] Fix | Delete
completeCallback() {
[2479] Fix | Delete
// Return back the focus when closing the inserter.
[2480] Fix | Delete
// Only do this if the active element which triggers the action is inside the inserter,
[2481] Fix | Delete
// (the close button for instance). In that case the focus will be lost.
[2482] Fix | Delete
// Otherwise, we don't hijack the focus when the user is focusing on other elements
[2483] Fix | Delete
// (like the quick inserter).
[2484] Fix | Delete
if (contentContainer.contains(activeElement)) {
[2485] Fix | Delete
// Return back the focus when closing the inserter.
[2486] Fix | Delete
if (this.activeElementBeforeExpanded) {
[2487] Fix | Delete
this.activeElementBeforeExpanded.focus();
[2488] Fix | Delete
}
[2489] Fix | Delete
}
[2490] Fix | Delete
}
[2491] Fix | Delete
});
[2492] Fix | Delete
}
[2493] Fix | Delete
}
[2494] Fix | Delete
};
[2495] Fix | Delete
}
[2496] Fix | Delete
[2497] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/sidebar-control.js
[2498] Fix | Delete
/**
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function