Ticket #26952: 26952.6.patch
File 26952.6.patch, 24.7 KB (added by , 11 years ago) |
---|
-
src/wp-admin/css/media.css
333 333 right: 0; 334 334 } 335 335 336 @media screen and ( max-width: 782px ) { 337 338 .find-box-inside { 339 bottom: 69px; 340 } 341 342 } 343 336 344 @media screen and ( max-width: 660px ) { 337 345 338 346 .find-box { … … 344 352 width: 100%; 345 353 } 346 354 347 .find-box-inside {348 bottom: 69px;349 }350 355 } 351 356 352 357 .ui-find-overlay { -
src/wp-includes/class-wp-editor.php
492 492 493 493 if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) { 494 494 wp_enqueue_script('wplink'); 495 wp_enqueue_script('wpdialogs');496 wp_enqueue_style('wp-jquery-ui-dialog');497 495 } 498 496 499 497 if ( in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true) ) … … 1041 1039 * @since 3.1.0 1042 1040 */ 1043 1041 public static function wp_link_dialog() { 1044 ?> 1045 <div style="display:none;"> 1046 <form id="wp-link" tabindex="-1"> 1047 <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> 1048 <div id="link-selector"> 1049 <div id="link-options"> 1050 <p class="howto"><?php _e( 'Enter the destination URL' ); ?></p> 1051 <div> 1052 <label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" name="href" /></label> 1053 </div> 1054 <div> 1055 <label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" name="linktitle" /></label> 1056 </div> 1057 <div class="link-target"> 1058 <label><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label> 1059 </div> 1060 </div> 1061 <?php $show_internal = '1' == get_user_setting( 'wplink', '0' ); ?> 1062 <p class="howto toggle-arrow <?php if ( $show_internal ) echo 'toggle-arrow-active'; ?>" id="internal-toggle"><?php _e( 'Or link to existing content' ); ?></p> 1063 <div id="search-panel"<?php if ( ! $show_internal ) echo ' style="display:none"'; ?>> 1064 <div class="link-search-wrapper"> 1065 <label> 1066 <span class="search-label"><?php _e( 'Search' ); ?></span> 1067 <input type="search" id="search-field" class="link-search-field" autocomplete="off" /> 1068 <span class="spinner"></span> 1069 </label> 1042 ?> 1043 <div id="link-modal-backdrop"></div> 1044 <form id="link-modal" tabindex="-1"> 1045 <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> 1046 <div id="link-modal-title"> 1047 <?php _e( 'Insert/edit link' ) ?> 1048 <div id="link-modal-close"></div> 1070 1049 </div> 1071 <div id="search-results" class="query-results"> 1072 <ul></ul> 1073 <div class="river-waiting"> 1074 <span class="spinner"></span> 1050 <div id="link-modal-content"> 1051 <div id="link-modal-content-height"> 1052 <label for="url-field"> 1053 <?php _e( 'Destination URL' ); ?> 1054 <input id="url-field" type="text" name="href" /> 1055 </label> 1056 <label for="link-title-field"> 1057 <?php _e( 'Title attribute' ); ?> 1058 <input id="link-title-field" type="text" name="linktitle" /> 1059 </label> 1060 <label> 1061 <input type="checkbox" id="link-target-checkbox" /> 1062 <?php _e( 'Open link in a new window/tab' ); ?> 1063 </label> 1064 <label> 1065 <?php _e( 'Search existing content to link' ); ?> 1066 <input type="search" id="search-field" class="link-search-field" autocomplete="off" /> 1067 </label> 1068 <div id="search-panel"> 1069 <div id="search-results" class="query-results"> 1070 <ul></ul> 1071 <div class="river-waiting"> 1072 <span class="spinner"></span> 1073 </div> 1074 </div> 1075 <div id="most-recent-results" class="query-results"> 1076 <div class="query-notice"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></div> 1077 <ul></ul> 1078 <div class="river-waiting"> 1079 <span class="spinner"></span> 1080 </div> 1081 </div> 1082 </div> 1075 1083 </div> 1076 1084 </div> 1077 <div id="most-recent-results" class="query-results"> 1078 <div class="query-notice"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></div> 1079 <ul></ul> 1080 <div class="river-waiting"> 1081 <span class="spinner"></span> 1082 </div> 1085 <div id="link-modal-footer"> 1086 <input type="submit" value="<?php esc_attr_e( 'Insert Link' ); ?>" class="button button-primary alignright" id="wp-link-submit" name="wp-link-submit"> 1083 1087 </div> 1084 </div> 1085 </div> 1086 <div class="submitbox"> 1087 <div id="wp-link-update"> 1088 <input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button-primary" id="wp-link-submit" name="wp-link-submit"> 1089 </div> 1090 <div id="wp-link-cancel"> 1091 <a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a> 1092 </div> 1093 </div> 1094 </form> 1095 </div> 1096 <?php 1088 </form> 1089 <?php 1097 1090 } 1098 1091 } -
src/wp-includes/css/editor.css
862 862 background-color: #ccc; 863 863 } 864 864 865 /*------------------------------------------------------------------------------ 866 wp-link 867 ------------------------------------------------------------------------------*/ 868 869 #wp-link { 870 background-color: #F5F5F5; 871 line-height: 1.4em; 872 font-size: 12px; 873 } 874 875 #wp-link ol, 876 #wp-link ul { 877 list-style: none; 878 margin: 0; 879 padding: 0; 865 /* Link Modal */ 866 #link-modal { 867 background-color: #fff; 868 display: none; 869 margin-top: -190px; 870 margin-left: -300px; 871 width: 600px; 872 height: 380px; 873 overflow: hidden; 874 position: fixed; 875 top: 50%; 876 left: 50%; 877 z-index: 160000; 880 878 } 881 879 882 #wp-link input[type="text"] { 883 -webkit-box-sizing: border-box; 884 -moz-box-sizing: border-box; 885 box-sizing: border-box; 880 #link-modal.link-modal-toggled { 881 height: auto; 882 margin-top: 0; 883 top: 30px; 884 bottom: 30px; 886 885 } 887 886 888 #wp-link input[type="text"], 889 #wp-link textarea { 890 border-width: 1px; 891 border-style: solid; 892 -webkit-border-radius: 4px; 893 border-radius: 4px; 894 font-size: 12px; 895 margin: 1px; 896 padding: 3px; 887 #link-modal-backdrop { 888 background-color: #000; 889 display: none; 890 opacity: 0.7; 891 position: fixed; 892 top: 0; 893 right: 0; 894 bottom: 0; 895 left: 0; 896 z-index: 159900; 897 897 } 898 898 899 # wp-link #link-options{900 padding: 10px 0 14px;899 #link-modal-title { 900 background: #fcfcfc; 901 901 border-bottom: 1px solid #dfdfdf; 902 margin: 0 6px 14px; 903 } 904 905 #wp-link p.howto { 906 margin: 3px; 902 height: 56px; 903 font-size: 22px; 904 font-weight: 600; 905 line-height: 56px; 906 padding: 0 40px 0 16px; 907 position: absolute; 908 top: 0; 909 right: 0; 910 left: 0; 907 911 } 908 912 909 # wp-link #internal-toggle {910 display: inline-block;913 #link-modal-close { 914 color: #666; 911 915 cursor: pointer; 912 padding-left: 18px; 913 } 914 915 #wp-link .toggle-arrow { 916 background: transparent url(../images/toggle-arrow.png) top left no-repeat; 917 height: 23px; 918 line-height: 23px; 919 } 920 921 #wp-link .toggle-arrow-active { 922 background-position: center left; 916 text-align: center; 917 width: 40px; 918 height: 40px; 919 position: absolute; 920 top: 0; 921 right: 0; 923 922 } 924 923 925 #wp-link label input[type="text"] { 926 width: 360px; 927 margin-top: 5px; 924 #link-modal-close:hover { 925 color: #2ea2cc; 928 926 } 929 927 930 #wp-link #link-options label span, 931 #wp-link #search-panel label span.search-label { 932 display: inline-block; 933 width: 80px; 934 text-align: right; 935 padding-right: 5px; 928 #link-modal-close:before { 929 font: normal 20px/40px 'dashicons'; 930 vertical-align: top; 931 speak: none; 932 -webkit-font-smoothing: antialiased; 933 -moz-osx-font-smoothing: grayscale; 934 content: '\f158'; 936 935 } 937 936 938 #wp-link .link-search-field { 939 float: left; 940 width: 220px; 937 #link-modal-content { 938 background-color: #fff; 939 padding: 16px; 940 position: absolute; 941 top: 57px; 942 right: 0; 943 bottom: 57px; 944 left: 0; 945 overflow-y: scroll; 941 946 } 942 947 943 #wp-link .link-search-wrapper { 944 margin: 5px 6px 9px; 948 #link-modal-content label { 945 949 display: block; 946 overflow: hidden; 947 } 948 949 #wp-link .link-search-wrapper span { 950 float: left; 951 margin-top: 4px; 950 padding-bottom: 16px; 952 951 } 953 952 954 #wp-link .link-search-wrapper .spinner { 955 display: none; 956 vertical-align: text-bottom; 953 #link-modal ol, 954 #link-modal ul { 955 list-style: none; 956 margin: 0; 957 padding: 0; 957 958 } 958 959 959 #wp-link .link-target { 960 width: auto; 961 padding: 3px 0 0; 962 margin: 0 0 0 87px; 963 font-size: 11px; 960 #link-modal label input[type="text"], 961 #link-modal label input[type="search"] { 962 margin-top: 4px; 963 width: 99%; 964 964 } 965 965 966 # wp-link.query-results {966 #link-modal .query-results { 967 967 border: 1px #dfdfdf solid; 968 margin: 0 5px 5px;969 968 background: #fff; 970 height: 185px;971 overflow: auto;972 969 position: relative; 973 970 } 974 971 975 # wp-linkli,976 # wp-link.query-notice {972 #link-modal li, 973 #link-modal .query-notice { 977 974 clear: both; 978 975 margin-bottom: 0; 979 976 border-bottom: 1px solid #f1f1f1; … … 983 980 position: relative; 984 981 } 985 982 986 #wp-link li:hover { 987 background: #eaf2fa; 988 color: #151515; 983 #link-modal li:last-of-type { 984 border: none; 989 985 } 990 986 991 # wp-link li.unselectable{992 b order-bottom: 1px solid #dfdfdf;987 #link-modal li:hover { 988 background: #eaf2fa; 993 989 } 994 990 995 #wp-link li.unselectable:hover { 996 background: #fff; 997 cursor: auto; 998 color: #333; 991 #link-modal li.unselectable:hover { 992 cursor: default; 999 993 } 1000 994 1001 #wp-link li.selected { 1002 background: #ddd; 1003 color: #333; 995 #link-modal li.selected { 996 background: #f1f1f1; 1004 997 } 1005 998 1006 # wp-linkli.selected .item-title {999 #link-modal li.selected .item-title { 1007 1000 font-weight: bold; 1008 1001 } 1009 1002 1010 # wp-link.item-title {1003 #link-modal .item-title { 1011 1004 display: inline-block; 1012 1005 width: 80%; 1013 1006 } 1014 1007 1015 #wp-link .item-info { 1016 text-transform: uppercase; 1008 #link-modal .item-info { 1017 1009 color: #666; 1018 1010 font-size: 11px; 1011 text-transform: uppercase; 1019 1012 position: absolute; 1020 right: 5px;1021 1013 top: 4px; 1014 right: 5px; 1022 1015 bottom: 0; 1023 1016 } 1024 1017 1025 #wp-link #search-results { 1018 #link-modal #search-panel, 1019 #link-modal #search-results, 1020 #link-modal .river-waiting { 1026 1021 display: none; 1027 1022 } 1028 1023 1029 #wp-link #search-panel { 1030 float: left; 1031 width: 100%; 1032 } 1033 1034 #wp-link .river-waiting { 1035 display: none; 1036 padding: 10px 0; 1024 #link-modal.link-modal-toggled #search-panel { 1025 display: block; 1037 1026 } 1038 1027 1039 #wp-link .river-waiting .spinner { 1040 margin: 0 auto; 1028 #link-modal .river-waiting .spinner { 1041 1029 display: block; 1030 margin: 0 auto; 1042 1031 } 1043 1032 1044 #wp-link .submitbox { 1045 padding: 5px 10px; 1046 font-size: 11px; 1047 overflow: auto; 1048 height: 29px; 1033 #link-modal-footer { 1034 background: #fcfcfc; 1035 border-top: 1px solid #dfdfdf; 1036 padding: 14px 16px; 1037 position: absolute; 1038 right: 0; 1039 bottom: 0; 1040 left: 0; 1049 1041 } 1050 1042 1051 #wp-link-cancel { 1052 line-height: 25px; 1053 float: left; 1043 @media screen and ( max-width: 782px ) { 1044 1045 #link-modal { 1046 height: 420px; 1047 margin-top: -210px; 1048 } 1049 1050 #link-modal-content { 1051 bottom: 69px; 1052 } 1053 1054 1054 } 1055 1055 1056 #wp-link-update { 1057 line-height: 23px; 1058 float: right; 1056 @media screen and ( max-width: 660px ) { 1057 1058 #link-modal, 1059 #link-modal.link-modal-toggled { 1060 height: auto; 1061 top: 0; 1062 bottom: 0; 1063 left: 0; 1064 right: 0; 1065 margin: 0; 1066 width: 100%; 1067 } 1068 1059 1069 } 1060 1070 1061 1071 /*! … … 1819 1829 font-family: Arial, sans-serif; 1820 1830 } 1821 1831 1822 1823 1832 /* HiDPI */ 1824 1833 @media print, 1825 1834 (-o-min-device-pixel-ratio: 5/4), … … 1829 1838 #wp-fullscreen-buttons #wp_fs_image span.mce_image { 1830 1839 background: none; 1831 1840 } 1832 1833 #wp-link .toggle-arrow {1834 background: transparent url(../images/toggle-arrow-2x.png) top left no-repeat;1835 -webkit-background-size: 19px 69px;1836 background-size: 19px 69px;1837 }1838 1841 } 1839 1842 1840 1843 /* TODO: DFW responsive */ 1841 1842 -
src/wp-includes/js/wplink.js
1 /* global ajaxurl, tinymce, wpLinkL10n, setUserSetting,wpActiveEditor */1 /* global ajaxurl, tinymce, wpLinkL10n, wpActiveEditor */ 2 2 var wpLink; 3 3 4 ( function($){4 ( function( $ ) { 5 5 var inputs = {}, rivers = {}, ed, River, Query; 6 6 7 7 wpLink = { … … 12 12 lastSearch: '', 13 13 textarea: '', 14 14 15 init : function() { 16 inputs.dialog = $('#wp-link'); 17 inputs.submit = $('#wp-link-submit'); 18 // URL 19 inputs.url = $('#url-field'); 20 inputs.nonce = $('#_ajax_linking_nonce'); 21 // Secondary options 22 inputs.title = $('#link-title-field'); 23 // Advanced Options 24 inputs.openInNewTab = $('#link-target-checkbox'); 25 inputs.search = $('#search-field'); 26 // Build Rivers 27 rivers.search = new River( $('#search-results') ); 28 rivers.recent = new River( $('#most-recent-results') ); 29 rivers.elements = $('.query-results', inputs.dialog); 15 init: function() { 16 inputs.dialog = $( '#link-modal' ); 17 inputs.backdrop = $( '#link-modal-backdrop' ); 18 inputs.close = $( '#link-modal-close' ); 19 inputs.submit = $( '#wp-link-submit' ); 20 inputs.url = $( '#url-field' ); 21 inputs.nonce = $( '#_ajax_linking_nonce' ); 22 inputs.title = $( '#link-title-field' ); 23 inputs.openInNewTab = $( '#link-target-checkbox' ); 24 inputs.search = $( '#search-field' ); 25 26 rivers.search = new River( $( '#search-results' ) ); 27 rivers.recent = new River( $( '#most-recent-results' ) ); 28 rivers.elements = $( '.query-results', inputs.dialog ); 30 29 31 // Bind event handlers32 30 inputs.dialog.keydown( wpLink.keydown ); 33 31 inputs.dialog.keyup( wpLink.keyup ); 34 inputs.submit.click( function(e){ 35 e.preventDefault(); 32 33 inputs.submit.click( function( event ){ 34 event.preventDefault(); 36 35 wpLink.update(); 37 36 }); 38 $('#wp-link-cancel').click( function(e){ 39 e.preventDefault(); 40 wpLink.close(); 37 38 inputs.close.click( wpLink.close ); 39 inputs.backdrop.click( wpLink.close ); 40 41 inputs.search.focus( function() { 42 inputs.dialog.addClass( 'link-modal-toggled' ); 43 }); 44 inputs.url.add( inputs.title ).focus( function() { 45 inputs.dialog.removeClass( 'link-modal-toggled' ); 41 46 }); 42 $('#internal-toggle').click( wpLink.toggleInternalLinking );43 47 44 rivers.elements. bind('river-select', wpLink.updateFields );48 rivers.elements.on( 'river-select', wpLink.updateFields ); 45 49 46 50 inputs.search.keyup( wpLink.searchInternalLinks ); 47 48 inputs.dialog.bind('wpdialogrefresh', wpLink.refresh);49 inputs.dialog.bind('wpdialogbeforeopen', wpLink.beforeOpen);50 inputs.dialog.bind('wpdialogclose', wpLink.onClose);51 51 }, 52 52 53 beforeOpen : function() {53 open: function( editorId ) { 54 54 wpLink.range = null; 55 55 56 56 if ( ! wpLink.isMCE() && document.selection ) { 57 57 wpLink.textarea.focus(); 58 58 wpLink.range = document.selection.createRange(); 59 59 } 60 },61 60 62 open : function( editorId ) {63 61 if ( editorId ) { 64 62 window.wpActiveEditor = editorId; 65 63 } … … 68 66 return; 69 67 } 70 68 71 this.textarea = $( '#' + wpActiveEditor ).get( 0);69 this.textarea = $( '#' + wpActiveEditor ).get( 0 ); 72 70 73 71 if ( typeof tinymce !== 'undefined' ) { 74 72 ed = tinymce.get( wpActiveEditor ); … … 78 76 } 79 77 } 80 78 81 // Initialize the dialog 82 if ( ! inputs.dialog.data('wpdialog') ) { 83 inputs.dialog.wpdialog({ 84 title: wpLinkL10n.title, 85 width: 480, 86 height: 'auto', 87 modal: true, 88 dialogClass: 'wp-dialog' 89 }); 90 } 91 92 inputs.dialog.wpdialog('open'); 79 inputs.dialog.show(); 80 inputs.backdrop.show(); 81 82 wpLink.refresh(); 93 83 }, 94 84 95 isMCE 85 isMCE: function() { 96 86 return ed && ! ed.isHidden(); 97 87 }, 98 88 99 refresh 89 refresh: function() { 100 90 // Refresh rivers (clear links, check visibility) 101 91 rivers.search.refresh(); 102 92 rivers.recent.refresh(); 103 93 104 if ( wpLink.isMCE() ) 94 if ( wpLink.isMCE() ) { 105 95 wpLink.mceRefresh(); 106 else96 } else { 107 97 wpLink.setDefaultValues(); 98 } 108 99 109 100 // Focus the URL field and highlight its contents. 110 // 111 // 101 // If this is moved above the selection changes, 102 // IE will show a flashing cursor over the dialog. 112 103 inputs.url.focus()[0].select(); 113 104 // Load the most recent results if this is the first time opening the panel. 114 105 if ( ! rivers.recent.ul.children().length ) … … 135 126 }, 136 127 137 128 close: function() { 138 inputs.dialog.wpdialog('close');139 },140 141 onClose: function() {142 129 if ( ! wpLink.isMCE() ) { 143 130 wpLink.textarea.focus(); 144 131 … … 147 134 wpLink.range.select(); 148 135 } 149 136 } 137 inputs.dialog.hide(); 138 inputs.backdrop.hide(); 150 139 }, 151 140 152 141 getAttrs: function() { 153 142 return { 154 href 155 title 156 target 143 href: inputs.url.val(), 144 title: inputs.title.val(), 145 target: inputs.openInNewTab.prop('checked') ? '_blank' : '' 157 146 }; 158 147 }, 159 148 160 149 update: function() { 161 if ( wpLink.isMCE() ) 150 if ( wpLink.isMCE() ) { 162 151 wpLink.mceUpdate(); 163 else152 } else { 164 153 wpLink.htmlUpdate(); 154 } 165 155 }, 166 156 167 157 htmlUpdate: function() { … … 204 194 wpLink.range = null; 205 195 } else if ( typeof textarea.selectionStart !== 'undefined' ) { 206 196 // W3C 207 begin 208 end 209 selection 210 html 211 cursor 197 begin = textarea.selectionStart; 198 end = textarea.selectionEnd; 199 selection = textarea.value.substring( begin, end ); 200 html = html + selection + '</a>'; 201 cursor = begin + html.length; 212 202 213 203 // If no text is selected, place the cursor inside the closing tag. 214 204 if ( begin == end ) … … 255 245 }, 256 246 257 247 updateFields: function( e, li, originalEvent ) { 258 inputs.url.val( li.children( '.item-permalink').val() );259 inputs.title.val( li.hasClass( 'no-title') ? '' : li.children('.item-title').text() );248 inputs.url.val( li.children( '.item-permalink' ).val() ); 249 inputs.title.val( li.hasClass( 'no-title' ) ? '' : li.children( '.item-title' ).text() ); 260 250 if ( originalEvent && originalEvent.type == 'click' ) 261 251 inputs.url.focus(); 262 252 }, … … 264 254 setDefaultValues: function() { 265 255 // Set URL and description to defaults. 266 256 // Leave the new tab setting as-is. 267 inputs.url.val( 'http://');268 inputs.title.val( '');257 inputs.url.val( 'http://' ); 258 inputs.title.val( '' ); 269 259 270 260 // Update save prompt. 271 261 inputs.submit.val( wpLinkL10n.save ); … … 284 274 return; 285 275 286 276 wpLink.lastSearch = search; 287 waiting = t.parent().find( '.spinner').show();277 waiting = t.parent().find( '.spinner' ).show(); 288 278 289 279 rivers.search.change( search ); 290 rivers.search.ajax( function(){ waiting.hide(); }); 280 rivers.search.ajax( function(){ 281 waiting.hide(); 282 }); 291 283 } else { 292 284 rivers.search.hide(); 293 285 rivers.recent.show(); … … 353 345 funcContext = this; 354 346 funcTriggered = true; 355 347 }; 356 },357 358 toggleInternalLinking: function( event ) {359 var panel = $('#search-panel'),360 widget = inputs.dialog.wpdialog('widget'),361 // We're about to toggle visibility; it's currently the opposite362 visible = !panel.is(':visible'),363 win = $(window);364 365 $(this).toggleClass('toggle-arrow-active', visible);366 367 inputs.dialog.height('auto');368 panel.slideToggle( 300, function() {369 setUserSetting('wplink', visible ? '1' : '0');370 inputs[ visible ? 'search' : 'url' ].focus();371 372 // Move the box if the box is now expanded, was opened in a collapsed state,373 // and if it needs to be moved. (Judged by bottom not being positive or374 // bottom being smaller than top.)375 var scroll = win.scrollTop(),376 top = widget.offset().top,377 bottom = top + widget.outerHeight(),378 diff = bottom - win.height();379 380 if ( diff > scroll ) {381 widget.animate({'top': diff < top ? top - diff : scroll }, 200);382 }383 });384 event.preventDefault();385 348 } 386 349 }; 387 350 388 351 River = function( element, search ) { 389 352 var self = this; 390 353 this.element = element; 391 this.ul = element.children('ul'); 392 this.waiting = element.find('.river-waiting'); 354 this.ul = element.children( 'ul' ); 355 this.contentHeight = element.children( '#link-modal-content-height' ); 356 this.waiting = element.find( '.river-waiting' ); 393 357 394 358 this.change( search ); 395 359 this.refresh(); 396 360 397 element.scroll( function(){ self.maybeLoad(); }); 398 element.delegate('li', 'click', function(e){ self.select( $(this), e ); }); 361 $( '#link-modal-content' ).scroll( function() { 362 self.maybeLoad(); 363 }); 364 element.delegate( 'li', 'click', function( event ) { 365 self.select( $(this), event ); 366 }); 399 367 }; 400 368 401 369 $.extend( River.prototype, { 402 370 refresh: function() { 403 371 this.deselect(); 404 this.visible = this.element.is( ':visible');372 this.visible = this.element.is( ':visible' ); 405 373 }, 406 374 show: function() { 407 375 if ( ! this.visible ) { … … 418 386 select: function( li, event ) { 419 387 var liHeight, elHeight, liTop, elTop; 420 388 421 if ( li.hasClass( 'unselectable') || li == this.selected )389 if ( li.hasClass( 'unselectable' ) || li == this.selected ) 422 390 return; 423 391 424 392 this.deselect(); 425 this.selected = li.addClass( 'selected');393 this.selected = li.addClass( 'selected' ); 426 394 // Make sure the element is visible 427 395 liHeight = li.outerHeight(); 428 396 elHeight = this.element.height(); 429 397 liTop = li.position().top; 430 398 elTop = this.element.scrollTop(); 431 399 432 if ( liTop < 0 ) // Make first visible element400 if ( liTop < 0 ) { // Make first visible element 433 401 this.element.scrollTop( elTop + liTop ); 434 else if ( liTop + liHeight > elHeight )// Make last visible element402 } else if ( liTop + liHeight > elHeight ) { // Make last visible element 435 403 this.element.scrollTop( elTop + liTop - elHeight + liHeight ); 404 } 436 405 437 406 // Trigger the river-select event 438 this.element.trigger( 'river-select', [ li, event, this ]);407 this.element.trigger( 'river-select', [ li, event, this ] ); 439 408 }, 440 409 deselect: function() { 441 410 if ( this.selected ) 442 this.selected.removeClass( 'selected');411 this.selected.removeClass( 'selected' ); 443 412 this.selected = false; 444 413 }, 445 414 prev: function() { … … 448 417 449 418 var to; 450 419 if ( this.selected ) { 451 to = this.selected.prev( 'li');420 to = this.selected.prev( 'li' ); 452 421 if ( to.length ) 453 422 this.select( to ); 454 423 } … … 457 426 if ( ! this.visible ) 458 427 return; 459 428 460 var to = this.selected ? this.selected.next( 'li') : $('li:not(.unselectable):first', this.element);429 var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element); 461 430 if ( to.length ) 462 431 this.select( to ); 463 432 }, … … 481 450 this.element.scrollTop(0); 482 451 }, 483 452 process: function( results, params ) { 484 var list = '', alt = true, classes = '', 485 firstPage = params.page == 1; 453 var alt = true, 454 classes = '', 455 firstPage = params.page == 1, 456 list = ''; 486 457 487 if ( ! results ) {458 if ( ! results ) { 488 459 if ( firstPage ) { 489 460 list += '<li class="unselectable"><span class="item-title"><em>' + 490 461 wpLinkL10n.noMatchesFound + '</em></span></li>'; … … 509 480 el = this.element, 510 481 bottom = el.scrollTop() + el.height(); 511 482 512 if ( ! this.query.ready() || bottom < this. ul.height() - wpLink.riverBottomThreshold )483 if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold ) 513 484 return; 514 485 515 setTimeout( function() {486 setTimeout( function() { 516 487 var newTop = el.scrollTop(), 517 488 newBottom = newTop + el.height(); 518 489 519 if ( ! self.query.ready() || newBottom < self. ul.height() - wpLink.riverBottomThreshold )490 if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold ) 520 491 return; 521 492 522 493 self.waiting.show(); 523 494 el.scrollTop( newTop + self.waiting.outerHeight() ); 524 495 525 self.ajax( function() { self.waiting.hide(); }); 496 self.ajax( function() { 497 self.waiting.hide(); 498 }); 526 499 }, wpLink.timeToTriggerRiver ); 527 500 } 528 501 }); … … 536 509 537 510 $.extend( Query.prototype, { 538 511 ready: function() { 539 return ! ( this.querying || this.allLoaded );512 return ! ( this.querying || this.allLoaded ); 540 513 }, 541 514 ajax: function( callback ) { 542 515 var self = this, … … 551 524 552 525 this.querying = true; 553 526 554 $.post( ajaxurl, query, function( r) {527 $.post( ajaxurl, query, function( r ) { 555 528 self.page++; 556 529 self.querying = false; 557 530 self.allLoaded = !r; … … 560 533 } 561 534 }); 562 535 563 $( document).ready( wpLink.init );564 })( jQuery);536 $( document ).ready( wpLink.init ); 537 })( jQuery ); -
src/wp-includes/script-loader.php
338 338 339 339 $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 ); 340 340 341 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery' , 'wpdialogs'), false, 1 );341 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery' ), false, 1 ); 342 342 did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( 343 343 'title' => __('Insert/edit link'), 344 344 'update' => __('Update'),