Ticket #21273: 21273-6.patch

File 21273-6.patch, 2.4 KB (added by azaozz, 10 months ago)
  • wp-admin/js/common.dev.js

     
    9595        page:    null, // #wpcontent 
    9696 
    9797        init: function() { 
     98                var self = this; 
     99 
    98100                this.element = $('#screen-meta'); 
    99101                this.toggles = $('.screen-meta-toggle a'); 
    100102                this.page    = $('#wpcontent'); 
    101103 
    102104                this.toggles.click( this.toggleEvent ); 
     105 
     106                $(document).ready( function(){ 
     107                        $(document.body).bind('click.help-tabs focus.help-tabs', function(e){  
     108                                if ( e.target.href && /#tab-panel-/.test(e.target.href) ) { 
     109                                        self.triggerHelpPanel( e.target.href.replace(/.*?#/, '#') ); 
     110                                        e.preventDefault(); 
     111                                }  
     112                        }); 
     113                }); 
    103114        }, 
    104115 
    105116        toggleEvent: function( e ) { 
     
    131142                        $('.screen-meta-toggle').css('visibility', ''); 
    132143                        panel.parent().hide(); 
    133144                }); 
    134         } 
    135 }; 
     145        }, 
    136146 
    137 /** 
    138  * Help tabs. 
    139  */ 
    140 $('.contextual-help-tabs').delegate('a', 'click focus', function(e) { 
    141         var link = $(this), 
    142                 panel; 
     147        triggerHelpPanel: function( panel ) { 
     148                panel = panel || window.location.hash; 
    143149 
    144         e.preventDefault(); 
     150                // Check if the panel exists 
     151                if ( !panel || !$('#contextual-help-wrap '+panel).length ) 
     152                        return; 
    145153 
    146         // Don't do anything if the click is for the tab already showing. 
    147         if ( link.is('.active a') ) 
    148                 return false; 
     154                // Don't do anything if the panel is already visible and the click is for the active tab. 
     155                if ( $('#contextual-help-wrap').is(':visible') && $( panel ).hasClass('active') ) 
     156                        return false; 
    149157 
    150         // Links 
    151         $('.contextual-help-tabs .active').removeClass('active'); 
    152         link.parent('li').addClass('active'); 
     158                // Active the clicked panel. 
     159                $('.contextual-help-tabs li, div.help-tab-content').removeClass('active'); 
     160                $( panel+', '+panel.replace(/tab-panel-/, 'tab-link-') ).addClass('active'); 
    153161 
    154         panel = $( link.attr('href') ); 
     162                // Open the help panel. 
     163                $('html').animate({ scrollTop: 0 }, 'fast', function(){ 
     164                        if ( $('#contextual-help-wrap').is(':hidden') ) 
     165                                screenMeta.open( $('#contextual-help-wrap'), $('#contextual-help-link') ); 
     166                }); 
     167        } 
     168}; 
    155169 
    156         // Panels 
    157         $('.help-tab-content').not( panel ).removeClass('active').hide(); 
    158         panel.addClass('active').show(); 
    159 }); 
    160  
    161170$(document).ready( function() { 
    162171        var lastClicked = false, checks, first, last, checked, menu = $('#adminmenu'), 
    163172                pageInput = $('input.current-page'), currentPage = pageInput.val(), refresh;