mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature: client: sort: migrate to ESM
This commit is contained in:
parent
e27ef51d43
commit
6e778a35ba
2 changed files with 20 additions and 12 deletions
|
|
@ -7,6 +7,7 @@ const wraptile = require('wraptile');
|
|||
const load = require('load.js');
|
||||
|
||||
const {registerSW, listenSW} = require('./sw/register');
|
||||
const {initSortPanel, sortPanel} = require('./sort.mjs');
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
|
|
@ -21,11 +22,12 @@ module.exports = async (config) => {
|
|||
|
||||
require('./listeners');
|
||||
require('./key');
|
||||
require('./sort');
|
||||
|
||||
initSortPanel();
|
||||
globalThis.CloudCmd.sortPanel = sortPanel;
|
||||
const prefix = getPrefix(config.prefix);
|
||||
|
||||
window.CloudCmd.init(prefix, config);
|
||||
globalThis.CloudCmd.init(prefix, config);
|
||||
|
||||
if (window.CloudCmd.config('menu') === 'aleman')
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -1,26 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
/* global CloudCmd */
|
||||
const DOM = require('./dom');
|
||||
import {fullstore} from 'fullstore';
|
||||
import DOM from './dom/index.js';
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const {sort, order} = CloudCmd;
|
||||
const position = DOM.getPanelPosition();
|
||||
let sortPrevious = sort[position];
|
||||
const sortPrevious = fullstore();
|
||||
|
||||
const {getPanel} = DOM;
|
||||
|
||||
CloudCmd.sortPanel = (name, panel = getPanel()) => {
|
||||
export const initSortPanel = () => {
|
||||
const {sort, order} = CloudCmd;
|
||||
const position = DOM.getPanelPosition();
|
||||
|
||||
sortPrevious(sort[position]);
|
||||
};
|
||||
|
||||
export const sortPanel = (name, panel = getPanel()) => {
|
||||
const {sort, order} = CloudCmd;
|
||||
const Info = DOM.CurrentInfo;
|
||||
const position = panel.dataset.name.replace('js-', '');
|
||||
|
||||
if (name !== sortPrevious)
|
||||
if (name !== sortPrevious())
|
||||
order[position] = 'asc';
|
||||
else if (order[position] === 'asc')
|
||||
order[position] = 'desc';
|
||||
else
|
||||
order[position] = 'asc';
|
||||
|
||||
sortPrevious = name;
|
||||
sortPrevious(name);
|
||||
sort[position] = name;
|
||||
const noCurrent = position !== Info.panelPosition;
|
||||
|
||||
|
|
@ -29,3 +34,4 @@ CloudCmd.sortPanel = (name, panel = getPanel()) => {
|
|||
noCurrent,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue