Index: src/wp-admin/css/media.css
===================================================================
--- src/wp-admin/css/media.css	(revision 27409)
+++ src/wp-admin/css/media.css	(working copy)
@@ -333,6 +333,14 @@
 	right: 0;
 }
 
+@media screen and ( max-width: 782px ) {
+
+	.find-box-inside {
+		bottom: 69px;
+	}
+
+}
+
 @media screen and ( max-width: 660px ) {
 
 	.find-box {
@@ -344,9 +352,6 @@
 		width: 100%;
 	}
 
-	.find-box-inside {
-		bottom: 69px;
-	}
 }
 
 .ui-find-overlay {
Index: src/wp-includes/class-wp-editor.php
===================================================================
--- src/wp-includes/class-wp-editor.php	(revision 27409)
+++ src/wp-includes/class-wp-editor.php	(working copy)
@@ -492,8 +492,6 @@
 
 		if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) {
 			wp_enqueue_script('wplink');
-			wp_enqueue_script('wpdialogs');
-			wp_enqueue_style('wp-jquery-ui-dialog');
 		}
 
 		if ( in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true) )
@@ -1041,58 +1039,53 @@
 	 * @since 3.1.0
 	 */
 	public static function wp_link_dialog() {
-	?>
-	<div style="display:none;">
-	<form id="wp-link" tabindex="-1">
-	<?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
-	<div id="link-selector">
-		<div id="link-options">
-			<p class="howto"><?php _e( 'Enter the destination URL' ); ?></p>
-			<div>
-				<label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" name="href" /></label>
-			</div>
-			<div>
-				<label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" name="linktitle" /></label>
-			</div>
-			<div class="link-target">
-				<label><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
-			</div>
-		</div>
-		<?php $show_internal = '1' == get_user_setting( 'wplink', '0' ); ?>
-		<p class="howto toggle-arrow <?php if ( $show_internal ) echo 'toggle-arrow-active'; ?>" id="internal-toggle"><?php _e( 'Or link to existing content' ); ?></p>
-		<div id="search-panel"<?php if ( ! $show_internal ) echo ' style="display:none"'; ?>>
-			<div class="link-search-wrapper">
-				<label>
-					<span class="search-label"><?php _e( 'Search' ); ?></span>
-					<input type="search" id="search-field" class="link-search-field" autocomplete="off" />
-					<span class="spinner"></span>
-				</label>
+		?>
+		<div id="link-modal-backdrop"></div>
+		<form id="link-modal" tabindex="-1">
+			<?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
+			<div id="link-modal-title">
+				<?php _e( 'Insert/edit link' ) ?>
+				<div id="link-modal-close"></div>
 			</div>
-			<div id="search-results" class="query-results">
-				<ul></ul>
-				<div class="river-waiting">
-					<span class="spinner"></span>
+			<div id="link-modal-content">
+				<div id="link-modal-content-height">
+					<label for="url-field">
+						<?php _e( 'Destination URL' ); ?>
+						<input id="url-field" type="text" name="href" />
+					</label>
+					<label for="link-title-field">
+						<?php _e( 'Title attribute' ); ?>
+						<input id="link-title-field" type="text" name="linktitle" />
+					</label>
+					<label>
+						<input type="checkbox" id="link-target-checkbox" />
+						<?php _e( 'Open link in a new window/tab' ); ?>
+					</label>
+					<label>
+						<?php _e( 'Search existing content to link' ); ?>
+						<input type="search" id="search-field" class="link-search-field" autocomplete="off" />
+					</label>
+					<div id="search-panel">
+						<div id="search-results" class="query-results">
+							<ul></ul>
+							<div class="river-waiting">
+								<span class="spinner"></span>
+							</div>
+						</div>
+						<div id="most-recent-results" class="query-results">
+							<div class="query-notice"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></div>
+							<ul></ul>
+							<div class="river-waiting">
+								<span class="spinner"></span>
+							</div>
+						</div>
+					</div>
 				</div>
 			</div>
-			<div id="most-recent-results" class="query-results">
-				<div class="query-notice"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></div>
-				<ul></ul>
-				<div class="river-waiting">
-					<span class="spinner"></span>
-				</div>
+			<div id="link-modal-footer">
+				<input type="submit" value="<?php esc_attr_e( 'Insert Link' ); ?>" class="button button-primary alignright" id="wp-link-submit" name="wp-link-submit">
 			</div>
-		</div>
-	</div>
-	<div class="submitbox">
-		<div id="wp-link-update">
-			<input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button-primary" id="wp-link-submit" name="wp-link-submit">
-		</div>
-		<div id="wp-link-cancel">
-			<a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>
-		</div>
-	</div>
-	</form>
-	</div>
-	<?php
+		</form>
+		<?php
 	}
 }
