local changes from server
[fnpeditor.git] / src / editor / modules / documentToolbar / documentToolbar.js
index 82b6dca..6e3d630 100644 (file)
@@ -7,8 +7,6 @@ return function(sandbox) {
     
     var addedActions = [],
         contextParams = {},
     
     var addedActions = [],
         contextParams = {},
-        contextDefer = {},
-        duringClick = false,
         document, canvas;
 
     var view = {
         document, canvas;
 
     var view = {
@@ -29,19 +27,8 @@ return function(sandbox) {
             });
 
             group.append(view.dom);
             });
 
             group.append(view.dom);
-            view.on('actionExecuted', function(action, ret) {
+            action.on('actionExecuted', function(ret) {
                 sandbox.publish('actionExecuted', action, ret);
                 sandbox.publish('actionExecuted', action, ret);
-                duringClick = false;
-                _.pairs(contextDefer).forEach(function(pair) {
-                    var what = pair[0],
-                        deferred = pair[1];
-                    if(deferred) {
-                        refreshContextParam(what);
-                    }
-                });
-            });
-            view.on('mousedown', function() {
-                duringClick = true;
             });
 
             view.on('hover', function() {
             });
 
             view.on('hover', function() {
@@ -61,14 +48,6 @@ return function(sandbox) {
     
     var setContextParam = function(what, ctx) {
         contextParams[what] = ctx;
     
     var setContextParam = function(what, ctx) {
         contextParams[what] = ctx;
-        if(duringClick) {
-            contextDefer[what] = true;
-        } else {
-            refreshContextParam(what);
-        }
-    };
-
-    var refreshContextParam = function(what) {
         addedActions.forEach(function(action) {
             action.updateContextParam(what, contextParams[what]);
         });
         addedActions.forEach(function(action) {
             action.updateContextParam(what, contextParams[what]);
         });
@@ -110,6 +89,7 @@ return function(sandbox) {
                 document.on('operationEnd', function() {
                     setContextParam('document', document);
                 });
                 document.on('operationEnd', function() {
                     setContextParam('document', document);
                 });
+                setContextParam('document', document);
             }
             setContextParam('fragment', fragment);
 
             }
             setContextParam('fragment', fragment);