Make WordPress Core

Changeset 27034


Ignore:
Timestamp:
01/26/2014 12:28:49 AM (13 years ago)
Author:
azaozz
Message:

TinyMCE: do not run preventDefault() on the tab key when Ctrl, Alt or Command key is also pressed. Ctrl + Tab is used to switch between browser tabs. See #24067, fixes #17261.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.js

    r26876 r27034  
    1515
    1616        function tabCancel(e) {
    17                 if (e.keyCode === 9) {
     17                if (e.keyCode === 9 && !e.ctrlKey && !e.altKey && !e.metaKey) {
    1818                        e.preventDefault();
    1919                }
     
    2222        function tabHandler(e) {
    2323                var x, el, v, i;
     24
     25                if (e.keyCode !== 9 || e.ctrlKey || e.altKey || e.metaKey) {
     26                        return;
     27                }
    2428
    2529                function find(direction) {
     
    6367                }
    6468
    65                 if (e.keyCode === 9) {
    66                         v = explode(editor.getParam('tab_focus', editor.getParam('tabfocus_elements', ':prev,:next')));
     69                v = explode(editor.getParam('tab_focus', editor.getParam('tabfocus_elements', ':prev,:next')));
    6770
    68                         if (v.length == 1) {
    69                                 v[1] = v[0];
    70                                 v[0] = ':prev';
     71                if (v.length == 1) {
     72                        v[1] = v[0];
     73                        v[0] = ':prev';
     74                }
     75
     76                // Find element to focus
     77                if (e.shiftKey) {
     78                        if (v[0] == ':prev') {
     79                                el = find(-1);
     80                        } else {
     81                                el = DOM.get(v[0]);
     82                        }
     83                } else {
     84                        if (v[1] == ':next') {
     85                                el = find(1);
     86                        } else {
     87                                el = DOM.get(v[1]);
     88                        }
     89                }
     90
     91                if (el) {
     92                        var focusEditor = tinymce.get(el.id || el.name);
     93
     94                        if (el.id && focusEditor) {
     95                                focusEditor.focus();
     96                        } else {
     97                                window.setTimeout(function() {
     98                                        if (!tinymce.Env.webkit) {
     99                                                window.focus();
     100                                        }
     101
     102                                        el.focus();
     103                                }, 10);
    71104                        }
    72105
    73                         // Find element to focus
    74                         if (e.shiftKey) {
    75                                 if (v[0] == ':prev') {
    76                                         el = find(-1);
    77                                 } else {
    78                                         el = DOM.get(v[0]);
    79                                 }
    80                         } else {
    81                                 if (v[1] == ':next') {
    82                                         el = find(1);
    83                                 } else {
    84                                         el = DOM.get(v[1]);
    85                                 }
    86                         }
    87 
    88                         if (el) {
    89                                 var focusEditor = tinymce.get(el.id || el.name);
    90 
    91                                 if (el.id && focusEditor) {
    92                                         focusEditor.focus();
    93                                 } else {
    94                                         window.setTimeout(function() {
    95                                                 if (!tinymce.Env.webkit) {
    96                                                         window.focus();
    97                                                 }
    98 
    99                                                 el.focus();
    100                                         }, 10);
    101                                 }
    102 
    103                                 e.preventDefault();
    104                         }
     106                        e.preventDefault();
    105107                }
    106108        }
  • trunk/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js

    r26876 r27034  
    1 tinymce.PluginManager.add("tabfocus",function(e){function n(e){9===e.keyCode&&e.preventDefault()}function t(n){function t(n){function t(e){return"BODY"===e.nodeName||"hidden"!=e.type&&"none"!=e.style.display&&"hidden"!=e.style.visibility&&t(e.parentNode)}function r(e){return e.tabIndex||"INPUT"==e.nodeName||"TEXTAREA"==e.nodeName}function a(e){return!r(e)&&"-1"!=e.getAttribute("tabindex")&&t(e)}if(d=i.select(":input:enabled,*[tabindex]:not(iframe)"),o(d,function(n,t){return n.id==e.id?(u=t,!1):void 0}),n>0){for(c=u+1;c<d.length;c++)if(a(d[c]))return d[c]}else for(c=u-1;c>=0;c--)if(a(d[c]))return d[c];return null}var u,d,a,c;if(9===n.keyCode&&(a=r(e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))),1==a.length&&(a[1]=a[0],a[0]=":prev"),d=n.shiftKey?":prev"==a[0]?t(-1):i.get(a[0]):":next"==a[1]?t(1):i.get(a[1]))){var f=tinymce.get(d.id||d.name);d.id&&f?f.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),d.focus()},10),n.preventDefault()}}var i=tinymce.DOM,o=tinymce.each,r=tinymce.explode;e.on("init",function(){e.inline&&tinymce.DOM.setAttrib(e.getBody(),"tabIndex",null)}),e.on("keyup",n),tinymce.Env.gecko?e.on("keypress keydown",t):e.on("keydown",t)});
     1tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(b){function c(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&c(a.parentNode)}function f(a){return a.tabIndex||"INPUT"==a.nodeName||"TEXTAREA"==a.nodeName}function i(a){return!f(a)&&"-1"!=a.getAttribute("tabindex")&&c(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),b>0){for(j=g+1;j<h.length;j++)if(i(h[j]))return h[j]}else for(j=g-1;j>=0;j--)if(i(h[j]))return h[j];return null}var g,h,i,j;if(!(9!==b.keyCode||b.ctrlKey||b.altKey||b.metaKey)&&(i=f(a.getParam("tab_focus",a.getParam("tabfocus_elements",":prev,:next"))),1==i.length&&(i[1]=i[0],i[0]=":prev"),h=b.shiftKey?":prev"==i[0]?c(-1):d.get(i[0]):":next"==i[1]?c(1):d.get(i[1]))){var k=tinymce.get(h.id||h.name);h.id&&k?k.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),h.focus()},10),b.preventDefault()}}var d=tinymce.DOM,e=tinymce.each,f=tinymce.explode;a.on("init",function(){a.inline&&tinymce.DOM.setAttrib(a.getBody(),"tabIndex",null)}),a.on("keyup",b),tinymce.Env.gecko?a.on("keypress keydown",c):a.on("keydown",c)});
  • trunk/src/wp-includes/version.php

    r27030 r27034  
    1919 * @global string $tinymce_version
    2020 */
    21 $tinymce_version = '4012-20140124';
     21$tinymce_version = '4012-20140125';
    2222
    2323/**
Note: See TracChangeset for help on using the changeset viewer.