mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-01 20:22:29 +00:00
feature(cloudcmd) rm jquery
This commit is contained in:
parent
ec2591bff2
commit
8ab8adb400
19 changed files with 57 additions and 2822 deletions
40
client/modules/create-element.js
Normal file
40
client/modules/create-element.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
const query = (a) => document.querySelector(`[data-name="${a}"]`);
|
||||
const isStr = (a) => typeof a === 'string';
|
||||
|
||||
module.exports = (name, {innerHTML, className, dataName, textContent, parent} = {}) => {
|
||||
parent = parent || document.body;
|
||||
className = className || '';
|
||||
dataName = dataName || '';
|
||||
|
||||
const elFound = isElementPresent(dataName);
|
||||
|
||||
if (elFound)
|
||||
return elFound;
|
||||
|
||||
const el = document.createElement(name);
|
||||
|
||||
if (isStr(innerHTML))
|
||||
el.innerHTML = innerHTML;
|
||||
|
||||
if (isStr(textContent))
|
||||
el.textContent = textContent;
|
||||
|
||||
el.className = className;
|
||||
el.dataset.name = dataName;
|
||||
|
||||
parent.appendChild(el);
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
module.exports.isElementPresent = isElementPresent;
|
||||
|
||||
function isElementPresent(dataName) {
|
||||
if (!dataName)
|
||||
return;
|
||||
|
||||
return query(dataName);
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
/* global CloudCmd, DOM, $ */
|
||||
/* global CloudCmd, DOM */
|
||||
|
||||
require('../../css/view.css');
|
||||
|
||||
|
|
@ -11,6 +11,7 @@ const currify = require('currify/legacy');
|
|||
const {promisify} = require('es6-promisify');
|
||||
|
||||
const modal = require('@cloudcmd/modal');
|
||||
const createElement = require('./create-element')
|
||||
|
||||
const {time} = require('../../common/util');
|
||||
const {FS} = require('../../common/cloudfunc');
|
||||
|
|
@ -70,7 +71,6 @@ module.exports.init = promisify((fn) => {
|
|||
Loading = true;
|
||||
|
||||
exec.series([
|
||||
DOM.loadJquery,
|
||||
loadAll,
|
||||
(callback) => {
|
||||
Loading = false;
|
||||
|
|
@ -95,11 +95,15 @@ function show(data, options) {
|
|||
if (!options || options.bindKeys !== false)
|
||||
Events.addKey(listener);
|
||||
|
||||
El = $('<div class="view" tabindex=0>');
|
||||
El = createElement('div', {
|
||||
className: 'view',
|
||||
});
|
||||
|
||||
El.tabindex = 0;
|
||||
|
||||
if (data) {
|
||||
const element = $(El).append(data);
|
||||
modal.open(element[0], initConfig(Config, options));
|
||||
El.append(data);
|
||||
modal.open(El, initConfig(Config, options));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -151,12 +155,15 @@ function viewFile() {
|
|||
if (CloudCmd.config('showFileName'))
|
||||
options.title = Info.name;
|
||||
|
||||
modal.open(El.append(element)[0], options);
|
||||
El.append(element);
|
||||
modal.open(El, options);
|
||||
});
|
||||
}
|
||||
|
||||
function initConfig(Config, options) {
|
||||
const config = Object.assign({}, Config);
|
||||
const config = {
|
||||
...Config
|
||||
};
|
||||
|
||||
if (!options)
|
||||
return config;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue