Make WordPress Core

Ticket #25914: wplink.diff

File wplink.diff, 4.8 KB (added by jorbin, 12 years ago)
  • .jshintrc

     
    11{
    22        "boss": true,
    3         "curly": true,
    4         "eqeqeq": true,
     3        "curly": false,
     4        "eqeqeq": false,
    55        "eqnull": true,
    66        "es3": true,
    77        "expr": true,
  • src/wp-includes/js/wplink.js

     
     1/* global ajaxurl:true, tinymce: true, wpLinkL10n:true, tinyMCEPopup:true, setUserSetting:true, wpActiveEditor: true */
    12var wpLink;
    23
    34(function($){
     
    113114                                inputs.url.val( ed.dom.getAttrib(e, 'href') );
    114115                                inputs.title.val( ed.dom.getAttrib(e, 'title') );
    115116                                // Set open in new tab.
    116                                 inputs.openInNewTab.prop('checked', ( "_blank" == ed.dom.getAttrib( e, 'target' ) ) );
     117                                inputs.openInNewTab.prop('checked', ( '_blank' == ed.dom.getAttrib( e, 'target' ) ) );
    117118                                // Update save prompt.
    118119                                inputs.submit.val( wpLinkL10n.update );
    119120
     
    156157                },
    157158
    158159                htmlUpdate : function() {
    159                         var attrs, html, begin, end, cursor,
     160                        var attrs, html, begin, end, cursor, selection,
    160161                                textarea = wpLink.textarea;
    161162
    162163                        if ( ! textarea )
     
    201202                                if ( begin == end )
    202203                                        cursor -= '</a>'.length;
    203204
    204                                 textarea.value = textarea.value.substring( 0, begin )
    205                                                + html
    206                                                + textarea.value.substring( end, textarea.value.length );
     205                                textarea.value = textarea.value.substring( 0, begin ) +
     206                                               html +
     207                                               textarea.value.substring( end, textarea.value.length );
    207208
    208209                                // Update cursor position
    209210                                textarea.selectionStart = textarea.selectionEnd = cursor;
     
    227228                                        b = ed.selection.getBookmark();
    228229                                        ed.dom.remove(e, 1);
    229230                                        ed.selection.moveToBookmark(b);
    230                                         tinyMCEPopup.execCommand("mceEndUndoLevel");
     231                                        tinyMCEPopup.execCommand('mceEndUndoLevel');
    231232                                        wpLink.close();
    232233                                }
    233234                                return;
    234235                        }
    235236
    236237                        if (e == null) {
    237                                 ed.getDoc().execCommand("unlink", false, null);
    238                                 tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
     238                                ed.getDoc().execCommand('unlink', false, null);
     239                                tinyMCEPopup.execCommand('mceInsertLink', false, '#mce_temp_url#', {skip_undo : 1});
    239240
    240                                 tinymce.each(ed.dom.select("a"), function(n) {
     241                                tinymce.each(ed.dom.select('a'), function(n) {
    241242                                        if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
    242243                                                e = n;
    243244                                                ed.dom.setAttribs(e, attrs);
     
    262263                                tinyMCEPopup.storeSelection();
    263264                        }
    264265
    265                         ed.execCommand("mceEndUndoLevel");
     266                        ed.execCommand('mceEndUndoLevel');
    266267                        wpLink.close();
    267268                        ed.focus();
    268269                },
     
    270271                updateFields : function( e, li, originalEvent ) {
    271272                        inputs.url.val( li.children('.item-permalink').val() );
    272273                        inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() );
    273                         if ( originalEvent && originalEvent.type == "click" )
     274                        if ( originalEvent && originalEvent.type == 'click' )
    274275                                inputs.url.focus();
    275276                },
    276277                setDefaultValues : function() {
     
    320321
    321322                        switch( event.which ) {
    322323                                case key.UP:
    323                                         fn = 'prev';
    324324                                case key.DOWN:
    325                                         fn = fn || 'next';
     325                                        fn = key.UP ? 'prev' : 'next';
    326326                                        clearInterval( wpLink.keyInterval );
    327327                                        wpLink[ fn ]();
    328328                                        wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
     
    342342                                                wpLink.close();
    343343
    344344                                        return false;
    345                                         break;
    346345                                case key.UP:
    347346                                case key.DOWN:
    348347                                        clearInterval( wpLink.keyInterval );
     
    507506
    508507                        if ( !results ) {
    509508                                if ( firstPage ) {
    510                                         list += '<li class="unselectable"><span class="item-title"><em>'
    511                                         + wpLinkL10n.noMatchesFound
    512                                         + '</em></span></li>';
     509                                        list += '<li class="unselectable"><span class="item-title"><em>' +
     510                                        wpLinkL10n.noMatchesFound +
     511                                        '</em></span></li>';
    513512                                }
    514513                        } else {
    515514                                $.each( results, function() {
    516515                                        classes = alt ? 'alternate' : '';
    517                                         classes += this['title'] ? '' : ' no-title';
     516                                        classes += this.title ? '' : ' no-title';
    518517                                        list += classes ? '<li class="' + classes + '">' : '<li>';
    519                                         list += '<input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />';
     518                                        list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
    520519                                        list += '<span class="item-title">';
    521                                         list += this['title'] ? this['title'] : wpLinkL10n.noTitle;
    522                                         list += '</span><span class="item-info">' + this['info'] + '</span></li>';
     520                                        list += this.title ? this.title : wpLinkL10n.noTitle;
     521                                        list += '</span><span class="item-info">' + this.info + '</span></li>';
    523522                                        alt = ! alt;
    524523                                });
    525524                        }
     
    578577                                self.querying = false;
    579578                                self.allLoaded = !r;
    580579                                callback( r, query );
    581                         }, "json" );
     580                        }, 'json' );
    582581                }
    583582        });
    584583