Changeset 2888166
- Timestamp:
- 03/28/2023 08:48:56 AM (3 years ago)
- Location:
- admin-sticky-sidebar
- Files:
-
- 6 added
- 4 edited
-
tags/1.5.2 (added)
-
tags/1.5.2/LICENSE (added)
-
tags/1.5.2/admin-sticky-sidebar.css (added)
-
tags/1.5.2/admin-sticky-sidebar.js (added)
-
tags/1.5.2/admin-sticky-sidebar.php (added)
-
tags/1.5.2/readme.txt (added)
-
trunk/admin-sticky-sidebar.css (modified) (1 diff)
-
trunk/admin-sticky-sidebar.js (modified) (5 diffs)
-
trunk/admin-sticky-sidebar.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-sticky-sidebar/trunk/admin-sticky-sidebar.css
r2885551 r2888166 1 1 /* make right sided elements sticky on post.php page */ 2 #post-body-content {2 .body--ass #post-body-content { 3 3 float: none; 4 4 margin-bottom: 40px; 5 5 } 6 6 7 #postbox-container-1 {7 .body--ass #postbox-container-1 { 8 8 position: sticky; 9 z-index: 1; 9 10 top: 50px; /* overwritten in js */ 10 11 right: 20px; 11 z-index: 1;12 12 13 height: 0; 13 14 margin-top: -92px; /* overwritten in js */ 14 15 margin-left: auto; 15 16 height: 0;17 16 18 17 transition: top 0.2s; 19 18 } 20 19 21 #postbox-container-2 {20 .body--ass #postbox-container-2 { 22 21 float: none; 23 22 } 24 23 25 #postbox-container-2 .inside {24 .body--ass #postbox-container-2 .inside { 26 25 display: inline-block; 27 28 26 width: 100%; 29 27 } 30 28 31 29 @media (max-width: 1200px) { 32 .post-type-attachment #postbox-container-1 { 30 .body--ass .post-type-attachment #postbox-container-1 { 31 height: auto; 33 32 margin-top: 0 !important; 34 35 height: auto;36 33 } 37 34 } 38 35 39 36 @media (max-width: 850px) { 40 #postbox-container-1 { 37 .body--ass #postbox-container-1 { 38 height: auto; 41 39 margin-top: 0 !important; 42 43 height: auto;44 40 } 45 41 46 #postbox-container-2 {42 .body--ass #postbox-container-2 { 47 43 float: left; 48 44 } -
admin-sticky-sidebar/trunk/admin-sticky-sidebar.js
r2885551 r2888166 1 1 // makes the right sidebar on post.php sticky, if needed to the bottom --------- 2 function assResizeHandler(){2 const assResizeHandler = () => { 3 3 // console.log('assResizeHandler'); 4 4 5 varsubmitEl = document.getElementById('submitdiv');5 let submitEl = document.getElementById('submitdiv'); 6 6 if (submitEl === null) return; 7 7 8 document.body.classList.add('body--ass'); 9 8 10 // elements available? 9 varsideEl = document.getElementById('side-sortables');10 varsidePosEl = document.getElementById('postbox-container-1');11 let sideEl = document.getElementById('side-sortables'); 12 let sidePosEl = document.getElementById('postbox-container-1'); 11 13 if (sideEl === null || sidePosEl === null) return; 12 14 13 15 // get heights 14 varsideHeight = sideEl.offsetHeight;15 varsideSpace = window.innerHeight - 50;16 let sideHeight = sideEl.offsetHeight; 17 let sideSpace = window.innerHeight - 50; 16 18 17 19 // if the sidebar is larger than the available space … … 29 31 30 32 // also set margin top in case of weird elements oreder 31 varpostBody = document.getElementById('post-body-content');33 let postBody = document.getElementById('post-body-content'); 32 34 if (postBody === null) { 33 35 sidePosEl.style['margin-top'] = '0'; … … 35 37 sidePosEl.style['margin-top'] = -postBody.offsetHeight - 20 + 'px'; 36 38 } 37 } 39 }; 38 40 39 41 // go back to previous scroll position if remaining on same post --------------- 40 function assGotoPrevScroll(){41 var prev_scrollpos = localStorage.getItem('prev_scrollpos');42 var prev_url = localStorage.getItem('prev_url');42 const assGotoPrevScroll = () => { 43 let prevScrollpos = localStorage.getItem('prev_scrollpos'); 44 let prevUrl = localStorage.getItem('prev_url'); 43 45 44 46 // both vars exist and scrollpos is not 0 45 if (prev _scrollpos && prev_url) {47 if (prevScrollpos && prevUrl) { 46 48 // if on same url as previously 47 if (window.location.href == prev _url) {49 if (window.location.href == prevUrl) { 48 50 // scroll to previous position 49 window.scrollTo(0, prev _scrollpos);51 window.scrollTo(0, prevScrollpos); 50 52 } 51 53 } 52 } 54 }; 53 55 54 56 // listeners and callers … … 57 59 jQuery(window).on('resize', assResizeHandler); 58 60 59 jQuery(window). load(function (){61 jQuery(window).on('load', () => { 60 62 // console.log('load'); 61 63 … … 64 66 65 67 // add listener to sidebar size 66 varsideEl = document.getElementById('side-sortables');68 let sideEl = document.getElementById('side-sortables'); 67 69 if (sideEl !== null) new ResizeObserver(assResizeHandler).observe(sideEl); 68 70 69 71 // add listener to body size 70 varbodyEl = document.getElementById('post-body-content');72 let bodyEl = document.getElementById('post-body-content'); 71 73 if (bodyEl !== null) new ResizeObserver(assResizeHandler).observe(bodyEl); 72 74 }); 73 75 74 jQuery(window).on('beforeunload', function (){76 jQuery(window).on('beforeunload', () => { 75 77 localStorage.setItem('prev_scrollpos', window.scrollY); 76 78 localStorage.setItem('prev_url', window.location.href); -
admin-sticky-sidebar/trunk/admin-sticky-sidebar.php
r2885674 r2888166 3 3 Plugin Name: Admin Sticky Sidebar 4 4 Description: Makes the sidebar follow you when you scroll and remembers scroll position on update. For more info, see the readme. 5 Version: 1.5. 15 Version: 1.5.2 6 6 Author: Tom Walter 7 7 Author URI: https://littlefragments.com … … 12 12 function admin_sticky_sidebar_css($hook) { 13 13 // only add to the post.php admin page. 14 wp_enqueue_style( 'admin-sticky-sidebar-style', plugins_url( 'admin-sticky-sidebar.css?v=1.5. 1' , __FILE__ ));14 wp_enqueue_style( 'admin-sticky-sidebar-style', plugins_url( 'admin-sticky-sidebar.css?v=1.5.2' , __FILE__ )); 15 15 } 16 16 add_action('admin_enqueue_scripts', 'admin_sticky_sidebar_css'); … … 21 21 function admin_sticky_sidebar_js($hook) { 22 22 // only add to the post.php admin page. 23 wp_enqueue_script('admin-sticky-sidebar-script', plugins_url( 'admin-sticky-sidebar.js?v=1.5. 1' , __FILE__ ));23 wp_enqueue_script('admin-sticky-sidebar-script', plugins_url( 'admin-sticky-sidebar.js?v=1.5.2' , __FILE__ )); 24 24 } 25 25 add_action('admin_enqueue_scripts', 'admin_sticky_sidebar_js'); 26 27 ?> -
admin-sticky-sidebar/trunk/readme.txt
r2885674 r2888166 5 5 Requires at least: 5.0 6 6 Tested up to: 6.0 7 Stable tag: 1.5. 17 Stable tag: 1.5.2 8 8 Requires PHP: 5.6 9 9 License: GPLv2 or later … … 64 64 = 1.5.1 = 65 65 * Cache bust 66 67 = 1.5.2 = 68 * Fix dashboard bug, es5 syntax
Note: See TracChangeset
for help on using the changeset viewer.