Make WordPress Core

Ticket #25914: 25914.diff

File 25914.diff, 5.0 KB (added by jorbin, 12 years ago)
  • src/wp-includes/js/wplink.js

     
     1/* global ajaxurl, tinymce, wpLinkL10n, tinyMCEPopup, setUserSetting, wpActiveEditor */
    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 );
     
    333333                        event.preventDefault();
    334334                },
    335335                keyup: function( event ) {
    336                         var key = $.ui.keyCode;
     336                        var key = $.ui.keyCode,
     337                                returnStatus;
    337338
    338339                        switch( event.which ) {
    339340                                case key.ESCAPE:
    340341                                        event.stopImmediatePropagation();
    341342                                        if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) )
    342343                                                wpLink.close();
    343 
    344                                         return false;
     344                                        returnStatus = false;
    345345                                        break;
    346346                                case key.UP:
    347347                                case key.DOWN:
     
    350350                                default:
    351351                                        return;
    352352                        }
     353                        if (typeof(returnStatus) !== 'undefined')
     354                                return returnStatus;
    353355                        event.preventDefault();
    354356                },
    355357
     
    507509
    508510                        if ( !results ) {
    509511                                if ( firstPage ) {
    510                                         list += '<li class="unselectable"><span class="item-title"><em>'
    511                                         + wpLinkL10n.noMatchesFound
    512                                         + '</em></span></li>';
     512                                        list += '<li class="unselectable"><span class="item-title"><em>' +
     513                                        wpLinkL10n.noMatchesFound +
     514                                        '</em></span></li>';
    513515                                }
    514516                        } else {
    515517                                $.each( results, function() {
    516518                                        classes = alt ? 'alternate' : '';
    517                                         classes += this['title'] ? '' : ' no-title';
     519                                        classes += this.title ? '' : ' no-title';
    518520                                        list += classes ? '<li class="' + classes + '">' : '<li>';
    519                                         list += '<input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />';
     521                                        list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
    520522                                        list += '<span class="item-title">';
    521                                         list += this['title'] ? this['title'] : wpLinkL10n.noTitle;
    522                                         list += '</span><span class="item-info">' + this['info'] + '</span></li>';
     523                                        list += this.title ? this.title : wpLinkL10n.noTitle;
     524                                        list += '</span><span class="item-info">' + this.info + '</span></li>';
    523525                                        alt = ! alt;
    524526                                });
    525527                        }
     
    578580                                self.querying = false;
    579581                                self.allLoaded = !r;
    580582                                callback( r, query );
    581                         }, "json" );
     583                        }, 'json' );
    582584                }
    583585        });
    584586