mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(package) add domtokenlist-shim from npm
This commit is contained in:
parent
1ce28fd500
commit
d3cbd442e7
9 changed files with 12 additions and 13245 deletions
|
|
@ -28,7 +28,6 @@
|
|||
"test"
|
||||
],
|
||||
"dependencies": {
|
||||
"domtokenlist-shim": "~1.1.0",
|
||||
"olark": "^1.0.0",
|
||||
"jquery": "3.3.1",
|
||||
"fancybox": "^2.1.6"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ const itype = require('itype/legacy');
|
|||
const Emitify = require('emitify/legacy');
|
||||
const inherits = require('inherits');
|
||||
const rendy = require('rendy/legacy');
|
||||
const wraptile = require('wraptile/legacy');
|
||||
const exec = require('execon');
|
||||
|
||||
const Images = require('./dom/images');
|
||||
const {
|
||||
registerSW,
|
||||
|
|
@ -185,16 +187,14 @@ function CloudCmdProto(Util, DOM) {
|
|||
exec.with(CloudCmd.route, location.hash),
|
||||
], noop);
|
||||
|
||||
const addPrefix = (a) => `${prefix}${a}`;
|
||||
const {
|
||||
load,
|
||||
loadJquery,
|
||||
} = DOM;
|
||||
|
||||
const funcBefore = (callback) => {
|
||||
const srcs = [
|
||||
CloudCmd.DIRCLIENT_MODULES + 'polyfill.js',
|
||||
'/modules/domtokenlist-shim/dist/domtokenlist.min.js',
|
||||
].map(addPrefix);
|
||||
|
||||
DOM.loadJquery(() => {
|
||||
DOM.load.parallel(srcs, callback);
|
||||
});
|
||||
const src = prefix + CloudCmd.DIRCLIENT_MODULES + 'polyfill.js';
|
||||
loadJquery(wraptile(load.js, src, callback));
|
||||
};
|
||||
|
||||
CloudCmd.PREFIX = prefix;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
/* global DOM */
|
||||
|
||||
require('domtokenlist-shim');
|
||||
|
||||
const scrollIntoViewIfNeeded = require('scroll-into-view-if-needed').default;
|
||||
DOM.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
"name": "domtokenlist-shim",
|
||||
"description": "A super strict shim/polyfill for DOMTokenList",
|
||||
"main": "dist/domtokenlist.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"*.json",
|
||||
"*.md",
|
||||
"gulpfile.js",
|
||||
"src",
|
||||
"tests",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test"
|
||||
],
|
||||
"keywords": [
|
||||
"classlist",
|
||||
"domtokenlist",
|
||||
"polyfill",
|
||||
"rellist",
|
||||
"shim"
|
||||
],
|
||||
"authors": [
|
||||
"Jonathan Wilsson <jonathan.wilsson@gmail.com>",
|
||||
"Bogdan Chadkin <trysound@yandex.ru>"
|
||||
],
|
||||
"homepage": "https://github.com/jwilsson/domtokenlist",
|
||||
"version": "1.1.1",
|
||||
"_release": "1.1.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.1.1",
|
||||
"commit": "83b9acb080e47a5dcdaa75f2351a0602ab8351b5"
|
||||
},
|
||||
"_source": "https://github.com/jwilsson/domtokenlist.git",
|
||||
"_target": "~1.1.0",
|
||||
"_originalSource": "domtokenlist-shim"
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"name": "domtokenlist-shim",
|
||||
"description": "A super strict shim/polyfill for DOMTokenList",
|
||||
"main": "dist/domtokenlist.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"*.json",
|
||||
"*.md",
|
||||
"gulpfile.js",
|
||||
"src",
|
||||
"tests",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test"
|
||||
],
|
||||
"keywords": [
|
||||
"classlist",
|
||||
"domtokenlist",
|
||||
"polyfill",
|
||||
"rellist",
|
||||
"shim"
|
||||
],
|
||||
"authors": [
|
||||
"Jonathan Wilsson <jonathan.wilsson@gmail.com>",
|
||||
"Bogdan Chadkin <trysound@yandex.ru>"
|
||||
],
|
||||
"homepage": "https://github.com/jwilsson/domtokenlist"
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
Before Width: | Height: | Size: 950 KiB |
211
modules/domtokenlist-shim/dist/domtokenlist.js
vendored
211
modules/domtokenlist-shim/dist/domtokenlist.js
vendored
|
|
@ -1,211 +0,0 @@
|
|||
/*! DOMTokenlist shim | Copyright 2015 Jonathan Wilsson and Bogdan Chadkin. */
|
||||
;(function (window) {
|
||||
'use strict';
|
||||
|
||||
if (!window.DOMTokenList) {
|
||||
return;
|
||||
}
|
||||
|
||||
var el = document.createElement('a').classList;
|
||||
var dtp = DOMTokenList.prototype;
|
||||
var add = dtp.add;
|
||||
var remove = dtp.remove;
|
||||
var toggle = dtp.toggle;
|
||||
|
||||
el.add('c1', 'c2');
|
||||
|
||||
// Older versions of the HTMLElement.classList spec didn't allow multiple
|
||||
// arguments, easy to test for
|
||||
var iterateArg = function (fn) {
|
||||
return function () {
|
||||
var tokens = arguments;
|
||||
var i;
|
||||
|
||||
for (i = 0; i < tokens.length; i += 1) {
|
||||
fn.call(this, tokens[i]);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
if (!el.contains('c2')) {
|
||||
dtp.add = iterateArg(add);
|
||||
dtp.remove = iterateArg(remove);
|
||||
}
|
||||
|
||||
// Older versions of the spec didn't have a forcedState argument for
|
||||
// `toggle` either, test by checking the return value after forcing
|
||||
if (!el.toggle('c1', true)) {
|
||||
dtp.toggle = function (cls, force) {
|
||||
if (force === undefined) {
|
||||
return toggle.call(this, cls);
|
||||
}
|
||||
|
||||
(force ? add : remove).call(this, cls);
|
||||
return !!force;
|
||||
};
|
||||
}
|
||||
}(window));
|
||||
|
||||
;(function (window) {
|
||||
'use strict';
|
||||
|
||||
var arr = [];
|
||||
|
||||
var inArray = function (array, value) {
|
||||
var i;
|
||||
|
||||
if (arr.indexOf) {
|
||||
return arr.indexOf.call(array, value);
|
||||
}
|
||||
|
||||
for (i = 0; i < array.length; i++) {
|
||||
if (array[i] === value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
var validateToken = function (token) {
|
||||
var whitespace = /[\u0009\u000A\u000C\u000D\u0020]/;
|
||||
|
||||
if (token === '' || whitespace.test(token)) {
|
||||
throw new Error('Token must not be empty or contain whitespace.');
|
||||
}
|
||||
};
|
||||
|
||||
var DOMTokenList = function (element, prop) {
|
||||
var inst = this;
|
||||
var i;
|
||||
var values = [];
|
||||
|
||||
if (element && prop) {
|
||||
inst.element = element;
|
||||
inst.prop = prop;
|
||||
|
||||
if (element[prop]) {
|
||||
values = element[prop].replace(/^\s+|\s+$/g, '').split(/\s+/);
|
||||
|
||||
for (i = 0; i < values.length; i++) {
|
||||
inst[i] = values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inst.length = values.length;
|
||||
};
|
||||
|
||||
DOMTokenList.prototype = {
|
||||
add: function () {
|
||||
var inst = this;
|
||||
var i;
|
||||
var tokens = arguments;
|
||||
|
||||
for (i = 0; i < tokens.length; i++) {
|
||||
validateToken(tokens[i]);
|
||||
|
||||
if (!inst.contains(tokens[i])) {
|
||||
arr.push.call(inst, tokens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (inst.element) {
|
||||
inst.element[inst.prop] = inst;
|
||||
}
|
||||
},
|
||||
|
||||
contains: function (token) {
|
||||
validateToken(token);
|
||||
|
||||
return inArray(this, token) !== -1;
|
||||
},
|
||||
|
||||
item: function (index) {
|
||||
return this[index] || null;
|
||||
},
|
||||
|
||||
remove: function () {
|
||||
var tokens = arguments;
|
||||
var inst = this;
|
||||
var key;
|
||||
var i;
|
||||
|
||||
for (i = 0; i < tokens.length; i++) {
|
||||
validateToken(tokens[i]);
|
||||
|
||||
key = inArray(inst, tokens[i]);
|
||||
|
||||
if (key !== -1) {
|
||||
arr.splice.call(inst, key, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (inst.element) {
|
||||
inst.element[inst.prop] = inst;
|
||||
}
|
||||
},
|
||||
|
||||
toggle: function (token, force) {
|
||||
var inst = this;
|
||||
|
||||
if (inst.contains(token)) {
|
||||
if (force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
inst.remove(token);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
if (force === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inst.add(token);
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return arr.join.call(this, ' ');
|
||||
}
|
||||
};
|
||||
|
||||
window.DOMTokenList = DOMTokenList;
|
||||
}(window));
|
||||
|
||||
;(function () {
|
||||
'use strict';
|
||||
|
||||
if ('classList' in document.createElement('a') && !window.QUnit) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.defineProperty(Element.prototype, 'classList', {
|
||||
get: function () {
|
||||
return new DOMTokenList(this, 'className');
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
;(function () {
|
||||
'use strict';
|
||||
|
||||
if ('relList' in document.createElement('a') && !window.QUnit) {
|
||||
return;
|
||||
}
|
||||
|
||||
var i;
|
||||
var elements = [HTMLAnchorElement, HTMLAreaElement, HTMLLinkElement];
|
||||
var getter = function () {
|
||||
return new DOMTokenList(this, 'rel');
|
||||
};
|
||||
|
||||
for (i = 0; i < elements.length; i++) {
|
||||
Object.defineProperty(elements[i].prototype, 'relList', {
|
||||
get: getter
|
||||
});
|
||||
}
|
||||
}());
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
/*! DOMTokenlist shim | Copyright 2015 Jonathan Wilsson and Bogdan Chadkin. */
|
||||
!function(t){"use strict";if(t.DOMTokenList){var e=document.createElement("a").classList,n=DOMTokenList.prototype,r=n.add,i=n.remove,o=n.toggle;e.add("c1","c2");var c=function(t){return function(){var e,n=arguments;for(e=0;e<n.length;e+=1)t.call(this,n[e])}};e.contains("c2")||(n.add=c(r),n.remove=c(i)),e.toggle("c1",!0)||(n.toggle=function(t,e){return void 0===e?o.call(this,t):((e?r:i).call(this,t),!!e)})}}(window),function(t){"use strict";var e=[],n=function(t,n){var r;if(e.indexOf)return e.indexOf.call(t,n);for(r=0;r<t.length;r++)if(t[r]===n)return r;return-1},r=function(t){var e=/[\u0009\u000A\u000C\u000D\u0020]/;if(""===t||e.test(t))throw new Error("Token must not be empty or contain whitespace.")},i=function(t,e){var n,r=this,i=[];if(t&&e&&(r.element=t,r.prop=e,t[e]))for(i=t[e].replace(/^\s+|\s+$/g,"").split(/\s+/),n=0;n<i.length;n++)r[n]=i[n];r.length=i.length};i.prototype={add:function(){var t,n=this,i=arguments;for(t=0;t<i.length;t++)r(i[t]),n.contains(i[t])||e.push.call(n,i[t]);n.element&&(n.element[n.prop]=n)},contains:function(t){return r(t),-1!==n(this,t)},item:function(t){return this[t]||null},remove:function(){var t,i,o=arguments,c=this;for(i=0;i<o.length;i++)r(o[i]),t=n(c,o[i]),-1!==t&&e.splice.call(c,t,1);c.element&&(c.element[c.prop]=c)},toggle:function(t,e){var n=this;return n.contains(t)?e?!0:(n.remove(t),!1):e===!1?!1:(n.add(t),!0)},toString:function(){return e.join.call(this," ")}},t.DOMTokenList=i}(window),function(){"use strict";"classList"in document.createElement("a")&&!window.QUnit||Object.defineProperty(Element.prototype,"classList",{get:function(){return new DOMTokenList(this,"className")}})}(),function(){"use strict";if(!("relList"in document.createElement("a"))||window.QUnit){var t,e=[HTMLAnchorElement,HTMLAreaElement,HTMLLinkElement],n=function(){return new DOMTokenList(this,"rel")};for(t=0;t<e.length;t++)Object.defineProperty(e[t].prototype,"relList",{get:n})}}();
|
||||
|
|
@ -167,6 +167,7 @@
|
|||
"clear-module": "^2.1.0",
|
||||
"coveralls": "^3.0.0",
|
||||
"css-loader": "^0.28.4",
|
||||
"domtokenlist-shim": "^1.2.0",
|
||||
"emitify": "^3.0.2",
|
||||
"es6-promise": "^4.0.5",
|
||||
"eslint": "^4.0.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue