diff --git a/wp-admin/includes/internal-linking.php b/wp-admin/includes/internal-linking.php index 04a9e7d7b0..db3262adf9 100644 --- a/wp-admin/includes/internal-linking.php +++ b/wp-admin/includes/internal-linking.php @@ -113,7 +113,7 @@ function wp_link_dialog() {
diff --git a/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js b/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js index 896d83baed..7a91261206 100644 --- a/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js +++ b/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js @@ -10,6 +10,7 @@ var wpLink; lastSearch: '', init : function() { inputs.dialog = $('#wp-link'); + inputs.update = $('#wp-link-update a'); // URL inputs.url = $('#url-field'); // Secondary options @@ -23,7 +24,7 @@ var wpLink; rivers.elements = $('.query-results', inputs.dialog); // Bind event handlers - $('#wp-link-update').click( wpLink.update ); + inputs.update.click( wpLink.update ); $('#wp-link-cancel').click( function() { tinyMCEPopup.close(); } ); rivers.elements.delegate('li', 'click', wpLink.selectInternalLink ) @@ -39,11 +40,9 @@ var wpLink; // Clear previously selected links rivers.elements.find('.selected').removeClass('selected'); - // Clear fields and focus the URL field - inputs.url.val('http://'); - inputs.title.val(''); tinyMCEPopup.restoreSelection(); + // If link exists, select proper values. if ( e = ed.dom.getParent(ed.selection.getNode(), 'A') ) { // Set URL and description. @@ -52,7 +51,19 @@ var wpLink; // Set open in new tab. if ( "_blank" == ed.dom.getAttrib(e, 'target') ) inputs.openInNewTab.attr('checked','checked'); + // Update save prompt. + inputs.update.text( wpLinkL10n.update ); + + // If there's no link, set the default values. + } else { + // Set URL and description to defaults. + // Leave the new tab setting as-is. + inputs.url.val('http://'); + inputs.title.val(''); + // Update save prompt. + inputs.update.text( wpLinkL10n.save ); } + tinyMCEPopup.storeSelection(); // If the focus is moved above the selection changes, // IE will show a flashing cursor over the dialog. diff --git a/wp-includes/js/tinymce/plugins/wplink/js/wplink.js b/wp-includes/js/tinymce/plugins/wplink/js/wplink.js index 22aa72dc6b..679c84b13e 100644 --- a/wp-includes/js/tinymce/plugins/wplink/js/wplink.js +++ b/wp-includes/js/tinymce/plugins/wplink/js/wplink.js @@ -1 +1 @@ -var wpLink;(function(f){var b={},e={},d,a,c;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,lastSearch:"",init:function(){b.dialog=f("#wp-link");b.url=f("#url-field");b.title=f("#link-title-field");b.openInNewTab=f("#link-target-checkbox");b.search=f("#search-field");e.search=new a(f("#search-results"));e.recent=new a(f("#most-recent-results"));e.elements=f(".query-results",b.dialog);f("#wp-link-update").click(wpLink.update);f("#wp-link-cancel").click(function(){tinyMCEPopup.close()});e.elements.delegate("li","click",wpLink.selectInternalLink);b.search.keyup(wpLink.searchInternalLinks);b.dialog.bind("dialogopen",wpLink.refresh)},refresh:function(){var g;d=tinyMCEPopup.editor;e.elements.find(".selected").removeClass("selected");b.url.val("http://");b.title.val("");tinyMCEPopup.restoreSelection();if(g=d.dom.getParent(d.selection.getNode(),"A")){b.url.val(g.href);b.title.val(d.dom.getAttrib(g,"title"));if("_blank"==d.dom.getAttrib(g,"target")){b.openInNewTab.attr("checked","checked")}}tinyMCEPopup.storeSelection();b.url.focus();if(!e.recent.ul.children().length){e.recent.ajax()}},update:function(){var k,h=tinyMCEPopup.editor,i={href:b.url.val(),title:b.title.val(),target:b.openInNewTab.attr("checked")?"_blank":""},l,g,j=i.title?i.title:i.href;tinyMCEPopup.restoreSelection();l=h.dom.getParent(h.selection.getNode(),"A");if(!i.href||i.href=="http://"){if(h.selection.isCollapsed()){tinyMCEPopup.close();return}else{if(l){tinyMCEPopup.execCommand("mceBeginUndoLevel");g=h.selection.getBookmark();h.dom.remove(l,1);h.selection.moveToBookmark(g);tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close();return}}}tinyMCEPopup.execCommand("mceBeginUndoLevel");if(l==null){h.getDoc().execCommand("unlink",false,null);if(h.selection.isCollapsed()){k=h.dom.create("a",{href:"#mce_temp_url#"},j);h.selection.setNode(k)}else{tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1})}tinymce.each(h.dom.select("a"),function(m){if(h.dom.getAttrib(m,"href")=="#mce_temp_url#"){l=m;h.dom.setAttribs(l,i)}})}else{h.dom.setAttribs(l,i)}children=f(l).children();if(l.childNodes.length!=1||l.firstChild.nodeName!="IMG"){h.focus();h.selection.select(l);h.selection.collapse(0);tinyMCEPopup.storeSelection()}tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close()},selectInternalLink:function(){var g=f(this);if(g.hasClass("unselectable")){return}g.siblings(".selected").removeClass("selected");g.addClass("selected");b.url.val(g.children(".item-permalink").val());b.title.val(g.children(".item-title").text())},searchInternalLinks:function(){var h=f(this),i,g=h.val();if(g.length>2){e.recent.element.hide();e.search.element.show();if(wpLink.lastSearch==g){return}wpLink.lastSearch=g;i=h.siblings("img.waiting").show();e.search.change(g);e.search.ajax(function(){i.hide()})}else{e.search.element.hide();e.recent.element.show()}},delayedCallback:function(i,g){var l,k,j,h;if(!g){return i}setTimeout(function(){if(k){return i.apply(h,j)}l=true},g);return function(){if(l){return i.apply(this,arguments)}j=arguments;h=this;k=true}}};a=function(i,h){var g=this;this.element=i;this.ul=i.children("ul");this.waiting=i.find(".river-waiting");this.change(h);i.scroll(function(){g.maybeLoad()})};f.extend(a.prototype,{ajax:function(j){var h=this,i=this.query.page==1?0:wpLink.minRiverAJAXDuration,g=wpLink.delayedCallback(function(k,l){h.process(k,l);if(j){j(k,l)}},i);this.query.ajax(g)},change:function(g){if(this.query&&this._search==g){return}this._search=g;this.query=new c(g);this.element.scrollTop(0)},process:function(g,k){var h="",i=true,j=k.page==1;if(!g){if(j){h+='