From 066d40be6ced1c9593804034fa45781b7710a326 Mon Sep 17 00:00:00 2001 From: Andy Earnshaw Date: Wed, 18 Jun 2014 19:49:05 +0100 Subject: [PATCH] Minified build and version bump to v0.0.2 --- bower.json | 2 +- keylime.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 1fccb66..f35d2a3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "keylime", - "version": "0.0.1", + "version": "0.0.2", "description": "Key Lime is an input method editor written using pure JavaScript.", "main": ["keylime.js", "keylime.min.js"], "keywords": [ diff --git a/keylime.min.js b/keylime.min.js index 5733330..8c881c2 100644 --- a/keylime.min.js +++ b/keylime.min.js @@ -1 +1 @@ -(function(e,t){var i,o=t(e);if(typeof define==="function"&&define.amd)define(i=o);if(typeof exports==="object")module.exports=i=o;e.keyLime=o})(typeof global!=="undefined"?global:this,function(e){"use strict";var t,i,o,l,n,r,a,s,c,m=document.createElement("style"),d=document.createElement("div"),f=e.keyLime||{config:{}},u=false,g=[".lime-container { background-color: #333; position: absolute; bottom: 0; left: 0; right: 0; color: #fff; z-index:1000000; }",'.lime-container-dim::before { position: absolute; content: ""; top: 0; left: 0; right: 0; bottom: 0; background-color: #000; opacity: 0.5; }',".lime-key-row { list-style-type: none; clear: both; text-align: center; padding: 0; margin: 0; font-size: 28px; font-weight: bold; }",".lime-diacritics-row { position: absolute; z-index: 2; overflow: hidden; -webkit-transition: width 400ms; transition: width 400ms; white-space: nowrap; }",".lime-key { vertical-align: top; display: inline-block; border: 3px solid #333; background-color: #666; width: 66px; line-height: 50px; -webkit-transition: all 400ms linear; transition: all 400ms linear; }",".lime-key[data-text]::before { content: attr(data-text) }",".lime-container.symbol-toggle .lime-key[data-symbol]::before { content: attr(data-symbol) }",".lime-container.shift-toggle .lime-key[data-text]:not(.lime-http):not(.lime-dotcom):not(.lime-wwwdot)::before { text-transform: uppercase; }",".lime-special-key { background-color: #999; color: #333; }",".lime-return { background-color: #ccc; width: 138px; }",".lime-focus { background-color: #26f; color: #fff; }",".lime-toggle { background-color: #2f2; color: #fff; position: relative; }",".lime-spacebar { width:498px; }",".lime-http, .lime-dotcom, .lime-wwwdot { font-size: 20px; }"],y=/^(?:text|search|url|tel|password)$/i,p=b(),h={Tab:N,Return:B,Shift:function(e){var t=d.querySelector(".lime-toggle");if(t)t.classList.remove("lime-toggle");d.classList.remove("shift-toggle","symbol-toggle");n=r=false;if(o){o=false;l=true;e.classList.add("lime-toggle")}else if(l)l=false;else o=true;if(o||l)d.classList.add("shift-toggle")},Symbol:function(e){var t=d.querySelector(".lime-toggle");if(t)t.classList.remove("lime-toggle");n=!n;o=l=r=false;d.classList.remove("shift-toggle");d.classList.toggle("symbol-toggle");if(n)e.classList.toggle("lime-toggle")},Backspace:function(){if(!D(document.activeElement))return;var e=window.getSelection();if(!String(e).length)e.modify("extend","backward","character");e.deleteFromDocument()},Caret:function(e){var t=d.querySelector(".lime-toggle");if(t)t.classList.remove("lime-toggle");n=o=l=false;d.classList.remove("shift-toggle","symbol-toggle");r=!r;if(r)e.classList.add("lime-toggle")}},v={verbatim:{keys:{standard:[["@","1","2","3","4","5","6","7","8","9","0","-","="],["q","w","e","r","t","y","u","i","o","p","[","]"],["a","s","d","f","g","h","j","k","l",";","'"],["z","x","c","v","b","n","m",",",".","/"]],symbol:[["@","1","2","3","4","5","6","7","8","9","0","-","="],["~","#","`","£","$","%","^","&","(",")","[","]"],["•","€","¥","¡","¿","*","|","{","}",":","""],["غ","=","!","\\","«","»","§","<",">","?"]]},diacritics:{a:"äáâàåæ",c:"ç©",d:"ð",e:"ëéêè",i:"ïíîì",m:"µ",n:"ñ",o:"öóôòõø",u:"üúûù",y:"ÿý"}}};d.className="lime-container";d.lang="en";document.head.insertBefore(m,document.head.firstChild);for(var w=0;w⇥',after:'
  • '},row3:{before:'
  • ',after:'
  • |⇄
  • '}},i=v.verbatim.diacritics,o=v.verbatim.keys;e+=o.standard.map(function(e,i){var l=t["row"+i];return''+(l&&l.before||"")+e.map(function(e,t){return'
  • '}).join("")+(l&&l.after||"")+"
    "}).join("");e+=''+'
  • '+'
  • '+'
  • '+'
  •  
  • '+'
  • '+'
  • '+"
    ";d.innerHTML=e}function x(e){if(!e.classList.contains("lime-key"))return;if(i)i.classList.remove("lime-focus");i=e;i.classList.add("lime-focus")}function C(e){var t;if(!i)t=d.querySelector(".lime-key");else if(e==="left"||e==="right"){t=i[(e==="left"?"previous":"next")+"Sibling"];if(!t&&!c)t=i.parentNode[(e==="left"?"last":"first")+"Child"]}else if(!c){var o=i.getBoundingClientRect(),l=i.offsetHeight,n=o.top+(e==="down"?l:-l),r=a;if(!a)r=a=o.left+i.offsetWidth/2;t=document.elementFromPoint(r-10,n);if(!t.classList.contains("lime-key"))t=document.elementFromPoint(r+10,n);if(!t.classList.contains("lime-key"))t=null}if(t){x(t);if(e==="left"||e==="right")a=i.getBoundingClientRect().left+i.offsetWidth/2}else if(c){var o=i.getBoundingClientRect();R();x(document.elementFromPoint(o.left,o.top));a=o.left+i.offsetWidth/2;return C(e)}}function S(){var e,t,r=i,a="toLocaleUpperCase"in String.prototype?"toLocaleUpperCase":"toUpperCase";if(t=h[r.id.slice(4)])return t(r);else{e=r.dataset[n?"symbol":"text"]||r.dataset.text;if(!e)return;if(o||l)e=e[a]();if(o){o=false;d.classList.remove("shift-toggle")}var s=document.activeElement;if(p||y.test(s.type)){var c=s.selectionStart;s.value=s.value.slice(0,c)+e+s.value.slice(s.selectionEnd);s.selectionStart=s.selectionEnd=c+e.length}else{var m,f,u,g=window.getSelection();g.deleteFromDocument();do{m=String(g).length;g.modify("extend","backward","line")}while(String(g).length!==m);f=String(g);g.deleteFromDocument();do{m=String(g).length;g.modify("extend","forward","line")}while(String(g).length!==m);u=String(g);g.deleteFromDocument();s.setAttribute("value",s.defaultValue);s.value=f+e+u;s.select();g=window.getSelection();g.collapseToEnd();while(m-->0)g.modify("move","backward","character")}}}function A(e){e.preventDefault();e.stopPropagation()}function B(){if(document.activeElement.form)document.activeElement.form.submit();L()}function T(){var e,t,o,l,n,r=v.verbatim.diacritics[i&&i.dataset.text];if(!i||!r)return;if(!(e=d.querySelector(".lime-diacritics-row"))){e=document.createElement("menu");e.className="lime-key-row lime-diacritics-row"}d.classList.add("lime-container-dim");i.classList.add("lime-toggle");o=d.getBoundingClientRect();t=i.getBoundingClientRect();l=i.parentNode.lastChild.getBoundingClientRect();e.innerHTML="";Array.prototype.forEach.call(r,function(t){var i=e.appendChild(document.createElement("li"));i.className="lime-key lime-diacritical";i.dataset.text=t});d.appendChild(e);c=e;n=e.offsetWidth;e.style.left=e.style.right="";if(t.right+n<=l.right)e.style.left=t.right-o.left+"px";else e.style.right=o.right-t.left+"px";e.style.top=t.top-o.top+"px";e.style.width=0;window.setTimeout(function(){e.style.width=n+"px"})}function R(){if(!c)return;c.parentNode.removeChild(c);d.classList.remove("lime-container-dim");x(d.querySelector(".lime-toggle[data-text]"));i.classList.remove("lime-toggle");a=i.getBoundingClientRect().left;c=null}function N(){var e,t=Array.prototype.slice.call(document.getElementsByTagName("*"));t=t.filter(function(e){return e.tabIndex>-1});t.sort(function(e,t){return(e.tabIndex||Number.MAX_VALUE)-(t.tabIndex||Number.MAX_VALUE)});e=t[t.indexOf(document.activeElement)+1];if(!e)e=t[0];if(e)e.focus()}function D(e){var t=/^(?:text|email|number|password|tel|url|search)$/,i=/^(?:email|number)$/;return(t.test(e.type)||e.isContentEditable)&&!e.readOnly}document.addEventListener("DOMFocusIn",function(e){var t=e.target.tagName;if(!f.config.noauto&&(e.target.isContentEditable||t==="INPUT"||t==="TEXTAREA"))k()});document.addEventListener("DOMFocusOut",function(e){if(u&&!f.config.noauto)L()});document.addEventListener("keydown",function(e){if(!u)return;var o;switch(e.key){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":if(r)return;A(e);C(e.key.slice(5).toLowerCase());break;case"Enter":if(!t)t=setTimeout(T,500);A(e);break;case"Escape":case"BrowserBack":A(e);if(r)h.Caret(i);else if(c)R();else L()}},true);document.addEventListener("keypress",function(e){var t=String.fromCharCode(e.keyCode).toLowerCase(),i=d.querySelector('li[data-text="'+t+'"]');if(i){x(i);window.setTimeout(function(){i.classList.remove("lime-focus")},100)}},true);document.addEventListener("keyup",function(e){if(!u)return;var o;switch(e.key){case"Escape":case"BrowserBack":case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":A(e);break;case"Enter":A(e);clearTimeout(t);t=null;if(c&&!i.classList.contains("lime-diacritical"))x(c.firstChild);else{S();if(c)R()}}},true);d.addEventListener("mousedown",function(e){A(e);var i=e.target,o=document.activeElement;if(!e.target.classList.contains("lime-key"))return;t=setTimeout(T,500)},true);d.addEventListener("mouseup",function(e){A(e);var i=e.target,o=document.activeElement;if(!e.target.classList.contains("lime-key"))return;clearTimeout(t);t=null;S();if(c)R()},true);d.addEventListener("mousemove",function(e){x(e.target)});d.addEventListener("mouseout",function(e){if(i===e.target)i.classList.remove("lime-focus")});(function(){var t={13:"Enter",27:"Escape",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown"},i={get:function(){var e=this.which;return t[e]||"Unidentified"}};if(e.KeyboardEvent&&!e.KeyboardEvent.prototype.hasOwnProperty("key"))Object.defineProperty(e.KeyboardEvent.prototype,"key",i);if(e.KeyEvent&&!e.KeyEvent.prototype.hasOwnProperty("key"))Object.defineProperty(e.KeyEvent.prototype,"key",i)})(e);E();f.show=k;f.hide=L;return f}); \ No newline at end of file +!function(e,t){var i,keyLime=t(e);"function"==typeof define&&define.amd&&define(i=keyLime),"object"==typeof exports&&(module.exports=i=keyLime),e.keyLime=keyLime}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){var e=document.createElement("input");e.type="number";try{return e.selectionStart=0,!0}catch(t){return!1}}function i(){g(document.activeElement)&&(clearTimeout(p),!K&&f("keylimeshow")&&(document.body.appendChild(T),K=!0))}function o(){clearTimeout(p),p=setTimeout(function(){K&&f("keylimehide")&&(document.body.removeChild(T),K=!1,v&&(v.classList.remove("lime-focus"),v=null))})}function n(){var e="",t={row2:{before:'
  • Tab
  • ',after:'
  • '},row3:{before:'
  • ',after:'
  • |↔
  • '}},i=D.verbatim.keys;e+=i.standard.map(function(e,o){var n=t["row"+o];return''+(n&&n.before||"")+e.map(function(e,t){return'
  • '}).join("")+(n&&n.after||"")+"
    "}).join(""),e+='
  •  
  • ',T.innerHTML=e}function l(e){e.classList.contains("lime-key")&&(v&&v.classList.remove("lime-focus"),v=e,v.classList.add("lime-focus"))}function a(e){var t;if(v){if("left"===e||"right"===e)t=v[("left"===e?"previous":"next")+"Sibling"],t||x||(t=v.parentNode[("left"===e?"last":"first")+"Child"]);else if(!x){var i=v.getBoundingClientRect(),o=v.offsetHeight,n=i.top+("down"===e?o:-o),r=E;E||(r=E=i.left+v.offsetWidth/2),t=document.elementFromPoint("left"===L?r-10:r+10,n),t.classList.contains("lime-key")||(t=document.elementFromPoint(r+10,n))}}else t=T.querySelector(".lime-key");if(t.classList.contains("lime-key"))l(t),("left"===e||"right"===e)&&(E=v.getBoundingClientRect().left+v.offsetWidth/2,L=e);else if(x){var i=v.getBoundingClientRect();return d(),l(document.elementFromPoint(i.left,i.top)),E=i.left+v.offsetWidth/2,a(e)}}function r(){var e,t,i=v,o="toLocaleUpperCase"in String.prototype?"toLocaleUpperCase":"toUpperCase";if(t=U[i.id.slice(4)])return t(i);if(e=i.dataset[b?"symbol":"text"]||i.dataset.text){(h||w)&&(e=e[o]()),h&&(h=!1,T.classList.remove("shift-toggle"));var n=document.activeElement;if(N||B.test(n.type)){var l=n.selectionStart;n.value=n.value.slice(0,l)+e+n.value.slice(n.selectionEnd),n.selectionStart=n.selectionEnd=l+e.length}else{var a,r,s,c=window.getSelection();c.deleteFromDocument();do a=String(c).length,c.modify("extend","backward","line");while(String(c).length!==a);r=String(c),c.deleteFromDocument();do a=String(c).length,c.modify("extend","forward","line");while(String(c).length!==a);for(s=String(c),c.deleteFromDocument(),n.setAttribute("value",n.defaultValue),n.value=r+e+s,n.select(),c=window.getSelection(),c.collapseToEnd();a-->0;)c.modify("move","backward","character")}}}function s(e){e.preventDefault(),e.stopPropagation()}function c(){document.activeElement.form&&document.activeElement.form.submit(),o()}function m(){var e,t,i,o,n,l=D.verbatim.diacritics[v&&v.dataset.text];v&&l&&((e=T.querySelector(".lime-diacritics-row"))||(e=document.createElement("menu"),e.className="lime-key-row lime-diacritics-row"),T.classList.add("lime-container-dim"),v.classList.add("lime-toggle"),i=T.getBoundingClientRect(),t=v.getBoundingClientRect(),o=v.parentNode.lastChild.getBoundingClientRect(),e.innerHTML="",Array.prototype.forEach.call(l,function(t){var i=e.appendChild(document.createElement("li"));i.className="lime-key lime-diacritical",i.dataset.text=t}),T.appendChild(e),x=e,n=e.offsetWidth,e.style.left=e.style.right="",t.right+n<=o.right?e.style.left=t.right-i.left+"px":e.style.right=i.right-t.left+"px",e.style.top=t.top-i.top+"px",e.style.width=0,window.setTimeout(function(){e.style.width=n+"px"}))}function d(){x&&(x.parentNode.removeChild(x),T.classList.remove("lime-container-dim"),l(T.querySelector(".lime-toggle[data-text]")),v.classList.remove("lime-toggle"),E=v.getBoundingClientRect().left,x=null)}function u(){var e,t,i=document.activeElement,o=Array.prototype.slice.call((i.form||document).getElementsByTagName("*"));for(o=o.filter(function(e){return e.tabIndex>-1&&e.offsetHeight&&!e.disabled}),o.sort(function(e,t){return(e.tabIndex||Number.MAX_VALUE)-(t.tabIndex||Number.MAX_VALUE)}),t=o.indexOf(i),o=o.slice(t+1).concat(o.slice(0,t)),t=0;document.activeElement!=e&&o.length;)e=o.shift(),e.focus()}function f(e){var t;return R?t=new CustomEvent(e,{bubbles:!0,cancelable:!0}):(t=document.createEvent("CustomEvent"),t.initCustomEvent(e,!0,!0)),document.activeElement.dispatchEvent(t)}function g(e){var t=/^(?:text|email|number|password|tel|url|search)$/;return(t.test(e.type)||e.isContentEditable)&&!e.readOnly}var y,p,v,h,w,b,k,E,L,x,C=document.createElement("style"),T=document.createElement("div"),S=e.keyLime||{config:{}},K=!1,R=function(){try{return!!new CustomEvent("a")}catch(e){return!1}}(),A=[".lime-container { background-color: #333; position: absolute; bottom: 0; left: 0; right: 0; color: #fff; z-index:1000000; font-family: sans-serif; }",'.lime-container-dim::before { position: absolute; content: ""; top: 0; left: 0; right: 0; bottom: 0; background-color: #000; opacity: 0.5; }',".lime-key-row { list-style-type: none; clear: both; text-align: center; padding: 0; margin: 0; font-size: 28px; }",".lime-diacritics-row { position: absolute; z-index: 2; overflow: hidden; -webkit-transition: width 400ms; transition: width 400ms; white-space: nowrap; }",".lime-key { vertical-align: top; display: inline-block; border: 3px solid #333; background-color: #666; width: 66px; line-height: 50px; -webkit-transition: all 400ms linear; transition: all 400ms linear; }",".lime-key[data-text]::before { content: attr(data-text) }",".lime-container.symbol-toggle .lime-key[data-symbol]::before { content: attr(data-symbol) }",".lime-container.shift-toggle .lime-key[data-text]:not(.lime-http):not(.lime-dotcom):not(.lime-wwwdot)::before { text-transform: uppercase; }",".lime-special-key { background-color: #999; color: #333; }",".lime-return { background-color: #ccc; width: 138px; }",".lime-focus { background-color: #26f; color: #fff; }",".lime-toggle { background-color: #2f2; color: #fff; position: relative; }",".lime-spacebar { width:498px; }",".lime-http, .lime-dotcom, .lime-wwwdot { font-size: 20px; }"],B=/^(?:text|search|url|tel|password)$/i,N=t(),U={Tab:u,Return:c,Shift:function(e){var t=T.querySelector(".lime-toggle");t&&t.classList.remove("lime-toggle"),T.classList.remove("shift-toggle","symbol-toggle"),b=k=!1,h?(h=!1,w=!0,e.classList.add("lime-toggle")):w?w=!1:h=!0,(h||w)&&T.classList.add("shift-toggle")},Symbol:function(e){var t=T.querySelector(".lime-toggle");t&&t.classList.remove("lime-toggle"),b=!b,h=w=k=!1,T.classList.remove("shift-toggle"),T.classList.toggle("symbol-toggle"),b&&e.classList.toggle("lime-toggle")},Backspace:function(){var e=document.activeElement,t=window.getSelection();if(g(e))if(N||B.test(e.type)){var i=e.selectionStart;String(t).length?(e.value=e.value.slice(0,i)+e.value.slice(e.selectionEnd),e.selectionStart=i):(e.value=e.value.slice(0,i-1)+e.value.slice(i),e.selectionStart=i-1)}else String(t).length||t.modify("extend","backward","character"),t.deleteFromDocument()},Caret:function(e){var t=T.querySelector(".lime-toggle");t&&t.classList.remove("lime-toggle"),b=h=w=!1,T.classList.remove("shift-toggle","symbol-toggle"),k=!k,k&&e.classList.add("lime-toggle")}},D={verbatim:{keys:{standard:[["@","1","2","3","4","5","6","7","8","9","0","-","="],["q","w","e","r","t","y","u","i","o","p","[","]"],["a","s","d","f","g","h","j","k","l",";","'"],["z","x","c","v","b","n","m",",",".","/"]],symbol:[["@","1","2","3","4","5","6","7","8","9","0","-","="],["~","#","`","£","$","%","^","&","(",")","[","]"],["•","€","¥","¡","¿","*","|","{","}",":","""],["_","+","!","\\","«","»","§","<",">","?"]]},diacritics:{a:"äáâàåæ",c:"ç©",d:"ð",e:"ëéêè",i:"ïíîì",m:"µ",n:"ñ",o:"öóôòõø",u:"üúûù",y:"ÿý"}}};T.className="lime-container",T.lang="en",document.head.insertBefore(C,document.head.firstChild);for(var P=0;P