UNPKG

altinn-designsystem

Version:

Altinn Design system based on Pattern Lab.

1 lines 3.46 kB
!function(e,t){function r(e,t){return null===e?"null"===t:void 0===e?"undefined"===t:e.is&&e instanceof u?"element"===t:Object.prototype.toString.call(e).toLowerCase().indexOf(t)>7}function o(e){var t,n,a,i,s,u,f,y,d;if(e instanceof o)return e;for(r(e,"array")||(e=String(e).replace(/\s/g,"").toLowerCase().match(/(?:\+,|[^,])+/g)),t=0,n=e.length;t<n;++t){for(r(e[t],"array")||(e[t]=String(e[t]).match(/(?:\+\/|[^\/])+/g)),u=[],a=e[t].length;a--;){var f=e[t][a];for(s={jwertyCombo:String(f),shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1},r(f,"array")||(f=String(f).toLowerCase().match(/(?:(?:[^\+])+|\+\+|^\+$)/g)),i=f.length;i--;)"++"===f[i]&&(f[i]="+"),f[i]in l.mods?s[c[l.mods[f[i]]]]=!0:f[i]in l.keys?s.keyCode=l.keys[f[i]]:y=f[i].match(/^\[([^-]+\-?[^-]*)-([^-]+\-?[^-]*)\]$/);if(r(s.keyCode,"undefined"))if(y&&y[1]in l.keys&&y[2]in l.keys){for(y[2]=l.keys[y[2]],y[1]=l.keys[y[1]],d=y[1];d<y[2];++d)u.push({altKey:s.altKey,shiftKey:s.shiftKey,metaKey:s.metaKey,ctrlKey:s.ctrlKey,keyCode:d,jwertyCombo:String(f)});s.keyCode=d}else s.keyCode=0;u.push(s)}this[t]=u}return this.length=t,this}var a,i,s=e.document,u=e.jQuery||e.Zepto||e.ender||s,f="keydown";u===s?(a=function(e,t){return e?u.querySelector(e,t||u):u},i=function(e,t){e.addEventListener(f,t,!1)},$f=function(e,t){var n,r=document.createEvent("Event");r.initEvent(f,!0,!0);for(n in t)r[n]=t[n];return(e||u).dispatchEvent(r)}):(a=function(e,t,n){return u(e||s,t)},i=function(e,t){u(e).bind(f+".jwerty",t)},$f=function(e,t){u(e||s).trigger(u.Event(f,t))});var c={16:"shiftKey",17:"ctrlKey",18:"altKey",91:"metaKey"},l={mods:{"⇧":16,shift:16,"⌃":17,ctrl:17,"⌥":18,alt:18,option:18,"⌘":91,meta:91,cmd:91,"super":91,win:91},keys:{"⌫":8,backspace:8,"⇥":9,"⇆":9,tab:9,"↩":13,"return":13,enter:13,"⌅":13,pause:19,"pause-break":19,"⇪":20,caps:20,"caps-lock":20,"⎋":27,escape:27,esc:27,space:32,"↖":33,pgup:33,"page-up":33,"↘":34,pgdown:34,"page-down":34,"⇟":35,end:35,"⇞":36,home:36,ins:45,insert:45,del:46,"delete":46,"←":37,left:37,"arrow-left":37,"↑":38,up:38,"arrow-up":38,"→":39,right:39,"arrow-right":39,"↓":40,down:40,"arrow-down":40,"*":106,star:106,asterisk:106,multiply:106,"+":107,plus:107,"-":109,subtract:109,";":186,semicolon:186,"=":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}};for(y=95,n=0;++y<106;)l.keys["num-"+n]=y,++n;for(y=47,n=0;++y<58;)l.keys[n]=y,++n;for(y=111,n=1;++y<136;)l.keys["f"+n]=y,++n;for(var y=64;++y<91;)l.keys[String.fromCharCode(y).toLowerCase()]=y;var d=t.jwerty={event:function(e,t,n){if(r(t,"boolean")){var a=t;t=function(){return a}}e=new o(e);var i,s,u=0,f=e.length-1;return function(r){return(s=d.is(e,r,u))?u<f?void++u:(i=t.call(n||this,r,s),i===!1&&r.preventDefault(),void(u=0)):void(u=d.is(e,r)?1:0)}},is:function(e,t,n){e=new o(e),n=n||0,e=e[n],t=t.originalEvent||t;for(var r=e.length,a=!1;r--;){a=e[r].jwertyCombo;for(var i in e[r])"jwertyCombo"!==i&&t[i]!=e[r][i]&&(a=!1);if(a!==!1)return a}return a},key:function(t,n,o,s,u){var f=r(o,"element")||r(o,"string")?o:s,c=f===o?e:o,l=f===o?s:u;i(r(f,"element")?f:a(f,l),d.event(t,n,c))},fire:function(e,t,n,i){e=new o(e);var s=r(n,"number")?n:i;$f(r(t,"element")?t:a(t,n),e[s||0][0])},KEYS:l}}(this,"undefined"!=typeof module&&module.exports?module.exports:this);