Moving caret back to selected node when documentCanvas is shown again
[fnpeditor.git] / fnpjs / layout.js
1 define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($ ,_) {\r
2     'use strict';\r
3       \r
4     var Layout = function(template) {\r
5         var layout = this;\r
6         this.dom = $(_.template(template)());\r
7         this.views = {};\r
8         \r
9         this.dom.onShow = function() {\r
10             _.values(layout.views).forEach(function(view) {\r
11                 if(view.onShow)\r
12                     view.onShow();\r
13             });\r
14         };\r
15         \r
16     };\r
17     \r
18     Layout.prototype.setView = function(place, view) {\r
19         this.dom.find('[fnpjs-place=' + place + ']').append(view);\r
20         this.views[place] = view;\r
21         if(this.dom.is(':visible') && view.onShow) {\r
22             view.onShow();\r
23         }\r
24     };\r
25     \r
26     Layout.prototype.getAsView = function() {\r
27         return this.dom\r
28     };\r
29     \r
30     return {Layout: Layout};\r
31 });