refactor(sort) add

This commit is contained in:
coderaiser 2017-02-06 14:59:10 +02:00
parent 82e38cb7c4
commit 61eba36c67
3 changed files with 41 additions and 27 deletions

View file

@ -24,7 +24,8 @@ var CloudCmd;
client + 'buffer',
client + 'listeners',
client + 'key',
client + 'directory'
client + 'directory',
client + 'sort'
];
var moduleFiles = [

View file

@ -32,12 +32,6 @@ var Util, DOM, CloudFunc, CloudCmd;
function header() {
var fm = DOM.getFM();
var position = Info.panelPosition;
var sortPrevious = CloudCmd.sort[position];
var sort = CloudCmd.sort;
var order = CloudCmd.order;
var isDataset = function(el) {
return el.dataset;
};
@ -64,26 +58,7 @@ var Util, DOM, CloudFunc, CloudCmd;
.filter(isPanel)
.pop();
var position = panel
.dataset
.name
.replace('js-', '');
if (name !== sortPrevious) {
order[position] = 'asc';
} else {
if (order[position] === 'asc')
order[position] = 'desc';
else
order[position] = 'asc';
}
sortPrevious =
sort[position] = name;
CloudCmd.refresh(panel, {
noCurrent: position !== Info.panelPosition
});
CloudCmd.sortPanel(name, panel);
});
}

38
client/sort.js Normal file
View file

@ -0,0 +1,38 @@
/* global CloudCmd */
/* global DOM */
(function() {
'use strict';
var Info = DOM.CurrentInfo;
var sort = CloudCmd.sort;
var order = CloudCmd.order;
var position = DOM.getPanelPosition();
var sortPrevious = sort[position];
CloudCmd.sortPanel = function(name, panel) {
panel = panel || DOM.getPanel();
var position = panel
.dataset
.name
.replace('js-', '');
if (name !== sortPrevious) {
order[position] = 'asc';
} else {
if (order[position] === 'asc')
order[position] = 'desc';
else
order[position] = 'asc';
}
sortPrevious =
sort[position] = name;
CloudCmd.refresh(panel, {
noCurrent: position !== Info.panelPosition
});
};
})();