Make WordPress Core

Changeset 21300


Ignore:
Timestamp:
07/22/2012 02:33:53 AM (12 years ago)
Author:
azaozz
Message:

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

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r21212 r21300  
    313313<div id="postdivrich" class="postarea">
    314314
    315 <?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabindex' => 1) ); ?>
     315<?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabindex' => 1, 'tabfocus_elements' => 'sample-permalink,post-preview') ); ?>
    316316
    317317<table id="post-status-info" cellspacing="0"><tbody><tr>
  • trunk/wp-admin/includes/post.php

    r21189 r21300  
    10921092
    10931093    if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
    1094         $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n";
     1094        $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
    10951095        if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) )
    10961096            $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
     
    11211121    $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
    11221122    $return =  '<strong>' . __('Permalink:') . "</strong>\n";
    1123     $return .= '<span id="sample-permalink">' . $display_link . "</span>\n";
     1123    $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
    11241124    $return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
    11251125    $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";
  • trunk/wp-includes/class-wp-editor.php

    r21218 r21300  
    3535            'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
    3636            'tabindex' => '',
     37            'tabfocus_elements' => ':prev,:next', // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE
    3738            'editor_css' => '', // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped".
    3839            'editor_class' => '', // add extra class(es) to the editor textarea
     
    312313                    'entities' => '38,amp,60,lt,62,gt',
    313314                    'accessibility_focus' => true,
    314                     'tabfocus_elements' => 'title,publish',
    315315                    'media_strict' => false,
    316316                    'paste_remove_styles' => true,
     
    399399                'theme_advanced_buttons3' => implode($mce_buttons_3, ','),
    400400                'theme_advanced_buttons4' => implode($mce_buttons_4, ','),
     401                'tabfocus_elements' => $set['tabfocus_elements'],
    401402                'body_class' => $body_class
    402403            );
  • trunk/wp-includes/js/autosave.dev.js

    r19593 r21300  
    22
    33jQuery(document).ready( function($) {
    4     var dotabkey = true;
    54
    65    autosaveLast = $('#post #title').val() + $('#post #content').val();
     
    3029
    3130    window.onbeforeunload = function(){
    32         var mce = typeof(tinyMCE) != 'undefined' ? tinyMCE.activeEditor : false, title, content;
     31        var mce = typeof(tinymce) != 'undefined' ? tinymce.activeEditor : false, title, content;
    3332
    3433        if ( mce && !mce.isHidden() ) {
     
    9897    }
    9998
    100     //  This code is meant to allow tabbing from Title to Post if tinyMCE is defined.
    101     if ( typeof tinyMCE != 'undefined' ) {
    102         $('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) {
    103             if ( e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey ) {
    104                 if ( ($('#auto_draft').val() == '1') && ($("#title").val().length > 0) ) { autosave(); }
    105                 if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
    106                     e.preventDefault();
    107                     dotabkey = false;
    108                     tinyMCE.activeEditor.focus();
    109                     return false;
    110                 }
     99    //  This code is meant to allow tabbing from Title to Post if tinymce is defined.
     100    if ( typeof tinymce != 'undefined' ) {
     101        $('#title').bind('keydown.focus-tinymce', function(e) {
     102            if ( e.which != 9 )
     103                return;
     104
     105            if ( !e.ctrlKey && !e.altKey && !e.shiftKey && tinymce.activeEditor && !tinymce.activeEditor.isHidden() ) {
     106                $('td.mceToolbar > a').focus();
     107                e.preventDefault();
    111108            }
    112109        });
     
    245242    // (bool) is rich editor enabled and active
    246243    blockSave = true;
    247     var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(),
     244    var rich = (typeof tinymce != "undefined") && tinymce.activeEditor && !tinymce.activeEditor.isHidden(),
    248245        post_data, doAutoSave, ed, origStatus, successCallback;
    249246
     
    270267        doAutoSave = false;
    271268
    272     /* Gotta do this up here so we can check the length when tinyMCE is in use */
     269    /* Gotta do this up here so we can check the length when tinymce is in use */
    273270    if ( rich && doAutoSave ) {
    274         ed = tinyMCE.activeEditor;
    275         // Don't run while the TinyMCE spellcheck is on. It resets all found words.
     271        ed = tinymce.activeEditor;
     272        // Don't run while the tinymce spellcheck is on. It resets all found words.
    276273        if ( ed.plugins.spellchecker && ed.plugins.spellchecker.active ) {
    277274            doAutoSave = false;
    278275        } else {
    279276            if ( 'mce_fullscreen' == ed.id || 'wp_mce_fullscreen' == ed.id )
    280                 tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
    281             tinyMCE.triggerSave();
     277                tinymce.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
     278            tinymce.triggerSave();
    282279        }
    283280    }
  • trunk/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js

    r21228 r21300  
    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)})();
     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);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)})();
  • trunk/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin_src.js

    r21228 r21300  
    9898
    9999            ed.onKeyUp.add(tabCancel);
     100            ed.onKeyDown.add(tabHandler);
    100101
    101             if (tinymce.isGecko) {
    102                 ed.onKeyPress.add(tabHandler);
    103                 ed.onKeyDown.add(tabCancel);
    104             } else
    105                 ed.onKeyDown.add(tabHandler);
    106 
     102            if (tinymce.isGecko)
     103                ed.onKeyPress.add(tabCancel);
    107104        },
    108105
Note: See TracChangeset for help on using the changeset viewer.