META-INF.resources.bower_components.datatables.net-keytable.js.dataTables.keyTable.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-data-tables Show documentation
Show all versions of jwebmp-data-tables Show documentation
The JWebSwing implementation for Data Tables
/*! KeyTable 2.4.1
* ©2009-2018 SpryMedia Ltd - datatables.net/license
*/
(function(a){if(typeof define==="function"&&define.amd){define(["jquery","datatables.net"],function(b){return a(b,window,document)})}else{if(typeof exports==="object"){module.exports=function(b,c){if(!b){b=window}if(!c||!c.fn.dataTable){c=require("datatables.net")(b,c).$}return a(c,b,b.document)}}else{a(jQuery,window,document)}}}(function(d,b,a,f){var c=d.fn.dataTable;var e=function(j,i){if(!c.versionCheck||!c.versionCheck("1.10.8")){throw"KeyTable requires DataTables 1.10.8 or newer"}this.c=d.extend(true,{},c.defaults.keyTable,e.defaults,i);this.s={dt:new c.Api(j),enable:true,focusDraw:false,waitingForDraw:false,lastFocus:null};this.dom={};var h=this.s.dt.settings()[0];var g=h.keytable;if(g){return g}h.keytable=this;this._constructor()};d.extend(e.prototype,{blur:function(){this._blur()},enable:function(g){this.s.enable=g},focus:function(h,g){this._focus(this.s.dt.cell(h,g))},focused:function(g){var i=this.s.lastFocus;if(!i){return false}var h=this.s.lastFocus.cell.index();return g.row===h.row&&g.column===h.column},_constructor:function(){this._tabInput();var j=this;var i=this.s.dt;var h=d(i.table().node());if(h.css("position")==="static"){h.css("position","relative")}d(i.table().body()).on("click.keyTable","th, td",function(m){if(j.s.enable===false){return}var l=i.cell(this);if(!l.any()){return}j._focus(l,null,false,m)});d(a).on("keydown.keyTable",function(l){j._key(l)});if(this.c.blurable){d(a).on("mousedown.keyTable",function(l){if(d(l.target).parents(".dataTables_filter").length){j._blur()}if(d(l.target).parents().filter(i.table().container()).length){return}if(d(l.target).parents("div.DTE").length){return}if(d(l.target).parents("div.editor-datetime").length){return}if(d(l.target).parents().filter(".DTFC_Cloned").length){return}j._blur()})}if(this.c.editor){var g=this.c.editor;g.on("open.keyTableMain",function(m,n,l){if(n!=="inline"&&j.s.enable){j.enable(false);g.one("close.keyTable",function(){j.enable(true)})}});if(this.c.editOnFocus){i.on("key-focus.keyTable key-refocus.keyTable",function(n,m,l,o){j._editor(null,o)})}i.on("key.keyTable",function(o,n,m,l,p){j._editor(m,p)})}if(i.settings()[0].oFeatures.bStateSave){i.on("stateSaveParams.keyTable",function(m,l,n){n.keyTable=j.s.lastFocus?j.s.lastFocus.cell.index():null})}i.on("draw.keyTable",function(o){if(j.s.focusDraw){return}var n=j.s.lastFocus;if(n&&n.node&&d(n.node).closest("body")===a.body){var l=j.s.lastFocus.relative;var m=i.page.info();var p=l.row+m.start;if(m.recordsDisplay===0){return}if(p>=m.recordsDisplay){p=m.recordsDisplay-1}j._focus(p,l.column,true,o)}});if(this.c.clipboard){this._clipboard()}i.on("destroy.keyTable",function(){i.off(".keyTable");d(i.table().body()).off("click.keyTable","th, td");d(a).off("keydown.keyTable").off("click.keyTable").off("copy.keyTable").off("paste.keyTable")});var k=i.state.loaded();if(k&&k.keyTable){i.one("init",function(){var l=i.cell(k.keyTable);if(l.any()){l.focus()}})}else{if(this.c.focus){i.cell(this.c.focus).focus()}}},_blur:function(){if(!this.s.enable||!this.s.lastFocus){return}var g=this.s.lastFocus.cell;d(g.node()).removeClass(this.c.className);this.s.lastFocus=null;this._updateFixedColumns(g.index().column);this._emitEvent("key-blur",[this.s.dt,g])},_clipboard:function(){var h=this.s.dt;var g=this;if(!b.getSelection){return}d(a).on("copy.keyTable",function(i){var l=i.originalEvent;var j=b.getSelection().toString();var k=g.s.lastFocus;if(!j&&k){l.clipboardData.setData("text/plain",k.cell.render(g.c.clipboardOrthogonal));l.preventDefault()}});d(a).on("paste.keyTable",function(j){var m=j.originalEvent;var l=g.s.lastFocus;var n=a.activeElement;var k=g.c.editor;var i;if(l&&(!n||n.nodeName.toLowerCase()==="body")){m.preventDefault();if(b.clipboardData&&b.clipboardData.getData){i=b.clipboardData.getData("Text")}else{if(m.clipboardData&&m.clipboardData.getData){i=m.clipboardData.getData("text/plain")}}if(k){k.inline(l.cell.index()).set(k.displayed()[0],i).submit()}else{l.cell.data(i);h.draw(false)}}})},_columns:function(){var i=this.s.dt;var g=i.columns(this.c.columns).indexes();var h=[];i.columns(":visible").every(function(j){if(g.indexOf(j)!==-1){h.push(j)}});return h},_editor:function(h,l){var k=this;var j=this.s.dt;var i=this.c.editor;if(d("div.DTE",this.s.lastFocus.cell.node()).length){return}if((h>=0&&h<=9)||h===11||h===12||(h>=14&&h<=31)||(h>=112&&h<=123)||(h>=127&&h<=159)){return}l.stopPropagation();if(h===13){l.preventDefault()}var g=function(){i.one("open.keyTable",function(){i.off("cancelOpen.keyTable");if(k.c.editAutoSelect){d("div.DTE_Field_InputControl input, div.DTE_Field_InputControl textarea").select()}j.keys.enable(k.c.editorKeys);j.one("key-blur.editor",function(){if(i.displayed()){i.submit()}});i.one("close",function(){j.keys.enable(true);j.off("key-blur.editor")})}).one("cancelOpen.keyTable",function(){i.off("open.keyTable")}).inline(k.s.lastFocus.cell.index())};if(h===13){d(a).one("keyup",function(){g()})}else{g()}},_emitEvent:function(h,g){this.s.dt.iterator("table",function(j,k){d(j.nTable).triggerHandler(h,g)})},_focus:function(t,k,i,g){var m=this;var h=this.s.dt;var q=h.page.info();var s=this.s.lastFocus;if(!g){g=null}if(!this.s.enable){return}if(typeof t!=="number"){if(!t.any()){return}var l=t.index();k=l.column;t=h.rows({filter:"applied",order:"applied"}).indexes().indexOf(l.row);if(q.serverSide){t+=q.start}}if(q.length!==-1&&(t=q.start+q.length)){this.s.focusDraw=true;this.s.waitingForDraw=true;h.one("draw",function(){m.s.focusDraw=false;m.s.waitingForDraw=false;m._focus(t,k,f,g)}).page(Math.floor(t/q.length)).draw(false);return}if(d.inArray(k,this._columns())===-1){return}if(q.serverSide){t-=q.start}var r=h.cells(null,k,{search:"applied",order:"applied"}).flatten();var p=h.cell(r[t]);if(s){if(s.node===p.node()){this._emitEvent("key-refocus",[this.s.dt,p,g||null]);return}this._blur()}var j=d(p.node());j.addClass(this.c.className);this._updateFixedColumns(k);if(i===f||i===true){this._scroll(d(b),d(a.body),j,"offset");var o=h.table().body().parentNode;if(o!==h.table().header().parentNode){var n=d(o.parentNode);this._scroll(n,n,j,"position")}}this.s.lastFocus={cell:p,node:p.node(),relative:{row:h.rows({page:"current"}).indexes().indexOf(p.index().row),column:p.index().column}};this._emitEvent("key-focus",[this.s.dt,p,g||null]);h.state.save()},_key:function(m){if(this.s.waitingForDraw){m.preventDefault();return}var j=this.s.enable;var n=j===true||j==="navigation-only";if(!j){return}if((m.keyCode===0||m.ctrlKey||m.metaKey||m.altKey)&&!(m.ctrlKey&&m.altKey)){return}var o=this.s.lastFocus;if(!o){return}var l=this;var g=this.s.dt;var i=this.s.dt.settings()[0].oScroll.sY?true:false;if(this.c.keys&&d.inArray(m.keyCode,this.c.keys)===-1){return}switch(m.keyCode){case 9:this._shift(m,m.shiftKey?"left":"right",true);break;case 27:if(this.s.blurable&&j===true){this._blur()}break;case 33:case 34:if(n&&!i){m.preventDefault();g.page(m.keyCode===33?"previous":"next").draw(false)}break;case 35:case 36:if(n){m.preventDefault();var k=g.cells({page:"current"}).indexes();var h=this._columns();this._focus(g.cell(k[m.keyCode===35?k.length-1:h[0]]),null,true,m)}break;case 37:if(n){this._shift(m,"left")}break;case 38:if(n){this._shift(m,"up")}break;case 39:if(n){this._shift(m,"right")}break;case 40:if(n){this._shift(m,"down")}break;default:if(j===true){this._emitEvent("key",[g,m.keyCode,this.s.lastFocus.cell,m])}break}},_scroll:function(g,l,n,p){var k=n[p]();var o=n.outerHeight();var h=n.outerWidth();var i=l.scrollTop();var j=l.scrollLeft();var q=g.height();var m=g.width();if(p==="position"){k.top+=parseInt(n.closest("table").css("top"),10)}if(k.topi+q&&oj+m&&h=j.length-1){q++;i=j[0]}else{i=j[h+1]}}else{if(o==="left"){if(h===0){q--;i=j[j.length-1]}else{i=j[h-1]}}else{if(o==="up"){q--}else{if(o==="down"){q++}}}}if(q>=0&&q