From 60a1d7cf9e46c7b6e7b809f42da5a23a7b44f894 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 20 Oct 2017 19:09:06 +0200 Subject: [PATCH] interpolate v1, camelCase htmlId --- forms/account/address-list/address-list.js | 10 +-- forms/account/address-list/ui.xml | 7 +- forms/account/address/address.js | 8 +-- forms/account/conf/conf.js | 38 +++++----- forms/admin/connections/connections.js | 10 +-- forms/admin/links/links.js | 5 -- forms/admin/links/ui.xml | 8 +-- forms/admin/photos/photos.js | 20 +++--- forms/admin/queries/queries.js | 14 ++-- forms/admin/users/ui.xml | 12 ++-- forms/admin/users/users.js | 12 +--- forms/admin/visits/visits.js | 16 ++--- forms/cms/contact/contact.js | 10 +-- forms/cms/home/ui.xml | 8 +-- forms/cms/location/location.js | 2 +- forms/ecomerce/basket/basket.js | 4 +- forms/ecomerce/catalog/catalog.js | 84 +++++++++------------- forms/ecomerce/catalog/ui.xml | 18 ++--- forms/ecomerce/checkout/checkout.js | 42 +++++------ forms/ecomerce/confirm/confirm.js | 48 ++++++------- forms/ecomerce/orders/orders.js | 10 +-- forms/ecomerce/orders/ui.xml | 12 +--- forms/ecomerce/ticket/ticket.js | 4 +- forms/ecomerce/ticket/ui.xml | 6 +- forms/news/new/new.js | 12 ++-- forms/news/news/news.js | 10 +-- forms/news/news/ui.xml | 4 +- forms/reports/items-form/items-form.js | 4 +- forms/reports/shelves/shelves.js | 6 +- js/hedera/form.js | 11 +-- js/hedera/gui.js | 52 +++++++------- js/hedera/login.js | 30 ++++---- js/hedera/report.js | 2 +- js/htk/image-editor.js | 20 +++--- js/htk/repeater.js | 4 +- js/vn/builder.js | 16 ++--- js/vn/compiler-element.js | 4 +- js/vn/compiler-object.js | 6 +- js/vn/compiler-text.js | 4 +- js/vn/component.js | 24 ++----- js/vn/scope.js | 79 ++++++++++---------- 41 files changed, 326 insertions(+), 370 deletions(-) diff --git a/forms/account/address-list/address-list.js b/forms/account/address-list/address-list.js index 2a9f7f49..8fc092be 100644 --- a/forms/account/address-list/address-list.js +++ b/forms/account/address-list/address-list.js @@ -5,8 +5,8 @@ Hedera.AddressList = new Class ,activate: function () { - this.$('user-model').setInfo ('c', 'customer_view', 'hedera'); - this.$('addresses').setInfo ('a', 'address_view', 'hedera'); + this.$.userModel.setInfo ('c', 'customer_view', 'hedera'); + this.$.addresses.setInfo ('a', 'address_view', 'hedera'); } ,onAddAddressClick: function () @@ -33,9 +33,9 @@ Hedera.AddressList = new Class ,repeaterFunc: function (res, form) { - res.$('link').href = this.hash.make ({ - 'form': 'account/address', - 'address': form.get ('id') + res.$.link.href = this.hash.make ({ + form: 'account/address', + address: form.$.id }); } }); diff --git a/forms/account/address-list/ui.xml b/forms/account/address-list/ui.xml index 9e0c2955..9d824cbc 100755 --- a/forms/account/address-list/ui.xml +++ b/forms/account/address-list/ui.xml @@ -47,14 +47,13 @@ on-click="onRemoveAddressClick"/>

- + {{consignee}}

- + {{name}}

- , - + {{zip_code}}, {{city}}

