UNPKG

nakedobjects.spa

Version:

Single Page Application client for a Naked Objects application.

47 lines 1.96 kB
import * as Msg from '../user-messages'; var AttachmentViewModel = (function () { function AttachmentViewModel(link, parent, context, error, onPaneId) { var _this = this; this.link = link; this.parent = parent; this.context = context; this.error = error; this.onPaneId = onPaneId; this.downloadFile = function () { return _this.context.getFile(_this.parent, _this.href, _this.mimeType); }; this.clearCachedFile = function () { return _this.context.clearCachedFile(_this.href); }; this.empty = false; this.displayInline = function () { return _this.mimeType === "image/jpeg" || _this.mimeType === "image/gif" || _this.mimeType === "application/octet-stream"; }; this.href = link.href(); this.mimeType = link.type().asString; this.title = link.title() || Msg.unknownFileTitle; } AttachmentViewModel.prototype.setImage = function (setImageOn) { var _this = this; this.downloadFile().then(function (blob) { if (blob.size > 0) { var reader_1 = new FileReader(); reader_1.onloadend = function () { if (reader_1.result) { setImageOn.image = reader_1.result; } }; reader_1.readAsDataURL(blob); } else { _this.empty = true; _this.title = Msg.noImageMessage; } setImageOn.title = _this.title; }).catch(function (reject) { return _this.error.handleError(reject); }); }; AttachmentViewModel.prototype.setTitle = function (setTitleOn) { setTitleOn.title = this.title; }; return AttachmentViewModel; }()); export { AttachmentViewModel }; //# sourceMappingURL=attachment-view-model.js.map