Changeset 26402
- Timestamp:
- 11/26/2013 08:56:11 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/color-schemes/_admin.scss
r26387 r26402 385 385 /* Responsive Component */ 386 386 387 div# moby6-toggle a:before {388 color: $menu-icon; 389 } 390 391 . moby6-open div#moby6-toggle a {387 div#wp-responsive-toggle a:before { 388 color: $menu-icon; 389 } 390 391 .wp-responsive-open div#wp-responsive-toggle a { 392 392 // ToDo: make inset border 393 393 border-color: transparent; -
trunk/src/wp-admin/css/wp-admin.css
r26396 r26402 10601 10601 } 10602 10602 10603 li#wp-admin-bar- toggle-button{10603 li#wp-admin-bar-menu-toggle { 10604 10604 display: none; 10605 10605 } … … 11099 11099 11100 11100 /* Sidebar Toggle */ 11101 # moby6-toggle {11101 #wp-responsive-toggle { 11102 11102 position: fixed; 11103 11103 top: 5px; … … 11114 11114 } 11115 11115 11116 . moby6-open #wpadminbar #wp-admin-bar-toggle-buttona {11116 .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { 11117 11117 background: #000; 11118 11118 } 11119 11119 11120 . moby6-open #wpbody {11120 .wp-responsive-open #wpbody { 11121 11121 right: -190px; 11122 11122 } 11123 11123 11124 .auto-fold . moby6-open #adminmenuback,11125 .auto-fold . moby6-open #adminmenuwrap {11124 .auto-fold .wp-responsive-open #adminmenuback, 11125 .auto-fold .wp-responsive-open #adminmenuwrap { 11126 11126 left: 0; 11127 11127 } … … 12139 12139 12140 12140 @media screen and ( max-width: 782px ) { 12141 #wpadminbar #wp-admin-bar- toggle-buttona {12141 #wpadminbar #wp-admin-bar-menu-toggle a { 12142 12142 display: block; 12143 12143 padding: 0; … … 12151 12151 } 12152 12152 12153 li#wp-admin-bar- toggle-button{12153 li#wp-admin-bar-menu-toggle { 12154 12154 display: block; 12155 12155 } 12156 12156 12157 #wpadminbar #wp-admin-bar- toggle-buttona:hover {12157 #wpadminbar #wp-admin-bar-menu-toggle a:hover { 12158 12158 border: 1px solid transparent; 12159 12159 } 12160 12160 12161 #wpadminbar #wp-admin-bar- toggle-button.ab-icon:before {12161 #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { 12162 12162 content: '\f228'; 12163 12163 display: inline-block; … … 12194 12194 } 12195 12195 12196 # moby6-overlay {12196 #wp-responsive-overlay { 12197 12197 position: fixed; 12198 12198 top: 0; -
trunk/src/wp-admin/js/common.js
r26208 r26402 1 1 /* global setUserSetting, ajaxurl, commonL10n, alert, confirm, toggleWithKeyboard, pagenow */ 2 var showNotice, adminMenu, columns, validateForm, screenMeta , stickyMenu;3 ( function($){2 var showNotice, adminMenu, columns, validateForm, screenMeta; 3 ( function( $, window, undefined ) { 4 4 // Removed in 3.3. 5 5 // (perhaps) needed for back-compat … … 218 218 // close any open submenus when touch/click is not on the menu 219 219 $(document.body).on( mobileEvent+'.wp-mobile-hover', function(e) { 220 if ( !$(e.target).closest('#adminmenu').length ) 220 if ( menu.data('wp-responsive') ) { 221 return; 222 } 223 224 if ( ! $(e.target).closest('#adminmenu').length ) { 221 225 menu.find('li.wp-has-submenu.opensub').removeClass('opensub'); 226 } 222 227 }); 223 228 224 229 menu.find('a.wp-has-submenu').on( mobileEvent+'.wp-mobile-hover', function(e) { 225 230 var el = $(this), parent = el.parent(); 231 232 if ( menu.data('wp-responsive') ) { 233 return; 234 } 226 235 227 236 // Show the sub instead of following the link if: … … 448 457 }); 449 458 450 stickyMenu = { 451 active: false, 452 453 init: function () { 454 this.$window = $( window ); 455 this.$body = $( document.body ); 456 this.$adminMenuWrap = $( '#adminmenuwrap' ); 457 this.$collapseMenu = $( '#collapse-menu' ); 458 this.bodyMinWidth = parseInt( this.$body.css( 'min-width' ), 10 ); 459 this.enable(); 460 }, 461 462 enable: function () { 463 if ( ! this.active ) { 464 this.$window.on( 'resize.stickyMenu scroll.stickyMenu', this.debounce( 465 $.proxy( this.update, this ), 200 466 ) ); 467 this.$collapseMenu.on( 'click.stickyMenu', $.proxy( this.update, this ) ); 468 this.update(); 469 this.active = true; 470 } 471 }, 472 473 disable: function () { 474 if ( this.active ) { 475 this.$window.off( 'resize.stickyMenu scroll.stickyMenu' ); 476 this.$collapseMenu.off( 'click.stickyMenu' ); 477 this.$body.removeClass( 'sticky-menu' ); 478 this.active = false; 479 } 480 }, 481 482 update: function () { 483 // Make the admin menu sticky if both of the following: 484 // 1. The viewport is taller than the admin menu 485 // 2. The viewport is wider than the min-width of the <body> 486 if ( this.$window.height() > this.$adminMenuWrap.height() + 32 && this.$window.width() > this.bodyMinWidth) { 487 if ( ! this.$body.hasClass( 'sticky-menu' ) ) { 488 this.$body.addClass( 'sticky-menu' ); 489 } 490 } else { 491 if ( this.$body.hasClass( 'sticky-menu' ) ) { 492 this.$body.removeClass( 'sticky-menu' ); 493 } 494 } 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 } 459 // Fire a custom jQuery event at the end of window resize 460 ( function() { 461 var timeout; 462 463 function triggerEvent() { 464 $(document).trigger( 'wp-window-resized' ); 465 } 466 467 function fireOnce() { 468 window.clearTimeout( timeout ); 469 timeout = window.setTimeout( triggerEvent, 200 ); 470 } 471 472 $(window).on( 'resize.wp-fire-once', fireOnce ); 473 }()); 474 475 $(document).ready( function() { 476 var $document = $( document ), 477 $window = $( window ), 478 $body = $( document.body ), 479 $adminMenuWrap = $( '#adminmenuwrap' ), 480 $collapseMenu = $( '#collapse-menu' ), 481 $wpwrap = $( '#wpwrap' ), 482 $adminmenu = $( '#adminmenu' ), 483 $overlay = $( '#wp-responsive-overlay' ), 484 $toolbar = $( '#wp-toolbar' ), 485 $toolbarPopups = $toolbar.find( 'a[aria-haspopup="true"]' ), 486 $sortables = $('.meta-box-sortables'), 487 stickyMenuActive = false, 488 wpResponsiveActive = false; 489 490 window.stickyMenu = { 491 enable: function() { 492 if ( ! stickyMenuActive ) { 493 $document.on( 'wp-window-resized.sticky-menu', $.proxy( this.update, this ) ); 494 $collapseMenu.on( 'click.sticky-menu', $.proxy( this.update, this ) ); 495 this.update(); 496 stickyMenuActive = true; 497 } 498 }, 499 500 disable: function() { 501 if ( stickyMenuActive ) { 502 $window.off( 'resize.sticky-menu' ); 503 $collapseMenu.off( 'click.sticky-menu' ); 504 $body.removeClass( 'sticky-menu' ); 505 stickyMenuActive = false; 506 } 507 }, 508 509 update: function() { 510 // Make the admin menu sticky if the viewport is taller than it 511 if ( $window.height() > $adminMenuWrap.height() + 32 ) { 512 if ( ! $body.hasClass( 'sticky-menu' ) ) { 513 $body.addClass( 'sticky-menu' ); 515 514 } 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 }; 528 } 529 }; 530 531 stickyMenu.init(); 532 533 var moby6 = { 534 535 init: function() { 536 // cached selectors 537 this.$html = $( document.documentElement ); 538 this.$body = $( document.body ); 539 this.$wpwrap = $( '#wpwrap' ); 540 this.$wpbody = $( '#wpbody' ); 541 this.$adminmenu = $( '#adminmenu' ); 542 this.$overlay = $( '#moby6-overlay' ); 543 this.$toolbar = $( '#wp-toolbar' ); 544 this.$toolbarPopups = this.$toolbar.find( 'a[aria-haspopup="true"]' ); 545 546 // Modify functionality based on custom activate/deactivate event 547 this.$html 548 .on( 'activate.moby6', function() { moby6.activate(); } ) 549 .on( 'deactivate.moby6', function() { moby6.deactivate(); } ); 550 551 // Toggle sidebar when toggle is clicked 552 $( '#wp-admin-bar-toggle-button' ).on( 'click', function(evt) { 553 evt.preventDefault(); 554 moby6.$wpwrap.toggleClass( 'moby6-open' ); 555 } ); 556 557 // Trigger custom events based on active media query. 558 this.matchMedia(); 559 $( window ).on( 'resize', $.proxy( this.matchMedia, this ) ); 560 }, 561 562 activate: function() { 563 564 window.stickymenu && window.stickymenu.disable(); 565 566 if ( ! moby6.$body.hasClass( 'auto-fold' ) ) 567 moby6.$body.addClass( 'auto-fold' ); 568 569 this.modifySidebarEvents(); 570 this.disableDraggables(); 571 this.movePostSearch(); 572 573 }, 574 575 deactivate: function() { 576 577 window.stickymenu && window.stickymenu.enable(); 578 579 this.enableDraggables(); 580 this.removeHamburgerButton(); 581 this.restorePostSearch(); 582 583 }, 584 585 matchMedia: function() { 586 clearTimeout( this.resizeTimeout ); 587 this.resizeTimeout = setTimeout( function() { 588 589 if ( ! window.matchMedia ) 590 return; 591 592 if ( window.matchMedia( '(max-width: 782px)' ).matches ) { 593 if ( moby6.$html.hasClass( 'touch' ) ) 515 } else { 516 if ( $body.hasClass( 'sticky-menu' ) ) { 517 $body.removeClass( 'sticky-menu' ); 518 } 519 } 520 } 521 }; 522 523 window.wpResponsive = { 524 init: function() { 525 var self = this, 526 scrollStart = 0; 527 528 // Modify functionality based on custom activate/deactivate event 529 $document.on( 'wp-responsive-activate.wp-responsive', function() { 530 self.activate(); 531 }).on( 'wp-responsive-deactivate.wp-responsive', function() { 532 self.deactivate(); 533 }); 534 535 // Toggle sidebar when toggle is clicked 536 $( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) { 537 event.preventDefault(); 538 $wpwrap.toggleClass( 'wp-responsive-open' ); 539 } ); 540 541 // Add menu events 542 $adminmenu.on( 'touchstart.wp-responsive', 'li.wp-has-submenu > a', function() { 543 scrollStart = $window.scrollTop(); 544 }).on( 'touchend.wp-responsive', 'li.wp-has-submenu > a', function( event ) { 545 if ( ! $adminmenu.data('wp-responsive') || $window.scrollTop() !== scrollStart ) { 594 546 return; 595 moby6.$html.addClass( 'touch' ).trigger( 'activate.moby6' ); 547 } 548 549 $( this ).find( 'li.wp-has-submenu' ).removeClass( 'selected' ); 550 $( this ).parent( 'li' ).addClass( 'selected' ); 551 event.preventDefault(); 552 }); 553 554 self.trigger(); 555 $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) ); 556 }, 557 558 activate: function() { 559 window.stickyMenu.disable(); 560 561 if ( ! $body.hasClass( 'auto-fold' ) ) { 562 $body.addClass( 'auto-fold' ); 563 } 564 565 $adminmenu.data( 'wp-responsive', 1 ); 566 this.disableSortables(); 567 this.movePostSearch(); 568 }, 569 570 deactivate: function() { 571 window.stickyMenu.enable(); 572 $adminmenu.removeData('wp-responsive'); 573 this.enableSortables(); 574 this.restorePostSearch(); 575 }, 576 577 trigger: function() { 578 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth; 579 580 if ( width <= 782 ) { 581 if ( ! wpResponsiveActive ) { 582 $document.trigger( 'wp-responsive-activate' ); 583 wpResponsiveActive = true; 584 } 596 585 } else { 597 if ( ! moby6.$html.hasClass( 'touch' ) ) 598 return; 599 moby6.$html.removeClass( 'touch' ).trigger( 'deactivate.moby6' ); 600 } 601 602 if ( window.matchMedia( '(max-width: 480px)' ).matches ) { 603 moby6.enableOverlay(); 586 if ( wpResponsiveActive ) { 587 $document.trigger( 'wp-responsive-deactivate' ); 588 wpResponsiveActive = false; 589 } 590 } 591 592 if ( width <= 480 ) { 593 this.enableOverlay(); 604 594 } else { 605 moby6.disableOverlay(); 606 } 607 608 }, 150 ); 609 }, 610 611 enableOverlay: function() { 612 if ( this.$overlay.length === 0 ) { 613 this.$overlay = $( '<div id="moby6-overlay"></div>' ) 614 .insertAfter( '#wpcontent' ) 615 .hide() 616 .on( 'click.moby6', function() { 617 moby6.$toolbar.find( '.menupop.hover' ).removeClass( 'hover' ); 618 $( this ).hide(); 619 }); 620 } 621 this.$toolbarPopups.on( 'click.moby6', function() { 622 moby6.$overlay.show(); 623 }); 624 }, 625 626 disableOverlay: function() { 627 this.$toolbarPopups.off( 'click.moby6' ); 628 this.$overlay.hide(); 629 }, 630 631 modifySidebarEvents: function() { 632 this.$body.off( '.wp-mobile-hover' ); 633 this.$adminmenu.find( 'a.wp-has-submenu' ).off( '.wp-mobile-hover' ); 634 635 var scrollStart = 0; 636 this.$adminmenu.on( 'touchstart.moby6', 'li.wp-has-submenu > a', function() { 637 scrollStart = $( window ).scrollTop(); 638 }); 639 640 this.$adminmenu.on( 'touchend.moby6', 'li.wp-has-submenu > a', function( e ) { 641 e.preventDefault(); 642 643 if ( $( window ).scrollTop() !== scrollStart ) 644 return false; 645 646 $( this ).find( 'li.wp-has-submenu' ).removeClass( 'selected' ); 647 $( this ).parent( 'li' ).addClass( 'selected' ); 648 }); 649 }, 650 651 disableDraggables: function() { 652 this.$wpbody 653 .find( '.hndle' ) 654 .removeClass( 'hndle' ) 655 .addClass( 'hndle-disabled' ); 656 }, 657 658 enableDraggables: function() { 659 this.$wpbody 660 .find( '.hndle-disabled' ) 661 .removeClass( 'hndle-disabled' ) 662 .addClass( 'hndle' ); 663 }, 664 665 removeHamburgerButton: function() { 666 if ( this.hamburgerButtonView !== undefined ) 667 this.hamburgerButtonView.destroy(); 668 }, 669 670 movePostSearch: function() { 671 this.searchBox = this.$wpbody.find( 'p.search-box' ); 672 if ( this.searchBox.length ) { 673 this.searchBox.hide(); 674 if ( this.searchBoxClone === undefined ) { 675 this.searchBoxClone = this.searchBox.first().clone().insertAfter( 'div.tablenav.bottom' ); 676 } 677 this.searchBoxClone.show(); 678 } 679 }, 680 681 restorePostSearch: function() { 682 if ( this.searchBox !== undefined ) { 683 this.searchBox.show(); 684 if ( this.searchBoxClone !== undefined ) 685 this.searchBoxClone.hide(); 686 } 687 } 688 }; 689 690 // Fire moby6.init when document is ready 691 $( document ).ready( $.proxy( moby6.init, moby6 ) ); 595 this.disableOverlay(); 596 } 597 }, 598 599 enableOverlay: function() { 600 if ( $overlay.length === 0 ) { 601 $overlay = $( '<div id="wp-responsive-overlay"></div>' ) 602 .insertAfter( '#wpcontent' ) 603 .hide() 604 .on( 'click.wp-responsive', function() { 605 $toolbar.find( '.menupop.hover' ).removeClass( 'hover' ); 606 $( this ).hide(); 607 }); 608 } 609 610 $toolbarPopups.on( 'click.wp-responsive', function() { 611 $overlay.show(); 612 }); 613 }, 614 615 disableOverlay: function() { 616 $toolbarPopups.off( 'click.wp-responsive' ); 617 $overlay.hide(); 618 }, 619 620 disableSortables: function() { 621 if ( $sortables.length ) { 622 try { 623 $sortables.sortable('disable'); 624 } catch(e) {} 625 } 626 }, 627 628 enableSortables: function() { 629 if ( $sortables.length ) { 630 try { 631 $sortables.sortable('enable'); 632 } catch(e) {} 633 } 634 }, 635 636 movePostSearch: function() { 637 this.searchBox = $( 'p.search-box' ); 638 639 if ( this.searchBox.length ) { 640 this.searchBox.hide(); 641 642 if ( this.searchBoxClone === undefined ) { 643 this.searchBoxClone = this.searchBox.first().clone().insertAfter( 'div.tablenav.bottom' ); 644 } 645 646 this.searchBoxClone.show(); 647 } 648 }, 649 650 restorePostSearch: function() { 651 if ( this.searchBox !== undefined ) { 652 this.searchBox.show(); 653 654 if ( this.searchBoxClone !== undefined ) { 655 this.searchBoxClone.hide(); 656 } 657 } 658 } 659 }; 660 661 window.stickyMenu.enable(); 662 window.wpResponsive.init(); 663 }); 692 664 693 665 // make Windows 8 devices playing along nicely … … 713 685 }); 714 686 715 } )(jQuery);687 }( jQuery, window )); -
trunk/src/wp-includes/admin-bar.php
r26134 r26402 166 166 if ( is_admin() ) { 167 167 $wp_admin_bar->add_menu( array( 168 'id' => ' toggle-button',168 'id' => 'menu-toggle', 169 169 'title' => '<span class="ab-icon"></span>', 170 170 'href' => '#', -
trunk/src/wp-includes/css/admin-bar.css
r26382 r26402 946 946 } 947 947 948 # moby6-overlay {948 #wp-responsive-overlay { 949 949 position: fixed; 950 950 top: 0;
Note: See TracChangeset
for help on using the changeset viewer.