Skip to content

Commit

Permalink
Listenable panel
Browse files Browse the repository at this point in the history
  • Loading branch information
rauenzi committed Nov 2, 2018
1 parent fb3dff0 commit 72caabe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
19 changes: 11 additions & 8 deletions release/0PluginLibrary.plugin.js
Expand Up @@ -6469,9 +6469,11 @@ class SettingGroup extends _structs_listenable__WEBPACK_IMPORTED_MODULE_0__["def

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var modules__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! modules */ "./src/modules/modules.js");
/* harmony import */ var _settingfield__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./settingfield */ "./src/ui/settings/settingfield.js");
/* harmony import */ var _settinggroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./settinggroup */ "./src/ui/settings/settinggroup.js");
/* harmony import */ var _structs_listenable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../structs/listenable */ "./src/structs/listenable.js");
/* harmony import */ var modules__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! modules */ "./src/modules/modules.js");
/* harmony import */ var _settingfield__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./settingfield */ "./src/ui/settings/settingfield.js");
/* harmony import */ var _settinggroup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./settinggroup */ "./src/ui/settings/settinggroup.js");




Expand All @@ -6481,16 +6483,17 @@ __webpack_require__.r(__webpack_exports__);
* @memberof module:Settings
* @version 1.0.1
*/
class SettingPanel {
class SettingPanel extends _structs_listenable__WEBPACK_IMPORTED_MODULE_0__["default"] {

/**
* Creates a new settings panel
* @param {callable} onChange - callback to fire when settings change
* @param {(...HTMLElement|...jQuery|...module:Settings.SettingField|...module:Settings.SettingGroup)} nodes - list of nodes to add to the panel container
*/
constructor(onChange, ...nodes) {
this.element = modules__WEBPACK_IMPORTED_MODULE_0__["DOMTools"].parseHTML(`<div class="plugin-form-container"></div>`);
this.onChangeCallback = typeof(onChange) == "function" ? onChange : _ => _;
super();
this.element = modules__WEBPACK_IMPORTED_MODULE_1__["DOMTools"].parseHTML(`<div class="plugin-form-container"></div>`);
if (typeof(onChange) == "function") this.addListener(onChange);
this.onChange = this.onChange.bind(this);
this.append(...nodes);
}
Expand All @@ -6516,14 +6519,14 @@ class SettingPanel {
append(...nodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i] instanceof jQuery || nodes[i] instanceof Element) this.element.append(nodes[i]);
else if (nodes[i] instanceof _settingfield__WEBPACK_IMPORTED_MODULE_1__["default"] || nodes[i] instanceof _settinggroup__WEBPACK_IMPORTED_MODULE_2__["default"]) this.element.append(nodes[i].getElement()), nodes[i].addListener(this.onChange);
else if (nodes[i] instanceof _settingfield__WEBPACK_IMPORTED_MODULE_2__["default"] || nodes[i] instanceof _settinggroup__WEBPACK_IMPORTED_MODULE_3__["default"]) this.element.append(nodes[i].getElement()), nodes[i].addListener(this.onChange);
}
return this;
}

/** Fires onchange to listeners */
onChange() {
this.onChangeCallback(...arguments);
this.alertListeners(...arguments);
}
}

Expand Down
19 changes: 11 additions & 8 deletions release/ZLibrary.js
Expand Up @@ -6364,9 +6364,11 @@ class SettingGroup extends _structs_listenable__WEBPACK_IMPORTED_MODULE_0__["def

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var modules__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! modules */ "./src/modules/modules.js");
/* harmony import */ var _settingfield__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./settingfield */ "./src/ui/settings/settingfield.js");
/* harmony import */ var _settinggroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./settinggroup */ "./src/ui/settings/settinggroup.js");
/* harmony import */ var _structs_listenable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../structs/listenable */ "./src/structs/listenable.js");
/* harmony import */ var modules__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! modules */ "./src/modules/modules.js");
/* harmony import */ var _settingfield__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./settingfield */ "./src/ui/settings/settingfield.js");
/* harmony import */ var _settinggroup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./settinggroup */ "./src/ui/settings/settinggroup.js");




Expand All @@ -6376,16 +6378,17 @@ __webpack_require__.r(__webpack_exports__);
* @memberof module:Settings
* @version 1.0.1
*/
class SettingPanel {
class SettingPanel extends _structs_listenable__WEBPACK_IMPORTED_MODULE_0__["default"] {

/**
* Creates a new settings panel
* @param {callable} onChange - callback to fire when settings change
* @param {(...HTMLElement|...jQuery|...module:Settings.SettingField|...module:Settings.SettingGroup)} nodes - list of nodes to add to the panel container
*/
constructor(onChange, ...nodes) {
this.element = modules__WEBPACK_IMPORTED_MODULE_0__["DOMTools"].parseHTML(`<div class="plugin-form-container"></div>`);
this.onChangeCallback = typeof(onChange) == "function" ? onChange : _ => _;
super();
this.element = modules__WEBPACK_IMPORTED_MODULE_1__["DOMTools"].parseHTML(`<div class="plugin-form-container"></div>`);
if (typeof(onChange) == "function") this.addListener(onChange);
this.onChange = this.onChange.bind(this);
this.append(...nodes);
}
Expand All @@ -6411,14 +6414,14 @@ class SettingPanel {
append(...nodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i] instanceof jQuery || nodes[i] instanceof Element) this.element.append(nodes[i]);
else if (nodes[i] instanceof _settingfield__WEBPACK_IMPORTED_MODULE_1__["default"] || nodes[i] instanceof _settinggroup__WEBPACK_IMPORTED_MODULE_2__["default"]) this.element.append(nodes[i].getElement()), nodes[i].addListener(this.onChange);
else if (nodes[i] instanceof _settingfield__WEBPACK_IMPORTED_MODULE_2__["default"] || nodes[i] instanceof _settinggroup__WEBPACK_IMPORTED_MODULE_3__["default"]) this.element.append(nodes[i].getElement()), nodes[i].addListener(this.onChange);
}
return this;
}

/** Fires onchange to listeners */
onChange() {
this.onChangeCallback(...arguments);
this.alertListeners(...arguments);
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/ui/settings/settingpanel.js
@@ -1,3 +1,4 @@
import Listenable from "../../structs/listenable";
import {DOMTools} from "modules";
import SettingField from "./settingfield";
import SettingGroup from "./settinggroup";
Expand All @@ -7,16 +8,17 @@ import SettingGroup from "./settinggroup";
* @memberof module:Settings
* @version 1.0.1
*/
class SettingPanel {
class SettingPanel extends Listenable {

/**
* Creates a new settings panel
* @param {callable} onChange - callback to fire when settings change
* @param {(...HTMLElement|...jQuery|...module:Settings.SettingField|...module:Settings.SettingGroup)} nodes - list of nodes to add to the panel container
*/
constructor(onChange, ...nodes) {
this.element = DOMTools.parseHTML(`<div class="plugin-form-container"></div>`);
this.onChangeCallback = typeof(onChange) == "function" ? onChange : _ => _;
super();
this.element = DOMTools.parseHTML(`<div class="plugin-form-container"></div>`);
if (typeof(onChange) == "function") this.addListener(onChange);
this.onChange = this.onChange.bind(this);
this.append(...nodes);
}
Expand Down Expand Up @@ -49,7 +51,7 @@ class SettingPanel {

/** Fires onchange to listeners */
onChange() {
this.onChangeCallback(...arguments);
this.alertListeners(...arguments);
}
}

Expand Down

0 comments on commit 72caabe

Please sign in to comment.