From 2307c167488bbd1813928b7dabc18c6e4d562008 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 6 Jun 2022 18:02:17 +0200 Subject: [PATCH] Checkpoint --- forms/ecomerce/catalog/catalog.js | 7 ++- forms/ecomerce/catalog/ui.xml | 8 +-- forms/ecomerce/checkout/checkout.js | 7 +-- forms/ecomerce/checkout/ui.xml | 32 +++++------ js/db/db-lot.js | 2 +- js/db/model.js | 17 ++++-- js/db/query.js | 2 +- js/hedera/form.js | 2 +- js/hedera/gui.js | 5 +- js/hedera/login.js | 2 +- js/hedera/report.js | 2 +- js/htk/assistant/index.js | 2 +- js/htk/check/index.js | 21 +++----- js/htk/column/index.js | 5 +- js/htk/columns/button/index.js | 5 +- .../button/style.scss} | 26 --------- js/htk/columns/check/index.js | 5 +- js/htk/columns/check/style.scss | 5 ++ js/htk/columns/date/index.js | 4 +- js/htk/columns/image/index.js | 5 +- js/htk/columns/image/style.scss | 11 ++++ js/htk/columns/link/index.js | 2 +- js/htk/columns/radio/index.js | 4 +- js/htk/columns/spin/index.js | 7 +-- js/htk/columns/spin/style.scss | 8 +++ js/htk/columns/text/index.js | 4 +- js/htk/dialog/index.js | 4 +- js/htk/image-editor/index.js | 2 +- js/htk/popup/index.js | 2 +- js/htk/radio/radio-group.js | 2 +- js/htk/repeater/index.js | 4 +- js/htk/step/index.js | 2 +- js/htk/style/index.scss | 1 - js/sql/list.js | 6 +-- js/vn/component.js | 11 ++-- js/vn/form.js | 2 +- js/vn/hash.js | 4 +- js/vn/iterator.js | 2 +- js/vn/json-connection.js | 6 +-- js/vn/lot-query.js | 2 +- js/vn/lot.js | 2 +- js/vn/node-builder.js | 4 +- js/vn/object.js | 54 ++++++++++--------- js/vn/scope.js | 2 +- 44 files changed, 159 insertions(+), 153 deletions(-) rename js/htk/{style/components.scss => columns/button/style.scss} (61%) create mode 100644 js/htk/columns/check/style.scss create mode 100644 js/htk/columns/image/style.scss create mode 100644 js/htk/columns/spin/style.scss diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index a5341e76..dd8e67c7 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -17,6 +17,10 @@ Hedera.Catalog = new Class({ } } + ,refreshColors() { + this.$.colors.lazyRefresh(); + } + ,onBasketCheck: function(isOk) { if (isOk) this.loadUi(); @@ -104,8 +108,7 @@ Hedera.Catalog = new Class({ $.items.clean(); for (const tag of tags) - if (params[tag] != null) - $[`${tag}`].lot = this.getFilter(params, tags); + $[`${tag}s`].lot = this.getFilter(params, tags, tag); } ,refreshTitle: function() { diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 07dd0b3e..ea0ed4aa 100644 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -266,7 +266,7 @@ placeholder="_Color" form="params" column="color" - on-click="$.colors.refresh()"> + on-mousedown="this.refreshColors()"> + on-mousedown="$.producers.lazyRefresh()"> + on-mousedown="$.origins.lazyRefresh()"> + on-mousedown="$.categorys.lazyRefresh()">
@@ -112,8 +114,7 @@ + on-change="onAddressChange"> SELECT a.id, a.nickname, p.name province, a.city, a.street, a.isActive, c.country FROM myAddress a @@ -122,13 +123,12 @@ WHERE a.isActive -
-

- -

-

- -

+
+

{{iter.nickname}}

+

{{iter.street}}

@@ -142,7 +142,8 @@
@@ -155,7 +156,8 @@
@@ -166,7 +168,7 @@

Arrival - +

@@ -184,7 +186,7 @@

Pickup - +

Warehouse diff --git a/js/db/db-lot.js b/js/db/db-lot.js index c17e8dd9..67a3b3c6 100644 --- a/js/db/db-lot.js +++ b/js/db/db-lot.js @@ -58,7 +58,7 @@ module.exports = new Class({ ,initialize: function(props) { this.model = new Model(); - this.parent(props); + Vn.Form.prototype.initialize.call(this, props); } ,appendChild: function(child) { diff --git a/js/db/model.js b/js/db/model.js index 63e8a25f..942b9fec 100644 --- a/js/db/model.js +++ b/js/db/model.js @@ -197,6 +197,7 @@ Model.implement({ ,columns: null ,columnMap: null ,_updatable: false + ,_paramsChanged: true ,_requestedSortIndex: -1 ,_requestedSortName: null @@ -213,7 +214,7 @@ Model.implement({ ,_requestedMainTable: null ,initialize: function(props) { - this.parent(props); + Vn.Object.prototype.initialize.call(this, props); this._cleanData(); this._setStatus(Status.CLEAN); } @@ -224,7 +225,7 @@ Model.implement({ } ,loadXml: function(builder, node) { - this.parent(builder, node); + Vn.Object.prototype.loadXml.call(this, builder, node); var query = node.firstChild.nodeValue; @@ -277,11 +278,11 @@ Model.implement({ ,_onLotChange: function() { const params = this._getHolderValues(); - const isEqual = Vn.Value.equals(params, this._lastParams); + this._paramsChanged = !Vn.Value.equals(params, this._lastParams); this._lastParams = params; - if (!isEqual) - this._autoLoad(); + if (this.autoLoad) + this.lazyRefresh(); } ,_autoLoad: function() { @@ -302,6 +303,11 @@ Model.implement({ return true; } + ,lazyRefresh: function() { + if (this._paramsChanged) + this.refresh(); + } + /** * Refresh the model data reexecuting the query on the database. */ @@ -310,6 +316,7 @@ Model.implement({ if (this._isReady(params)) { this._setStatus(Status.LOADING); + this._paramsChanged = false; this._conn.execStmt(this._stmt, this._selectDone.bind(this), params); } else diff --git a/js/db/query.js b/js/db/query.js index d1d4561b..95685a25 100644 --- a/js/db/query.js +++ b/js/db/query.js @@ -72,7 +72,7 @@ module.exports = new Class({ } ,loadXml: function(builder, node) { - this.parent(builder, node); + Vn.Object.prototype.loadXml.call(this, builder, node); var query = node.firstChild.nodeValue; diff --git a/js/hedera/form.js b/js/hedera/form.js index cac2aec8..63f273e4 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -103,7 +103,7 @@ module.exports = new Class({ ,_destroy: function() { this.close(); - this.parent(); + Vn.Object.prototype._destroy.call(this); } }); diff --git a/js/hedera/gui.js b/js/hedera/gui.js index 8311a915..355ea778 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -39,7 +39,7 @@ module.exports = new Class({ event.stopPropagation(); }); - this.parent(props); + Vn.Component.prototype.initialize.call(this, props); var sql = 'SELECT id, name, nickname FROM account.myUser;' +'SELECT defaultForm FROM config;' @@ -512,7 +512,6 @@ module.exports = new Class({ ,_destroy: function() { this.hide(); - this.parent(); + Vn.Component.prototype.initialize.call(this); } }); - diff --git a/js/hedera/login.js b/js/hedera/login.js index e042cb7f..36fba7c7 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -19,7 +19,7 @@ module.exports = new Class({ } ,initialize: function(props) { - this.parent(props); + Vn.Component.prototype.initialize.call(this, props); this.loadTemplateFromString(Tpl); //this.$.socialBar.conn = this._conn; diff --git a/js/hedera/report.js b/js/hedera/report.js index 772aed81..06c53530 100644 --- a/js/hedera/report.js +++ b/js/hedera/report.js @@ -6,7 +6,7 @@ module.exports = new Class({ this.info = moduleInfo; this.gui = gui; this.conn = gui.conn; - this.parent(null); + Vn.Object.prototype.initialize.call(this); } ,open: function(lot) { diff --git a/js/htk/assistant/index.js b/js/htk/assistant/index.js index cd26e6cb..dd9c411c 100644 --- a/js/htk/assistant/index.js +++ b/js/htk/assistant/index.js @@ -83,7 +83,7 @@ module.exports = new Class({ initialize: function(props) { var node = this.createRoot('div'); node.className = 'htk-assistant'; - this.parent(props); + Component.prototype.initialize.call(this, props); }, appendChild: function(step) { diff --git a/js/htk/check/index.js b/js/htk/check/index.js index 2cfc9b5e..56d4f8e8 100644 --- a/js/htk/check/index.js +++ b/js/htk/check/index.js @@ -1,31 +1,26 @@ -module.exports = new Class -({ +module.exports = new Class({ Extends: Htk.Field ,Tag: 'htk-check' - ,render: function () - { - var node = this.createRoot ('input'); + ,render: function() { + var node = this.createRoot('input'); node.type = 'checkbox'; - node.addEventListener ('change', this.changed.bind (this)); + node.addEventListener('change', this.changed.bind(this)); } - ,changed: function () - { - this.valueChanged (this.node.checked); + ,changed: function() { + this.valueChanged(this.node.checked); } - ,putValue: function (value) - { + ,putValue: function(value) { if (value) this.node.checked = true; else this.node.checked = false; } - ,setEditable: function (editable) - { + ,setEditable: function(editable) { this.node.disabled = !editable; } }); diff --git a/js/htk/column/index.js b/js/htk/column/index.js index c1588bfb..e5f9385b 100644 --- a/js/htk/column/index.js +++ b/js/htk/column/index.js @@ -8,8 +8,7 @@ var NodeBuilder = require('../../vn/node-builder'); module.exports = new Class({ Extends: NodeBuilder ,Tag: 'htk-column' - ,Properties: - { + ,Properties: { value: { type: String ,value: null @@ -57,7 +56,7 @@ module.exports = new Class({ * Initializes the column. */ ,initialize: function(props) { - this.parent(props); + NodeBuilder.prototype.initialize.call(this, props); this.td = this.createElement('td'); } diff --git a/js/htk/columns/button/index.js b/js/htk/columns/button/index.js index 1c4565ae..552a39e5 100644 --- a/js/htk/columns/button/index.js +++ b/js/htk/columns/button/index.js @@ -1,3 +1,4 @@ +require('./style.scss'); module.exports = new Class({ Extends: Htk.Column, @@ -36,11 +37,11 @@ module.exports = new Class({ initialize: function(props) { this._cssClass = 'cell-button'; - this.parent(props); + Htk.Column.prototype.initialize.call(this, props); }, render: function(tr) { - const td = this.parent(tr); + const td = Htk.Column.prototype.render.call(this, tr); let button; diff --git a/js/htk/style/components.scss b/js/htk/columns/button/style.scss similarity index 61% rename from js/htk/style/components.scss rename to js/htk/columns/button/style.scss index ca8f89fa..3520b492 100644 --- a/js/htk/style/components.scss +++ b/js/htk/columns/button/style.scss @@ -1,19 +1,4 @@ -@import "./variables"; - -th.cell-spin { - text-align: right; -} -td.cell-spin { - width: 2.5em; - text-align: right; -} - -th.cell-check, -th.cell-radio { - text-align: center; -} - td.cell-button { max-width: 20px; text-align: center; @@ -46,14 +31,3 @@ td.cell-button { padding: 0; } } - -td.cell-image { - text-align: center; - - .htk-image { - max-width: 2.5em; - max-height: 2.5em; - display: block; - margin: auto; - } -} \ No newline at end of file diff --git a/js/htk/columns/check/index.js b/js/htk/columns/check/index.js index 60868aa1..0face4d1 100644 --- a/js/htk/columns/check/index.js +++ b/js/htk/columns/check/index.js @@ -1,3 +1,4 @@ +require('./style.scss'); module.exports = new Class({ Extends: Htk.Column @@ -5,7 +6,7 @@ module.exports = new Class({ ,initialize: function(props) { this._cssClass = 'cell-check'; - this.parent(props); + Htk.Column.prototype.initialize.call(this, props); } ,render: function(tr) { @@ -19,7 +20,7 @@ module.exports = new Class({ else checkButton.disabled = true; - var td = this.parent(tr); + var td = Htk.Column.prototype.render.call(this, tr); td.appendChild(checkButton); return td; } diff --git a/js/htk/columns/check/style.scss b/js/htk/columns/check/style.scss new file mode 100644 index 00000000..bdee6773 --- /dev/null +++ b/js/htk/columns/check/style.scss @@ -0,0 +1,5 @@ + +th.cell-check, +th.cell-radio { + text-align: center; +} diff --git a/js/htk/columns/date/index.js b/js/htk/columns/date/index.js index f215c755..336573fc 100644 --- a/js/htk/columns/date/index.js +++ b/js/htk/columns/date/index.js @@ -24,13 +24,13 @@ module.exports = new Class ,initialize: function(props) { this._cssClass = 'cell-date'; - this.parent(props); + Htk.Column.prototype.initialize.call(this, props); } ,render: function(tr) { var text = Vn.Date.strftime(this.value, this._format); - var td = this.parent(tr); + var td = Htk.Column.prototype.render.call(this, tr); td.appendChild(this.createTextNode(text)); return td; diff --git a/js/htk/columns/image/index.js b/js/htk/columns/image/index.js index 757aa913..3542f238 100644 --- a/js/htk/columns/image/index.js +++ b/js/htk/columns/image/index.js @@ -1,3 +1,4 @@ +require('./style.scss'); module.exports = new Class({ Extends: Htk.Column @@ -34,7 +35,7 @@ module.exports = new Class({ ,initialize: function(props) { this._cssClass = 'cell-image'; - this.parent(props); + Htk.Column.prototype.initialize.call(this, props); } ,render: function(tr) { @@ -47,7 +48,7 @@ module.exports = new Class({ ,doc: this.doc }); - var td = this.parent(tr); + var td = Htk.Column.prototype.render.call(this, tr); td.appendChild(image.node); return td; } diff --git a/js/htk/columns/image/style.scss b/js/htk/columns/image/style.scss new file mode 100644 index 00000000..9be8f215 --- /dev/null +++ b/js/htk/columns/image/style.scss @@ -0,0 +1,11 @@ + +td.cell-image { + text-align: center; + + .htk-image { + max-width: 2.5em; + max-height: 2.5em; + display: block; + margin: auto; + } +} diff --git a/js/htk/columns/link/index.js b/js/htk/columns/link/index.js index 97efdc49..23b44895 100644 --- a/js/htk/columns/link/index.js +++ b/js/htk/columns/link/index.js @@ -27,7 +27,7 @@ module.exports = new Class({ if (this.target) link.target = this.target; - var td = this.parent(tr); + var td = Htk.Column.prototype.render.call(this, tr); td.appendChild(link); return td; } diff --git a/js/htk/columns/radio/index.js b/js/htk/columns/radio/index.js index 4ae7690e..29b753e4 100644 --- a/js/htk/columns/radio/index.js +++ b/js/htk/columns/radio/index.js @@ -14,11 +14,11 @@ module.exports = new Class({ ,initialize: function(props) { this._cssClass = 'cell-radio'; this.radioGroup = new Htk.RadioGroup(this.doc); - this.parent(props); + Htk.Column.prototype.initialize.call(this, props); } ,render: function(tr) { - var td = this.parent(tr); + var td = Htk.Column.prototype.render.call(this, tr); var radio = this.radioGroup.createButton(this.value); td.appendChild(radio); diff --git a/js/htk/columns/spin/index.js b/js/htk/columns/spin/index.js index f5885668..85022c4e 100644 --- a/js/htk/columns/spin/index.js +++ b/js/htk/columns/spin/index.js @@ -1,3 +1,4 @@ +require('./style.scss'); module.exports = new Class({ Extends: Htk.Column @@ -21,17 +22,17 @@ module.exports = new Class({ ,initialize: function(props) { this._cssClass = 'cell-spin'; - this.parent(props); + Htk.Column.prototype.initialize.call(this, props); } ,renderHeader: function() { - var th = this.parent(); + var th = Htk.Column.prototype.renderHeader.call(this, ); th.className = 'cell-spin'; return th; } ,render: function(tr) { - var td = this.parent(tr); + var td = Htk.Column.prototype.render.call(this, tr); var valueString = null; diff --git a/js/htk/columns/spin/style.scss b/js/htk/columns/spin/style.scss new file mode 100644 index 00000000..33603fb3 --- /dev/null +++ b/js/htk/columns/spin/style.scss @@ -0,0 +1,8 @@ + +th.cell-spin { + text-align: right; +} +td.cell-spin { + width: 2.5em; + text-align: right; +} diff --git a/js/htk/columns/text/index.js b/js/htk/columns/text/index.js index 7d6bf395..749823c1 100644 --- a/js/htk/columns/text/index.js +++ b/js/htk/columns/text/index.js @@ -21,7 +21,7 @@ module.exports = new Class({ ,initialize: function(props) { this._cssClass = 'cell-text'; - this.parent(props); + Htk.Column.prototype.initialize.call(this, props); } ,render: function(tr) { @@ -39,7 +39,7 @@ module.exports = new Class({ node = this.createTextNode( Vn.Value.format(this.value, this._format)); - var td = this.parent(tr); + var td = Htk.Column.prototype.render.call(this, tr); td.appendChild(node); return td; } diff --git a/js/htk/dialog/index.js b/js/htk/dialog/index.js index 0c1709a0..5ac11fd2 100644 --- a/js/htk/dialog/index.js +++ b/js/htk/dialog/index.js @@ -97,7 +97,7 @@ Dialog.implement({ ,_buttons: Button.ACCEPT ,open: function() { - this.parent(); + Popup.prototype.open.call(this); // Dialog body @@ -146,7 +146,7 @@ Dialog.implement({ ,hide(response) { if (!this._isOpen) return; - this.parent(); + Popup.prototype.hide.call(this); this.emit('response', response); } diff --git a/js/htk/image-editor/index.js b/js/htk/image-editor/index.js index f18797e0..3ba053ae 100644 --- a/js/htk/image-editor/index.js +++ b/js/htk/image-editor/index.js @@ -26,7 +26,7 @@ module.exports = new Class({ self._onSubmit(); return false; }; - this.parent(props); + Component.prototype.initialize.call(this, props); }, onNameChange: function() { diff --git a/js/htk/popup/index.js b/js/htk/popup/index.js index a0f82f27..5afca3bd 100644 --- a/js/htk/popup/index.js +++ b/js/htk/popup/index.js @@ -55,7 +55,7 @@ module.exports = new Class({ ,initialize: function(props) { this._bgMouseDownHandler = this._bgMouseDown.bind(this); - this.parent(props); + Component.prototype.initialize.call(this, props); } ,render: function() { diff --git a/js/htk/radio/radio-group.js b/js/htk/radio/radio-group.js index 74c38ba8..59673b4f 100644 --- a/js/htk/radio/radio-group.js +++ b/js/htk/radio/radio-group.js @@ -9,7 +9,7 @@ module.exports = new Class({ ,initialize: function(props) { this.clear(); - this.parent(props); + Htk.Field.prototype.initialize.call(this, props); } ,clear: function() { diff --git a/js/htk/repeater/index.js b/js/htk/repeater/index.js index 77b45ea7..53b3f3b6 100644 --- a/js/htk/repeater/index.js +++ b/js/htk/repeater/index.js @@ -91,7 +91,7 @@ module.exports = new Class({ } ,loadXml: function(scope, node) { - this.parent(scope, node); + Component.prototype.loadXml.call(this, scope, node); this._parentScope = scope; var builder = this._builder = new Vn.Builder(); @@ -233,7 +233,7 @@ module.exports = new Class({ ,destroy: function() { this._freeChildsData(); - this.parent(); + Component.prototype.destroy.call(this); } }); diff --git a/js/htk/step/index.js b/js/htk/step/index.js index 7634d657..86ce2a2f 100644 --- a/js/htk/step/index.js +++ b/js/htk/step/index.js @@ -22,7 +22,7 @@ module.exports = new Class({ initialize: function(props) { var node = this.createRoot('div'); node.className = 'htk-step'; - this.parent(props); + Component.prototype.initialize.call(this, props); }, show: function() { diff --git a/js/htk/style/index.scss b/js/htk/style/index.scss index 90999008..5242ad67 100644 --- a/js/htk/style/index.scss +++ b/js/htk/style/index.scss @@ -4,5 +4,4 @@ @import "./spacing"; @import "./text"; @import "./width"; -@import "./components"; @import "./material-symbols"; diff --git a/js/sql/list.js b/js/sql/list.js index 1f539f4a..b9c7e697 100644 --- a/js/sql/list.js +++ b/js/sql/list.js @@ -1,11 +1,11 @@ -var Object = require('./object'); +var SqlObject = require('./object'); /** * List of Sql.Object */ module.exports = new Class({ - Extends: Object + Extends: SqlObject ,objects: [] @@ -65,7 +65,7 @@ module.exports = new Class({ for (var i = 0; i < this.objects.length; i++) this._unrefObject(this.objects[i]); - this.parent(); + SqlObject.prototype._destroy.call(this); } }); diff --git a/js/vn/component.js b/js/vn/component.js index b52e4444..2d72fa39 100644 --- a/js/vn/component.js +++ b/js/vn/component.js @@ -7,8 +7,9 @@ module.exports = Klass; Klass.extend({Classes: ''}); const ComponentClass = { - Extends: NodeBuilder - ,Properties: { + Extends: NodeBuilder, + Tag: 'vn-component', + Properties: { /** * Main HTML node that represents the component */ @@ -101,7 +102,7 @@ const ComponentClass = { ,initialize: function(props) { this.doc = document; this.renderBase(); - this.parent(props); + NodeBuilder.prototype.initialize.call(this, props); } ,createRoot: function(tagName) { @@ -142,7 +143,7 @@ const ComponentClass = { this.addEventListener(id, callback.bind(instance, this)); } else - this.parent(id, callback, instance); + NodeBuilder.prototype.on.call(this, id, callback, instance); } ,loadTemplateFromFile: function(path) { @@ -169,7 +170,7 @@ const ComponentClass = { if (this.scope) this.scope.unref(); - this.parent(); + NodeBuilder.prototype._destroy.call(this, ); } }; diff --git a/js/vn/form.js b/js/vn/form.js index 3437407e..208bc25b 100644 --- a/js/vn/form.js +++ b/js/vn/form.js @@ -44,7 +44,7 @@ module.exports = new Class({ _lastRow: 0 ,_lastReady: false }); - this.parent(props); + Iterator.prototype.initialize.call(this, props); } ,onModelChange: function() { diff --git a/js/vn/hash.js b/js/vn/hash.js index 655e2f10..146bb690 100644 --- a/js/vn/hash.js +++ b/js/vn/hash.js @@ -33,7 +33,7 @@ module.exports = new Class({ ,_window: null ,_hashChangedHandler: this._hashChanged.bind(this) }); - this.parent(props); + Lot.prototype.initialize.call(this, props); } ,_paramsChanged: function() { @@ -159,6 +159,6 @@ module.exports = new Class({ ,_destroy: function() { this._window.removeEventListener('hashchange', this._hashChangedHandler); this._window = null; - this.parent(); + Lot.prototype._destroy.call(this); } }); diff --git a/js/vn/iterator.js b/js/vn/iterator.js index ba6f51aa..01888c7a 100644 --- a/js/vn/iterator.js +++ b/js/vn/iterator.js @@ -53,7 +53,7 @@ module.exports = new Class({ _row: -1 ,_rowLock: false }); - this.parent(props); + Lot.prototype.initialize.call(this, props); } ,_paramsChanged: function(diff) { diff --git a/js/vn/json-connection.js b/js/vn/json-connection.js index ca00d381..f6655927 100644 --- a/js/vn/json-connection.js +++ b/js/vn/json-connection.js @@ -1,12 +1,12 @@ -var Object = require('./object'); +var VnObject = require('./object'); var JsonException = require('./json-exception'); /** * Handler for JSON rest connections. */ module.exports = new Class({ - Extends: Object + Extends: VnObject ,_connected: false ,_requestsCount: 0 @@ -16,7 +16,7 @@ module.exports = new Class({ * Initilizes the connection object. */ ,initialize: function() { - this.parent(); + VnObject.prototype.initialize.call(this); this.fetchToken(); } diff --git a/js/vn/lot-query.js b/js/vn/lot-query.js index 3e4ffa39..63981d7d 100644 --- a/js/vn/lot-query.js +++ b/js/vn/lot-query.js @@ -37,7 +37,7 @@ module.exports = new Class({ _lockSource: false, _specs: {} }); - this.parent(props); + Lot.prototype.initialize.call(this, props); } ,appendChild: function(child) { diff --git a/js/vn/lot.js b/js/vn/lot.js index 68a4353d..bd6bbe09 100644 --- a/js/vn/lot.js +++ b/js/vn/lot.js @@ -30,7 +30,7 @@ module.exports = new Class({ ,initialize: function(props) { this._params = {}; - this.parent(props); + VnObject.prototype.initialize.call(this, props); } ,keys: function() { diff --git a/js/vn/node-builder.js b/js/vn/node-builder.js index 7727285c..30b8c004 100644 --- a/js/vn/node-builder.js +++ b/js/vn/node-builder.js @@ -11,11 +11,11 @@ module.exports = new Class({ } ,createElement: function(tagName) { - return document.createElement(tagName); + return this.doc.createElement(tagName); } ,createTextNode: function(text) { - return document.createTextNode(text); + return this.doc.createTextNode(text); } ,render: function() {} diff --git a/js/vn/object.js b/js/vn/object.js index a4474687..2b2c3668 100644 --- a/js/vn/object.js +++ b/js/vn/object.js @@ -3,27 +3,27 @@ * The main base class. Manages the signal system. Objects based on this class * can be instantiated declaratively using XML. */ -module.exports = new Class({ +module.exports = class VnObject { /** * Tag to be used when the class instance is defined via XML. All classes * must define this attribute, even if it is not used. */ - Tag: 'vn-object' + static Tag = 'vn-object'; /** * Class public properties. */ - ,Properties: {} + static Properties = {}; /* - * Reference count. - */ - ,_refCount: 1 + * Reference count. + */ + _refCount = 1; /* - * Signal handlers data. - */ - ,_thisArg: null + * Signal handlers data. + */ + _thisArg = null; /** * Initializes the object and sets all properties passed to the class @@ -31,7 +31,11 @@ module.exports = new Class({ * * @param {Object} props The properties passed to the contructor */ - ,initialize: function(props) { + constructor(props) { + this.setProperties(props); + } + + initialize(props) { this.setProperties(props); } @@ -40,7 +44,7 @@ module.exports = new Class({ * * @param {Object} props Properties */ - ,setProperties: function(props) { + setProperties(props) { for (var prop in props) this[prop] = props[prop]; } @@ -48,7 +52,7 @@ module.exports = new Class({ /** * Increases the object reference count. */ - ,ref: function() { + ref() { this._refCount++; return this; } @@ -56,7 +60,7 @@ module.exports = new Class({ /** * Decreases the object reference count. */ - ,unref: function() { + unref() { this._refCount--; if (this._refCount === 0) @@ -70,7 +74,7 @@ module.exports = new Class({ * @param {Vn.Scope} scope The scope instance * @param {Node} node The custom tag child nodes */ - ,loadXml: function() {} + loadXml() {} /** * Called from @Vn.Builder when it finds a a child tag that isn't @@ -78,7 +82,7 @@ module.exports = new Class({ * * @param {Object} child The child object instance */ - ,appendChild: function() {} + appendChild() {} /** * Conects a signal with a function. @@ -87,7 +91,7 @@ module.exports = new Class({ * @param {function} callback The callback * @param {Object} instance The instance */ - ,on: function(id, callback, instance) { + on(id, callback, instance) { if (!(callback instanceof Function)) { console.warn('Vn.Object: Invalid callback for signal \'%s\'', id); return; @@ -113,7 +117,7 @@ module.exports = new Class({ * @param {function} callback The callback * @param {boolean} block %true for lock the signal, %false for unlock */ - ,blockSignal: function(id, callback, block, instance) { + blockSignal(id, callback, block, instance) { if (!this._thisArg) return; @@ -133,7 +137,7 @@ module.exports = new Class({ * * @param {string} id The signal identifier */ - ,emit: function(id) { + emit(id) { if (!this._thisArg) return; @@ -160,7 +164,7 @@ module.exports = new Class({ * @param {function} callback The connected callback * @param {Object} instance The instance */ - ,disconnect: function(id, callback, instance) { + disconnect(id, callback, instance) { if (!this._thisArg) return; @@ -178,7 +182,7 @@ module.exports = new Class({ * * @param {Object} instance The instance */ - ,disconnectByInstance: function(instance) { + disconnectByInstance(instance) { if (!this._thisArg) return; @@ -199,7 +203,7 @@ module.exports = new Class({ * the last reference to the object. It can be overwritten by child classes * but should always call the parent method. */ - ,_destroy: function() { + _destroy() { if (!this._thisArg) return; @@ -217,7 +221,7 @@ module.exports = new Class({ * @param {Object} prop The linked property * @param {Object} handlers The object events to listen with */ - ,link: function(prop, handlers) { + link(prop, handlers) { this._signalInit(); var links = this._thisArg.links; @@ -240,16 +244,16 @@ module.exports = new Class({ } } - ,_unlink: function(object) { + _unlink(object) { object.disconnectByInstance(this); object.unref(); } - ,_signalInit: function() { + _signalInit() { if (!this._thisArg) this._thisArg = { signals: {}, links: {} }; } -}); \ No newline at end of file +} diff --git a/js/vn/scope.js b/js/vn/scope.js index bf92ab14..57b9771b 100644 --- a/js/vn/scope.js +++ b/js/vn/scope.js @@ -53,6 +53,6 @@ module.exports = new Class({ if (objects[i] instanceof VnObject) objects[i].unref(); - this.parent(); + VnObject.prototype._destroy.call(this); } });