Edit File by line
/home/barbar84/www/wp-conte.../plugins/file-man.../applicat.../library/js/commands
File: view.js
/**
[0] Fix | Delete
* @class elFinder command "view"
[1] Fix | Delete
* Change current directory view (icons/list)
[2] Fix | Delete
*
[3] Fix | Delete
* @author Dmitry (dio) Levashov
[4] Fix | Delete
**/
[5] Fix | Delete
elFinder.prototype.commands.view = function() {
[6] Fix | Delete
"use strict";
[7] Fix | Delete
var self = this,
[8] Fix | Delete
fm = this.fm,
[9] Fix | Delete
subMenuRaw;
[10] Fix | Delete
this.value = fm.viewType;
[11] Fix | Delete
this.alwaysEnabled = true;
[12] Fix | Delete
this.updateOnSelect = false;
[13] Fix | Delete
[14] Fix | Delete
this.options = { ui : 'viewbutton'};
[15] Fix | Delete
[16] Fix | Delete
this.getstate = function() {
[17] Fix | Delete
return 0;
[18] Fix | Delete
};
[19] Fix | Delete
[20] Fix | Delete
this.extra = {
[21] Fix | Delete
icon: 'menu',
[22] Fix | Delete
node: $('<span></span>')
[23] Fix | Delete
.attr({title: fm.i18n('viewtype')})
[24] Fix | Delete
.on('click touchstart', function(e){
[25] Fix | Delete
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
[26] Fix | Delete
return;
[27] Fix | Delete
}
[28] Fix | Delete
var node = $(this);
[29] Fix | Delete
e.stopPropagation();
[30] Fix | Delete
e.preventDefault();
[31] Fix | Delete
fm.trigger('contextmenu', {
[32] Fix | Delete
raw: getSubMenuRaw(),
[33] Fix | Delete
x: node.offset().left,
[34] Fix | Delete
y: node.offset().top
[35] Fix | Delete
});
[36] Fix | Delete
})
[37] Fix | Delete
};
[38] Fix | Delete
[39] Fix | Delete
this.exec = function() {
[40] Fix | Delete
var self = this,
[41] Fix | Delete
value = this.value == 'list' ? 'icons' : 'list';
[42] Fix | Delete
[43] Fix | Delete
fm.storage('view', value);
[44] Fix | Delete
return fm.lazy(function() {
[45] Fix | Delete
fm.viewchange();
[46] Fix | Delete
self.update(void(0), value);
[47] Fix | Delete
this.resolve();
[48] Fix | Delete
});
[49] Fix | Delete
};
[50] Fix | Delete
[51] Fix | Delete
fm.bind('init', function() {
[52] Fix | Delete
subMenuRaw = (function() {
[53] Fix | Delete
var cwd = fm.getUI('cwd'),
[54] Fix | Delete
raws = [],
[55] Fix | Delete
sizeNames = fm.options.uiOptions.cwd.iconsView.sizeNames,
[56] Fix | Delete
max = fm.options.uiOptions.cwd.iconsView.sizeMax,
[57] Fix | Delete
i, size;
[58] Fix | Delete
for (i = 0; i <= max; i++) {
[59] Fix | Delete
raws.push(
[60] Fix | Delete
{
[61] Fix | Delete
label : fm.i18n(sizeNames[i] || ('Size-' + i + ' icons')),
[62] Fix | Delete
icon : 'view',
[63] Fix | Delete
callback : (function(s) {
[64] Fix | Delete
return function() {
[65] Fix | Delete
cwd.trigger('iconpref', {size: s});
[66] Fix | Delete
fm.storage('iconsize', s);
[67] Fix | Delete
if (self.value === 'list') {
[68] Fix | Delete
self.exec();
[69] Fix | Delete
}
[70] Fix | Delete
};
[71] Fix | Delete
})(i)
[72] Fix | Delete
}
[73] Fix | Delete
);
[74] Fix | Delete
}
[75] Fix | Delete
raws.push('|');
[76] Fix | Delete
raws.push(
[77] Fix | Delete
{
[78] Fix | Delete
label : fm.i18n('viewlist'),
[79] Fix | Delete
icon : 'view-list',
[80] Fix | Delete
callback : function() {
[81] Fix | Delete
if (self.value !== 'list') {
[82] Fix | Delete
self.exec();
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
);
[87] Fix | Delete
return raws;
[88] Fix | Delete
})();
[89] Fix | Delete
}).bind('contextmenucreate', function() {
[90] Fix | Delete
self.extra = {
[91] Fix | Delete
icon: 'menu',
[92] Fix | Delete
node: $('<span></span>')
[93] Fix | Delete
.attr({title: fm.i18n('cmdview')})
[94] Fix | Delete
.on('click touchstart', function(e){
[95] Fix | Delete
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
[96] Fix | Delete
return;
[97] Fix | Delete
}
[98] Fix | Delete
var node = $(this),
[99] Fix | Delete
raw = subMenuRaw.concat(),
[100] Fix | Delete
idx, i;
[101] Fix | Delete
if (self.value === 'list') {
[102] Fix | Delete
idx = subMenuRaw.length - 1;
[103] Fix | Delete
} else {
[104] Fix | Delete
idx = parseInt(fm.storage('iconsize') || 0);
[105] Fix | Delete
}
[106] Fix | Delete
for (i = 0; i < subMenuRaw.length; i++) {
[107] Fix | Delete
if (subMenuRaw[i] !== '|') {
[108] Fix | Delete
subMenuRaw[i].options = (i === idx? {'className': 'ui-state-active'} : void(0))
[109] Fix | Delete
;
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
e.stopPropagation();
[113] Fix | Delete
e.preventDefault();
[114] Fix | Delete
fm.trigger('contextmenu', {
[115] Fix | Delete
raw: subMenuRaw,
[116] Fix | Delete
x: node.offset().left,
[117] Fix | Delete
y: node.offset().top
[118] Fix | Delete
});
[119] Fix | Delete
})
[120] Fix | Delete
};
[121] Fix | Delete
});
[122] Fix | Delete
[123] Fix | Delete
};
[124] Fix | Delete
[125] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function