* @class elFinder command "view"
* Change current directory view (icons/list)
* @author Dmitry (dio) Levashov
elFinder.prototype.commands.view = function() {
this.value = fm.viewType;
this.alwaysEnabled = true;
this.updateOnSelect = false;
this.options = { ui : 'viewbutton'};
this.getstate = function() {
.attr({title: fm.i18n('viewtype')})
.on('click touchstart', function(e){
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
fm.trigger('contextmenu', {
value = this.value == 'list' ? 'icons' : 'list';
fm.storage('view', value);
return fm.lazy(function() {
self.update(void(0), value);
fm.bind('init', function() {
subMenuRaw = (function() {
var cwd = fm.getUI('cwd'),
sizeNames = fm.options.uiOptions.cwd.iconsView.sizeNames,
max = fm.options.uiOptions.cwd.iconsView.sizeMax,
for (i = 0; i <= max; i++) {
label : fm.i18n(sizeNames[i] || ('Size-' + i + ' icons')),
callback : (function(s) {
cwd.trigger('iconpref', {size: s});
fm.storage('iconsize', s);
if (self.value === 'list') {
label : fm.i18n('viewlist'),
if (self.value !== 'list') {
}).bind('contextmenucreate', function() {
.attr({title: fm.i18n('cmdview')})
.on('click touchstart', function(e){
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
raw = subMenuRaw.concat(),
if (self.value === 'list') {
idx = subMenuRaw.length - 1;
idx = parseInt(fm.storage('iconsize') || 0);
for (i = 0; i < subMenuRaw.length; i++) {
if (subMenuRaw[i] !== '|') {
subMenuRaw[i].options = (i === idx? {'className': 'ui-state-active'} : void(0))
fm.trigger('contextmenu', {