diff --git a/forms/account/address/address.js b/forms/account/address/address.js index 809e8d2d..4c295c0b 100644 --- a/forms/account/address/address.js +++ b/forms/account/address/address.js @@ -5,14 +5,14 @@ Hedera.Address = new Class ,activate: function () { - this.$('model').setInfo ('a', 'address_view', 'hedera', ['id'], 'id'); - this.$('model').setDefault ('customer_id', 'a', + this.$.model.setInfo ('a', 'address_view', 'hedera', ['id'], 'id'); + this.$.model.setDefault ('customer_id', 'a', new Sql.Function ({schema: 'account', name: 'userGetId'})); } ,onStatusChange: function (form) { - if (form.ready && this.$('params').$.address == 0) + if (form.ready && this.$.params.$.address == 0) form.insertRow (); } @@ -24,7 +24,7 @@ Hedera.Address = new Class ,onAcceptClick: function () { - this.$('iter').performOperations (); + this.$.iter.performOperations (); } ,onReturnClick: function () diff --git a/forms/account/conf/conf.js b/forms/account/conf/conf.js index 49a0aeb9..3a331c14 100644 --- a/forms/account/conf/conf.js +++ b/forms/account/conf/conf.js @@ -5,31 +5,31 @@ Hedera.Conf = new Class ,activate: function () { - this.$('user-model').setInfo ('c', 'customer_view', 'hedera'); + this.$.userModel.setInfo ('c', 'customer_view', 'hedera'); } ,onPassChangeClick: function () { - this.$('old-password').value = ''; - this.$('new-password').value = ''; - this.$('repeat-password').value = ''; + this.$.oldPassword.value = ''; + this.$.newPassword.value = ''; + this.$.repeatPassword.value = ''; - var recoverPass = this.$('user').get ('recoverPass'); - this.$('old-password').style.display = recoverPass ? 'none' : 'block'; - this.$('change-password').show (); + var recoverPass = this.$.user.get ('recoverPass'); + this.$.oldPassword.style.display = recoverPass ? 'none' : 'block'; + this.$.changePassword.show (); if (recoverPass) - this.$('new-password').focus (); + this.$.newPassword.focus (); else - this.$('old-password').focus (); + this.$.oldPassword.focus (); } ,onPassModifyClick: function () { try { - var oldPassword = this.$('old-password').value; - var newPassword = this.$('new-password').value; - var repeatedPassword = this.$('repeat-password').value; + var oldPassword = this.$.oldPassword.value; + var newPassword = this.$.newPassword.value; + var repeatedPassword = this.$.repeatPassword.value; if (newPassword == '' && repeatedPassword == '') throw new Error (_('Passwords empty')); @@ -37,8 +37,8 @@ Hedera.Conf = new Class throw new Error (_('Passwords doesn\'t match')); var params = { - 'oldPassword': oldPassword, - 'newPassword': newPassword + oldPassword: oldPassword, + newPassword: newPassword }; this.conn.send ('core/change-password', params, this._onPassChange.bind (this)); @@ -53,25 +53,25 @@ Hedera.Conf = new Class { if (json) { - this.$('change-password').hide (); + this.$.changePassword.hide (); Htk.Toast.showMessage (_('Password changed!')); - this.$('user').refresh (); + this.$.user.refresh (); } else { Htk.Toast.showError (error.message); - this.$('old-password').select (); + this.$.oldPassword.select (); } } ,onPassInfoClick: function () { - this.$('password-info').show (); + this.$.passwordInfo.show (); } ,onAddressesClick: function () { - this.hash.setAll ({'form': 'account/address-list'}); + this.hash.setAll ({form: 'account/address-list'}); } }); diff --git a/forms/admin/connections/connections.js b/forms/admin/connections/connections.js index 30dfb3e3..92e41dab 100644 --- a/forms/admin/connections/connections.js +++ b/forms/admin/connections/connections.js @@ -23,14 +23,14 @@ Hedera.Connections = new Class ,onRefreshClick: function () { - this.$('sessions').refresh (); + this.$.sessions.refresh (); } ,repeaterFunc: function (res, form) { - res.$('link').href = this.hash.make ({ - 'form': 'admin/access-log', - 'user': form.get ('userId') + res.$.link.href = this.hash.make ({ + form: 'admin/access-log', + user: form.$.userId }); } @@ -42,7 +42,7 @@ Hedera.Connections = new Class ,_onUserSupplant: function () { - this.hash.setAll ({'form': 'ecomerce/orders'}); + this.hash.setAll ({form: 'ecomerce/orders'}); } ,sessionsFunc: function () diff --git a/forms/admin/links/links.js b/forms/admin/links/links.js index f19f14a1..8f8932c0 100644 --- a/forms/admin/links/links.js +++ b/forms/admin/links/links.js @@ -2,10 +2,5 @@ Hedera.Links = new Class ({ Extends: Hedera.Form - - ,repeaterFunc: function (res, form) - { - res.$('link').href = form.get ('link'); - } }); diff --git a/forms/admin/links/ui.xml b/forms/admin/links/ui.xml index a0bb3ed4..6d97810f 100755 --- a/forms/admin/links/ui.xml +++ b/forms/admin/links/ui.xml @@ -4,23 +4,23 @@
- + SELECT image, name, description, link FROM link ORDER BY name - +

- + {{name}}

- + {{description}}

diff --git a/forms/admin/photos/photos.js b/forms/admin/photos/photos.js index bbe23baa..3504c7eb 100644 --- a/forms/admin/photos/photos.js +++ b/forms/admin/photos/photos.js @@ -18,7 +18,7 @@ Hedera.Photos = new Class ,activate: function () { - this.$('schema').value = 'catalog'; + this.$.schema.value = 'catalog'; } ,addFiles: function (files) @@ -70,7 +70,7 @@ Hedera.Photos = new Class this.filesData.push (fileData); button.value = fileData; - this.$('file-list').appendChild (div); + this.$.fileList.appendChild (div); } ,onUploadClick: function () @@ -112,7 +112,7 @@ Hedera.Photos = new Class var formData = new FormData(); formData.append ('image', fileData.file); formData.append ('name', fileData.name.value); - formData.append ('schema', this.$('schema').value); + formData.append ('schema', this.$.schema.value); formData.append ('srv', 'json:image/upload'); this.conn.sendFormData (formData, this.onFileUpload.bind (this, fileData)); @@ -163,7 +163,7 @@ Hedera.Photos = new Class ,onFileRemove: function (button) { var fileData = button.value; - this.$('file-list').removeChild (fileData.div); + this.$.fileList.removeChild (fileData.div); for (var i = 0; i < this.filesData.length; i++) if (this.filesData[i] === fileData) @@ -176,27 +176,27 @@ Hedera.Photos = new Class ,onClearClick: function () { this.filesData = []; - Vn.Node.removeChilds (this.$('file-list')); + Vn.Node.removeChilds (this.$.file-list); } ,onDropzoneClick: function () { - this.$('file').click (); + this.$.file.click (); } ,onFileChange: function () { - this.addFiles (this.$('file').files); + this.addFiles (this.$.file.files); } ,onDragEnter: function () { - Vn.Node.addClass (this.$('dropzone'), 'dragover'); + Vn.Node.addClass (this.$.dropzone, 'dragover'); } ,onDragLeave: function () { - Vn.Node.removeClass (this.$('dropzone'), 'dragover'); + Vn.Node.removeClass (this.$.dropzone, 'dragover'); } ,onDragOver: function (event) @@ -206,7 +206,7 @@ Hedera.Photos = new Class ,onDragEnd: function (event) { - Vn.Node.removeClass (this.$('dropzone'), 'dragover'); + Vn.Node.removeClass (this.$.dropzone, 'dragover'); event.dataTransfer.clearData (); } diff --git a/forms/admin/queries/queries.js b/forms/admin/queries/queries.js index cc2bb678..a8c6771f 100644 --- a/forms/admin/queries/queries.js +++ b/forms/admin/queries/queries.js @@ -5,14 +5,14 @@ Hedera.Queries = new Class ,activate: function () { - this.$('result-index').value = 0; + this.$.resultIndex.value = 0; } ,clean: function () { if (this._grid) { - this.$('grid-holder').removeChild (this._grid.node); + this.$.gridHolder.removeChild (this._grid.node); this._grid.unref (); this._grid = null; } @@ -24,9 +24,9 @@ Hedera.Queries = new Class var model = new Db.Model ({ conn: this.conn, - query: this.$('sql').value, - resultIndex: this.$('result-index').value, - updatable: this.$('updatable').value + query: this.$.sql.value, + resultIndex: this.$.resultIndex.value, + updatable: this.$.updatable.value }); model.on ('status-changed', this._onModelChange, this); } @@ -49,7 +49,7 @@ Hedera.Queries = new Class Htk.Toast.showMessage (_('Query executed!')); - var gridHolder = this.$('grid-holder'); + var gridHolder = this.$.gridHolder; if (gridHolder.firstChild) gridHolder.removeChilds (gridHolder.firstChild); @@ -86,7 +86,7 @@ Hedera.Queries = new Class column.setProperties ({ title: c.name, - editable: this.$('updatable').value, + editable: this.$.updatable.value, columnIndex: i }); diff --git a/forms/admin/users/ui.xml b/forms/admin/users/ui.xml index bec423d8..ae4eafd8 100755 --- a/forms/admin/users/ui.xml +++ b/forms/admin/users/ui.xml @@ -7,7 +7,7 @@
- + SELECT u.id, u.name, c.Cliente FROM account.user u @@ -18,7 +18,10 @@ ORDER BY u.name LIMIT 200 - +

- + {{Cliente}}

- - - + {{id}} - {{name}}

diff --git a/forms/admin/users/users.js b/forms/admin/users/users.js index 2edbfdc7..acb8f491 100644 --- a/forms/admin/users/users.js +++ b/forms/admin/users/users.js @@ -2,24 +2,16 @@ Hedera.Users = new Class ({ Extends: Hedera.Form - - ,repeaterFunc: function (res, form) - { - res.$('link').href = this.hash.make ({ - 'form': 'admin/access-log', - 'user': form.get ('id') - }); - } ,onChangeUserClick: function (button, form) { - this.gui.supplantUser (form.get ('name'), + this.gui.supplantUser (form.$.name, this.onUserSupplant.bind (this)); } ,onUserSupplant: function () { - this.hash.setAll ({'form': 'ecomerce/orders'}); + this.hash.setAll ({form: 'ecomerce/orders'}); } }); diff --git a/forms/admin/visits/visits.js b/forms/admin/visits/visits.js index 31898066..af66d33b 100644 --- a/forms/admin/visits/visits.js +++ b/forms/admin/visits/visits.js @@ -5,23 +5,21 @@ Hedera.Visits = new Class ,activate: function () { - var hash = this.hash; - - if (!hash.get ('to')) - { - hash.set ('from', new Date ()); - hash.set ('to', new Date ()); - } + if (!this.hash.$.to) + this.hash.assign ({ + from: new Date (), + to: new Date () + }); } ,onRefreshClick: function () { - this.$('visits').refresh (); + this.$.visits.refresh (); } ,onSessionsClick: function () { - this.hash.setAll ({'form': 'admin/connections'}); + this.hash.setAll ({form: 'admin/connections'}); } }); diff --git a/forms/cms/contact/contact.js b/forms/cms/contact/contact.js index 509863ae..df57f3ad 100644 --- a/forms/cms/contact/contact.js +++ b/forms/cms/contact/contact.js @@ -6,7 +6,7 @@ Hedera.Contact = new Class ,activate: function () { var self = this; - this.$('contact-form').onsubmit = function () + this.$.contactForm.onsubmit = function () { self._onSubmit (); return false; }; this.refreshCaptcha (); @@ -18,18 +18,18 @@ Hedera.Contact = new Class 'srv': 'rest:core/captcha', 'stamp': new Date ().getTime () }; - this.$('captcha-img').src = '?'+ Vn.Url.makeUri (params); + this.$.captchaImg.src = '?'+ Vn.Url.makeUri (params); } ,_onSubmit: function () { - this.conn.sendForm (this.$('contact-form'), + this.conn.sendForm (this.$.contactForm, this._onResponse.bind (this)); } - ,_onResponse: function (json, error) + ,_onResponse: function (json) { - var form = this.$('contact-form'); + var form = this.$.contactForm; if (json) { diff --git a/forms/cms/home/ui.xml b/forms/cms/home/ui.xml index 7e6e7365..79daa16f 100755 --- a/forms/cms/home/ui.xml +++ b/forms/cms/home/ui.xml @@ -11,7 +11,7 @@
- + SELECT title, date_time, text, image, id FROM news WHERE tag != 'course' @@ -21,20 +21,20 @@
-

+

{{title}}

- +
diff --git a/forms/cms/location/location.js b/forms/cms/location/location.js index 0d06c2fb..5d0e7b3c 100644 --- a/forms/cms/location/location.js +++ b/forms/cms/location/location.js @@ -48,7 +48,7 @@ Hedera.Location = new Class ,center: new google.maps.LatLng (46.0, 4.0) }; - var div = this.$('form'); + var div = this.$.form; var gmap = new google.maps.Map (div, options); var row; diff --git a/forms/ecomerce/basket/basket.js b/forms/ecomerce/basket/basket.js index f8e331f0..7ae1bf06 100644 --- a/forms/ecomerce/basket/basket.js +++ b/forms/ecomerce/basket/basket.js @@ -20,7 +20,7 @@ Hedera.Basket = new Class ,activate: function () { - this.$('items').setInfo ('i', 'basket_item', 'hedera'); + this.$.items.setInfo ('i', 'basket_item', 'hedera'); } ,onConfigureClick: function () @@ -41,7 +41,7 @@ Hedera.Basket = new Class ,repeaterFunc: function (res, form) { - res.$('subtotal').value = this.subtotal (form); + res.$.subtotal.value = this.subtotal (form); } ,onDeleteClick: function (button, form) diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index 4f40e225..3823e653 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -36,8 +36,8 @@ Hedera.Catalog = new Class ,activate: function () { - this.$('items').setInfo ('a', 'Articles', 'vn2008', ['item_id']); - document.body.appendChild (this.$('right-panel')); + this.$.items.setInfo ('a', 'Articles', 'vn2008', ['item_id']); + document.body.appendChild (this.$.rightPanel); if (localStorage.getItem ('hederaView')) this.setView (parseInt (localStorage.getItem ('hederaView'))); @@ -52,15 +52,15 @@ Hedera.Catalog = new Class ,deactivate: function () { this.hideMenu (); - this.gui.$('top-bar').style.backgroundColor = ''; - Vn.Node.remove (this.$('right-panel')); + this.gui.$.topBar.style.backgroundColor = ''; + Vn.Node.remove (this.$.rightPanel); } ,setView: function (view) { if (view === View.GRID) { - this.$('view-button').setProperties ({ + this.$.viewButton.setProperties ({ icon: 'view-list', tip: _('List view') }); @@ -69,7 +69,7 @@ Hedera.Catalog = new Class } else { - this.$('view-button').setProperties ({ + this.$.viewButton.setProperties ({ icon: 'view-grid', tip: _('Grid view') }); @@ -77,7 +77,7 @@ Hedera.Catalog = new Class var className = 'list-view'; } - var node = this.$('grid-view').node; + var node = this.$.gridView.node; node.className = className; localStorage.setItem ('hederaView', this.view); } @@ -91,9 +91,9 @@ Hedera.Catalog = new Class ,onBasketReady: function (form) { if (form.get ('method') != 'PICKUP') - Vn.Node.setText (this.$('method'), _('Agency')); + Vn.Node.setText (this.$.method, _('Agency')); else - Vn.Node.setText (this.$('method'), _('Warehouse')); + Vn.Node.setText (this.$.method, _('Warehouse')); } ,onOrderChange: function (e) @@ -104,7 +104,7 @@ Hedera.Catalog = new Class Db.Model.SortWay.ASC : Db.Model.SortWay.DESC; if (sortField) - this.$('items').sortByName (sortField, sortWay); + this.$.items.sortByName (sortField, sortWay); this.hideMenu (); } @@ -123,47 +123,33 @@ Hedera.Catalog = new Class if (shouldRefresh) { - var filterSql = this.$('filter').render (params); + var filterSql = this.$.filter.render (params); var modelParams = { filter: new Sql.String ({query: filterSql}) }; - this.$('items').refresh (modelParams); + this.$.items.refresh (modelParams); this.hideMenu (); - this.$('order').style.display = 'block'; + this.$.order.style.display = 'block'; } else { - this.$('items').clean (); - this.$('order').style.display = 'none'; + this.$.items.clean (); + this.$.order.style.display = 'none'; } } - ,realmRenderer: function (builder, form) - { - var link = builder.$('link'); - link.href = this.hash.make ({ - form: this.hash.$.form, - realm: form.$.id - }); - - var img = builder.$('image'); - img.src = 'image/family/light/'+ form.$.id +'.svg'; - img.title = form.$.name; - img.alt = img.title; - } - ,onRealmChange: function () { var newValue = this.params.$.realm; - this.$('filters').style.display = newValue ? 'block' : 'none'; - this.$('realm-msg').style.display = newValue ? 'none' : 'block'; + this.$.filters.style.display = newValue ? 'block' : 'none'; + this.$.realmMsg.style.display = newValue ? 'none' : 'block'; this.refreshTitleColor (); } ,refreshTitleColor: function () { - var realms = this.$('realms'); + var realms = this.$.realms; var realm = this.params.$.realm; var color = null; @@ -175,12 +161,12 @@ Hedera.Catalog = new Class color = '#'+ realms.get (row, 'color'); } - this.gui.$('top-bar').style.backgroundColor = color; + this.gui.$.topBar.style.backgroundColor = color; } ,refreshTitle: function () { - var types = this.$('types'); + var types = this.$.types; var type = this.params.$.type; var title = _('Catalog'); @@ -192,7 +178,7 @@ Hedera.Catalog = new Class title = types.get (row, 'name'); } - Vn.Node.setText (this.$('title'), title); + Vn.Node.setText (this.$.title, title); } ,onRightPanelClick: function (event) @@ -205,7 +191,7 @@ Hedera.Catalog = new Class this._menuShown = true; event.stopPropagation (); this.gui.showBackground (); - Vn.Node.addClass (this.$('right-panel'), 'show'); + Vn.Node.addClass (this.$.rightPanel, 'show'); this.hideMenuCallback = this.hideMenu.bind (this); document.addEventListener ('click', this.hideMenuCallback); } @@ -216,7 +202,7 @@ Hedera.Catalog = new Class return; this.gui.hideBackground (); - Vn.Node.removeClass (this.$('right-panel'), 'show'); + Vn.Node.removeClass (this.$.rightPanel, 'show'); document.removeEventListener ('click', this.hideMenuCallback); this.hideMenuCallback = null; } @@ -254,14 +240,14 @@ Hedera.Catalog = new Class return; this.onEraseClick (); - this.$('card').row = form.row; - this.$('card-lot').assign ({item: form.$.item_id}); - this.$('card-popup').show (button.node); + this.$.card.row = form.row; + this.$.cardLot.assign ({item: form.$.item_id}); + this.$.cardPopup.show (button.node); } ,onAddLotClick: function (column, value, rowIndex) { - var row = this.$('item-lots').getObject (rowIndex); + var row = this.$.itemLots.getObject (rowIndex); var lotAmount = this.items[row.warehouse]; if (lotAmount === undefined) @@ -275,7 +261,7 @@ Hedera.Catalog = new Class newAmount = row.available; this.items[row.warehouse] = newAmount; - this.$('amount').value += newAmount - lotAmount; + this.$.amount.value += newAmount - lotAmount; } else Htk.Toast.showError (_('NoMoreAmountAvailable')); @@ -293,7 +279,7 @@ Hedera.Catalog = new Class amountSum += amount; var params = { - item: this.$('card-item').value, + item: this.$.cardItem.value, warehouse: warehouse, amount: amount }; @@ -304,30 +290,30 @@ Hedera.Catalog = new Class { this.conn.execQuery (sql); - var itemName = this.$('card').$.Article; + var itemName = this.$.card.$.Article; Htk.Toast.showMessage ( sprintf (_('Added%dOf%s'), amountSum, itemName)); } - this.$('card-popup').hide (); + this.$.cardPopup.hide (); } ,onEraseClick: function () { - this.$('amount').value = 0; + this.$.amount.value = 0; this.items = {}; } ,onPopupClose: function () { this.onEraseClick (); - this.$('card').row = -1; - this.$('card-item').value = undefined; + this.$.card.row = -1; + this.$.cardItem.value = undefined; } ,onStatusChange: function () { - this.$('card-popup').reset (); + this.$.cardPopup.reset (); } }); diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index fdc52e68..ebdf0cdf 100755 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -143,17 +143,15 @@ icon="add" on-click="onAddItemClick" class="add-button"/> -

