Make WordPress Core

Ticket #25187: 25187.18.diff

File 25187.18.diff, 3.4 KB (added by tollmanz, 11 years ago)
  • src/wp-admin/css/wp-admin.css

     
    15041504        text-decoration: none;
    15051505}
    15061506
     1507.sticky-menu #adminmenuwrap {
     1508        position: fixed;
     1509        top: 32px;
     1510        left: 0;
     1511        z-index: 80000;
     1512}
     1513.sticky-menu.rtl #adminmenuwrap {
     1514        right: 0;
     1515        left: auto;
     1516}
     1517
     1518.sticky-menu #TB_overlay {
     1519        z-index: 80100;
     1520}
     1521.sticky-menu #TB_window {
     1522        z-index: 80102;
     1523}
     1524
     1525/* hotfix! increase `zindex` in `wp-pointer.js` to 80010 */
     1526.sticky-menu .wp-pointer {
     1527        z-index: 80010 !important;
     1528}
     1529
    15071530/*------------------------------------------------------------------------------
    15081531  6.1 - Screen Options Tabs
    15091532------------------------------------------------------------------------------*/
  • src/wp-admin/js/common.js

     
    438438        })();
    439439});
    440440
     441var stickymenu = {
     442        active: false,
     443
     444        init: function () {
     445                this.$window = $( window );
     446                this.$body = $( document.body );
     447                this.$adminMenuWrap = $( '#adminmenuwrap' );
     448                this.$collapseMenu = $( '#collapse-menu' );
     449                this.bodyMinWidth = parseInt( this.$body.css( 'min-width' ), 10 );
     450                this.enable();
     451        },
     452
     453        enable: function () {
     454                if ( ! this.active ) {
     455                        this.$window.on( 'resize.stickymenu scroll.stickymenu', this.debounce(
     456                                $.proxy( this.update, this ), 200
     457                        ) );
     458                        this.$collapseMenu.on( 'click.stickymenu', $.proxy( this.update, this ) );
     459                        this.update();
     460                        this.active = true;
     461                }
     462        },
     463
     464        disable: function () {
     465                if ( this.active ) {
     466                        this.$window.off( 'resize.stickymenu scroll.stickymenu' );
     467                        this.$collapseMenu.off( 'click.stickymenu' );
     468                        this.$body.removeClass( 'sticky-menu' );
     469                        this.active = false;
     470                }
     471        },
     472
     473        update: function () {
     474                // float the admin menu sticky if:
     475                // 1) the viewport is taller than the admin menu
     476                // 2) the viewport is wider than the min-width of the <body>
     477                // to float it only if it's collapsed add: $(document.body).hasClass('folded')
     478                if ( this.$window.height() > this.$adminMenuWrap.height() + 32 && this.$window.width() > this.bodyMinWidth) {
     479                        if ( ! this.$body.hasClass( 'sticky-menu' ) ) {
     480                                this.$body.addClass( 'sticky-menu' );
     481                        }
     482                } else {
     483                        if ( this.$body.hasClass( 'sticky-menu' ) ) {
     484                                this.$body.removeClass( 'sticky-menu' );
     485                        }
     486                }
     487        },
     488
     489        // Borrowed from Underscore.js
     490        debounce: function( func, wait, immediate ) {
     491                var timeout, args, context, timestamp, result;
     492                return function() {
     493                        context = this;
     494                        args = arguments;
     495                        timestamp = new Date().getTime();
     496                        var later = function() {
     497                                var last = new Date().getTime() - timestamp;
     498                                if ( last < wait ) {
     499                                        timeout = setTimeout( later, wait - last );
     500                                } else {
     501                                        timeout = null;
     502                                        if ( ! immediate ) {
     503                                                result = func.apply( context, args );
     504                                                context = args = null;
     505                                        }
     506                                }
     507                        };
     508                        var callNow = immediate && !timeout;
     509                        if ( ! timeout ) {
     510                                timeout = setTimeout( later, wait );
     511                        }
     512                        if ( callNow ) {
     513                                result = func.apply( context, args );
     514                                context = args = null;
     515                        }
     516
     517                        return result;
     518                };
     519        }
     520};
     521
     522stickymenu.init();
     523
    441524// internal use
    442525$(document).bind( 'wp_CloseOnEscape', function( e, data ) {
    443526        if ( typeof(data.cb) != 'function' )