Advertisement
SergeyBiryukov

Untitled

Dec 2nd, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.24 KB | None | 0 0
  1. --- S:/home/wordpress/trunk/wp-content/plugins/preserve-editor-scroll-position/preserve-editor-scroll-position.old.php  Mon Dec  1 20:31:38 2014
  2. +++ S:/home/wordpress/trunk/wp-content/plugins/preserve-editor-scroll-position/preserve-editor-scroll-position.php  Mon Dec  1 20:44:12 2014
  3. @@ -47,7 +47,6 @@
  4.         add_filter( 'redirect_post_location', array( __CLASS__, 'add_query_arg' ) );
  5.         add_action( 'edit_form_advanced', array( __CLASS__, 'add_input_field' ) );
  6.         add_action( 'edit_page_form', array( __CLASS__, 'add_input_field' ) );
  7. -       add_filter( 'tiny_mce_before_init', array( __CLASS__, 'extend_tiny_mce' ) );
  8.         add_action( 'after_wp_tiny_mce', array( __CLASS__, 'print_js' ) );
  9.     }
  10.  
  11. @@ -64,23 +63,6 @@
  12.  
  13.  
  14.     /**
  15. -    * Extend TinyMCE config with a setup function.
  16. -    * See http://www.tinymce.com/wiki.php/API3:event.tinymce.Editor.onInit
  17. -    *
  18. -    * @since 0.1.0
  19. -    *
  20. -    * @param array $init
  21. -    * @return array
  22. -    */
  23. -   public static function extend_tiny_mce( $init ) {
  24. -       if ( wp_default_editor() == 'tinymce' )
  25. -           $init['setup'] = 'rich_scroll';
  26. -
  27. -       return $init;
  28. -   }
  29. -
  30. -
  31. -   /**
  32.      * Returns redirect url with query arg for scroll position.
  33.      *
  34.      * @since 0.1.0
  35. @@ -107,30 +89,19 @@
  36.  <script>
  37.  ( function( $ ) {
  38.     $( '#post' ).submit( function() {
  39. -       // TinyMCE or HTML Editor?
  40. -       scrollto =
  41. -           $('#content' ).is(':hidden') ?
  42. -           $('#content_ifr').contents().find( 'body' ).scrollTop() :
  43. -           $('#content' ).scrollTop();
  44. +       var scrollto = $( 'html' ).scrollTop();
  45.  
  46.         // Save scrollto value
  47.         $( '#scrollto' ).val( scrollto );
  48.     } );
  49.  
  50. -   // Only HTML editor: scroll to scrollto value
  51. -   $( '#content' ).scrollTop( $( '#scrollto' ).val() );
  52. +   // Scroll to scrollto value
  53. +   function scroll() {
  54. +       $( 'html' ).scrollTop( $( '#scrollto' ).val() );
  55. +   }
  56. +
  57. +   setTimeout( scroll, 1500 );
  58.  } )( jQuery );
  59. -<?php if ( wp_default_editor() == 'tinymce' && ! empty( $mce_settings ) ) : ?>
  60. -/*
  61. - * Callback function for TinyMCE setup event
  62. - * See http://www.tinymce.com/wiki.php/API3:event.tinymce.Editor.onInit
  63. - */
  64. -function rich_scroll( ed ) {
  65. -   ed.onInit.add( function() {
  66. -       jQuery( '#content_ifr' ).contents().find( 'body' ).scrollTop( jQuery( '#scrollto' ).val() );
  67. -   } );
  68. -};
  69. -<?php endif; ?>
  70.  </script>
  71.         <?php
  72.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement