var Composer = function( context ) { var that = this; Component.call( this, 'div', 'component-composer' ); this._context = context; // Slot used to close this frame when a button of the `head` or `tail` is clicked. var onClose = context.remove.bind( context, this ); var head = new Head( onClose ); var tail = new Tail( onClose ); var autocomplete = new Autocomplete(); this._autocomplete = autocomplete; var editor = new Editor(); this._editor = editor; head.appendTo( this.element ); tail.appendTo( this.element ); addBody( this.element, autocomplete, editor ); // Activate when clicked. this.element.addEventListener( 'click', function( evt ) { evt.stopPropagation(); context.activate( that ); }); };
var CompletionItem = function( email, onClick ) { var that = this; Component.call( this, 'div', 'component-completion-item' ); this.element.textContent = email.label + " <" + email.value + ">"; Object.defineProperty( this, 'email', { value: email, writable: false, configurable: true, enumerable: true }); // this.element.addEventListener( 'click', function( evt ) { evt.preventDefault(); evt.stopPropagation(); if( typeof onClick === 'function' ) { onClick.call( that, email ); } }, false); };
var CompletionBox = function( onClick ) { Component.call( this, 'div', 'component-completion-box' ); this._onClick = typeof onClick === 'function' ? onClick : function() {}; this._completion = new CompletionManager(); };