forked from MapComplete/MapComplete
Intermediate refactoring
This commit is contained in:
parent
93db813cfc
commit
069cddf034
103 changed files with 7950 additions and 0 deletions
49
UI/Base/Button.js
Normal file
49
UI/Base/Button.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
"use strict";
|
||||
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 });
|
||||
exports.Button = void 0;
|
||||
var UIElement_1 = require("../UIElement");
|
||||
var Button = /** @class */ (function (_super) {
|
||||
__extends(Button, _super);
|
||||
function Button(text, onclick, clss) {
|
||||
if (clss === void 0) { clss = ""; }
|
||||
var _this = _super.call(this, undefined) || this;
|
||||
_this._text = text;
|
||||
_this._onclick = onclick;
|
||||
if (clss !== "") {
|
||||
_this._clss = "class='" + clss + "'";
|
||||
}
|
||||
else {
|
||||
_this._clss = "";
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
Button.prototype.InnerRender = function () {
|
||||
return "<form>" +
|
||||
"<button id='button-" + this.id + "' type='button' " + this._clss + ">" + this._text.Render() + "</button>" +
|
||||
"</form>";
|
||||
};
|
||||
Button.prototype.InnerUpdate = function (htmlElement) {
|
||||
_super.prototype.InnerUpdate.call(this, htmlElement);
|
||||
var self = this;
|
||||
console.log("Update for ", htmlElement);
|
||||
document.getElementById("button-" + this.id).onclick = function () {
|
||||
console.log("Clicked");
|
||||
self._onclick();
|
||||
};
|
||||
};
|
||||
return Button;
|
||||
}(UIElement_1.UIElement));
|
||||
exports.Button = Button;
|
57
UI/Base/CollapseButton.js
Normal file
57
UI/Base/CollapseButton.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
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 });
|
||||
exports.CollapseButton = void 0;
|
||||
var UIElement_1 = require("../UIElement");
|
||||
var UIEventSource_1 = require("../UIEventSource");
|
||||
var CollapseButton = /** @class */ (function (_super) {
|
||||
__extends(CollapseButton, _super);
|
||||
function CollapseButton(idToCollapse) {
|
||||
var _this = _super.call(this, undefined) || this;
|
||||
_this.isCollapsed = new UIEventSource_1.UIEventSource(false);
|
||||
_this.ListenTo(_this.isCollapsed);
|
||||
_this.isCollapsed.addCallback(function (collapse) {
|
||||
var el = document.getElementById(idToCollapse);
|
||||
if (el === undefined || el === null) {
|
||||
console.log("Element not found");
|
||||
return;
|
||||
}
|
||||
if (collapse) {
|
||||
el.style.height = "3.5em";
|
||||
el.style.width = "15em";
|
||||
}
|
||||
else {
|
||||
el.style.height = "auto";
|
||||
el.style.width = "auto";
|
||||
}
|
||||
});
|
||||
var self = _this;
|
||||
_this.onClick(function () {
|
||||
self.isCollapsed.setData(!self.isCollapsed.data);
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
CollapseButton.prototype.InnerRender = function () {
|
||||
var up = './assets/arrow-up.svg';
|
||||
var down = './assets/arrow-down.svg';
|
||||
var arrow = up;
|
||||
if (this.isCollapsed.data) {
|
||||
arrow = down;
|
||||
}
|
||||
return "<img class='collapse-button' src='" + arrow + "' alt='collapse'>";
|
||||
};
|
||||
return CollapseButton;
|
||||
}(UIElement_1.UIElement));
|
||||
exports.CollapseButton = CollapseButton;
|
30
UI/Base/FixedUiElement.js
Normal file
30
UI/Base/FixedUiElement.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
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 });
|
||||
exports.FixedUiElement = void 0;
|
||||
var UIElement_1 = require("../UIElement");
|
||||
var FixedUiElement = /** @class */ (function (_super) {
|
||||
__extends(FixedUiElement, _super);
|
||||
function FixedUiElement(html) {
|
||||
var _this = _super.call(this, undefined) || this;
|
||||
_this._html = html !== null && html !== void 0 ? html : "";
|
||||
return _this;
|
||||
}
|
||||
FixedUiElement.prototype.InnerRender = function () {
|
||||
return this._html;
|
||||
};
|
||||
return FixedUiElement;
|
||||
}(UIElement_1.UIElement));
|
||||
exports.FixedUiElement = FixedUiElement;
|
38
UI/Base/VariableUIElement.js
Normal file
38
UI/Base/VariableUIElement.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
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 });
|
||||
exports.VariableUiElement = void 0;
|
||||
var UIElement_1 = require("../UIElement");
|
||||
var VariableUiElement = /** @class */ (function (_super) {
|
||||
__extends(VariableUiElement, _super);
|
||||
function VariableUiElement(html, innerUpdate) {
|
||||
if (innerUpdate === void 0) { innerUpdate = undefined; }
|
||||
var _this = _super.call(this, html) || this;
|
||||
_this._html = html;
|
||||
_this._innerUpdate = innerUpdate;
|
||||
return _this;
|
||||
}
|
||||
VariableUiElement.prototype.InnerRender = function () {
|
||||
return this._html.data;
|
||||
};
|
||||
VariableUiElement.prototype.InnerUpdate = function (htmlElement) {
|
||||
_super.prototype.InnerUpdate.call(this, htmlElement);
|
||||
if (this._innerUpdate !== undefined) {
|
||||
this._innerUpdate(htmlElement);
|
||||
}
|
||||
};
|
||||
return VariableUiElement;
|
||||
}(UIElement_1.UIElement));
|
||||
exports.VariableUiElement = VariableUiElement;
|
45
UI/Base/VerticalCombine.js
Normal file
45
UI/Base/VerticalCombine.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
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 });
|
||||
exports.VerticalCombine = void 0;
|
||||
var UIElement_1 = require("../UIElement");
|
||||
var VerticalCombine = /** @class */ (function (_super) {
|
||||
__extends(VerticalCombine, _super);
|
||||
function VerticalCombine(elements, className) {
|
||||
if (className === void 0) { className = undefined; }
|
||||
var _this = _super.call(this, undefined) || this;
|
||||
_this._elements = elements;
|
||||
_this._className = className;
|
||||
return _this;
|
||||
}
|
||||
VerticalCombine.prototype.InnerRender = function () {
|
||||
var html = "";
|
||||
for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
|
||||
var element = _a[_i];
|
||||
if (!element.IsEmpty()) {
|
||||
html += "<div>" + element.Render() + "</div>";
|
||||
}
|
||||
}
|
||||
if (html === "") {
|
||||
return "";
|
||||
}
|
||||
if (this._className === undefined) {
|
||||
return html;
|
||||
}
|
||||
return "<div class='" + this._className + "'>" + html + "</div>";
|
||||
};
|
||||
return VerticalCombine;
|
||||
}(UIElement_1.UIElement));
|
||||
exports.VerticalCombine = VerticalCombine;
|
Loading…
Add table
Add a link
Reference in a new issue