radio/libjs/wController/imageById.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

"use strict";
var LocalModel = require("./localModel");
var File = require("./file/file");
var Address = require("../wType/address");
var ImageById = LocalModel.inherit({
className: "ImageById",
constructor: function(properties, id) {
LocalModel.fn.constructor.call(this, properties);
this._imageId = id;
this._fileCtrl = new File(new Address(["images", this._imageId.toString()]));
this._need = 0;
this._fileCtrl.on("data", this._onControllerData, this);
this.addForeignController("Corax", this._fileCtrl);
},
dontNeedData: function() {
--this._need;
if (this._need === 0) {
this._fileCtrl.dontNeedData();
}
},
getMimeType: function () {
return this._fileCtrl.getMimeType();
},
hasData: function() {
return this._fileCtrl.hasData();
},
needData: function() {
if (this._need === 0) {
this._fileCtrl.needData();
}
++this._need;
},
_onControllerData: function() {
this.data = this._fileCtrl.data;
this.trigger("data");
}
});
module.exports = ImageById;