Another set of missing semicolons
[fnpeditor.git] / fnpjs / layout.js
index a7c27fe..d5fa098 100644 (file)
@@ -2,16 +2,35 @@ define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($ ,_) {
     '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