Make WordPress Core

Ticket #24042: 24042.diff

File 24042.diff, 2.8 KB (added by lessbloat, 12 years ago)
  • wp-admin/js/common.js

     
    1 var showNotice, adminMenu, columns, validateForm, screenMeta;
     1var showNotice, adminMenu, columns, validateForm, screenMeta, inputPlaceholder;
    22(function($){
    33// Removed in 3.3.
    44// (perhaps) needed for back-compat
     
    430430        return true;
    431431});
    432432
     433inputPlaceholder = function(id) {
     434               
     435        if ( '' === id )
     436                return;
     437
     438        var input = $( '#' + id ), placeholderText = $( '#' + id + '-prompt-text' );
     439
     440        placeholderText.click( function () {
     441                input.focus();
     442        });
     443
     444        input.blur( function () {
     445                hidePlaceholder();
     446        }).keyup( _.throttle( function () {
     447                placeholderText.addClass('screen-reader-text');
     448                hidePlaceholder();
     449        }, 300 ));
     450       
     451        function hidePlaceholder () {
     452                if ( '' === input.val() )
     453                        placeholderText.removeClass('screen-reader-text');
     454        }
     455       
     456        hidePlaceholder();
     457}
     458
    433459})(jQuery);
  • wp-admin/js/dashboard.js

     
    8888                $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
    8989
    9090                $('#title, #tags-input').each( function() {
    91                         var input = $(this), prompt = $('#' + this.id + '-prompt-text');
    92 
    93                         if ( '' === this.value )
    94                                 prompt.removeClass('screen-reader-text');
    95 
    96                         prompt.click( function() {
    97                                 $(this).addClass('screen-reader-text');
    98                                 input.focus();
    99                         });
    100 
    101                         input.blur( function() {
    102                                 if ( '' === this.value )
    103                                         prompt.removeClass('screen-reader-text');
    104                         });
    105 
    106                         input.focus( function() {
    107                                 prompt.addClass('screen-reader-text');
    108                         });
     91                        inputPlaceholder(this.id);
    10992                });
    11093
    11194                $('#quick-press').on( 'click focusin', function() {
  • wp-admin/js/post.js

     
    769769                });
    770770        }
    771771
    772         wptitlehint = function(id) {
    773                 id = id || 'title';
     772        inputPlaceholder('title');
    774773
    775                 var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text');
    776 
    777                 if ( title.val() == '' )
    778                         titleprompt.removeClass('screen-reader-text');
    779 
    780                 titleprompt.click(function(){
    781                         $(this).addClass('screen-reader-text');
    782                         title.focus();
    783                 });
    784 
    785                 title.blur(function(){
    786                         if ( this.value == '' )
    787                                 titleprompt.removeClass('screen-reader-text');
    788                 }).focus(function(){
    789                         titleprompt.addClass('screen-reader-text');
    790                 }).keydown(function(e){
    791                         titleprompt.addClass('screen-reader-text');
    792                         $(this).unbind(e);
    793                 });
    794         }
    795 
    796         wptitlehint();
    797 
    798774        // resizable textarea#content
    799775        (function() {
    800776                var textarea = $('textarea#content'), offset = null, el;