interpolate v1, camelCase htmlId

This commit is contained in:
Juan Ferrer Toribio 2017-10-20 19:09:06 +02:00
parent 63158d335e
commit 60a1d7cf9e
41 changed files with 326 additions and 370 deletions

View File

@ -5,8 +5,8 @@ Hedera.AddressList = new Class
,activate: function () ,activate: function ()
{ {
this.$('user-model').setInfo ('c', 'customer_view', 'hedera'); this.$.userModel.setInfo ('c', 'customer_view', 'hedera');
this.$('addresses').setInfo ('a', 'address_view', 'hedera'); this.$.addresses.setInfo ('a', 'address_view', 'hedera');
} }
,onAddAddressClick: function () ,onAddAddressClick: function ()
@ -33,9 +33,9 @@ Hedera.AddressList = new Class
,repeaterFunc: function (res, form) ,repeaterFunc: function (res, form)
{ {
res.$('link').href = this.hash.make ({ res.$.link.href = this.hash.make ({
'form': 'account/address', form: 'account/address',
'address': form.get ('id') address: form.$.id
}); });
} }
}); });

View File

@ -47,14 +47,13 @@
on-click="onRemoveAddressClick"/> on-click="onRemoveAddressClick"/>
</div> </div>
<p class="important"> <p class="important">
<htk-text lot="iter" name="consignee"/> {{consignee}}
</p> </p>
<p> <p>
<htk-text lot="iter" name="name"/> {{name}}
</p> </p>
<p> <p>
<htk-text lot="iter" name="zip_code"/>, {{zip_code}}, {{city}}
<htk-text lot="iter" name="city"/>
</p> </p>
</a> </a>
</custom> </custom>

View File

@ -5,14 +5,14 @@ Hedera.Address = new Class
,activate: function () ,activate: function ()
{ {
this.$('model').setInfo ('a', 'address_view', 'hedera', ['id'], 'id'); this.$.model.setInfo ('a', 'address_view', 'hedera', ['id'], 'id');
this.$('model').setDefault ('customer_id', 'a', this.$.model.setDefault ('customer_id', 'a',
new Sql.Function ({schema: 'account', name: 'userGetId'})); new Sql.Function ({schema: 'account', name: 'userGetId'}));
} }
,onStatusChange: function (form) ,onStatusChange: function (form)
{ {
if (form.ready && this.$('params').$.address == 0) if (form.ready && this.$.params.$.address == 0)
form.insertRow (); form.insertRow ();
} }
@ -24,7 +24,7 @@ Hedera.Address = new Class
,onAcceptClick: function () ,onAcceptClick: function ()
{ {
this.$('iter').performOperations (); this.$.iter.performOperations ();
} }
,onReturnClick: function () ,onReturnClick: function ()

View File

@ -5,31 +5,31 @@ Hedera.Conf = new Class
,activate: function () ,activate: function ()
{ {
this.$('user-model').setInfo ('c', 'customer_view', 'hedera'); this.$.userModel.setInfo ('c', 'customer_view', 'hedera');
} }
,onPassChangeClick: function () ,onPassChangeClick: function ()
{ {
this.$('old-password').value = ''; this.$.oldPassword.value = '';
this.$('new-password').value = ''; this.$.newPassword.value = '';
this.$('repeat-password').value = ''; this.$.repeatPassword.value = '';
var recoverPass = this.$('user').get ('recoverPass'); var recoverPass = this.$.user.get ('recoverPass');
this.$('old-password').style.display = recoverPass ? 'none' : 'block'; this.$.oldPassword.style.display = recoverPass ? 'none' : 'block';
this.$('change-password').show (); this.$.changePassword.show ();
if (recoverPass) if (recoverPass)
this.$('new-password').focus (); this.$.newPassword.focus ();
else else
this.$('old-password').focus (); this.$.oldPassword.focus ();
} }
,onPassModifyClick: function () ,onPassModifyClick: function ()
{ {
try { try {
var oldPassword = this.$('old-password').value; var oldPassword = this.$.oldPassword.value;
var newPassword = this.$('new-password').value; var newPassword = this.$.newPassword.value;
var repeatedPassword = this.$('repeat-password').value; var repeatedPassword = this.$.repeatPassword.value;
if (newPassword == '' && repeatedPassword == '') if (newPassword == '' && repeatedPassword == '')
throw new Error (_('Passwords empty')); throw new Error (_('Passwords empty'));
@ -37,8 +37,8 @@ Hedera.Conf = new Class
throw new Error (_('Passwords doesn\'t match')); throw new Error (_('Passwords doesn\'t match'));
var params = { var params = {
'oldPassword': oldPassword, oldPassword: oldPassword,
'newPassword': newPassword newPassword: newPassword
}; };
this.conn.send ('core/change-password', params, this.conn.send ('core/change-password', params,
this._onPassChange.bind (this)); this._onPassChange.bind (this));
@ -53,25 +53,25 @@ Hedera.Conf = new Class
{ {
if (json) if (json)
{ {
this.$('change-password').hide (); this.$.changePassword.hide ();
Htk.Toast.showMessage (_('Password changed!')); Htk.Toast.showMessage (_('Password changed!'));
this.$('user').refresh (); this.$.user.refresh ();
} }
else else
{ {
Htk.Toast.showError (error.message); Htk.Toast.showError (error.message);
this.$('old-password').select (); this.$.oldPassword.select ();
} }
} }
,onPassInfoClick: function () ,onPassInfoClick: function ()
{ {
this.$('password-info').show (); this.$.passwordInfo.show ();
} }
,onAddressesClick: function () ,onAddressesClick: function ()
{ {
this.hash.setAll ({'form': 'account/address-list'}); this.hash.setAll ({form: 'account/address-list'});
} }
}); });

View File

@ -23,14 +23,14 @@ Hedera.Connections = new Class
,onRefreshClick: function () ,onRefreshClick: function ()
{ {
this.$('sessions').refresh (); this.$.sessions.refresh ();
} }
,repeaterFunc: function (res, form) ,repeaterFunc: function (res, form)
{ {
res.$('link').href = this.hash.make ({ res.$.link.href = this.hash.make ({
'form': 'admin/access-log', form: 'admin/access-log',
'user': form.get ('userId') user: form.$.userId
}); });
} }
@ -42,7 +42,7 @@ Hedera.Connections = new Class
,_onUserSupplant: function () ,_onUserSupplant: function ()
{ {
this.hash.setAll ({'form': 'ecomerce/orders'}); this.hash.setAll ({form: 'ecomerce/orders'});
} }
,sessionsFunc: function () ,sessionsFunc: function ()

View File

@ -2,10 +2,5 @@
Hedera.Links = new Class Hedera.Links = new Class
({ ({
Extends: Hedera.Form Extends: Hedera.Form
,repeaterFunc: function (res, form)
{
res.$('link').href = form.get ('link');
}
}); });

View File

@ -4,23 +4,23 @@
</h1> </h1>
<div id="main" class="cpanel"> <div id="main" class="cpanel">
<div class="card list"> <div class="card list">
<htk-repeater form-id="iter" renderer="repeaterFunc"> <htk-repeater>
<db-model property="model"> <db-model property="model">
SELECT image, name, description, link FROM link SELECT image, name, description, link FROM link
ORDER BY name ORDER BY name
</db-model> </db-model>
<custom> <custom>
<a id="link" class="list-row" target="_blank"> <a class="list-row" href="{{link}}" target="_blank">
<htk-image <htk-image
lot="iter" lot="iter"
name="image" name="image"
directory="link" directory="link"
subdir="full"/> subdir="full"/>
<p class="important"> <p class="important">
<htk-text lot="iter" name="name"/> {{name}}
</p> </p>
<p> <p>
<htk-text lot="iter" name="description"/> {{description}}
</p> </p>
</a> </a>
</custom> </custom>

View File

