From fc22db73f2c4330671a69fc858f1b17c5c9a9227 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sat, 28 May 2022 03:18:06 +0200 Subject: [PATCH] Vn.Scope: $ is now an object --- forms/account/address-list/address-list.js | 6 +- forms/account/address/address.js | 10 +-- forms/account/conf/conf.js | 34 ++++----- forms/admin/connections/connections.js | 4 +- forms/admin/items/items.js | 2 +- forms/admin/photos/photos.js | 22 +++--- forms/admin/queries/queries.js | 14 ++-- forms/admin/users/users.js | 4 +- forms/admin/visits/visits.js | 6 +- forms/cms/contact/contact.js | 8 +-- forms/cms/location/location.js | 2 +- forms/ecomerce/basket/basket.js | 2 +- forms/ecomerce/catalog/catalog.js | 84 +++++++++++----------- forms/ecomerce/checkout/checkout.js | 76 ++++++++++---------- forms/ecomerce/confirm/confirm.js | 48 ++++++------- forms/ecomerce/orders/orders.js | 10 +-- forms/ecomerce/ticket/ticket.js | 18 ++--- forms/news/new/new.js | 16 ++--- forms/reports/items-form/items-form.js | 10 +-- forms/reports/shelves/shelves.js | 6 +- js/hedera/form.js | 20 ++---- js/hedera/gui.js | 60 ++++++++-------- js/hedera/login.js | 30 ++++---- js/hedera/report.js | 16 +---- js/hedera/responsive.scss | 4 +- js/htk/component.js | 10 +-- js/htk/field/image.js | 1 - js/htk/image-editor.js | 22 +++--- js/sql/batch.js | 3 +- js/vn/builder.js | 4 +- js/vn/scope.js | 23 +++--- pages/production/main.js | 10 +-- reports/delivery-note/delivery-note.js | 8 +-- 33 files changed, 278 insertions(+), 315 deletions(-) diff --git a/forms/account/address-list/address-list.js b/forms/account/address-list/address-list.js index af8cf66d..5a73cee4 100644 --- a/forms/account/address-list/address-list.js +++ b/forms/account/address-list/address-list.js @@ -4,8 +4,8 @@ Hedera.AddressList = new Class Extends: Hedera.Form ,activate: function() { - this.$('user-model').setInfo('c', 'myClient', 'hedera'); - this.$('addresses').setInfo('a', 'myAddress', 'hedera'); + this.$.userModel.setInfo('c', 'myClient', 'hedera'); + this.$.addresses.setInfo('a', 'myAddress', 'hedera'); } ,onAddAddressClick: function() { @@ -21,7 +21,7 @@ Hedera.AddressList = new Class ,onSetDefaultClick: function(event, addressId) { if (event.defaultPrevented) return; - this.$('defaultAddress').value = addressId; + this.$.defaultAddress.value = addressId; Htk.Toast.showMessage(_('DefaultAddressModified')); } diff --git a/forms/account/address/address.js b/forms/account/address/address.js index 163c57aa..2e77b3f0 100644 --- a/forms/account/address/address.js +++ b/forms/account/address/address.js @@ -3,14 +3,14 @@ Hedera.Address = new Class({ Extends: Hedera.Form, activate: function() { - this.$('model').setInfo('a', 'myAddress', 'hedera', ['id'], 'id'); - this.$('model').setDefault('clientFk', 'a', + this.$.model.setInfo('a', 'myAddress', 'hedera', ['id'], 'id'); + this.$.model.setDefault('clientFk', 'a', new Sql.Function({schema: 'account', name: 'myUser_getId'})); }, onStatusChange: function() { - if (this.$('iter').ready && this.$('address').value == 0) - this.$('iter').insertRow(); + if (this.$.iter.ready && this.$.address.value == 0) + this.$.iter.insertRow(); }, onOperationsDone: function() { @@ -19,7 +19,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 5a7c37d1..a1a35b28 100644 --- a/forms/account/conf/conf.js +++ b/forms/account/conf/conf.js @@ -3,33 +3,33 @@ Hedera.Conf = new Class({ Extends: Hedera.Form ,activate: function() { - this.$('user-model').setInfo('c', 'myClient', 'hedera'); - this.$('user-model').setInfo('u', 'myUser', 'account'); + this.$.userModel.setInfo('c', 'myClient', 'hedera'); + this.$.userModel.setInfo('u', 'myUser', 'account'); if (this.hash.get('verificationToken')) this.onPassChangeClick(); } ,onPassChangeClick: function() { - this.$('old-password').value = ''; - this.$('new-password').value = ''; - this.$('repeat-password').value = ''; + this.$.oldPassword.value = ''; + this.$.newPassword.value = ''; + this.$.repeatPassword.value = ''; var verificationToken = this.hash.get('verificationToken'); - this.$('old-password').style.display = verificationToken ? 'none' : 'block'; - this.$('change-password').show(); + this.$.oldPassword.style.display = verificationToken ? 'none' : 'block'; + this.$.changePassword.show(); if (verificationToken) - 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')); @@ -58,22 +58,22 @@ Hedera.Conf = new Class({ ,_onPassChange: function(json, error) { if (!error) { - this.$('change-password').hide(); + this.$.changePassword.hide(); this.hash.unset('verificationToken'); Htk.Toast.showMessage(_('Password changed!')); - this.$('user-form').refresh(); + this.$.userForm.refresh(); } else { Htk.Toast.showError(error.message); if (this.hash.get('verificationToken')) - this.$('new-password').select(); + this.$.newPassword.select(); else - this.$('old-password').select(); + this.$.oldPassword.select(); } } ,onPassInfoClick: function() { - this.$('password-info').show(); + this.$.passwordInfo.show(); } ,onAddressesClick: function() { diff --git a/forms/admin/connections/connections.js b/forms/admin/connections/connections.js index 29b44b14..2bacd32c 100644 --- a/forms/admin/connections/connections.js +++ b/forms/admin/connections/connections.js @@ -5,14 +5,14 @@ Hedera.Connections = new Class({ ,_timeoutId: null ,onModelStatusChange: function() { - if (!this.$('sessions').ready) + if (!this.$.sessions.ready) return; if (this._timeoutId) clearTimeout(this._timeoutId); this._timeoutId = setTimeout( - () => this.$('sessions').refresh(), 60000); + () => this.$.sessions.refresh(), 60000); } ,deactivate: function() { diff --git a/forms/admin/items/items.js b/forms/admin/items/items.js index 63a56c8c..9c835278 100644 --- a/forms/admin/items/items.js +++ b/forms/admin/items/items.js @@ -3,6 +3,6 @@ Hedera.Items = new Class({ Extends: Hedera.Form, activate: function() { - this.$('items').setInfo('i', 'item', 'vn', ['id']); + this.$.items.setInfo('i', 'item', 'vn', ['id']); } }); diff --git a/forms/admin/photos/photos.js b/forms/admin/photos/photos.js index ecffa24a..79b78584 100644 --- a/forms/admin/photos/photos.js +++ b/forms/admin/photos/photos.js @@ -15,7 +15,7 @@ Hedera.Photos = new Class({ ,isUploading: false ,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); - this.$('file-list').appendChild(li); + this.$.fileList.appendChild(li); this.setImageStatus(fileData, Status.NONE, 'add', _('Pending upload')); } @@ -107,10 +107,10 @@ Hedera.Photos = new Class({ fileData, Status.UPLOADING, 'upload', _('Uploading file')); var formData = new FormData(); - formData.append('updateMatching', this.$('update-matching').value); + formData.append('updateMatching', this.$.updateMatching.value); 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)); @@ -152,7 +152,7 @@ Hedera.Photos = new Class({ } ,onFileRemove: function(fileData) { - this.$('file-list').removeChild(fileData.li); + this.$.fileList.removeChild(fileData.li); for (var i = 0; i < this.filesData.length; i++) if (this.filesData[i] === fileData) { @@ -163,23 +163,23 @@ Hedera.Photos = new Class({ ,onClearClick: function() { this.filesData = []; - Vn.Node.removeChilds(this.$('file-list')); + Vn.Node.removeChilds(this.$.fileList); } ,onDropzoneClick: function() { - this.$('file').click(); + this.$.file.click(); } ,onFileChange: function() { - this.addFiles(this.$('file').files); + this.addFiles(this.$.file.files); } ,onDragEnter: function() { - this.$('dropzone').classList.add('dragover'); + this.$.dropzone.classList.add('dragover'); } ,onDragLeave: function() { - this.$('dropzone').classList.remove('dragover'); + this.$.dropzone.classList.remove('dragover'); } ,onDragOver: function(event) { @@ -187,7 +187,7 @@ Hedera.Photos = new Class({ } ,onDragEnd: function(event) { - this.$('dropzone').classList.remove('dragover'); + this.$.dropzone.classList.remove('dragover'); event.dataTransfer.clearData(); } diff --git a/forms/admin/queries/queries.js b/forms/admin/queries/queries.js index 5beee6b1..d27481e8 100644 --- a/forms/admin/queries/queries.js +++ b/forms/admin/queries/queries.js @@ -3,12 +3,12 @@ Hedera.Queries = new Class({ Extends: Hedera.Form ,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; } @@ -19,9 +19,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); } @@ -41,7 +41,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); @@ -76,7 +76,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/users.js b/forms/admin/users/users.js index 05f45af2..af9cbff0 100644 --- a/forms/admin/users/users.js +++ b/forms/admin/users/users.js @@ -4,9 +4,9 @@ Hedera.Users = new Class({ ,rendererFunc: function(scope, form) { var isEnabled = form.get('active') - scope.$('disabled').style.display = isEnabled ? + scope.$.disabled.style.display = isEnabled ? 'none' : 'block'; - scope.$('impersonate').node.style.display = isEnabled ? + scope.$.impersonate.node.style.display = isEnabled ? 'block' : 'none'; } diff --git a/forms/admin/visits/visits.js b/forms/admin/visits/visits.js index 7c1a7674..ffd35638 100644 --- a/forms/admin/visits/visits.js +++ b/forms/admin/visits/visits.js @@ -3,12 +3,12 @@ Hedera.Visits = new Class({ Extends: Hedera.Form ,activate: function() { - this.$('from').value = new Date(); - this.$('to').value = new Date(); + this.$.from.value = new Date(); + this.$.to.value = new Date(); } ,onRefreshClick: function() { - this.$('visits').refresh(); + this.$.visits.refresh(); } ,onSessionsClick: function() { diff --git a/forms/cms/contact/contact.js b/forms/cms/contact/contact.js index 509863ae..41ff9886 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) { - var form = this.$('contact-form'); + var form = this.$.contactForm; if (json) { diff --git a/forms/cms/location/location.js b/forms/cms/location/location.js index d98bd35b..d5e76ad4 100644 --- a/forms/cms/location/location.js +++ b/forms/cms/location/location.js @@ -44,7 +44,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); if (this.locations) diff --git a/forms/ecomerce/basket/basket.js b/forms/ecomerce/basket/basket.js index 8ee16071..ce9f187f 100644 --- a/forms/ecomerce/basket/basket.js +++ b/forms/ecomerce/basket/basket.js @@ -16,7 +16,7 @@ Hedera.Basket = new Class({ } ,activate: function() { - this.$('items').setInfo('bi', 'myBasketItem', 'hedera'); + this.$.items.setInfo('bi', 'myBasketItem', 'hedera'); } ,onConfigureClick: function() { diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index 842c79a0..d9598d3d 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -23,9 +23,9 @@ Hedera.Catalog = new Class({ } ,activate: function() { - document.body.appendChild(this.$('right-panel')); + document.body.appendChild(this.$.rightPanel); - this.$('items-model').setInfo('i', 'item', 'vn', ['id']); + this.$.itemsModel.setInfo('i', 'item', 'vn', ['id']); if (localStorage.getItem('hederaView')) this.setView(parseInt(localStorage.getItem('hederaView'))); @@ -35,20 +35,20 @@ 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 === Hedera.Catalog.View.GRID) { - this.$('view-button').setProperties({ + this.$.viewButton.setProperties({ icon: 'view_list', tip: _('List view') }); this.view = Hedera.Catalog.View.GRID; var className = 'grid-view'; } else { - this.$('view-button').setProperties({ + this.$.viewButton.setProperties({ icon: 'grid_on', tip: _('Grid view') }); @@ -56,7 +56,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); } @@ -68,16 +68,16 @@ 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')); } ,onItemsChange: function(model, status) { if (status !== Db.Model.Status.CLEAN) - this.$('order').style.display = 'block'; + this.$.order.style.display = 'block'; else - this.$('order').style.display = 'none'; + this.$.order.style.display = 'none'; } ,onOrderChange: function(e) { @@ -87,7 +87,7 @@ Hedera.Catalog = new Class({ Db.Model.SortWay.ASC : Db.Model.SortWay.DESC; if (sortField) - this.$('items-model').sortByName(sortField, sortWay); + this.$.itemsModel.sortByName(sortField, sortWay); this.hideMenu(); } @@ -98,7 +98,7 @@ Hedera.Catalog = new Class({ } ,realmRenderer: function(builder, form) { - var link = builder.$('link'); + var link = builder.$.link; link.href = this.hash.make({ form: this.hash.get('form'), realm: form.get('id') @@ -107,11 +107,11 @@ Hedera.Catalog = new Class({ ,onRealmChange: function(param, newValue) { if (newValue) { - this.$('filters').style.display = 'block'; - this.$('realm-msg').style.display = 'none'; + this.$.filters.style.display = 'block'; + this.$.realmMsg.style.display = 'none'; } else { - this.$('filters').style.display = 'none'; - this.$('realm-msg').style.display = 'block'; + this.$.filters.style.display = 'none'; + this.$.realmMsg.style.display = 'block'; } this.refreshFilter(newValue, undefined); @@ -124,27 +124,27 @@ Hedera.Catalog = new Class({ } ,refreshFilter: function(realm, type) { - var batch = this.$('filter-batch'); + var batch = this.$.filterBatch; batch.block(); - this.$('realm-value').value = realm; - this.$('type-value').value = type; - this.$('search').value = undefined; - this.$('color').value = undefined; - this.$('origin').value = undefined; - this.$('category').value = undefined; - this.$('producer').value = undefined; + this.$.realmValue.value = realm; + this.$.typeValue.value = type; + this.$.search.value = undefined; + this.$.color.value = undefined; + this.$.origin.value = undefined; + this.$.category.value = undefined; + this.$.producer.value = undefined; batch.unblock(); batch.changed(); } ,refreshTitle: function() { - var types = this.$('types-model'); + var types = this.$.typesModel; if (!types.ready) return; var title = _('Catalog'); - var type = this.$('type').value; + var type = this.$.type.value; if (type) { var row = types.search('id', type); @@ -153,7 +153,7 @@ Hedera.Catalog = new Class({ title = types.get(row, 'name'); } - Vn.Node.setText(this.$('title-text'), title); + Vn.Node.setText(this.$.titleText, title); } ,onRightPanelClick: function(event) { @@ -164,7 +164,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); } @@ -174,7 +174,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; } @@ -208,13 +208,13 @@ Hedera.Catalog = new Class({ if (this.isGuest()) return; this.onEraseClick(); - this.$('card').row = form.row; - this.$('card-item').value = form.get('id'); - this.$('card-popup').show(event.currentTarget); + this.$.card.row = form.row; + this.$.cardItem.value = form.get('id'); + this.$.cardPopup.show(event.currentTarget); } ,onAddLotClick: function(column, value, row) { - var model = this.$('item-lots'); + var model = this.$.itemLots; var grouping = model.get(row, 'grouping'); var warehouse = model.get(row, 'warehouseFk'); var available = model.get(row, 'available'); @@ -231,7 +231,7 @@ Hedera.Catalog = new Class({ newAmount = available; this.items[warehouse] = newAmount; - this.$('amount').value += newAmount - lotAmount; + this.$.amount.value += newAmount - lotAmount; } else Htk.Toast.showError(_('NoMoreAmountAvailable')); } @@ -247,7 +247,7 @@ Hedera.Catalog = new Class({ amountSum += amount; batch.addValue('warehouse', warehouse); - batch.addValue('item', this.$('card-item').value); + batch.addValue('item', this.$.cardItem.value); batch.addValue('amount', amount); sql += query.render(batch); } @@ -255,27 +255,27 @@ Hedera.Catalog = new Class({ if (amountSum > 0) { this.conn.execQuery(sql); - var itemName = this.$('card').get('item'); + var itemName = this.$.card.get('item'); 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; } ,onCardLoad: function() { - this.$('card-popup').reset(); + this.$.cardPopup.reset(); } }); diff --git a/forms/ecomerce/checkout/checkout.js b/forms/ecomerce/checkout/checkout.js index 216a5e38..0709c892 100644 --- a/forms/ecomerce/checkout/checkout.js +++ b/forms/ecomerce/checkout/checkout.js @@ -4,15 +4,15 @@ Hedera.Checkout = new Class({ activate: function() { this.autoStepLocked = true; - this.$('assistant').stepsIndex = this.agencySteps; + this.$.assistant.stepsIndex = this.agencySteps; this.today = new Date(); this.today.setHours(0, 0, 0, 0); }, 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; @@ -46,16 +46,16 @@ Hedera.Checkout = new Class({ date.setDate(date.getDate() + addDays); } - this.$('date').value = date; - this.$('method').value = i.get('deliveryMethod'); - this.$('agency').value = i.get('agencyModeFk'); - this.$('address').value = i.get('addressFk'); + this.$.date.value = date; + this.$.method.value = i.get('deliveryMethod'); + this.$.agency.value = i.get('agencyModeFk'); + this.$.address.value = i.get('addressFk'); this.autoStepLocked = false; }, disableButtons: function(disable) { - this.$('assistant-bar').disabled = disable; + this.$.assistantBar.disabled = disable; }, onConfirmClick: function() { @@ -64,10 +64,10 @@ Hedera.Checkout = new Class({ var query = 'CALL myBasket_configure(#date, #method, #agency, #address)'; var batch = new Sql.Batch(); - batch.addParam('method', this.$('method')); - batch.addParam('date', this.$('date')); - batch.addParam('agency', this.$('agency')); - batch.addParam('address', this.$('address')); + batch.addParam('method', this.$.method); + batch.addParam('date', this.$.date); + batch.addParam('agency', this.$.agency); + batch.addParam('address', this.$.address); this.conn.execQuery(query, this.onBasketConfigured.bind(this), batch); @@ -79,7 +79,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')); @@ -88,7 +88,7 @@ Hedera.Checkout = new Class({ }, onCancelClick: function() { - if (this.$('order-form').numRows > 0) + if (this.$.orderForm.numRows > 0) window.history.back(); else this.hash.set({form: 'ecomerce/orders'}); @@ -98,77 +98,77 @@ Hedera.Checkout = new Class({ pickupSteps: ['method', 'date', 'address', 'pickup', 'confirm-pickup'], isDelivery: function() { - return this.$('rg-method').value != 'PICKUP'; + return this.$.rgMethod.value != 'PICKUP'; }, onMethodChange: function() { - this.$('assistant').stepsIndex = this.isDelivery() ? + this.$.assistant.stepsIndex = this.isDelivery() ? this.agencySteps : this.pickupSteps; this.onFieldChange(); }, methodValidate: function() { - if (!this.$('rg-method').isSelected()) + if (!this.$.rgMethod.isSelected()) throw new Error(_('Please select an option')); }, dateShow: function() { - Vn.Node.setText(this.$('date-question'), this.isDelivery() ? + Vn.Node.setText(this.$.dateQuestion, this.isDelivery() ? _('OrderDateDeliveryQuestion'): _('OrderDatePickupQuestion')); - this.$('calendar').goToSelectedMonth(); + this.$.calendar.goToSelectedMonth(); }, dateValidate: function() { - if (!this.$('calendar').value) + if (!this.$.calendar.value) throw new Error(_('Please select a date')); }, addressShow: function() { - Vn.Node.setText(this.$('address-question'), this.isDelivery() ? + Vn.Node.setText(this.$.addressQuestion, this.isDelivery() ? _('AddressQuestion'): _('AddressQuestionPickup')); }, addressValidate: function() { - if (this.$('address-form').row == -1) + if (this.$.addressForm.row == -1) throw new Error(_('Please select an address')); }, agencyShow: function() { - this.$('agencies').refresh(); + this.$.agencies.refresh(); }, agencyValidate: function() { - if (this.$('agency-combo').row == -1 && this.isDelivery()) + if (this.$.agencyCombo.row == -1 && this.isDelivery()) throw new Error(_('Please select an agency')); }, pickupShow: function() { - this.$('warehouses').refresh(); + this.$.warehouses.refresh(); }, pickupValidate: function() { - if (this.$('warehouse-combo').row == -1) + if (this.$.warehouseCombo.row == -1) throw new Error(_('Please select a store')); }, onFieldChange: function() { if (!this.autoStepLocked) - this.$('assistant').moveNext(); + this.$.assistant.moveNext(); }, 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.$('address').value = addressId; + this.$.address.value = addressId; this.goNextStep(); }, @@ -176,16 +176,16 @@ Hedera.Checkout = new Class({ if (this.selectedNode) Vn.Node.removeClass(this.selectedNode, 'selected'); - var row = this.$('addresses').search('id', this.$('address').value); + var row = this.$.addresses.search('id', this.$.address.value); if (row != -1) { - var builder = this.$('repeater').getBuilder(row); + var builder = this.$.repeater.getBuilder(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) { @@ -194,9 +194,9 @@ Hedera.Checkout = new Class({ if (model.numRows > 0) { var agency; var defaults = [ - this.$('order-form').get('agencyModeFk'), - this.$('defaults').get('agencyModeFk'), - this.$('defaults').get('defaultAgencyFk') + this.$.orderForm.get('agencyModeFk'), + this.$.defaults.get('agencyModeFk'), + this.$.defaults.get('defaultAgencyFk') ]; for (var i = 0; i < defaults.length; i++) { @@ -206,7 +206,7 @@ Hedera.Checkout = new Class({ } this.autoStepLocked = true; - this.$('agency').value = agency; + this.$.agency.value = agency; this.autoStepLocked = false; } else Htk.Toast.showError(_('NoAgeciesAvailableForDate')); diff --git a/forms/ecomerce/confirm/confirm.js b/forms/ecomerce/confirm/confirm.js index 7fec5102..f63c1278 100644 --- a/forms/ecomerce/confirm/confirm.js +++ b/forms/ecomerce/confirm/confirm.js @@ -20,11 +20,11 @@ Hedera.Confirm = new Class({ return; if (form.get('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 = form.get('taxableBase') + form.get('tax'); @@ -43,21 +43,21 @@ Hedera.Confirm = new Class({ Htk.Toast.showWarning( _('You have exceeded your credit.')); - this.$('debt').value = debt; - this.$('total-debt').value = totalDebt; - this.$('total-amount').value = totalDebt; - this.$('credit-excess').value = exceededCredit; - this.$('excess-amount').value = exceededCredit; + this.$.debt.value = debt; + this.$.totalDebt.value = totalDebt; + this.$.totalAmount.value = totalDebt; + this.$.creditExcess.value = exceededCredit; + this.$.excessAmount.value = exceededCredit; - this.$('pay-amount').value = 'ALL'; + this.$.payAmount.value = 'ALL'; if (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.$('pay-amount').value = 'EXCEEDED'; + this.$.amountSelector.style.display = 'block'; + this.$.exceededInfo.style.display = 'table-row'; + this.$.payAmount.value = 'EXCEEDED'; } } @@ -79,7 +79,7 @@ Hedera.Confirm = new Class({ for (var i = 0; i < methods.length; i++) this.$(methods[i] +'-method').style.display = 'block'; - this.$('pay-method').value = selectedMethod; + this.$.payMethod.value = selectedMethod; }, onPayMethodChange: function(payMethod) { @@ -112,8 +112,8 @@ Hedera.Confirm = new Class({ }, disableButtons: function(disable) { - this.$('modify').disabled = disable; - this.$('confirm').disabled = disable; + this.$.modify.disabled = disable; + this.$.confirm.disabled = disable; }, onModifyClick: function() { @@ -122,25 +122,25 @@ Hedera.Confirm = new Class({ onConfirmClick: function() { this.disableButtons(true); - this.$('confirm-query').execute(); + this.$.confirmQuery.execute(); }, onConfirm: function(query, resultSet) { this.disableButtons(false); if (resultSet.fetchResult()) - this.$('success-dialog').show(); + this.$.successDialog.show(); }, onDialogResponse: function() { - if (this.$('pay-method').value === 'CARD') { - if (this.$('pay-amount').value === 'EXCEEDED') - var payAmount = this.$('excess-amount').value; + if (this.$.payMethod.value === 'CARD') { + if (this.$.payAmount.value === 'EXCEEDED') + var payAmount = this.$.excessAmount.value; else - var payAmount = this.$('total-amount').value; + var payAmount = this.$.totalAmount.value; var tpv = new Hedera.Tpv({conn: this.conn}); - tpv.pay(payAmount, this.$('order-form').get('companyFk')); + tpv.pay(payAmount, this.$.orderForm.get('companyFk')); } else this.hash.set({'form': 'ecomerce/orders'}); } diff --git a/forms/ecomerce/orders/orders.js b/forms/ecomerce/orders/orders.js index 5f7d4078..c566c18b 100644 --- a/forms/ecomerce/orders/orders.js +++ b/forms/ecomerce/orders/orders.js @@ -9,7 +9,7 @@ Hedera.Orders = new Class({ _onTpvCheck: function(tpv, tpvOrder, tpvStatus) { if (tpvStatus === 'ko') - this.$('error-dialog').show(); + this.$.errorDialog.show(); }, onBasketClick: function() { @@ -17,7 +17,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('id') }); @@ -27,13 +27,13 @@ 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').value; + var amount = -this.$.debt.value; amount = amount <= 0 ? null : amount; var defaultAmountStr = ''; diff --git a/forms/ecomerce/ticket/ticket.js b/forms/ecomerce/ticket/ticket.js index 2204818d..47f4ce7f 100644 --- a/forms/ecomerce/ticket/ticket.js +++ b/forms/ecomerce/ticket/ticket.js @@ -13,15 +13,15 @@ Hedera.Ticket = new Class({ onTicketReady: 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')); }, onPrintClick: function() { let params = Vn.Url.makeUri({ authorization: this.conn.token, - ticketId: this.$('ticket-id').value, + ticketId: this.$.ticketId.value, recipientId: this.gui.user.id, type: 'deliveryNote' }); @@ -29,10 +29,10 @@ Hedera.Ticket = new Class({ }, repeaterFunc: function(res, form) { - var discount = res.$('discount'); + var discount = res.$.discount; discount.style.display = form.get('discount') ? 'inline' : 'none'; - res.$('discount-subtotal').value = this.discountSubtotal(form); - res.$('subtotal').value = this.subtotal(form); + res.$.discountSubtotal.value = this.discountSubtotal(form); + res.$.subtotal.value = this.subtotal(form); }, discountSubtotal: function(form) { @@ -45,16 +45,16 @@ Hedera.Ticket = new Class({ }, servicesFunc: function(res, form) { - res.$('subtotal').value = form.get('quantity') * form.get('price'); + res.$.subtotal.value = form.get('quantity') * form.get('price'); }, onServicesChanged: function(model) { - this.$('services').node.style.display = + this.$.services.node.style.display = model.numRows > 0 ? 'block' : 'none'; }, onPackagesChanged: function(model) { - this.$('packages').node.style.display = + this.$.packages.node.style.display = model.numRows > 0 ? 'block' : 'none'; }, }); diff --git a/forms/news/new/new.js b/forms/news/new/new.js index 02c79053..3a096b6d 100644 --- a/forms/news/new/new.js +++ b/forms/news/new/new.js @@ -7,13 +7,13 @@ Hedera.New = new Class({ ,editor: null ,activate: function() { - this.$('model').mode = Db.Model.Mode.ON_DEMAND; - this.$('model').setDefault('userFk', 'news', + this.$.model.mode = Db.Model.Mode.ON_DEMAND; + this.$.model.setDefault('userFk', 'news', new Sql.Function({schema: 'account', name: 'myUser_getId'})); 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" @@ -46,7 +46,7 @@ Hedera.New = new Class({ if (!this.editor) return; - var newHtml = this.$('iter').get('text'); + var newHtml = this.$.iter.get('text'); if (!newHtml) newHtml = ''; @@ -55,8 +55,8 @@ Hedera.New = new Class({ }, onStatusChange: function() { - if (this.$('new-id').value == 0) - this.$('iter').insertRow(); + if (this.$.newId.value == 0) + this.$.iter.insertRow(); }, onOperationsDone: function() { @@ -69,8 +69,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/reports/items-form/items-form.js b/forms/reports/items-form/items-form.js index 9b61e689..c2f4d85d 100644 --- a/forms/reports/items-form/items-form.js +++ b/forms/reports/items-form/items-form.js @@ -3,16 +3,16 @@ Hedera.ItemsForm = new Class({ Extends: Hedera.Form ,activate: function() { - this.$('warehouse').value = 7; - this.$('realm').value = null; + this.$.warehouse.value = 7; + this.$.realm.value = null; } ,onPreviewClick: function() { var batch = new Sql.Batch(); batch.addValues({ - warehouse: this.$('warehouse').value - ,realm: this.$('realm').value - ,rate: this.$('rate').value + warehouse: this.$.warehouse.value + ,realm: this.$.realm.value + ,rate: this.$.rate.value }); this.gui.openReport('items-report', batch); } diff --git a/forms/reports/shelves/shelves.js b/forms/reports/shelves/shelves.js index 221f37df..694642b7 100644 --- a/forms/reports/shelves/shelves.js +++ b/forms/reports/shelves/shelves.js @@ -3,8 +3,8 @@ Hedera.Shelves = new Class({ Extends: Hedera.Form ,activate: function() { - this.$('date').value = new Date(); - this.$('useIds').value = false; + this.$.date.value = new Date(); + this.$.useIds.value = false; } ,onConfigChange: function() { @@ -21,7 +21,7 @@ Hedera.Shelves = new Class({ ]; for (var i = 0; i < fields.length; i++) - this.$(fields[i]).value = this.$('config').get(fields[i]); + this.$(fields[i]).value = this.$.config.get(fields[i]); } ,onPreviewClick: function() { diff --git a/js/hedera/form.js b/js/hedera/form.js index a3723c0d..c49484f5 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -11,19 +11,6 @@ module.exports = new Class({ this.hash = gui.hash; this.formInfo = formInfo; } - - /** - * Gets an object from the builder associated to this form. - * - * @param {string} objectId The object identifier - * @return {Object} The object, or %null if not found - */ - ,$: function(objectId) { - if (this.builder) - return this.builder.getById(objectId); - - return null; - } ,loadUi: function() { if (!this.isOpen) @@ -33,9 +20,10 @@ module.exports = new Class({ builder.compileFile('forms/'+ this.formInfo.path +'/ui.xml'); var scope = this.builder = builder.load(null, this); + this.$ = scope.$; scope.link(null, {conn: this.conn}); - this.node = scope.$('form'); + this.node = scope.$.form; var models = scope.getByTagName('db-model'); @@ -49,8 +37,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 5c248edc..21bc15f6 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -33,9 +33,9 @@ module.exports = new Class({ this.builderInitString(Tpl); this.loadingCount = 0; - this.$('background').onclick = function() {}; + this.$.background.onclick = function() {}; - this.$('left-panel').addEventListener('click', function(event) { + this.$.leftPanel.addEventListener('click', function(event) { event.stopPropagation(); }); @@ -57,7 +57,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()) { this._onScrollHandler = this._onScroll.bind(this); @@ -115,7 +115,7 @@ module.exports = new Class({ // Retrieving the user name this.user = resultSet.fetchObject(); - Vn.Node.setText(this.$('user-name'), this.user.nickname); + Vn.Node.setText(this.$.userName, this.user.nickname); // Retrieving configuration parameters @@ -135,8 +135,8 @@ module.exports = new Class({ var isTesting = !resultSet.fetchValue(); if (isTesting) { - this.$('dev-info').style.display = 'block'; - this.$('version').textContent = Vn.Cookie.get('vnVersion'); + this.$.devInfo.style.display = 'block'; + this.$.version.textContent = Vn.Cookie.get('vnVersion'); } // Retrieving configuration parameters @@ -152,11 +152,11 @@ module.exports = new Class({ var linkField = 'testDomain'; } - Vn.Node.setText(this.$('test-link'), _(linkText)); - this.$('test-link').href = '//'+ res.get(linkField); - this.$('test-link').style.display = 'block'; + Vn.Node.setText(this.$.testLink, _(linkText)); + this.$.testLink.href = '//'+ res.get(linkField); + this.$.testLink.style.display = 'block'; } else - this.$('test-link').style.display = 'none'; + this.$.testLink.style.display = 'none'; // Loading the default form @@ -184,8 +184,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 @@ -266,7 +266,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); @@ -278,7 +278,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); @@ -297,7 +297,7 @@ module.exports = new Class({ if (!this._shown) return; - var navbar = this.$('top-bar'); + var navbar = this.$.topBar; var yOffset = Vn.Browser.getPageYOffset(); var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight; @@ -319,11 +319,11 @@ module.exports = new Class({ //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Background ,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 @@ -332,7 +332,7 @@ module.exports = new Class({ this.loadingCount++; if (this.loadingCount == 1) - this.$('loader').start(); + this.$.loader.start(); } ,loaderPop: function() { @@ -342,7 +342,7 @@ module.exports = new Class({ this.loadingCount--; if (this.loadingCount == 0) - this.$('loader').stop(); + this.$.loader.stop(); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms @@ -397,35 +397,35 @@ module.exports = new Class({ } ,setForm: function(form) { - Vn.Node.removeChilds(this.$('form-holder')); + Vn.Node.removeChilds(this.$.formHolder); if (form) { - this.$('form-holder').appendChild(form); + this.$.formHolder.appendChild(form); setTimeout(this._onSetFormTimeout.bind(this), 0); } } ,_onSetFormTimeout: function() { - Vn.Node.addClass(this.$('form-holder'), 'show'); + Vn.Node.addClass(this.$.formHolder, 'show'); } ,setTitle: function(title) { - Vn.Node.removeChilds(this.$('title')); + Vn.Node.removeChilds(this.$.title); if (title) - this.$('title').appendChild(title); + this.$.title.appendChild(title); } ,setActions: function(actions) { - Vn.Node.removeChilds(this.$('action-bar')); + Vn.Node.removeChilds(this.$.actionBar); if (actions) - this.$('action-bar').appendChild(actions); + this.$.actionBar.appendChild(actions); } ,closeForm: function() { if (this.activeForm) { - Vn.Node.removeClass(this.$('form-holder'), 'show'); + Vn.Node.removeClass(this.$.formHolder, 'show'); this.activeForm.close(); this.activeForm.unref(); this.activeForm = null; @@ -492,12 +492,12 @@ module.exports = new Class({ ,_onSupplantName: function(resultSet) { var userName = resultSet.fetchValue(); - Vn.Node.setText(this.$('supplanted'), userName); - this.$('supplant').classList.toggle('show', true); + Vn.Node.setText(this.$.supplanted, userName); + this.$.supplant.classList.toggle('show', true); } ,onSupplantExitClick: function() { - this.$('supplant').classList.toggle('show', false); + this.$.supplant.classList.toggle('show', false); this._conn.supplantEnd(); sessionStorage.removeItem('supplantUser', sessionStorage.getItem('supplantUser')); diff --git a/js/hedera/login.js b/js/hedera/login.js index 0f4bea00..e47cdf9c 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -22,10 +22,10 @@ module.exports = new Class({ this.parent(props); this.builderInitString(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; }; @@ -33,9 +33,9 @@ module.exports = new Class({ ,_onConnLoadChange: function(conn, isLoading) { if (isLoading) - this.$('spinner').start(); + this.$.spinner.start(); else - this.$('spinner').stop(); + this.$.spinner.stop(); } ,show: function() { @@ -44,27 +44,27 @@ module.exports = new Class({ var lastUser = localStorage.getItem('hederaLastUser'); if (lastUser) - this.$('user').value = lastUser; + this.$.user.value = lastUser; this._focusUserInput(); } ,_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); } ,_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); @@ -81,19 +81,19 @@ 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 0d471090..6be4e667 100644 --- a/js/hedera/report.js +++ b/js/hedera/report.js @@ -9,19 +9,6 @@ module.exports = new Class({ this.parent(null); } - /** - * Gets an object from the builder associated to this report. - * - * @param {string} objectId The object identifier - * @return {Object} The object, or %null if not found - */ - ,$: function(objectId) { - if (this.scope) - return this.scope.getById(objectId); - - return null; - } - ,open: function(batch) { this.batch = batch; this.createWindow(); @@ -86,8 +73,9 @@ module.exports = new Class({ batch: this.batch, conn: this.conn }); + this.$ = scope.$; - this.doc.body.appendChild(scope.$('report')); + this.doc.body.appendChild(scope.$.report); } }); diff --git a/js/hedera/responsive.scss b/js/hedera/responsive.scss index bf30ae31..444471a6 100644 --- a/js/hedera/responsive.scss +++ b/js/hedera/responsive.scss @@ -33,7 +33,7 @@ @media (max-device-width: 383px) and (min-resolution: 192dpi), (max-device-width: 383px) and (-webkit-min-device-pixel-ratio: 2) { - body { font-size: 9pt; } + body { font-size: 10pt; } } @media (min-device-width: 384px) and (min-resolution: 192dpi), @@ -45,7 +45,7 @@ @media (max-device-width: 411px) and (min-resolution: 249dpi), (max-device-width: 411px) and (-webkit-min-device-pixel-ratio: 3) { - body { font-size: 9pt; } + body { font-size: 10pt; } } @media (min-device-width: 412px) and (min-resolution: 249dpi), diff --git a/js/htk/component.js b/js/htk/component.js index 2a0c8a8c..c536e3ae 100644 --- a/js/htk/component.js +++ b/js/htk/component.js @@ -22,14 +22,8 @@ module.exports = new Class({ const scope = this.scope = builder.load(this.doc, this); scope.link(); - this._node = scope.$('main'); - } - - ,$: function(id) { - if (this.scope) - return this.scope.getById(id); - - return null; + this.$ = scope.$; + this._node = scope.$.main; } ,_destroy: function() { diff --git a/js/htk/field/image.js b/js/htk/field/image.js index f6b3b51a..238c53ac 100644 --- a/js/htk/field/image.js +++ b/js/htk/field/image.js @@ -121,7 +121,6 @@ module.exports = new Class({ this.editButton = button; } - console.log(this.editable); } ,_makeSrc: function(subdir) { diff --git a/js/htk/image-editor.js b/js/htk/image-editor.js index 3b31ed94..cd0bcde2 100644 --- a/js/htk/image-editor.js +++ b/js/htk/image-editor.js @@ -22,7 +22,7 @@ module.exports = new Class({ this.builderInitString(Tpl); var self = this; - this.$('form').onsubmit = function() { + this.$.form.onsubmit = function() { self._onSubmit(); return false; }; @@ -30,7 +30,7 @@ module.exports = new Class({ }, onNameChange: function() { - var newValue = this.$('name').value; + var newValue = this.$.name.value; if (!newValue) newValue = null @@ -39,28 +39,28 @@ module.exports = new Class({ }, _onSubmit: function() { - this.$('hidden-name').value = this.$('name').value; - this.$('submit').disabled = true; - this.$('spinner').start(); + this.$.hiddenName.value = this.$.name.value; + 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.signalEmit('file-uploaded', this.$('name').value); + this.signalEmit('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/sql/batch.js b/js/sql/batch.js index 96312241..36cd7030 100644 --- a/js/sql/batch.js +++ b/js/sql/batch.js @@ -5,8 +5,7 @@ var Value = require('./value'); /** * A map container for many Sql.Object */ -module.exports = new Class -({ +module.exports = new Class({ Extends: Object ,Tag: 'sql-batch' ,Properties: diff --git a/js/vn/builder.js b/js/vn/builder.js index 13e41a77..1d397223 100644 --- a/js/vn/builder.js +++ b/js/vn/builder.js @@ -189,7 +189,7 @@ module.exports = new Class({ for (var i = links.length - 1; i >= 0; i--) { const link = links[i]; const object = objects[link.context.id]; - const objectRef = scope._$[link.objectId]; + const objectRef = scope.$[link.objectId]; if (objectRef === undefined) { this.showError('Referenced unexistent object with id \'%s\'', @@ -207,7 +207,7 @@ module.exports = new Class({ const baseExprScope = [ _, - scope._$ + scope.$ ].concat(exprScope); this.linkExpr(scope, baseExprScope); diff --git a/js/vn/scope.js b/js/vn/scope.js index d9684b93..34b33ea7 100644 --- a/js/vn/scope.js +++ b/js/vn/scope.js @@ -4,25 +4,24 @@ const kebabToCamel = require('./string-util').kebabToCamel; module.exports = new Class({ Extends: VnObject - ,initialize: function(builder, objects, thisArg, parentScope) { + ,initialize: function(builder, objects, thisArg, parent) { this.builder = builder; this.objects = objects; this.thisArg = thisArg; - this.parentScope = parentScope; + this.parentScope = parent; + this.$ = parent ? Object.create(parent.$) : {}; - if (!thisArg && parentScope) - this.thisArg = parentScope.thisArg; + if (!thisArg && parent) + this.thisArg = parent.thisArg; } ,link: function(exprScope, 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]; + this.$[id] = extraObjects[id]; for (var id in contextMap) - objectMap[id] = this.objects[contextMap[id]]; + this.$[id] = this.objects[contextMap[id]]; this.builder.link(this, exprScope); } @@ -31,13 +30,9 @@ module.exports = new Class({ return this.builder.getMain(this); } - ,$: function(objectId) { - if (!objectId) return null; - return this._$[kebabToCamel(objectId)]; - } - ,getById: function(objectId) { - return this.$(objectId); + if (!objectId) return null; + return this.$[kebabToCamel(objectId)]; } ,getByTagName: function(tagName) { diff --git a/pages/production/main.js b/pages/production/main.js index ab388a4d..d3a076e2 100644 --- a/pages/production/main.js +++ b/pages/production/main.js @@ -126,18 +126,18 @@ function display (text, status, error) if (error) { text = text ? text : 'Er'; - $('error').textContent = error; - $('error').style.display = 'block'; + $.error.textContent = error; + $.error.style.display = 'block'; bgColor = 'red'; } else { - $('error').textContent = ''; - $('error').style.display = 'none'; + $.error.textContent = ''; + $.error.style.display = 'none'; bgColor = 'green'; } - $('text').textContent = text; + $.text.textContent = text; body.className = status ? status : ''; body.addEventListener ('transitionend', onTransitionEnd); diff --git a/reports/delivery-note/delivery-note.js b/reports/delivery-note/delivery-note.js index bfe0332b..b9614cea 100644 --- a/reports/delivery-note/delivery-note.js +++ b/reports/delivery-note/delivery-note.js @@ -4,9 +4,9 @@ Hedera.DeliveryNote = new Class({ onTicketReady: 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')); }, discountRenderer: function(column, form) { @@ -28,12 +28,12 @@ Hedera.DeliveryNote = new Class({ }, onServicesChanged: function(model) { - this.$('services').node.style.display = + this.$.services.node.style.display = model.numRows > 0 ? 'block' : 'none'; }, onPackagesChanged: function(model) { - this.$('packages').node.style.display = + this.$.packages.node.style.display = model.numRows > 0 ? 'block' : 'none'; } });