diff --git a/blocks.js b/blocks.js index a69744ea2a1cc..41bf191a4c188 100644 --- a/blocks.js +++ b/blocks.js @@ -13,6 +13,7 @@ var editor = document.getElementsByClassName( 'editor' )[0]; var switcher = document.getElementsByClassName( 'block-switcher' )[0]; var blockControls = document.getElementsByClassName( 'block-controls' )[0]; var inlineControls = document.getElementsByClassName( 'inline-controls' )[0]; +var insertBlockButton = document.getElementsByClassName( 'insert-block__button' )[0]; var selectedBlock = null; /** @@ -21,6 +22,7 @@ var selectedBlock = null; window.addEventListener( 'click', clearBlocks, false ); editor.addEventListener( 'input', attachBlockHandlers, false ); editor.addEventListener( 'input', clearBlocks, false ); +insertBlockButton.addEventListener( 'click', openBlockMenu, false ); window.addEventListener( 'mouseup', onSelectText, false ); attachBlockHandlers(); @@ -60,6 +62,7 @@ function clearBlocks() { var selectedBlock = null; hideControls(); + hideMenu(); } function showControls( node ) { @@ -188,6 +191,20 @@ function siblingGetter( direction ) { } } +function openBlockMenu( event ) { + event.stopPropagation(); + var menu = document.getElementsByClassName( 'insert-block__menu' )[0]; + menu.style.display = 'block'; + menu.addEventListener( 'click', function( event ) { + event.stopPropagation(); + }, false ); +} + +function hideMenu() { + var menu = document.getElementsByClassName( 'insert-block__menu' )[0]; + menu.style.display = 'none'; +} + function l( data ) { console.log( data ); return data; diff --git a/index.html b/index.html index cca4525ab43ca..5aec0c86616a0 100644 --- a/index.html +++ b/index.html @@ -50,7 +50,36 @@
I like Apple for the opposite reason: they’re not afraid of getting a rudimentary 1.0 out into the world.