Ticket #21273: 21273-5.patch
| File 21273-5.patch, 2.5 KB (added by azaozz, 10 months ago) |
|---|
-
wp-admin/js/common.dev.js
95 95 page: null, // #wpcontent 96 96 97 97 init: function() { 98 var self = this; 99 98 100 this.element = $('#screen-meta'); 99 101 this.toggles = $('.screen-meta-toggle a'); 100 102 this.page = $('#wpcontent'); 101 103 102 104 this.toggles.click( this.toggleEvent ); 105 106 $(document).ready( function(){ 107 self.autoOpen(); // that happens too early when the page is not cached, may need to run on $(window).load() 108 109 if ( 'onhashchange' in window ) { 110 $(window).bind('hashchange.help-tabs', function(){ 111 self.autoOpen(); 112 }); 113 } else { // IE7 114 $(document.body).bind('click.help-tabs', function(e){ 115 if ( e.target.href && /^#.+/.test(e.target.href) ) { // only links where href="#something" 116 self.autoOpen(e.target.href); // no need to prevent default as the link doesn't go to another page 117 } 118 }); 119 } 120 }); 103 121 }, 104 122 105 123 toggleEvent: function( e ) { … … 131 149 $('.screen-meta-toggle').css('visibility', ''); 132 150 panel.parent().hide(); 133 151 }); 152 153 screenMeta.updateHash(); 154 }, 155 156 updateHash: function( hash ) { 157 hash = hash || ''; 158 window.location.hash = hash; 159 }, 160 161 autoOpen : function(hash) { 162 var panel = hash || window.location.hash; 163 164 if ( $(panel).length ) { 165 // Activate the panel. 166 $('.contextual-help-tabs li, div.help-tab-content').removeClass('active'); 167 $(panel+', '+panel.replace(/tab-panel-/, 'tab-link-')).addClass('active'); 168 169 // Scroll to the top. 170 $('html').animate({ scrollTop: 0 }, 'fast', function(){ 171 // Open the help panel if needed. 172 if ( ! $('#contextual-help-wrap').is(':visible') ) 173 screenMeta.open( $('#contextual-help-wrap'), $('#contextual-help-link') ); 174 }); 175 }; 134 176 } 135 177 }; 136 178 137 /**138 * Help tabs.139 */140 179 $('.contextual-help-tabs').delegate('a', 'click focus', function(e) { 141 180 var link = $(this), 142 181 panel; … … 144 183 e.preventDefault(); 145 184 146 185 // Don't do anything if the click is for the tab already showing. 147 if ( link. is('.active a') )186 if ( link.parent().hasClass('active') ) 148 187 return false; 149 188 150 189 // Links … … 153 192 154 193 panel = $( link.attr('href') ); 155 194 195 screenMeta.updateHash( $(panel).attr('id') ); 196 156 197 // Panels 157 $('.help-tab-content ').not( panel ).removeClass('active').hide();158 panel.addClass('active') .show();198 $('.help-tab-content.active').removeClass('active'); 199 panel.addClass('active'); 159 200 }); 160 201 161 202 $(document).ready( function() {
