Plugin Directory

Changeset 2888166


Ignore:
Timestamp:
03/28/2023 08:48:56 AM (3 years ago)
Author:
followalter
Message:

Fix dashboard bug, es5 syntax

Location:
admin-sticky-sidebar
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • admin-sticky-sidebar/trunk/admin-sticky-sidebar.css

    r2885551 r2888166  
    11/* make right sided elements sticky on post.php page */
    2 #post-body-content {
     2.body--ass #post-body-content {
    33  float: none;
    44  margin-bottom: 40px;
    55}
    66
    7 #postbox-container-1 {
     7.body--ass #postbox-container-1 {
    88  position: sticky;
     9  z-index: 1;
    910  top: 50px; /* overwritten in js */
    1011  right: 20px;
    11   z-index: 1;
    1212
     13  height: 0;
    1314  margin-top: -92px; /* overwritten in js */
    1415  margin-left: auto;
    15 
    16   height: 0;
    1716
    1817  transition: top 0.2s;
    1918}
    2019
    21 #postbox-container-2 {
     20.body--ass #postbox-container-2 {
    2221  float: none;
    2322}
    2423
    25 #postbox-container-2 .inside {
     24.body--ass #postbox-container-2 .inside {
    2625  display: inline-block;
    27 
    2826  width: 100%;
    2927}
    3028
    3129@media (max-width: 1200px) {
    32   .post-type-attachment #postbox-container-1 {
     30  .body--ass .post-type-attachment #postbox-container-1 {
     31    height: auto;
    3332    margin-top: 0 !important;
    34 
    35     height: auto;
    3633  }
    3734}
    3835
    3936@media (max-width: 850px) {
    40   #postbox-container-1 {
     37  .body--ass #postbox-container-1 {
     38    height: auto;
    4139    margin-top: 0 !important;
    42 
    43     height: auto;
    4440  }
    4541
    46   #postbox-container-2 {
     42  .body--ass #postbox-container-2 {
    4743    float: left;
    4844  }
  • admin-sticky-sidebar/trunk/admin-sticky-sidebar.js

    r2885551 r2888166  
    11// makes the right sidebar on post.php sticky, if needed to the bottom ---------
    2 function assResizeHandler() {
     2const assResizeHandler = () => {
    33  // console.log('assResizeHandler');
    44
    5   var submitEl = document.getElementById('submitdiv');
     5  let submitEl = document.getElementById('submitdiv');
    66  if (submitEl === null) return;
    77
     8  document.body.classList.add('body--ass');
     9
    810  // elements available?
    9   var sideEl = document.getElementById('side-sortables');
    10   var sidePosEl = document.getElementById('postbox-container-1');
     11  let sideEl = document.getElementById('side-sortables');
     12  let sidePosEl = document.getElementById('postbox-container-1');
    1113  if (sideEl === null || sidePosEl === null) return;
    1214
    1315  // get heights
    14   var sideHeight = sideEl.offsetHeight;
    15   var sideSpace = window.innerHeight - 50;
     16  let sideHeight = sideEl.offsetHeight;
     17  let sideSpace = window.innerHeight - 50;
    1618
    1719  // if the sidebar is larger than the available space
     
    2931
    3032  // also set margin top in case of weird elements oreder
    31   var postBody = document.getElementById('post-body-content');
     33  let postBody = document.getElementById('post-body-content');
    3234  if (postBody === null) {
    3335    sidePosEl.style['margin-top'] = '0';
     
    3537    sidePosEl.style['margin-top'] = -postBody.offsetHeight - 20 + 'px';
    3638  }
    37 }
     39};
    3840
    3941// 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');
     42const assGotoPrevScroll = () => {
     43  let prevScrollpos = localStorage.getItem('prev_scrollpos');
     44  let prevUrl = localStorage.getItem('prev_url');
    4345
    4446  // both vars exist and scrollpos is not 0
    45   if (prev_scrollpos && prev_url) {
     47  if (prevScrollpos && prevUrl) {
    4648    // if on same url as previously
    47     if (window.location.href == prev_url) {
     49    if (window.location.href == prevUrl) {
    4850      // scroll to previous position
    49       window.scrollTo(0, prev_scrollpos);
     51      window.scrollTo(0, prevScrollpos);
    5052    }
    5153  }
    52 }
     54};
    5355
    5456// listeners and callers
     
    5759jQuery(window).on('resize', assResizeHandler);
    5860
    59 jQuery(window).load(function () {
     61jQuery(window).on('load', () => {
    6062  // console.log('load');
    6163
     
    6466
    6567  // add listener to sidebar size
    66   var sideEl = document.getElementById('side-sortables');
     68  let sideEl = document.getElementById('side-sortables');
    6769  if (sideEl !== null) new ResizeObserver(assResizeHandler).observe(sideEl);
    6870
    6971  // add listener to body size
    70   var bodyEl = document.getElementById('post-body-content');
     72  let bodyEl = document.getElementById('post-body-content');
    7173  if (bodyEl !== null) new ResizeObserver(assResizeHandler).observe(bodyEl);
    7274});
    7375
    74 jQuery(window).on('beforeunload', function () {
     76jQuery(window).on('beforeunload', () => {
    7577  localStorage.setItem('prev_scrollpos', window.scrollY);
    7678  localStorage.setItem('prev_url', window.location.href);
  • admin-sticky-sidebar/trunk/admin-sticky-sidebar.php

    r2885674 r2888166  
    33Plugin Name: Admin Sticky Sidebar
    44Description: Makes the sidebar follow you when you scroll and remembers scroll position on update. For more info, see the readme.
    5 Version: 1.5.1
     5Version: 1.5.2
    66Author: Tom Walter
    77Author URI: https://littlefragments.com
     
    1212function admin_sticky_sidebar_css($hook) {
    1313  // 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__ ));
    1515}
    1616add_action('admin_enqueue_scripts', 'admin_sticky_sidebar_css');
     
    2121function admin_sticky_sidebar_js($hook) {
    2222  // 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__ ));
    2424}
    2525add_action('admin_enqueue_scripts', 'admin_sticky_sidebar_js');
    26 
    27 ?>
  • admin-sticky-sidebar/trunk/readme.txt

    r2885674 r2888166  
    55Requires at least: 5.0
    66Tested up to: 6.0
    7 Stable tag: 1.5.1
     7Stable tag: 1.5.2
    88Requires PHP: 5.6
    99License: GPLv2 or later
     
    6464= 1.5.1 =
    6565* Cache bust
     66
     67= 1.5.2 =
     68* Fix dashboard bug, es5 syntax
Note: See TracChangeset for help on using the changeset viewer.