Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of github.com:zupolgec/wp_save_with_keyboard

Conflicts:
	README.md
	readme.txt
	save_with_keyboard.php
  • Loading branch information...
commit 26628125155d7c7a0709723a7ae94853527e0416 2 parents 177a6dd + 4380a6e
Mattia Trapani authored

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. +9 0 jwerty.min.js
9 jwerty.min.js
... ... @@ -0,0 +1,9 @@
  1 +/*
  2 + * jwerty - Awesome handling of keyboard events
  3 + *
  4 + * @author Keith Cirkel ('keithamus') <jwerty@keithcirkel.co.uk>
  5 + * @license http://keithamus.mit-license.org/
  6 + * @copyright Copyright © 2011, Keith Cirkel
  7 + *
  8 + */
  9 +(function(a,b){function h(a,b){return a===null?b==="null":a===undefined?b==="undefined":a.is&&a instanceof d?b==="element":Object.prototype.toString.call(a).toLowerCase().indexOf(b)>7}function l(a){var b,c,d,e,f,g,k,m,n;if(a instanceof l)return a;h(a,"array")||(a=String(a).replace(/\s/g,"").toLowerCase().match(/(?:\+,|[^,])+/g));for(b=0,c=a.length;b<c;++b){h(a[b],"array")||(a[b]=String(a[b]).match(/(?:\+\/|[^\/])+/g)),g=[],d=a[b].length;while(d--){var k=a[b][d];f={jwertyCombo:String(k),shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1},h(k,"array")||(k=String(k).toLowerCase().match(/(?:(?:[^\+])+|\+\+|^\+$)/g)),e=k.length;while(e--)k[e]==="++"&&(k[e]="+"),k[e]in j.mods?f[i[j.mods[k[e]]]]=!0:k[e]in j.keys?f.keyCode=j.keys[k[e]]:m=k[e].match(/^\[([^-]+\-?[^-]*)-([^-]+\-?[^-]*)\]$/);if(h(f.keyCode,"undefined"))if(m&&m[1]in j.keys&&m[2]in j.keys){m[2]=j.keys[m[2]],m[1]=j.keys[m[1]];for(n=m[1];n<m[2];++n)g.push({altKey:f.altKey,shiftKey:f.shiftKey,metaKey:f.metaKey,ctrlKey:f.ctrlKey,keyCode:n,jwertyCombo:String(k)});f.keyCode=n}else f.keyCode=0;g.push(f)}this[b]=g}return this.length=b,this}var c=a.document,d=a.jQuery||a.Zepto||a.ender||c,e,f,g="keydown";d===c?(e=function(a,b){return a?d.querySelector(a,b||d):d},f=function(a,b){a.addEventListener(g,b,!1)},$f=function(a,b){var c=document.createEvent("Event"),e;c.initEvent(g,!0,!0);for(e in b)c[e]=b[e];return(a||d).dispatchEvent(c)}):(e=function(a,b,e){return d(a||c,b)},f=function(a,b){d(a).bind(g+".jwerty",b)},$f=function(a,b){d(a||c).trigger(d.Event(g,b))});var i={16:"shiftKey",17:"ctrlKey",18:"altKey",91:"metaKey"},j={mods:{"\u21e7":16,shift:16,"\u2303":17,ctrl:17,"\u2325":18,alt:18,option:18,"\u2318":91,meta:91,cmd:91,"super":91,win:91},keys:{"\u232b":8,backspace:8,"\u21e5":9,"\u21c6":9,tab:9,"\u21a9":13,"return":13,enter:13,"\u2305":13,pause:19,"pause-break":19,"\u21ea":20,caps:20,"caps-lock":20,"\u238b":27,escape:27,esc:27,space:32,"\u2196":33,pgup:33,"page-up":33,"\u2198":34,pgdown:34,"page-down":34,"\u21df":35,end:35,"\u21de":36,home:36,ins:45,insert:45,del:45,"delete":45,"\u2190":37,left:37,"arrow-left":37,"\u2191":38,up:38,"arrow-up":38,"\u2192":39,right:39,"arrow-right":39,"\u2193":40,down:40,"arrow-down":40,"*":106,star:106,asterisk:106,multiply:106,"+":107,plus:107,"-":109,subtract:109,"=":187,equals:187,",":188,comma:188,".":190,period:190,"full-stop":190,"/":191,slash:191,"forward-slash":191,"`":192,tick:192,"back-quote":192,"[":219,"open-bracket":219,"\\":220,"back-slash":220,"]":221,"close-bracket":221,"'":222,quote:222,apostraphe:222}};k=95,n=0;while(++k<106)j.keys["num-"+n]=k,++n;k=47,n=0;while(++k<58)j.keys[n]=k,++n;k=111,n=1;while(++k<136)j.keys["f"+n]=k,++n;var k=64;while(++k<91)j.keys[String.fromCharCode(k).toLowerCase()]=k;var m=b.jwerty={event:function(a,b,c){if(h(b,"boolean")){var d=b;b=function(){return d}}a=new l(a);var e=0,f=a.length-1,g,i;return function(d){if(i=m.is(a,d,e)){if(e<f){++e;return}g=b.call(c||this,d,i),g===!1&&d.preventDefault(),e=0;return}e=m.is(a,d)?1:0}},is:function(a,b,c){a=new l(a),c=c||0,a=a[c],b=b.originalEvent||b;var d,e=a.length,f=!1;while(e--){f=a[e].jwertyCombo;for(var g in a[e])g!=="jwertyCombo"&&b[g]!==a[e][g]&&(f=!1);if(f!==!1)return f}return f},key:function(b,c,d,g,i){var j=h(d,"element")||h(d,"string")?d:g,k=j===d?a:d,l=j===d?g:i;f(h(j,"element")?j:e(j,l),m.event(b,c,k))},fire:function(a,b,c,d){a=new l(a);var f=h(c,"number")?c:d;$f(h(b,"element")?b:e(b,c),a[f||0][0])},KEYS:j}})(this,typeof module!="undefined"&&module.exports?module.exports:this)

0 comments on commit 2662812

Please sign in to comment.
Something went wrong with that request. Please try again.