diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.js b/wp-includes/js/tinymce/plugins/wplink/plugin.js index 9f1a4eb91e..c426e80128 100644 --- a/wp-includes/js/tinymce/plugins/wplink/plugin.js +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.js @@ -56,7 +56,7 @@ renderHtml: function() { return ( '' ); @@ -235,6 +235,11 @@ inputInstance.reset(); editor.nodeChanged(); + + // Audible confirmation message when a link has been inserted in the Editor. + if ( typeof window.wp !== 'undefined' && window.wp.a11y && typeof window.wpLinkL10n !== 'undefined' ) { + window.wp.a11y.speak( window.wpLinkL10n.linkInserted ); + } } ); editor.addCommand( 'wp_link_cancel', function() { @@ -371,11 +376,22 @@ }, focus: function( event, ui ) { $input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID ); + /* + * Don't empty the URL input field, when using the arrow keys to + * highlight items. See api.jqueryui.com/autocomplete/#event-focus + */ event.preventDefault(); }, select: function( event, ui ) { $input.val( ui.item.permalink ); $( element.firstChild.nextSibling ).val( ui.item.title ); + + if ( 9 === event.keyCode && typeof window.wp !== 'undefined' && + window.wp.a11y && typeof window.wpLinkL10n !== 'undefined' ) { + // Audible confirmation message when a link has been selected. + window.wp.a11y.speak( window.wpLinkL10n.linkSelected ); + } + return false; }, open: function() { @@ -413,13 +429,21 @@ 'aria-autocomplete': 'list', 'aria-expanded': 'false', 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' ) - } ) + } ) .on( 'focus', function() { - $input.autocomplete( 'search' ); + var inputValue = $input.val(); + /* + * Don't trigger a search if the URL field already has a link or is empty. + * Also, avoids screen readers announce `No search results`. + */ + if ( inputValue && ! /^https?:/.test( inputValue ) ) { + $input.autocomplete( 'search' ); + } } ) .autocomplete( 'widget' ) .addClass( 'wplink-autocomplete' ) - .attr( 'role', 'listbox' ); + .attr( 'role', 'listbox' ) + .removeAttr( 'tabindex' ); // Remove the `tabindex=0` attribute added by jQuery UI. } tinymce.$( input ).on( 'keydown', function( event ) { @@ -483,7 +507,20 @@ var url = inputInstance.getURL() || null, text = inputInstance.getLinkText() || null; - editor.focus(); // Needed for IE + /* + * Accessibility note: moving focus back to the editor confuses + * screen readers. They will announce again the Editor ARIA role + * `application` and the iframe `title` attribute. + * + * Unfortunately IE looses the selection when the editor iframe + * looses focus, so without returning focus to the editor, the code + * in the modal will not be able to get the selection, place the caret + * at the same location, etc. + */ + if ( tinymce.Env.ie ) { + editor.focus(); // Needed for IE + } + window.wpLink.open( editor.id, url, text, linkNode ); editToolbar.tempHide = true; diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js index e3b5017fcc..9dcaad5865 100644 --- a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js @@ -1 +1 @@ -!function(a){a.ui.WPLinkPreview=a.ui.Control.extend({url:"#",renderHtml:function(){return'"},setURL:function(b){var c,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),-1!==(c=b.indexOf("?"))&&(b=b.slice(0,c)),-1!==(c=b.indexOf("#"))&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),""===b&&(b=this.url),b.length>40&&-1!==(c=b.indexOf("/"))&&-1!==(d=b.lastIndexOf("/"))&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}}),a.ui.WPLinkInput=a.ui.Control.extend({renderHtml:function(){return''},setURL:function(a){this.getEl().firstChild.value=a},getURL:function(){return a.trim(this.getEl().firstChild.value)},getLinkText:function(){var b=this.getEl().firstChild.nextSibling.value;return a.trim(b)?b.replace(/[\r\n\t ]+/g," "):""},reset:function(){var a=this.getEl().firstChild;a.value="",a.nextSibling.value=""}}),a.PluginManager.add("wplink",function(b){function c(){var a,c,d=b.selection.getNode(),e=b.dom.getParent(d,"a[href]");return e||(c=b.selection.getContent({format:"raw"}),c&&-1!==c.indexOf("")&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',d)[0]),e&&b.selection.select(e))),e}function d(){b.$("a").each(function(a,c){var d=b.$(c);"_wp_link_placeholder"===d.attr("href")?b.dom.remove(c,!0):d.attr("data-wplink-edit")&&d.attr("data-wplink-edit",null)})}function e(a,b){return b&&(a=a.replace(/ data-wplink-edit="true"/g,"")),a.replace(/]*?href="_wp_link_placeholder"[^>]*>([\s\S]+)<\/a>/g,"$1")}var f,g,h,i,j,k,l,m=window.jQuery;return b.on("preinit",function(){if(b.wp&&b.wp._createToolbar){f=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0);var c=["wp_link_input","wp_link_apply"];"undefined"!=typeof window.wpLink&&c.push("wp_link_advanced"),g=b.wp._createToolbar(c,!0),g.on("show",function(){a.$(document.body).hasClass("modal-open")||window.setTimeout(function(){var a=g.$el.find("input.ui-autocomplete-input")[0],b=j&&(j.textContent||j.innerText);a&&(!a.value&&b&&"undefined"!=typeof window.wpLink&&(a.value=window.wpLink.getUrlFromSelection(b)),k||(a.focus(),a.select()))})}),g.on("hide",function(){g.scrolling||b.execCommand("wp_link_cancel")})}}),b.addCommand("WP_Link",function(){return a.Env.ie&&a.Env.ie<10&&"undefined"!=typeof window.wpLink?void window.wpLink.open(b.id):(j=c(),g.tempHide=!1,void(j?b.dom.setAttribs(j,{"data-wplink-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),j=b.$('a[href="_wp_link_placeholder"]')[0],b.nodeChanged())))}),b.addCommand("wp_link_apply",function(){if(!g.scrolling){var c,d;if(j){if(c=i.getURL(),d=i.getLinkText(),b.focus(),!c)return void b.dom.remove(j,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)||(c="http://"+c),b.dom.setAttribs(j,{href:c,"data-wplink-edit":null}),a.trim(j.innerHTML)||b.$(j).text(d||c)}i.reset(),b.nodeChanged()}}),b.addCommand("wp_link_cancel",function(){g.tempHide||(i.reset(),d(),b.focus(),g.tempHide=!1)}),b.addShortcut("access+a","","WP_Link"),b.addShortcut("meta+k","","WP_Link"),b.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),b.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),b.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),b.on("pastepreprocess",function(c){var d=c.content,e=/^(?:https?:)?\/\/\S+$/i;b.selection.isCollapsed()||e.test(b.selection.getContent())||(d=d.replace(/<[^>]+>/g,""),d=a.trim(d),e.test(d)&&(b.execCommand("mceInsertLink",!1,{href:b.dom.decode(d)}),c.preventDefault()))}),b.on("savecontent",function(a){a.content=e(a.content,!0)}),b.on("BeforeAddUndo",function(a){a.lastLevel&&a.lastLevel.content&&a.level.content&&a.lastLevel.content===e(a.level.content)&&a.preventDefault()}),b.on("keydown",function(b){b.altKey||a.Env.mac&&(!b.metaKey||b.ctrlKey)||!a.Env.mac&&!b.ctrlKey||(89===b.keyCode||90===b.keyCode)&&(k=!0,window.clearTimeout(l),l=window.setTimeout(function(){k=!1},500))}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){h=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e,f=this.getEl(),h=f.firstChild;i=this,m&&m.ui&&m.ui.autocomplete&&(c=m(h),c.on("keydown",function(){c.removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return e===a.term?void b(d):/^https?:/.test(a.term)||-1!==a.term.indexOf(".")?b():(m.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:a.term,_ajax_linking_nonce:m("#_ajax_linking_nonce").val()},function(a){d=a,b(a)},"json"),void(e=a.term))},focus:function(a,b){c.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID),a.preventDefault()},select:function(a,b){return c.val(b.item.permalink),m(f.firstChild.nextSibling).val(b.item.title),!1},open:function(){c.attr("aria-expanded","true"),g.blockHide=!0},close:function(){c.attr("aria-expanded","false"),g.blockHide=!1},minLength:2,position:{my:"left top+2"},messages:{noResults:"undefined"!=typeof window.uiAutocompleteL10n?window.uiAutocompleteL10n.noResults:"",results:function(a){return"undefined"!=typeof window.uiAutocompleteL10n?a>1?window.uiAutocompleteL10n.manyResults.replace("%d",a):window.uiAutocompleteL10n.oneResult:void 0}}}).autocomplete("instance")._renderItem=function(a,b){return m('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},c.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":c.autocomplete("widget").attr("id")}).on("focus",function(){c.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox")),a.$(h).on("keydown",function(a){13===a.keyCode&&(b.execCommand("wp_link_apply"),a.preventDefault())})}}),b.on("wptoolbar",function(c){var d,e,j,k=b.dom.getParent(c.element,"a");return a.$(document.body).hasClass("modal-open")?void(g.tempHide=!0):(g.tempHide=!1,void(k&&(d=b.$(k),e=d.attr("href"),j=d.attr("data-wplink-edit"),"_wp_link_placeholder"===e||j?(j&&!i.getURL()&&i.setURL(e),c.element=k,c.toolbar=g):e&&!d.find("img").length&&(h.setURL(e),c.element=k,c.toolbar=f))))}),b.addButton("wp_link_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),b.addButton("wp_link_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",cmd:"unlink"}),b.addButton("wp_link_advanced",{tooltip:"Advanced",icon:"dashicon dashicons-admin-generic",onclick:function(){if("undefined"!=typeof window.wpLink){var a=i.getURL()||null,c=i.getLinkText()||null;b.focus(),window.wpLink.open(b.id,a,c,j),g.tempHide=!0,i.reset()}}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"}),{close:function(){g.tempHide=!1,b.execCommand("wp_link_cancel")}}})}(window.tinymce); \ No newline at end of file +!function(a){a.ui.WPLinkPreview=a.ui.Control.extend({url:"#",renderHtml:function(){return'"},setURL:function(b){var c,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),-1!==(c=b.indexOf("?"))&&(b=b.slice(0,c)),-1!==(c=b.indexOf("#"))&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),""===b&&(b=this.url),b.length>40&&-1!==(c=b.indexOf("/"))&&-1!==(d=b.lastIndexOf("/"))&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}}),a.ui.WPLinkInput=a.ui.Control.extend({renderHtml:function(){return''},setURL:function(a){this.getEl().firstChild.value=a},getURL:function(){return a.trim(this.getEl().firstChild.value)},getLinkText:function(){var b=this.getEl().firstChild.nextSibling.value;return a.trim(b)?b.replace(/[\r\n\t ]+/g," "):""},reset:function(){var a=this.getEl().firstChild;a.value="",a.nextSibling.value=""}}),a.PluginManager.add("wplink",function(b){function c(){var a,c,d=b.selection.getNode(),e=b.dom.getParent(d,"a[href]");return e||(c=b.selection.getContent({format:"raw"}),c&&-1!==c.indexOf("")&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',d)[0]),e&&b.selection.select(e))),e}function d(){b.$("a").each(function(a,c){var d=b.$(c);"_wp_link_placeholder"===d.attr("href")?b.dom.remove(c,!0):d.attr("data-wplink-edit")&&d.attr("data-wplink-edit",null)})}function e(a,b){return b&&(a=a.replace(/ data-wplink-edit="true"/g,"")),a.replace(/]*?href="_wp_link_placeholder"[^>]*>([\s\S]+)<\/a>/g,"$1")}var f,g,h,i,j,k,l,m=window.jQuery;return b.on("preinit",function(){if(b.wp&&b.wp._createToolbar){f=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0);var c=["wp_link_input","wp_link_apply"];"undefined"!=typeof window.wpLink&&c.push("wp_link_advanced"),g=b.wp._createToolbar(c,!0),g.on("show",function(){a.$(document.body).hasClass("modal-open")||window.setTimeout(function(){var a=g.$el.find("input.ui-autocomplete-input")[0],b=j&&(j.textContent||j.innerText);a&&(!a.value&&b&&"undefined"!=typeof window.wpLink&&(a.value=window.wpLink.getUrlFromSelection(b)),k||(a.focus(),a.select()))})}),g.on("hide",function(){g.scrolling||b.execCommand("wp_link_cancel")})}}),b.addCommand("WP_Link",function(){return a.Env.ie&&a.Env.ie<10&&"undefined"!=typeof window.wpLink?void window.wpLink.open(b.id):(j=c(),g.tempHide=!1,void(j?b.dom.setAttribs(j,{"data-wplink-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),j=b.$('a[href="_wp_link_placeholder"]')[0],b.nodeChanged())))}),b.addCommand("wp_link_apply",function(){if(!g.scrolling){var c,d;if(j){if(c=i.getURL(),d=i.getLinkText(),b.focus(),!c)return void b.dom.remove(j,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)||(c="http://"+c),b.dom.setAttribs(j,{href:c,"data-wplink-edit":null}),a.trim(j.innerHTML)||b.$(j).text(d||c)}i.reset(),b.nodeChanged(),"undefined"!=typeof window.wp&&window.wp.a11y&&"undefined"!=typeof window.wpLinkL10n&&window.wp.a11y.speak(window.wpLinkL10n.linkInserted)}}),b.addCommand("wp_link_cancel",function(){g.tempHide||(i.reset(),d(),b.focus(),g.tempHide=!1)}),b.addShortcut("access+a","","WP_Link"),b.addShortcut("meta+k","","WP_Link"),b.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),b.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),b.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),b.on("pastepreprocess",function(c){var d=c.content,e=/^(?:https?:)?\/\/\S+$/i;b.selection.isCollapsed()||e.test(b.selection.getContent())||(d=d.replace(/<[^>]+>/g,""),d=a.trim(d),e.test(d)&&(b.execCommand("mceInsertLink",!1,{href:b.dom.decode(d)}),c.preventDefault()))}),b.on("savecontent",function(a){a.content=e(a.content,!0)}),b.on("BeforeAddUndo",function(a){a.lastLevel&&a.lastLevel.content&&a.level.content&&a.lastLevel.content===e(a.level.content)&&a.preventDefault()}),b.on("keydown",function(b){b.altKey||a.Env.mac&&(!b.metaKey||b.ctrlKey)||!a.Env.mac&&!b.ctrlKey||(89===b.keyCode||90===b.keyCode)&&(k=!0,window.clearTimeout(l),l=window.setTimeout(function(){k=!1},500))}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){h=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e,f=this.getEl(),h=f.firstChild;i=this,m&&m.ui&&m.ui.autocomplete&&(c=m(h),c.on("keydown",function(){c.removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return e===a.term?void b(d):/^https?:/.test(a.term)||-1!==a.term.indexOf(".")?b():(m.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:a.term,_ajax_linking_nonce:m("#_ajax_linking_nonce").val()},function(a){d=a,b(a)},"json"),void(e=a.term))},focus:function(a,b){c.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID),a.preventDefault()},select:function(a,b){return c.val(b.item.permalink),m(f.firstChild.nextSibling).val(b.item.title),9===a.keyCode&&"undefined"!=typeof window.wp&&window.wp.a11y&&"undefined"!=typeof window.wpLinkL10n&&window.wp.a11y.speak(window.wpLinkL10n.linkSelected),!1},open:function(){c.attr("aria-expanded","true"),g.blockHide=!0},close:function(){c.attr("aria-expanded","false"),g.blockHide=!1},minLength:2,position:{my:"left top+2"},messages:{noResults:"undefined"!=typeof window.uiAutocompleteL10n?window.uiAutocompleteL10n.noResults:"",results:function(a){return"undefined"!=typeof window.uiAutocompleteL10n?a>1?window.uiAutocompleteL10n.manyResults.replace("%d",a):window.uiAutocompleteL10n.oneResult:void 0}}}).autocomplete("instance")._renderItem=function(a,b){return m('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},c.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":c.autocomplete("widget").attr("id")}).on("focus",function(){var a=c.val();a&&!/^https?:/.test(a)&&c.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox").removeAttr("tabindex")),a.$(h).on("keydown",function(a){13===a.keyCode&&(b.execCommand("wp_link_apply"),a.preventDefault())})}}),b.on("wptoolbar",function(c){var d,e,j,k=b.dom.getParent(c.element,"a");return a.$(document.body).hasClass("modal-open")?void(g.tempHide=!0):(g.tempHide=!1,void(k&&(d=b.$(k),e=d.attr("href"),j=d.attr("data-wplink-edit"),"_wp_link_placeholder"===e||j?(j&&!i.getURL()&&i.setURL(e),c.element=k,c.toolbar=g):e&&!d.find("img").length&&(h.setURL(e),c.element=k,c.toolbar=f))))}),b.addButton("wp_link_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),b.addButton("wp_link_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",cmd:"unlink"}),b.addButton("wp_link_advanced",{tooltip:"Advanced",icon:"dashicon dashicons-admin-generic",onclick:function(){if("undefined"!=typeof window.wpLink){var c=i.getURL()||null,d=i.getLinkText()||null;a.Env.ie&&b.focus(),window.wpLink.open(b.id,c,d,j),g.tempHide=!0,i.reset()}}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"}),{close:function(){g.tempHide=!1,b.execCommand("wp_link_cancel")}}})}(window.tinymce); \ No newline at end of file diff --git a/wp-includes/js/tinymce/wp-tinymce.js.gz b/wp-includes/js/tinymce/wp-tinymce.js.gz index b2492522a5..191391008b 100644 Binary files a/wp-includes/js/tinymce/wp-tinymce.js.gz and b/wp-includes/js/tinymce/wp-tinymce.js.gz differ diff --git a/wp-includes/js/wplink.js b/wp-includes/js/wplink.js index c32a998449..3851c2fd59 100644 --- a/wp-includes/js/wplink.js +++ b/wp-includes/js/wplink.js @@ -1,7 +1,7 @@ var wpLink; -( function( $, wpLinkL10n ) { +( function( $, wpLinkL10n, wp ) { var editor, correctedURL, linkNode, inputs = {}, isTouch = ( 'ontouchend' in document ); @@ -76,6 +76,10 @@ var wpLink; }, focus: function( event, ui ) { $input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID ); + /* + * Don't empty the URL input field, when using the arrow keys to + * highlight items. See api.jqueryui.com/autocomplete/#event-focus + */ event.preventDefault(); }, select: function( event, ui ) { @@ -85,6 +89,9 @@ var wpLink; inputs.text.val( ui.item.title ); } + // Audible confirmation message when a link has been selected. + wp.a11y.speak( wpLinkL10n.linkSelected ); + return false; }, open: function() { @@ -117,15 +124,21 @@ var wpLink; $input.attr( { 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' ) - } ) + } ) .on( 'focus', function() { - $input.autocomplete( 'search' ); + var inputValue = $input.val(); + /* + * Don't trigger a search if the URL field already has a link or is empty. + * Also, avoids screen readers announce `No search results`. + */ + if ( inputValue && ! /^https?:/.test( inputValue ) ) { + $input.autocomplete( 'search' ); + } } ) .autocomplete( 'widget' ) .addClass( 'wplink-autocomplete' ) - .attr( 'role', 'listbox' ); - - + .attr( 'role', 'listbox' ) + .removeAttr( 'tabindex' ); // Remove the `tabindex=0` attribute added by jQuery UI. }, // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http:// @@ -170,7 +183,7 @@ var wpLink; editor = null; } - if ( editor && window.tinymce.isIE && ! editor.windowManager.wplinkBookmark ) { + if ( editor && window.tinymce.isIE ) { editor.windowManager.wplinkBookmark = editor.selection.getBookmark(); } } @@ -402,6 +415,9 @@ var wpLink; wpLink.close(); textarea.focus(); + + // Audible confirmation message when a link has been inserted in the Editor. + wp.a11y.speak( wpLinkL10n.linkInserted ); }, mceUpdate: function() { @@ -450,6 +466,9 @@ var wpLink; wpLink.close( 'noReset' ); editor.focus(); editor.nodeChanged(); + + // Audible confirmation message when a link has been inserted in the Editor. + wp.a11y.speak( wpLinkL10n.linkInserted ); }, keydown: function( event ) { @@ -511,4 +530,4 @@ var wpLink; }; $( document ).ready( wpLink.init ); -})( jQuery, window.wpLinkL10n ); +})( jQuery, window.wpLinkL10n, window.wp ); diff --git a/wp-includes/js/wplink.min.js b/wp-includes/js/wplink.min.js index 109a7fd216..a881b0ddea 100644 --- a/wp-includes/js/wplink.min.js +++ b/wp-includes/js/wplink.min.js @@ -1 +1 @@ -var wpLink;!function(a,b){function c(){return f||d.dom.getParent(d.selection.getNode(),"a[href]")}var d,e,f,g={},h="ontouchend"in document;wpLink={textarea:"",init:function(){g.wrap=a("#wp-link-wrap"),g.dialog=a("#wp-link"),g.backdrop=a("#wp-link-backdrop"),g.submit=a("#wp-link-submit"),g.close=a("#wp-link-close"),g.text=a("#wp-link-text"),g.url=a("#wp-link-url"),g.openInNewTab=a("#wp-link-target"),a.ui&&a.ui.autocomplete&&wpLink.setAutocomplete(),g.dialog.on("keydown",wpLink.keydown),g.submit.on("click",function(a){a.preventDefault(),wpLink.update()}),g.close.add(g.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),g.url.on("paste",function(){setTimeout(wpLink.correctURL,0)})},setAutocomplete:function(){var b,c,d=g.url;d.on("keydown",function(){d.removeAttr("aria-activedescendant")}).autocomplete({source:function(d,e){return c===d.term?void e(b):/^https?:/.test(d.term)||-1!==d.term.indexOf(".")?e():(a.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:d.term,_ajax_linking_nonce:a("#_ajax_linking_nonce").val()},function(a){b=a,e(a)},"json"),void(c=d.term))},focus:function(a,b){d.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID),a.preventDefault()},select:function(b,c){return d.val(c.item.permalink),g.wrap.hasClass("has-text-field")&&""===a.trim(g.text.val())&&g.text.val(c.item.title),!1},open:function(){d.attr("aria-expanded","true")},close:function(){d.attr("aria-expanded","false")},minLength:2,position:{my:"left top+2"},messages:{noResults:"undefined"!=typeof window.uiAutocompleteL10n?window.uiAutocompleteL10n.noResults:"",results:function(a){return"undefined"!=typeof window.uiAutocompleteL10n?a>1?window.uiAutocompleteL10n.manyResults.replace("%d",a):window.uiAutocompleteL10n.oneResult:void 0}}}).autocomplete("instance")._renderItem=function(b,c){return a('
  • ').append(''+c.title+' '+c.info+"").appendTo(b)},d.attr({"aria-owns":d.autocomplete("widget").attr("id")}).on("focus",function(){d.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox")},correctURL:function(){var b=a.trim(g.url.val());b&&e!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(g.url.val("http://"+b),e=b)},open:function(b,c,e,h){var i,j=a(document.body);j.addClass("modal-open"),f=h,wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof window.tinymce&&(j.append(g.backdrop,g.wrap),i=window.tinymce.get(window.wpActiveEditor),d=i&&!i.isHidden()?i:null,d&&window.tinymce.isIE&&!d.windowManager.wplinkBookmark&&(d.windowManager.wplinkBookmark=d.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),g.wrap.show(),g.backdrop.show(),wpLink.refresh(c,e),a(document).trigger("wplink-open",g.wrap))},isMCE:function(){return d&&!d.isHidden()},refresh:function(a,b){var c="";wpLink.isMCE()?wpLink.mceRefresh(a,b):(g.wrap.hasClass("has-text-field")||g.wrap.addClass("has-text-field"),document.selection?c=document.selection.createRange().text||b||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||b||""),g.text.val(b),wpLink.setDefaultValues()),h?g.url.focus().blur():window.setTimeout(function(){g.url.focus()[0].select()}),e=g.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b,c,e,f=d.selection.getContent();if(/]+>[^<]+<\/a>$/.test(f)||-1===f.indexOf("href=")))return!1;if(a){if(c=a.childNodes,0===c.length)return!1;for(e=c.length-1;e>=0;e--)if(b=c[e],3!=b.nodeType&&!window.tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(e,f){var h,i=c(),j=this.hasSelectedText(i);i?(h=i.innerText||i.textContent,a.trim(h)||(h=f||""),e=e||d.dom.getAttrib(i,"href"),"_wp_link_placeholder"!==e?(g.url.val(e),g.openInNewTab.prop("checked","_blank"===d.dom.getAttrib(i,"target")),g.submit.val(b.update)):this.setDefaultValues(h)):(h=d.selection.getContent({format:"text"})||f||"",this.setDefaultValues(h)),j?(g.text.val(h),g.wrap.addClass("has-text-field")):(g.text.val(""),g.wrap.removeClass("has-text-field"))},close:function(b){a(document.body).removeClass("modal-open"),"noReset"!==b&&(wpLink.isMCE()?(d.plugins.wplink&&d.plugins.wplink.close(),d.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),g.backdrop.hide(),g.wrap.hide(),e=!1,a(document).trigger("wplink-close",g.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(g.url.val()),target:g.openInNewTab.prop("checked")?"_blank":""}},buildHtml:function(a){var b='"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,h,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=g.text.val(),a.href&&(c=wpLink.buildHtml(a),document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,e=i.selectionEnd,h=b||i.value.substring(d,e),c=c+h+"",f=d+c.length,d!==e||h||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,b,e=wpLink.getAttrs();return d.focus(),window.tinymce.isIE&&d.windowManager.wplinkBookmark&&(d.selection.moveToBookmark(d.windowManager.wplinkBookmark),d.windowManager.wplinkBookmark=null),e.href?(a=c(),g.wrap.hasClass("has-text-field")&&(b=g.text.val()||e.href),a?(b&&("innerText"in a?a.innerText=b:a.textContent=b),e["data-wplink-edit"]=null,d.dom.setAttribs(a,e)):b?d.selection.setNode(d.dom.create("a",e,d.dom.encode(b))):d.execCommand("mceInsertLink",!1,e),wpLink.close("noReset"),d.focus(),void d.nodeChanged()):(d.execCommand("unlink"),void wpLink.close())},keydown:function(a){var b;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(b=a.target.id,"wp-link-submit"!==b||a.shiftKey?"wp-link-close"===b&&a.shiftKey&&(g.submit.focus(),a.preventDefault()):(g.close.focus(),a.preventDefault()))},getUrlFromSelection:function(b){var c=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,e=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;return b||(this.isMCE()?b=d.selection.getContent({format:"text"}):document.selection&&wpLink.range?b=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd))),b=a.trim(b),b&&c.test(b)?"mailto:"+b:b&&e.test(b)?b.replace(/&|�?38;/gi,"&"):""},setDefaultValues:function(a){g.url.val(this.getUrlFromSelection(a)),g.submit.val(b.save)}},a(document).ready(wpLink.init)}(jQuery,window.wpLinkL10n); \ No newline at end of file +var wpLink;!function(a,b,c){function d(){return g||e.dom.getParent(e.selection.getNode(),"a[href]")}var e,f,g,h={},i="ontouchend"in document;wpLink={textarea:"",init:function(){h.wrap=a("#wp-link-wrap"),h.dialog=a("#wp-link"),h.backdrop=a("#wp-link-backdrop"),h.submit=a("#wp-link-submit"),h.close=a("#wp-link-close"),h.text=a("#wp-link-text"),h.url=a("#wp-link-url"),h.openInNewTab=a("#wp-link-target"),a.ui&&a.ui.autocomplete&&wpLink.setAutocomplete(),h.dialog.on("keydown",wpLink.keydown),h.submit.on("click",function(a){a.preventDefault(),wpLink.update()}),h.close.add(h.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),h.url.on("paste",function(){setTimeout(wpLink.correctURL,0)})},setAutocomplete:function(){var d,e,f=h.url;f.on("keydown",function(){f.removeAttr("aria-activedescendant")}).autocomplete({source:function(b,c){return e===b.term?void c(d):/^https?:/.test(b.term)||-1!==b.term.indexOf(".")?c():(a.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:b.term,_ajax_linking_nonce:a("#_ajax_linking_nonce").val()},function(a){d=a,c(a)},"json"),void(e=b.term))},focus:function(a,b){f.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID),a.preventDefault()},select:function(d,e){return f.val(e.item.permalink),h.wrap.hasClass("has-text-field")&&""===a.trim(h.text.val())&&h.text.val(e.item.title),c.a11y.speak(b.linkSelected),!1},open:function(){f.attr("aria-expanded","true")},close:function(){f.attr("aria-expanded","false")},minLength:2,position:{my:"left top+2"},messages:{noResults:"undefined"!=typeof window.uiAutocompleteL10n?window.uiAutocompleteL10n.noResults:"",results:function(a){return"undefined"!=typeof window.uiAutocompleteL10n?a>1?window.uiAutocompleteL10n.manyResults.replace("%d",a):window.uiAutocompleteL10n.oneResult:void 0}}}).autocomplete("instance")._renderItem=function(b,c){return a('
  • ').append(''+c.title+' '+c.info+"").appendTo(b)},f.attr({"aria-owns":f.autocomplete("widget").attr("id")}).on("focus",function(){var a=f.val();a&&!/^https?:/.test(a)&&f.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox").removeAttr("tabindex")},correctURL:function(){var b=a.trim(h.url.val());b&&f!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(h.url.val("http://"+b),f=b)},open:function(b,c,d,f){var i,j=a(document.body);j.addClass("modal-open"),g=f,wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof window.tinymce&&(j.append(h.backdrop,h.wrap),i=window.tinymce.get(window.wpActiveEditor),e=i&&!i.isHidden()?i:null,e&&window.tinymce.isIE&&(e.windowManager.wplinkBookmark=e.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),h.wrap.show(),h.backdrop.show(),wpLink.refresh(c,d),a(document).trigger("wplink-open",h.wrap))},isMCE:function(){return e&&!e.isHidden()},refresh:function(a,b){var c="";wpLink.isMCE()?wpLink.mceRefresh(a,b):(h.wrap.hasClass("has-text-field")||h.wrap.addClass("has-text-field"),document.selection?c=document.selection.createRange().text||b||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||b||""),h.text.val(b),wpLink.setDefaultValues()),i?h.url.focus().blur():window.setTimeout(function(){h.url.focus()[0].select()}),f=h.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b,c,d,f=e.selection.getContent();if(/]+>[^<]+<\/a>$/.test(f)||-1===f.indexOf("href=")))return!1;if(a){if(c=a.childNodes,0===c.length)return!1;for(d=c.length-1;d>=0;d--)if(b=c[d],3!=b.nodeType&&!window.tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(c,f){var g,i=d(),j=this.hasSelectedText(i);i?(g=i.innerText||i.textContent,a.trim(g)||(g=f||""),c=c||e.dom.getAttrib(i,"href"),"_wp_link_placeholder"!==c?(h.url.val(c),h.openInNewTab.prop("checked","_blank"===e.dom.getAttrib(i,"target")),h.submit.val(b.update)):this.setDefaultValues(g)):(g=e.selection.getContent({format:"text"})||f||"",this.setDefaultValues(g)),j?(h.text.val(g),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(b){a(document.body).removeClass("modal-open"),"noReset"!==b&&(wpLink.isMCE()?(e.plugins.wplink&&e.plugins.wplink.close(),e.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),h.backdrop.hide(),h.wrap.hide(),f=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(h.url.val()),target:h.openInNewTab.prop("checked")?"_blank":""}},buildHtml:function(a){var b='"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,d,e,f,g,i,j,k=wpLink.textarea;k&&(a=wpLink.getAttrs(),d=h.text.val(),a.href&&(e=wpLink.buildHtml(a),document.selection&&wpLink.range?(k.focus(),wpLink.range.text=e+(d||wpLink.range.text)+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof k.selectionStart&&(f=k.selectionStart,g=k.selectionEnd,j=d||k.value.substring(f,g),e=e+j+"",i=f+e.length,f!==g||j||(i-=4),k.value=k.value.substring(0,f)+e+k.value.substring(g,k.value.length),k.selectionStart=k.selectionEnd=i),wpLink.close(),k.focus(),c.a11y.speak(b.linkInserted)))},mceUpdate:function(){var a,f,g=wpLink.getAttrs();return e.focus(),window.tinymce.isIE&&e.windowManager.wplinkBookmark&&(e.selection.moveToBookmark(e.windowManager.wplinkBookmark),e.windowManager.wplinkBookmark=null),g.href?(a=d(),h.wrap.hasClass("has-text-field")&&(f=h.text.val()||g.href),a?(f&&("innerText"in a?a.innerText=f:a.textContent=f),g["data-wplink-edit"]=null,e.dom.setAttribs(a,g)):f?e.selection.setNode(e.dom.create("a",g,e.dom.encode(f))):e.execCommand("mceInsertLink",!1,g),wpLink.close("noReset"),e.focus(),e.nodeChanged(),void c.a11y.speak(b.linkInserted)):(e.execCommand("unlink"),void wpLink.close())},keydown:function(a){var b;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(b=a.target.id,"wp-link-submit"!==b||a.shiftKey?"wp-link-close"===b&&a.shiftKey&&(h.submit.focus(),a.preventDefault()):(h.close.focus(),a.preventDefault()))},getUrlFromSelection:function(b){var c=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;return b||(this.isMCE()?b=e.selection.getContent({format:"text"}):document.selection&&wpLink.range?b=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd))),b=a.trim(b),b&&c.test(b)?"mailto:"+b:b&&d.test(b)?b.replace(/&|�?38;/gi,"&"):""},setDefaultValues:function(a){h.url.val(this.getUrlFromSelection(a)),h.submit.val(b.save)}},a(document).ready(wpLink.init)}(jQuery,window.wpLinkL10n,window.wp); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index b40bab76a5..9b4643fc2d 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -204,7 +204,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); - $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array('jquery-ui-menu'), '1.11.4', 1 ); + $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 ); $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array('jquery-ui-core'), '1.11.4', 1 ); $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.11.4', 1 ); @@ -226,10 +226,10 @@ function wp_default_scripts( &$scripts ) { // Strings for 'jquery-ui-autocomplete' live region messages did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', array( - 'noResults' => __( 'No search results.' ), - /* translators: Number of results found when using jQuery UI Autocomplete */ - 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), - 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), + 'noResults' => __( 'No search results.' ), + /* translators: Number of results found when using jQuery UI Autocomplete */ + 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), + 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), ) ); // deprecated, not used in core, most functionality is included in jQuery 1.3 @@ -252,13 +252,13 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 ); did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array( - 'next' => __('Next >'), - 'prev' => __('< Prev'), - 'image' => __('Image'), - 'of' => __('of'), - 'close' => __('Close'), - 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), - 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), + 'next' => __('Next >'), + 'prev' => __('< Prev'), + 'image' => __('Image'), + 'of' => __('of'), + 'close' => __('Close'), + 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), + 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), ) ); $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.js", array('jquery'), '0.9.12'); @@ -401,13 +401,15 @@ 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' ), false, 1 ); + $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( 'title' => __('Insert/edit link'), 'update' => __('Update'), 'save' => __('Add Link'), 'noTitle' => __('(no title)'), - 'noMatchesFound' => __('No results found.') + 'noMatchesFound' => __('No results found.'), + 'linkSelected' => __( 'Link selected.' ), + 'linkInserted' => __( 'Link inserted.' ), ) ); $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 2e6dd7823b..bdd8ba63f5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-beta3-36983'; +$wp_version = '4.5-beta3-36984'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.