/* ===================================================================================================
 * bookmarkControl
 * ===================================================================================================
 */
 
/// cell: html-div-Element
/// descr: <columnDescriptor>
bookmarkControl_setup = function(cell, txt)
{
	var descr = cell.description;
	
	cell.enabled = false;
	cell.setAttribute("contenteditable", "true");
	cell.setAttribute("class", cell.getAttribute("class") + " bookmark");
	addControlEvent(cell, "focus", function(event) { bookmarkControl_onFocus(cell, event); });
	addControlEvent(cell, "blur", function(event) { bookmarkControl_onBlur(cell, event); });
	addControlEvent(cell, "paste", function(event) { bookmarkControl_onPaste(cell, event); });
	addControlEvent(cell, "beforeinput", function(event) { bookmarkControl_onBeforeInput(cell, event); });
	addControlEvent(cell, "keydown", function(event) { bookmarkControl_onKeyDown(cell, event); });
	addControlEvent(cell, "contextmenu", function(event) { control_onContextMenu(cell, event); });
	cell.enabled = descr.enabled && parseInt(descr.enabled);
	bookmarkControl_setText(cell, txt);
};

bookmarkControl_setText = function(cell, txt)
{
};

bookmarkControl_onFocus = function(cell, event)
{
	if (getBaseClassName(cell).startsWith("grid"))
		gridControl_cellNotify(cell, "onSetFocus");
};

bookmarkControl_onBlur = function(cell, event)
{
	if (getBaseClassName(cell).startsWith("grid"))
		gridControl_cellNotify(cell, "onKillFocus");
};

bookmarkControl_onBeforeInput = function(cell, event)
{
	event.preventDefault();
	switch(event.inputType)
	{
		case "insertParagraph":
			editControl_selectNext(cell);
			break;

		case "insertLineBreak":
			editControl_selectPrev(cell);
			break;
	}
};

bookmarkControl_onPaste = function(cell, event)
{
	event.preventDefault();
};

bookmarkControl_onKeyDown = function(cell, event)
{
	if (getBaseClassName(cell).startsWith("grid"))
	{
		switch (event.key)
		{
			case " ":
			case "Enter":
				event.preventDefault();
				gridControl_cellNotify(cell, "onDblClick");
				break;
			case "ArrowLeft":
				event.preventDefault();
				editControl_selectPrev(cell);
				break;
			case "ArrowRight":
				event.preventDefault();
				editControl_selectNext(cell);
				break;
		}
	}
};