Index: src/wp-includes/css/editor.css
===================================================================
--- src/wp-includes/css/editor.css	(revision 27409)
+++ src/wp-includes/css/editor.css	(working copy)
@@ -862,118 +862,115 @@
 	background-color: #ccc;
 }
 
-/*------------------------------------------------------------------------------
- wp-link
-------------------------------------------------------------------------------*/
-
-#wp-link {
-	background-color: #F5F5F5;
-	line-height: 1.4em;
-	font-size: 12px;
-}
-
-#wp-link ol,
-#wp-link ul {
-	list-style: none;
-	margin: 0;
-	padding: 0;
+/* Link Modal */
+#link-modal {
+	background-color: #fff;
+	display: none;
+	margin-top: -190px;
+	margin-left: -300px;
+	width: 600px;
+	height: 380px;
+	overflow: hidden;
+	position: fixed;
+	top: 50%;
+	left: 50%;
+	z-index: 160000;
 }
 
-#wp-link input[type="text"] {
-	-webkit-box-sizing: border-box;
-	-moz-box-sizing: border-box;
-	box-sizing: border-box;
+#link-modal.link-modal-toggled {
+	height: auto;
+	margin-top: 0;
+	top: 30px;
+	bottom: 30px;
 }
 
-#wp-link input[type="text"],
-#wp-link textarea {
-	border-width: 1px;
-	border-style: solid;
-	-webkit-border-radius: 4px;
-	border-radius: 4px;
-	font-size: 12px;
-	margin: 1px;
-	padding: 3px;
+#link-modal-backdrop {
+	background-color: #000;
+	display: none;
+	opacity: 0.7;
+	position: fixed;
+	top: 0;
+	right: 0;
+	bottom: 0;
+	left: 0;
+	z-index: 159900;
 }
 
-#wp-link #link-options {
-	padding: 10px 0 14px;
+#link-modal-title {
+	background: #fcfcfc;
 	border-bottom: 1px solid #dfdfdf;
-	margin: 0 6px 14px;
-}
-
-#wp-link p.howto {
-	margin: 3px;
+	height: 56px;
+	font-size: 22px;
+	font-weight: 600;
+	line-height: 56px;
+	padding: 0 40px 0 16px;
+	position: absolute;
+	top: 0;
+	right: 0;
+	left: 0;
 }
 
-#wp-link #internal-toggle {
-	display: inline-block;
+#link-modal-close {
+	color: #666;
 	cursor: pointer;
-	padding-left: 18px;
-}
-
-#wp-link .toggle-arrow {
-	background: transparent url(../images/toggle-arrow.png) top left no-repeat;
-	height: 23px;
-	line-height: 23px;
-}
-
-#wp-link .toggle-arrow-active {
-	background-position: center left;
+	text-align: center;
+	width: 40px;
+	height: 40px;
+	position: absolute;
+	top: 0;
+	right: 0;
 }
 
-#wp-link label input[type="text"] {
-	width: 360px;
-	margin-top: 5px;
+#link-modal-close:hover {
+	color: #2ea2cc;
 }
 
-#wp-link #link-options label span,
-#wp-link #search-panel label span.search-label {
-	display: inline-block;
-	width: 80px;
-	text-align: right;
-	padding-right: 5px;
+#link-modal-close:before {
+	font: normal 20px/40px 'dashicons';
+	vertical-align: top;
+	speak: none;
+	-webkit-font-smoothing: antialiased;
+	-moz-osx-font-smoothing: grayscale;
+	content: '\f158';
 }
 
