67 lines
981 B
JavaScript
Executable File
67 lines
981 B
JavaScript
Executable File
/**
|
|
* List of Sql.Object
|
|
**/
|
|
Sql.List = new Class
|
|
({
|
|
Extends: Sql.Object
|
|
|
|
,objects: []
|
|
|
|
,add: function (object)
|
|
{
|
|
this.objects.push (object.ref ());
|
|
object.on ('changed', this._onObjectChange, this);
|
|
this._onObjectChange ();
|
|
}
|
|
|
|
,get: function (i)
|
|
{
|
|
return objects[i];
|
|
}
|
|
|
|
,getArray: function ()
|
|
{
|
|
return this.objects;
|
|
}
|
|
|
|
,remove: function (i)
|
|
{
|
|
this._unrefObject (this.objects.splice (i, 1));
|
|
this._onObjectChange ();
|
|
}
|
|
|
|
,_onObjectChange: function ()
|
|
{
|
|
this.signalEmit ('changed');
|
|
}
|
|
|
|
,isReady: function ()
|
|
{
|
|
var o = this.objects;
|
|
|
|
if (o.length == 0)
|
|
return false;
|
|
|
|
for (var i = 0; i < o.length; i++)
|
|
if (!o[i].isReady ())
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
,_unrefObject: function (object)
|
|
{
|
|
object.disconnect ('changed', this._onObjectChange, this);
|
|
object.unref ();
|
|
}
|
|
|
|
,_destroy: function ()
|
|
{
|
|
for (var i = 0; i < this.objects.length; i++)
|
|
this._unrefObject (this.objects[i]);
|
|
|
|
this.parent ();
|
|
}
|
|
});
|
|
|