Ticket #15544: 15544.2.diff
File 15544.2.diff, 18.8 KB (added by , 14 years ago) |
---|
-
wp-includes/js/tinymce/plugins/wplink/editor_plugin.js
1 (function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){ a.addCommand("WP_Link",function(){a.windowManager.open({id:"wp-link",width:480,height:"auto",wpDialog:true,title:a.getLang("advlink.link_desc")},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(d,c,e){c.setActive("wplink",e.nodeName=="A")})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})();2 No newline at end of file 1 (function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){var c=true;a.addCommand("WP_Link",function(){if(c){return}a.windowManager.open({id:"wp-link",width:480,height:"auto",wpDialog:true,title:a.getLang("advlink.link_desc")},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(e,d,g,f){c=f&&g.nodeName!="A"})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})(); 2 No newline at end of file -
wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css
46 46 background: #fff; 47 47 height: 185px; 48 48 overflow: auto; 49 position: relative; 49 50 } 50 51 #wp-link li, 51 52 #wp-link .query-notice { … … 104 105 #wp-link-update { 105 106 line-height: 23px; 106 107 float: right; 107 }108 #wp-link-update a {109 display: inline-block;110 108 } 111 No newline at end of file -
wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js
7 7 timeToTriggerRiver: 150, 8 8 minRiverAJAXDuration: 200, 9 9 riverBottomThreshold: 5, 10 keySensitivity: 100, 10 11 lastSearch: '', 11 12 init : function() { 12 13 inputs.dialog = $('#wp-link'); 13 inputs. update = $('#wp-link-update a');14 inputs.submit = $('#wp-link-submit'); 14 15 // URL 15 16 inputs.url = $('#url-field'); 16 17 // Secondary options … … 24 25 rivers.elements = $('.query-results', inputs.dialog); 25 26 26 27 // Bind event handlers 27 inputs.update.click( wpLink.update ); 28 $('#wp-link-cancel').click( function() { tinyMCEPopup.close(); } ); 28 inputs.dialog.keydown( wpLink.keydown ); 29 inputs.dialog.keyup( wpLink.keyup ); 30 inputs.submit.click( function(e){ 31 wpLink.update(); 32 e.preventDefault(); 33 }); 34 $('#wp-link-cancel').click( wpLink.cancel ); 29 35 30 rivers.elements. delegate('li', 'click', wpLink.selectInternalLink )36 rivers.elements.bind('river-select', wpLink.updateFields ); 31 37 32 38 inputs.search.keyup( wpLink.searchInternalLinks ); 33 39 34 inputs.dialog.bind(' dialogopen', wpLink.refresh);40 inputs.dialog.bind('wpdialogrefresh', wpLink.refresh); 35 41 }, 36 42 37 43 refresh : function() { 38 44 var e; 39 45 ed = tinyMCEPopup.editor; 40 46 41 // Clear previously selected links 42 rivers.elements.find('.selected').removeClass('selected'); 47 // Refresh rivers (clear links, check visibility) 48 rivers.search.refresh(); 49 rivers.recent.refresh(); 43 50 44 51 tinyMCEPopup.restoreSelection(); 45 52 … … 52 59 if ( "_blank" == ed.dom.getAttrib(e, 'target') ) 53 60 inputs.openInNewTab.attr('checked','checked'); 54 61 // Update save prompt. 55 inputs. update.text( wpLinkL10n.update );62 inputs.submit.val( wpLinkL10n.update ); 56 63 57 64 // If there's no link, set the default values. 58 65 } else { 59 // Set URL and description to defaults. 60 // Leave the new tab setting as-is. 61 inputs.url.val('http://'); 62 inputs.title.val(''); 66 wpLink.setDefaultValues(); 63 67 // Update save prompt. 64 inputs. update.text( wpLinkL10n.save );68 inputs.submit.val( wpLinkL10n.save ); 65 69 } 66 70 67 71 tinyMCEPopup.storeSelection(); 68 // If the focus is moved above the selection changes, 69 // IE will show a flashing cursor over the dialog. 70 inputs.url.focus(); 72 // Focus the URL field and highlight its contents. 73 // If this is moved above the selection changes, 74 // IE will show a flashing cursor over the dialog. 75 inputs.url.focus()[0].select(); 71 76 // Load the most recent results if this is the first time opening the panel. 72 77 if ( ! rivers.recent.ul.children().length ) 73 78 rivers.recent.ajax(); 74 79 }, 80 81 cancel : function() { 82 tinyMCEPopup.close(); 83 }, 75 84 76 85 update : function() { 77 86 var el, … … 86 95 tinyMCEPopup.restoreSelection(); 87 96 e = ed.dom.getParent(ed.selection.getNode(), 'A'); 88 97 89 // If the values are empty ...98 // If the values are empty, unlink and return 90 99 if ( ! attrs.href || attrs.href == 'http://' ) { 91 // ...and nothing is selected, we should return 92 if ( ed.selection.isCollapsed() ) { 93 tinyMCEPopup.close(); 94 return; 95 // ...and a link exists, we should unlink and return 96 } else if ( e ) { 100 if ( e ) { 97 101 tinyMCEPopup.execCommand("mceBeginUndoLevel"); 98 102 b = ed.selection.getBookmark(); 99 103 ed.dom.remove(e, 1); 100 104 ed.selection.moveToBookmark(b); 101 105 tinyMCEPopup.execCommand("mceEndUndoLevel"); 102 106 tinyMCEPopup.close(); 103 return;104 107 } 108 return; 105 109 } 106 110 107 111 tinyMCEPopup.execCommand("mceBeginUndoLevel"); 108 112 109 113 if (e == null) { 110 114 ed.getDoc().execCommand("unlink", false, null); 115 tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1}); 111 116 112 // If no selection exists, create a new link from scratch.113 if ( ed.selection.isCollapsed() ) {114 el = ed.dom.create('a', { href: "#mce_temp_url#" }, defaultContent);115 ed.selection.setNode(el);116 // If a selection exists, wrap it in a link.117 } else {118 tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});119 }120 121 117 tinymce.each(ed.dom.select("a"), function(n) { 122 118 if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') { 123 119 e = n; 124 120 ed.dom.setAttribs(e, attrs); 125 121 } 126 122 }); 123 124 // Sometimes WebKit lets a user create a link where 125 // they shouldn't be able to. In this case, CreateLink 126 // injects "#mce_temp_url#" into their content. Fix it. 127 if ( $(e).text() == '#mce_temp_url#' ) { 128 ed.dom.remove(e); 129 e = null; 130 } 127 131 } else { 128 132 ed.dom.setAttribs(e, attrs); 129 133 } 130 134 131 children = $(e).children();132 135 // Don't move caret if selection was image 133 if ( e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {136 if ( e && (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') ) { 134 137 ed.focus(); 135 138 ed.selection.select(e); 136 139 ed.selection.collapse(0); … … 141 144 tinyMCEPopup.close(); 142 145 }, 143 146 144 selectInternalLink : function() { 145 var t = $(this); 146 if ( t.hasClass('unselectable') ) 147 return; 148 t.siblings('.selected').removeClass('selected'); 149 t.addClass('selected'); 150 inputs.url.val( t.children('.item-permalink').val() ); 151 inputs.title.val( t.children('.item-title').text() ); 147 updateFields : function( e, li, originalEvent ) { 148 inputs.url.val( li.children('.item-permalink').val() ); 149 inputs.title.val( li.children('.item-title').text() ); 150 if ( originalEvent && originalEvent.type == "click" ) 151 inputs.url.focus(); 152 152 }, 153 setDefaultValues : function() { 154 // Set URL and description to defaults. 155 // Leave the new tab setting as-is. 156 inputs.url.val('http://'); 157 inputs.title.val(''); 158 }, 153 159 154 160 searchInternalLinks : function() { 155 161 var t = $(this), waiting, 156 162 search = t.val(); 157 163 158 164 if ( search.length > 2 ) { 159 rivers.recent. element.hide();160 rivers.search. element.show();165 rivers.recent.hide(); 166 rivers.search.show(); 161 167 162 168 // Don't search if the keypress didn't change the title. 163 169 if ( wpLink.lastSearch == search ) … … 169 175 rivers.search.change( search ); 170 176 rivers.search.ajax( function(){ waiting.hide(); }); 171 177 } else { 172 rivers.search. element.hide();173 rivers.recent. element.show();178 rivers.search.hide(); 179 rivers.recent.show(); 174 180 } 175 181 }, 182 183 next : function() { 184 rivers.search.next(); 185 rivers.recent.next(); 186 }, 187 prev : function() { 188 rivers.search.prev(); 189 rivers.recent.prev(); 190 }, 191 192 keydown : function( event ) { 193 var fn, key = $.ui.keyCode; 194 195 switch( event.which ) { 196 case key.UP: 197 fn = 'prev'; 198 case key.DOWN: 199 fn = fn || 'next'; 200 clearInterval( wpLink.keyInterval ); 201 wpLink[ fn ](); 202 wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity ); 203 break; 204 default: 205 return; 206 } 207 event.preventDefault(); 208 }, 209 210 keyup: function( event ) { 211 var key = $.ui.keyCode; 212 213 switch( event.which ) { 214 case key.ESCAPE: 215 wpLink.cancel(); 216 break; 217 case key.UP: 218 case key.DOWN: 219 clearInterval( wpLink.keyInterval ); 220 break; 221 default: 222 return; 223 } 224 event.preventDefault(); 225 }, 176 226 177 227 delayedCallback : function( func, delay ) { 178 228 var timeoutTriggered, funcTriggered, funcArgs, funcContext; … … 205 255 this.waiting = element.find('.river-waiting'); 206 256 207 257 this.change( search ); 258 this.refresh(); 208 259 209 260 element.scroll( function(){ self.maybeLoad(); }); 261 element.delegate('li', 'click', function(e){ self.select( $(this), e ); }); 210 262 }; 211 263 212 264 $.extend( River.prototype, { 265 refresh: function() { 266 this.deselect(); 267 this.visible = this.element.is(':visible'); 268 }, 269 show: function() { 270 if ( ! this.visible ) { 271 this.deselect(); 272 this.element.show(); 273 this.visible = true; 274 } 275 }, 276 hide: function() { 277 this.element.hide(); 278 this.visible = false; 279 }, 280 // Selects a list item and triggers the river-select event. 281 select: function( li, event ) { 282 var liHeight, elHeight, liTop, elTop; 283 284 if ( li.hasClass('unselectable') || li == this.selected ) 285 return; 286 287 this.deselect(); 288 this.selected = li.addClass('selected'); 289 // Make sure the element is visible 290 liHeight = li.outerHeight(); 291 elHeight = this.element.height(); 292 liTop = li.position().top; 293 elTop = this.element.scrollTop(); 294 295 if ( liTop < 0 ) // Make first visible element 296 this.element.scrollTop( elTop + liTop ); 297 else if ( liTop + liHeight > elHeight ) // Make last visible element 298 this.element.scrollTop( elTop + liTop - elHeight + liHeight ); 299 300 // Trigger the river-select event 301 this.element.trigger('river-select', [ li, event, this ]); 302 }, 303 deselect: function() { 304 if ( this.selected ) 305 this.selected.removeClass('selected'); 306 this.selected = false; 307 }, 308 prev: function() { 309 if ( ! this.visible ) 310 return; 311 312 var to; 313 if ( this.selected ) { 314 to = this.selected.prev('li'); 315 if ( to.length ) 316 this.select( to ); 317 } 318 }, 319 next: function() { 320 if ( ! this.visible ) 321 return; 322 323 var to = this.selected ? this.selected.next('li') : $('li:not(.unselectable):first', this.element); 324 if ( to.length ) 325 this.select( to ); 326 }, 213 327 ajax: function( callback ) { 214 328 var self = this, 215 329 delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration, -
wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js
9 9 * @param {string} url Absolute URL to where the plugin is located. 10 10 */ 11 11 init : function(ed, url) { 12 var disabled = true; 13 12 14 // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); 13 15 ed.addCommand('WP_Link', function() { 16 if ( disabled ) 17 return; 14 18 ed.windowManager.open({ 15 19 id : 'wp-link', 16 20 width : 480, … … 29 33 }); 30 34 31 35 ed.addShortcut('alt+shift+a', ed.getLang('advanced.link_desc'), 'WP_Link'); 32 33 // Add a node change handler, selects the button in the UI when a link is selected 34 ed.onNodeChange.add(function(ed, cm, n) { 35 cm.setActive('wplink', n.nodeName == 'A'); 36 37 ed.onNodeChange.add(function(ed, cm, n, co) { 38 disabled = co && n.nodeName != 'A'; 36 39 }); 37 40 }, 38 41 /** -
wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js
1 (function(b){var a=function(c){return function(){if(this.features.wpDialog){return c.apply(this,arguments)}else{return this.parent.apply(this,arguments)}}};tinymce.create("tinymce.plugins.WPDialogs",{init:function(c,d){c.onBeforeRenderUI.add(function(){c.windowManager=new tinymce.WPWindowManager(c)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}}); tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=b("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark();if(tinyMCEPopup){tinyMCEPopup.init()}c.dialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})},close:a(function(){this.element.dialog("close")})});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})(jQuery);2 No newline at end of file 1 (function(b){var a=function(c){return function(){if(this.features.wpDialog){return c.apply(this,arguments)}else{return this.parent.apply(this,arguments)}}};tinymce.create("tinymce.plugins.WPDialogs",{init:function(c,d){c.onBeforeRenderUI.add(function(){c.windowManager=new tinymce.WPWindowManager(c)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}});b.widget("wp.wpdialog",b.ui.dialog,{open:function(){if(tinyMCEPopup){tinyMCEPopup.init()}b.ui.dialog.prototype.open.apply(this,arguments);this.element.focus();this._trigger("refresh")}});tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=b("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark(1);c.wpdialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})},close:a(function(){this.element.wpdialog("close")})});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})(jQuery); 2 No newline at end of file -
wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js
36 36 }; 37 37 } 38 38 }); 39 40 $.widget("wp.wpdialog", $.ui.dialog, { 41 open: function() { 42 // Initialize tinyMCEPopup if it exists. 43 if ( tinyMCEPopup ) 44 tinyMCEPopup.init(); 45 // Open the dialog. 46 $.ui.dialog.prototype.open.apply( this, arguments ); 47 // WebKit leaves focus in the TinyMCE editor unless we shift focus. 48 this.element.focus(); 49 this._trigger('refresh'); 50 } 51 }); 39 52 40 53 tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', { 41 54 WPWindowManager : function(ed) { … … 60 73 t.element = t.windows[ f.id ] = element; 61 74 62 75 // Store selection 63 t.bookmark = t.editor.selection.getBookmark( );76 t.bookmark = t.editor.selection.getBookmark(1); 64 77 65 if ( tinyMCEPopup ) 66 tinyMCEPopup.init(); 67 68 element.dialog({ 78 element.wpdialog({ 69 79 title: f.title, 70 80 width: f.width, 71 81 height: f.height, … … 75 85 }); 76 86 }, 77 87 close : wpDialogFn(function() { 78 this.element. dialog('close');88 this.element.wpdialog('close'); 79 89 }) 80 90 }); 81 91 -
wp-admin/includes/internal-linking.php
70 70 */ 71 71 function wp_link_dialog() { 72 72 ?> 73 < div id="wp-link">73 <form id="wp-link" tabindex="-1"> 74 74 <div id="link-selector"> 75 75 <div id="link-options"> 76 76 <p class="howto"><?php _e( 'Enter the destination URL:' ); ?></p> 77 77 <div> 78 <label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" /></label>78 <label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" tabindex="10" autocomplete="off" /></label> 79 79 </div> 80 80 <div> 81 <label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" /></label>81 <label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" tabindex="20" autocomplete="off" /></label> 82 82 </div> 83 83 <div class="link-target"> 84 <label><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label>84 <label><input type="checkbox" id="link-target-checkbox" tabindex="30" /> <?php _e( 'Open link in a new window/tab' ); ?></label> 85 85 </div> 86 86 </div> 87 87 <div id="search-panel"> … … 89 89 <p class="howto"><?php _e( 'Or, link to existing site content:' ); ?></p> 90 90 <label for="search-field"> 91 91 <span><?php _e( 'Search' ); ?></span> 92 <input type="text" id="search-field" class="link-search-field" />92 <input type="text" id="search-field" class="link-search-field" tabindex="60" autocomplete="off" /> 93 93 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 94 94 </label> 95 95 </div> … … 113 113 <a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a> 114 114 </div> 115 115 <div id="wp-link-update"> 116 < a class="button-primary" href="#"></a>116 <?php submit_button( __('Update'), 'primary', 'wp-link-submit', false, array('tabindex' => 100)); ?> 117 117 </div> 118 118 </div> 119 </ div>119 </form> 120 120 <?php 121 121 } 122 122 ?> 123 No newline at end of file