cloudcmd/modules/smalltalk/dist/smalltalk.poly.min.js
2017-02-24 10:37:34 +02:00

1 line
7.3 KiB
JavaScript

!function(e){function n(){}function t(e,n){return function(){e.apply(n,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(e,this)}function i(e,n){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(n):(e._handled=!0,void o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null===t)return void(1===e._state?r:u)(n.promise,e._value);var o;try{o=t(e._value)}catch(i){return void u(n.promise,i)}r(n.promise,o)}))}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var i=n.then;if(n instanceof o)return e._state=3,e._value=n,void f(e);if("function"==typeof i)return void s(t(i,n),e)}e._state=1,e._value=n,f(e)}catch(r){u(e,r)}}function u(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n<t;n++)i(e,e._deferreds[n]);e._deferreds=null}function c(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}function s(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,u(n,e))})}catch(o){if(t)return;t=!0,u(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var o=new this.constructor(n);return i(this,new c(e,t,o)),o},o.all=function(e){var n=Array.prototype.slice.call(e);return new o(function(e,t){function o(r,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var f=u.then;if("function"==typeof f)return void f.call(u,function(e){o(r,e)},t)}n[r]=u,0===--i&&e(n)}catch(c){t(c)}}if(0===n.length)return e([]);for(var i=n.length,r=0;r<n.length;r++)o(r,n[r])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(n,t){for(var o=0,i=e.length;o<i;o++)e[o].then(n,t)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},o._setImmediateFn=function(e){o._immediateFn=e},o._setUnhandledRejectionFn=function(e){o._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=o:e.Promise||(e.Promise=o)}(this);!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,"&quot;"),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")});