mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
36 lines
745 B
JavaScript
36 lines
745 B
JavaScript
'use strict';
|
|
|
|
/* global CloudCmd */
|
|
const DOM = require('./dom');
|
|
|
|
const Info = DOM.CurrentInfo;
|
|
|
|
const {sort, order} = CloudCmd;
|
|
|
|
const position = DOM.getPanelPosition();
|
|
|
|
let sortPrevious = sort[position];
|
|
|
|
const {getPanel} = DOM;
|
|
|
|
CloudCmd.sortPanel = (name, panel = getPanel()) => {
|
|
const 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;
|
|
|
|
const noCurrent = position !== Info.panelPosition;
|
|
|
|
CloudCmd.refresh({
|
|
panel,
|
|
noCurrent,
|
|
});
|
|
};
|