
module.exports = new Class({
	Extends: Htk.Field
	,Tag: 'htk-entry'
	,Properties: {
		/**
		 * Displayed text when there is no content.
		 */
		placeholder:
		{ 
			type: String
			,set(x) {
				this.node.placeholder = x;
			}
			,get() {
				return this.node.placeholder;
			}
		},
		/**
		 * Whether is disabled.
		 */
		disabled:
		{ 
			type: Boolean
			,set(x) {
				this.node.disabled = x;
			}
			,get() {
				return this.node.disabled;
			}
		},
		/**
		 * Whether is readonly data.
		 */
		 readonly:
		{ 
			type: Boolean
			,set(x) {
				this.node.readonly = x;
			}
			,get() {
				return this.node.readonly;
			}
		}
	}
	
	,render() {
		var node = this.createRoot('input');
		node.type = 'text';
		node.addEventListener('change', this._onChange.bind(this));
	}

	,_onChange() {
		var newValue;
	
		if (this.node.value == '')
			newValue = null;
		else
			newValue = this.node.value;

		this.valueChanged(newValue);
	}

	,putValue(value) {
		if (!value)
			this.node.value = '';
		else
			this.node.value = value;
	}

	,setEditable(editable) {
		this.node.readOnly = !editable;
	}
});