@ -18,7 +18,7 @@ Hedera.Photos = new Class
,activate: function () ,activate: function ()
{ {
this.$('schema').value = 'catalog'; this.$.schema.value = 'catalog';
} }
,addFiles: function (files) ,addFiles: function (files)
@ -70,7 +70,7 @@ Hedera.Photos = new Class
this.filesData.push (fileData); this.filesData.push (fileData);
button.value = fileData; button.value = fileData;
this.$('file-list').appendChild (div); this.$.fileList.appendChild (div);
} }
,onUploadClick: function () ,onUploadClick: function ()
@ -112,7 +112,7 @@ Hedera.Photos = new Class
var formData = new FormData(); var formData = new FormData();
formData.append ('image', fileData.file); formData.append ('image', fileData.file);
formData.append ('name', fileData.name.value); formData.append ('name', fileData.name.value);
formData.append ('schema', this.$('schema').value); formData.append ('schema', this.$.schema.value);
formData.append ('srv', 'json:image/upload'); formData.append ('srv', 'json:image/upload');
this.conn.sendFormData (formData, this.conn.sendFormData (formData,
this.onFileUpload.bind (this, fileData)); this.onFileUpload.bind (this, fileData));
@ -163,7 +163,7 @@ Hedera.Photos = new Class
,onFileRemove: function (button) ,onFileRemove: function (button)
{ {
var fileData = button.value; var fileData = button.value;
this.$('file-list').removeChild (fileData.div); this.$.fileList.removeChild (fileData.div);
for (var i = 0; i < this.filesData.length; i++) for (var i = 0; i < this.filesData.length; i++)
if (this.filesData[i] === fileData) if (this.filesData[i] === fileData)
@ -176,27 +176,27 @@ Hedera.Photos = new Class
,onClearClick: function () ,onClearClick: function ()
{ {
this.filesData = []; this.filesData = [];
Vn.Node.removeChilds (this.$('file-list')); Vn.Node.removeChilds (this.$.file-list);
} }
,onDropzoneClick: function () ,onDropzoneClick: function ()
{ {
this.$('file').click (); this.$.file.click ();
} }
,onFileChange: function () ,onFileChange: function ()
{ {
this.addFiles (this.$('file').files); this.addFiles (this.$.file.files);
} }
,onDragEnter: function () ,onDragEnter: function ()
{ {
Vn.Node.addClass (this.$('dropzone'), 'dragover'); Vn.Node.addClass (this.$.dropzone, 'dragover');
} }
,onDragLeave: function () ,onDragLeave: function ()
{ {
Vn.Node.removeClass (this.$('dropzone'), 'dragover'); Vn.Node.removeClass (this.$.dropzone, 'dragover');
} }
,onDragOver: function (event) ,onDragOver: function (event)
@ -206,7 +206,7 @@ Hedera.Photos = new Class
,onDragEnd: function (event) ,onDragEnd: function (event)
{ {
Vn.Node.removeClass (this.$('dropzone'), 'dragover'); Vn.Node.removeClass (this.$.dropzone, 'dragover');
event.dataTransfer.clearData (); event.dataTransfer.clearData ();
} }

View File

@ -5,14 +5,14 @@ Hedera.Queries = new Class
,activate: function () ,activate: function ()
{ {
this.$('result-index').value = 0; this.$.resultIndex.value = 0;
} }
,clean: function () ,clean: function ()
{ {
if (this._grid) if (this._grid)
{ {
this.$('grid-holder').removeChild (this._grid.node); this.$.gridHolder.removeChild (this._grid.node);
this._grid.unref (); this._grid.unref ();
this._grid = null; this._grid = null;
} }
@ -24,9 +24,9 @@ Hedera.Queries = new Class
var model = new Db.Model ({ var model = new Db.Model ({
conn: this.conn, conn: this.conn,
query: this.$('sql').value, query: this.$.sql.value,
resultIndex: this.$('result-index').value, resultIndex: this.$.resultIndex.value,
updatable: this.$('updatable').value updatable: this.$.updatable.value
}); });
model.on ('status-changed', this._onModelChange, this); model.on ('status-changed', this._onModelChange, this);
} }
@ -49,7 +49,7 @@ Hedera.Queries = new Class
Htk.Toast.showMessage (_('Query executed!')); Htk.Toast.showMessage (_('Query executed!'));
var gridHolder = this.$('grid-holder'); var gridHolder = this.$.gridHolder;
if (gridHolder.firstChild) if (gridHolder.firstChild)
gridHolder.removeChilds (gridHolder.firstChild); gridHolder.removeChilds (gridHolder.firstChild);
@ -86,7 +86,7 @@ Hedera.Queries = new Class
column.setProperties ({ column.setProperties ({
title: c.name, title: c.name,
editable: this.$('updatable').value, editable: this.$.updatable.value,
columnIndex: i columnIndex: i
}); });

View File

@ -7,7 +7,7 @@
</div> </div>
<div id="main" class="users"> <div id="main" class="users">
<div class="card list"> <div class="card list">
<htk-repeater form-id="iter" renderer="repeaterFunc"> <htk-repeater>
<db-model property="model" lot="hash"> <db-model property="model" lot="hash">
SELECT u.id, u.name, c.Cliente SELECT u.id, u.name, c.Cliente
FROM account.user u FROM account.user u
@ -18,7 +18,10 @@
ORDER BY u.name LIMIT 200 ORDER BY u.name LIMIT 200
</db-model> </db-model>
<custom> <custom>
<a id="link" class="list-row" title="_AccessLog"> <a
class="list-row"
href="#!form=admin/access-log&amp;user={{id}}"
title="_AccessLog">
<div class="actions"> <div class="actions">
<htk-button <htk-button
lot="iter" lot="iter"
@ -28,11 +31,10 @@
on-click="onChangeUserClick"/> on-click="onChangeUserClick"/>
</div> </div>
<p class="important"> <p class="important">
<htk-text lot="iter" name="Cliente"/> {{Cliente}}
</p> </p>
<p> <p>
<htk-text lot="iter" name="id"/> - {{id}} - {{name}}
<htk-text lot="iter" name="name"/>
</p> </p>
</a> </a>
</custom> </custom>

View File

@ -3,23 +3,15 @@ Hedera.Users = new Class
({ ({
Extends: Hedera.Form 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) ,onChangeUserClick: function (button, form)
{ {
this.gui.supplantUser (form.get ('name'), this.gui.supplantUser (form.$.name,
this.onUserSupplant.bind (this)); this.onUserSupplant.bind (this));
} }
,onUserSupplant: function () ,onUserSupplant: function ()
{ {
this.hash.setAll ({'form': 'ecomerce/orders'}); this.hash.setAll ({form: 'ecomerce/orders'});
} }
}); });

View File

@ -5,23 +5,21 @@ Hedera.Visits = new Class
,activate: function () ,activate: function ()
{ {
var hash = this.hash; if (!this.hash.$.to)
this.hash.assign ({
if (!hash.get ('to')) from: new Date (),
{ to: new Date ()
hash.set ('from', new Date ()); });
hash.set ('to', new Date ());
}
} }
,onRefreshClick: function () ,onRefreshClick: function ()
{ {
this.$('visits').refresh (); this.$.visits.refresh ();
} }
,onSessionsClick: function () ,onSessionsClick: function ()
{ {
this.hash.setAll ({'form': 'admin/connections'}); this.hash.setAll ({form: 'admin/connections'});
} }
}); });

View File

