+
-
-
- 2 ) {
@@ -284,10 +283,12 @@ var wpLink;
return;
wpLink.lastSearch = search;
- waiting = t.parent().find('.spinner').show();
+ waiting = $( '#river-waiting' ).show();
rivers.search.change( search );
- rivers.search.ajax( function(){ waiting.hide(); });
+ rivers.search.ajax( function() {
+ waiting.hide();
+ });
} else {
rivers.search.hide();
rivers.recent.show();
@@ -305,18 +306,29 @@ var wpLink;
},
keydown: function( event ) {
- var fn, key = $.ui.keyCode;
+ var fn, id,
+ key = $.ui.keyCode;
- if ( key.ESCAPE === event.which ) {
+ if ( key.ESCAPE === event.keyCode ) {
wpLink.close();
event.stopImmediatePropagation();
+ } else if ( key.TAB === event.keyCode ) {
+ id = event.target.id;
+
+ if ( id === 'wp-link-submit' && ! event.shiftKey ) {
+ inputs.close.focus();
+ event.preventDefault();
+ } else if ( id === 'wp-link-close' && event.shiftKey ) {
+ inputs.submit.focus();
+ event.preventDefault();
+ }
}
- if ( event.which !== key.UP && event.which !== key.DOWN ) {
+ if ( event.keyCode !== key.UP && event.keyCode !== key.DOWN ) {
return;
}
- fn = event.which === key.UP ? 'prev' : 'next';
+ fn = event.keyCode === key.UP ? 'prev' : 'next';
clearInterval( wpLink.keyInterval );
wpLink[ fn ]();
wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
@@ -343,7 +355,7 @@ var wpLink;
return func.apply( funcContext, funcArgs );
// Otherwise, wait.
timeoutTriggered = true;
- }, delay);
+ }, delay );
return function() {
if ( timeoutTriggered )
@@ -355,53 +367,37 @@ var wpLink;
};
},
- toggleInternalLinking: function( event ) {
- var panel = $('#search-panel'),
- widget = inputs.dialog.wpdialog('widget'),
- // We're about to toggle visibility; it's currently the opposite
- visible = !panel.is(':visible'),
- win = $(window);
+ toggleInternalLinking: function() {
+ var visible = inputs.wrap.hasClass( 'search-panel-visible' );
- $(this).toggleClass('toggle-arrow-active', visible);
-
- inputs.dialog.height('auto');
- panel.slideToggle( 300, function() {
- setUserSetting('wplink', visible ? '1' : '0');
- inputs[ visible ? 'search' : 'url' ].focus();
-
- // Move the box if the box is now expanded, was opened in a collapsed state,
- // and if it needs to be moved. (Judged by bottom not being positive or
- // bottom being smaller than top.)
- var scroll = win.scrollTop(),
- top = widget.offset().top,
- bottom = top + widget.outerHeight(),
- diff = bottom - win.height();
-
- if ( diff > scroll ) {
- widget.animate({'top': diff < top ? top - diff : scroll }, 200);
- }
- });
- event.preventDefault();
+ inputs.wrap.toggleClass( 'search-panel-visible', ! visible );
+ setUserSetting( 'wplink', visible ? '0' : '1' );
+ inputs[ ! visible ? 'search' : 'url' ].focus();
}
};
River = function( element, search ) {
var self = this;
this.element = element;
- this.ul = element.children('ul');
- this.waiting = element.find('.river-waiting');
+ this.ul = element.children( 'ul' );
+ this.contentHeight = element.children( '#link-selector-height' );
+ this.waiting = $( '#river-waiting' );
this.change( search );
this.refresh();
- element.scroll( function(){ self.maybeLoad(); });
- element.delegate('li', 'click', function(e){ self.select( $(this), e ); });
+ $( '#wp-link .query-results, #wp-link #link-selector' ).scroll( function() {
+ self.maybeLoad();
+ });
+ element.on( 'click', 'li', function( event ) {
+ self.select( $( this ), event );
+ });
};
$.extend( River.prototype, {
refresh: function() {
this.deselect();
- this.visible = this.element.is(':visible');
+ this.visible = this.element.is( ':visible' );
},
show: function() {
if ( ! this.visible ) {
@@ -418,11 +414,11 @@ var wpLink;
select: function( li, event ) {
var liHeight, elHeight, liTop, elTop;
- if ( li.hasClass('unselectable') || li == this.selected )
+ if ( li.hasClass( 'unselectable' ) || li == this.selected )
return;
this.deselect();
- this.selected = li.addClass('selected');
+ this.selected = li.addClass( 'selected' );
// Make sure the element is visible
liHeight = li.outerHeight();
elHeight = this.element.height();
@@ -435,11 +431,11 @@ var wpLink;
this.element.scrollTop( elTop + liTop - elHeight + liHeight );
// Trigger the river-select event
- this.element.trigger('river-select', [ li, event, this ]);
+ this.element.trigger( 'river-select', [ li, event, this ] );
},
deselect: function() {
if ( this.selected )
- this.selected.removeClass('selected');
+ this.selected.removeClass( 'selected' );
this.selected = false;
},
prev: function() {
@@ -448,7 +444,7 @@ var wpLink;
var to;
if ( this.selected ) {
- to = this.selected.prev('li');
+ to = this.selected.prev( 'li' );
if ( to.length )
this.select( to );
}
@@ -457,7 +453,7 @@ var wpLink;
if ( ! this.visible )
return;
- var to = this.selected ? this.selected.next('li') : $('li:not(.unselectable):first', this.element);
+ var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element );
if ( to.length )
this.select( to );
},
@@ -478,13 +474,13 @@ var wpLink;
this._search = search;
this.query = new Query( search );
- this.element.scrollTop(0);
+ this.element.scrollTop( 0 );
},
process: function( results, params ) {
var list = '', alt = true, classes = '',
firstPage = params.page == 1;
- if ( !results ) {
+ if ( ! results ) {
if ( firstPage ) {
list += '
' +
wpLinkL10n.noMatchesFound + '';
@@ -509,20 +505,22 @@ var wpLink;
el = this.element,
bottom = el.scrollTop() + el.height();
- if ( ! this.query.ready() || bottom < this.ul.height() - wpLink.riverBottomThreshold )
+ if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold )
return;
setTimeout(function() {
var newTop = el.scrollTop(),
newBottom = newTop + el.height();
- if ( ! self.query.ready() || newBottom < self.ul.height() - wpLink.riverBottomThreshold )
+ if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
return;
self.waiting.show();
el.scrollTop( newTop + self.waiting.outerHeight() );
- self.ajax( function() { self.waiting.hide(); });
+ self.ajax( function() {
+ self.waiting.hide();
+ });
}, wpLink.timeToTriggerRiver );
}
});
@@ -536,7 +534,7 @@ var wpLink;
$.extend( Query.prototype, {
ready: function() {
- return !( this.querying || this.allLoaded );
+ return ! ( this.querying || this.allLoaded );
},
ajax: function( callback ) {
var self = this,
@@ -551,14 +549,14 @@ var wpLink;
this.querying = true;
- $.post( ajaxurl, query, function(r) {
+ $.post( ajaxurl, query, function( r ) {
self.page++;
self.querying = false;
- self.allLoaded = !r;
+ self.allLoaded = ! r;
callback( r, query );
}, 'json' );
}
});
- $(document).ready( wpLink.init );
-})(jQuery);
+ $( document ).ready( wpLink.init );
+})( jQuery );
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index 9c7787ffd3..c80ed52ffa 100644
--- a/src/wp-includes/script-loader.php
+++ b/src/wp-includes/script-loader.php
@@ -338,7 +338,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
- $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), false, 1 );
+ $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array(
'title' => __('Insert/edit link'),
'update' => __('Update'),