- -

+

{{Article}}

- + {{producer}}

- + @{{item_id}}

- _Size , + _Size _Category

@@ -191,7 +189,6 @@

- - + + {{name}} diff --git a/forms/ecomerce/checkout/checkout.js b/forms/ecomerce/checkout/checkout.js index 9fdcdb1b..defd2fe2 100644 --- a/forms/ecomerce/checkout/checkout.js +++ b/forms/ecomerce/checkout/checkout.js @@ -17,8 +17,8 @@ Hedera.Checkout = new Class ,onValuesReady: function () { - var orderForm = this.$('order-form'); - var defaultsForm = this.$('defaults'); + var orderForm = this.$.orderForm; + var defaultsForm = this.$.defaults; if (!(orderForm.ready && defaultsForm.ready)) return; @@ -43,7 +43,7 @@ Hedera.Checkout = new Class date.setHours (0, 0, 0, 0); } - this.$('lot').assign ({ + this.$.lot.assign ({ date: date, method: i.get ('delivery_method'), agency: i.get ('agency_id'), @@ -54,9 +54,9 @@ Hedera.Checkout = new Class ,disableButtons: function (disable) { - this.$('confirm-agency').disabled = disable; - this.$('confirm-delivery').disabled = disable; - this.$('confirm-pickup').disabled = disable; + this.$.confirmAgency.disabled = disable; + this.$.confirmDelivery.disabled = disable; + this.$.confirmPickup.disabled = disable; } ,onConfirmClick: function () @@ -65,7 +65,7 @@ Hedera.Checkout = new Class var query = 'CALL basketConfigure (#date, #method, #agency, #address)'; this.conn.execQuery (query, - this.onBasketConfigured.bind (this), this.$('lot').params); + this.onBasketConfigured.bind (this), this.$.lot.params); } ,onBasketConfigured: function (resultSet) @@ -75,7 +75,7 @@ Hedera.Checkout = new Class if (!resultSet.fetchResult ()) return; - if (this.$('order-form').numRows > 0) + if (this.$.orderForm.numRows > 0) Htk.Toast.showMessage (_('OrderUpdated')); else Htk.Toast.showMessage (_('OrderStarted')); @@ -85,7 +85,7 @@ Hedera.Checkout = new Class ,onCancelClick: function () { - if (this.$('order-form').numRows > 0) + if (this.$.orderForm.numRows > 0) window.history.back(); else this.hash.setAll ({'form': 'ecomerce/orders'}); @@ -100,7 +100,7 @@ Hedera.Checkout = new Class var steps; var isDelivery; - switch (this.$('rg-method').value) + switch (this.$.rgMethod.value) { case 'AGENCY': steps = this.agencySteps; @@ -125,18 +125,18 @@ Hedera.Checkout = new Class switch (stepId) { case 'date': - Vn.Node.setText (this.$('date-question'), isDelivery ? + Vn.Node.setText (this.$.dateQuestion, isDelivery ? _('OrderDateDeliveryQuestion'): _('OrderDatePickupQuestion')); - this.$('calendar').goToSelectedMonth (); + this.$.calendar.goToSelectedMonth (); break; case 'agency': case 'pickup': - this.$('agencies').refresh (); + this.$.agencies.refresh (); break; } - return this.$(stepId +'-step'); + return this.$[stepId +'Step']; } ,onFieldChange: function () @@ -147,18 +147,18 @@ Hedera.Checkout = new Class ,goNextStep: function () { - this.$('assistant').moveNext (); + this.$.assistant.moveNext (); } ,addressRenderer: function (builder, form) { - builder.$('address').addEventListener ('click', + builder.$.address.addEventListener ('click', this.onAddressClick.bind (this, form.get ('id'))); } ,onAddressClick: function (addressId) { - this.$('lot').set ('address', addressId); + this.$.lot.set ('address', addressId); this.goNextStep (); } @@ -167,17 +167,17 @@ Hedera.Checkout = new Class if (this.selectedNode) Vn.Node.removeClass (this.selectedNode, 'selected'); - var row = this.$('addresses').search ('id', this.$('lot').get ('address')); + var row = this.$.addresses.search ('id', this.$.lot.get ('address')); if (row != -1) { - var builder = this.$('repeater').getScope (row); + var builder = this.$.repeater.getScope (row); - this.selectedNode = builder.$('address'); + this.selectedNode = builder.$.address; Vn.Node.addClass (this.selectedNode, 'selected'); } - this.$('address-form').row = row; + this.$.addressForm.row = row; } ,onAgenciesReady: function (model) diff --git a/forms/ecomerce/confirm/confirm.js b/forms/ecomerce/confirm/confirm.js index 97c9c1c4..8e168fdc 100644 --- a/forms/ecomerce/confirm/confirm.js +++ b/forms/ecomerce/confirm/confirm.js @@ -27,13 +27,13 @@ Hedera.Confirm = new Class if (order.method != 'PICKUP') { - Vn.Node.show (this.$('address')); - Vn.Node.setText (this.$('method'), _('Agency')); + Vn.Node.show (this.$.address); + Vn.Node.setText (this.$.method, _('Agency')); } else { - Vn.Node.hide (this.$('address')); - Vn.Node.setText (this.$('method'), _('Warehouse')); + Vn.Node.hide (this.$.address); + Vn.Node.setText (this.$.method, _('Warehouse')); } var total = order.taxBase + order.vat; @@ -57,12 +57,12 @@ Hedera.Confirm = new Class if (order.credit > 0) { - this.$('credit-info').style.display = 'table-row'; + this.$.creditInfo.style.display = 'table-row'; if (creditExceededCond) { - this.$('amount-selector').style.display = 'block'; - this.$('exceeded-info').style.display = 'table-row'; + this.$.amountSelector.style.display = 'block'; + this.$.exceededInfo.style.display = 'table-row'; lot.payAmount = 'EXCEEDED'; } } @@ -88,9 +88,9 @@ Hedera.Confirm = new Class } for (var i = 0; i < methods.length; i++) - this.$(methods[i] +'-method').style.display = 'block'; + this.$[methods[i] +'Method'].style.display = 'block'; - this.$('lot').assign (lot); + this.$.lot.assign (lot); } ,onPayMethodChange: function (payMethod) @@ -98,21 +98,21 @@ Hedera.Confirm = new Class var id = this.displayedInfo; if (id) - Vn.Node.removeClass (this.$(id), 'selected'); + Vn.Node.removeClass (this.$[id], 'selected'); switch (payMethod.value) { case 'BALANCE': - id = 'balance-method'; + id = 'balanceMethod'; break; case 'CREDIT': - id = 'credit-method'; + id = 'creditMethod'; break; case 'CARD': - id = 'card-method'; + id = 'cardMethod'; break; case 'TRANSFER': - id = 'transfer-method'; + id = 'transferMethod'; break; default: id = null; @@ -121,13 +121,13 @@ Hedera.Confirm = new Class this.displayedInfo = id; if (id) - Vn.Node.addClass (this.$(id), 'selected'); + Vn.Node.addClass (this.$[id], 'selected'); } ,disableButtons: function (disable) { - this.$('modify').disabled = disable; - this.$('confirm').disabled = disable; + this.$.modify.disabled = disable; + this.$.confirm.disabled = disable; } ,onModifyClick: function () @@ -137,9 +137,9 @@ Hedera.Confirm = new Class ,onConfirmClick: function () { - console.log (this.$('lot').params); + console.log (this.$.lot.params); this.disableButtons (true); - this.$('confirm-query').execute (); + this.$.confirmQuery.execute (); } ,onConfirm: function (query, resultSet) @@ -147,16 +147,16 @@ Hedera.Confirm = new Class this.disableButtons (false); if (resultSet.fetchResult ()) - this.$('success-dialog').show (); + this.$.successDialog.show (); } ,onDialogResponse: function () { - var lot = this.$('lot').params; + var lot = this.$.lot.params; - if (this.$('pay-method').value === 'CARD') + if (this.$.payMethod.value === 'CARD') { - if (this.$('pay-amount').value === 'EXCEEDED') + if (this.$.payAmount.value === 'EXCEEDED') var payAmount = lot.exceededCredit; else var payAmount = lot.totalDebt; @@ -165,7 +165,7 @@ Hedera.Confirm = new Class conn: this.conn, hash: this.hash }); - tpv.pay (payAmount, this.$('order').get ('company')); + tpv.pay (payAmount, this.$.order.get ('company')); } else this.hash.params = {form: 'ecomerce/orders'}; diff --git a/forms/ecomerce/orders/orders.js b/forms/ecomerce/orders/orders.js index 6ebb8db2..2e11ab4e 100644 --- a/forms/ecomerce/orders/orders.js +++ b/forms/ecomerce/orders/orders.js @@ -25,7 +25,7 @@ Hedera.Orders = new Class ,_onTpvCheck: function (tpv, tpvOrder, tpvStatus) { if (tpvStatus === 'ko') - this.$('error-dialog').show (); + this.$.errorDialog.show (); } ,onBasketClick: function () @@ -35,7 +35,7 @@ Hedera.Orders = new Class ,repeaterFunc: function (res, form) { - res.$('link').href = this.hash.make ({ + res.$.link.href = this.hash.make ({ form: 'ecomerce/ticket', ticket: form.get ('ticket_id') }); @@ -46,14 +46,14 @@ Hedera.Orders = new Class ,balanceConditionalFunc: function (field, value) { if (value >= 0) - Vn.Node.removeClass (this.$('balance'), 'negative'); + Vn.Node.removeClass (this.$.balance, 'negative'); else - Vn.Node.addClass (this.$('balance'), 'negative'); + Vn.Node.addClass (this.$.balance, 'negative'); } ,onPayButtonClick: function () { - var amount = -this.$('debt').get('debt'); + var amount = -this.$.debt.$.debt; amount = amount <= 0 ? null : amount; diff --git a/forms/ecomerce/orders/ui.xml b/forms/ecomerce/orders/ui.xml index ece1420c..b7b282f7 100755 --- a/forms/ecomerce/orders/ui.xml +++ b/forms/ecomerce/orders/ui.xml @@ -60,15 +60,9 @@

-

- -

-

- -

-

- -

+

@{{ticket_id}}

+

{{consignee}}

+

{{type}}

diff --git a/forms/ecomerce/ticket/ticket.js b/forms/ecomerce/ticket/ticket.js index 1afebd3a..f91cafd5 100644 --- a/forms/ecomerce/ticket/ticket.js +++ b/forms/ecomerce/ticket/ticket.js @@ -24,9 +24,9 @@ Hedera.Ticket = new Class column.value = this.subtotal (form); } - ,repeaterFunc: function (res, form) + ,repeaterFunc: function (scope, form) { - res.$('subtotal').value = this.subtotal (form); + scope.$.subtotal.value = this.subtotal (form); } ,subtotal: function (form) diff --git a/forms/ecomerce/ticket/ui.xml b/forms/ecomerce/ticket/ui.xml index 90475df8..933b9401 100755 --- a/forms/ecomerce/ticket/ui.xml +++ b/forms/ecomerce/ticket/ui.xml @@ -68,12 +68,10 @@ subdir="200x200" full-dir="900x900"/>

- - - + {{concept}} {{Medida}} {{Categoria}}

- x + {{amount}} x diff --git a/forms/news/new/new.js b/forms/news/new/new.js index 54e270a8..e05c387a 100644 --- a/forms/news/new/new.js +++ b/forms/news/new/new.js @@ -10,13 +10,13 @@ Hedera.New = new Class ,activate: function () { - this.$('model').mode = Db.Model.Mode.ON_DEMAND; - this.$('model').setDefault ('user_id', 'news', + this.$.model.mode = Db.Model.Mode.ON_DEMAND; + this.$.model.setDefault ('user_id', 'news', new Sql.Function ({schema: 'account', name: 'userGetId'})); tinymce.init ({ mode : 'exact' - ,target: this.$('html-editor') + ,target: this.$.htmlEditor ,plugins: [ "advlist autolink lists link image charmap print preview hr" ,"anchor pagebreak searchreplace wordcount visualblocks" @@ -53,7 +53,7 @@ Hedera.New = new Class if (!this.editor) return; - var newHtml = this.$('iter').get ('text'); + var newHtml = this.$.iter.get ('text'); if (!newHtml) newHtml = ''; @@ -80,8 +80,8 @@ Hedera.New = new Class ,onAcceptClick: function () { - this.$('iter').set ('text', this.editor.getContent ()); - this.$('iter').performOperations (); + this.$.iter.set ('text', this.editor.getContent ()); + this.$.iter.performOperations (); } ,onReturnClick: function () diff --git a/forms/news/news/news.js b/forms/news/news/news.js index 9465449f..d2525976 100644 --- a/forms/news/news/news.js +++ b/forms/news/news/news.js @@ -11,17 +11,17 @@ Hedera.News = new Class ,repeaterFunc: function (res, form) { - res.$('link').href = this.hash.make ({ - 'form': 'news/new', - 'new': form.get ('id') + res.$.link.href = this.hash.make ({ + form: 'news/new', + new: form.$.id }); } ,onAddClick: function () { this.hash.setAll ({ - 'form': 'news/new', - 'new': 0 + form: 'news/new', + new: 0 }); } }); diff --git a/forms/news/news/ui.xml b/forms/news/news/ui.xml index 15c1ce12..1178e256 100755 --- a/forms/news/news/ui.xml +++ b/forms/news/news/ui.xml @@ -37,10 +37,10 @@ editable="true" conn="conn"/>

- + {{title}}

- + {{Cliente}}

_Priority diff --git a/forms/reports/items-form/items-form.js b/forms/reports/items-form/items-form.js index 4836fed2..f1d3ac85 100644 --- a/forms/reports/items-form/items-form.js +++ b/forms/reports/items-form/items-form.js @@ -5,7 +5,7 @@ Hedera.ItemsForm = new Class ,activate: function () { - this.$('lot').assign ({ + this.$.lot.assign ({ warehouse: 7, realm: null }); @@ -13,7 +13,7 @@ Hedera.ItemsForm = new Class ,onShowClick: function () { - this.gui.openReport ('items-report', this.$('lot').params); + this.gui.openReport ('items-report', this.$.lot.$); } }); diff --git a/forms/reports/shelves/shelves.js b/forms/reports/shelves/shelves.js index fbda8be9..381fd4ed 100644 --- a/forms/reports/shelves/shelves.js +++ b/forms/reports/shelves/shelves.js @@ -5,7 +5,7 @@ Hedera.Shelves = new Class ,activate: function () { - this.$('lot').assign ({ + this.$.lot.assign ({ date: new Date (), useIds: false }); @@ -13,12 +13,12 @@ Hedera.Shelves = new Class ,onConfigChange: function () { - this.$('lot').assignLot (this.$('config')); + this.$.lot.assignLot (this.$.config); } ,onShowClick: function () { - this.gui.openReport ('shelves-report', this.$('lot').params); + this.gui.openReport ('shelves-report', this.$.lot.$); } }); diff --git a/js/hedera/form.js b/js/hedera/form.js index 373473d8..bb00421d 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -41,11 +41,12 @@ module.exports = new Class conn: this.conn, hash: this.hash }; - var scope = builder.load (this.doc, this, null, extraObjects); + var scope = builder.load (this.doc, this, null, extraObjects, this.hash); this.scope = scope; - this._node = this.$('main'); + this.$ = scope.$; + this._node = this.$.main; - var paramsLot = this.$('params'); + var paramsLot = this.$.params; if (paramsLot) { @@ -68,8 +69,8 @@ module.exports = new Class if (this.node) { this.gui.setForm (this.node); - this.gui.setTitle (scope.$('title')); - this.gui.setActions (scope.$('actions')); + this.gui.setTitle (scope.$.title); + this.gui.setActions (scope.$.actions); this.activate (); } diff --git a/js/hedera/gui.js b/js/hedera/gui.js index de027cbc..a29fce9a 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -57,22 +57,22 @@ module.exports = new Class this.loadTemplateFromString (Tpl); this.loadingCount = 0; - this.$('background').onclick = function () {}; + this.$.background.onclick = function () {}; - this.$('menu-button').addEventListener ('click', function (event) + this.$.menuButton.addEventListener ('click', function (event) { event.stopPropagation (); this.showMenu (); }.bind (this)); - this.$('left-panel').addEventListener ('click', function (event) + this.$.leftPanel.addEventListener ('click', function (event) { event.stopPropagation (); }); this.parent (props); - this.$('social-bar').conn = this._conn; + this.$.socialBar.conn = this._conn; var sql = 'SELECT name FROM customer_user;' +'SELECT default_form, image_dir, image_host FROM config;' @@ -89,7 +89,7 @@ module.exports = new Class this._shown = true; this.doc.body.appendChild (this.node); - Htk.Toast.pushTop (this.$('form-holder')); + Htk.Toast.pushTop (this.$.formHolder); if (Vn.isMobile ()) { @@ -155,7 +155,7 @@ module.exports = new Class // Retrieving the user name var userName = resultSet.fetchValue (); - Vn.Node.setText (this.$('user-name'), userName); + Vn.Node.setText (this.$.userName, userName); // Retrieving configuration parameters @@ -178,11 +178,11 @@ module.exports = new Class var linkField = 'test_domain'; } - Vn.Node.setText (this.$('test-link'), _(linkText)); - this.$('test-link').href = '//'+ row[linkField]; + Vn.Node.setText (this.$.testLink, _(linkText)); + this.$.testLink.href = '//'+ row[linkField]; } else - Vn.Node.hide (this.$('test-link')); + Vn.Node.hide (this.$.testLink); // Loading the default form @@ -214,8 +214,8 @@ module.exports = new Class sectionMap[parent].push (i); } - Vn.Node.removeChilds (this.$('main-menu')); - this.createMenu (res, sectionMap, null, this.$('main-menu')); + Vn.Node.removeChilds (this.$.mainMenu); + this.createMenu (res, sectionMap, null, this.$.mainMenu); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu @@ -301,7 +301,7 @@ module.exports = new Class ,showMenu: function () { this.showBackground (); - Vn.Node.addClass (this.$('left-panel'), 'show'); + Vn.Node.addClass (this.$.leftPanel, 'show'); this._menuShown = true; this.hideMenuCallback = this.hideMenu.bind (this); @@ -314,7 +314,7 @@ module.exports = new Class return; this.hideBackground (); - Vn.Node.removeClass (this.$('left-panel'), 'show'); + Vn.Node.removeClass (this.$.leftPanel, 'show'); this._menuShown = false; this.doc.removeEventListener ('click', this.hideMenuCallback); @@ -335,7 +335,7 @@ module.exports = new Class if (!this._shown) return; - var navbar = this.$('top-bar'); + var navbar = this.$.topBar; var yOffset = window.pageYOffset; var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight; @@ -359,12 +359,12 @@ module.exports = new Class ,showBackground: function () { - Vn.Node.addClass (this.$('background'), 'show'); + Vn.Node.addClass (this.$.background, 'show'); } ,hideBackground: function () { - Vn.Node.removeClass (this.$('background'), 'show'); + Vn.Node.removeClass (this.$.background, 'show'); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner @@ -374,7 +374,7 @@ module.exports = new Class this.loadingCount++; if (this.loadingCount == 1) - this.$('loader').start (); + this.$.loader.start (); } ,loaderPop: function () @@ -385,7 +385,7 @@ module.exports = new Class this.loadingCount--; if (this.loadingCount == 0) - this.$('loader').stop (); + this.$.loader.stop (); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms @@ -447,31 +447,31 @@ module.exports = new Class ,setForm: function (form) { - Vn.Node.removeChilds (this.$('form-holder')); + Vn.Node.removeChilds (this.$.formHolder); if (form) { var div = this.createElement('div'); div.appendChild (form); - this.$('form-holder').appendChild (div); + this.$.formHolder.appendChild (div); setTimeout (this._onSetFormTimeout.bind (this), 10); } } ,_onSetFormTimeout: function () { - Vn.Node.addClass (this.$('form-holder').firstChild, 'slide'); + Vn.Node.addClass (this.$.formHolder.firstChild, 'slide'); } ,setTitle: function (title) { - Vn.Node.setChild (this.$('title'), title); + Vn.Node.setChild (this.$.title, title); } ,setActions: function (actions) { - Vn.Node.setChild (this.$('action-bar'), actions); + Vn.Node.setChild (this.$.actionBar, actions); } ,closeForm: function () @@ -525,13 +525,13 @@ module.exports = new Class ,_onSupplantName: function (resultSet) { var userName = resultSet.fetchValue (); - Vn.Node.setText (this.$('supplanted'), userName); - Vn.Node.show (this.$('supplant')); + Vn.Node.setText (this.$.supplanted, userName); + Vn.Node.show (this.$.supplant); } ,onSupplantExitClick: function () { - Vn.Node.hide (this.$('supplant')); + Vn.Node.hide (this.$.supplant); this._conn.supplantEnd (); this.loadMenu (); this._onFormChange (); diff --git a/js/hedera/login.js b/js/hedera/login.js index eadd1132..ae7c9db4 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -33,10 +33,10 @@ module.exports = new Class this.parent (props); this.loadTemplateFromString (Tpl); - this.$('social-bar').conn = this._conn; + this.$.socialBar.conn = this._conn; var self = this; - this.$('form').onsubmit = function () + this.$.form.onsubmit = function () { self._onSubmit (); return false; @@ -50,7 +50,7 @@ module.exports = new Class var lastUser = localStorage.getItem ('hederaLastUser'); if (lastUser) - this.$('user').value = lastUser; + this.$.user.value = lastUser; this._focusUserInput (); } @@ -63,17 +63,17 @@ module.exports = new Class ,_onConnLoadChange: function (conn, isLoading) { if (isLoading) - this.$('spinner').start (); + this.$.spinner.start (); else - this.$('spinner').stop (); + this.$.spinner.stop (); } ,_onSubmit: function () { this._conn.open ( - this.$('user').value, - this.$('pass').value, - this.$('remember').checked, + this.$.user.value, + this.$.pass.value, + this.$.remember.checked, this._onConnOpen.bind (this) ); this._disableUi (true); @@ -81,12 +81,12 @@ module.exports = new Class ,_onConnOpen: function (conn, success, error) { - this.$('pass').value = ''; + this.$.pass.value = ''; this._disableUi (false); if (success) { - var user = this.$('user').value; + var user = this.$.user.value; if (user) localStorage.setItem ('hederaLastUser', user); @@ -102,21 +102,21 @@ module.exports = new Class ,_focusUserInput: function () { - var userEntry = this.$('user'); + var userEntry = this.$.user; userEntry.focus (); userEntry.select (); } ,_disableUi: function (disabled) { - this.$('user').disabled = disabled; - this.$('pass').disabled = disabled; - this.$('submit').disabled = disabled; + this.$.user.disabled = disabled; + this.$.pass.disabled = disabled; + this.$.submit.disabled = disabled; } ,onPasswordLost: function () { - var user = this.$('user').value; + var user = this.$.user.value; if (!user) Htk.Toast.showError (_('Please write your user name')); diff --git a/js/hedera/report.js b/js/hedera/report.js index f546585a..bf993f02 100644 --- a/js/hedera/report.js +++ b/js/hedera/report.js @@ -53,6 +53,6 @@ module.exports = new Class hash: this.hash }; this.loadScope (builder, null, extraObjects); - this.body.appendChild (this.$('report')); + this.body.appendChild (this.$.report); } }); diff --git a/js/htk/image-editor.js b/js/htk/image-editor.js index c80b15df..b1a2a397 100644 --- a/js/htk/image-editor.js +++ b/js/htk/image-editor.js @@ -25,7 +25,7 @@ module.exports = new Class this.loadTemplateFromString (Tpl); var self = this; - this.$('form').onsubmit = function () + this.$.form.onsubmit = function () { self._onSubmit (); return false; }; this.parent (props); @@ -33,7 +33,7 @@ module.exports = new Class ,onNameChange: function () { - var newValue = this.$('name').value; + var newValue = this.$.name.value; if (!newValue) newValue = null @@ -43,29 +43,29 @@ module.exports = new Class ,_onSubmit: function () { - this.$('submit').disabled = true; - this.$('spinner').start (); + this.$.submit.disabled = true; + this.$.spinner.start (); - this.conn.sendFormMultipart (this.$('form'), + this.conn.sendFormMultipart (this.$.form, this._onResponse.bind (this)); } ,_onResponse: function (json, error) { - this.$('submit').disabled = false; - this.$('spinner').stop (); + this.$.submit.disabled = false; + this.$.spinner.stop (); if (error) throw error; Toast.showMessage (_('ImageAdded')); - this.emit ('file-uploaded', this.$('name').value); + this.emit ('file-uploaded', this.$.name.value); } ,setData: function (image, directory) { - this.$('name').value = image; - this.$('schema').value = directory; + this.$.name.value = image; + this.$.schema.value = directory; } }); diff --git a/js/htk/repeater.js b/js/htk/repeater.js index b4afbf97..284a061b 100644 --- a/js/htk/repeater.js +++ b/js/htk/repeater.js @@ -71,7 +71,7 @@ module.exports = new Class } ,_builder: null - ,_formId: 'form' + ,_formId: 'iter' ,_parentScope: null ,render: function () @@ -119,7 +119,7 @@ module.exports = new Class var extraObjects = {}; extraObjects[this._formId] = set; - var scope = this._builder.load (this.doc, null, this._parentScope, extraObjects); + var scope = this._builder.load (this.doc, null, this._parentScope, extraObjects, set); scope.link (); this._childsData.push ({ diff --git a/js/vn/builder.js b/js/vn/builder.js index d0a70b7c..55d3b46d 100644 --- a/js/vn/builder.js +++ b/js/vn/builder.js @@ -1,6 +1,7 @@ var VnObject = require ('./object'); var Scope = require ('./scope'); +var kebabToCamel = require ('./string-util').kebabToCamel; var CompilerObject = require ('./compiler-object'); var CompilerElement = require ('./compiler-element'); @@ -148,7 +149,7 @@ module.exports = new Class if (nodeId) { - this._contextMap[nodeId] = context.id; + this._contextMap[kebabToCamel (nodeId)] = context.id; context.nodeId = nodeId; } @@ -170,9 +171,10 @@ module.exports = new Class * @param {Document} dstDocument The document used to create the nodes * @param {Object} signalData The object where to bind methods * @param {Scope} parentScope The parent scope or %null for no parent + * @param {Lot} lot The default lot * @return {Scope} The created scope */ - ,load: function (dstDocument, signalData, parentScope, extraObjects) + ,load: function (dstDocument, signalData, parentScope, extraObjects, lot) { if (this._contexts === null) return null; @@ -181,7 +183,7 @@ module.exports = new Class var contexts = this._contexts; var len = contexts.length; var objects = new Array (len); - var scope = new Scope (this, objects, signalData, parentScope, extraObjects) + var scope = new Scope (this, objects, signalData, parentScope, lot) for (var i = 0; i < len; i++) { @@ -189,6 +191,7 @@ module.exports = new Class objects[i] = context.compiler.instantiate (doc, context, scope); } + scope.init (extraObjects); return scope; } @@ -241,12 +244,7 @@ module.exports = new Class { return result.objects[this._mainContext]; } - - ,getById: function (objectId) - { - return this._contextMap[objectId]; - } - + ,getByTagName: function (scope, tagName) { var tags = this._tags[tagName]; diff --git a/js/vn/compiler-element.js b/js/vn/compiler-element.js index 6f396df8..86c0eb60 100644 --- a/js/vn/compiler-element.js +++ b/js/vn/compiler-element.js @@ -65,7 +65,7 @@ module.exports = new Class var props = context.props; for (var prop in props) - object.setAttribute (prop, props[prop]); + object.setAttribute (prop, scope.interpolate (props[prop])); if (context.nodeId) object.setAttribute ('id', scope.getHtmlId (context.nodeId)); @@ -78,7 +78,7 @@ module.exports = new Class var props = context.objectProps; for (var prop in props) { - var objectValue = scope.$(props[prop]); + var objectValue = scope.$[props[prop]]; var htmlId; if (objectValue instanceof Component) diff --git a/js/vn/compiler-object.js b/js/vn/compiler-object.js index 2d0746a4..9544c223 100644 --- a/js/vn/compiler-object.js +++ b/js/vn/compiler-object.js @@ -178,9 +178,9 @@ module.exports = new Class ,addLink: function (context, prop, objectId) { this._links.push ({ - context: context + context: context ,prop: prop - ,objectId: objectId + ,objectId: kebabToCamel (objectId) }); } @@ -204,7 +204,7 @@ module.exports = new Class { var link = links[i]; var object = objects[link.context.id]; - var objectRef = scope.$(link.objectId); + var objectRef = scope.$[link.objectId]; if (objectRef == null) { diff --git a/js/vn/compiler-text.js b/js/vn/compiler-text.js index 566b8bfa..d461df1c 100644 --- a/js/vn/compiler-text.js +++ b/js/vn/compiler-text.js @@ -31,8 +31,8 @@ module.exports = new Class return {text: text}; } - ,instantiate: function (doc, context) + ,instantiate: function (doc, context, scope) { - return doc.createTextNode (context.text); + return doc.createTextNode (scope.interpolate (context.text)); } }); diff --git a/js/vn/component.js b/js/vn/component.js index d7cc0e95..81416b17 100644 --- a/js/vn/component.js +++ b/js/vn/component.js @@ -57,11 +57,12 @@ module.exports = new Class { return this._htmlId; } - } + }, } ,_node: null ,scope: null + ,$: {} ,initialize: function (props) { @@ -127,29 +128,16 @@ module.exports = new Class { var scope = builder.load (this.doc, this, parentScope, extraObjects); this.scope = scope; - this._node = this.$('main'); scope.link (); + this.$ = scope.$; + this._node = this.$.main; return scope; } - - /** - * Gets an object from the scope associated to this component. - * - * @param {String} id The object identifier - * @return {Object} The object, or %null if not found - */ - ,$: function (id) - { - if (this.scope) - return this.scope.$(id); - - return null; - } ,_destroy: function () { - if (this.builder) - this.builder.unref (); + if (this.scope) + this.scope.unref (); this.parent (); } diff --git a/js/vn/scope.js b/js/vn/scope.js index e3dd8dac..45b52c6f 100644 --- a/js/vn/scope.js +++ b/js/vn/scope.js @@ -7,14 +7,14 @@ module.exports = new Class ({ Extends: VnObject - ,initialize: function (builder, objects, signalData, parentScope, extraObjects) + ,initialize: function (builder, objects, signalData, parentScope, lot) { this.builder = builder; this.objects = objects; this.signalData = signalData; this.parentScope = parentScope; this.uid = ++scopeUid; - this.extraObjects = extraObjects; + this.lot = lot; if (!signalData && parentScope) this.signalData = parentScope.signalData; @@ -22,46 +22,23 @@ module.exports = new Class this.parent (); } + ,init: function (extraObjects) + { + var contextMap = this.builder._contextMap; + var objectMap = this.parentScope ? Object.create (this.parentScope.$) : {}; + this.$ = objectMap; + + for (var id in extraObjects) + objectMap[id] = extraObjects[id]; + for (var id in contextMap) + objectMap[id] = this.objects[contextMap[id]]; + } + ,getMain: function () { return this.builder.getMain (this); } - /** - * Fetchs an element by it's identifier. - * - * @param {String} id The node identifier - * @return {Object} The object or %null if it doesn't exists - */ - ,$: function (id) - { - var object; - var index = this.builder.getById (id); - - if (index !== undefined) - object = this.objects[index]; - else - { - object = this.extraObjects[id]; - - if (object === undefined && this.parentScope) - object = this.parentScope.getById (id); - } - - return object ? object : null; - } - - /** - * Fetchs an element by it's identifier. - * - * @param {String} id The node identifier - * @return {Object} The object or %null if it doesn't exists - */ - ,getById: function (id) - { - return this.$(id); - } - /** * Fetchs a set of elements by it's tag name. * @@ -81,6 +58,34 @@ module.exports = new Class this.builder.link (this); } + /** + * Replaces all ocurrences of {{value}} by it's corresponding value in the + * scope lot. + */ + ,interpolate: function (string) + { + var self = this; + + function replaceFunc (token) + { + var key = token.substr (2, token.length - 4); + var value = self.getLotValue (key); + return value ? value : ''; + } + + return string.replace (/{{[\w_]+}}/g, replaceFunc); + } + + ,getLotValue: function (key) + { + var value = this.lot.$[key]; + + if (value === undefined && this.parentScope) + return this.parentScope.getLotValue (key); + + return value; + } + ,getMethod: function (value, binded) { if (this.signalData)