mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(sort) add
This commit is contained in:
parent
82e38cb7c4
commit
61eba36c67
3 changed files with 41 additions and 27 deletions
|
|
@ -24,7 +24,8 @@ var CloudCmd;
|
|||
client + 'buffer',
|
||||
client + 'listeners',
|
||||
client + 'key',
|
||||
client + 'directory'
|
||||
client + 'directory',
|
||||
client + 'sort'
|
||||
];
|
||||
|
||||
var moduleFiles = [
|
||||
|
|
|
|||
|
|
@ -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
38
client/sort.js
Normal 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
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue