Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image handlers: actually change selected image… #42

Merged
merged 1 commit into from
Feb 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 10 additions & 26 deletions blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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' );

/**
* Globals
Expand All @@ -29,6 +33,7 @@ var config = {
'default': []
}
};

var editor = queryFirst( '.editor' );
var switcher = queryFirst( '.block-switcher' );
var switcherButtons = query( '.block-switcher .type svg' );
Expand Down Expand Up @@ -82,7 +87,7 @@ function clearBlocks() {
getBlocks().forEach( function( block ) {
block.className = block.className.replace( 'is-selected', '' );
} );
var selectedBlock = null;
selectedBlock = null;

hideControls();
hideMenu();
Expand Down Expand Up @@ -221,42 +226,21 @@ function siblingGetter( direction ) {

function openBlockMenu( event ) {
event.stopPropagation();
var menu = document.getElementsByClassName( 'insert-block__menu' )[0];
var menu = queryFirst( '.insert-block__menu' );
menu.style.display = 'block';
menu.addEventListener( 'click', function( event ) {
event.stopPropagation();
}, false );
}

function hideMenu() {
var menu = document.getElementsByClassName( 'insert-block__menu' )[0];
var menu = queryFirst( '.insert-block__menu' );
menu.style.display = 'none';
}

function setImageFullBleed( event ) {
event.stopPropagation();
var image = query('img')[0];
console.log(image);
image.className = 'is-selected align-full-bleed';
}

function setImageAlignNone( event ) {
event.stopPropagation();
var image = query('img')[0];
console.log(image);
image.className = 'is-selected';
}

function setImageAlignLeft( event ) {
event.stopPropagation();
var image = query('img')[0];
image.className = 'is-selected align-left';
}

function setImageAlignRight( event ) {
function setImageState( classes, event ) {
event.stopPropagation();
var image = query('img')[0];
image.className = 'is-selected align-right';
selectedBlock.className = 'is-selected ' + classes;
}

function l( data ) {
Expand Down