Make WordPress Core

Ticket #26907: 26907 V2.patch

File 26907 V2.patch, 6.6 KB (added by GregRoss, 11 years ago)

Minor update to previous patch to resolve inverted logic for the user preference.

  • wp-admin/includes/user.php

     
    9292
    9393        if ( $update ) {
    9494                $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
     95                $user->dfw_mouse = isset( $_POST['dfw_mouse'] ) && 'true' == $_POST['dfw_mouse'] ? 'true' : 'false';
    9596                $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
    9697                $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
    9798        }
  • wp-admin/js/wp-fullscreen.js

     
    1111                uiScrollTop = 0,
    1212                transitionend = 'transitionend webkitTransitionEnd',
    1313                $body = $( document.body ),
    14                 $document = $( document );
     14                $document = $( document ),
     15                MouseInToolbar = false;
    1516
    1617        /**
    1718         * PubSub
     
    101102                        $body.addClass('wp-dfw-show-ui');
    102103                }
    103104
    104                 if ( hide === 'hide' ) {
     105                if ( hide === 'hide' || hide === 'peak' ) {
    105106                        uiTimer = setTimeout( _hideUI, 2000 );
    106107                }
    107108        };
     
    198199                        s.$dfwTitle = null;
    199200                }
    200201
     202                /*
     203                        Bind mouse/touch events to the document root, this usually catches events anywhere on screen
     204                        *except* within TinyMCE.
     205
     206                        To capture events within TinyMCE's iframe we also have to bind to the iframe that TinyMCE creates
     207                        for it's contents.
     208
     209                        For the mouse capture on the document we don't ru toggleUI as otherwise it will cancel out the
     210                        behaviour of keeping the toolbar visible when the pointer is inside of it.
     211                */
     212                var wpfs_capture = wp_fullscreen_mouse();
     213               
     214                if( wpfs_capture == true ) {
     215                        var fs_body = $(document);
     216                       
     217                        // Show/hide the ui when a touch event happens anywhere on screen.
     218                        fs_body.on( 'touchstart.wpdfw', function() {
     219                                toggleUI('show');
     220                        }).on( 'touchend', function() {
     221                                toggleUI('hide');
     222                        });
     223
     224                        // Show the ui when the mouse moves.
     225                        fs_body.on( 'mousemove.wpdfw', function() {
     226                                if( MouseInToolbar == false ) {
     227                                        toggleUI('peak');
     228                                }
     229                        });
     230
     231                        // Bind to the iframe, we don't need to check if we're in the toolbar as we can't be, we're in the iframe ;)
     232                        var content_ifr = document.getElementById('content_ifr');
     233                        if( content_ifr != null ) {
     234                                content_ifr.contentWindow.document.onmousemove = function() {
     235                                        toggleUI('peak');
     236                                }
     237                        }
     238                }
     239               
    201240                api.ui.fade( 'show', 'showing', 'shown' );
    202241        };
    203242
     
    210249                if ( ! s.visible )
    211250                        return;
    212251
     252                var wpfs_capture = wp_fullscreen_mouse();
     253               
     254                if( wpfs_capture == true ) {
     255                        // Clear out the mouse/touch events we setup when we enabled fullscreen.
     256                        var fs_body = $(document);
     257                        fs_body.off( 'mousemove.wpdfw' );
     258                        fs_body.off( 'touchstart.wpdfw' );
     259
     260                        // Clear out the iframe mouse event we setup when we enabled fullscreen.
     261                        var content_ifr = document.getElementById('content_ifr');
     262                        if( content_ifr != null ) {
     263                                content_ifr.contentWindow.document.onmousemove = null;
     264                        }
     265                }
     266               
    213267                api.ui.fade( 'hide', 'hiding', 'hidden' );
    214268        };
    215269
     
    510564                                }
    511565                        });
    512566
     567                        // Show/hide the toolbar when entering/leaving it on the screen.
    513568                        toolbar.on( 'mouseenter', function() {
     569                                MouseInToolbar = true;
    514570                                toggleUI('show');
    515571                        }).on( 'mouseleave', function() {
     572                                MouseInToolbar = false;
    516573                                toggleUI('hide');
    517574                        });
    518 
     575                       
    519576                        // Bind buttons
    520577                        $('#wp-fullscreen-buttons').on( 'click.wp-fullscreen', 'button', function( event ) {
    521578                                var command = event.currentTarget.id ? event.currentTarget.id.substr(6) : null;
  • wp-admin/user-edit.php

     
    246246                <th scope="row"><?php _e('Visual Editor')?></th>
    247247                <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td>
    248248        </tr>
     249        <tr>
     250                <th scope="row"><?php _e('DFW Mouse')?></th>
     251                <td><label for="dfw_mouse"><input name="dfw_mouse" type="checkbox" id="dfw_mouse" value="true" <?php if ( ! empty( $profileuser->dfw_mouse ) ) checked( 'true', $profileuser->dfw_mouse ); ?> /> <?php _e( 'Disable showing the toolbar in Distraction Free Writing mode unless the mouse is inside the toolbar' ); ?></label></td>
     252        </tr>
    249253<?php endif; ?>
    250254<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
    251255<tr>
  • wp-includes/class-wp-editor.php

     
    835835                                }
    836836                        }
    837837                }());
     838               
     839                function wp_fullscreen_mouse() {
     840                        return <?php $dfw_mouse = get_user_option( 'dfw_mouse' ); if( $dfw_mouse === false ) { echo 'true'; } else { if( $dfw_mouse == 'true' ) { echo 'false'; } else { echo 'true'; } }?>;
     841                }
    838842                </script>
    839843                <?php
    840844
     
    892896                                continue;
    893897                        }
    894898
    895                         $onclick = ! empty( $args['onclick'] ) ? ' onclick="' . $args['onclick'] . '"' : '';
     899                        if( true == array_key_exists( 'customhtml', $args ) ) {
     900                                echo $args['customhtml'];
     901                        }
     902                        else {
     903                       
     904                                $onclick = ! empty( $args['onclick'] ) ? ' onclick="' . $args['onclick'] . '"' : '';
    896905                        ?>
    897906
    898907                        <div class="mce-widget mce-btn<?php if ( $args['both'] ) { ?> wp-fullscreen-both<?php } ?>">
     
    901910                        </button>
    902911                        </div>
    903912                        <?php
     913                        }
    904914                }
    905915
    906916                ?>
  • wp-includes/user.php

     
    16071607        if ( empty($rich_editing) )
    16081608                $rich_editing = 'true';
    16091609
     1610        if ( empty($dfw_mouse) )
     1611                $dfw_mouse = 'false';
     1612               
    16101613        if ( empty($comment_shortcuts) )
    16111614                $comment_shortcuts = 'false';
    16121615
     
    17801783 * @return array
    17811784 */
    17821785function _get_additional_user_keys( $user ) {
    1783         $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
     1786        $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'dfw_mouse' );
    17841787        return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
    17851788}
    17861789