TinyMCE: fix tabbig in and out of the editor, fixes #20834

git-svn-id: http://core.svn.wordpress.org/trunk@21300 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2012-07-22 02:33:53 +00:00
parent a530304b68
commit 2309fcb9d7
6 changed files with 25 additions and 30 deletions

View File

@ -312,7 +312,7 @@ wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
<?php if ( post_type_supports($post_type, 'editor') ) { ?>
<div id="postdivrich" class="postarea">
<?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabindex' => 1) ); ?>
<?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabindex' => 1, 'tabfocus_elements' => 'sample-permalink,post-preview') ); ?>
<table id="post-status-info" cellspacing="0"><tbody><tr>
<td id="wp-word-count"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>

View File

@ -1091,7 +1091,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
}
if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n";
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) )
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
if ( isset($view_post) )
@ -1120,7 +1120,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
$display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
$view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
$return = '<strong>' . __('Permalink:') . "</strong>\n";
$return .= '<span id="sample-permalink">' . $display_link . "</span>\n";
$return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
$return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";

View File

@ -34,6 +34,7 @@ final class _WP_Editors {
'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
'tabindex' => '',
'tabfocus_elements' => ':prev,:next', // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE
'editor_css' => '', // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped".
'editor_class' => '', // add extra class(es) to the editor textarea
'teeny' => false, // output the minimal editor config used in Press This
@ -311,7 +312,6 @@ final class _WP_Editors {
'keep_styles' => false,
'entities' => '38,amp,60,lt,62,gt',
'accessibility_focus' => true,
'tabfocus_elements' => 'title,publish',
'media_strict' => false,
'paste_remove_styles' => true,
'paste_remove_spans' => true,
@ -398,6 +398,7 @@ final class _WP_Editors {
'theme_advanced_buttons2' => implode($mce_buttons_2, ','),
'theme_advanced_buttons3' => implode($mce_buttons_3, ','),
'theme_advanced_buttons4' => implode($mce_buttons_4, ','),
'tabfocus_elements' => $set['tabfocus_elements'],
'body_class' => $body_class
);

View File

@ -1,7 +1,6 @@
var autosave, autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, notSaved = true, blockSave = false, fullscreen, autosaveLockRelease = true;
jQuery(document).ready( function($) {
var dotabkey = true;
autosaveLast = $('#post #title').val() + $('#post #content').val();
autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true});
@ -29,7 +28,7 @@ jQuery(document).ready( function($) {
});
window.onbeforeunload = function(){
var mce = typeof(tinyMCE) != 'undefined' ? tinyMCE.activeEditor : false, title, content;
var mce = typeof(tinymce) != 'undefined' ? tinymce.activeEditor : false, title, content;
if ( mce && !mce.isHidden() ) {
if ( mce.isDirty() )
@ -97,17 +96,15 @@ jQuery(document).ready( function($) {
$('input#wp-preview').val('');
}
// This code is meant to allow tabbing from Title to Post if tinyMCE is defined.
if ( typeof tinyMCE != 'undefined' ) {
$('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) {
if ( e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey ) {
if ( ($('#auto_draft').val() == '1') && ($("#title").val().length > 0) ) { autosave(); }
if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
e.preventDefault();
dotabkey = false;
tinyMCE.activeEditor.focus();
return false;
}
// This code is meant to allow tabbing from Title to Post if tinymce is defined.
if ( typeof tinymce != 'undefined' ) {
$('#title').bind('keydown.focus-tinymce', function(e) {
if ( e.which != 9 )
return;
if ( !e.ctrlKey && !e.altKey && !e.shiftKey && tinymce.activeEditor && !tinymce.activeEditor.isHidden() ) {
$('td.mceToolbar > a').focus();
e.preventDefault();
}
});
}
@ -244,7 +241,7 @@ function delayed_autosave() {
autosave = function() {
// (bool) is rich editor enabled and active
blockSave = true;
var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(),
var rich = (typeof tinymce != "undefined") && tinymce.activeEditor && !tinymce.activeEditor.isHidden(),
post_data, doAutoSave, ed, origStatus, successCallback;
autosave_disable_buttons();
@ -269,16 +266,16 @@ autosave = function() {
if ( jQuery("#TB_window").css('display') == 'block' )
doAutoSave = false;
/* Gotta do this up here so we can check the length when tinyMCE is in use */
/* Gotta do this up here so we can check the length when tinymce is in use */
if ( rich && doAutoSave ) {
ed = tinyMCE.activeEditor;
// Don't run while the TinyMCE spellcheck is on. It resets all found words.
ed = tinymce.activeEditor;
// Don't run while the tinymce spellcheck is on. It resets all found words.
if ( ed.plugins.spellchecker && ed.plugins.spellchecker.active ) {
doAutoSave = false;
} else {
if ( 'mce_fullscreen' == ed.id || 'wp_mce_fullscreen' == ed.id )
tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
tinyMCE.triggerSave();
tinymce.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
tinymce.triggerSave();
}
}

View File

@ -1 +1 @@
(function(){var c=tinymce.DOM,a=tinymce.dom.Event,d=tinymce.each,b=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(f,g){function e(i,j){if(j.keyCode===9){return a.cancel(j)}}function h(l,p){var j,m,o,n,k;function q(t){n=c.select(":input:enabled,*[tabindex]:not(iframe)");function s(v){return v.nodeName==="BODY"||(v.type!="hidden"&&!(v.style.display=="none")&&!(v.style.visibility=="hidden")&&s(v.parentNode))}function i(v){return v.attributes.tabIndex.specified||v.nodeName=="INPUT"||v.nodeName=="TEXTAREA"}function u(){return tinymce.isIE6||tinymce.isIE7}function r(v){return((!u()||i(v)))&&v.getAttribute("tabindex")!="-1"&&s(v)}d(n,function(w,v){if(w.id==l.id){j=v;return false}});if(t>0){for(m=j+1;m<n.length;m++){if(r(n[m])){return n[m]}}}else{for(m=j-1;m>=0;m--){if(r(n[m])){return n[m]}}}return null}if(p.keyCode===9){k=b(l.getParam("tab_focus",l.getParam("tabfocus_elements",":prev,:next")));if(k.length==1){k[1]=k[0];k[0]=":prev"}if(p.shiftKey){if(k[0]==":prev"){n=q(-1)}else{n=c.get(k[0])}}else{if(k[1]==":next"){n=q(1)}else{n=c.get(k[1])}}if(n){if(n.id&&(l=tinymce.get(n.id||n.name))){l.focus()}else{window.setTimeout(function(){if(!tinymce.isWebKit){window.focus()}n.focus()},10)}return a.cancel(p)}}}f.onKeyUp.add(e);if(tinymce.isGecko){f.onKeyPress.add(h);f.onKeyDown.add(e)}else{f.onKeyDown.add(h)}},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})();
(function(){var c=tinymce.DOM,a=tinymce.dom.Event,d=tinymce.each,b=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(f,g){function e(i,j){if(j.keyCode===9){return a.cancel(j)}}function h(l,p){var j,m,o,n,k;function q(t){n=c.select(":input:enabled,*[tabindex]:not(iframe)");function s(v){return v.nodeName==="BODY"||(v.type!="hidden"&&!(v.style.display=="none")&&!(v.style.visibility=="hidden")&&s(v.parentNode))}function i(v){return v.attributes.tabIndex.specified||v.nodeName=="INPUT"||v.nodeName=="TEXTAREA"}function u(){return tinymce.isIE6||tinymce.isIE7}function r(v){return((!u()||i(v)))&&v.getAttribute("tabindex")!="-1"&&s(v)}d(n,function(w,v){if(w.id==l.id){j=v;return false}});if(t>0){for(m=j+1;m<n.length;m++){if(r(n[m])){return n[m]}}}else{for(m=j-1;m>=0;m--){if(r(n[m])){return n[m]}}}return null}if(p.keyCode===9){k=b(l.getParam("tab_focus",l.getParam("tabfocus_elements",":prev,:next")));if(k.length==1){k[1]=k[0];k[0]=":prev"}if(p.shiftKey){if(k[0]==":prev"){n=q(-1)}else{n=c.get(k[0])}}else{if(k[1]==":next"){n=q(1)}else{n=c.get(k[1])}}if(n){if(n.id&&(l=tinymce.get(n.id||n.name))){l.focus()}else{window.setTimeout(function(){if(!tinymce.isWebKit){window.focus()}n.focus()},10)}return a.cancel(p)}}}f.onKeyUp.add(e);f.onKeyDown.add(h);if(tinymce.isGecko){f.onKeyPress.add(e)}},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})();

View File

@ -97,13 +97,10 @@
}
ed.onKeyUp.add(tabCancel);
ed.onKeyDown.add(tabHandler);
if (tinymce.isGecko) {
ed.onKeyPress.add(tabHandler);
ed.onKeyDown.add(tabCancel);
} else
ed.onKeyDown.add(tabHandler);
if (tinymce.isGecko)
ed.onKeyPress.add(tabCancel);
},
getInfo : function() {