-#wp-link .link-search-field {
-	float: left;
-	width: 220px;
+#link-modal-content {
+	background-color: #fff;
+	padding: 16px;
+	position: absolute;
+	top: 57px;
+	right: 0;
+	bottom: 57px;
+	left: 0;
+	overflow-y: scroll;
 }
 
-#wp-link .link-search-wrapper {
-	margin: 5px 6px 9px;
+#link-modal-content label {
 	display: block;
-	overflow: hidden;
-}
-
-#wp-link .link-search-wrapper span {
-	float: left;
-	margin-top: 4px;
+	padding-bottom: 16px;
 }
 
-#wp-link .link-search-wrapper .spinner {
-	display: none;
-	vertical-align: text-bottom;
+#link-modal ol,
+#link-modal ul {
+	list-style: none;
+	margin: 0;
+	padding: 0;
 }
 
-#wp-link .link-target {
-	width: auto;
-	padding: 3px 0 0;
-	margin: 0 0 0 87px;
-	font-size: 11px;
+#link-modal label input[type="text"],
+#link-modal label input[type="search"] {
+	margin-top: 4px;
+	width: 99%;
 }
 
-#wp-link .query-results {
+#link-modal .query-results {
 	border: 1px #dfdfdf solid;
-	margin: 0 5px 5px;
 	background: #fff;
-	height: 185px;
-	overflow: auto;
 	position: relative;
 }
 
-#wp-link li,
-#wp-link .query-notice {
+#link-modal li,
+#link-modal .query-notice {
 	clear: both;
 	margin-bottom: 0;
 	border-bottom: 1px solid #f1f1f1;
@@ -983,79 +980,92 @@
 	position: relative;
 }
 
-#wp-link li:hover {
-	background: #eaf2fa;
-	color: #151515;
+#link-modal li:last-of-type {
+	border: none;
 }
 
-#wp-link li.unselectable {
-	border-bottom: 1px solid #dfdfdf;
+#link-modal li:hover {
+	background: #eaf2fa;
 }
 
-#wp-link li.unselectable:hover {
-	background: #fff;
-	cursor: auto;
-	color: #333;
+#link-modal li.unselectable:hover {
+	cursor: default;
 }
 
-#wp-link li.selected {
-	background: #ddd;
-	color: #333;
+#link-modal li.selected {
+	background: #f1f1f1;
 }
 
-#wp-link li.selected .item-title {
+#link-modal li.selected .item-title {
 	font-weight: bold;
 }
 
-#wp-link .item-title {
+#link-modal .item-title {
 	display: inline-block;
 	width: 80%;
 }
 
-#wp-link .item-info {
-	text-transform: uppercase;
+#link-modal .item-info {
 	color: #666;
 	font-size: 11px;
+	text-transform: uppercase;
 	position: absolute;
-	right: 5px;
 	top: 4px;
+	right: 5px;
 	bottom: 0;
 }
 
-#wp-link #search-results {
+#link-modal #search-panel,
+#link-modal #search-results,
+#link-modal .river-waiting {
 	display: none;
 }
 
-#wp-link #search-panel {
-	float: left;
-	width: 100%;
-}
-
-#wp-link .river-waiting {
-	display: none;
-	padding: 10px 0;
+#link-modal.link-modal-toggled #search-panel {
+	display: block;
 }
 
-#wp-link .river-waiting .spinner {
-	margin: 0 auto;
+#link-modal .river-waiting .spinner {
 	display: block;
+	margin: 0 auto;
 }
 
-#wp-link .submitbox {
-	padding: 5px 10px;
-	font-size: 11px;
-	overflow: auto;
-	height: 29px;
+#link-modal-footer {
+	background: #fcfcfc;
+	border-top: 1px solid #dfdfdf;
+	padding: 14px 16px;
+	position: absolute;
+	right: 0;
+	bottom: 0;
+	left: 0;
 }
 
-#wp-link-cancel {
-	line-height: 25px;
-	float: left;
+@media screen and ( max-width: 782px ) {
+
+	#link-modal {
+		height: 420px;
+		margin-top: -210px;
+	}
+
+	#link-modal-content {
+		bottom: 69px;
+	}
+
 }
 
