mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(bower) smalltalk v2.2.0
This commit is contained in:
parent
79c171655b
commit
c761d083a7
8 changed files with 158 additions and 129 deletions
|
|
@ -36,6 +36,6 @@
|
|||
"olark": "^1.0.0",
|
||||
"philip": "^1.3.3",
|
||||
"jquery": "3.1.1",
|
||||
"smalltalk": "2.1.4"
|
||||
"smalltalk": "2.2.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@
|
|||
"test"
|
||||
],
|
||||
"dependencies": {},
|
||||
"version": "2.1.4",
|
||||
"_release": "2.1.4",
|
||||
"version": "2.2.0",
|
||||
"_release": "2.2.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v2.1.4",
|
||||
"commit": "e543b688db2bb971195812138c3cd7b4dde2109d"
|
||||
"tag": "v2.2.0",
|
||||
"commit": "150c70746faa991c18f8d34417da9172ba87e586"
|
||||
},
|
||||
"_source": "https://github.com/coderaiser/smalltalk.git",
|
||||
"_target": "^2.1.4",
|
||||
"_target": "^2.2.0",
|
||||
"_originalSource": "smalltalk",
|
||||
"_direct": true
|
||||
}
|
||||
|
|
@ -1,3 +1,13 @@
|
|||
2017.02.24, v2.2.0
|
||||
|
||||
fix:
|
||||
- test(smalltalk) fixture: confirm, prompt
|
||||
- test(smalltalk) alert: fixture
|
||||
|
||||
feature:
|
||||
- (smalltalk) add currify
|
||||
|
||||
|
||||
2017.02.23, v2.1.4
|
||||
|
||||
fix:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Smalltalk [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL]
|
||||
====
|
||||
# Smalltalk [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage][CoverageIMGURL]][CoverageURL]
|
||||
|
||||
|
||||
Simple [Promise](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise)-based replacement of native Alert, Confirm and Prompt.
|
||||
|
||||
|
|
@ -81,3 +81,6 @@ MIT
|
|||
[DependencyStatusURL]: https://gemnasium.com/coderaiser/smalltalk "Dependency Status"
|
||||
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
|
||||
|
||||
[CoverageURL]: https://coveralls.io/github/coderaiser/smalltalk?branch=master
|
||||
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/smalltalk/badge.svg?branch=master&service=github
|
||||
|
||||
|
|
|
|||
2
modules/smalltalk/dist/smalltalk.min.js
vendored
2
modules/smalltalk/dist/smalltalk.min.js
vendored
|
|
@ -1 +1 @@
|
|||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.smalltalk=n()}}(function(){return function n(e,t,r){function o(u,i){if(!t[u]){if(!e[u]){var c="function"==typeof require&&require;if(!i&&c)return c(u,!0);if(a)return a(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[u]={exports:{}};e[u][0].call(l.exports,function(n){var t=e[u][1][n];return o(t?t:n)},l,l.exports,n,e,t,r)}return t[u].exports}for(var a="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({smalltalk:[function(n,e,t){"use strict";function r(n,e,t,r){if(!Array.isArray(r))throw Error("buttons should be array!");return'<div class="page">\n <div data-name="js-close" class="close-button"></div>\n <header>'+n+'</header>\n <div class="content-area">\n '+e+"\n "+t+'\n </div>\n <div class="action-area">\n <div class="button-strip"> '+r.map(function(n,e){return"<button tabindex="+e+' data-name="js-'+n.toLowerCase()+'">'+n+"</button>"}).join("")+"\n </div>\n </div>\n </div>"}function o(n,e,t,o,u){var i=void 0,c=void 0,s=document.createElement("div"),p=["cancel","close","ok"],v=new Promise(function(n,e){var t=u&&!u.cancel,r=function(){};i=n,c=t?r:e}),m=r(n,e,t,o);return s.innerHTML=m,s.className="smalltalk",document.body.appendChild(s),l(s,["ok","input"]).forEach(function(n){return n.focus()}),l(s,["input"]).forEach(function(n){n.setSelectionRange(0,t.length)}),d("click",s,p,function(n){return f(n.target,s,i,c)}),["click","contextmenu"].forEach(function(n){return s.addEventListener(n,function(){return l(s,["ok","input"]).forEach(function(n){return n.focus()})})}),s.addEventListener("keydown",a(s,i,c)),v}function a(n,e,t){return function(r){var o={ENTER:13,ESC:27,TAB:9,LEFT:37,UP:38,RIGHT:39,DOWN:40},a=r.keyCode,d=r.target,s=["ok","cancel","input"],p=l(n,s).map(function(n){return u(n)}),m=void 0;switch(a){case o.ENTER:f(d,n,e,t),r.preventDefault();break;case o.ESC:v(),t();break;case o.TAB:r.shiftKey&&c(n,p),c(n,p),r.preventDefault();break;default:m=["left","right","up","down"].some(function(n){return a===o[n.toUpperCase()]}),m&&i(n,p)}r.stopPropagation()}}function u(n){return n.getAttribute("data-name").replace("js-","")}function i(n,e){var t="",r=document.activeElement,o=u(r),a=/ok|cancel/.test(o),i=e.length-1;"input"!==o&&i&&a&&(t="cancel"===o?"ok":"cancel",l(n,[t]).forEach(function(n){n.focus()}))}function c(n,e){var t=document.activeElement,r=u(t),o=e.length-1,a=e.indexOf(r);a===o?a=0:a<o&&++a;var i=e[a];l(n,[i]).forEach(function(n){return n.focus()})}function f(n,e,t,r){var o=void 0,a=n.getAttribute("data-name").replace("js-","");/close|cancel/.test(a)?r():(o=l(e,["input"]).reduce(function(n,e){return e.value},null),t(o)),v()}function l(n,e){var t=e.map(function(e){return n.querySelector('[data-name="js-'+e+'"]')}).filter(function(n){return n});return t}function d(n,e,t,r){l(e,t).forEach(function(e){return e.addEventListener(n,r)})}function s(n){var e=document.querySelector(n);e.parentElement.removeChild(e)}function p(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return function(){return n.apply(void 0,t)}}var v=p(s,".smalltalk"),m=["OK"],h=["OK","Cancel"];t.alert=function(n,e){return o(n,e,"",m,{cancel:!1})},t.prompt=function(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments[3],a=t.replace(/\"/g,"""),u='<input type="text" value="'+a+'" data-name="js-input">';return o(n,e,u,h,r)},t.confirm=function(n,e,t){return o(n,e,"",h,t)}},{}]},{},["smalltalk"])("smalltalk")});
|
||||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.smalltalk=n()}}(function(){return function n(t,e,r){function o(i,a){if(!e[i]){if(!t[i]){var c="function"==typeof require&&require;if(!a&&c)return c(i,!0);if(u)return u(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var l=e[i]={exports:{}};t[i][0].call(l.exports,function(n){var e=t[i][1][n];return o(e?e:n)},l,l.exports,n,t,e,r)}return e[i].exports}for(var u="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(n,t,e){t.exports=n("./lib/currify")},{"./lib/currify":2}],2:[function(n,t,e){"use strict";function r(n){if(Array.isArray(n)){for(var t=0,e=Array(n.length);t<n.length;t++)e[t]=n[t];return e}return Array.from(n)}function o(n){if("function"!=typeof n)throw Error("fn should be function!")}var u=function(n){return[].slice.call(n,1)},i=function(n){return[function(t){return n.apply(void 0,arguments)},function(t,e){return n.apply(void 0,arguments)},function(t,e,r){return n.apply(void 0,arguments)},function(t,e,r,o){return n.apply(void 0,arguments)},function(t,e,r,o,u){return n.apply(void 0,arguments)}]};t.exports=function n(t){o(t);var e=u(arguments);if(e.length>=t.length)return t.apply(void 0,r(e));var a=function(){return n.apply(void 0,[t].concat(r(e),Array.prototype.slice.call(arguments)))},c=t.length-arguments.length,f=i(a)[c];return f||a}},{}],smalltalk:[function(n,t,e){"use strict";function r(n,t,e,r){return'<div class="page">\n <div data-name="js-close" class="close-button"></div>\n <header>'+n+'</header>\n <div class="content-area">\n '+t+"\n "+e+'\n </div>\n <div class="action-area">\n <div class="button-strip"> '+r.map(function(n,t){return"<button tabindex="+t+' data-name="js-'+n.toLowerCase()+'">'+n+"</button>"}).join("")+"\n </div>\n </div>\n </div>"}function o(n,t,e,o,u){var i=E(),a=E(),c=document.createElement("div"),s=["cancel","close","ok"],p=new Promise(function(n,t){var e=u&&!u.cancel,r=function(){};i(n),a(e?r:t)}),v=r(n,t,e,o);return c.innerHTML=v,c.className="smalltalk",document.body.appendChild(c),l(c,["ok","input"]).forEach(function(n){return n.focus()}),l(c,["input"]).forEach(function(n){n.setSelectionRange(0,e.length)}),d("click",c,s,function(n){return f(n.target,c,i(),a())}),["click","contextmenu"].forEach(function(n){return c.addEventListener(n,function(){return l(c,["ok","input"]).forEach(function(n){return n.focus()})})}),c.addEventListener("keydown",y(c,i(),a())),p}function u(n,t,e,r){var o={ENTER:13,ESC:27,TAB:9,LEFT:37,UP:38,RIGHT:39,DOWN:40},u=r.keyCode,d=r.target,s=["ok","cancel","input"],p=l(n,s).map(i);switch(u){case o.ENTER:f(d,n,t,e),r.preventDefault();break;case o.ESC:m(),e();break;case o.TAB:r.shiftKey&&c(n,p),c(n,p),r.preventDefault();break;default:["left","right","up","down"].filter(function(n){return u===o[n.toUpperCase()]}).forEach(function(){a(n,p)})}r.stopPropagation()}function i(n){return n.getAttribute("data-name").replace("js-","")}function a(n,t){var e=document.activeElement,r=i(e),o=/ok|cancel/.test(r),u=t.length-1,a=function(n){return"cancel"===n?"ok":"cancel"};if("input"!==r&&u&&o){var c=a(r);l(n,[c]).forEach(function(n){n.focus()})}}function c(n,t){var e=document.activeElement,r=i(e),o=t.length-1,u=t.indexOf(r),a=k(o,u),c=t[a];l(n,[c]).forEach(function(n){return n.focus()})}function f(n,t,e,r){var o=n.getAttribute("data-name").replace("js-","");if(/close|cancel/.test(o))return r(),void m();var u=l(t,["input"]).reduce(function(n,t){return t.value},null);e(u),m()}function l(n,t){var e=function(n){return n},r=t.map(function(t){return n.querySelector('[data-name="js-'+t+'"]')}).filter(e);return r}function d(n,t,e,r){l(t,e).forEach(function(t){return t.addEventListener(n,r)})}function s(n){var t=document.querySelector(n);t.parentElement.removeChild(t)}function p(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return function(){return n.apply(void 0,e)}}var v=n("currify/legacy"),y=v(u),m=p(s,".smalltalk"),h=["OK"],g=["OK","Cancel"];e.alert=function(n,t){return o(n,t,"",h,{cancel:!1})},e.prompt=function(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments[3],u=e.replace(/\"/g,"""),i='<input type="text" value="'+u+'" data-name="js-input">';return o(n,t,i,g,r)},e.confirm=function(n,t,e){return o(n,t,"",g,e)};var E=function(){var n=void 0;return function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.length&&(n=e.pop()),n}},k=function(n,t){return t===n?0:t<n?t+1:void 0}},{"currify/legacy":1}]},{},["smalltalk"])("smalltalk")});
|
||||
|
|
|
|||
2
modules/smalltalk/dist/smalltalk.poly.min.js
vendored
2
modules/smalltalk/dist/smalltalk.poly.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,10 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
const remove = bind(removeEl, '.smalltalk');
|
||||
const currify = require('currify/legacy');
|
||||
const keyDown = currify(keyDown_);
|
||||
|
||||
const remove = bind(removeEl, '.smalltalk');
|
||||
|
||||
const BUTTON_OK = ['OK'];
|
||||
const BUTTON_OK_CANCEL = ['OK', 'Cancel'];
|
||||
|
||||
const BUTTON_OK = ['OK'];
|
||||
const BUTTON_OK_CANCEL = ['OK', 'Cancel'];
|
||||
|
||||
exports.alert = (title, msg) => {
|
||||
return showDialog(title, msg, '', BUTTON_OK, {cancel: false});
|
||||
};
|
||||
|
|
@ -21,9 +24,6 @@ exports.confirm = (title, msg, options) => {
|
|||
};
|
||||
|
||||
function getTemplate(title, msg, value, buttons) {
|
||||
if (!Array.isArray(buttons))
|
||||
throw Error('buttons should be array!');
|
||||
|
||||
return `<div class="page">
|
||||
<div data-name="js-close" class="close-button"></div>
|
||||
<header>${ title }</header>
|
||||
|
|
@ -42,110 +42,115 @@ function getTemplate(title, msg, value, buttons) {
|
|||
</div>`;
|
||||
}
|
||||
|
||||
const store = () => {
|
||||
let a;
|
||||
return (...b) => {
|
||||
if (b.length)
|
||||
a = b.pop();
|
||||
|
||||
return a;
|
||||
};
|
||||
};
|
||||
|
||||
function showDialog(title, msg, value, buttons, options) {
|
||||
let ok, cancel;
|
||||
const ok = store();
|
||||
const cancel = store();
|
||||
|
||||
const dialog = document.createElement('div');
|
||||
const closeButtons = [
|
||||
const dialog = document.createElement('div');
|
||||
const closeButtons = [
|
||||
'cancel',
|
||||
'close',
|
||||
'ok'
|
||||
];
|
||||
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const noCancel = options && !options.cancel;
|
||||
const empty = () => {};
|
||||
const noCancel = options && !options.cancel;
|
||||
const empty = () => {};
|
||||
|
||||
ok = resolve;
|
||||
cancel = noCancel ? empty : reject;
|
||||
ok(resolve);
|
||||
cancel(noCancel ? empty : reject);
|
||||
});
|
||||
|
||||
const tmpl = getTemplate(title, msg, value, buttons);
|
||||
const tmpl = getTemplate(title, msg, value, buttons);
|
||||
|
||||
dialog.innerHTML = tmpl;
|
||||
dialog.className = 'smalltalk';
|
||||
|
||||
document.body.appendChild(dialog);
|
||||
|
||||
find(dialog, ['ok', 'input']).forEach(el =>
|
||||
find(dialog, ['ok', 'input']).forEach((el) =>
|
||||
el.focus()
|
||||
);
|
||||
|
||||
find(dialog, ['input']).forEach(el => {
|
||||
find(dialog, ['input']).forEach((el) => {
|
||||
el.setSelectionRange(0, value.length);
|
||||
});
|
||||
|
||||
addListenerAll('click', dialog, closeButtons, event =>
|
||||
closeDialog(event.target, dialog, ok, cancel)
|
||||
addListenerAll('click', dialog, closeButtons, (event) =>
|
||||
closeDialog(event.target, dialog, ok(), cancel())
|
||||
);
|
||||
|
||||
['click', 'contextmenu'].forEach(event =>
|
||||
['click', 'contextmenu'].forEach((event) =>
|
||||
dialog.addEventListener(event, () =>
|
||||
find(dialog, ['ok', 'input']).forEach(el =>
|
||||
find(dialog, ['ok', 'input']).forEach((el) =>
|
||||
el.focus()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
dialog.addEventListener('keydown', keyDown(dialog, ok, cancel));
|
||||
dialog.addEventListener('keydown', keyDown(dialog, ok(), cancel()));
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
function keyDown(dialog, ok, cancel) {
|
||||
return event => {
|
||||
const KEY = {
|
||||
ENTER : 13,
|
||||
ESC : 27,
|
||||
TAB : 9,
|
||||
LEFT : 37,
|
||||
UP : 38,
|
||||
RIGHT : 39,
|
||||
DOWN : 40
|
||||
};
|
||||
function keyDown_(dialog, ok, cancel, event) {
|
||||
const KEY = {
|
||||
ENTER : 13,
|
||||
ESC : 27,
|
||||
TAB : 9,
|
||||
LEFT : 37,
|
||||
UP : 38,
|
||||
RIGHT : 39,
|
||||
DOWN : 40
|
||||
};
|
||||
|
||||
const keyCode = event.keyCode;
|
||||
const el = event.target;
|
||||
|
||||
const namesAll = ['ok', 'cancel', 'input'];
|
||||
const names = find(dialog, namesAll)
|
||||
.map(getDataName);
|
||||
|
||||
switch(keyCode) {
|
||||
case KEY.ENTER:
|
||||
closeDialog(el, dialog, ok, cancel);
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
||||
case KEY.ESC:
|
||||
remove();
|
||||
cancel();
|
||||
break;
|
||||
|
||||
case KEY.TAB:
|
||||
if (event.shiftKey)
|
||||
tab(dialog, names);
|
||||
|
||||
const keyCode = event.keyCode;
|
||||
const el = event.target;
|
||||
|
||||
const namesAll = ['ok', 'cancel', 'input'];
|
||||
const names = find(dialog, namesAll).map((el) => {
|
||||
return getDataName(el);
|
||||
tab(dialog, names);
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
||||
default:
|
||||
['left', 'right', 'up', 'down'].filter((name) => {
|
||||
return keyCode === KEY[name.toUpperCase()];
|
||||
}).forEach(() => {
|
||||
changeButtonFocus(dialog, names);
|
||||
});
|
||||
|
||||
let is;
|
||||
|
||||
switch(keyCode) {
|
||||
case KEY.ENTER:
|
||||
closeDialog(el, dialog, ok, cancel);
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
||||
case KEY.ESC:
|
||||
remove();
|
||||
cancel();
|
||||
break;
|
||||
|
||||
case KEY.TAB:
|
||||
if (event.shiftKey)
|
||||
tab(dialog, names);
|
||||
|
||||
tab(dialog, names);
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
||||
default:
|
||||
is = ['left', 'right', 'up', 'down'].some((name) => {
|
||||
return keyCode === KEY[name.toUpperCase()];
|
||||
});
|
||||
|
||||
if (is)
|
||||
changeButtonFocus(dialog, names);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
function getDataName(el) {
|
||||
|
|
@ -155,82 +160,88 @@ function getDataName(el) {
|
|||
}
|
||||
|
||||
function changeButtonFocus(dialog, names) {
|
||||
let name = '';
|
||||
const active = document.activeElement,
|
||||
activeName = getDataName(active),
|
||||
isButton = /ok|cancel/.test(activeName),
|
||||
count = names.length - 1;
|
||||
|
||||
if (activeName !== 'input' && count && isButton) {
|
||||
const active = document.activeElement;
|
||||
const activeName = getDataName(active);
|
||||
const isButton = /ok|cancel/.test(activeName);
|
||||
const count = names.length - 1;
|
||||
const getName = (activeName) => {
|
||||
if (activeName === 'cancel')
|
||||
name = 'ok';
|
||||
else
|
||||
name = 'cancel';
|
||||
|
||||
find(dialog, [name]).forEach(el => {
|
||||
el.focus();
|
||||
});
|
||||
}
|
||||
return 'ok';
|
||||
|
||||
return 'cancel';
|
||||
};
|
||||
|
||||
if (activeName === 'input' || !count || !isButton)
|
||||
return;
|
||||
|
||||
const name = getName(activeName);
|
||||
|
||||
find(dialog, [name]).forEach((el) => {
|
||||
el.focus();
|
||||
});
|
||||
}
|
||||
|
||||
function tab(dialog, names) {
|
||||
const active = document.activeElement,
|
||||
activeName = getDataName(active),
|
||||
|
||||
count = names.length - 1;
|
||||
let index = names.indexOf(activeName);
|
||||
|
||||
const getIndex = (count, index) => {
|
||||
if (index === count)
|
||||
index = 0;
|
||||
else if (index < count)
|
||||
++index;
|
||||
return 0;
|
||||
|
||||
if (index < count)
|
||||
return index + 1;
|
||||
};
|
||||
|
||||
function tab(dialog, names) {
|
||||
const active = document.activeElement;
|
||||
const activeName = getDataName(active);
|
||||
const count = names.length - 1;
|
||||
|
||||
const activeIndex = names.indexOf(activeName);
|
||||
const index = getIndex(count, activeIndex);
|
||||
|
||||
const name = names[index];
|
||||
|
||||
find(dialog, [name]).forEach(el =>
|
||||
find(dialog, [name]).forEach((el) =>
|
||||
el.focus()
|
||||
);
|
||||
}
|
||||
|
||||
function closeDialog(el, dialog, ok, cancel) {
|
||||
let value;
|
||||
const name = el
|
||||
.getAttribute('data-name')
|
||||
.replace('js-', '');
|
||||
.getAttribute('data-name')
|
||||
.replace('js-', '');
|
||||
|
||||
if (/close|cancel/.test(name)) {
|
||||
cancel();
|
||||
} else {
|
||||
value = find(dialog, ['input']).reduce((value, el) => {
|
||||
return el.value;
|
||||
}, null);
|
||||
|
||||
ok(value);
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
const value = find(dialog, ['input'])
|
||||
.reduce((value, el) => el.value, null);
|
||||
|
||||
ok(value);
|
||||
remove();
|
||||
}
|
||||
|
||||
function find(element, names) {
|
||||
const elements = names.map(name =>
|
||||
const notEmpty = (a) => a;
|
||||
const elements = names.map((name) =>
|
||||
element.querySelector(`[data-name="js-${ name }"]`)
|
||||
).filter(el =>
|
||||
el
|
||||
);
|
||||
).filter(notEmpty);
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
function addListenerAll(event, parent, elements, fn) {
|
||||
find(parent, elements).forEach(el =>
|
||||
el.addEventListener(event, fn)
|
||||
);
|
||||
find(parent, elements)
|
||||
.forEach((el) =>
|
||||
el.addEventListener(event, fn)
|
||||
);
|
||||
}
|
||||
|
||||
function removeEl(name) {
|
||||
var el = document.querySelector(name);
|
||||
|
||||
el.parentElement.removeChild(el);
|
||||
const el = document.querySelector(name);
|
||||
|
||||
el.parentElement.removeChild(el);
|
||||
}
|
||||
|
||||
function bind(fn, ...args) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "smalltalk",
|
||||
"version": "2.1.4",
|
||||
"version": "2.2.0",
|
||||
"description": "Promise-based Alert, Confirm and Prompt replacement",
|
||||
"homepage": "http://github.com/coderaiser/smalltalk",
|
||||
"repository": {
|
||||
|
|
@ -19,6 +19,8 @@
|
|||
"scripts": {
|
||||
"watch": "nodemon --watch lib --watch test --exec",
|
||||
"watch:test": "npm run watch -- npm test",
|
||||
"watch:lint": "npm run watch -- 'npm run lint'",
|
||||
"watch:lint:js": "npm run watch -- \"run lint:js\"",
|
||||
"watch:coverage": "redrun watch -- redrun coverage",
|
||||
"coverage": "nyc npm test",
|
||||
"report": "nyc report --reporter=text-lcov | coveralls",
|
||||
|
|
@ -81,5 +83,8 @@
|
|||
"stylelint-config-standard": "^16.0.0",
|
||||
"systemjs": "^0.20.2",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"currify": "^2.0.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue