Browse Source

fixed text editor & scope issue

Torkel Ödegaard 11 years ago
parent
commit
d6f1c379c0
2 changed files with 12 additions and 8 deletions
  1. 1 1
      src/app/directives/panelMenu.js
  2. 11 7
      src/app/services/panelSrv.js

+ 1 - 1
src/app/directives/panelMenu.js

@@ -53,7 +53,6 @@ function (angular, $, _) {
         link: function($scope, elem) {
           var $link = $(linkTemplate);
           var $panelContainer = elem.parents(".panel-container");
-          var menuTemplate = createMenuTemplate($scope);
           var menuWidth = 246;
           var menuScope = null;
           var timeout = null;
@@ -106,6 +105,7 @@ function (angular, $, _) {
               menuLeftPos = 0;
             }
 
+            var menuTemplate = createMenuTemplate($scope);
             $menu = $(menuTemplate);
             $menu.css('left', menuLeftPos);
             $menu.mouseleave(function() {

+ 11 - 7
src/app/services/panelSrv.js

@@ -20,13 +20,8 @@ function (angular, _) {
         },
         {
           text: 'edit',
-          editorLink: "app/partials/paneleditor.html",
-          condition: !$scope.panelMeta.fullscreenEdit
-        },
-        {
-          text: 'edit',
-          click: "toggleFullscreen(true)",
-          condition: $scope.panelMeta.fullscreenEdit
+          click: 'editPanel()',
+          condition: true,
         },
         {
           text: 'duplicate',
@@ -66,6 +61,15 @@ function (angular, _) {
       $scope.inspector = {};
       $scope.panelMeta.menu = _.where(menu, { condition: true });
 
+      $scope.editPanel = function() {
+        if ($scope.panelMeta.fullscreenEdit) {
+          $scope.toggleFullscreen(true);
+        }
+        else {
+          $scope.emitAppEvent('show-dash-editor', { src: 'app/partials/paneleditor.html', scope: $scope });
+        }
+      };
+
       $scope.editPanelJson = function() {
         $scope.emitAppEvent('show-json-editor', { object: $scope.panel, updateHandler: $scope.replacePanel });
       };