-#wp-link-update {
-	line-height: 23px;
-	float: right;
+@media screen and ( max-width: 660px ) {
+
+	#link-modal,
+	#link-modal.link-modal-toggled {
+		height: auto;
+		top: 0;
+		bottom: 0;
+		left: 0;
+		right: 0;
+		margin: 0;
+		width: 100%;
+	}
+
 }
 
 /*!
@@ -1819,7 +1829,6 @@
  	font-family: Arial, sans-serif;
 }
 
-
 /* HiDPI */
 @media print,
   (-o-min-device-pixel-ratio: 5/4),
@@ -1829,14 +1838,6 @@
 	#wp-fullscreen-buttons #wp_fs_image span.mce_image {
 		background: none;
 	}
-
-	#wp-link .toggle-arrow {
-		background: transparent url(../images/toggle-arrow-2x.png) top left no-repeat;
-		-webkit-background-size: 19px 69px;
-		background-size: 19px 69px;
-	}
 }
 
 /* TODO: DFW responsive */
-
-
Index: src/wp-includes/js/wplink.js
===================================================================
--- src/wp-includes/js/wplink.js	(revision 27409)
+++ src/wp-includes/js/wplink.js	(working copy)
@@ -1,7 +1,7 @@
-/* global ajaxurl, tinymce, wpLinkL10n, setUserSetting, wpActiveEditor */
+/* global ajaxurl, tinymce, wpLinkL10n, wpActiveEditor */
 var wpLink;
 
