documentCanvas: displaying lists and tables
[fnpeditor.git] / fnpjs / layout.js
index a7c27fe..5fe61cc 100644 (file)
@@ -2,12 +2,31 @@ 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