X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/0214643f72c6aaa8e85eaba2ad27f2ca03ca6401..3ef4adb18d58aa2570142c19762e4f2a48cb0d1b:/fnpjs/layout.js diff --git a/fnpjs/layout.js b/fnpjs/layout.js index a7c27fe..5fe61cc 100644 --- a/fnpjs/layout.js +++ b/fnpjs/layout.js @@ -2,12 +2,31 @@ define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($ ,_) { 'use strict'; var Layout = function(template) { + var layout = this; this.dom = $(_.template(template)()); + this.views = {}; + + this.dom.onShow = function() { + _.values(layout.views).forEach(function(view) { + if(view.onShow) + view.onShow(); + }); + }; + this.dom.onHide = function() { + _.values(layout.views).forEach(function(view) { + if(view.onHide) + view.onHide(); + }); + }; }; Layout.prototype.setView = function(place, view) { this.dom.find('[fnpjs-place=' + place + ']').append(view); + this.views[place] = view; + if(this.dom.is(':visible') && view.onShow) { + view.onShow(); + } }; Layout.prototype.getAsView = function() {