diff options
Diffstat (limited to 'sources/plugins/button/plugin.js')
-rw-r--r-- | sources/plugins/button/plugin.js | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/sources/plugins/button/plugin.js b/sources/plugins/button/plugin.js index 0ce75c6..e91fa86 100644 --- a/sources/plugins/button/plugin.js +++ b/sources/plugins/button/plugin.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -12,6 +12,7 @@ | |||
12 | ' hidefocus="true"' + | 12 | ' hidefocus="true"' + |
13 | ' role="button"' + | 13 | ' role="button"' + |
14 | ' aria-labelledby="{id}_label"' + | 14 | ' aria-labelledby="{id}_label"' + |
15 | ' aria-describedby="{id}_description"' + | ||
15 | ' aria-haspopup="{hasArrow}"' + | 16 | ' aria-haspopup="{hasArrow}"' + |
16 | ' aria-disabled="{ariaDisabled}"'; | 17 | ' aria-disabled="{ariaDisabled}"'; |
17 | 18 | ||
@@ -28,13 +29,14 @@ | |||
28 | 29 | ||
29 | template += ' onkeydown="return CKEDITOR.tools.callFunction({keydownFn},event);"' + | 30 | template += ' onkeydown="return CKEDITOR.tools.callFunction({keydownFn},event);"' + |
30 | ' onfocus="return CKEDITOR.tools.callFunction({focusFn},event);" ' + | 31 | ' onfocus="return CKEDITOR.tools.callFunction({focusFn},event);" ' + |
31 | ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) + // #188 | 32 | ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) + // http://dev.ckeditor.com/ticket/188 |
32 | '="CKEDITOR.tools.callFunction({clickFn},this);return false;">' + | 33 | '="CKEDITOR.tools.callFunction({clickFn},this);return false;">' + |
33 | '<span class="cke_button_icon cke_button__{iconName}_icon" style="{style}"'; | 34 | '<span class="cke_button_icon cke_button__{iconName}_icon" style="{style}"'; |
34 | 35 | ||
35 | 36 | ||
36 | template += '> </span>' + | 37 | template += '> </span>' + |
37 | '<span id="{id}_label" class="cke_button_label cke_button__{name}_label" aria-hidden="false">{label}</span>' + | 38 | '<span id="{id}_label" class="cke_button_label cke_button__{name}_label" aria-hidden="false">{label}</span>' + |
39 | '<span id="{id}_description" class="cke_button_label" aria-hidden="false">{ariaShortcut}</span>' + | ||
38 | '{arrowHtml}' + | 40 | '{arrowHtml}' + |
39 | '</a>'; | 41 | '</a>'; |
40 | 42 | ||
@@ -47,7 +49,7 @@ | |||
47 | btnTpl = CKEDITOR.addTemplate( 'button', template ); | 49 | btnTpl = CKEDITOR.addTemplate( 'button', template ); |
48 | 50 | ||
49 | CKEDITOR.plugins.add( 'button', { | 51 | CKEDITOR.plugins.add( 'button', { |
50 | lang: 'af,ar,bg,ca,cs,da,de,de-ch,el,en,en-gb,eo,es,eu,fa,fi,fr,gl,he,hu,id,it,ja,km,ko,ku,lt,nb,nl,pl,pt,pt-br,ro,ru,sk,sl,sq,sv,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE% | 52 | lang: 'af,ar,az,bg,ca,cs,da,de,de-ch,el,en,en-gb,eo,es,es-mx,eu,fa,fi,fr,gl,he,hr,hu,id,it,ja,km,ko,ku,lt,nb,nl,no,oc,pl,pt,pt-br,ro,ru,sk,sl,sq,sv,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE% |
51 | beforeInit: function( editor ) { | 53 | beforeInit: function( editor ) { |
52 | editor.ui.addHandler( CKEDITOR.UI_BUTTON, CKEDITOR.ui.button.handler ); | 54 | editor.ui.addHandler( CKEDITOR.UI_BUTTON, CKEDITOR.ui.button.handler ); |
53 | } | 55 | } |
@@ -138,7 +140,9 @@ | |||
138 | stateName = '', | 140 | stateName = '', |
139 | command = this.command, | 141 | command = this.command, |
140 | // Get the command name. | 142 | // Get the command name. |
141 | clickFn; | 143 | clickFn, |
144 | keystroke, | ||
145 | shortcut; | ||
142 | 146 | ||
143 | this._.editor = editor; | 147 | this._.editor = editor; |
144 | 148 | ||
@@ -185,7 +189,7 @@ | |||
185 | } | 189 | } |
186 | instance.execute(); | 190 | instance.execute(); |
187 | 191 | ||
188 | // Fixed iOS focus issue when your press disabled button (#12381). | 192 | // Fixed iOS focus issue when your press disabled button (http://dev.ckeditor.com/ticket/12381). |
189 | if ( env.iOS ) { | 193 | if ( env.iOS ) { |
190 | editor.focus(); | 194 | editor.focus(); |
191 | } | 195 | } |
@@ -239,13 +243,20 @@ | |||
239 | }, this ); | 243 | }, this ); |
240 | } | 244 | } |
241 | 245 | ||
242 | if ( !command ) | 246 | if ( !command ) { |
243 | stateName += 'off'; | 247 | stateName += 'off'; |
248 | } else { | ||
249 | keystroke = editor.getCommandKeystroke( command ); | ||
250 | |||
251 | if ( keystroke ) { | ||
252 | shortcut = CKEDITOR.tools.keystrokeToString( editor.lang.common.keyboard, keystroke ); | ||
253 | } | ||
254 | } | ||
244 | 255 | ||
245 | var name = this.name || this.command, | 256 | var name = this.name || this.command, |
246 | iconName = name; | 257 | iconName = name; |
247 | 258 | ||
248 | // Check if we're pointing to an icon defined by another command. (#9555) | 259 | // Check if we're pointing to an icon defined by another command. (http://dev.ckeditor.com/ticket/9555) |
249 | if ( this.icon && !( /\./ ).test( this.icon ) ) { | 260 | if ( this.icon && !( /\./ ).test( this.icon ) ) { |
250 | iconName = this.icon; | 261 | iconName = this.icon; |
251 | this.icon = null; | 262 | this.icon = null; |
@@ -259,7 +270,8 @@ | |||
259 | cls: this.className || '', | 270 | cls: this.className || '', |
260 | state: stateName, | 271 | state: stateName, |
261 | ariaDisabled: stateName == 'disabled' ? 'true' : 'false', | 272 | ariaDisabled: stateName == 'disabled' ? 'true' : 'false', |
262 | title: this.title, | 273 | title: this.title + ( shortcut ? ' (' + shortcut.display + ')' : '' ), |
274 | ariaShortcut: shortcut ? editor.lang.common.keyboardShortcut + ' ' + shortcut.aria : '', | ||
263 | titleJs: env.gecko && !env.hc ? '' : ( this.title || '' ).replace( "'", '' ), | 275 | titleJs: env.gecko && !env.hc ? '' : ( this.title || '' ).replace( "'", '' ), |
264 | hasArrow: this.hasArrow ? 'true' : 'false', | 276 | hasArrow: this.hasArrow ? 'true' : 'false', |
265 | keydownFn: keydownFn, | 277 | keydownFn: keydownFn, |
@@ -299,7 +311,7 @@ | |||
299 | element.removeAttribute( 'aria-disabled' ); | 311 | element.removeAttribute( 'aria-disabled' ); |
300 | 312 | ||
301 | if ( !this.hasArrow ) { | 313 | if ( !this.hasArrow ) { |
302 | // Note: aria-pressed attribute should not be added to menuButton instances. (#11331) | 314 | // Note: aria-pressed attribute should not be added to menuButton instances. (http://dev.ckeditor.com/ticket/11331) |
303 | state == CKEDITOR.TRISTATE_ON ? | 315 | state == CKEDITOR.TRISTATE_ON ? |
304 | element.setAttribute( 'aria-pressed', true ) : | 316 | element.setAttribute( 'aria-pressed', true ) : |
305 | element.removeAttribute( 'aria-pressed' ); | 317 | element.removeAttribute( 'aria-pressed' ); |