Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HeuristicLabWeb.PluginHost/HLWebPluginHost/Content/jQuery/jQueryPlugins/DataTables-1.7.6/extras/KeyTable/js/KeyTable.min.js @ 6286

Last change on this file since 6286 was 6286, checked in by dkahn, 13 years ago

#1198 Added jQuery plus plugins

File size: 7.1 KB
RevLine 
[6286]1/*
2 * File:        KeyTable.min.js
3 * Version:     1.1.6
4 * Author:      Allan Jardine (www.sprymedia.co.uk)
5 *
6 * Copyright 2009-2011 Allan Jardine, all rights reserved.
7 *
8 * This source file is free software, under either the GPL v2 license or a
9 * BSD (3 point) style license, as supplied with this software.
10 *
11 * This source file is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
14 */
15function KeyTable(q){this.block=false;this.event={remove:{}};this.fnGetCurrentPosition=function(){return[c,a]
16};this.fnGetCurrentData=function(){return m.innerHTML};this.fnGetCurrentTD=function(){return m
17};this.fnSetPosition=function(H,I){if(typeof H=="object"&&H.nodeName){b(H)}else{b(E(H,I))
18}};var f=null;var m=null;var c=null;var a=null;var G=null;var i="focus";var w=false;
19var r={action:[],esc:[],focus:[],blur:[]};var e=null;var n;var s;var C=false;function B(H){return function(I,L,K){if((I===null||typeof I=="number")&&(L===null||typeof L=="number")&&typeof K=="function"){x(H,I,L,K)
20}else{if(typeof I=="object"&&typeof L=="function"){var J=j(I);x(H,J[0],J[1],L)}else{alert("Unhandable event type was added: x"+I+"  y:"+L+"  z:"+K)
21}}}}function d(H){return function(I,L,K){if((I===null||typeof arguments[0]=="number")&&(L===null||typeof arguments[1]=="number")){if(typeof arguments[2]=="function"){F(H,I,L,K)
22}else{F(H,I,L)}}else{if(typeof arguments[0]=="object"){var J=j(I);if(typeof arguments[1]=="function"){F(H,J[0],J[1],L)
23}else{F(H,J[0],J[1])}}else{alert("Unhandable event type was removed: x"+I+"  y:"+L+"  z:"+K)
24}}}}for(var o in r){if(o){this.event[o]=B(o);this.event.remove[o]=d(o)}}function x(K,H,J,I){r[K].push({x:H,y:J,fn:I})
25}function F(N,I,M,K){var L=0;for(var J=0,H=r[N].length;J<H-L;J++){if(typeof K!="undefined"){if(r[N][J-L].x==I&&r[N][J-L].y==M&&r[N][J-L].fn==K){r[N].splice(J-L,1);
26L++}}else{if(r[N][J-L].x==I&&r[N][J-L].y==M){r[N].splice(J,1);return 1}}}return L
27}function A(M,H,L){var K=0;var I=r[M];for(var J=0;J<I.length;J++){if((I[J].x==H&&I[J].y==L)||(I[J].x===null&&I[J].y==L)||(I[J].x==H&&I[J].y===null)||(I[J].x===null&&I[J].y===null)){I[J].fn(E(H,L),H,L);
28K++}}return K}function b(M,U){if(m==M){return}if(typeof U=="undefined"){U=true}if(m!==null){p(m)
29}jQuery(M).addClass(i);var J;if(e){J=e.fnSettings();var P=g(M)[1];var Q=w;while(P>=J.fnDisplayEnd()){if(J._iDisplayLength>=0){if(J._iDisplayStart+J._iDisplayLength<J.fnRecordsDisplay()){J._iDisplayStart+=J._iDisplayLength
30}}else{J._iDisplayStart=0}e.oApi._fnCalculateEnd(J)}while(P<J._iDisplayStart){J._iDisplayStart=J._iDisplayLength>=0?J._iDisplayStart-J._iDisplayLength:0;
31if(J._iDisplayStart<0){J._iDisplayStart=0}e.oApi._fnCalculateEnd(J)}e.oApi._fnDraw(J);
32w=Q}var N=j(M);m=M;c=N[0];a=N[1];var R,T,L,O,H,I,S;if(U){R=document.documentElement.clientHeight;
33T=document.documentElement.clientWidth;L=document.body.scrollTop||document.documentElement.scrollTop;
34O=document.body.scrollLeft||document.documentElement.scrollLeft;H=M.offsetHeight;
35I=M.offsetWidth;S=y(M);if(S[1]+H>L+R){z(S[1]+H-R)}else{if(S[1]<L){z(S[1])}}if(S[0]+I>O+T){t(S[0]+I-T)
36}else{if(S[0]<O){t(S[0])}}}if(e&&typeof J.oScroll!="undefined"&&(J.oScroll.sX!==""||J.oScroll.xY!=="")){var K=J.nTable.parentNode;
37R=K.clientHeight;T=K.clientWidth;L=K.scrollTop;O=K.scrollLeft;H=M.offsetHeight;I=M.offsetWidth;
38if(M.offsetTop+H>R+L){K.scrollTop=(M.offsetTop+H)-R}else{if(M.offsetTop<L){K.scrollTop=M.offsetTop
39}}if(M.offsetLeft+I>T+O){K.scrollLeft=(M.offsetLeft+I)-T}else{if(M.offsetLeft<O){K.scrollLeft=M.offsetLeft
40}}}A("focus",c,a)}function u(){p(m);c=null;a=null;m=null;k()}function p(H){jQuery(H).removeClass(i);
41A("blur",c,a)}function l(H){var I=this;while(I.nodeName!="TD"){I=I.parentNode}b(I);
42D()}function h(N){if(G.block||!w){return true}if(N.metaKey||N.altKey||N.ctrlKey){return true
43}var I,O,L=f.getElementsByTagName("tr")[0].getElementsByTagName("td").length,H;if(e){var M=e.fnSettings();
44H=M.aiDisplay.length;var K=g(m);if(K===null){return}c=K[0];a=K[1]}else{H=f.getElementsByTagName("tr").length
45}var J=(N.keyCode==9&&N.shiftKey)?-1:N.keyCode;switch(J){case 13:N.preventDefault();
46N.stopPropagation();A("action",c,a);return true;case 27:if(!A("esc",c,a)){u()}break;
47case -1:case 37:if(c>0){I=c-1;O=a}else{if(a>0){I=L-1;O=a-1}else{if(J==-1&&n){C=true;
48s.focus();setTimeout(function(){C=false},0);w=false;u();return true}else{return false
49}}}break;case 38:if(a>0){I=c;O=a-1}else{return false}break;case 9:case 39:if(c<L-1){I=c+1;
50O=a}else{if(a<H-1){I=0;O=a+1}else{if(J==9&&n){C=true;s.focus();setTimeout(function(){C=false
51},0);w=false;u();return true}else{return false}}}break;case 40:if(a<H-1){I=c;O=a+1
52}else{return false}break;default:return true}b(E(I,O));return false}function D(){if(!w){w=true
53}}function k(){w=false}function E(H,J){if(e){var I=e.fnSettings();if(typeof I.aoData[I.aiDisplay[J]]!="undefined"){return I.aoData[I.aiDisplay[J]].nTr.getElementsByTagName("td")[H]
54}else{return null}}else{return jQuery("tr:eq("+J+")>td:eq("+H+")",f)[0]}}function j(I){if(e){var H=e.fnSettings();
55return[jQuery("td",I.parentNode).index(I),jQuery("tr",I.parentNode.parentNode).index(I.parentNode)+H._iDisplayStart]
56}else{return[jQuery("td",I.parentNode).index(I),jQuery("tr",I.parentNode.parentNode).index(I.parentNode)]
57}}function z(H){document.documentElement.scrollTop=H;document.body.scrollTop=H}function t(H){document.documentElement.scrollLeft=H;
58document.body.scrollLeft=H}function y(J){var I=0;var H=0;if(J.offsetParent){I=J.offsetLeft;
59H=J.offsetTop;J=J.offsetParent;while(J){I+=J.offsetLeft;H+=J.offsetTop;J=J.offsetParent
60}}return[I,H]}function g(O){var M=e.fnSettings();for(var K=0,H=M.aiDisplay.length;
61K<H;K++){var N=M.aoData[M.aiDisplay[K]].nTr;var I=N.getElementsByTagName("td");for(var J=0,L=I.length;
62J<L;J++){if(I[J]==O){return[J,K]}}}return null}function v(H,J){G=J;if(typeof H=="undefined"){H={}
63}if(typeof H.focus=="undefined"){H.focus=[0,0]}if(typeof H.table=="undefined"){H.table=jQuery("table.KeyTable")[0]
64}if(typeof H.focusClass!="undefined"){i=H.focusClass}if(typeof H.datatable!="undefined"){e=H.datatable
65}if(typeof H.initScroll=="undefined"){H.initScroll=true}if(typeof H.form=="undefined"){H.form=false
66}n=H.form;f=H.table.getElementsByTagName("tbody")[0];if(n){var I=document.createElement("div");
67s=document.createElement("input");I.style.height="1px";I.style.width="0px";I.style.overflow="hidden";
68if(typeof H.tabIndex!="undefined"){s.tabIndex=H.tabIndex}I.appendChild(s);H.table.parentNode.insertBefore(I,H.table.nextSibling);
69jQuery(s).focus(function(){if(!C){w=true;C=false;if(typeof H.focus.nodeName!="undefined"){b(H.focus,H.initScroll)
70}else{b(E(H.focus[0],H.focus[1]),H.initScroll)}setTimeout(function(){s.blur()},0)
71}});w=false}else{if(typeof H.focus.nodeName!="undefined"){b(H.focus,H.initScroll)
72}else{b(E(H.focus[0],H.focus[1]),H.initScroll)}D()}if(jQuery.browser.mozilla||jQuery.browser.opera){jQuery(document).bind("keypress",h)
73}else{jQuery(document).bind("keydown",h)}if(e){jQuery("td",e.fnGetNodes()).click(l)
74}else{jQuery("td",f).click(l)}jQuery(document).click(function(L){var M=L.target;var K=false;
75while(M){if(M==H.table){K=true;break}M=M.parentNode}if(!K){u()}})}v(q,this)};
Note: See TracBrowser for help on using the repository browser.