@ -6,7 +6,7 @@ Hedera.Contact = new Class
,activate: function () ,activate: function ()
{ {
var self = this; var self = this;
this.$('contact-form').onsubmit = function () this.$.contactForm.onsubmit = function ()
{ self._onSubmit (); return false; }; { self._onSubmit (); return false; };
this.refreshCaptcha (); this.refreshCaptcha ();
@ -18,18 +18,18 @@ Hedera.Contact = new Class
'srv': 'rest:core/captcha', 'srv': 'rest:core/captcha',
'stamp': new Date ().getTime () 'stamp': new Date ().getTime ()
}; };
this.$('captcha-img').src = '?'+ Vn.Url.makeUri (params); this.$.captchaImg.src = '?'+ Vn.Url.makeUri (params);
} }
,_onSubmit: function () ,_onSubmit: function ()
{ {
this.conn.sendForm (this.$('contact-form'), this.conn.sendForm (this.$.contactForm,
this._onResponse.bind (this)); this._onResponse.bind (this));
} }
,_onResponse: function (json, error) ,_onResponse: function (json)
{ {
var form = this.$('contact-form'); var form = this.$.contactForm;
if (json) if (json)
{ {

View File

@ -11,7 +11,7 @@
</div> </div>
<div id="main" class="home"> <div id="main" class="home">
<div class="column mansonry" id="news-column"> <div class="column mansonry" id="news-column">
<htk-repeater form-id="new"> <htk-repeater>
<db-model property="model"> <db-model property="model">
SELECT title, date_time, text, image, id FROM news SELECT title, date_time, text, image, id FROM news
WHERE tag != 'course' WHERE tag != 'course'
@ -21,20 +21,20 @@
<div class="masonry-box"> <div class="masonry-box">
<div class="new"> <div class="new">
<div class="top"> <div class="top">
<h2><htk-text lot="new" name="title"/></h2> <h2>{{title}}</h2>
<!-- <!--
<p class="new-info"> <p class="new-info">
<htk-text format="_%a, %e %b %Y" lot="new" name="date_time"/> <htk-text format="_%a, %e %b %Y" lot="new" name="date_time"/>
</p> </p>
--> -->
<div class="new-text"> <div class="new-text">
<htk-html lot="new" name="text"/> <htk-html lot="iter" name="text"/>
</div> </div>
</div> </div>
<htk-image <htk-image
directory="news" directory="news"
subdir="full" subdir="full"
lot="new" lot="iter"
name="image" name="image"
editable="false" editable="false"
full-dir="full"/> full-dir="full"/>

View File

@ -48,7 +48,7 @@ Hedera.Location = new Class
,center: new google.maps.LatLng (46.0, 4.0) ,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 gmap = new google.maps.Map (div, options);
var row; var row;

View File

@ -20,7 +20,7 @@ Hedera.Basket = new Class
,activate: function () ,activate: function ()
{ {
this.$('items').setInfo ('i', 'basket_item', 'hedera'); this.$.items.setInfo ('i', 'basket_item', 'hedera');
} }
,onConfigureClick: function () ,onConfigureClick: function ()
@ -41,7 +41,7 @@ Hedera.Basket = new Class
,repeaterFunc: function (res, form) ,repeaterFunc: function (res, form)
{ {
res.$('subtotal').value = this.subtotal (form); res.$.subtotal.value = this.subtotal (form);
} }
,onDeleteClick: function (button, form) ,onDeleteClick: function (button, form)

View File

@ -36,8 +36,8 @@ Hedera.Catalog = new Class
,activate: function () ,activate: function ()
{ {
this.$('items').setInfo ('a', 'Articles', 'vn2008', ['item_id']); this.$.items.setInfo ('a', 'Articles', 'vn2008', ['item_id']);
document.body.appendChild (this.$('right-panel')); document.body.appendChild (this.$.rightPanel);
if (localStorage.getItem ('hederaView')) if (localStorage.getItem ('hederaView'))
this.setView (parseInt (localStorage.getItem ('hederaView'))); this.setView (parseInt (localStorage.getItem ('hederaView')));
@ -52,15 +52,15 @@ Hedera.Catalog = new Class
,deactivate: function () ,deactivate: function ()
{ {
this.hideMenu (); this.hideMenu ();
this.gui.$('top-bar').style.backgroundColor = ''; this.gui.$.topBar.style.backgroundColor = '';
Vn.Node.remove (this.$('right-panel')); Vn.Node.remove (this.$.rightPanel);
} }
,setView: function (view) ,setView: function (view)
{ {
if (view === View.GRID) if (view === View.GRID)
{ {
this.$('view-button').setProperties ({ this.$.viewButton.setProperties ({
icon: 'view-list', icon: 'view-list',
tip: _('List view') tip: _('List view')
}); });
@ -69,7 +69,7 @@ Hedera.Catalog = new Class
} }
else else
{ {
this.$('view-button').setProperties ({ this.$.viewButton.setProperties ({
icon: 'view-grid', icon: 'view-grid',
tip: _('Grid view') tip: _('Grid view')
}); });
@ -77,7 +77,7 @@ Hedera.Catalog = new Class
var className = 'list-view'; var className = 'list-view';
} }
var node = this.$('grid-view').node; var node = this.$.gridView.node;
node.className = className; node.className = className;
localStorage.setItem ('hederaView', this.view); localStorage.setItem ('hederaView', this.view);
} }
@ -91,9 +91,9 @@ Hedera.Catalog = new Class
,onBasketReady: function (form) ,onBasketReady: function (form)
{ {
if (form.get ('method') != 'PICKUP') if (form.get ('method') != 'PICKUP')
Vn.Node.setText (this.$('method'), _('Agency')); Vn.Node.setText (this.$.method, _('Agency'));
else else
Vn.Node.setText (this.$('method'), _('Warehouse')); Vn.Node.setText (this.$.method, _('Warehouse'));
} }
,onOrderChange: function (e) ,onOrderChange: function (e)
@ -104,7 +104,7 @@ Hedera.Catalog = new Class
Db.Model.SortWay.ASC : Db.Model.SortWay.DESC; Db.Model.SortWay.ASC : Db.Model.SortWay.DESC;
if (sortField) if (sortField)
this.$('items').sortByName (sortField, sortWay); this.$.items.sortByName (sortField, sortWay);
this.hideMenu (); this.hideMenu ();
} }
@ -123,47 +123,33 @@ Hedera.Catalog = new Class
if (shouldRefresh) if (shouldRefresh)
{ {
var filterSql = this.$('filter').render (params); var filterSql = this.$.filter.render (params);
var modelParams = { var modelParams = {
filter: new Sql.String ({query: filterSql}) filter: new Sql.String ({query: filterSql})
}; };
this.$('items').refresh (modelParams); this.$.items.refresh (modelParams);
this.hideMenu (); this.hideMenu ();
this.$('order').style.display = 'block'; this.$.order.style.display = 'block';
} }
else else
{ {
this.$('items').clean (); this.$.items.clean ();
this.$('order').style.display = 'none'; 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 () ,onRealmChange: function ()
{ {
var newValue = this.params.$.realm; var newValue = this.params.$.realm;
this.$('filters').style.display = newValue ? 'block' : 'none'; this.$.filters.style.display = newValue ? 'block' : 'none';
this.$('realm-msg').style.display = newValue ? 'none' : 'block'; this.$.realmMsg.style.display = newValue ? 'none' : 'block';
this.refreshTitleColor (); this.refreshTitleColor ();
} }
,refreshTitleColor: function () ,refreshTitleColor: function ()
{ {
var realms = this.$('realms'); var realms = this.$.realms;
var realm = this.params.$.realm; var realm = this.params.$.realm;
var color = null; var color = null;
@ -175,12 +161,12 @@ Hedera.Catalog = new Class
color = '#'+ realms.get (row, 'color'); color = '#'+ realms.get (row, 'color');
} }
this.gui.$('top-bar').style.backgroundColor = color; this.gui.$.topBar.style.backgroundColor = color;
} }
,refreshTitle: function () ,refreshTitle: function ()
{ {
var types = this.$('types'); var types = this.$.types;
var type = this.params.$.type; var type = this.params.$.type;
var title = _('Catalog'); var title = _('Catalog');
@ -192,7 +178,7 @@ Hedera.Catalog = new Class
title = types.get (row, 'name'); title = types.get (row, 'name');
} }
Vn.Node.setText (this.$('title'), title); Vn.Node.setText (this.$.title, title);
} }
,onRightPanelClick: function (event) ,onRightPanelClick: function (event)
@ -205,7 +191,7 @@ Hedera.Catalog = new Class
this._menuShown = true; this._menuShown = true;
event.stopPropagation (); event.stopPropagation ();
this.gui.showBackground (); this.gui.showBackground ();
Vn.Node.addClass (this.$('right-panel'), 'show'); Vn.Node.addClass (this.$.rightPanel, 'show');
this.hideMenuCallback = this.hideMenu.bind (this); this.hideMenuCallback = this.hideMenu.bind (this);
document.addEventListener ('click', this.hideMenuCallback); document.addEventListener ('click', this.hideMenuCallback);
} }
@ -216,7 +202,7 @@ Hedera.Catalog = new Class
return; return;
this.gui.hideBackground (); this.gui.hideBackground ();
Vn.Node.removeClass (this.$('right-panel'), 'show'); Vn.Node.removeClass (this.$.rightPanel, 'show');
document.removeEventListener ('click', this.hideMenuCallback); document.removeEventListener ('click', this.hideMenuCallback);
this.hideMenuCallback = null; this.hideMenuCallback = null;
} }
@ -254,14 +240,14 @@ Hedera.Catalog = new Class
return; return;
this.onEraseClick (); this.onEraseClick ();
this.$('card').row = form.row; this.$.card.row = form.row;
this.$('card-lot').assign ({item: form.$.item_id}); this.$.cardLot.assign ({item: form.$.item_id});
this.$('card-popup').show (button.node); this.$.cardPopup.show (button.node);
} }
,onAddLotClick: function (column, value, rowIndex) ,onAddLotClick: function (column, value, rowIndex)
{ {
var row = this.$('item-lots').getObject (rowIndex); var row = this.$.itemLots.getObject (rowIndex);
var lotAmount = this.items[row.warehouse]; var lotAmount = this.items[row.warehouse];
if (lotAmount === undefined) if (lotAmount === undefined)
@ -275,7 +261,7 @@ Hedera.Catalog = new Class
newAmount = row.available; newAmount = row.available;
this.items[row.warehouse] = newAmount; this.items[row.warehouse] = newAmount;
this.$('amount').value += newAmount - lotAmount; this.$.amount.value += newAmount - lotAmount;
} }
else else
Htk.Toast.showError (_('NoMoreAmountAvailable')); Htk.Toast.showError (_('NoMoreAmountAvailable'));
@ -293,7 +279,7 @@ Hedera.Catalog = new Class
amountSum += amount; amountSum += amount;
var params = { var params = {
item: this.$('card-item').value, item: this.$.cardItem.value,
warehouse: warehouse, warehouse: warehouse,
amount: amount amount: amount
}; };
@ -304,30 +290,30 @@ Hedera.Catalog = new Class
{ {
this.conn.execQuery (sql); this.conn.execQuery (sql);
var itemName = this.$('card').$.Article; var itemName = this.$.card.$.Article;
Htk.Toast.showMessage ( Htk.Toast.showMessage (
sprintf (_('Added%dOf%s'), amountSum, itemName)); sprintf (_('Added%dOf%s'), amountSum, itemName));
} }
this.$('card-popup').hide (); this.$.cardPopup.hide ();
} }
,onEraseClick: function () ,onEraseClick: function ()
{ {
this.$('amount').value = 0; this.$.amount.value = 0;
this.items = {}; this.items = {};
} }
,onPopupClose: function () ,onPopupClose: function ()
{ {
this.onEraseClick (); this.onEraseClick ();
this.$('card').row = -1; this.$.card.row = -1;
this.$('card-item').value = undefined; this.$.cardItem.value = undefined;
} }
,onStatusChange: function () ,onStatusChange: function ()
{ {
this.$('card-popup').reset (); this.$.cardPopup.reset ();
} }
}); });

