<commit_before>/**
 * Improve the UI of the default TextArea in two ways:
 * - Provide a popup editor to give full-screen editing
 * - Enable the scrolling of the text area
 */
Ext.define('Ext.ux.field.BetterTextArea', {

	extend: 'Ext.field.TextArea',
	xtype: 'bettertextareafield',

	config: {
		clearIcon: false,

		editorPanel: {
			xtype: 'panel',
			modal: true,
			centered: true,
			scrollable: false,
			items: [
				{ xtype: 'textareafield', style: 'background: #eeeeee;', clearIcon: false },
				{
					xtype: 'toolbar', docked: 'bottom', layout: { type: 'hbox', pack: 'center' },
					items: [
						{ xtype: 'button', text: 'Ok', padding: '0 1em' },
						{ xtype: 'button', text: 'Cancel', padding: '0 1em' }
					]
				}
			]
		}
	},


	initialize: function() {
		this.callParent();
		this.element.on('tap', this.onFormFieldTap, this);
	},


	applyEditorPanel: function(cfg) {

		if(!this.editorPanel) {
			this.editorPanel = Ext.factory(cfg, Ext.Panel);

			this.editorPanel.on('painted', this.onEditorPanelPainted, this);
			this.editorPanel.element.on('drag', this.onTouchMove, this);
		}

		return this.editorPanel;
	},


	onAccept: function() {
		this.setValue(this.editorPanel.down('textareafield').getValue());
		this.editorPanel.hide();
	},


	onCancel: function() {
		this.editorPanel.hide();
	},


	onEditorPanelPainted: function() {
		var panel = this.editorPanel;

		panel.query('button')[0].on('tap', this.onAccept, this, { single: true });
		panel.query('button')[1].on('tap', this.onCancel, this, { single: true });
		panel.down('textareafield').setHeight(panel.element.down('.x-panel-inner').getHeight());
		panel.down('textareafield').setWidth(panel.element.down('.x-panel-inner').getWidth());
		panel.down('textareafield').focus();
	},


	onTouchMove: function(e) {
		this.editorPanel.down('textareafield').element.down('textarea').dom.scrollTop -= (e.deltaY / 2.0);
	},


	onFormFieldTap: function() {
		var editor = this.getEditorPanel();

		if(!this.isInitialized) {
			this.isInitialized = true;
			editor.setWidth(Ext.getBody().getWidth() - 20 );
			editor.setHeight(Ext.getBody().getHeight() - 20);
			Ext.Viewport.add(editor);
		}

		editor.down('textareafield').setValue(this.getValue());
		editor.down('textareafield').setReadOnly(this.getReadOnly());

		editor.show();
	}
});<commit_msg>Virtual keyboard wont appear if readonly<commit_after>/**
 * Improve the UI of the default TextArea in two ways:
 * - Provide a popup editor to give full-screen editing
 * - Enable the scrolling of the text area
 */
Ext.define('Ext.ux.field.BetterTextArea', {

	extend: 'Ext.field.TextArea',
	xtype: 'bettertextareafield',

	config: {
		clearIcon: false,

		editorPanel: {
			xtype: 'panel',
			modal: true,
			centered: true,
			scrollable: false,
			items: [
				{ xtype: 'textareafield', style: 'background: #eeeeee;', clearIcon: false },
				{
					xtype: 'toolbar', docked: 'bottom', layout: { type: 'hbox', pack: 'center' },
					items: [
						{ xtype: 'button', text: 'Ok', padding: '0 1em' },
						{ xtype: 'button', text: 'Cancel', padding: '0 1em' }
					]
				}
			]
		}
	},


	initialize: function() {
		this.callParent();
		this.element.on('tap', this.onFormFieldTap, this);
	},


	applyEditorPanel: function(cfg) {

		if(!this.editorPanel) {
			this.editorPanel = Ext.factory(cfg, Ext.Panel);

			this.editorPanel.on('painted', this.onEditorPanelPainted, this);
			this.editorPanel.element.on('drag', this.onTouchMove, this);
		}

		return this.editorPanel;
	},


	onAccept: function() {
		this.setValue(this.editorPanel.down('textareafield').getValue());
		this.editorPanel.hide();
	},


	onCancel: function() {
		this.editorPanel.hide();
	},


	onEditorPanelPainted: function() {
		var panel = this.editorPanel;

		panel.query('button')[0].on('tap', this.onAccept, this, { single: true });
		panel.query('button')[1].on('tap', this.onCancel, this, { single: true });
		panel.down('textareafield').setHeight(panel.element.down('.x-panel-inner').getHeight());
		panel.down('textareafield').setWidth(panel.element.down('.x-panel-inner').getWidth());

		if(!this.getReadOnly()) {
			panel.down('textareafield').focus();
		}
	},


	onTouchMove: function(e) {
		this.editorPanel.down('textareafield').element.down('textarea').dom.scrollTop -= (e.deltaY / 2.0);
	},


	onFormFieldTap: function() {
		var editor = this.getEditorPanel();

		if(!this.isInitialized) {
			this.isInitialized = true;
			editor.setWidth(Ext.getBody().getWidth() - 20 );
			editor.setHeight(Ext.getBody().getHeight() - 20);
			Ext.Viewport.add(editor);
		}

		editor.down('textareafield').setValue(this.getValue());
		editor.down('textareafield').setReadOnly(this.getReadOnly());

		editor.show();
	}
});
{'fraction_non_alphanumeric': 0.1817411565346325, 'fraction_numerical': 0.005083668714255455, 'mean_word_length': 4.055674518201285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5256618', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1609, 'n_words': 288}