Edit File by line
/home/barbar84/www/wp-conte.../plugins/file-man.../applicat.../library/js
File: elFinder.history.js
/**
[0] Fix | Delete
* @class elFinder.history
[1] Fix | Delete
* Store visited folders
[2] Fix | Delete
* and provide "back" and "forward" methods
[3] Fix | Delete
*
[4] Fix | Delete
* @author Dmitry (dio) Levashov
[5] Fix | Delete
*/
[6] Fix | Delete
elFinder.prototype.history = function(fm) {
[7] Fix | Delete
"use strict";
[8] Fix | Delete
var self = this,
[9] Fix | Delete
/**
[10] Fix | Delete
* Update history on "open" event?
[11] Fix | Delete
*
[12] Fix | Delete
* @type Boolean
[13] Fix | Delete
*/
[14] Fix | Delete
update = true,
[15] Fix | Delete
/**
[16] Fix | Delete
* Directories hashes storage
[17] Fix | Delete
*
[18] Fix | Delete
* @type Array
[19] Fix | Delete
*/
[20] Fix | Delete
history = [],
[21] Fix | Delete
/**
[22] Fix | Delete
* Current directory index in history
[23] Fix | Delete
*
[24] Fix | Delete
* @type Number
[25] Fix | Delete
*/
[26] Fix | Delete
current,
[27] Fix | Delete
/**
[28] Fix | Delete
* Clear history
[29] Fix | Delete
*
[30] Fix | Delete
* @return void
[31] Fix | Delete
*/
[32] Fix | Delete
reset = function() {
[33] Fix | Delete
history = [fm.cwd().hash];
[34] Fix | Delete
current = 0;
[35] Fix | Delete
update = true;
[36] Fix | Delete
},
[37] Fix | Delete
/**
[38] Fix | Delete
* Browser native history object
[39] Fix | Delete
*/
[40] Fix | Delete
nativeHistory = (fm.options.useBrowserHistory && window.history && window.history.pushState)? window.history : null,
[41] Fix | Delete
/**
[42] Fix | Delete
* Open prev/next folder
[43] Fix | Delete
*
[44] Fix | Delete
* @Boolen open next folder?
[45] Fix | Delete
* @return jQuery.Deferred
[46] Fix | Delete
*/
[47] Fix | Delete
go = function(fwd) {
[48] Fix | Delete
if ((fwd && self.canForward()) || (!fwd && self.canBack())) {
[49] Fix | Delete
update = false;
[50] Fix | Delete
return fm.exec('open', history[fwd ? ++current : --current]).fail(reset);
[51] Fix | Delete
}
[52] Fix | Delete
return $.Deferred().reject();
[53] Fix | Delete
},
[54] Fix | Delete
/**
[55] Fix | Delete
* Sets the native history.
[56] Fix | Delete
*
[57] Fix | Delete
* @param String thash target hash
[58] Fix | Delete
*/
[59] Fix | Delete
setNativeHistory = function(thash) {
[60] Fix | Delete
if (nativeHistory && (! nativeHistory.state || nativeHistory.state.thash !== thash)) {
[61] Fix | Delete
nativeHistory.pushState({thash: thash}, null, location.pathname + location.search + (thash? '#elf_' + thash : ''));
[62] Fix | Delete
}
[63] Fix | Delete
};
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Return true if there is previous visited directories
[67] Fix | Delete
*
[68] Fix | Delete
* @return Boolen
[69] Fix | Delete
*/
[70] Fix | Delete
this.canBack = function() {
[71] Fix | Delete
return current > 0;
[72] Fix | Delete
};
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Return true if can go forward
[76] Fix | Delete
*
[77] Fix | Delete
* @return Boolen
[78] Fix | Delete
*/
[79] Fix | Delete
this.canForward = function() {
[80] Fix | Delete
return current < history.length - 1;
[81] Fix | Delete
};
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Go back
[85] Fix | Delete
*
[86] Fix | Delete
* @return void
[87] Fix | Delete
*/
[88] Fix | Delete
this.back = go;
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Go forward
[92] Fix | Delete
*
[93] Fix | Delete
* @return void
[94] Fix | Delete
*/
[95] Fix | Delete
this.forward = function() {
[96] Fix | Delete
return go(true);
[97] Fix | Delete
};
[98] Fix | Delete
[99] Fix | Delete
// bind to elfinder events
[100] Fix | Delete
fm.bind('init', function() {
[101] Fix | Delete
if (nativeHistory && !nativeHistory.state) {
[102] Fix | Delete
setNativeHistory(fm.startDir());
[103] Fix | Delete
}
[104] Fix | Delete
})
[105] Fix | Delete
.open(function() {
[106] Fix | Delete
var l = history.length,
[107] Fix | Delete
cwd = fm.cwd().hash;
[108] Fix | Delete
[109] Fix | Delete
if (update) {
[110] Fix | Delete
current >= 0 && l > current + 1 && history.splice(current+1);
[111] Fix | Delete
history[history.length-1] != cwd && history.push(cwd);
[112] Fix | Delete
current = history.length - 1;
[113] Fix | Delete
}
[114] Fix | Delete
update = true;
[115] Fix | Delete
[116] Fix | Delete
setNativeHistory(cwd);
[117] Fix | Delete
})
[118] Fix | Delete
.reload(fm.options.reloadClearHistory && reset);
[119] Fix | Delete
[120] Fix | Delete
};
[121] Fix | Delete
[122] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function