View File

@ -143,17 +143,15 @@
icon="add" icon="add"
on-click="onAddItemClick" on-click="onAddItemClick"
class="add-button"/> class="add-button"/>
<h2> <h2>{{Article}}</h2>
<htk-text lot="item" name="Article"/>
</h2>
<p class="producer"> <p class="producer">
<htk-text lot="item" name="producer"/> {{producer}}
</p> </p>
<p> <p>
<htk-text lot="item" name="item_id"/> @{{item_id}}
</p> </p>
<p> <p>
_Size <htk-text lot="item" name="Medida"/>, _Size <htk-text lot="item" name="Medida"/>
_Category <htk-text lot="item" name="Categoria"/> _Category <htk-text lot="item" name="Categoria"/>
</p> </p>
<p class="color"> <p class="color">
@ -191,7 +189,6 @@
<div class="categories"> <div class="categories">
<div class="realms"> <div class="realms">
<htk-repeater <htk-repeater
renderer="realmRenderer"
class="realms-box"> class="realms-box">
<db-model <db-model
id="realms" id="realms"
@ -204,8 +201,11 @@
ORDER BY name ORDER BY name
</db-model> </db-model>
<custom> <custom>
<a id="link" class="clickable"> <a class="clickable" href="#!form={{form}}&amp;realm={{id}}">
<img id="image"/> <img
src="image/family/light/{{id}}.svg"
title="{{name}}"
alt="{{name}}"/>
</a> </a>
</custom> </custom>
</htk-repeater> </htk-repeater>

View File

@ -17,8 +17,8 @@ Hedera.Checkout = new Class
,onValuesReady: function () ,onValuesReady: function ()
{ {
var orderForm = this.$('order-form'); var orderForm = this.$.orderForm;
var defaultsForm = this.$('defaults'); var defaultsForm = this.$.defaults;
if (!(orderForm.ready && defaultsForm.ready)) if (!(orderForm.ready && defaultsForm.ready))
return; return;
@ -43,7 +43,7 @@ Hedera.Checkout = new Class
date.setHours (0, 0, 0, 0); date.setHours (0, 0, 0, 0);
} }
this.$('lot').assign ({ this.$.lot.assign ({
date: date, date: date,
method: i.get ('delivery_method'), method: i.get ('delivery_method'),
agency: i.get ('agency_id'), agency: i.get ('agency_id'),
@ -54,9 +54,9 @@ Hedera.Checkout = new Class
,disableButtons: function (disable) ,disableButtons: function (disable)
{ {
this.$('confirm-agency').disabled = disable; this.$.confirmAgency.disabled = disable;
this.$('confirm-delivery').disabled = disable; this.$.confirmDelivery.disabled = disable;
this.$('confirm-pickup').disabled = disable; this.$.confirmPickup.disabled = disable;
} }
,onConfirmClick: function () ,onConfirmClick: function ()
@ -65,7 +65,7 @@ Hedera.Checkout = new Class
var query = 'CALL basketConfigure (#date, #method, #agency, #address)'; var query = 'CALL basketConfigure (#date, #method, #agency, #address)';
this.conn.execQuery (query, this.conn.execQuery (query,
this.onBasketConfigured.bind (this), this.$('lot').params); this.onBasketConfigured.bind (this), this.$.lot.params);
} }
,onBasketConfigured: function (resultSet) ,onBasketConfigured: function (resultSet)
@ -75,7 +75,7 @@ Hedera.Checkout = new Class
if (!resultSet.fetchResult ()) if (!resultSet.fetchResult ())
return; return;
if (this.$('order-form').numRows > 0) if (this.$.orderForm.numRows > 0)
Htk.Toast.showMessage (_('OrderUpdated')); Htk.Toast.showMessage (_('OrderUpdated'));
else else
Htk.Toast.showMessage (_('OrderStarted')); Htk.Toast.showMessage (_('OrderStarted'));
@ -85,7 +85,7 @@ Hedera.Checkout = new Class
,onCancelClick: function () ,onCancelClick: function ()
{ {
if (this.$('order-form').numRows > 0) if (this.$.orderForm.numRows > 0)
window.history.back(); window.history.back();
else else
this.hash.setAll ({'form': 'ecomerce/orders'}); this.hash.setAll ({'form': 'ecomerce/orders'});
@ -100,7 +100,7 @@ Hedera.Checkout = new Class
var steps; var steps;
var isDelivery; var isDelivery;
switch (this.$('rg-method').value) switch (this.$.rgMethod.value)
{ {
case 'AGENCY': case 'AGENCY':
steps = this.agencySteps; steps = this.agencySteps;
@ -125,18 +125,18 @@ Hedera.Checkout = new Class
switch (stepId) switch (stepId)
{ {
case 'date': case 'date':
Vn.Node.setText (this.$('date-question'), isDelivery ? Vn.Node.setText (this.$.dateQuestion, isDelivery ?
_('OrderDateDeliveryQuestion'): _('OrderDateDeliveryQuestion'):
_('OrderDatePickupQuestion')); _('OrderDatePickupQuestion'));
this.$('calendar').goToSelectedMonth (); this.$.calendar.goToSelectedMonth ();
break; break;
case 'agency': case 'agency':
case 'pickup': case 'pickup':
this.$('agencies').refresh (); this.$.agencies.refresh ();
break; break;
} }
return this.$(stepId +'-step'); return this.$[stepId +'Step'];
} }
,onFieldChange: function () ,onFieldChange: function ()
@ -147,18 +147,18 @@ Hedera.Checkout = new Class
,goNextStep: function () ,goNextStep: function ()
{ {
this.$('assistant').moveNext (); this.$.assistant.moveNext ();
} }
,addressRenderer: function (builder, form) ,addressRenderer: function (builder, form)
{ {
builder.$('address').addEventListener ('click', builder.$.address.addEventListener ('click',
this.onAddressClick.bind (this, form.get ('id'))); this.onAddressClick.bind (this, form.get ('id')));
} }
,onAddressClick: function (addressId) ,onAddressClick: function (addressId)
{ {
this.$('lot').set ('address', addressId); this.$.lot.set ('address', addressId);
this.goNextStep (); this.goNextStep ();
} }
@ -167,17 +167,17 @@ Hedera.Checkout = new Class
if (this.selectedNode) if (this.selectedNode)
Vn.Node.removeClass (this.selectedNode, 'selected'); 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) 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'); Vn.Node.addClass (this.selectedNode, 'selected');
} }
this.$('address-form').row = row; this.$.addressForm.row = row;
} }
,onAgenciesReady: function (model) ,onAgenciesReady: function (model)