-(function($){
+( function( $ ) {
 	var inputs = {}, rivers = {}, ed, River, Query;
 
 	wpLink = {
@@ -12,54 +12,52 @@
 		lastSearch: '',
 		textarea: '',
 
-		init : function() {
-			inputs.dialog = $('#wp-link');
-			inputs.submit = $('#wp-link-submit');
-			// URL
-			inputs.url = $('#url-field');
-			inputs.nonce = $('#_ajax_linking_nonce');
-			// Secondary options
-			inputs.title = $('#link-title-field');
-			// Advanced Options
-			inputs.openInNewTab = $('#link-target-checkbox');
-			inputs.search = $('#search-field');
-			// Build Rivers
-			rivers.search = new River( $('#search-results') );
-			rivers.recent = new River( $('#most-recent-results') );
-			rivers.elements = $('.query-results', inputs.dialog);
+		init: function() {
+			inputs.dialog = $( '#link-modal' );
+			inputs.backdrop = $( '#link-modal-backdrop' );
+			inputs.close = $( '#link-modal-close' );
+			inputs.submit = $( '#wp-link-submit' );
+			inputs.url = $( '#url-field' );
+			inputs.nonce = $( '#_ajax_linking_nonce' );
+			inputs.title = $( '#link-title-field' );
+			inputs.openInNewTab = $( '#link-target-checkbox' );
+			inputs.search = $( '#search-field' );
+
+			rivers.search = new River( $( '#search-results' ) );
+			rivers.recent = new River( $( '#most-recent-results' ) );
+			rivers.elements = $( '.query-results', inputs.dialog );
 
-			// Bind event handlers
 			inputs.dialog.keydown( wpLink.keydown );
 			inputs.dialog.keyup( wpLink.keyup );
-			inputs.submit.click( function(e){
-				e.preventDefault();
+
+			inputs.submit.click( function( event ){
+				event.preventDefault();
 				wpLink.update();
 			});
-			$('#wp-link-cancel').click( function(e){
-				e.preventDefault();
-				wpLink.close();
+
+			inputs.close.click( wpLink.close );
+			inputs.backdrop.click( wpLink.close );
+
+			inputs.search.focus( function() {
+				inputs.dialog.addClass( 'link-modal-toggled' );
+			});
+			inputs.url.add( inputs.title ).focus( function() {
+				inputs.dialog.removeClass( 'link-modal-toggled' );
 			});
-			$('#internal-toggle').click( wpLink.toggleInternalLinking );
 
-			rivers.elements.bind('river-select', wpLink.updateFields );
+			rivers.elements.on( 'river-select', wpLink.updateFields );
 
 			inputs.search.keyup( wpLink.searchInternalLinks );
-
-			inputs.dialog.bind('wpdialogrefresh', wpLink.refresh);
-			inputs.dialog.bind('wpdialogbeforeopen', wpLink.beforeOpen);
-			inputs.dialog.bind('wpdialogclose', wpLink.onClose);
 		},
 
-		beforeOpen : function() {
+		open: function( editorId ) {
 			wpLink.range = null;
 
 			if ( ! wpLink.isMCE() && document.selection ) {
 				wpLink.textarea.focus();
 				wpLink.range = document.selection.createRange();
 			}
-		},
 
-		open : function( editorId ) {
 			if ( editorId ) {
 				window.wpActiveEditor = editorId;
 			}
@@ -68,7 +66,7 @@
 				return;
 			}
 
-			this.textarea = $( '#' + wpActiveEditor ).get(0);
+			this.textarea = $( '#' + wpActiveEditor ).get( 0 );
 
 			if ( typeof tinymce !== 'undefined' ) {
 				ed = tinymce.get( wpActiveEditor );
@@ -78,37 +76,30 @@
 				}
 			}
 
-			// Initialize the dialog
-			if ( ! inputs.dialog.data('wpdialog') ) {
-				inputs.dialog.wpdialog({
-					title: wpLinkL10n.title,
-					width: 480,
-					height: 'auto',
-					modal: true,
-					dialogClass: 'wp-dialog'
-				});
-			}
-
-			inputs.dialog.wpdialog('open');
+			inputs.dialog.show();
+			inputs.backdrop.show();
+			
+			wpLink.refresh();
 		},
 
-		isMCE : function() {
+		isMCE: function() {
 			return ed && ! ed.isHidden();
 		},
 
-		refresh : function() {
+		refresh: function() {
 			// Refresh rivers (clear links, check visibility)
 			rivers.search.refresh();
 			rivers.recent.refresh();
 
-			if ( wpLink.isMCE() )
+			if ( wpLink.isMCE() ) {
 				wpLink.mceRefresh();
-			else
+			} else {
 				wpLink.setDefaultValues();
+			}
 
 			// Focus the URL field and highlight its contents.
-			//     If this is moved above the selection changes,
-			//     IE will show a flashing cursor over the dialog.
+			// If this is moved above the selection changes,
+			// IE will show a flashing cursor over the dialog.
 			inputs.url.focus()[0].select();
 			// Load the most recent results if this is the first time opening the panel.
 			if ( ! rivers.recent.ul.children().length )
@@ -135,10 +126,6 @@
 		},
 
 		close: function() {
-			inputs.dialog.wpdialog('close');
-		},
-
-		onClose: function() {
 			if ( ! wpLink.isMCE() ) {
 				wpLink.textarea.focus();
 
@@ -147,21 +134,24 @@
 					wpLink.range.select();
 				}
 			}
+			inputs.dialog.hide();
+			inputs.backdrop.hide();
 		},
 
 		getAttrs: function() {
 			return {
-				href : inputs.url.val(),
-				title : inputs.title.val(),
-				target : inputs.openInNewTab.prop('checked') ? '_blank' : ''
+				href: inputs.url.val(),
+				title: inputs.title.val(),
+				target: inputs.openInNewTab.prop('checked') ? '_blank' : ''
 			};
 		},
 
 		update: function() {
-			if ( wpLink.isMCE() )
+			if ( wpLink.isMCE() ) {
 				wpLink.mceUpdate();
-			else
+			} else {
 				wpLink.htmlUpdate();
+			}
 		},
 
 		htmlUpdate: function() {
@@ -204,11 +194,11 @@
 				wpLink.range = null;
 			} else if ( typeof textarea.selectionStart !== 'undefined' ) {
 				// W3C
-				begin       = textarea.selectionStart;
-				end         = textarea.selectionEnd;
-				selection   = textarea.value.substring( begin, end );
-				html        = html + selection + '</a>';
-				cursor      = begin + html.length;
+				begin = textarea.selectionStart;
+				end = textarea.selectionEnd;
+				selection = textarea.value.substring( begin, end );
+				html = html + selection + '</a>';
+				cursor = begin + html.length;
 
 				// If no text is selected, place the cursor inside the closing tag.
 				if ( begin == end )
@@ -255,8 +245,8 @@
 		},
 
 		updateFields: function( e, li, originalEvent ) {
-			inputs.url.val( li.children('.item-permalink').val() );
-			inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() );
+			inputs.url.val( li.children( '.item-permalink' ).val() );
+			inputs.title.val( li.hasClass( 'no-title' ) ? '' : li.children( '.item-title' ).text() );
 			if ( originalEvent && originalEvent.type == 'click' )
 				inputs.url.focus();
 		},
@@ -264,8 +254,8 @@
 		setDefaultValues: function() {
 			// Set URL and description to defaults.
 			// Leave the new tab setting as-is.
-			inputs.url.val('http://');
-			inputs.title.val('');
+			inputs.url.val( 'http://' );
+			inputs.title.val( '' );
 
 			// Update save prompt.
 			inputs.submit.val( wpLinkL10n.save );
@@ -284,10 +274,12 @@
 					return;
 
 				wpLink.lastSearch = search;
-				waiting = t.parent().find('.spinner').show();
+				waiting = t.parent().find( '.spinner' ).show();
 
 				rivers.search.change( search );
-				rivers.search.ajax( function(){ waiting.hide(); });
+				rivers.search.ajax( function(){
+					waiting.hide();
+				});
 			} else {
 				rivers.search.hide();
 				rivers.recent.show();
@@ -353,55 +345,31 @@
 				funcContext = this;
 				funcTriggered = true;
 			};
-		},
-
-		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);
-
-			$(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();
 		}
 	};
 
 	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-modal-content-height' );
+		this.waiting = element.find( '.river-waiting' );
 
 		this.change( search );
 		this.refresh();
 
-		element.scroll( function(){ self.maybeLoad(); });
-		element.delegate('li', 'click', function(e){ self.select( $(this), e ); });
+		$( '#link-modal-content' ).scroll( function() {
+			self.maybeLoad();
+		});
+		element.delegate( 'li', 'click', 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,28 +386,29 @@
 		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();
 			liTop = li.position().top;
 			elTop = this.element.scrollTop();
 
-			if ( liTop < 0 ) // Make first visible element
+			if ( liTop < 0 ) { // Make first visible element
 				this.element.scrollTop( elTop + liTop );
-			else if ( liTop + liHeight > elHeight ) // Make last visible element
+			} else if ( liTop + liHeight > elHeight ) { // Make last visible element
 				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 +417,7 @@
 
 			var to;
 			if ( this.selected ) {
-				to = this.selected.prev('li');
+				to = this.selected.prev( 'li' );
 				if ( to.length )
 					this.select( to );
 			}
@@ -457,7 +426,7 @@
 			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 );
 		},
@@ -481,10 +450,12 @@
 			this.element.scrollTop(0);
 		},
 		process: function( results, params ) {
-			var list = '', alt = true, classes = '',
-				firstPage = params.page == 1;
+			var alt = true,
+				classes = '',
+				firstPage = params.page == 1,
+				list = '';
 
-			if ( !results ) {
+			if ( ! results ) {
 				if ( firstPage ) {
 					list += '<li class="unselectable"><span class="item-title"><em>' +
 						wpLinkL10n.noMatchesFound + '</em></span></li>';
@@ -509,20 +480,22 @@
 				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() {
+			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 +509,7 @@
 
 	$.extend( Query.prototype, {
 		ready: function() {
-			return !( this.querying || this.allLoaded );
+			return ! ( this.querying || this.allLoaded );
 		},
 		ajax: function( callback ) {
 			var self = this,
@@ -551,7 +524,7 @@
 
 			this.querying = true;
 
-			$.post( ajaxurl, query, function(r) {
+			$.post( ajaxurl, query, function( r ) {
 				self.page++;
 				self.querying = false;
 				self.allLoaded = !r;
@@ -560,5 +533,5 @@
 		}
 	});
 
-	$(document).ready( wpLink.init );
-})(jQuery);
+	$( document ).ready( wpLink.init );
+})( jQuery );
Index: src/wp-includes/script-loader.php
===================================================================
--- src/wp-includes/script-loader.php	(revision 27409)
+++ src/wp-includes/script-loader.php	(working copy)
@@ -338,7 +338,7 @@
 
 	$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'),
