updates
This commit is contained in:
+1
-1
@@ -32,4 +32,4 @@ export class Print{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ut.extendNodeUx(Print);
|
Ut.uxRegister(Print);
|
||||||
@@ -3,56 +3,38 @@ export class AutoExpand {
|
|||||||
/**
|
/**
|
||||||
* Autoexpand, Constructor
|
* Autoexpand, Constructor
|
||||||
*/
|
*/
|
||||||
constructor(target, opts) {
|
constructor(target) {
|
||||||
|
|
||||||
this.opts = { ... { minRows: 3 }, ... opts };
|
|
||||||
|
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
|
||||||
if (this.target.dxData('autoexpand')) {
|
if (this.target.dxData('autoexpand')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.target.dxData('autoexpand', this);
|
this.target.dxData('autoexpand', this);
|
||||||
|
|
||||||
this.update();
|
this.target.rows = 1;
|
||||||
|
this.target.style.overflowY = 'hidden';
|
||||||
|
|
||||||
this.target.dxOn('input.autoExpand', this.setRows.bind(this));
|
this.target.dxOn('input.autoExpand', _ => this.updateRows() )
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoexpand, Update
|
* AutoExpand, Update Rows
|
||||||
*/
|
*/
|
||||||
update() {
|
updateRows() {
|
||||||
|
|
||||||
let val = this.target.dxVal();
|
const style = window.getComputedStyle(this.target);
|
||||||
|
|
||||||
this.target.dxVal('');
|
this.target.style.height = 'auto';
|
||||||
|
this.target.style.height = `${this.target.scrollHeight + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.borderBottomWidth) || 0)}px`;
|
||||||
this.target.dataset.baseScrollHeight = this.target.scrollHeight;
|
|
||||||
|
|
||||||
this.target.dxVal(val);
|
|
||||||
|
|
||||||
if (val) {
|
|
||||||
this.setRows();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Autoexpand, Set Rows
|
|
||||||
*/
|
|
||||||
setRows() {
|
|
||||||
this.target.rows = this.opts.minRows;
|
|
||||||
let rows = Math.ceil((this.target.scrollHeight - this.target.dataset.baseScrollHeight) / 16);
|
|
||||||
this.target.rows = this.opts.minRows + rows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoexpand, Destroy
|
* Autoexpand, Destroy
|
||||||
*/
|
*/
|
||||||
destroy = function() {
|
destroy() {
|
||||||
this.target.dxOff('input.autoExpand');
|
this.target.dxOff('input.autoExpand');
|
||||||
this.target.rows = 2;
|
|
||||||
this.target.dxRemoveData('autoexpand');
|
this.target.dxRemoveData('autoexpand');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user