From 9f7c5577221b662d264cfe6c1970fd4afb7a386f Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 4 Jan 2010 08:40:57 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9=E3=83=AA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= 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@5726 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/res/operationHistory.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/content/treestyletab/res/operationHistory.js b/content/treestyletab/res/operationHistory.js index ae837d53..0c36da16 100644 --- a/content/treestyletab/res/operationHistory.js +++ b/content/treestyletab/res/operationHistory.js @@ -20,6 +20,8 @@ // history item { label : 'Change tabbar position', onUndo : function() { MyService.myProp = oldValue; }, + /* "onRedo" is optional. If you don't specify it, + the undoable task becomes onRedo automatically. */ onRedo : function() { MyService.myProp = newValue; } } ); OH.undo('MyAddonFeature', window); @@ -53,8 +55,7 @@ onUndo : function() { var w = OH.getWindowById(this.id); w.MyAddonService.myProp = oldValue; - }, - onRedo : ... + } } ); @@ -73,7 +74,7 @@ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/operationHistory.test.js */ (function() { - const currentRevision = 4; + const currentRevision = 5; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; @@ -124,9 +125,14 @@ error = e; } - if (!wasInUndoableTask && !this._doingUndo && options.data) { + var data = options.data; + if (!wasInUndoableTask && !this._doingUndo && data) { + let f = this._getAvailableFunction(data.onRedo, data.onredo, data.redo); + if (!f && !data.onRedo && !data.onredo && !data.redo && options.task) + data.onRedo = options.task; + entries = entries.slice(0, history.index+1); - entries.push(options.data); + entries.push(data); entries = entries.slice(-this.MAX_ENTRIES); history.entries = entries;