feature(package) smalltalk: bower -> npm

This commit is contained in:
coderaiser 2018-04-27 16:22:53 +03:00
parent 9f0d3b2c4e
commit f604927cb6
21 changed files with 11 additions and 1115 deletions

View file

@ -31,7 +31,6 @@
"domtokenlist-shim": "~1.1.0",
"olark": "^1.0.0",
"jquery": "3.3.1",
"fancybox": "^2.1.6",
"smalltalk": "2.5.1"
"fancybox": "^2.1.6"
}
}

View file

@ -1,39 +1,16 @@
/* global DOM */
/* global smalltalk */
'use strict';
module.exports = Dialog;
const sm = require('smalltalk');
const smNative = require('smalltalk/native');
function Dialog(prefix, config) {
if (!(this instanceof Dialog))
return new Dialog(prefix, config);
load(config.htmlDialogs);
function getJsName(htmlDialogs) {
const is = window.Promise;
const js = '.min.js';
const jsName = is ? js : '.poly' + js;
if (!htmlDialogs)
return '.native' + jsName;
return jsName;
}
function load(htmlDialogs) {
const noop = () => {};
const name = 'smalltalk';
const dir = '/modules/' + name + '/dist/';
const jsName = getJsName(htmlDialogs);
const names = [jsName, '.min.css'].map((ext) => {
return prefix + dir + name + ext;
});
DOM.load.parallel(names, noop);
}
const {htmlDialogs} = config;
const smalltalk = htmlDialogs ? sm : smNative;
const alert = (title, message) => {
return smalltalk.alert(title, message);

View file

@ -6,7 +6,6 @@ const Format = require('format-io');
const currify = require('currify/legacy');
const store = require('fullstore/legacy');
const squad = require('squad/legacy');
const fullstore = require('fullstore/legacy');
const exec = require('execon');
const supermenu = require('supermenu');
@ -20,7 +19,6 @@ CloudCmd.EditFile = function EditFileProto(callback) {
const Dialog = DOM.Dialog;
const EditFile = exec.bind();
const config = CloudCmd.config;
const isFocuse = fullstore();
let Menu;
@ -125,7 +123,6 @@ CloudCmd.EditFile = function EditFileProto(callback) {
if (Menu)
return;
const editor = CloudCmd.Edit.getEditor();
const options = {
beforeShow: (params) => {
params.x -= 18;
@ -133,6 +130,7 @@ CloudCmd.EditFile = function EditFileProto(callback) {
},
afterClick: () => {
const editor = CloudCmd.Edit.getEditor();
editor.focus();
}
};
@ -144,6 +142,8 @@ CloudCmd.EditFile = function EditFileProto(callback) {
}
function getMenuData() {
const editor = CloudCmd.Edit.getEditor();
return {
'Save Ctrl+S' : () => {
editor.save();
@ -176,7 +176,7 @@ CloudCmd.EditFile = function EditFileProto(callback) {
EditFile.hide();
}
};
};
}
function setMsgChanged(name) {
MSG_CHANGED = 'Do you want to save changes to ' + name + '?';

View file

@ -5,7 +5,6 @@
CloudCmd.Menu = MenuProto;
const exec = require('execon');
const currify = require('currify/legacy');
const wrap = require('wraptile/legacy');
const supermenu = require('supermenu');
@ -27,7 +26,6 @@ function MenuProto(Position) {
const Images = DOM.Images;
const Menu = this;
const TITLE = 'Cloud Commander';
const alert = currify(Dialog.alert, TITLE);
const alertNoFiles = wrap(Dialog.alert.noFiles)(TITLE);
const uploadTo = wrap(_uploadTo);

View file

@ -1,39 +0,0 @@
{
"name": "smalltalk",
"homepage": "https://github.com/coderaiser/smalltalk",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "Promise-based Alert, Confirm and Prompt replacement",
"main": "dist/smalltalk.min.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"modal",
"alert",
"prompt",
"confirm"
],
"license": "MIT",
"ignore": [
"**/.*",
"screen",
"example",
"test",
"webpack.config.js"
],
"dependencies": {},
"version": "2.5.1",
"_release": "2.5.1",
"_resolution": {
"type": "version",
"tag": "v2.5.1",
"commit": "a5142a2693762d9ad729edd823506386497b4e41"
},
"_source": "https://github.com/coderaiser/smalltalk.git",
"_target": "^2.5.1",
"_originalSource": "smalltalk",
"_direct": true
}

View file

@ -1,343 +0,0 @@
2017.10.19, v2.5.1
fix:
- (smalltalk) new line at the end of a message
2017.10.09, v2.5.0
feature:
- (smalltalk) prompt: password (#8)
- (package) sinon v4.0.0
- (package) coveralls v3.0.0
2017.09.22, v2.4.2
fix:
- (smalltalk) confirm: no cancel
- (smalltalk) native: prompt: cancel
feature:
- (package) babel-preset-env v1.6.0
- (package) sinon v3.0.0
- (package) stylelint-config-standard v17.0.0
- (package) stylelint v8.0.0
2017.07.10, v2.4.1
fix:
- (example) fullstore
- (smalltalk) native: confirm, prompt: cancel: resolve -> do nothing (coderaiser/cloudcmd/issues/117)
feature:
- (package) es6-promise v4.1.1
- (package) webpack v3.0.0
- (package) nyc v11.0.2
- (package) eslint v4.0.0
2017.05.23, v2.4.0
feature:
- (smalltalk) add ability to encode new lines in message
- (smalltalk) .content-area: rm max-width: forced new lines
- (smalltalk) store -> fullstore
- (package) rm unused glob
2017.05.17, v2.3.1
feature:
- (bower) ignore: add webpack.config.js
2017.05.17, v2.3.0
feature:
- (package) browserify -> webpack: add sourcemaps
2017.05.16, v2.2.2
fix:
- (smalltalk) prompt value is a number
2017.05.10, v2.2.1
fix:
- feature(package) autoprefixer v7.0.1
feature:
- (package) postcss-cli v4.0.0
- (package) autoprefixer v7.0.1
- (package) postcss-cli v3.0.0
- (package) sinon v2.0.0
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:
- (smalltalk) double quotes (#2)
feature:
- (package) stylelint-config-standard v16.0.0
- (package) browserify v14.0.0
- (package) systemjs v0.20.2
- (package) nyc v10.0.0
- (package) stylelint-config-standard v15.0.0
- (package) nyc v9.0.1
- (package) stylelint-config-standard v14.0.0
2016.10.04, v2.1.3
feature:
- (smalltalk) showDialog: if -> ternary
- (package) stylelint-config-standard v13.0.0
- (package) nyc v8.1.0
2016.08.08, v2.1.2
fix:
- (smalltalk) get back old way of hiding all but first
feature:
- (package) stylelint-config-standard v12.0.0
2016.07.25, v2.1.1
fix:
- (smalltalk.native) confirm options: noCancel -> cancel
feature:
- (package) promise-polyfill v6.0.0
2016.07.20, v2.1.0
fix:
- feature(package) add postcss, autoprefixer
feature:
- (smalltalk) hide all windows but first, no matter where they located in DOM
- (travis) node v6
- (package) add postcss, autoprefixer
- (package) stylelint-config-standard v11.0.0
- (package) stylelint v7.0.2
2016.07.15, v2.0.0
feature:
- (npmignore) add
- (package) add legacy:index
- (smalltalk) hide all bu first
- (bower) ignore: clean
- (smalltalk) alert: rm options
- (package) lint: add eslint
- (smalltalk) src -> lib
- (gitignore) legacy
- (package) add bundle
- (example) add legacy
- (smalltalk) IIFE -> commonjs
- (jshint) esversion: 6
- (package) redrun v5.0.0
- (package) add lint
- (package) redrun v5.0.0
- (package) stylelint-config-standard v10.0.0
- (package) redrun v4.0.0
- (package) watch v0.19.1
- (package) stylelint-config-standard v9.0.0
- (package) stylelint-config-standard v8.0.0
2016.05.10, v1.6.8
feature:
- (package) v0.18.0
- (package) stylelint-config-standard v7.0.0
- (package) promise-polyfill v5.1.0
- (package) redrun v3.0.0
- (package) stylelint v6.2.2
- (package) jscs v3.0.3
- (package) stylelint-config-standard v5.0.0
- (package) stylelint v5.1.0, stylelint-config-standard v4.0.1
2016.03.21, v1.6.7
feature:
- (package) promise-poyfill v4.0.1
- (travis) notifications: default
2016.03.01, v1.6.6
feature:
- (package) add stylelint
- (smalltalk) .button: rm outline
2016.01.10, v1.6.5
feature:
- (package) promise-polyfill v3.0.0
- (travis) node v5
- (package) watch v0.17.1
2015.12.09, v1.6.4
feature:
- (smalltalk) bind: slice -> rest
2015.12.05, v1.6.3
fix:
- (package) minify-css -> minify:css
2015.12.05, v1.6.2
feature:
- (smalltalk) add z-index
- (package) babel v6
- (package) add npm-run-all
2015.11.02, v1.6.1
fix:
- (smalltalk) .content-area: rm nowrap
2015.11.02, v1.6.0
feature:
- (smalltalk) cut content when it is to large
2015.10.29, v1.5.6
feature:
- (package) 6to5: --blacklist strict
- (package) devDependencies: ~ -> ^
- (package) minify v2.0.0
2015.10.26, v1.5.5
fix:
- (package) build-native-full
feature:
- (gitignore) npm-debug.log -> npm-debug.log*
2015.10.26, v1.5.4
feature:
- (smalltalk) addListenerAll: fn(event) -> fn
2015.10.14, v1.5.3
fix:
- (smalltalk) prompt: focus on ok -> focus on input
2015.09.30, v1.5.2
fix:
- (smalltalk) changeButtons: when input active
2015.09.29, v1.5.1
feature:
- (smalltalk) add es6 native
2015.09.28, v1.5.0
feature:
- (smalltalk) add native
2015.09.26, v1.4.1
feature:
- (bower) rm promise-polyfill
2015.09.26, v1.4.0
feature:
- (smalltalk) Cancel, OK -> OK, Cancel
2015.09.26, v1.3.4
fix:
- (smalltalk) keyDown enter: prevent pass next
feature:
- (package) add jscs
- (package) add jshint support
2015.09.24, v1.3.3
feature:
- (smalltalk) header: add font-weight
2015.09.24, v1.3.2
feature:
- (smalltalk) h1 -> header
- (smalltalk) .content-area: add max-width
2015.09.23, v1.3.1
fix:
- (smalltalk) changeButtonFocus: left, right, up, down do not work with confirm
2015.09.23, v1.3.0
feature:
- (smalltalk) add handling of keys: left, right, up, down
2015.09.23, v1.2.0
feature:
- (smalltalk) keyDown: add stopPropogation
- (smalltalk) .smalltalk: rm background-color
2015.09.22, v1.1.0
feature:
- (package) scripts build: add build-poly
- (smalltalk) add options {cancel}
- (screen) add

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015 coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,105 +0,0 @@
# 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.
# Install
With help of [bower](http://bower.io "Bower").
```
bower install smalltalk
```
Or npm:
```
npm i smalltalk
```
# API
In every method of `smalltalk` last parameter *options* is optional and could be used
for preventing of handling cancel event.
```js
{
cancel: true /* default */
}
```
## smalltalk.alert(title, message)
![Alert](https://raw.githubusercontent.com/coderaiser/smalltalk/master/screen/alert.png "Alert")
```js
smalltalk
.alert('Error', 'There was an error!')
.then(() => {
console.log('ok');
});
```
## smalltalk.confirm(title, message [, options])
![Confirm](https://raw.githubusercontent.com/coderaiser/smalltalk/master/screen/confirm.png "Confirm")
```js
smalltalk
.confirm('Question', 'Are you sure?')
.then(() => {
console.log('yes');
.catch(() => {
console.log('no');
});
```
## smalltalk.prompt(title, message, value [, options])
![Prompt](https://raw.githubusercontent.com/coderaiser/smalltalk/master/screen/prompt.png "Prompt")
```js
smalltalk
.prompt('Question', 'How old are you?', '10')
.then((value) => {
console.log(value);
.catch(() => {
console.log('cancel');
});
```
Use `type='password'` for `password` fields:
```js
smalltalk
.prompt('Question', 'How old are you?', '10', {
type: 'password',
})
.then((value) => {
console.log(value);
.catch(() => {
console.log('cancel');
});
```
## Bundlers
When `webpack` `rollup` or `browserify` used, you can import `es5` version with:
```js
import smalltalk from 'smalltalk/legacy';
```
# License
MIT
[NPMIMGURL]: https://img.shields.io/npm/v/smalltalk.svg?style=flat
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/smalltalk/master.svg?style=flat
[DependencyStatusIMGURL]: https://img.shields.io/gemnasium/coderaiser/smalltalk.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/smalltalk "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/smalltalk "Build Status"
[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

View file

@ -1,28 +0,0 @@
{
"name": "smalltalk",
"homepage": "https://github.com/coderaiser/smalltalk",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "Promise-based Alert, Confirm and Prompt replacement",
"main": "dist/smalltalk.min.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"modal",
"alert",
"prompt",
"confirm"
],
"license": "MIT",
"ignore": [
"**/.*",
"screen",
"example",
"test",
"webpack.config.js"
],
"dependencies": {}
}

View file

@ -1,153 +0,0 @@
.smalltalk {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
transition: 200ms opacity;
bottom: 0;
left: 0;
overflow: auto;
padding: 20px;
position: fixed;
right: 0;
top: 0;
z-index: 100;
}
.smalltalk + .smalltalk {
transition: ease 1s;
display: none;
}
.smalltalk .page {
border-radius: 3px;
background: white;
box-shadow: 0 4px 23px 5px rgba(0, 0, 0, .2), 0 2px 6px rgba(0, 0, 0, .15);
color: #333;
min-width: 400px;
padding: 0;
position: relative;
z-index: 0;
}
@media only screen and (max-width: 500px) {
.smalltalk .page {
min-width: 0;
}
}
.smalltalk .page > .close-button {
background-image: url(../img/IDR_CLOSE_DIALOG.png);
background-position: center;
background-repeat: no-repeat;
height: 14px;
position: absolute;
right: 7px;
top: 7px;
width: 14px;
z-index: 1;
}
.smalltalk .page > .close-button:hover {
background-image: url(../img/IDR_CLOSE_DIALOG_H.png);
}
.smalltalk .page header {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 500px;
user-select: none;
color: #333;
font-size: 120%;
font-weight: bold;
margin: 0;
padding: 14px 17px;
text-shadow: white 0 1px 2px;
}
.smalltalk .page .content-area {
overflow: hidden;
text-overflow: ellipsis;
padding: 6px 17px;
position: relative;
}
.smalltalk .page .action-area {
padding: 14px 17px;
}
.smalltalk .page .button-strip {
display: flex;
flex-direction: row;
justify-content: flex-end;
}
.smalltalk .page .button-strip > button {
margin-left: 10px;
}
.smalltalk button:enabled:focus, .smalltalk input:enabled:focus {
transition: border-color 200ms;
border-color: rgb(77, 144, 254);
outline: none;
}
.smalltalk button:enabled:active {
background-image: linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
box-shadow: none;
text-shadow: none;
}
.smalltalk button, .smalltalk .smalltalk {
min-height: 2em;
min-width: 4em;
}
.smalltalk button::-moz-focus-inner {
border: 0;
}
.smalltalk button {
appearance: none;
user-select: none;
background-image: linear-gradient(#ededed, #ededed 38%, #dedede);
border: 1px solid rgba(0, 0, 0, 0.25);
border-radius: 2px;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.75);
color: #444;
font: inherit;
margin: 0 1px 0 0;
text-shadow: 0 1px 0 rgb(240, 240, 240);
}
.smalltalk button:enabled:focus, .smalltalk input:enabled:focus {
transition: border-color 200ms;
border-color: rgb(77, 144, 254);
outline: none;
}
.smalltalk input {
width: 100%;
border: 1px solid #bfbfbf;
border-radius: 2px;
box-sizing: border-box;
color: #444;
font: inherit;
margin: 0;
min-height: 2em;
padding: 3px;
outline: none;
}
button {
font-family: Ubuntu, Arial, sans-serif;
}

View file

@ -1,2 +0,0 @@
.smalltalk{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-transition:.2s opacity;transition:.2s opacity;bottom:0;left:0;overflow:auto;padding:20px;position:fixed;right:0;top:0;z-index:100}.smalltalk+.smalltalk{-webkit-transition:ease 1s;transition:ease 1s;display:none}.smalltalk .page{border-radius:3px;background:#fff;-webkit-box-shadow:0 4px 23px 5px rgba(0,0,0,.2),0 2px 6px rgba(0,0,0,.15);box-shadow:0 4px 23px 5px rgba(0,0,0,.2),0 2px 6px rgba(0,0,0,.15);color:#333;min-width:400px;padding:0;position:relative;z-index:0}@media only screen and (max-width:500px){.smalltalk .page{min-width:0}}.smalltalk .page>.close-button{background-image:url(../img/IDR_CLOSE_DIALOG.png);background-position:center;background-repeat:no-repeat;height:14px;position:absolute;right:7px;top:7px;width:14px;z-index:1}.smalltalk .page>.close-button:hover{background-image:url(../img/IDR_CLOSE_DIALOG_H.png)}.smalltalk .page header{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:500px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:#333;font-size:120%;font-weight:700;margin:0;padding:14px 17px;text-shadow:#fff 0 1px 2px}.smalltalk .page .content-area{overflow:hidden;text-overflow:ellipsis;padding:6px 17px;position:relative}.smalltalk .page .action-area{padding:14px 17px}.smalltalk .page .button-strip{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}.smalltalk .page .button-strip>button{margin-left:10px}.smalltalk button:enabled:focus,.smalltalk input:enabled:focus{-webkit-transition:border-color .2s;transition:border-color .2s;border-color:#4d90fe;outline:0}.smalltalk button:enabled:active{background-image:-webkit-gradient(linear,left top,left bottom,from(#e7e7e7),color-stop(38%,#e7e7e7),to(#d7d7d7));background-image:linear-gradient(#e7e7e7,#e7e7e7 38%,#d7d7d7);-webkit-box-shadow:none;box-shadow:none;text-shadow:none}.smalltalk .smalltalk,.smalltalk button{min-height:2em;min-width:4em}.smalltalk button::-moz-focus-inner{border:0}.smalltalk button{-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:-webkit-gradient(linear,left top,left bottom,from(#ededed),color-stop(38%,#ededed),to(#dedede));background-image:linear-gradient(#ededed,#ededed 38%,#dedede);border:1px solid rgba(0,0,0,.25);border-radius:2px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.08),inset 0 1px 2px rgba(255,255,255,.75);box-shadow:0 1px 0 rgba(0,0,0,.08),inset 0 1px 2px rgba(255,255,255,.75);color:#444;font:inherit;margin:0 1px 0 0;text-shadow:0 1px 0 #f0f0f0}.smalltalk button:enabled:focus,.smalltalk input:enabled:focus{-webkit-transition:border-color .2s;transition:border-color .2s;border-color:#4d90fe;outline:0}.smalltalk input{width:100%;border:1px solid #bfbfbf;border-radius:2px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#444;font:inherit;margin:0;min-height:2em;padding:3px;outline:0}button{font-family:Ubuntu,Arial,sans-serif}
/*# sourceMappingURL=smalltalk.min.css.map */

View file

@ -1,2 +0,0 @@
var smalltalk=function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=1)}([function(n,t){n.exports=es6-promise},function(n,t,e){"use strict";function r(){return"password"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).type?"password":"text"}function o(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">'+t.replace(/\n/g,"<br>")+e+'</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 u(n,t,e,r,u){var c=m(),a=m(),i=document.createElement("div"),f=["cancel","close","ok"],d=new Promise(function(n,t){var e=u&&!u.cancel,r=function(){};c(n),a(e?r:t)}),v=o(n,t,e,r);return i.innerHTML=v,i.className="smalltalk",document.body.appendChild(i),s(i,["ok","input"]).forEach(function(n){return n.focus()}),s(i,["input"]).forEach(function(n){n.setSelectionRange(0,e.length)}),p("click",i,f,function(n){return l(n.target,i,c(),a())}),["click","contextmenu"].forEach(function(n){return i.addEventListener(n,function(){return s(i,["ok","input"]).forEach(function(n){return n.focus()})})}),i.addEventListener("keydown",h(i,c(),a())),d}function c(n,t,e,r){var o={ENTER:13,ESC:27,TAB:9,LEFT:37,UP:38,RIGHT:39,DOWN:40},u=r.keyCode,c=r.target,p=["ok","cancel","input"],d=s(n,p).map(a);switch(u){case o.ENTER:l(c,n,t,e),r.preventDefault();break;case o.ESC:g(),e();break;case o.TAB:r.shiftKey&&f(n,d),f(n,d),r.preventDefault();break;default:["left","right","up","down"].filter(function(n){return u===o[n.toUpperCase()]}).forEach(function(){i(n,d)})}r.stopPropagation()}function a(n){return n.getAttribute("data-name").replace("js-","")}function i(n,t){var e=document.activeElement,r=a(e),o=/ok|cancel/.test(r),u=t.length-1;if("input"!==r&&u&&o){s(n,[function(n){return"cancel"===n?"ok":"cancel"}(r)]).forEach(function(n){n.focus()})}}function f(n,t){var e=document.activeElement,r=a(e),o=t.length-1,u=t.indexOf(r);s(n,[t[b(o,u)]]).forEach(function(n){return n.focus()})}function l(n,t,e,r){if(/close|cancel/.test(n.getAttribute("data-name").replace("js-","")))return r(),void g();e(s(t,["input"]).reduce(function(n,t){return t.value},null)),g()}function s(n,t){var e=function(n){return n};return t.map(function(t){return n.querySelector('[data-name="js-'+t+'"]')}).filter(e)}function p(n,t,e,r){s(t,e).forEach(function(t){return t.addEventListener(n,r)})}function d(n){var t=document.querySelector(n);t.parentElement.removeChild(t)}window.Promise=window.Promise||e(0);var v=e(2),m=e(4),h=v(c),g=function(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)}}(d,".smalltalk"),y=["OK"],E=["OK","Cancel"];t.alert=function(n,t){return u(n,t,"",y,{cancel:!1})},t.prompt=function(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments[3];return u(n,t,'<input type="'+r(o)+'" value="'+String(e).replace(/"/g,"&quot;")+'" data-name="js-input">',E,o)},t.confirm=function(n,t,e){return u(n,t,"",E,e)};var b=function(n,t){return t===n?0:t+1}},function(n,t,e){n.exports=e(3)},function(n,t,e){"use strict";function r(n){if("function"!=typeof n)throw Error("fn should be function!")}var o=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)}]};n.exports=function n(t){for(var e=arguments.length,u=Array(e>1?e-1:0),c=1;c<e;c++)u[c-1]=arguments[c];if(r(t),u.length>=t.length)return t.apply(void 0,u);var a=function(){return n.apply(void 0,[t].concat(u,Array.prototype.slice.call(arguments)))},i=t.length-u.length-1;return o(a)[i]||a}},function(n,t,e){n.exports=e(5)},function(n,t,e){"use strict";n.exports=function(n){var t={value:n};return function(n){return arguments.length?(t.value=n,n):t.value}}}]);
//# sourceMappingURL=smalltalk.min.js.map

View file

@ -1,2 +0,0 @@
var smalltalk=function(n){function r(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var e={};return r.m=n,r.c=e,r.d=function(n,e,t){r.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:t})},r.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},r.p="",r(r.s=6)}({0:function(n,r){n.exports=es6-promise},6:function(n,r,e){"use strict";window.Promise=window.Promise||e(0),r.alert=function(n,r){return new Promise(function(n){alert(r),n()})},r.prompt=function(n,r,e,t){var o=t;return new Promise(function(n,t){var u=o&&!o.cancel,i=prompt(r,e);if(null!==i)return n(i);u||t()})},r.confirm=function(n,r,e){var t=e,o=t&&!t.cancel;return new Promise(function(n,e){if(confirm(r))return n();o||e()})}}});
//# sourceMappingURL=smalltalk.native.min.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

View file

@ -1,254 +0,0 @@
'use strict';
window.Promise = window.Promise || require('es6-promise');
const currify = require('currify/legacy');
const store = require('fullstore/legacy');
const keyDown = currify(keyDown_);
const remove = bind(removeEl, '.smalltalk');
const BUTTON_OK = ['OK'];
const BUTTON_OK_CANCEL = ['OK', 'Cancel'];
exports.alert = (title, msg) => {
return showDialog(title, msg, '', BUTTON_OK, {cancel: false});
};
exports.prompt = (title, msg, value = '', options) => {
const type = getType(options);
const val = String(value)
.replace(/"/g, '&quot;');
const valueStr = `<input type="${ type }" value="${ val }" data-name="js-input">`;
return showDialog(title, msg, valueStr, BUTTON_OK_CANCEL, options);
};
exports.confirm = (title, msg, options) => {
return showDialog(title, msg, '', BUTTON_OK_CANCEL, options);
};
function getType(options = {}) {
const {type} = options;
if (type === 'password')
return 'password';
return 'text';
}
function getTemplate(title, msg, value, buttons) {
const encodedMsg = msg.replace(/\n/g, '<br>');
return `<div class="page">
<div data-name="js-close" class="close-button"></div>
<header>${ title }</header>
<div class="content-area">${ encodedMsg }${ value }</div>
<div class="action-area">
<div class="button-strip"> ${
buttons.map((name, i) =>
`<button tabindex=${ i } data-name="js-${ name.toLowerCase() }">${ name }</button>`
).join('')
}
</div>
</div>
</div>`;
}
function showDialog(title, msg, value, buttons, options) {
const ok = store();
const cancel = store();
const dialog = document.createElement('div');
const closeButtons = [
'cancel',
'close',
'ok'
];
const promise = new Promise((resolve, reject) => {
const noCancel = options && !options.cancel;
const empty = () => {};
ok(resolve);
cancel(noCancel ? empty : reject);
});
const tmpl = getTemplate(title, msg, value, buttons);
dialog.innerHTML = tmpl;
dialog.className = 'smalltalk';
document.body.appendChild(dialog);
find(dialog, ['ok', 'input']).forEach((el) =>
el.focus()
);
find(dialog, ['input']).forEach((el) => {
el.setSelectionRange(0, value.length);
});
addListenerAll('click', dialog, closeButtons, (event) =>
closeDialog(event.target, dialog, ok(), cancel())
);
['click', 'contextmenu'].forEach((event) =>
dialog.addEventListener(event, () =>
find(dialog, ['ok', 'input']).forEach((el) =>
el.focus()
)
)
);
dialog.addEventListener('keydown', keyDown(dialog, ok(), cancel()));
return promise;
}
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);
tab(dialog, names);
event.preventDefault();
break;
default:
['left', 'right', 'up', 'down'].filter((name) => {
return keyCode === KEY[name.toUpperCase()];
}).forEach(() => {
changeButtonFocus(dialog, names);
});
break;
}
event.stopPropagation();
}
function getDataName(el) {
return el
.getAttribute('data-name')
.replace('js-', '');
}
function changeButtonFocus(dialog, names) {
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')
return 'ok';
return 'cancel';
};
if (activeName === 'input' || !count || !isButton)
return;
const name = getName(activeName);
find(dialog, [name]).forEach((el) => {
el.focus();
});
}
const getIndex = (count, index) => {
if (index === count)
return 0;
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) =>
el.focus()
);
}
function closeDialog(el, dialog, ok, cancel) {
const name = el
.getAttribute('data-name')
.replace('js-', '');
if (/close|cancel/.test(name)) {
cancel();
remove();
return;
}
const value = find(dialog, ['input'])
.reduce((value, el) => el.value, null);
ok(value);
remove();
}
function find(element, names) {
const notEmpty = (a) => a;
const elements = names.map((name) =>
element.querySelector(`[data-name="js-${ name }"]`)
).filter(notEmpty);
return elements;
}
function addListenerAll(event, parent, elements, fn) {
find(parent, elements)
.forEach((el) =>
el.addEventListener(event, fn)
);
}
function removeEl(name) {
const el = document.querySelector(name);
el.parentElement.removeChild(el);
}
function bind(fn, ...args) {
return () => fn(...args);
}

View file

@ -1,49 +0,0 @@
'use strict';
window.Promise = window.Promise || require('es6-promise');
exports.alert = (title, message) => {
const promise = new Promise((resolve) => {
alert(message);
resolve();
});
return promise;
};
exports.prompt = (title, message, value, options) => {
const o = options;
const promise = new Promise((resolve, reject) => {
const noCancel = o && !o.cancel;
const result = prompt(message, value);
if (result !== null)
return resolve(result);
if (noCancel)
return;
reject();
});
return promise;
};
exports.confirm = (title, message, options) => {
const o = options;
const noCancel = o && !o.cancel;
const promise = new Promise((resolve, reject) => {
const is = confirm(message);
if (is)
return resolve();
if (noCancel)
return;
reject();
});
return promise;
};

View file

@ -1,77 +0,0 @@
{
"name": "smalltalk",
"version": "2.5.1",
"description": "Promise-based Alert, Confirm and Prompt replacement",
"homepage": "http://github.com/coderaiser/smalltalk",
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/smalltalk.git"
},
"main": "lib/smalltalk.js",
"babel": {
"presets": [
"es2015"
]
},
"scripts": {
"watch": "nodemon --watch lib --watch test --exec",
"watch:client": "redrun compile:client -- --watch",
"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",
"compile:server": "babel -d legacy lib",
"compile:client": "webpack --progress",
"compile:client:poly": "BUILD_TYPE=poly webpack --progress",
"build": "redrun clean build:js build:css",
"build:js": "redrun compile:* legacy:index",
"build:css": "postcss css/*.css -o dist/smalltalk.min.css -m --use autoprefixer postcss-clean",
"legacy:index": "echo \"module.exports = require('./smalltalk');\" > legacy/index.js",
"clean": "rimraf dist",
"wisdom": "npm run build",
"lint:css": "stylelint css/*.css",
"lint:js": "jshint lib test && jscs lib test && eslint lib test webpack.config.js",
"lint": "redrun lint:*",
"test": "tape 'test/**/*.js'"
},
"keywords": [
"modal",
"alert",
"confirm",
"prompt"
],
"author": "coderaiser <mnemonic.enemy@gmail.com> (http://coderaiser.github.io/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/coderaiser/smalltalk/issues"
},
"devDependencies": {
"autoprefixer": "^7.0.1",
"babel-cli": "^6.1.1",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.6.0",
"coveralls": "^3.0.0",
"eslint": "^4.0.0",
"jscs": "^3.0.3",
"jshint": "^2.8.0",
"nodemon": "^1.9.2",
"nyc": "^11.0.2",
"postcss-clean": "^1.0.2",
"postcss-cli": "^4.0.0",
"redrun": "^5.0.1",
"rimraf": "^2.5.3",
"sinon": "^4.0.0",
"stylelint": "^8.0.0",
"stylelint-config-standard": "^17.0.0",
"systemjs": "^0.20.2",
"tape": "^4.6.0",
"webpack": "^3.0.0"
},
"dependencies": {
"currify": "^2.0.3",
"es6-promise": "^4.1.1",
"fullstore": "^1.0.0"
}
}

View file

@ -195,6 +195,7 @@
"shortdate": "^1.0.1",
"sinon": "^4.0.0",
"sinon-called-with-diff": "^2.0.0",
"smalltalk": "^3.0.0",
"socket.io-client": "^2.0.1",
"style-loader": "^0.21.0",
"stylelint": "^9.0.0",