Visual editor: simple parent/children navigation in edit pane
[fnpeditor.git] / modules / tabsManager.js
index 56d647d..4ede9a0 100644 (file)
@@ -3,7 +3,7 @@ rng.modules.tabsManager = function(sandbox) {
     var $ = sandbox.$;\r
     \r
     var view = $(sandbox.getTemplate('main')());\r
     var $ = sandbox.$;\r
     \r
     var view = $(sandbox.getTemplate('main')());\r
-    \r
+    var currentSlug;\r
     var tabContent = {};\r
     \r
     function selectTab(slug) {\r
     var tabContent = {};\r
     \r
     function selectTab(slug) {\r
@@ -25,10 +25,12 @@ rng.modules.tabsManager = function(sandbox) {
         if(prevSlug)\r
             tabContent[prevSlug].detach();\r
         tabContent[slug].appendTo(view.find('#rng-tabsManager-content'));\r
         if(prevSlug)\r
             tabContent[prevSlug].detach();\r
         tabContent[slug].appendTo(view.find('#rng-tabsManager-content'));\r
+        currentSlug = slug;\r
+        sandbox.publish('showed', slug);\r
     }\r
        \r
     \r
     }\r
        \r
     \r
-    view.on('click', 'li a', function(e) {\r
+    view.on('click', '#rng-tabsManager-tabBar li a', function(e) {\r
         selectTab($(e.target).attr('href').substr(1));\r
     });\r
     \r
         selectTab($(e.target).attr('href').substr(1));\r
     });\r
     \r
@@ -46,6 +48,9 @@ rng.modules.tabsManager = function(sandbox) {
             view.find('#rng-tabsManager-tabBar').append(sandbox.getTemplate('tabHandle')({title: title, slug: slug}));\r
             if(_.values(tabContent).length === 1)\r
                 selectTab(slug);\r
             view.find('#rng-tabsManager-tabBar').append(sandbox.getTemplate('tabHandle')({title: title, slug: slug}));\r
             if(_.values(tabContent).length === 1)\r
                 selectTab(slug);\r
+        },\r
+        getCurrentSlug: function() {\r
+            return currentSlug;\r
         }\r
     }\r
 \r
         }\r
     }\r
 \r