ライブラリ更新
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5809 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
9f7f121464
commit
acca1ee9bd
@ -74,7 +74,8 @@
|
|||||||
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/operationHistory.test.js
|
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/operationHistory.test.js
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
const currentRevision = 11;
|
const currentRevision = 12;
|
||||||
|
const DEBUG = false;
|
||||||
|
|
||||||
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
||||||
|
|
||||||
@ -94,6 +95,11 @@
|
|||||||
var Cc = Components.classes;
|
var Cc = Components.classes;
|
||||||
var Ci = Components.interfaces;
|
var Ci = Components.interfaces;
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
if (DEBUG)
|
||||||
|
Application.console.log(Array.slice(arguments).join('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
window['piro.sakura.ne.jp'].operationHistory = {
|
window['piro.sakura.ne.jp'].operationHistory = {
|
||||||
revision : currentRevision,
|
revision : currentRevision,
|
||||||
|
|
||||||
@ -108,6 +114,7 @@
|
|||||||
|
|
||||||
doUndoableTask : function()
|
doUndoableTask : function()
|
||||||
{
|
{
|
||||||
|
log('doUndoableTask');
|
||||||
var options = this._getOptionsFromArguments(arguments);
|
var options = this._getOptionsFromArguments(arguments);
|
||||||
var history = options.history;
|
var history = options.history;
|
||||||
var entries = history.entries;
|
var entries = history.entries;
|
||||||
@ -119,14 +126,17 @@
|
|||||||
|
|
||||||
var data = options.data;
|
var data = options.data;
|
||||||
if (!this._doingUndo && data) {
|
if (!this._doingUndo && data) {
|
||||||
|
log('register entry to history');
|
||||||
let f = this._getAvailableFunction(data.onRedo, data.onredo, data.redo);
|
let f = this._getAvailableFunction(data.onRedo, data.onredo, data.redo);
|
||||||
if (!f && !data.onRedo && !data.onredo && !data.redo && options.task)
|
if (!f && !data.onRedo && !data.onredo && !data.redo && options.task)
|
||||||
data.onRedo = options.task;
|
data.onRedo = options.task;
|
||||||
|
|
||||||
if (wasInUndoableTask) {
|
if (wasInUndoableTask) {
|
||||||
|
log('top level');
|
||||||
entries[entries.length-1].children.push(data);
|
entries[entries.length-1].children.push(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
log('child level');
|
||||||
entries = entries.slice(0, history.index+1);
|
entries = entries.slice(0, history.index+1);
|
||||||
entries.push({
|
entries.push({
|
||||||
__proto__ : data,
|
__proto__ : data,
|
||||||
@ -142,7 +152,15 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (options.task)
|
if (options.task)
|
||||||
options.task.call(this);
|
options.task.call(
|
||||||
|
this,
|
||||||
|
{
|
||||||
|
level : 0,
|
||||||
|
parent : null,
|
||||||
|
done : false,
|
||||||
|
manager : this
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
error = e;
|
error = e;
|
||||||
@ -167,6 +185,7 @@
|
|||||||
|
|
||||||
undo : function()
|
undo : function()
|
||||||
{
|
{
|
||||||
|
log('undo start');
|
||||||
var options = this._getOptionsFromArguments(arguments);
|
var options = this._getOptionsFromArguments(arguments);
|
||||||
var history = options.history;
|
var history = options.history;
|
||||||
if (history.index < 0 || this._doingUndo)
|
if (history.index < 0 || this._doingUndo)
|
||||||
@ -179,15 +198,18 @@
|
|||||||
{
|
{
|
||||||
let entry = history.entries[history.index--];
|
let entry = history.entries[history.index--];
|
||||||
if (!entry) continue;
|
if (!entry) continue;
|
||||||
|
log('undo '+(history.index+1)+' '+entry.label);
|
||||||
let done = false;
|
let done = false;
|
||||||
[entry.data].concat(entry.children).forEach(function(aData, aIndex) {
|
[entry.data].concat(entry.children).forEach(function(aData, aIndex) {
|
||||||
|
log('undo level '+(aIndex)+' '+aData.label);
|
||||||
let f = this._getAvailableFunction(aData.onUndo, aData.onundo, aData.undo);
|
let f = this._getAvailableFunction(aData.onUndo, aData.onundo, aData.undo);
|
||||||
try {
|
try {
|
||||||
if (f) {
|
if (f) {
|
||||||
let info = {
|
let info = {
|
||||||
level : aIndex,
|
level : aIndex,
|
||||||
parent : (aIndex ? entry.data : null ),
|
parent : (aIndex ? entry.data : null ),
|
||||||
done : processed && done
|
done : processed && done,
|
||||||
|
manager : this
|
||||||
};
|
};
|
||||||
let oneProcessed = f.call(aData, info);
|
let oneProcessed = f.call(aData, info);
|
||||||
done = true;
|
done = true;
|
||||||
@ -205,6 +227,7 @@
|
|||||||
this._dispatchEvent('UIOperationGlobalHistoryUndo', options, entry.data, done);
|
this._dispatchEvent('UIOperationGlobalHistoryUndo', options, entry.data, done);
|
||||||
}
|
}
|
||||||
this._doingUndo = false;
|
this._doingUndo = false;
|
||||||
|
log('undo finish');
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
throw error;
|
throw error;
|
||||||
@ -214,6 +237,7 @@
|
|||||||
|
|
||||||
redo : function()
|
redo : function()
|
||||||
{
|
{
|
||||||
|
log('undo start');
|
||||||
var options = this._getOptionsFromArguments(arguments);
|
var options = this._getOptionsFromArguments(arguments);
|
||||||
var history = options.history;
|
var history = options.history;
|
||||||
var max = history.entries.length;
|
var max = history.entries.length;
|
||||||
@ -227,16 +251,19 @@
|
|||||||
{
|
{
|
||||||
let entry = history.entries[++history.index];
|
let entry = history.entries[++history.index];
|
||||||
if (!entry) continue;
|
if (!entry) continue;
|
||||||
|
log('redo '+(history.index)+' '+entry.label);
|
||||||
let done = false;
|
let done = false;
|
||||||
[entry.data].concat(entry.children).forEach(function(aData, aIndex) {
|
[entry.data].concat(entry.children).forEach(function(aData, aIndex) {
|
||||||
|
log('redo level '+(aIndex)+' '+aData.label);
|
||||||
let f = this._getAvailableFunction(aData.onRedo, aData.onredo, aData.redo);
|
let f = this._getAvailableFunction(aData.onRedo, aData.onredo, aData.redo);
|
||||||
let done = false;
|
let done = false;
|
||||||
try {
|
try {
|
||||||
if (f) {
|
if (f) {
|
||||||
let info = {
|
let info = {
|
||||||
level : aIndex,
|
level : aIndex,
|
||||||
parent : (aIndex ? entry.data : null ),
|
parent : (aIndex ? entry.data : null ),
|
||||||
done : processed && done
|
done : processed && done,
|
||||||
|
manager : this
|
||||||
};
|
};
|
||||||
let oneProcessed = f.call(aData, info);
|
let oneProcessed = f.call(aData, info);
|
||||||
done = true;
|
done = true;
|
||||||
@ -254,6 +281,7 @@
|
|||||||
this._dispatchEvent('UIOperationGlobalHistoryRedo', options, entry.data, done);
|
this._dispatchEvent('UIOperationGlobalHistoryRedo', options, entry.data, done);
|
||||||
}
|
}
|
||||||
this._doingUndo = false;
|
this._doingUndo = false;
|
||||||
|
log('redo finish');
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
throw error;
|
throw error;
|
||||||
|
Loading…
Reference in New Issue
Block a user