Skip to content

Commit

Permalink
feature(cloudcmd) rm jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Sep 19, 2018
1 parent ec2591b commit 8ab8adb
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 2,822 deletions.
9 changes: 0 additions & 9 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ cssnano.config.js

bin/release.js

modules/jquery/dist
modules/jquery/external
modules/jquery/src

!modules/jquery/dist/jquery.min.js

modules/execon
modules/emitify

client
legacy
server_
Expand Down
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ node_modules
npm-debug.log*
coverage

modules/jquery-mouse-wheel

modules/jquery/dist
modules/jquery/external
modules/jquery/src

!modules/jquery/dist/jquery.min.js

modules/execon
modules/emitify

Expand Down
8 changes: 0 additions & 8 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ yarn.lock
now.json
cssnano.config.js

modules/jquery-mouse-wheel

modules/jquery/dist
modules/jquery/external
modules/jquery/src

!modules/jquery/dist/jquery.min.js

app.json
bower.json
manifest.yml
Expand Down
3 changes: 1 addition & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"test"
],
"dependencies": {
"olark": "^1.0.0",
"jquery": "3.3.1"
"olark": "^1.0.0"
}
}
5 changes: 2 additions & 3 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ function CloudCmdProto(DOM) {

const {
load,
loadJquery,
} = DOM;

const funcBefore = (callback) => {
const funcBefore = (callback) => {
const src = prefix + CloudCmd.DIRCLIENT_MODULES + 'polyfill.js';
loadJquery(wraptile(load.js, src, callback));
load.js(src, callback));
};

CloudCmd.PREFIX = prefix;
Expand Down
11 changes: 0 additions & 11 deletions client/dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ function CmdProto() {
loadRemote(name, options, callback);
return DOM;
};
/**
* load jquery from google cdn or local copy
* @param callback
*/
this.loadJquery = function(callback) {
DOM.loadRemote('jquery', {
name : '$'
}, callback);

return DOM;
};

this.loadSocket = function(callback) {
DOM.loadRemote('socket', {
Expand Down
40 changes: 40 additions & 0 deletions client/modules/create-element.js
Original file line number Diff line number Diff line change
@@ -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);
}

21 changes: 14 additions & 7 deletions client/modules/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

/* global CloudCmd, DOM, $ */
/* global CloudCmd, DOM */

require('../../css/view.css');

Expand All @@ -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');
Expand Down Expand Up @@ -70,7 +71,6 @@ module.exports.init = promisify((fn) => {
Loading = true;

exec.series([
DOM.loadJquery,
loadAll,
(callback) => {
Loading = false;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions json/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
"cloud"
],
"remote": [{
"name": "jquery",
"version": "3.3.1",
"local": "/modules/jquery/dist/jquery.min.js",
"remote": "https://code.jquery.com/jquery-{{ version }}.min.js"
}, {
"name": "socket",
"version": "2.1.1",
"local": "/socket.io/socket.io.js",
Expand Down
25 changes: 0 additions & 25 deletions modules/jquery/.bower.json

This file was deleted.

Loading

0 comments on commit 8ab8adb

Please sign in to comment.