even more tutorial in editor (status bar)
[fnpeditor.git] / src / fnpjs / runner.js
index f3edd31..27441b1 100644 (file)
@@ -15,7 +15,8 @@ var Runner = function(app, modules) {
         plugins = [],
         actionDefinitions = {},
         config,
         plugins = [],
         actionDefinitions = {},
         config,
-        actionsAppObject;
+        actionsAppObject,
+        currentContextMenu;
         
     _.each(_.keys(modules || {}), function(moduleName) {
         if(_.contains(app.permissions[moduleName] || [], 'handleEvents')) {
         
     _.each(_.keys(modules || {}), function(moduleName) {
         if(_.contains(app.permissions[moduleName] || [], 'handleEvents')) {
@@ -78,9 +79,33 @@ var Runner = function(app, modules) {
         this.registerActionsAppObject = function(_actionsAppObject) {
             actionsAppObject = _actionsAppObject;
         };
         this.registerActionsAppObject = function(_actionsAppObject) {
             actionsAppObject = _actionsAppObject;
         };
+
+        this.showContextMenu = function(menu, coors) {
+            if(currentContextMenu) {
+                currentContextMenu.close();
+            }
+            currentContextMenu = menu;
+            $(config.rootSelector).append(menu.dom);
+            menu.dom.css({top: coors.y, left: coors.x});
+            menu.show();
+        };
+
+        this.getTutorialItem = function(name) {
+            var tutorial = this.getConfig().tutorial;
+            var tutorialText, index;
+            tutorial.some(function(item, i) {
+                if(item.name === name) {
+                    tutorialText = item.text;
+                    index = i;
+                    return true;
+                }
+            });
+            if(!tutorialText)
+                return;
+            return {index: index + 1, text: tutorialText};
+        }
     };
     };
-    
-    
+      
     this.setBootstrappedData = function(moduleName, data) {
         bootstrappedData[moduleName] = data;
     };
     this.setBootstrappedData = function(moduleName, data) {
         bootstrappedData[moduleName] = data;
     };
@@ -120,6 +145,13 @@ var Runner = function(app, modules) {
         app.initModules.forEach(function(moduleName) {
             getModuleInstance(moduleName).start();
         });
         app.initModules.forEach(function(moduleName) {
             getModuleInstance(moduleName).start();
         });
+
+        $(config.rootSelector)[0].addEventListener('click', function(e) {
+            if(currentContextMenu && !currentContextMenu.dom[0].contains(e.target)) {
+                currentContextMenu.close();
+                currentContextMenu = null;
+            }
+        }, true);
     };
 };
 
     };
 };