Make WordPress Core

Ticket #26086: 26086.diff

File 26086.diff, 10.4 KB (added by tollmanz, 13 years ago)

The patch described in the previous message

  • src/wp-admin/css/color-schemes/_admin.scss

    diff --git src/wp-admin/css/color-schemes/_admin.scss src/wp-admin/css/color-schemes/_admin.scss
    index f7a4bc2..0a467a4 100644
    ul#adminmenu > li.current > a.current:after { 
    366366
    367367/* Responsive Component */
    368368
    369 div#moby6-toggle a:before {
     369div#responsive-toggle a:before {
    370370        color: $menu-icon;
    371371}
    372372
    373 .moby6-open div#moby6-toggle a {
     373.responsive-open div#responsive-toggle a {
    374374        // ToDo: make inset border
    375375        border-color: transparent;
    376376        background: $menu-highlight-background;
  • src/wp-admin/css/wp-admin.css

    diff --git src/wp-admin/css/wp-admin.css src/wp-admin/css/wp-admin.css
    index fadb683..b67a721 100644
    li#wp-admin-bar-toggle-button { 
    1121111211                transition: left .05s ease-in-out, opacity .3s ease-in;
    1121211212        }
    1121311213
    11214         .auto-fold .moby6-open #adminmenu {
     11214        .auto-fold .responsive-open #adminmenu {
    1121511215                -moz-opacity: 1;
    1121611216                -webkit-opacity: 1;
    1121711217                opacity: 1;
    li#wp-admin-bar-toggle-button { 
    1128311283        }
    1128411284
    1128511285        /*  Sidebar Toggle */
    11286         #moby6-toggle {
     11286        #responsive-toggle {
    1128711287                position: fixed;
    1128811288                top: 5px;
    1128911289                left: 4px;
    li#wp-admin-bar-toggle-button { 
    1129811298                margin-top: -2px;
    1129911299        }
    1130011300
    11301         .moby6-open #wpadminbar #wp-admin-bar-toggle-button a {
     11301        .responsive-open #wpadminbar #wp-admin-bar-toggle-button a {
    1130211302                background: #000;
    1130311303        }
    1130411304
    11305         .moby6-open #wpbody {
     11305        .responsive-open #wpbody {
    1130611306                right: -190px;
    1130711307        }
    1130811308
    11309         .auto-fold .moby6-open #adminmenuback,
    11310         .auto-fold .moby6-open #adminmenuwrap {
     11309        .auto-fold .responsive-open #adminmenuback,
     11310        .auto-fold .responsive-open #adminmenuwrap {
    1131111311                left: 0;
    1131211312        }
    1131311313
    li#wp-admin-bar-toggle-button { 
    1237212372
    1237312373/* Smartphone */
    1237412374@media screen and (max-width: 480px) {
    12375         #moby6-overlay {
     12375        #responsive-overlay {
    1237612376                position: fixed;
    1237712377                top: 0;
    1237812378                left: 0;
  • src/wp-admin/js/common.js

    diff --git src/wp-admin/js/common.js src/wp-admin/js/common.js
    index 3406ee0..fa5b995 100644
     
    1 /* global setUserSetting, ajaxurl, commonL10n, alert, confirm, toggleWithKeyboard, pagenow */
    2 var showNotice, adminMenu, columns, validateForm, screenMeta, stickyMenu;
     1/* global setUserSetting, ajaxurl, commonL10n, alert, confirm, toggleWithKeyboard, pagenow, _ */
     2var showNotice, adminMenu, columns, validateForm, screenMeta, stickyMenu, responsive;
    33(function($){
    44// Removed in 3.3.
    55// (perhaps) needed for back-compat
    stickyMenu = { 
    461461
    462462        enable: function () {
    463463                if ( ! this.active ) {
    464                         this.$window.on( 'resize.stickyMenu scroll.stickyMenu', this.debounce(
     464                        this.$window.on( 'resize.stickyMenu scroll.stickyMenu', _.debounce(
    465465                                $.proxy( this.update, this ), 200
    466466                        ) );
    467467                        this.$collapseMenu.on( 'click.stickyMenu', $.proxy( this.update, this ) );
    stickyMenu = { 
    492492                                this.$body.removeClass( 'sticky-menu' );
    493493                        }
    494494                }
    495         },
    496 
    497         // Borrowed from Underscore.js
    498         debounce: function( func, wait, immediate ) {
    499                 var timeout, args, context, timestamp, result;
    500                 return function() {
    501                         var later, callNow;
    502                         context = this;
    503                         args = arguments;
    504                         timestamp = new Date().getTime();
    505                         later = function() {
    506                                 var last = new Date().getTime() - timestamp;
    507                                 if ( last < wait ) {
    508                                         timeout = setTimeout( later, wait - last );
    509                                 } else {
    510                                         timeout = null;
    511                                         if ( ! immediate ) {
    512                                                 result = func.apply( context, args );
    513                                                 context = args = null;
    514                                         }
    515                                 }
    516                         };
    517                         callNow = immediate && !timeout;
    518                         if ( ! timeout ) {
    519                                 timeout = setTimeout( later, wait );
    520                         }
    521                         if ( callNow ) {
    522                                 result = func.apply( context, args );
    523                                 context = args = null;
    524                         }
    525 
    526                         return result;
    527                 };
    528495        }
    529496};
    530497
    531498stickyMenu.init();
    532499
    533 var moby6 = {
     500responsive = {
    534501
    535502        init: function() {
    536503                // cached selectors
     504                this.$window = $( window );
    537505                this.$html = $( document.documentElement );
    538506                this.$body = $( document.body );
    539507                this.$wpwrap = $( '#wpwrap' );
    540508                this.$wpbody = $( '#wpbody' );
    541509                this.$adminmenu = $( '#adminmenu' );
    542                 this.$overlay = $( '#moby6-overlay' );
     510                this.$overlay = $( '#responsive-overlay' );
    543511                this.$toolbar = $( '#wp-toolbar' );
    544512                this.$toolbarPopups = this.$toolbar.find( 'a[aria-haspopup="true"]' );
    545513
    546514                // Modify functionality based on custom activate/deactivate event
    547515                this.$html
    548                         .on( 'activate.moby6', function() { moby6.activate(); } )
    549                         .on( 'deactivate.moby6', function() { moby6.deactivate(); } );
     516                        .on( 'activate.responsive', function() {
     517                                responsive.activate();
     518                        } )
     519                        .on( 'deactivate.responsive', function() {
     520                                responsive.deactivate();
     521                        } );
    550522
    551523                // Toggle sidebar when toggle is clicked
    552                 $( '#wp-admin-bar-toggle-button' ).on( 'click', function(evt) {
     524                $( '#wp-admin-bar-toggle-button' ).on( 'click', function( evt ) {
    553525                        evt.preventDefault();
    554                         moby6.$wpwrap.toggleClass( 'moby6-open' );
     526                        responsive.$wpwrap.toggleClass( 'responsive-open' );
    555527                } );
    556528
    557529                // Trigger custom events based on active media query.
    558                 this.matchMedia();
    559                 $( window ).on( 'resize', $.proxy( this.matchMedia, this ) );
     530                this.toggleElements();
     531                this.$window.on( 'resize', _.debounce(
     532                        $.proxy( this.toggleElements, this ), 150
     533                ) );
    560534        },
    561535
    562536        activate: function() {
     537                stickyMenu.disable();
    563538
    564                 window.stickymenu && window.stickymenu.disable();
    565 
    566                 if ( ! moby6.$body.hasClass( 'auto-fold' ) )
    567                         moby6.$body.addClass( 'auto-fold' );
     539                if ( ! this.$body.hasClass( 'auto-fold' ) ) {
     540                        this.$body.addClass( 'auto-fold' );
     541                }
    568542
    569543                this.modifySidebarEvents();
    570544                this.disableDraggables();
    571545                this.movePostSearch();
    572 
    573546        },
    574547
    575548        deactivate: function() {
    576 
    577                 window.stickymenu && window.stickymenu.enable();
    578 
     549                stickyMenu.enable();
    579550                this.enableDraggables();
    580                 this.removeHamburgerButton();
    581551                this.restorePostSearch();
    582 
    583552        },
    584553
    585         matchMedia: function() {
    586                 clearTimeout( this.resizeTimeout );
    587                 this.resizeTimeout = setTimeout( function() {
    588 
    589                         if ( ! window.matchMedia )
     554        toggleElements: function() {
     555                var width = this.$window.width();
     556                if ( width <= 782 ) {
     557                        if ( responsive.$html.hasClass( 'touch' ) ) {
    590558                                return;
    591 
    592                         if ( window.matchMedia( '(max-width: 782px)' ).matches ) {
    593                                 if ( moby6.$html.hasClass( 'touch' ) )
    594                                         return;
    595                                 moby6.$html.addClass( 'touch' ).trigger( 'activate.moby6' );
    596                         } else {
    597                                 if ( ! moby6.$html.hasClass( 'touch' ) )
    598                                         return;
    599                                 moby6.$html.removeClass( 'touch' ).trigger( 'deactivate.moby6' );
    600559                        }
    601560
    602                         if ( window.matchMedia( '(max-width: 480px)' ).matches ) {
    603                                 moby6.enableOverlay();
    604                         } else {
    605                                 moby6.disableOverlay();
     561                        responsive.$html.addClass( 'touch' ).trigger( 'activate.responsive' );
     562                } else {
     563                        if ( ! responsive.$html.hasClass( 'touch' ) ) {
     564                                return;
    606565                        }
    607566
    608                 }, 150 );
     567                        responsive.$html.removeClass( 'touch' ).trigger( 'deactivate.responsive' );
     568                }
     569
     570                if ( width <= 480 ) {
     571                        responsive.enableOverlay();
     572                } else {
     573                        responsive.disableOverlay();
     574                }
    609575        },
    610576
    611577        enableOverlay: function() {
    612578                if ( this.$overlay.length === 0 ) {
    613                         this.$overlay = $( '<div id="moby6-overlay"></div>' )
     579                        this.$overlay = $( '<div id="responsive-overlay"></div>' )
    614580                                .insertAfter( '#wpcontent' )
    615581                                .hide()
    616                                 .on( 'click.moby6', function() {
    617                                         moby6.$toolbar.find( '.menupop.hover' ).removeClass( 'hover' );
     582                                .on( 'click.responsive', function() {
     583                                        responsive.$toolbar.find( '.menupop.hover' ).removeClass( 'hover' );
    618584                                        $( this ).hide();
    619585                                });
    620586                }
    621                 this.$toolbarPopups.on( 'click.moby6', function() {
    622                         moby6.$overlay.show();
     587                this.$toolbarPopups.on( 'click.responsive', function() {
     588                        responsive.$overlay.show();
    623589                });
    624590        },
    625591
    626592        disableOverlay: function() {
    627                 this.$toolbarPopups.off( 'click.moby6' );
     593                this.$toolbarPopups.off( 'click.responsive' );
    628594                this.$overlay.hide();
    629595        },
    630596
    var moby6 = { 
    633599                this.$adminmenu.find( 'a.wp-has-submenu' ).off( '.wp-mobile-hover' );
    634600
    635601                var scrollStart = 0;
    636                 this.$adminmenu.on( 'touchstart.moby6', 'li.wp-has-submenu > a', function() {
    637                         scrollStart = $( window ).scrollTop();
     602                this.$adminmenu.on( 'touchstart.responsive', 'li.wp-has-submenu > a', function() {
     603                        scrollStart = responsive.$window.scrollTop();
    638604                });
    639605
    640                 this.$adminmenu.on( 'touchend.moby6', 'li.wp-has-submenu > a', function( e ) {
     606                this.$adminmenu.on( 'touchend.responsive', 'li.wp-has-submenu > a', function( e ) {
    641607                        e.preventDefault();
    642608
    643                         if ( $( window ).scrollTop() !== scrollStart )
    644                                 return false;
     609                        if ( responsive.$window.scrollTop() !== scrollStart ) {
     610                                return;
     611                        }
    645612
    646613                        $( this ).find( 'li.wp-has-submenu' ).removeClass( 'selected' );
    647614                        $( this ).parent( 'li' ).addClass( 'selected' );
    var moby6 = { 
    662629                        .addClass( 'hndle' );
    663630        },
    664631
    665         removeHamburgerButton: function() {
    666                 if ( this.hamburgerButtonView !== undefined )
    667                         this.hamburgerButtonView.destroy();
    668         },
    669 
    670632        movePostSearch: function() {
    671633                this.searchBox = this.$wpbody.find( 'p.search-box' );
    672634                if ( this.searchBox.length ) {
    var moby6 = { 
    681643        restorePostSearch: function() {
    682644                if ( this.searchBox !== undefined ) {
    683645                        this.searchBox.show();
    684                         if ( this.searchBoxClone !== undefined )
     646                        if ( this.searchBoxClone !== undefined ) {
    685647                                this.searchBoxClone.hide();
     648                        }
    686649                }
    687650        }
    688651};
    689652
    690 // Fire moby6.init when document is ready
    691 $( document ).ready( $.proxy( moby6.init, moby6 ) );
     653// Fire responsive.init when document is ready
     654$( document ).ready( $.proxy( responsive.init, responsive ) );
    692655
    693656// make Windows 8 devices playing along nicely
    694657(function(){
  • src/wp-includes/css/admin-bar.css

    diff --git src/wp-includes/css/admin-bar.css src/wp-includes/css/admin-bar.css
    index 0f1f5d8..35837de 100644
     
    947947
    948948/* Smartphone */
    949949@media screen and (max-width: 480px) {
    950         #moby6-overlay {
     950        #responsive-overlay {
    951951                position: fixed;
    952952                top: 0;
    953953                left: 0;
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index b1f0680..bfafa83 100644
    function wp_default_scripts( &$scripts ) { 
    7272                'time' => (string) time(),
    7373        ) );
    7474
    75         $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
     75        $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils', 'underscore'), false, 1 );
    7676        did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
    7777                'warnDelete' => __("You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete.")
    7878        ) );