View File

@ -27,13 +27,13 @@ Hedera.Confirm = new Class
if (order.method != 'PICKUP') if (order.method != 'PICKUP')
{ {
Vn.Node.show (this.$('address')); Vn.Node.show (this.$.address);
Vn.Node.setText (this.$('method'), _('Agency')); Vn.Node.setText (this.$.method, _('Agency'));
} }
else else
{ {
Vn.Node.hide (this.$('address')); Vn.Node.hide (this.$.address);
Vn.Node.setText (this.$('method'), _('Warehouse')); Vn.Node.setText (this.$.method, _('Warehouse'));
} }
var total = order.taxBase + order.vat; var total = order.taxBase + order.vat;
@ -57,12 +57,12 @@ Hedera.Confirm = new Class
if (order.credit > 0) if (order.credit > 0)
{ {
this.$('credit-info').style.display = 'table-row'; this.$.creditInfo.style.display = 'table-row';
if (creditExceededCond) if (creditExceededCond)
{ {
this.$('amount-selector').style.display = 'block'; this.$.amountSelector.style.display = 'block';
this.$('exceeded-info').style.display = 'table-row'; this.$.exceededInfo.style.display = 'table-row';
lot.payAmount = 'EXCEEDED'; lot.payAmount = 'EXCEEDED';
} }
} }
@ -88,9 +88,9 @@ Hedera.Confirm = new Class
} }
for (var i = 0; i < methods.length; i++) 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) ,onPayMethodChange: function (payMethod)
@ -98,21 +98,21 @@ Hedera.Confirm = new Class
var id = this.displayedInfo; var id = this.displayedInfo;
if (id) if (id)
Vn.Node.removeClass (this.$(id), 'selected'); Vn.Node.removeClass (this.$[id], 'selected');
switch (payMethod.value) switch (payMethod.value)
{ {
case 'BALANCE': case 'BALANCE':
id = 'balance-method'; id = 'balanceMethod';
break; break;
case 'CREDIT': case 'CREDIT':
id = 'credit-method'; id = 'creditMethod';
break; break;
case 'CARD': case 'CARD':
id = 'card-method'; id = 'cardMethod';
break; break;
case 'TRANSFER': case 'TRANSFER':
id = 'transfer-method'; id = 'transferMethod';
break; break;
default: default:
id = null; id = null;
@ -121,13 +121,13 @@ Hedera.Confirm = new Class
this.displayedInfo = id; this.displayedInfo = id;
if (id) if (id)
Vn.Node.addClass (this.$(id), 'selected'); Vn.Node.addClass (this.$[id], 'selected');
} }
,disableButtons: function (disable) ,disableButtons: function (disable)
{ {
this.$('modify').disabled = disable; this.$.modify.disabled = disable;
this.$('confirm').disabled = disable; this.$.confirm.disabled = disable;
} }
,onModifyClick: function () ,onModifyClick: function ()
@ -137,9 +137,9 @@ Hedera.Confirm = new Class
,onConfirmClick: function () ,onConfirmClick: function ()
{ {
console.log (this.$('lot').params); console.log (this.$.lot.params);
this.disableButtons (true); this.disableButtons (true);
this.$('confirm-query').execute (); this.$.confirmQuery.execute ();
} }
,onConfirm: function (query, resultSet) ,onConfirm: function (query, resultSet)
@ -147,16 +147,16 @@ Hedera.Confirm = new Class
this.disableButtons (false); this.disableButtons (false);
if (resultSet.fetchResult ()) if (resultSet.fetchResult ())
this.$('success-dialog').show (); this.$.successDialog.show ();
} }
,onDialogResponse: function () ,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; var payAmount = lot.exceededCredit;
else else
var payAmount = lot.totalDebt; var payAmount = lot.totalDebt;
@ -165,7 +165,7 @@ Hedera.Confirm = new Class
conn: this.conn, conn: this.conn,
hash: this.hash hash: this.hash
}); });
tpv.pay (payAmount, this.$('order').get ('company')); tpv.pay (payAmount, this.$.order.get ('company'));
} }
else else
this.hash.params = {form: 'ecomerce/orders'}; this.hash.params = {form: 'ecomerce/orders'};

View File

