X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fbutton%2Fplugin.js;h=305a6f91ff5c15723941e53aa711e86460878bc4;hb=039a051ccf3901311661022a30afd60fc38130c9;hp=b1dca98038cc122135b09fe8143728c08842032f;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git
diff --git a/_source/plugins/button/plugin.js b/_source/plugins/button/plugin.js
index b1dca98..305a6f9 100644
--- a/_source/plugins/button/plugin.js
+++ b/_source/plugins/button/plugin.js
@@ -69,9 +69,13 @@ CKEDITOR.ui.button.prototype =
*/
render : function( editor, output )
{
- var env = CKEDITOR.env;
+ var env = CKEDITOR.env,
+ id = this._.id = CKEDITOR.tools.getNextId(),
+ classes = '',
+ command = this.command, // Get the command name.
+ clickFn,
+ index;
- var id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber();
this._.editor = editor;
var instance =
@@ -90,14 +94,9 @@ CKEDITOR.ui.button.prototype =
}
};
- var clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
+ instance.clickFn = clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
- var index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
-
- var classes = '';
-
- // Get the command name.
- var command = this.command;
+ instance.index = index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
if ( this.modes )
{
@@ -134,10 +133,14 @@ CKEDITOR.ui.button.prototype =
output.push(
'',
'= 10900 && !env.hc ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'", '' )+ '\')"',
' title="', this.title, '"' +
' tabindex="-1"' +
- ' hidefocus="true"' );
+ ' hidefocus="true"' +
+ ' role="button"' +
+ ' aria-labelledby="' + id + '_label"' +
+ ( this.hasArrow ? ' aria-haspopup="true"' : '' ) );
// Some browsers don't cancel key events in the keydown but in the
// keypress.
@@ -169,13 +172,16 @@ CKEDITOR.ui.button.prototype =
}
output.push(
- '>' +
- '', this.label, '' );
+ '> ' +
+ '', this.label, '' );
if ( this.hasArrow )
{
output.push(
- '' );
+ ''
+ // BLACK DOWN-POINTING TRIANGLE
+ + ( CKEDITOR.env.hc ? '▼' : ' ' )
+ + '' );
}
output.push(
@@ -191,25 +197,27 @@ CKEDITOR.ui.button.prototype =
setState : function( state )
{
if ( this._.state == state )
- return;
+ return false;
+
+ this._.state = state;
var element = CKEDITOR.document.getById( this._.id );
if ( element )
{
element.setState( state );
+ state == CKEDITOR.TRISTATE_DISABLED ?
+ element.setAttribute( 'aria-disabled', true ) :
+ element.removeAttribute( 'aria-disabled' );
- var htmlTitle = this.title,
- unavailable = this._.editor.lang.common.unavailable,
- labelElement = element.getChild( 1 );
-
- if ( state == CKEDITOR.TRISTATE_DISABLED )
- htmlTitle = unavailable.replace( '%1', this.title );
+ state == CKEDITOR.TRISTATE_ON ?
+ element.setAttribute( 'aria-pressed', true ) :
+ element.removeAttribute( 'aria-pressed' );
- labelElement.setHtml( htmlTitle );
+ return true;
}
-
- this._.state = state;
+ else
+ return false;
}
};
@@ -262,3 +270,8 @@ CKEDITOR.ui.prototype.addButton = function( name, definition )
{
this.add( name, CKEDITOR.UI_BUTTON, definition );
};
+
+CKEDITOR.on( 'reset', function()
+ {
+ CKEDITOR.ui.button._.instances = [];
+ });