From 12fdfcf9f77edb2ca5e4061fffc89254b44250f5 Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 4 Jan 2010 03:56:08 +0000 Subject: [PATCH] =?UTF-8?q?API=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5689 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/res/operationHistory.js | 16 ++++++++-------- .../treestyletabbrowser_tabpanelDNDObserver.js | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/content/treestyletab/res/operationHistory.js b/content/treestyletab/res/operationHistory.js index 768c28b2..a2bca6ea 100644 --- a/content/treestyletab/res/operationHistory.js +++ b/content/treestyletab/res/operationHistory.js @@ -5,8 +5,8 @@ // window specific history window['piro.sakura.ne.jp'].operationHistory.addEntry( 'MyAddonFeature', - { undo : function() { ... }, - redo : function() { ... } }, + { onUndo : function() { ... }, + onRedo : function() { ... } }, window ); window['piro.sakura.ne.jp'].operationHistory.undo('MyAddonFeature', window); @@ -32,12 +32,12 @@ // to reduce memory leak. For example... var id = window['piro.sakura.ne.jp'].operationHistory.getWindowId(targetWindow); window['piro.sakura.ne.jp'].operationHistory.addEntry({ - undo : function() { + onUndo : function() { // "this" in undo/redo functions refers the operationHistory service itself. - var w = this.getWindowById(id); + var w = window['piro.sakura.ne.jp'].operationHistory.getWindowById(id); w.MyAddonService.undoSomething(); }, - redo : ... + onRedo : ... }); lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi @@ -46,7 +46,7 @@ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/operationHistory.js */ (function() { - const currentRevision = 1; + const currentRevision = 2; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; @@ -102,7 +102,7 @@ this._doingUndo = true; var data = history.entries[history.index--]; try { - data.undo.call(this); + (data.onUndo || data.onundo)(); } catch(e) { error = e; @@ -126,7 +126,7 @@ this._doingUndo = true; var data = history.entries[history.index++]; try { - data.redo.call(this); + (data.onRedo || data.onredo)(this); } catch(e) { error = e; diff --git a/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js b/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js index e88f3c9f..a3b91f62 100644 --- a/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js +++ b/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js @@ -38,12 +38,14 @@ TreeStyleTabBrowserTabpanelDNDObserver.prototype = { sv.currentTabbarPosition = position; window['piro.sakura.ne.jp'].operationHistory.addEntry( 'TabbarDNDOperations', - { undo : function() { sv.currentTabbarPosition = current; }, - redo : function() { sv.currentTabbarPosition = position; } }, + { onUndo : function() { TreeStyleTabService.currentTabbarPosition = current; }, + onRedo : function() { TreeStyleTabService.currentTabbarPosition = position; } }, window ); } + sv = null; + aEvent.stopPropagation(); },