@ -25,7 +25,7 @@ Hedera.Orders = new Class
,_onTpvCheck: function (tpv, tpvOrder, tpvStatus) ,_onTpvCheck: function (tpv, tpvOrder, tpvStatus)
{ {
if (tpvStatus === 'ko') if (tpvStatus === 'ko')
this.$('error-dialog').show (); this.$.errorDialog.show ();
} }
,onBasketClick: function () ,onBasketClick: function ()
@ -35,7 +35,7 @@ Hedera.Orders = new Class
,repeaterFunc: function (res, form) ,repeaterFunc: function (res, form)
{ {
res.$('link').href = this.hash.make ({ res.$.link.href = this.hash.make ({
form: 'ecomerce/ticket', form: 'ecomerce/ticket',
ticket: form.get ('ticket_id') ticket: form.get ('ticket_id')
}); });
@ -46,14 +46,14 @@ Hedera.Orders = new Class
,balanceConditionalFunc: function (field, value) ,balanceConditionalFunc: function (field, value)
{ {
if (value >= 0) if (value >= 0)
Vn.Node.removeClass (this.$('balance'), 'negative'); Vn.Node.removeClass (this.$.balance, 'negative');
else else
Vn.Node.addClass (this.$('balance'), 'negative'); Vn.Node.addClass (this.$.balance, 'negative');
} }
,onPayButtonClick: function () ,onPayButtonClick: function ()
{ {
var amount = -this.$('debt').get('debt'); var amount = -this.$.debt.$.debt;
amount = amount <= 0 ? null : amount; amount = amount <= 0 ? null : amount;

View File

@ -60,15 +60,9 @@
<p class="important"> <p class="important">
<htk-text lot="iter" name="date" format="%D"/> <htk-text lot="iter" name="date" format="%D"/>
</p> </p>
<p> <p>@{{ticket_id}}</p>
<htk-text lot="iter" name="ticket_id"/> <p>{{consignee}}</p>
</p> <p>{{type}}</p>
<p>
<htk-text lot="iter" name="consignee"/>
</p>
<p>
<htk-text lot="iter" name="type"/>
</p>
</a> </a>
</custom> </custom>
</htk-repeater> </htk-repeater>

View File

@ -24,9 +24,9 @@ Hedera.Ticket = new Class
column.value = this.subtotal (form); 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) ,subtotal: function (form)

View File

@ -68,12 +68,10 @@
subdir="200x200" subdir="200x200"
full-dir="900x900"/> full-dir="900x900"/>
<p class="concept"> <p class="concept">
<htk-text lot="iter" name="concept"/> {{concept}} {{Medida}} {{Categoria}}
<htk-text lot="iter" name="Medida"/>
<htk-text lot="iter" name="Categoria"/>
</p> </p>
<p class="amount"> <p class="amount">
<htk-text lot="iter" name="amount"/> x {{amount}} x
<htk-text lot="iter" name="price" format="%.2d€"/> <htk-text lot="iter" name="price" format="%.2d€"/>
<span class="subtotal"> <span class="subtotal">
<htk-text id="subtotal" format="%.2d€"/> <htk-text id="subtotal" format="%.2d€"/>

View File

@ -10,13 +10,13 @@ Hedera.New = new Class
,activate: function () ,activate: function ()
{ {
this.$('model').mode = Db.Model.Mode.ON_DEMAND; this.$.model.mode = Db.Model.Mode.ON_DEMAND;
this.$('model').setDefault ('user_id', 'news', this.$.model.setDefault ('user_id', 'news',
new Sql.Function ({schema: 'account', name: 'userGetId'})); new Sql.Function ({schema: 'account', name: 'userGetId'}));
tinymce.init ({ tinymce.init ({
mode : 'exact' mode : 'exact'
,target: this.$('html-editor') ,target: this.$.htmlEditor
,plugins: [ ,plugins: [
"advlist autolink lists link image charmap print preview hr" "advlist autolink lists link image charmap print preview hr"
,"anchor pagebreak searchreplace wordcount visualblocks" ,"anchor pagebreak searchreplace wordcount visualblocks"
@ -53,7 +53,7 @@ Hedera.New = new Class
if (!this.editor) if (!this.editor)
return; return;
var newHtml = this.$('iter').get ('text'); var newHtml = this.$.iter.get ('text');
if (!newHtml) if (!newHtml)
newHtml = ''; newHtml = '';
@ -80,8 +80,8 @@ Hedera.New = new Class
,onAcceptClick: function () ,onAcceptClick: function ()
{ {
this.$('iter').set ('text', this.editor.getContent ()); this.$.iter.set ('text', this.editor.getContent ());
this.$('iter').performOperations (); this.$.iter.performOperations ();
} }
,onReturnClick: function () ,onReturnClick: function ()

View File

@ -11,17 +11,17 @@ Hedera.News = new Class
,repeaterFunc: function (res, form) ,repeaterFunc: function (res, form)
{ {
res.$('link').href = this.hash.make ({ res.$.link.href = this.hash.make ({
'form': 'news/new', form: 'news/new',
'new': form.get ('id') new: form.$.id
}); });
} }
,onAddClick: function () ,onAddClick: function ()
{ {
this.hash.setAll ({ this.hash.setAll ({
'form': 'news/new', form: 'news/new',
'new': 0 new: 0
}); });
} }
}); });

View File

@ -37,10 +37,10 @@
editable="true" editable="true"
conn="conn"/> conn="conn"/>
<p class="important"> <p class="important">
<htk-text lot="iter" name="title"/> {{title}}
</p> </p>
<p> <p>
<htk-text lot="iter" name="Cliente"/> {{Cliente}}
</p> </p>
<p> <p>
_Priority _Priority

View File

@ -5,7 +5,7 @@ Hedera.ItemsForm = new Class
,activate: function () ,activate: function ()
{ {
this.$('lot').assign ({ this.$.lot.assign ({
warehouse: 7, warehouse: 7,
realm: null realm: null
}); });
@ -13,7 +13,7 @@ Hedera.ItemsForm = new Class
,onShowClick: function () ,onShowClick: function ()
{ {
this.gui.openReport ('items-report', this.$('lot').params); this.gui.openReport ('items-report', this.$.lot.$);
} }
}); });

View File

@ -5,7 +5,7 @@ Hedera.Shelves = new Class
,activate: function () ,activate: function ()
{ {
this.$('lot').assign ({ this.$.lot.assign ({
date: new Date (), date: new Date (),
useIds: false useIds: false
}); });
@ -13,12 +13,12 @@ Hedera.Shelves = new Class
,onConfigChange: function () ,onConfigChange: function ()
{ {
this.$('lot').assignLot (this.$('config')); this.$.lot.assignLot (this.$.config);
} }
,onShowClick: function () ,onShowClick: function ()
{ {
this.gui.openReport ('shelves-report', this.$('lot').params); this.gui.openReport ('shelves-report', this.$.lot.$);
} }
}); });

View File

@ -41,11 +41,12 @@ module.exports = new Class
conn: this.conn, conn: this.conn,
hash: this.hash 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.scope = scope;
this._node = this.$('main'); this.$ = scope.$;
this._node = this.$.main;
var paramsLot = this.$('params'); var paramsLot = this.$.params;
if (paramsLot) if (paramsLot)
{ {
@ -68,8 +69,8 @@ module.exports = new Class
if (this.node) if (this.node)
{ {
this.gui.setForm (this.node); this.gui.setForm (this.node);
this.gui.setTitle (scope.$('title')); this.gui.setTitle (scope.$.title);
this.gui.setActions (scope.$('actions')); this.gui.setActions (scope.$.actions);
this.activate (); this.activate ();
} }

View File

@ -57,22 +57,22 @@ module.exports = new Class
this.loadTemplateFromString (Tpl); this.loadTemplateFromString (Tpl);
this.loadingCount = 0; 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 (); event.stopPropagation ();
this.showMenu (); this.showMenu ();
}.bind (this)); }.bind (this));
this.$('left-panel').addEventListener ('click', function (event) this.$.leftPanel.addEventListener ('click', function (event)
{ {
event.stopPropagation (); event.stopPropagation ();
}); });
this.parent (props); this.parent (props);
this.$('social-bar').conn = this._conn; this.$.socialBar.conn = this._conn;
var sql = 'SELECT name FROM customer_user;' var sql = 'SELECT name FROM customer_user;'
+'SELECT default_form, image_dir, image_host FROM config;' +'SELECT default_form, image_dir, image_host FROM config;'
@ -89,7 +89,7 @@ module.exports = new Class
this._shown = true; this._shown = true;
this.doc.body.appendChild (this.node); this.doc.body.appendChild (this.node);
Htk.Toast.pushTop (this.$('form-holder')); Htk.Toast.pushTop (this.$.formHolder);
if (Vn.isMobile ()) if (Vn.isMobile ())
{ {
@ -155,7 +155,7 @@ module.exports = new Class
// Retrieving the user name // Retrieving the user name
var userName = resultSet.fetchValue (); var userName = resultSet.fetchValue ();
Vn.Node.setText (this.$('user-name'), userName); Vn.Node.setText (this.$.userName, userName);
// Retrieving configuration parameters // Retrieving configuration parameters
@ -178,11 +178,11 @@ module.exports = new Class
var linkField = 'test_domain'; var linkField = 'test_domain';
} }
Vn.Node.setText (this.$('test-link'), _(linkText)); Vn.Node.setText (this.$.testLink, _(linkText));
this.$('test-link').href = '//'+ row[linkField]; this.$.testLink.href = '//'+ row[linkField];
} }
else else
Vn.Node.hide (this.$('test-link')); Vn.Node.hide (this.$.testLink);
// Loading the default form // Loading the default form
@ -214,8 +214,8 @@ module.exports = new Class
sectionMap[parent].push (i); sectionMap[parent].push (i);
} }
Vn.Node.removeChilds (this.$('main-menu')); Vn.Node.removeChilds (this.$.mainMenu);
this.createMenu (res, sectionMap, null, this.$('main-menu')); this.createMenu (res, sectionMap, null, this.$.mainMenu);
} }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu
@ -301,7 +301,7 @@ module.exports = new Class
,showMenu: function () ,showMenu: function ()
{ {
this.showBackground (); this.showBackground ();
Vn.Node.addClass (this.$('left-panel'), 'show'); Vn.Node.addClass (this.$.leftPanel, 'show');
this._menuShown = true; this._menuShown = true;
this.hideMenuCallback = this.hideMenu.bind (this); this.hideMenuCallback = this.hideMenu.bind (this);
@ -314,7 +314,7 @@ module.exports = new Class
return; return;
this.hideBackground (); this.hideBackground ();
Vn.Node.removeClass (this.$('left-panel'), 'show'); Vn.Node.removeClass (this.$.leftPanel, 'show');
this._menuShown = false; this._menuShown = false;
this.doc.removeEventListener ('click', this.hideMenuCallback); this.doc.removeEventListener ('click', this.hideMenuCallback);
@ -335,7 +335,7 @@ module.exports = new Class
if (!this._shown) if (!this._shown)
return; return;
var navbar = this.$('top-bar'); var navbar = this.$.topBar;
var yOffset = window.pageYOffset; var yOffset = window.pageYOffset;
var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight; var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight;
@ -359,12 +359,12 @@ module.exports = new Class
,showBackground: function () ,showBackground: function ()
{ {
Vn.Node.addClass (this.$('background'), 'show'); Vn.Node.addClass (this.$.background, 'show');
} }
,hideBackground: function () ,hideBackground: function ()
{ {
Vn.Node.removeClass (this.$('background'), 'show'); Vn.Node.removeClass (this.$.background, 'show');
} }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner
@ -374,7 +374,7 @@ module.exports = new Class
this.loadingCount++; this.loadingCount++;
if (this.loadingCount == 1) if (this.loadingCount == 1)
this.$('loader').start (); this.$.loader.start ();
} }
,loaderPop: function () ,loaderPop: function ()
@ -385,7 +385,7 @@ module.exports = new Class
this.loadingCount--; this.loadingCount--;
if (this.loadingCount == 0) if (this.loadingCount == 0)
this.$('loader').stop (); this.$.loader.stop ();
} }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms
@ -447,31 +447,31 @@ module.exports = new Class
,setForm: function (form) ,setForm: function (form)
{ {
Vn.Node.removeChilds (this.$('form-holder')); Vn.Node.removeChilds (this.$.formHolder);
if (form) if (form)
{ {
var div = this.createElement('div'); var div = this.createElement('div');
div.appendChild (form); div.appendChild (form);
this.$('form-holder').appendChild (div); this.$.formHolder.appendChild (div);
setTimeout (this._onSetFormTimeout.bind (this), 10); setTimeout (this._onSetFormTimeout.bind (this), 10);
} }
} }
,_onSetFormTimeout: function () ,_onSetFormTimeout: function ()
{ {
Vn.Node.addClass (this.$('form-holder').firstChild, 'slide'); Vn.Node.addClass (this.$.formHolder.firstChild, 'slide');
} }
,setTitle: function (title) ,setTitle: function (title)
{ {
Vn.Node.setChild (this.$('title'), title); Vn.Node.setChild (this.$.title, title);
} }
,setActions: function (actions) ,setActions: function (actions)
{ {
Vn.Node.setChild (this.$('action-bar'), actions); Vn.Node.setChild (this.$.actionBar, actions);
} }
,closeForm: function () ,closeForm: function ()
@ -525,13 +525,13 @@ module.exports = new Class
,_onSupplantName: function (resultSet) ,_onSupplantName: function (resultSet)
{ {
var userName = resultSet.fetchValue (); var userName = resultSet.fetchValue ();
Vn.Node.setText (this.$('supplanted'), userName); Vn.Node.setText (this.$.supplanted, userName);
Vn.Node.show (this.$('supplant')); Vn.Node.show (this.$.supplant);
} }
,onSupplantExitClick: function () ,onSupplantExitClick: function ()
{ {
Vn.Node.hide (this.$('supplant')); Vn.Node.hide (this.$.supplant);
this._conn.supplantEnd (); this._conn.supplantEnd ();
this.loadMenu (); this.loadMenu ();
this._onFormChange (); this._onFormChange ();

View File

@ -33,10 +33,10 @@ module.exports = new Class
this.parent (props); this.parent (props);
this.loadTemplateFromString (Tpl); this.loadTemplateFromString (Tpl);
this.$('social-bar').conn = this._conn; this.$.socialBar.conn = this._conn;
var self = this; var self = this;
this.$('form').onsubmit = function () this.$.form.onsubmit = function ()
{ {
self._onSubmit (); self._onSubmit ();
return false; return false;
@ -50,7 +50,7 @@ module.exports = new Class
var lastUser = localStorage.getItem ('hederaLastUser'); var lastUser = localStorage.getItem ('hederaLastUser');
if (lastUser) if (lastUser)
this.$('user').value = lastUser; this.$.user.value = lastUser;
this._focusUserInput (); this._focusUserInput ();
} }
@ -63,17 +63,17 @@ module.exports = new Class
,_onConnLoadChange: function (conn, isLoading) ,_onConnLoadChange: function (conn, isLoading)
{ {
if (isLoading) if (isLoading)
this.$('spinner').start (); this.$.spinner.start ();
else else
this.$('spinner').stop (); this.$.spinner.stop ();
} }
,_onSubmit: function () ,_onSubmit: function ()
{ {
this._conn.open ( this._conn.open (
this.$('user').value, this.$.user.value,
this.$('pass').value, this.$.pass.value,
this.$('remember').checked, this.$.remember.checked,
this._onConnOpen.bind (this) this._onConnOpen.bind (this)
); );
this._disableUi (true); this._disableUi (true);
@ -81,12 +81,12 @@ module.exports = new Class
,_onConnOpen: function (conn, success, error) ,_onConnOpen: function (conn, success, error)
{ {
this.$('pass').value = ''; this.$.pass.value = '';
this._disableUi (false); this._disableUi (false);
if (success) if (success)
{ {
var user = this.$('user').value; var user = this.$.user.value;
if (user) if (user)
localStorage.setItem ('hederaLastUser', user); localStorage.setItem ('hederaLastUser', user);
@ -102,21 +102,21 @@ module.exports = new Class
,_focusUserInput: function () ,_focusUserInput: function ()
{ {
var userEntry = this.$('user'); var userEntry = this.$.user;
userEntry.focus (); userEntry.focus ();
userEntry.select (); userEntry.select ();
} }
,_disableUi: function (disabled) ,_disableUi: function (disabled)
{ {
this.$('user').disabled = disabled; this.$.user.disabled = disabled;
this.$('pass').disabled = disabled; this.$.pass.disabled = disabled;
this.$('submit').disabled = disabled; this.$.submit.disabled = disabled;
} }
,onPasswordLost: function () ,onPasswordLost: function ()
{ {
var user = this.$('user').value; var user = this.$.user.value;
if (!user) if (!user)
Htk.Toast.showError (_('Please write your user name')); Htk.Toast.showError (_('Please write your user name'));

View File

@ -53,6 +53,6 @@ module.exports = new Class
hash: this.hash hash: this.hash
}; };
this.loadScope (builder, null, extraObjects); this.loadScope (builder, null, extraObjects);
this.body.appendChild (this.$('report')); this.body.appendChild (this.$.report);
} }
}); });

View File

@ -25,7 +25,7 @@ module.exports = new Class
this.loadTemplateFromString (Tpl); this.loadTemplateFromString (Tpl);
var self = this; var self = this;
this.$('form').onsubmit = function () this.$.form.onsubmit = function ()
{ self._onSubmit (); return false; }; { self._onSubmit (); return false; };
this.parent (props); this.parent (props);
@ -33,7 +33,7 @@ module.exports = new Class
,onNameChange: function () ,onNameChange: function ()
{ {
var newValue = this.$('name').value; var newValue = this.$.name.value;
if (!newValue) if (!newValue)
newValue = null newValue = null
@ -43,29 +43,29 @@ module.exports = new Class
,_onSubmit: function () ,_onSubmit: function ()
{ {
this.$('submit').disabled = true; this.$.submit.disabled = true;
this.$('spinner').start (); this.$.spinner.start ();
this.conn.sendFormMultipart (this.$('form'), this.conn.sendFormMultipart (this.$.form,
this._onResponse.bind (this)); this._onResponse.bind (this));
} }
,_onResponse: function (json, error) ,_onResponse: function (json, error)
{ {
this.$('submit').disabled = false; this.$.submit.disabled = false;
this.$('spinner').stop (); this.$.spinner.stop ();
if (error) if (error)
throw error; throw error;
Toast.showMessage (_('ImageAdded')); Toast.showMessage (_('ImageAdded'));
this.emit ('file-uploaded', this.$('name').value); this.emit ('file-uploaded', this.$.name.value);
} }
,setData: function (image, directory) ,setData: function (image, directory)
{ {
this.$('name').value = image; this.$.name.value = image;
this.$('schema').value = directory; this.$.schema.value = directory;
} }
}); });

