PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.6.25
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.6.25
2.7.1 2.7.2 2.7.0 2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 All 141 releases
metasync / admin / js / metasync-admin-menu-height.js

metasync-admin-menu-height.js in Search Atlas SEO – OTTO AI SEO Automation for WordPress 2.6.25, at admin/js/metasync-admin-menu-height.js

51 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Keeps WordPress core's admin-menu pinning in sync with the real page height.
3 *
4 * Core measures #wpwrap once and reuses that figure to decide whether to pin
5 * the admin menu. Plugin pages change height after that measurement — tab
6 * panels being shown or hidden, list tables loading over AJAX, sections
7 * expanding — and core is never told. It then works from a stale height,
8 * concludes the page is too short to pin, and lets the menu scroll off-screen
9 * on a page that is in fact tall enough.
10 *
11 * Watching the document for height changes and re-firing the event core
12 * already listens for keeps the two in agreement, without having to patch
13 * every feature that changes layout.
14 *
15 * @package Metasync
16 */
17 (function ($) {
18 'use strict';
19
20 if (typeof window.ResizeObserver === 'undefined') {
21 return;
22 }
23
24 $(function () {
25 var lastHeight = document.documentElement.scrollHeight;
26 var pending = null;
27
28 function notifyCore() {
29 var height = document.documentElement.scrollHeight;
30
31 // Ignore sub-pixel churn so the observer cannot feed itself.
32 if (Math.abs(height - lastHeight) < 2) {
33 return;
34 }
35
36 lastHeight = height;
37 $(document).trigger('wp-window-resized');
38 }
39
40 function schedule() {
41 window.clearTimeout(pending);
42 pending = window.setTimeout(notifyCore, 100);
43 }
44
45 new window.ResizeObserver(schedule).observe(document.body);
46
47 // Late-loading fonts, images and iframes shift the page after ready.
48 $(window).on('load', schedule);
49 });
50 })(jQuery);
51