Edit File by line
/home/barbar84/www/wp-conte.../plugins/file-man.../applicat.../library/js/commands
File: undo.js
/**
[0] Fix | Delete
* @class elFinder command "undo"
[1] Fix | Delete
* Undo previous commands
[2] Fix | Delete
*
[3] Fix | Delete
* @author Naoki Sawada
[4] Fix | Delete
**/
[5] Fix | Delete
elFinder.prototype.commands.undo = function() {
[6] Fix | Delete
"use strict";
[7] Fix | Delete
var self = this,
[8] Fix | Delete
fm = this.fm,
[9] Fix | Delete
setTitle = function(undo) {
[10] Fix | Delete
if (undo) {
[11] Fix | Delete
self.title = fm.i18n('cmdundo') + ' ' + fm.i18n('cmd'+undo.cmd);
[12] Fix | Delete
self.state = 0;
[13] Fix | Delete
} else {
[14] Fix | Delete
self.title = fm.i18n('cmdundo');
[15] Fix | Delete
self.state = -1;
[16] Fix | Delete
}
[17] Fix | Delete
self.change();
[18] Fix | Delete
},
[19] Fix | Delete
cmds = [];
[20] Fix | Delete
[21] Fix | Delete
this.alwaysEnabled = true;
[22] Fix | Delete
this.updateOnSelect = false;
[23] Fix | Delete
this.shortcuts = [{
[24] Fix | Delete
pattern : 'ctrl+z'
[25] Fix | Delete
}];
[26] Fix | Delete
this.syncTitleOnChange = true;
[27] Fix | Delete
[28] Fix | Delete
this.getstate = function() {
[29] Fix | Delete
return cmds.length? 0 : -1;
[30] Fix | Delete
};
[31] Fix | Delete
[32] Fix | Delete
this.setUndo = function(undo, redo) {
[33] Fix | Delete
var _undo = {};
[34] Fix | Delete
if (undo) {
[35] Fix | Delete
if ($.isPlainObject(undo) && undo.cmd && undo.callback) {
[36] Fix | Delete
Object.assign(_undo, undo);
[37] Fix | Delete
if (redo) {
[38] Fix | Delete
delete redo.undo;
[39] Fix | Delete
_undo.redo = redo;
[40] Fix | Delete
} else {
[41] Fix | Delete
fm.getCommand('redo').setRedo(null);
[42] Fix | Delete
}
[43] Fix | Delete
cmds.push(_undo);
[44] Fix | Delete
setTitle(_undo);
[45] Fix | Delete
}
[46] Fix | Delete
}
[47] Fix | Delete
};
[48] Fix | Delete
[49] Fix | Delete
this.exec = function() {
[50] Fix | Delete
var redo = fm.getCommand('redo'),
[51] Fix | Delete
dfd = $.Deferred(),
[52] Fix | Delete
undo, res, _redo = {};
[53] Fix | Delete
if (cmds.length) {
[54] Fix | Delete
undo = cmds.pop();
[55] Fix | Delete
if (undo.redo) {
[56] Fix | Delete
Object.assign(_redo, undo.redo);
[57] Fix | Delete
delete undo.redo;
[58] Fix | Delete
} else {
[59] Fix | Delete
_redo = null;
[60] Fix | Delete
}
[61] Fix | Delete
dfd.done(function() {
[62] Fix | Delete
if (_redo) {
[63] Fix | Delete
redo.setRedo(_redo, undo);
[64] Fix | Delete
}
[65] Fix | Delete
});
[66] Fix | Delete
[67] Fix | Delete
setTitle(cmds.length? cmds[cmds.length-1] : void(0));
[68] Fix | Delete
[69] Fix | Delete
res = undo.callback();
[70] Fix | Delete
[71] Fix | Delete
if (res && res.done) {
[72] Fix | Delete
res.done(function() {
[73] Fix | Delete
dfd.resolve();
[74] Fix | Delete
}).fail(function() {
[75] Fix | Delete
dfd.reject();
[76] Fix | Delete
});
[77] Fix | Delete
} else {
[78] Fix | Delete
dfd.resolve();
[79] Fix | Delete
}
[80] Fix | Delete
if (cmds.length) {
[81] Fix | Delete
this.update(0, cmds[cmds.length - 1].name);
[82] Fix | Delete
} else {
[83] Fix | Delete
this.update(-1, '');
[84] Fix | Delete
}
[85] Fix | Delete
} else {
[86] Fix | Delete
dfd.reject();
[87] Fix | Delete
}
[88] Fix | Delete
return dfd;
[89] Fix | Delete
};
[90] Fix | Delete
[91] Fix | Delete
fm.bind('exec', function(e) {
[92] Fix | Delete
var data = e.data || {};
[93] Fix | Delete
if (data.opts && data.opts._userAction) {
[94] Fix | Delete
if (data.dfrd && data.dfrd.done) {
[95] Fix | Delete
data.dfrd.done(function(res) {
[96] Fix | Delete
if (res && res.undo && res.redo) {
[97] Fix | Delete
res.undo.redo = res.redo;
[98] Fix | Delete
self.setUndo(res.undo);
[99] Fix | Delete
}
[100] Fix | Delete
});
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
});
[104] Fix | Delete
};
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* @class elFinder command "redo"
[108] Fix | Delete
* Redo previous commands
[109] Fix | Delete
*
[110] Fix | Delete
* @author Naoki Sawada
[111] Fix | Delete
**/
[112] Fix | Delete
elFinder.prototype.commands.redo = function() {
[113] Fix | Delete
"use strict";
[114] Fix | Delete
var self = this,
[115] Fix | Delete
fm = this.fm,
[116] Fix | Delete
setTitle = function(redo) {
[117] Fix | Delete
if (redo && redo.callback) {
[118] Fix | Delete
self.title = fm.i18n('cmdredo') + ' ' + fm.i18n('cmd'+redo.cmd);
[119] Fix | Delete
self.state = 0;
[120] Fix | Delete
} else {
[121] Fix | Delete
self.title = fm.i18n('cmdredo');
[122] Fix | Delete
self.state = -1;
[123] Fix | Delete
}
[124] Fix | Delete
self.change();
[125] Fix | Delete
},
[126] Fix | Delete
cmds = [];
[127] Fix | Delete
[128] Fix | Delete
this.alwaysEnabled = true;
[129] Fix | Delete
this.updateOnSelect = false;
[130] Fix | Delete
this.shortcuts = [{
[131] Fix | Delete
pattern : 'shift+ctrl+z ctrl+y'
[132] Fix | Delete
}];
[133] Fix | Delete
this.syncTitleOnChange = true;
[134] Fix | Delete
[135] Fix | Delete
this.getstate = function() {
[136] Fix | Delete
return cmds.length? 0 : -1;
[137] Fix | Delete
};
[138] Fix | Delete
[139] Fix | Delete
this.setRedo = function(redo, undo) {
[140] Fix | Delete
if (redo === null) {
[141] Fix | Delete
cmds = [];
[142] Fix | Delete
setTitle();
[143] Fix | Delete
} else {
[144] Fix | Delete
if (redo && redo.cmd && redo.callback) {
[145] Fix | Delete
if (undo) {
[146] Fix | Delete
redo.undo = undo;
[147] Fix | Delete
}
[148] Fix | Delete
cmds.push(redo);
[149] Fix | Delete
setTitle(redo);
[150] Fix | Delete
}
[151] Fix | Delete
}
[152] Fix | Delete
};
[153] Fix | Delete
[154] Fix | Delete
this.exec = function() {
[155] Fix | Delete
var undo = fm.getCommand('undo'),
[156] Fix | Delete
dfd = $.Deferred(),
[157] Fix | Delete
redo, res, _undo = {}, _redo = {};
[158] Fix | Delete
if (cmds.length) {
[159] Fix | Delete
redo = cmds.pop();
[160] Fix | Delete
if (redo.undo) {
[161] Fix | Delete
Object.assign(_undo, redo.undo);
[162] Fix | Delete
Object.assign(_redo, redo);
[163] Fix | Delete
delete _redo.undo;
[164] Fix | Delete
dfd.done(function() {
[165] Fix | Delete
undo.setUndo(_undo, _redo);
[166] Fix | Delete
});
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
setTitle(cmds.length? cmds[cmds.length-1] : void(0));
[170] Fix | Delete
[171] Fix | Delete
res = redo.callback();
[172] Fix | Delete
[173] Fix | Delete
if (res && res.done) {
[174] Fix | Delete
res.done(function() {
[175] Fix | Delete
dfd.resolve();
[176] Fix | Delete
}).fail(function() {
[177] Fix | Delete
dfd.reject();
[178] Fix | Delete
});
[179] Fix | Delete
} else {
[180] Fix | Delete
dfd.resolve();
[181] Fix | Delete
}
[182] Fix | Delete
return dfd;
[183] Fix | Delete
} else {
[184] Fix | Delete
return dfd.reject();
[185] Fix | Delete
}
[186] Fix | Delete
};
[187] Fix | Delete
};
[188] Fix | Delete
[189] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function