mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Forgot PopupPreviewController.js
This commit is contained in:
parent
7a355b39a0
commit
68a807ccb5
45
src/js/controller/PopupPreviewController.js
Normal file
45
src/js/controller/PopupPreviewController.js
Normal file
@ -0,0 +1,45 @@
|
||||
(function () {
|
||||
var ns = $.namespace('pskl.controller');
|
||||
|
||||
ns.PopupPreviewController = function (piskelController) {
|
||||
this.popup = null;
|
||||
this.renderer = null;
|
||||
};
|
||||
|
||||
ns.PopupPreviewController.prototype.init = function () {
|
||||
pskl.utils.Event.addEventListener('.open-popup-preview-button', 'click', this.onOpenPopupPreviewClick_, this);
|
||||
pskl.utils.Event.addEventListener(window, 'unload', this.onMainWindowUnload_, this);
|
||||
};
|
||||
|
||||
ns.PopupPreviewController.prototype.isOpen = function () {
|
||||
return !!this.popup;
|
||||
};
|
||||
|
||||
ns.PopupPreviewController.prototype.onOpenPopupPreviewClick_ = function () {
|
||||
if (!this.isOpen()) {
|
||||
this.popup = this.createPopup_();
|
||||
window.setTimeout(function () {
|
||||
var container = this.popup.document.querySelector('.preview-container');
|
||||
this.renderer = new pskl.rendering.frame.TiledFrameRenderer($(container));
|
||||
}.bind(this), 200);
|
||||
}
|
||||
};
|
||||
|
||||
ns.PopupPreviewController.prototype.createPopup_ = function () {
|
||||
var popup = window.open('about:blank', '', 'width=320,height=320');
|
||||
popup.document.body.innerHTML = pskl.utils.Template.get('popup-preview-partial');
|
||||
return popup;
|
||||
};
|
||||
|
||||
ns.PopupPreviewController.prototype.render = function (frame) {
|
||||
if (this.isOpen() && this.renderer) {
|
||||
this.renderer.render(frame);
|
||||
}
|
||||
};
|
||||
|
||||
ns.PopupPreviewController.prototype.onMainWindowUnload_ = function () {
|
||||
if (this.isOpen()) {
|
||||
this.popup.close();
|
||||
}
|
||||
};
|
||||
})();
|
Loading…
Reference in New Issue
Block a user