diff --git a/blocks.js b/blocks.js index 9d2cf17399ae7..5625112357d4a 100644 --- a/blocks.js +++ b/blocks.js @@ -7,10 +7,14 @@ var getNextSibling = siblingGetter( 'next' ); var getPreviousSibling = siblingGetter( 'previous' ); var getTagType = getConfig.bind( null, 'tagTypes' ); var getTypeKinds = getConfig.bind( null, 'typeKinds' ); -var setImageFullBleed = setImageState.bind( null, 'align-full-bleed' ); -var setImageAlignNone = setImageState.bind( null, '' ); -var setImageAlignLeft = setImageState.bind( null, 'align-left' ); -var setImageAlignRight = setImageState.bind( null, 'align-right' ); +var setImageFullBleed = setElementState.bind( null, 'align-full-bleed' ); +var setImageAlignNone = setElementState.bind( null, '' ); +var setImageAlignLeft = setElementState.bind( null, 'align-left' ); +var setImageAlignRight = setElementState.bind( null, 'align-right' ); + +var setTextAlignLeft = setElementState.bind( null, 'align-left' ); +var setTextAlignCenter = setElementState.bind( null, 'align-center' ); +var setTextAlignRight = setElementState.bind( null, 'align-right' ); /** * Globals @@ -45,6 +49,9 @@ var blockControls = queryFirst( '.block-controls' ); var inlineControls = queryFirst( '.inline-controls' ); var insertBlockButton = queryFirst( '.insert-block__button' ); var insertBlockMenu = queryFirst( '.insert-block__menu' ); +var textAlignLeft = queryFirst( '.block-text__align-left' ); +var textAlignCenter = queryFirst( '.block-text__align-center' ); +var textAlignRight = queryFirst( '.block-text__align-right' ); var imageFullBleed = queryFirst( '.block-image__full-width' ); var imageAlignNone = queryFirst( '.block-image__no-align' ); var imageAlignLeft = queryFirst( '.block-image__align-left' ); @@ -187,6 +194,16 @@ function attachControlActions() { } } ); + // Text block event handlers. + textAlignLeft.addEventListener( 'click', setTextAlignLeft, false ); + textAlignCenter.addEventListener( 'click', setTextAlignCenter, false ); + textAlignRight.addEventListener( 'click', setTextAlignRight, false ); + + switcherButtons.forEach( function( button ) { + button.addEventListener( 'click', showSwitcherMenu, false ); + } ); + + // Image block event handlers. imageFullBleed.addEventListener( 'click', setImageFullBleed, false ); imageAlignNone.addEventListener( 'click', setImageAlignNone, false ); imageAlignLeft.addEventListener( 'click', setImageAlignLeft, false ); @@ -309,7 +326,7 @@ function showSwitcherMenu( event ) { switcherMenu.style.display = 'block'; } -function setImageState( className, event ) { +function setElementState( className, event ) { event.stopPropagation(); selectedBlock.className = 'is-selected'; if ( className ) { diff --git a/index.html b/index.html index 2f509ae6a93a5..ce4f7c6d5e665 100644 --- a/index.html +++ b/index.html @@ -19,13 +19,13 @@