Make WordPress Core

Changeset 26204


Ignore:
Timestamp:
11/15/2013 05:34:14 AM (12 years ago)
Author:
nacin
Message:

Fix JSHint errors in post.js.

props atimmer.
fixes #25994.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/post.js

    r26169 r26204  
     1/* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting, getUserSetting, setUserSetting */
     2/* global theList:true, theExtraList:true, autosave:true */
     3
    14var tagBox, commentsBox, editPermalink, makeSlugeditClickable, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint;
    25
     
    8285
    8386    flushTags : function(el, a, f) {
     87        var tagsval, newtags, text,
     88            tags = $('.the-tags', el),
     89            newtag = $('input.newtag', el),
     90            comma = postL10n.comma;
    8491        a = a || false;
    85         var tags = $('.the-tags', el),
    86             newtag = $('input.newtag', el),
    87             comma = postL10n.comma,
    88             newtags, text;
    8992
    9093        text = a ? $(a).text() : newtag.val();
     
    109112
    110113        $.post(ajaxurl, {'action':'get-tagcloud', 'tax':tax}, function(r, stat) {
    111             if ( 0 == r || 'success' != stat )
     114            if ( 0 === r || 'success' != stat )
    112115                r = wpAjax.broken;
    113116
     
    138141
    139142        $('input.newtag', ajaxtag).blur(function() {
    140             if ( this.value == '' )
     143            if ( '' === this.value )
    141144                $(this).parent().siblings('.taghint').css('visibility', '');
    142145        }).focus(function(){
     
    207210
    208211                    theList = theExtraList = null;
    209                     $("a[className*=':']").unbind();
     212                    $( 'a[className*=\':\']' ).unbind();
    210213
    211214                    if ( commentsBox.st > commentsBox.total )
     
    241244WPRemoveThumbnail = function(nonce){
    242245    $.post(ajaxurl, {
    243         action:"set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
     246        action: 'set-post-thumbnail', post_id: $( '#post_ID' ).val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
    244247    }, function(str){
    245248        if ( str == '0' ) {
     
    260263        return;
    261264
    262     send['post_id'] = post_id;
     265    send.post_id = post_id;
    263266
    264267    if ( lock )
    265         send['lock'] = lock;
     268        send.lock = lock;
    266269
    267270    data['wp-refresh-post-lock'] = send;
     
    352355
    353356jQuery(document).ready( function($) {
    354     var stamp, visibility, sticky = '', last = 0, co = $('#content');
     357    var stamp, visibility, updateVisibility, updateText,
     358        sticky = '', last = 0, co = $('#content');
    355359
    356360    postboxes.add_postbox_toggles(pagenow);
     
    407411            $(t).show();
    408412            if ( '#' + taxonomy + '-all' == t )
    409                 deleteUserSetting(settingName);
     413                deleteUserSetting( settingName );
    410414            else
    411                 setUserSetting(settingName, 'pop');
    412             return false;
    413         });
    414 
    415         if ( getUserSetting(settingName) )
     415                setUserSetting( settingName, 'pop' );
     416            return false;
     417        });
     418
     419        if ( getUserSetting( settingName ) )
    416420            $('a[href="#' + taxonomy + '-pop"]', '#' + taxonomy + '-tabs').click();
    417421
    418422        // Ajax Cat
    419         $('#new' + taxonomy).one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
     423        $( '#new' + taxonomy ).one( 'focus', function() { $( this ).val( '' ).removeClass( 'form-input-tip' ); } );
    420424
    421425        $('#new' + taxonomy).keypress( function(event){
     
    469473    // Custom Fields
    470474    if ( $('#postcustom').length ) {
    471         $('#the-list').wpList( { addAfter: function( xml, s ) {
     475        $( '#the-list' ).wpList( { addAfter: function() {
    472476            $('table#list-table').show();
    473477        }, addBefore: function( s ) {
     
    483487        visibility = $('#post-visibility-display').html();
    484488
    485         function updateVisibility() {
     489        updateVisibility = function() {
    486490            var pvSelect = $('#post-visibility-select');
    487491            if ( $('input:radio:checked', pvSelect).val() != 'public' ) {
     
    496500                $('#password-span').show();
    497501            }
    498         }
    499 
    500         function updateText() {
     502        };
     503
     504        updateText = function() {
    501505
    502506            if ( ! $('#timestampdiv').length )
     
    537541                        .replace( '%3$s', aa )
    538542                        .replace( '%4$s', hh )
    539                         .replace( '%5$s', mn )
    540                     + '</b> '
     543                        .replace( '%5$s', mn ) +
     544                        '</b> '
    541545                );
    542546            }
     
    544548            if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) {
    545549                $('#publish').val( postL10n.update );
    546                 if ( optPublish.length == 0 ) {
     550                if ( 0 === optPublish.length ) {
    547551                    postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
    548552                } else {
     
    575579            }
    576580            return true;
    577         }
     581        };
    578582
    579583        $('.edit-visibility', '#visibility').click(function () {
    580             if ($('#post-visibility-select').is(":hidden")) {
     584            if ( $( '#post-visibility-select' ).is( ':hidden' ) ) {
    581585                updateVisibility();
    582586                $('#post-visibility-select').slideDown('fast');
     
    608612            } // WEAPON LOCKED
    609613
    610             if ( true == $('#sticky').prop('checked') ) {
     614            if ( $('#sticky').prop('checked') ) {
    611615                sticky = 'Sticky';
    612616            } else {
     
    623627
    624628        $('#timestampdiv').siblings('a.edit-timestamp').click(function() {
    625             if ($('#timestampdiv').is(":hidden")) {
     629            if ( $( '#timestampdiv' ).is( ':hidden' ) ) {
    626630                $('#timestampdiv').slideDown('fast');
    627631                $('#mm').focus();
     
    662666
    663667        $('#post-status-select').siblings('a.edit-post-status').click(function() {
    664             if ($('#post-status-select').is(":hidden")) {
     668            if ( $( '#post-status-select' ).is( ':hidden' ) ) {
    665669                $('#post-status-select').slideDown('fast');
    666670                $(this).hide();
     
    688692    if ( $('#edit-slug-box').length ) {
    689693        editPermalink = function(post_id) {
    690             var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html();
     694            var slug_value, i,
     695                c = 0,
     696                e = $( '#editable-post-name' ),
     697                revert_e = e.html(),
     698                real_slug = $( '#post_name' ),
     699                revert_slug = real_slug.val(),
     700                b = $( '#edit-slug-buttons' ),
     701                revert_b = b.html(),
     702                full = $( '#editable-post-name-full' ).html();
    691703
    692704            $('#view-post-btn').hide();
     
    744756                    return false;
    745757                }
    746             }).keyup(function(e) {
     758            } ).keyup( function() {
    747759                real_slug.val(this.value);
    748760            }).focus();
    749         }
     761        };
    750762
    751763        makeSlugeditClickable = function() {
     
    753765                $('#edit-slug-buttons').children('.edit-slug').click();
    754766            });
    755         }
     767        };
    756768        makeSlugeditClickable();
    757769    }
     
    780792        var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text');
    781793
    782         if ( title.val() == '' )
     794        if ( '' === title.val() )
    783795            titleprompt.removeClass('screen-reader-text');
    784796
     
    789801
    790802        title.blur(function(){
    791             if ( this.value == '' )
     803            if ( '' === this.value )
    792804                titleprompt.removeClass('screen-reader-text');
    793805        }).focus(function(){
     
    797809            $(this).unbind(e);
    798810        });
    799     }
     811    };
    800812
    801813    wptitlehint();
     
    813825        }
    814826
    815         function endDrag(e) {
     827        function endDrag() {
    816828            var height;
    817829
     
    860872
    861873            // resize TinyMCE to match the textarea height when switching Text -> Visual
    862             ed.onLoadContent.add( function(ed, o) {
     874            ed.onLoadContent.add( function() {
    863875                var ifr_height, node = document.getElementById('content'),
    864876                    height = node ? parseInt( node.style.height, 10 ) : 0,
     
    883895
    884896            // resize the textarea to match TinyMCE's height when switching Visual -> Text
    885             ed.onSaveContent.add( function(ed, o) {
     897            ed.onSaveContent.add( function() {
    886898                var height = getHeight();
    887899
     
    894906            // save on resizing TinyMCE
    895907            ed.onPostRender.add(function() {
    896                 $('#content_resize').on('mousedown.wp-mce-resize', function(e){
    897                     $(document).on('mouseup.wp-mce-resize', function(e){
     908                $( '#content_resize' ).on( 'mousedown.wp-mce-resize', function() {
     909                    $( document ).on( 'mouseup.wp-mce-resize', function() {
    898910                        var height;
    899911
     
    910922
    911923        // When changing post formats, change the editor body class
    912         $('#post-formats-select input.post-format').on( 'change.set-editor-class', function( event ) {
     924        $( '#post-formats-select input.post-format' ).on( 'change.set-editor-class', function() {
    913925            var editor, body, format = this.id;
    914926
Note: See TracChangeset for help on using the changeset viewer.