@jswf/core
Version:
JavaScript Window Framework
83 lines • 2.98 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var BaseView_1 = require("./BaseView");
require("../scss/TextBox.scss");
/**
*テキストボックス
*
* @class TextBox
* @extends {JSW.Window}
*/
var TextBox = /** @class */ (function (_super) {
__extends(TextBox, _super);
function TextBox(params) {
var _this = _super.call(this) || this;
_this.setJwfStyle("TextBox");
_this.setAutoSize(true);
var client = _this.getClient();
var node = document.createElement("div");
client.appendChild(node);
var img = document.createElement("img");
if (params && params.image)
img.src = params.image;
node.appendChild(img);
var textArea = document.createElement("div");
node.appendChild(textArea);
var nodeLabel = document.createElement("div");
textArea.appendChild(nodeLabel);
_this.nodeLabel = nodeLabel;
if (params && params.label)
nodeLabel.textContent = params.label;
var nodeText = document.createElement("input");
if (params && params.type)
nodeText.type = params.type;
textArea.appendChild(nodeText);
_this.nodeText = nodeText;
nodeText.addEventListener("keydown", function (e) {
if (e.keyCode == 13)
_this.callEvent("enter", e);
});
if (params && params.text)
_this.setText(params.text);
return _this;
}
TextBox.prototype.setText = function (text) {
var nodeText = this.nodeText;
nodeText.value = text;
var parent = this.getParent();
if (parent)
parent.layout();
};
TextBox.prototype.getText = function () {
return this.nodeText.value;
};
TextBox.prototype.setLabel = function (text) {
var node = this.nodeLabel;
node.textContent = text;
};
TextBox.prototype.getLabel = function () {
return this.nodeLabel.textContent || "";
};
TextBox.prototype.getTextNode = function () {
return this.nodeText;
};
TextBox.prototype.focus = function () {
this.nodeText.focus();
};
return TextBox;
}(BaseView_1.BaseView));
exports.TextBox = TextBox;
//# sourceMappingURL=TextBox.js.map