View File

@ -71,7 +71,7 @@ module.exports = new Class
} }
,_builder: null ,_builder: null
,_formId: 'form' ,_formId: 'iter'
,_parentScope: null ,_parentScope: null
,render: function () ,render: function ()
@ -119,7 +119,7 @@ module.exports = new Class
var extraObjects = {}; var extraObjects = {};
extraObjects[this._formId] = set; 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 (); scope.link ();
this._childsData.push ({ this._childsData.push ({

View File

@ -1,6 +1,7 @@
var VnObject = require ('./object'); var VnObject = require ('./object');
var Scope = require ('./scope'); var Scope = require ('./scope');
var kebabToCamel = require ('./string-util').kebabToCamel;
var CompilerObject = require ('./compiler-object'); var CompilerObject = require ('./compiler-object');
var CompilerElement = require ('./compiler-element'); var CompilerElement = require ('./compiler-element');
@ -148,7 +149,7 @@ module.exports = new Class
if (nodeId) if (nodeId)
{ {
this._contextMap[nodeId] = context.id; this._contextMap[kebabToCamel (nodeId)] = context.id;
context.nodeId = nodeId; context.nodeId = nodeId;
} }
@ -170,9 +171,10 @@ module.exports = new Class
* @param {Document} dstDocument The document used to create the nodes * @param {Document} dstDocument The document used to create the nodes
* @param {Object} signalData The object where to bind methods * @param {Object} signalData The object where to bind methods
* @param {Scope} parentScope The parent scope or %null for no parent * @param {Scope} parentScope The parent scope or %null for no parent
* @param {Lot} lot The default lot
* @return {Scope} The created scope * @return {Scope} The created scope
*/ */
,load: function (dstDocument, signalData, parentScope, extraObjects) ,load: function (dstDocument, signalData, parentScope, extraObjects, lot)
{ {
if (this._contexts === null) if (this._contexts === null)
return null; return null;
@ -181,7 +183,7 @@ module.exports = new Class
var contexts = this._contexts; var contexts = this._contexts;
var len = contexts.length; var len = contexts.length;
var objects = new Array (len); 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++) for (var i = 0; i < len; i++)
{ {
@ -189,6 +191,7 @@ module.exports = new Class
objects[i] = context.compiler.instantiate (doc, context, scope); objects[i] = context.compiler.instantiate (doc, context, scope);
} }
scope.init (extraObjects);
return scope; return scope;
} }
@ -242,11 +245,6 @@ module.exports = new Class
return result.objects[this._mainContext]; return result.objects[this._mainContext];
} }
,getById: function (objectId)
{
return this._contextMap[objectId];
}
,getByTagName: function (scope, tagName) ,getByTagName: function (scope, tagName)
{ {
var tags = this._tags[tagName]; var tags = this._tags[tagName];

View File

@ -65,7 +65,7 @@ module.exports = new Class
var props = context.props; var props = context.props;
for (var prop in props) for (var prop in props)
object.setAttribute (prop, props[prop]); object.setAttribute (prop, scope.interpolate (props[prop]));
if (context.nodeId) if (context.nodeId)
object.setAttribute ('id', scope.getHtmlId (context.nodeId)); object.setAttribute ('id', scope.getHtmlId (context.nodeId));
@ -78,7 +78,7 @@ module.exports = new Class
var props = context.objectProps; var props = context.objectProps;
for (var prop in props) for (var prop in props)
{ {
var objectValue = scope.$(props[prop]); var objectValue = scope.$[props[prop]];
var htmlId; var htmlId;
if (objectValue instanceof Component) if (objectValue instanceof Component)

View File

@ -180,7 +180,7 @@ module.exports = new Class
this._links.push ({ this._links.push ({
context: context context: context
,prop: prop ,prop: prop
,objectId: objectId ,objectId: kebabToCamel (objectId)
}); });
} }
@ -204,7 +204,7 @@ module.exports = new Class
{ {
var link = links[i]; var link = links[i];
var object = objects[link.context.id]; var object = objects[link.context.id];
var objectRef = scope.$(link.objectId); var objectRef = scope.$[link.objectId];
if (objectRef == null) if (objectRef == null)
{ {

View File

@ -31,8 +31,8 @@ module.exports = new Class
return {text: text}; return {text: text};
} }
,instantiate: function (doc, context) ,instantiate: function (doc, context, scope)
{ {
return doc.createTextNode (context.text); return doc.createTextNode (scope.interpolate (context.text));
} }
}); });

View File

@ -57,11 +57,12 @@ module.exports = new Class
{ {
return this._htmlId; return this._htmlId;
} }
} },
} }
,_node: null ,_node: null
,scope: null ,scope: null
,$: {}
,initialize: function (props) ,initialize: function (props)
{ {
@ -127,29 +128,16 @@ module.exports = new Class
{ {
var scope = builder.load (this.doc, this, parentScope, extraObjects); var scope = builder.load (this.doc, this, parentScope, extraObjects);
this.scope = scope; this.scope = scope;
this._node = this.$('main');
scope.link (); scope.link ();
this.$ = scope.$;
this._node = this.$.main;
return scope; 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 () ,_destroy: function ()
{ {
if (this.builder) if (this.scope)
this.builder.unref (); this.scope.unref ();
this.parent (); this.parent ();
} }

View File

@ -7,14 +7,14 @@ module.exports = new Class
({ ({
Extends: VnObject Extends: VnObject
,initialize: function (builder, objects, signalData, parentScope, extraObjects) ,initialize: function (builder, objects, signalData, parentScope, lot)
{ {
this.builder = builder; this.builder = builder;
this.objects = objects; this.objects = objects;
this.signalData = signalData; this.signalData = signalData;
this.parentScope = parentScope; this.parentScope = parentScope;
this.uid = ++scopeUid; this.uid = ++scopeUid;
this.extraObjects = extraObjects; this.lot = lot;
if (!signalData && parentScope) if (!signalData && parentScope)
this.signalData = parentScope.signalData; this.signalData = parentScope.signalData;
@ -22,46 +22,23 @@ module.exports = new Class
this.parent (); 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 () ,getMain: function ()
{ {
return this.builder.getMain (this); 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. * Fetchs a set of elements by it's tag name.
* *
@ -81,6 +58,34 @@ module.exports = new Class
this.builder.link (this); 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) ,getMethod: function (value, binded)
{ {
if (this.signalData) if (this.signalData)