- {{amount}} x
+ {{amount}} x
diff --git a/js/db/db.js b/js/db/db.js
index 975fe107..12125233 100644
--- a/js/db/db.js
+++ b/js/db/db.js
@@ -6,6 +6,7 @@ Db = module.exports = {
,Result : require ('./result')
,ResultSet : require ('./result-set')
,Model : require ('./model')
+ ,Lot : require ('./lot')
,Query : require ('./query')
,Calc : require ('./calc')
,CalcSum : require ('./calc-sum')
diff --git a/js/db/lot.js b/js/db/lot.js
new file mode 100644
index 00000000..0be4d385
--- /dev/null
+++ b/js/db/lot.js
@@ -0,0 +1,84 @@
+
+var Connection = require ('./connection');
+var Model = require ('./model');
+
+module.exports = new Class
+({
+ Extends: Vn.Form
+ ,Tag: 'db-lot'
+ ,Properties:
+ {
+ /**
+ * The connection used to execute the statement.
+ */
+ conn:
+ {
+ type: Connection
+ ,set: function (x)
+ {
+ this.model.conn = x;
+ }
+ ,get: function ()
+ {
+ return this.model.conn;
+ }
+ },
+ /**
+ * The model query.
+ */
+ query:
+ {
+ type: String
+ ,set: function (x)
+ {
+ this.model.query = x;
+ }
+ ,get: function ()
+ {
+ return this.model.query;
+ }
+ },
+ /**
+ * The model select statement.
+ */
+ stmt:
+ {
+ type: Sql.Stmt
+ ,set: function (x)
+ {
+ this.model.stmt = x;
+ }
+ ,get: function ()
+ {
+ return this.model.stmt;
+ }
+ },
+ /**
+ * The lot used to execute the statement.
+ */
+ lot:
+ {
+ type: Vn.Lot
+ ,set: function (x)
+ {
+ this.model.lot = x;
+ }
+ ,get: function ()
+ {
+ return this.model.lot;
+ }
+ }
+ }
+
+ ,initialize: function (props)
+ {
+ this.model = new Model ();
+ this.parent (props);
+ }
+
+ ,appendChild: function (child)
+ {
+ if (child.nodeType === Node.TEXT_NODE)
+ this.query = child.textContent;
+ }
+});
diff --git a/js/db/query.js b/js/db/query.js
index c9c7e7c3..b23f30d3 100644
--- a/js/db/query.js
+++ b/js/db/query.js
@@ -90,7 +90,7 @@ module.exports = new Class
,execute: function ()
{
this._conn.execStmt (this._stmt,
- this.onQueryDone.bind (this), this._batch);
+ this.onQueryDone.bind (this), this._lot ? this._lot.$ : null);
}
,onQueryDone: function (resultSet)
@@ -100,7 +100,7 @@ module.exports = new Class
,onChange: function ()
{
- if (this.autoLoad && this._conn && this._stmt && this._batch)
+ if (this.autoLoad && this._conn && this._stmt && this._lot)
this.execute ();
}
});
diff --git a/js/hedera/app.js b/js/hedera/app.js
index 92db4264..78469ccb 100644
--- a/js/hedera/app.js
+++ b/js/hedera/app.js
@@ -118,8 +118,12 @@ module.exports = new Class
case 'OutdatedVersion':
this._newVersion ();
break;
- default:
+ case 'User':
Htk.Toast.showError (error.message);
+ break;
+ default:
+ Htk.Toast.showError (_('Something went wrong'));
+ console.error (error.message);
}
else
{
@@ -160,10 +164,10 @@ module.exports = new Class
Htk.Toast.showError (_('Something went wrong'));
var params = {
- 'file': error.fileName
- ,'line': error.lineNumber
- ,'message': error.message
- ,'stack': error.stack
+ file: error.fileName
+ ,line: error.lineNumber
+ ,message: error.message
+ ,stack: error.stack
};
this._conn.send ('core/log', params);
}
diff --git a/js/hedera/form.js b/js/hedera/form.js
index 1c3d276a..02af45b7 100644
--- a/js/hedera/form.js
+++ b/js/hedera/form.js
@@ -37,11 +37,14 @@ module.exports = new Class
var builder = new Vn.Builder ();
builder.compileFile ('forms/'+ this.formInfo.path +'/ui.xml');
+ var conn = this.conn;
+ var hash = this.hash;
+
var extraObjects = {
- conn: this.conn,
- hash: this.hash
+ conn: conn,
+ hash: hash
};
- var scope = builder.load (this.doc, this, null, extraObjects, this.hash);
+ var scope = builder.load (this.doc, this, null, extraObjects, hash);
this.scope = scope;
this.$ = scope.$;
this._node = this.$.main;
@@ -50,21 +53,22 @@ module.exports = new Class
if (paramsLot)
{
- paramsLot.source = this.hash;
+ paramsLot.source = hash;
this.params = paramsLot;
}
scope.link ();
- var models = scope.getByTagName ('db-model');
+ function setConnection (tagName)
+ {
+ var objects = scope.getByTagName (tagName);
+ for (var i = 0; i < objects.length; i++)
+ objects[i].conn = conn;
+ }
- for (var i = 0; i < models.length; i++)
- models[i].conn = this.conn;
-
- var queries = scope.getByTagName ('db-query');
-
- for (var i = 0; i < queries.length; i++)
- queries[i].conn = this.conn;
+ var tags = ['db-model', 'db-query', 'db-lot'];
+ for (var i = 0; i < tags.length; i++)
+ setConnection (tags[i]);
if (this.node)
{
diff --git a/js/hedera/gui.js b/js/hedera/gui.js
index a29fce9a..ee5f6a2f 100644
--- a/js/hedera/gui.js
+++ b/js/hedera/gui.js
@@ -57,31 +57,16 @@ module.exports = new Class
this.loadTemplateFromString (Tpl);
this.loadingCount = 0;
- this.$.background.onclick = function () {};
-
- this.$.menuButton.addEventListener ('click', function (event)
- {
- event.stopPropagation ();
- this.showMenu ();
- }.bind (this));
-
- this.$.leftPanel.addEventListener ('click', function (event)
- {
- event.stopPropagation ();
- });
-
this.parent (props);
this.$.socialBar.conn = this._conn;
-
- var sql = 'SELECT name FROM customer_user;'
- +'SELECT default_form, image_dir, image_host FROM config;'
- +'SELECT production_domain, test_domain FROM config;';
- this._conn.execQuery (sql, this.onMainQueryDone.bind (this));
+ this.$.user.conn = this._conn;
+ this.$.configQuery.conn = this._conn;
+ this.$.configQuery.execute ();
this.loadMenu ();
}
-
+
,show: function ()
{
if (this._shown)
@@ -150,13 +135,8 @@ module.exports = new Class
this.loaderPop ();
}
- ,onMainQueryDone: function (resultSet)
+ ,onConfigQueryReady: function (query, resultSet)
{
- // Retrieving the user name
-
- var userName = resultSet.fetchValue ();
- Vn.Node.setText (this.$.userName, userName);
-
// Retrieving configuration parameters
Object.assign (Vn.Config, resultSet.fetchObject ());
@@ -178,8 +158,10 @@ module.exports = new Class
var linkField = 'test_domain';
}
- Vn.Node.setText (this.$.testLink, _(linkText));
- this.$.testLink.href = '//'+ row[linkField];
+ this.$.newVersion.assign ({
+ text: _(linkText),
+ link: '//'+ row[linkField]
+ });
}
else
Vn.Node.hide (this.$.testLink);
@@ -298,6 +280,17 @@ module.exports = new Class
}
}
+ ,onMenuButtonClick: function (event)
+ {
+ event.stopPropagation ();
+ this.showMenu ();
+ }
+
+ ,onLeftPanelClick: function (event)
+ {
+ event.stopPropagation ();
+ }
+
,showMenu: function ()
{
this.showBackground ();
@@ -335,7 +328,7 @@ module.exports = new Class
if (!this._shown)
return;
- var navbar = this.$.topBar;
+ var navbar = this.$.navbar;
var yOffset = window.pageYOffset;
var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight;
@@ -357,6 +350,8 @@ module.exports = new Class
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Background
+ ,onBackgroundClick: function () {}
+
,showBackground: function ()
{
Vn.Node.addClass (this.$.background, 'show');
diff --git a/js/hedera/gui.xml b/js/hedera/gui.xml
index ab26d747..82ee799b 100755
--- a/js/hedera/gui.xml
+++ b/js/hedera/gui.xml
@@ -1,14 +1,22 @@
+
+
+ SELECT name FROM customer_user
+
+
+ SELECT default_form, image_dir, image_host FROM config;
+ SELECT production_domain, test_domain FROM config;
+
-
+
-
+
diff --git a/js/htk/repeater.js b/js/htk/repeater.js
index 284a061b..d11df339 100644
--- a/js/htk/repeater.js
+++ b/js/htk/repeater.js
@@ -3,7 +3,6 @@ module.exports = new Class
({
Extends: Vn.Component
,Tag: 'htk-repeater'
- ,Child: 'model'
,Properties:
{
/**
@@ -119,7 +118,8 @@ module.exports = new Class
var extraObjects = {};
extraObjects[this._formId] = set;
- var scope = this._builder.load (this.doc, null, this._parentScope, extraObjects, set);
+ var scope = this._builder.load (
+ this.doc, null, this._parentScope, extraObjects, set);
scope.link ();
this._childsData.push ({
diff --git a/js/vn/builder.js b/js/vn/builder.js
index 55d3b46d..b4a136b4 100644
--- a/js/vn/builder.js
+++ b/js/vn/builder.js
@@ -6,6 +6,7 @@ var kebabToCamel = require ('./string-util').kebabToCamel;
var CompilerObject = require ('./compiler-object');
var CompilerElement = require ('./compiler-element');
var CompilerText = require ('./compiler-text');
+var CompilerInterpolable = require ('./compiler-interpolable');
var regCompilers = [
CompilerObject,
@@ -103,6 +104,7 @@ module.exports = new Class
this._contexts = [];
this._contextMap = {};
this._mainContext = null;
+ this._interpoler = new CompilerInterpolable (this);
var compilers = [];
this._compilers = compilers;
@@ -169,12 +171,12 @@ module.exports = new Class
* Creates a new scope from a compiled XML tree.
*
* @param {Document} dstDocument The document used to create the nodes
- * @param {Object} signalData The object where to bind methods
+ * @param {Object} thisArg The object where to bind methods
* @param {Scope} parentScope The parent scope or %null for no parent
* @param {Lot} lot The default lot
* @return {Scope} The created scope
*/
- ,load: function (dstDocument, signalData, parentScope, extraObjects, lot)
+ ,load: function (dstDocument, thisArg, parentScope, extraObjects, lot)
{
if (this._contexts === null)
return null;
@@ -183,7 +185,7 @@ module.exports = new Class
var contexts = this._contexts;
var len = contexts.length;
var objects = new Array (len);
- var scope = new Scope (this, objects, signalData, parentScope, lot)
+ var scope = new Scope (this, objects, thisArg, parentScope, lot)
for (var i = 0; i < len; i++)
{
@@ -204,6 +206,8 @@ module.exports = new Class
var objects = scope.objects;
var compilers = this._compilers;
+ this._interpoler.preLink (scope);
+
for (var i = 0; i < compilers.length; i++)
compilers[i].preLink (scope);
@@ -219,10 +223,24 @@ module.exports = new Class
context.compiler.connect (context, objects[i], objects, scope);
}
+ this._interpoler.postLink (scope);
+
for (var i = 0; i < compilers.length; i++)
compilers[i].postLink (scope);
}
+ /**
+ * Frees all resources allocated by a scope.
+ */
+ ,freeScope: function (scope)
+ {
+ this._interpoler.free (scope);
+
+ var compilers = this._compilers;
+ for (var i = 0; i < compilers.length; i++)
+ compilers[i].free (scope);
+ }
+
/**
* Logs an error parsing the node.
*
diff --git a/js/vn/compiler-element.js b/js/vn/compiler-element.js
index 47688855..64ae303a 100644
--- a/js/vn/compiler-element.js
+++ b/js/vn/compiler-element.js
@@ -28,6 +28,14 @@ module.exports = new Class
var childs = [];
var events = {};
+ var context = {
+ tagName: tagName,
+ props: props,
+ objectProps: objectProps,
+ childs: childs,
+ events: events
+ };
+
var a = node.attributes;
for (var i = 0; i < a.length; i++)
@@ -40,7 +48,12 @@ module.exports = new Class
else if (objectAttrs[attribute])
objectProps[attribute] = kebabToCamel(value);
else if (!specialAttrs[attribute])
- props[attribute] = this.translateValue (value);
+ {
+ value = this.translateValue (value);
+
+ if (!this._interpoler.compile (context, attribute, value))
+ props[attribute] = this.translateValue (value);
+ }
}
var childContext;
@@ -51,13 +64,7 @@ module.exports = new Class
if (childContext = builder._compile (childNodes[i]))
childs.push (childContext.id);
- return {
- tagName: tagName,
- props: props,
- objectProps: objectProps,
- childs: childs,
- events: events
- };
+ return context;
}
,instantiate: function (doc, context, scope)
@@ -66,13 +73,18 @@ module.exports = new Class
var props = context.props;
for (var prop in props)
- object.setAttribute (prop, scope.interpolate (props[prop]));
+ object.setAttribute (prop, props[prop]);
if (context.nodeId)
object.setAttribute ('id', scope.getHtmlId (context.nodeId));
return object;
}
+
+ ,setProperty: function (object, data, value)
+ {
+ object.setAttribute (data, value);
+ }
,link: function (context, object, objects, scope)
{
diff --git a/js/vn/compiler-interpolable.js b/js/vn/compiler-interpolable.js
new file mode 100644
index 00000000..8856d32a
--- /dev/null
+++ b/js/vn/compiler-interpolable.js
@@ -0,0 +1,144 @@
+
+var VnObject = require ('./object');
+
+var regex = /{{[\w_]+(\.[\w_]+)?}}/g;
+
+/**
+ * Replaces all ocurrences of {{value}} by it's corresponding value in the
+ * scope lot.
+ */
+module.exports = new Class
+({
+ Extends: VnObject
+
+ ,_lots: {}
+ ,_links: []
+
+ ,initialize: function (builder)
+ {
+ this._builder = builder;
+ this.parent ();
+ }
+
+ ,compile: function (objContext, data, string)
+ {
+ var matchs = string.match (regex);
+
+ if (!matchs)
+ return null;
+
+ var lots = this._lots;
+ var links = this._links;
+
+ var regLots = {};
+ var params = [];
+
+ var context = {
+ objContext: objContext,
+ data: data,
+ string: string,
+ params: params
+ };
+
+ for (var i = 0; i < matchs.length; i++)
+ {
+ var match = matchs[i];
+ match = matchs[i].substr (2, match.length - 4);
+ match = match.split ('.');
+
+ var lotId;
+ var name;
+
+ if (match.length > 1)
+ {
+ lotId = match[0];
+ name = match[1];
+ }
+ else
+ {
+ lotId = null;
+ name = match[0];
+ }
+
+ params.push ({
+ lotId: lotId,
+ name: name
+ });
+
+ if (regLots[lotId] === undefined)
+ {
+ if (!lots[lotId])
+ lots[lotId] = [];
+
+ lots[lotId].push (context);
+ regLots[lotId] = 1;
+ }
+ }
+
+ links.push (context);
+ return context;
+ }
+
+ ,interpolate: function (link, scope)
+ {
+ var i = 0;
+ var params = link.params;
+ var $ = scope.$;
+
+ return link.string.replace (regex, function () {
+ var param = params[i++];
+ var lotId = param.lotId;
+ var lot = lotId ? $[lotId] : scope.lot;
+ var value = lot ? lot.$[param.name] : null;
+ return value != null ? value : '';
+ });
+ }
+
+ ,preLink: function (scope)
+ {
+ this._link (this._links, scope);
+ }
+
+ ,_link: function (links, scope)
+ {
+ for (var i = 0; i < links.length; i++)
+ {
+ var link = links[i];
+ var string = this.interpolate (link, scope);
+ var object = scope.objects[link.objContext.id];
+ link.objContext.compiler.setProperty (object, link.data, string);
+ }
+ }
+
+ ,getLot: function (lotId, scope)
+ {
+ return lotId == 'null' ? scope.lot : scope.$[lotId];
+ }
+
+ ,postLink: function (scope)
+ {
+ for (var lotId in this._lots)
+ {
+ var lot = this.getLot (lotId, scope);
+
+ if (lot)
+ lot.on ('change', this.onLotChange.bind (this, lotId, scope), scope);
+ }
+ }
+
+ ,free: function (scope)
+ {
+ for (var lotId in this._lots)
+ {
+ var lot = this.getLot (lotId, scope);
+
+ if (lot)
+ lot.disconnectByInstance (scope);
+ }
+ }
+
+ ,onLotChange: function (lotId, scope)
+ {
+ this._link (this._lots[lotId], scope);
+ }
+});
diff --git a/js/vn/compiler-object.js b/js/vn/compiler-object.js
index 55693d79..e25ccf3e 100644
--- a/js/vn/compiler-object.js
+++ b/js/vn/compiler-object.js
@@ -1,4 +1,5 @@
+var VnObject = require ('./object');
var Compiler = require ('./compiler');
var Component = require ('./component');
var Type = require ('./type');
@@ -115,6 +116,9 @@ module.exports = new Class
return;
}
+ if (this._interpoler.compile (context, propName, value))
+ return;
+
switch (propInfo.type)
{
case null:
@@ -172,6 +176,11 @@ module.exports = new Class
return object;
}
+
+ ,setProperty: function (object, data, value)
+ {
+ object[data] = value;
+ }
,preLink: function (scope)
{
@@ -229,7 +238,23 @@ module.exports = new Class
var method = scope.getMethod (events[event]);
if (method)
- object.on (event, method, scope.signalData);
+ object.on (event, method, scope.thisArg);
+ }
+ }
+
+ ,free: function (scope)
+ {
+ var objects = scope.objects;
+
+ for (var i = objects.length; i--;)
+ {
+ var object = objects[i];
+
+ if (object instanceof VnObject)
+ {
+ object.disconnectByInstance (scope.thisArg);
+ object.unref ();
+ }
}
}
diff --git a/js/vn/compiler-text.js b/js/vn/compiler-text.js
index d461df1c..42055442 100644
--- a/js/vn/compiler-text.js
+++ b/js/vn/compiler-text.js
@@ -28,11 +28,23 @@ module.exports = new Class
else
return null;
- return {text: text};
+ var context = {text: null};
+
+ if (this._interpoler.compile (context, null, text))
+ context.text = '';
+ else
+ context.text = text;
+
+ return context;
}
,instantiate: function (doc, context, scope)
{
- return doc.createTextNode (scope.interpolate (context.text));
+ return doc.createTextNode (context.text);
+ }
+
+ ,setProperty: function (object, data, value)
+ {
+ object.textContent = value;
}
});
diff --git a/js/vn/compiler.js b/js/vn/compiler.js
index 62fd1bc5..91c44a2b 100644
--- a/js/vn/compiler.js
+++ b/js/vn/compiler.js
@@ -15,10 +15,13 @@ module.exports = new Class
,link: function () {}
,connect: function () {}
,postLink: function () {}
+ ,setProperty: function () {}
+ ,free: function () {}
,initialize: function (builder)
{
this._builder = builder;
+ this._interpoler = builder._interpoler;
this.parent ();
}
diff --git a/js/vn/iterator.js b/js/vn/iterator.js
index ecd4f8ae..d88e1bc6 100644
--- a/js/vn/iterator.js
+++ b/js/vn/iterator.js
@@ -58,11 +58,12 @@ module.exports = new Class
}
}
+ ,_model: null
+
,initialize: function (props)
{
Object.assign (this, {
- _model: null
- ,_row: -1
+ _row: -1
,_rowLock: false
});
this.parent (props);
diff --git a/js/vn/json-connection.js b/js/vn/json-connection.js
index d9b9b15c..1441531b 100644
--- a/js/vn/json-connection.js
+++ b/js/vn/json-connection.js
@@ -1,6 +1,6 @@
var VnObject = require ('./object');
-var JsonException = require ('./json-exception');
+var JsonError = require ('./json-error');
/**
* Handler for JSON rest connections.
@@ -125,7 +125,7 @@ module.exports = new Class
*/
,supplantUser: function (user, callback)
{
- var params = {'supplantUser': user};
+ var params = {supplantUser: user};
this.send ('core/supplant', params,
this._onUserSupplant.bind (this, callback));
}
@@ -160,7 +160,7 @@ module.exports = new Class
if (!params)
params = {};
- params['srv'] = 'json:'+ restService;
+ params.srv = 'json:'+ restService;
this.sendWithUrl (params, callback, 'POST', '.');
}
@@ -213,7 +213,7 @@ module.exports = new Class
,sendWithUrl: function (params, callback, method, url)
{
if (this.token)
- params['token'] = this.token;
+ params.token = this.token;
var request = new XMLHttpRequest ();
request.open (method, url, true);
@@ -255,7 +255,7 @@ module.exports = new Class
throw ex;
}
- var contentType = null;
+ var contentType;
try {
contentType = request
@@ -263,7 +263,9 @@ module.exports = new Class
.split (';')[0]
.trim ();
}
- catch (e) {}
+ catch (e) {
+ contentType = null;
+ }
if (contentType != 'application/json')
{
@@ -291,7 +293,7 @@ module.exports = new Class
.replace (/Exception$/, '')
.replace (/^Vn\.Web\./, '');
- var ex = new JsonException ();
+ var ex = new JsonError ();
Object.assign (ex, {
exception: exception,
message: jsData.message,
@@ -310,20 +312,20 @@ module.exports = new Class
}
if (callback)
-// try {
+ try {
callback (data, error);
-/* error = null;
+ error = null;
}
catch (e)
{
error = e;
}
-*/
+
if (error)
{
if (error.exception == 'SessionExpired')
this.clearToken ();
-
+
this.emit ('error', error);
}
}
diff --git a/js/vn/json-exception.js b/js/vn/json-error.js
similarity index 79%
rename from js/vn/json-exception.js
rename to js/vn/json-error.js
index 63d0a85d..4e2e26d1 100644
--- a/js/vn/json-exception.js
+++ b/js/vn/json-error.js
@@ -3,7 +3,9 @@
*/
module.exports = new Class
({
- exception: null
+ Extends: Error
+
+ ,exception: null
,message: null
,code: null
,file: null
@@ -12,6 +14,8 @@ module.exports = new Class
,initialize: function (exception, message, code, file, line, trace)
{
+ this.name = 'JsonError'
+ this.stack = (new Error ()).stack;
this.exception = exception;
this.message = message;
this.code = code;
diff --git a/js/vn/object.js b/js/vn/object.js
index f94ed69b..8e07a3e4 100644
--- a/js/vn/object.js
+++ b/js/vn/object.js
@@ -23,7 +23,7 @@ module.exports = new Class
/*
* Signal handlers data.
*/
- ,_signalData: null
+ ,_thisArg: null
/**
* Initializes the object and sets all properties passed to the class
@@ -100,10 +100,10 @@ module.exports = new Class
}
this._signalInit ();
- var callbacks = this._signalData.signals[id];
+ var callbacks = this._thisArg.signals[id];
if (!callbacks)
- callbacks = this._signalData.signals[id] = [];
+ callbacks = this._thisArg.signals[id] = [];
callbacks.push ({
blocked: false
@@ -121,10 +121,10 @@ module.exports = new Class
*/
,blockSignal: function (id, callback, block, instance)
{
- if (!this._signalData)
+ if (!this._thisArg)
return;
- var callbacks = this._signalData.signals[id];
+ var callbacks = this._thisArg.signals[id];
if (!callbacks)
return;
@@ -142,10 +142,10 @@ module.exports = new Class
*/
,emit: function (id)
{
- if (!this._signalData)
+ if (!this._thisArg)
return;
- var callbacks = this._signalData.signals[id];
+ var callbacks = this._thisArg.signals[id];
if (!callbacks)
return;
@@ -170,10 +170,10 @@ module.exports = new Class
*/
,disconnect: function (id, callback, instance)
{
- if (!this._signalData)
+ if (!this._thisArg)
return;
- var callbacks = this._signalData.signals[id];
+ var callbacks = this._thisArg.signals[id];
if (callbacks)
for (var i = callbacks.length; i--;)
@@ -189,10 +189,10 @@ module.exports = new Class
*/
,disconnectByInstance: function (instance)
{
- if (!this._signalData)
+ if (!this._thisArg)
return;
- var signals = this._signalData.signals;
+ var signals = this._thisArg.signals;
for (var signalId in signals)
{
@@ -212,15 +212,15 @@ module.exports = new Class
*/
,_destroy: function ()
{
- if (!this._signalData)
+ if (!this._thisArg)
return;
- var links = this._signalData.links;
+ var links = this._thisArg.links;
for (var key in links)
this._unlink (links[key]);
- this._signalData = null;
+ this._thisArg = null;
}
/**
@@ -232,7 +232,7 @@ module.exports = new Class
,link: function (prop, handlers)
{
this._signalInit ();
- var links = this._signalData.links;
+ var links = this._thisArg.links;
for (var key in prop)
{
@@ -264,8 +264,8 @@ module.exports = new Class
,_signalInit: function ()
{
- if (!this._signalData)
- this._signalData = {
+ if (!this._thisArg)
+ this._thisArg = {
signals: {},
links: {}
};
diff --git a/js/vn/scope.js b/js/vn/scope.js
index 2ddffd36..f673a049 100644
--- a/js/vn/scope.js
+++ b/js/vn/scope.js
@@ -7,17 +7,17 @@ module.exports = new Class
({
Extends: VnObject
- ,initialize: function (builder, objects, signalData, parentScope, lot)
+ ,initialize: function (builder, objects, thisArg, parentScope, lot)
{
this.builder = builder;
this.objects = objects;
- this.signalData = signalData;
+ this.thisArg = thisArg;
this.parentScope = parentScope;
this.uid = ++scopeUid;
this.lot = lot;
- if (!signalData && parentScope)
- this.signalData = parentScope.signalData;
+ if (!thisArg && parentScope)
+ this.thisArg = parentScope.thisArg;
this.parent ();
}
@@ -58,42 +58,14 @@ module.exports = new Class
this.builder.link (this);
}
- /**
- * Replaces all ocurrences of {{value}} by it's corresponding value in the
- * scope lot.
- */
- ,interpolate: function (string)
- {
- var self = this;
-
- function replaceFunc (token)
- {
- var key = token.substr (2, token.length - 4);
- var value = self.getLotValue (key);
- return value ? value : '';
- }
-
- return string.replace (/{{[\w_]+}}/g, replaceFunc);
- }
-
- ,getLotValue: function (key)
- {
- var value = this.lot.$[key];
-
- if (value === undefined && this.parentScope)
- return this.parentScope.getLotValue (key);
-
- return value;
- }
-
,getMethod: function (value, binded)
{
- if (this.signalData)
+ if (this.thisArg)
{
- var method = this.signalData[value];
+ var method = this.thisArg[value];
if (method && binded)
- method = method.bind (this.signalData);
+ method = method.bind (this.thisArg);
}
else
var method = window[value];
@@ -111,19 +83,7 @@ module.exports = new Class
,_destroy: function ()
{
- var objects = this.objects;
-
- for (var i = objects.length; i--;)
- {
- var object = objects[i];
-
- if (object instanceof VnObject)
- {
- object.unref ();
- object.disconnectByInstance (this.builder.signalData);
- }
- }
-
+ this.builder.freeScope (this);
this.parent ();
}
});
diff --git a/js/vn/vn.js b/js/vn/vn.js
index 1d096c13..e8c497c3 100644
--- a/js/vn/vn.js
+++ b/js/vn/vn.js
@@ -31,7 +31,7 @@ Vn = module.exports = {
,NodeBuilder : require ('./node-builder')
,Builder : require ('./builder')
,Component : require ('./component')
- ,JsonException : require ('./json-exception')
+ ,JsonException : require ('./json-error')
,JsonConnection : require ('./json-connection')
,Config: {}