'use strict';\r
\r
var Layout = function(template) {\r
+ var layout = this;\r
this.dom = $(_.template(template)());\r
+ this.views = {};\r
+ \r
+ this.dom.onShow = function() {\r
+ _.values(layout.views).forEach(function(view) {\r
+ if(view.onShow)\r
+ view.onShow();\r
+ });\r
+ };\r
+ this.dom.onHide = function() {\r
+ _.values(layout.views).forEach(function(view) {\r
+ if(view.onHide)\r
+ view.onHide();\r
+ });\r
+ };\r
\r
};\r
\r
Layout.prototype.setView = function(place, view) {\r
this.dom.find('[fnpjs-place=' + place + ']').append(view);\r
+ this.views[place] = view;\r
+ if(this.dom.is(':visible') && view.onShow) {\r
+ view.onShow();\r
+ }\r
};\r
\r
Layout.prototype.getAsView = function() {\r
- return this.dom\r
+ return this.dom;\r
};\r
\r
return {Layout: Layout};\r