- var currentAlign = firstBlock.getComputedStyle( 'text-align' ).replace( alignRemoveRegex, '' );\r
- if ( ( !currentAlign && this.isDefaultAlign ) || currentAlign == this.value )\r
- return CKEDITOR.TRISTATE_ON;\r
- return CKEDITOR.TRISTATE_OFF;\r
+ return ( getAlignment( firstBlock, editor.config.useComputedState ) == this.value ) ?\r
+ CKEDITOR.TRISTATE_ON :\r
+ CKEDITOR.TRISTATE_OFF;\r
+ }\r
+\r
+ function getAlignment( element, useComputedState )\r
+ {\r
+ useComputedState = useComputedState === undefined || useComputedState;\r
+\r
+ var align;\r
+ if ( useComputedState )\r
+ align = element.getComputedStyle( 'text-align' );\r
+ else\r
+ {\r
+ while ( !element.hasAttribute || !( element.hasAttribute( 'align' ) || element.getStyle( 'text-align' ) ) )\r
+ {\r
+ var parent = element.getParent();\r
+ if ( !parent )\r
+ break;\r
+ element = parent;\r
+ }\r
+ align = element.getStyle( 'text-align' ) || element.getAttribute( 'align' ) || '';\r
+ }\r
+\r
+ align && ( align = align.replace( /-moz-|-webkit-|start|auto/i, '' ) );\r
+\r
+ !align && useComputedState && ( align = element.getComputedStyle( 'direction' ) == 'rtl' ? 'right' : 'left' );\r
+\r
+ return align;\r