src/pyams_skin/resources/js/ext/jquery-dataTables-keyTable.min.js
changeset 475 79ae32c82e3e
parent 0 bb4aabe07487
equal deleted inserted replaced
473:ca7ba7882abe 475:79ae32c82e3e
     1 /* KeyTable 1.2.0
     1 var KeyTable;!function(e,t,n){!function(n,o){"use strict";KeyTable=function(o){function l(e,t,n,o){E[e].push({x:t,y:n,fn:o})}function a(e,t,n,o){for(var l=0,a=0,i=E[e].length;a<i-l;a++)if(void 0!==o)E[e][a-l].x==t&&E[e][a-l].y==n&&E[e][a-l].fn==o&&(E[e].splice(a-l,1),l++);else if(E[e][a-l].x==t&&E[e][a-l].y==n)return E[e].splice(a,1),1;return l}function i(e,t,n){for(var o=0,l=E[e],a=0;a<l.length;a++)(l[a].x==t&&l[a].y==n||null===l[a].x&&l[a].y==n||l[a].x==t&&null===l[a].y||null===l[a].x&&null===l[a].y)&&(l[a].fn(y(t,n),t,n),o++);return o}function r(o,l){if(S!=o){void 0===l&&(l=!0),null!==S&&s(S),n(o).addClass(_),n(o).parent().addClass(_);var a;if(K){a=K;for(var r=m(o)[1],f=C;r>=a.fnDisplayEnd();)a._iDisplayLength>=0?a._iDisplayStart+a._iDisplayLength<a.fnRecordsDisplay()&&(a._iDisplayStart+=a._iDisplayLength):a._iDisplayStart=0,K.oApi._fnCalculateEnd(a);for(;r<a._iDisplayStart;)a._iDisplayStart=a._iDisplayLength>=0?a._iDisplayStart-a._iDisplayLength:0,a._iDisplayStart<0&&(a._iDisplayStart=0),K.oApi._fnCalculateEnd(a);K.oApi._fnDraw(a),C=f}var u=b(o);S=o,x=u[0],L=u[1];var c,p,y,g,D,N,k;if(l&&(c=n(e).height(),p=n(e).width(),y=n(t).scrollTop(),g=n(t).scrollLeft(),D=o.offsetHeight,N=o.offsetWidth,k=h(o),!K||void 0===a.oScroll||""===a.oScroll.sX&&""===a.oScroll.sY||(k[1]-=n(a.nTable.parentNode).scrollTop(),k[0]-=n(a.nTable.parentNode).scrollLeft()),k[1]+D>y+c?v(k[1]+D-c):k[1]<y&&v(k[1]),k[0]+N>g+p?T(k[0]+N-p):k[0]<g&&T(k[0])),K&&void 0!==a.oScroll&&(""!==a.oScroll.sX||""!==a.oScroll.sY)){var E=a.nTable.parentNode;c=E.clientHeight,p=E.clientWidth,y=E.scrollTop,g=E.scrollLeft,D=o.offsetHeight,N=o.offsetWidth,o.offsetTop+D>c+y?E.scrollTop=o.offsetTop+D-c:o.offsetTop<y&&(E.scrollTop=o.offsetTop),o.offsetLeft+N>p+g?E.scrollLeft=o.offsetLeft+N-p:o.offsetLeft<g&&(E.scrollLeft=o.offsetLeft)}d(),i("focus",x,L)}}function f(){s(S),x=null,L=null,S=null,p()}function s(e){n(e).removeClass(_),n(e).parent().removeClass(_),i("blur",x,L)}function u(e){for(var t=this;"TD"!=t.nodeName;)t=t.parentNode;r(t),d()}function c(e){if(k.block||!C)return!0;if(e.metaKey||e.altKey||e.ctrlKey)return!0;var t,n,o,l=N.getElementsByTagName("tr")[0].getElementsByTagName("td").length;if(K){o=K.aiDisplay.length;var a=m(S);if(null===a)return;x=a[0],L=a[1]}else o=N.getElementsByTagName("tr").length;var s=9==e.keyCode&&e.shiftKey?-1:e.keyCode;switch(s){case 13:return e.preventDefault(),e.stopPropagation(),i("action",x,L),!0;case 27:if(!i("esc",x,L))return void f();t=x,n=L;break;case-1:case 37:if(x>0)t=x-1,n=L;else{if(!(L>0))return!(-1!=s||!g||(w=!0,D.focus(),setTimeout(function(){w=!1},0),C=!1,f(),0));t=l-1,n=L-1}break;case 38:if(!(L>0))return!1;t=x,n=L-1;break;case 36:t=x,n=0;break;case 33:t=x,(n=L-10)<0&&(n=0);break;case 9:case 39:if(x<l-1)t=x+1,n=L;else{if(!(L<o-1))return!(9!=s||!g||(w=!0,D.focus(),setTimeout(function(){w=!1},0),C=!1,f(),0));t=0,n=L+1}break;case 40:if(!(L<o-1))return!1;t=x,n=L+1;break;case 35:t=x,n=o-1;break;case 34:t=x,(n=L+10)>o-1&&(n=o-1);break;default:return!0}return r(y(t,n)),!1}function d(){C||(C=!0)}function p(){C=!1}function y(e,t){return K?void 0!==K.aoData[K.aiDisplay[t]]?K.aoData[K.aiDisplay[t]].nTr.getElementsByTagName("td")[e]:null:n("tr:eq("+t+")>td:eq("+e+")",N)[0]}function b(e){return K?[n("td",e.parentNode).index(e),n("tr",e.parentNode.parentNode).index(e.parentNode)+K._iDisplayStart]:[n("td",e.parentNode).index(e),n("tr",e.parentNode.parentNode).index(e.parentNode)]}function v(e){t.documentElement.scrollTop=e,t.body.scrollTop=e}function T(e){t.documentElement.scrollLeft=e,t.body.scrollLeft=e}function h(e){var t=0,n=0;if(e.offsetParent)for(t=e.offsetLeft,n=e.offsetTop,e=e.offsetParent;e;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;return[t,n]}function m(e){for(var t=0,n=K.aiDisplay.length;t<n;t++)for(var o=K.aoData[K.aiDisplay[t]].nTr.getElementsByTagName("td"),l=0,a=o.length;l<a;l++)if(o[l]==e)return[l,t];return null}this.block=!1,this.event={remove:{}},this.fnGetCurrentPosition=function(){return[x,L]},this.fnGetCurrentData=function(){return S.innerHTML},this.fnGetCurrentTD=function(){return S},this.fnSetPosition=function(e,t){r("object"==typeof e&&e.nodeName?e:y(e,t))},this.fnBlur=function(){f()};var g,D,N=null,S=null,x=null,L=null,k=null,_="focus",C=!1,E={action:[],esc:[],focus:[],blur:[]},K=null,w=!1;for(var B in E)B&&(this.event[B]=function(e){return function(t,n,o){if(null!==t&&"number"!=typeof t||null!==n&&"number"!=typeof n||"function"!=typeof o)if("object"==typeof t&&"function"==typeof n){var a=b(t);l(e,a[0],a[1],n)}else alert("Unhandable event type was added: x"+t+"  y:"+n+"  z:"+o);else l(e,t,n,o)}}(B),this.event.remove[B]=function(e){return function(t,n,o){if(null!==t&&"number"!=typeof arguments[0]||null!==n&&"number"!=typeof arguments[1])if("object"==typeof arguments[0]){var l=b(t);"function"==typeof arguments[1]?a(e,l[0],l[1],n):a(e,l[0],l[1])}else alert("Unhandable event type was removed: x"+t+"  y:"+n+"  z:"+o);else"function"==typeof arguments[2]?a(e,t,n,o):a(e,t,n)}}(B));var P,j;void 0===o?(P=n("table.KeyTable")[0],j=null):n.isPlainObject(o)?(P=o.table,j=o.datatable):P=(j=new n.fn.dataTable.Api(o).settings()[0]).nTable,function(e,o,l,a){if(k=a,void 0===l&&(l={}),void 0===l.focus&&(l.focus=[0,0]),l.table=e,n(l.table).addClass("KeyTable"),void 0!==l.focusClass&&(_=l.focusClass),void 0!==o&&(K=o),void 0===l.initScroll&&(l.initScroll=!0),void 0===l.form&&(l.form=!1),g=l.form,N=l.table.getElementsByTagName("tbody")[0],g){var i=t.createElement("div");D=t.createElement("input"),i.style.height="1px",i.style.width="0px",i.style.overflow="hidden",void 0!==l.tabIndex&&(D.tabIndex=l.tabIndex),i.appendChild(D),l.table.parentNode.insertBefore(i,l.table.nextSibling),n(D).focus(function(){w||(C=!0,w=!1,void 0!==l.focus.nodeName?r(l.focus,l.initScroll):r(y(l.focus[0],l.focus[1]),l.initScroll),setTimeout(function(){D.blur()},0))}),C=!1}else void 0!==l.focus.nodeName?r(l.focus,l.initScroll):r(y(l.focus[0],l.focus[1]),l.initScroll),d();n(t).bind("keydown",c),K?n(K.nTable).on("click","td",u):n(N).on("click","td",u),n(t).click(function(e){for(var t=e.target,n=!1;t;){if(t==l.table){n=!0;break}t=t.parentNode}n||f()})}(P,j,o,this)},KeyTable.version="1.2.0",n.fn.dataTable.KeyTable=KeyTable,n.fn.DataTable.KeyTable=KeyTable}(jQuery,jQuery.fn.dataTable)}(window,document);
     2  * ©2010-2014 SpryMedia Ltd - datatables.net/license
       
     3  */
       
     4 var KeyTable;(function(c,a,d){var b=function(f,e){KeyTable=function(x){this.block=false;this.event={remove:{}};this.fnGetCurrentPosition=function(){return[i,g]};this.fnGetCurrentData=function(){return t.innerHTML};this.fnGetCurrentTD=function(){return t};this.fnSetPosition=function(P,Q){if(typeof P=="object"&&P.nodeName){h(P)}else{h(M(P,Q))}};this.fnBlur=function(){B()};var l=null;var t=null;var i=null;var g=null;var O=null;var o="focus";var D=false;var y={action:[],esc:[],focus:[],blur:[]};var k=null;var u;var z;var K=false;function J(P){return function(Q,T,S){if((Q===null||typeof Q=="number")&&(T===null||typeof T=="number")&&typeof S=="function"){E(P,Q,T,S)}else{if(typeof Q=="object"&&typeof T=="function"){var R=q(Q);E(P,R[0],R[1],T)}else{alert("Unhandable event type was added: x"+Q+"  y:"+T+"  z:"+S)}}}}function j(P){return function(Q,T,S){if((Q===null||typeof arguments[0]=="number")&&(T===null||typeof arguments[1]=="number")){if(typeof arguments[2]=="function"){N(P,Q,T,S)}else{N(P,Q,T)}}else{if(typeof arguments[0]=="object"){var R=q(Q);if(typeof arguments[1]=="function"){N(P,R[0],R[1],T)}else{N(P,R[0],R[1])}}else{alert("Unhandable event type was removed: x"+Q+"  y:"+T+"  z:"+S)}}}}for(var v in y){if(v){this.event[v]=J(v);this.event.remove[v]=j(v)}}function E(S,P,R,Q){y[S].push({x:P,y:R,fn:Q})}function N(V,Q,U,S){var T=0;for(var R=0,P=y[V].length;R<P-T;R++){if(typeof S!="undefined"){if(y[V][R-T].x==Q&&y[V][R-T].y==U&&y[V][R-T].fn==S){y[V].splice(R-T,1);T++}}else{if(y[V][R-T].x==Q&&y[V][R-T].y==U){y[V].splice(R,1);return 1}}}return T}function H(U,P,T){var S=0;var Q=y[U];for(var R=0;R<Q.length;R++){if((Q[R].x==P&&Q[R].y==T)||(Q[R].x===null&&Q[R].y==T)||(Q[R].x==P&&Q[R].y===null)||(Q[R].x===null&&Q[R].y===null)){Q[R].fn(M(P,T),P,T);S++}}return S}function h(U,ac){if(t==U){return}if(typeof ac=="undefined"){ac=true}if(t!==null){w(t)}f(U).addClass(o);f(U).parent().addClass(o);var R;if(k){R=k;var X=m(U)[1];var Y=D;while(X>=R.fnDisplayEnd()){if(R._iDisplayLength>=0){if(R._iDisplayStart+R._iDisplayLength<R.fnRecordsDisplay()){R._iDisplayStart+=R._iDisplayLength}}else{R._iDisplayStart=0}k.oApi._fnCalculateEnd(R)}while(X<R._iDisplayStart){R._iDisplayStart=R._iDisplayLength>=0?R._iDisplayStart-R._iDisplayLength:0;if(R._iDisplayStart<0){R._iDisplayStart=0}k.oApi._fnCalculateEnd(R)}k.oApi._fnDraw(R);D=Y}var V=q(U);t=U;i=V[0];g=V[1];var Z,ab,T,W,P,Q,aa;if(ac){Z=f(c).height();ab=f(c).width();T=f(a).scrollTop();W=f(a).scrollLeft();P=U.offsetHeight;Q=U.offsetWidth;aa=F(U);if(k&&typeof R.oScroll!="undefined"&&(R.oScroll.sX!==""||R.oScroll.sY!=="")){aa[1]-=f(R.nTable.parentNode).scrollTop();aa[0]-=f(R.nTable.parentNode).scrollLeft()}if(aa[1]+P>T+Z){G(aa[1]+P-Z)}else{if(aa[1]<T){G(aa[1])}}if(aa[0]+Q>W+ab){A(aa[0]+Q-ab)}else{if(aa[0]<W){A(aa[0])}}}if(k&&typeof R.oScroll!="undefined"&&(R.oScroll.sX!==""||R.oScroll.sY!=="")){var S=R.nTable.parentNode;Z=S.clientHeight;ab=S.clientWidth;T=S.scrollTop;W=S.scrollLeft;P=U.offsetHeight;Q=U.offsetWidth;if(U.offsetTop+P>Z+T){S.scrollTop=(U.offsetTop+P)-Z}else{if(U.offsetTop<T){S.scrollTop=U.offsetTop}}if(U.offsetLeft+Q>ab+W){S.scrollLeft=(U.offsetLeft+Q)-ab}else{if(U.offsetLeft<W){S.scrollLeft=U.offsetLeft}}}L();H("focus",i,g)}function B(){w(t);i=null;g=null;t=null;r()}function w(P){f(P).removeClass(o);f(P).parent().removeClass(o);H("blur",i,g)}function s(P){var Q=this;while(Q.nodeName!="TD"){Q=Q.parentNode}h(Q);L()}function n(U){if(O.block||!D){return true}if(U.metaKey||U.altKey||U.ctrlKey){return true}var Q,V,T=l.getElementsByTagName("tr")[0].getElementsByTagName("td").length,P;if(k){P=k.aiDisplay.length;var S=m(t);if(S===null){return}i=S[0];g=S[1]}else{P=l.getElementsByTagName("tr").length}var R=(U.keyCode==9&&U.shiftKey)?-1:U.keyCode;switch(R){case 13:U.preventDefault();U.stopPropagation();H("action",i,g);return true;case 27:if(!H("esc",i,g)){B();return}Q=i;V=g;break;case -1:case 37:if(i>0){Q=i-1;V=g}else{if(g>0){Q=T-1;V=g-1}else{if(R==-1&&u){K=true;z.focus();setTimeout(function(){K=false},0);D=false;B();return true}else{return false}}}break;case 38:if(g>0){Q=i;V=g-1}else{return false}break;case 36:Q=i;V=0;break;case 33:Q=i;V=g-10;if(V<0){V=0}break;case 9:case 39:if(i<T-1){Q=i+1;V=g}else{if(g<P-1){Q=0;V=g+1}else{if(R==9&&u){K=true;z.focus();setTimeout(function(){K=false},0);D=false;B();return true}else{return false}}}break;case 40:if(g<P-1){Q=i;V=g+1}else{return false}break;case 35:Q=i;V=P-1;break;case 34:Q=i;V=g+10;if(V>P-1){V=P-1}break;default:return true}h(M(Q,V));return false}function L(){if(!D){D=true}}function r(){D=false}function M(P,Q){if(k){if(typeof k.aoData[k.aiDisplay[Q]]!="undefined"){return k.aoData[k.aiDisplay[Q]].nTr.getElementsByTagName("td")[P]}else{return null}}else{return f("tr:eq("+Q+")>td:eq("+P+")",l)[0]}}function q(P){if(k){return[f("td",P.parentNode).index(P),f("tr",P.parentNode.parentNode).index(P.parentNode)+k._iDisplayStart]}else{return[f("td",P.parentNode).index(P),f("tr",P.parentNode.parentNode).index(P.parentNode)]}}function G(P){a.documentElement.scrollTop=P;a.body.scrollTop=P}function A(P){a.documentElement.scrollLeft=P;a.body.scrollLeft=P}function F(R){var Q=0;var P=0;if(R.offsetParent){Q=R.offsetLeft;P=R.offsetTop;R=R.offsetParent;while(R){Q+=R.offsetLeft;P+=R.offsetTop;R=R.offsetParent}}return[Q,P]}function m(V){for(var S=0,P=k.aiDisplay.length;S<P;S++){var U=k.aoData[k.aiDisplay[S]].nTr;var Q=U.getElementsByTagName("td");for(var R=0,T=Q.length;R<T;R++){if(Q[R]==V){return[R,S]}}}return null}function C(T,Q,P,S){O=S;if(typeof P=="undefined"){P={}}if(typeof P.focus=="undefined"){P.focus=[0,0]}P.table=T;f(P.table).addClass("KeyTable");if(typeof P.focusClass!="undefined"){o=P.focusClass}if(typeof Q!="undefined"){k=Q}if(typeof P.initScroll=="undefined"){P.initScroll=true}if(typeof P.form=="undefined"){P.form=false}u=P.form;l=P.table.getElementsByTagName("tbody")[0];if(u){var R=a.createElement("div");z=a.createElement("input");R.style.height="1px";R.style.width="0px";R.style.overflow="hidden";if(typeof P.tabIndex!="undefined"){z.tabIndex=P.tabIndex}R.appendChild(z);P.table.parentNode.insertBefore(R,P.table.nextSibling);f(z).focus(function(){if(!K){D=true;K=false;if(typeof P.focus.nodeName!="undefined"){h(P.focus,P.initScroll)}else{h(M(P.focus[0],P.focus[1]),P.initScroll)}setTimeout(function(){z.blur()},0)}});D=false}else{if(typeof P.focus.nodeName!="undefined"){h(P.focus,P.initScroll)}else{h(M(P.focus[0],P.focus[1]),P.initScroll)}L()}f(a).bind("keydown",n);if(k){f(k.nTable).on("click","td",s)}else{f(l).on("click","td",s)}f(a).click(function(V){var W=V.target;var U=false;while(W){if(W==P.table){U=true;break}W=W.parentNode}if(!U){B()}})}var I,p;if(x===d){I=f("table.KeyTable")[0];p=null}else{if(f.isPlainObject(x)){I=x.table;p=x.datatable}else{p=new f.fn.dataTable.Api(x).settings()[0];I=p.nTable}}C(I,p,x,this)};KeyTable.version="1.2.0";f.fn.dataTable.KeyTable=KeyTable;f.fn.DataTable.KeyTable=KeyTable;return KeyTable};b(jQuery,jQuery.fn.dataTable)})(window,document);