X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fbutton%2Fplugin.js;h=a5bbccbac412e64aa0282e94feff998fddd19704;hb=1056598c95187351dc58f4991d331e2258d038b5;hp=c0c8208b5c2a1c80cc7e2a46faec4a7eefd4c56c;hpb=614511639979907ceb0da3614122a4d8eb963ad4;p=ckeditor.git diff --git a/_source/plugins/button/plugin.js b/_source/plugins/button/plugin.js index c0c8208..a5bbccb 100644 --- a/_source/plugins/button/plugin.js +++ b/_source/plugins/button/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -55,6 +55,45 @@ CKEDITOR.ui.button.handler = } }; +/** + * Handles a button click. + * @private + */ +CKEDITOR.ui.button._ = +{ + instances : [], + + keydown : function( index, ev ) + { + var instance = CKEDITOR.ui.button._.instances[ index ]; + + if ( instance.onkey ) + { + ev = new CKEDITOR.dom.event( ev ); + return ( instance.onkey( instance, ev.getKeystroke() ) !== false ); + } + }, + + focus : function( index, ev ) + { + var instance = CKEDITOR.ui.button._.instances[ index ], + retVal; + + if ( instance.onfocus ) + retVal = ( instance.onfocus( instance, new CKEDITOR.dom.event( ev ) ) !== false ); + + // FF2: prevent focus event been bubbled up to editor container, which caused unexpected editor focus. + if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) + ev.preventBubble(); + return retVal; + } +}; + +( function() +{ + var keydownFn = CKEDITOR.tools.addFunction( CKEDITOR.ui.button._.keydown, CKEDITOR.ui.button._ ), + focusFn = CKEDITOR.tools.addFunction( CKEDITOR.ui.button._.focus, CKEDITOR.ui.button._ ); + CKEDITOR.ui.button.prototype = { canGroup : true, @@ -142,7 +181,7 @@ CKEDITOR.ui.button.prototype = classes += ' ' + this.className; output.push( - '', + '', '= 10900 && !env.hc ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'", '' )+ '\')"', @@ -171,8 +210,8 @@ CKEDITOR.ui.button.prototype = } output.push( - ' onkeydown="return CKEDITOR.ui.button._.keydown(', index, ', event);"' + - ' onfocus="return CKEDITOR.ui.button._.focus(', index, ', event);"' + + ' onkeydown="return CKEDITOR.tools.callFunction(', keydownFn, ', ', index, ', event);"' + + ' onfocus="return CKEDITOR.tools.callFunction(', focusFn,', ', index, ', event);"' + ' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' + '