1 | /*!
|
---|
2 | Copyright 2010-2019 SpryMedia Ltd.
|
---|
3 |
|
---|
4 | This source file is free software, available under the following license:
|
---|
5 | MIT license - http://datatables.net/license/mit
|
---|
6 |
|
---|
7 | This source file is distributed in the hope that it will be useful, but
|
---|
8 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
---|
9 | or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
---|
10 |
|
---|
11 | For details please refer to: http://www.datatables.net
|
---|
12 | AutoFill 2.3.4
|
---|
13 | ©2008-2019 SpryMedia Ltd - datatables.net/license
|
---|
14 | */
|
---|
15 | var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var h=0;return function(){return h<a.length?{done:!1,value:a[h++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
|
---|
16 | $jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,h,e){a!=Array.prototype&&a!=Object.prototype&&(a[h]=e.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};
|
---|
17 | $jscomp.SymbolClass=function(a,h){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:h})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};$jscomp.Symbol=function(){function a(e){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(e||"")+"_"+h++,e)}var h=0;return a}();
|
---|
18 | $jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
|
---|
19 | $jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};
|
---|
20 | $jscomp.iteratorFromArray=function(a,h){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var e=0,l={next:function(){if(e<a.length){var k=e++;return{value:h(k,a[k]),done:!1}}l.next=function(){return{done:!0,value:void 0}};return l.next()}};l[Symbol.iterator]=function(){return l};return l};
|
---|
21 | $jscomp.polyfill=function(a,h,e,l){if(h){e=$jscomp.global;a=a.split(".");for(l=0;l<a.length-1;l++){var k=a[l];k in e||(e[k]={});e=e[k]}a=a[a.length-1];l=e[a];h=h(l);h!=l&&null!=h&&$jscomp.defineProperty(e,a,{configurable:!0,writable:!0,value:h})}};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6","es3");
|
---|
22 | (function(a){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(h){return a(h,window,document)}):"object"===typeof exports?module.exports=function(h,e){h||(h=window);e&&e.fn.dataTable||(e=require("datatables.net")(h,e).$);return a(e,h,h.document)}:a(jQuery,window,document)})(function(a,h,e,l){var k=a.fn.dataTable,w=0,m=function(b,d){if(!k.versionCheck||!k.versionCheck("1.10.8"))throw"Warning: AutoFill requires DataTables 1.10.8 or greater";this.c=a.extend(!0,{},k.defaults.autoFill,
|
---|
23 | m.defaults,d);this.s={dt:new k.Api(b),namespace:".autoFill"+w++,scroll:{},scrollInterval:null,handle:{height:0,width:0},enabled:!1};this.dom={handle:a('<div class="dt-autofill-handle"/>'),select:{top:a('<div class="dt-autofill-select top"/>'),right:a('<div class="dt-autofill-select right"/>'),bottom:a('<div class="dt-autofill-select bottom"/>'),left:a('<div class="dt-autofill-select left"/>')},background:a('<div class="dt-autofill-background"/>'),list:a('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info",
|
---|
24 | "")+"<ul/></div>"),dtScroll:null,offsetParent:null};this._constructor()};a.extend(m.prototype,{enabled:function(){return this.s.enabled},enable:function(b){var d=this;if(!1===b)return this.disable();this.s.enabled=!0;this._focusListener();this.dom.handle.on("mousedown",function(b){d._mousedown(b);return!1});return this},disable:function(){this.s.enabled=!1;this._focusListenerRemove();return this},_constructor:function(){var b=this,d=this.s.dt,c=a("div.dataTables_scrollBody",this.s.dt.table().container());
|
---|
25 | d.settings()[0].autoFill=this;c.length&&(this.dom.dtScroll=c,"static"===c.css("position")&&c.css("position","relative"));!1!==this.c.enable&&this.enable();d.on("destroy.autoFill",function(){b._focusListenerRemove()})},_attach:function(b){var d=this.s.dt,c=d.cell(b).index(),f=this.dom.handle,g=this.s.handle;c&&-1!==d.columns(this.c.columns).indexes().indexOf(c.column)?(this.dom.offsetParent||(this.dom.offsetParent=a(d.table().node()).offsetParent()),g.height&&g.width||(f.appendTo("body"),g.height=
|
---|
26 | f.outerHeight(),g.width=f.outerWidth()),d=this._getPosition(b,this.dom.offsetParent),this.dom.attachedTo=b,f.css({top:d.top+b.offsetHeight-g.height,left:d.left+b.offsetWidth-g.width}).appendTo(this.dom.offsetParent)):this._detach()},_actionSelector:function(b){var d=this,c=this.s.dt,f=m.actions,g=[];a.each(f,function(d,a){a.available(c,b)&&g.push(d)});if(1===g.length&&!1===this.c.alwaysAsk){var e=f[g[0]].execute(c,b);this._update(e,b)}else{var n=this.dom.list.children("ul").empty();g.push("cancel");
|
---|
27 | a.each(g,function(g,e){n.append(a("<li/>").append('<div class="dt-autofill-question">'+f[e].option(c,b)+"<div>").append(a('<div class="dt-autofill-button">').append(a('<button class="'+m.classes.btn+'">'+c.i18n("autoFill.button",">")+"</button>").on("click",function(){var g=f[e].execute(c,b,a(this).closest("li"));d._update(g,b);d.dom.background.remove();d.dom.list.remove()}))))});this.dom.background.appendTo("body");this.dom.list.appendTo("body");this.dom.list.css("margin-top",this.dom.list.outerHeight()/
|
---|
28 | 2*-1)}},_detach:function(){this.dom.attachedTo=null;this.dom.handle.detach()},_drawSelection:function(b,d){var c=this.s.dt;d=this.s.start;var f=a(this.dom.start),g={row:this.c.vertical?c.rows({page:"current"}).nodes().indexOf(b.parentNode):d.row,column:this.c.horizontal?a(b).index():d.column};b=c.column.index("toData",g.column);var e=c.row(":eq("+g.row+")",{page:"current"});e=a(c.cell(e.index(),b).node());if(c.cell(e).any()&&-1!==c.columns(this.c.columns).indexes().indexOf(b)){this.s.end=g;c=d.row<
|
---|
29 | g.row?f:e;var n=d.row<g.row?e:f;b=d.column<g.column?f:e;f=d.column<g.column?e:f;c=this._getPosition(c.get(0)).top;b=this._getPosition(b.get(0)).left;d=this._getPosition(n.get(0)).top+n.outerHeight()-c;f=this._getPosition(f.get(0)).left+f.outerWidth()-b;g=this.dom.select;g.top.css({top:c,left:b,width:f});g.left.css({top:c,left:b,height:d});g.bottom.css({top:c+d,left:b,width:f});g.right.css({top:c,left:b+f,height:d})}},_editor:function(b){var d=this.s.dt,c=this.c.editor;if(c){for(var a={},g=[],e=c.fields(),
|
---|
30 | n=0,h=b.length;n<h;n++)for(var k=0,m=b[n].length;k<m;k++){var q=b[n][k],p=d.settings()[0].aoColumns[q.index.column],r=p.editField;if(r===l){p=p.mData;for(var u=0,y=e.length;u<y;u++){var v=c.field(e[u]);if(v.dataSrc()===p){r=v.name();break}}}if(!r)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";a[r]||(a[r]={});p=d.row(q.index.row).id();a[r][p]=q.set;g.push(q.index)}c.bubble(g,!1).multiSet(a).submit()}},_emitEvent:function(b,d){this.s.dt.iterator("table",
|
---|
31 | function(c,f){a(c.nTable).triggerHandler(b+".dt",d)})},_focusListener:function(){var b=this,d=this.s.dt,c=this.s.namespace,f=null!==this.c.focus?this.c.focus:d.init().keys||d.settings()[0].keytable?"focus":"hover";if("focus"===f)d.on("key-focus.autoFill",function(c,d,a){b._attach(a.node())}).on("key-blur.autoFill",function(c,a,d){b._detach()});else if("click"===f)a(d.table().body()).on("click"+c,"td, th",function(c){b._attach(this)}),a(e.body).on("click"+c,function(c){a(c.target).parents().filter(d.table().body()).length||
|
---|
32 | b._detach()});else a(d.table().body()).on("mouseenter"+c,"td, th",function(c){b._attach(this)}).on("mouseleave"+c,function(c){a(c.relatedTarget).hasClass("dt-autofill-handle")||b._detach()})},_focusListenerRemove:function(){var b=this.s.dt;b.off(".autoFill");a(b.table().body()).off(this.s.namespace);a(e.body).off(this.s.namespace)},_getPosition:function(b,d){var c=0,f=0;d||(d=a(a(this.s.dt.table().node())[0].offsetParent));do{var g=b.offsetTop,e=b.offsetLeft;var h=a(b.offsetParent);c+=g+1*parseInt(h.css("border-top-width"));
|
---|
33 | f+=e+1*parseInt(h.css("border-left-width"));if("body"===b.nodeName.toLowerCase())break;b=h.get(0)}while(h.get(0)!==d.get(0));return{top:c,left:f}},_mousedown:function(b){var d=this,c=this.s.dt;this.dom.start=this.dom.attachedTo;this.s.start={row:c.rows({page:"current"}).nodes().indexOf(a(this.dom.start).parent()[0]),column:a(this.dom.start).index()};a(e.body).on("mousemove.autoFill",function(b){d._mousemove(b)}).on("mouseup.autoFill",function(b){d._mouseup(b)});var f=this.dom.select;c=a(c.table().node()).offsetParent();
|
---|
34 | f.top.appendTo(c);f.left.appendTo(c);f.right.appendTo(c);f.bottom.appendTo(c);this._drawSelection(this.dom.start,b);this.dom.handle.css("display","none");b=this.dom.dtScroll;this.s.scroll={windowHeight:a(h).height(),windowWidth:a(h).width(),dtTop:b?b.offset().top:null,dtLeft:b?b.offset().left:null,dtHeight:b?b.outerHeight():null,dtWidth:b?b.outerWidth():null}},_mousemove:function(b){var a=b.target.nodeName.toLowerCase();if("td"===a||"th"===a)this._drawSelection(b.target,b),this._shiftScroll(b)},_mouseup:function(b){a(e.body).off(".autoFill");
|
---|
35 | var d=this,c=this.s.dt,f=this.dom.select;f.top.remove();f.left.remove();f.right.remove();f.bottom.remove();this.dom.handle.css("display","block");f=this.s.start;var g=this.s.end;if(f.row!==g.row||f.column!==g.column){var h=c.cell(":eq("+f.row+")",f.column+":visible",{page:"current"});if(a("div.DTE",h.node()).length){var n=c.editor();n.on("submitSuccess.dtaf close.dtaf",function(){n.off(".dtaf");setTimeout(function(){d._mouseup(b)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",
|
---|
36 | function(){n.off(".dtaf")});n.submit()}else{var k=this._range(f.row,g.row);f=this._range(f.column,g.column);g=[];for(var m=c.settings()[0],x=m.aoColumns,q=c.columns(this.c.columns).indexes(),p=0;p<k.length;p++)g.push(a.map(f,function(b){var a=c.row(":eq("+k[p]+")",{page:"current"});b=c.cell(a.index(),b+":visible");a=b.data();var d=b.index(),f=x[d.column].editField;f!==l&&(a=m.oApi._fnGetObjectDataFn(f)(c.row(d.row).data()));if(-1!==q.indexOf(d.column))return{cell:b,data:a,label:b.data(),index:d}}));
|
---|
37 | this._actionSelector(g);clearInterval(this.s.scrollInterval);this.s.scrollInterval=null}}},_range:function(b,a){var c=[];if(b<=a)for(;b<=a;b++)c.push(b);else for(;b>=a;b--)c.push(b);return c},_shiftScroll:function(b){var a=this,c=this.s.scroll,f=!1,g=b.pageY-e.body.scrollTop,h=b.pageX-e.body.scrollLeft,n,k,l,m;65>g?n=-5:g>c.windowHeight-65&&(n=5);65>h?k=-5:h>c.windowWidth-65&&(k=5);null!==c.dtTop&&b.pageY<c.dtTop+65?l=-5:null!==c.dtTop&&b.pageY>c.dtTop+c.dtHeight-65&&(l=5);null!==c.dtLeft&&b.pageX<
|
---|
38 | c.dtLeft+65?m=-5:null!==c.dtLeft&&b.pageX>c.dtLeft+c.dtWidth-65&&(m=5);n||k||l||m?(c.windowVert=n,c.windowHoriz=k,c.dtVert=l,c.dtHoriz=m,f=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null);!this.s.scrollInterval&&f&&(this.s.scrollInterval=setInterval(function(){c.windowVert&&(e.body.scrollTop+=c.windowVert);c.windowHoriz&&(e.body.scrollLeft+=c.windowHoriz);if(c.dtVert||c.dtHoriz){var b=a.dom.dtScroll[0];c.dtVert&&(b.scrollTop+=c.dtVert);c.dtHoriz&&(b.scrollLeft+=
|
---|
39 | c.dtHoriz)}},20))},_update:function(b,a){if(!1!==b){b=this.s.dt;var c=b.columns(this.c.columns).indexes();this._emitEvent("preAutoFill",[b,a]);this._editor(a);if(null!==this.c.update?this.c.update:!this.c.editor){for(var d=0,g=a.length;d<g;d++)for(var e=0,h=a[d].length;e<h;e++){var k=a[d][e];-1!==c.indexOf(k.index.column)&&k.cell.data(k.set)}b.draw(!1)}this._emitEvent("autoFill",[b,a])}}});m.actions={increment:{available:function(b,a){b=a[0][0].label;return!isNaN(b-parseFloat(b))},option:function(b,
|
---|
40 | a){return b.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(b,d,c){b=1*d[0][0].data;c=1*a("input",c).val();for(var f=0,g=d.length;f<g;f++)for(var e=0,h=d[f].length;e<h;e++)d[f][e].set=b,b+=c}},fill:{available:function(b,a){return!0},option:function(b,a){return b.i18n("autoFill.fill","Fill all cells with <i>"+a[0][0].label+"</i>")},execute:function(b,a,c){b=a[0][0].data;c=0;for(var d=a.length;c<d;c++)for(var e=0,h=a[c].length;e<h;e++)a[c][e].set=
|
---|
41 | b}},fillHorizontal:{available:function(b,a){return 1<a.length&&1<a[0].length},option:function(b,a){return b.i18n("autoFill.fillHorizontal","Fill cells horizontally")},execute:function(b,a,c){b=0;for(c=a.length;b<c;b++)for(var d=0,e=a[b].length;d<e;d++)a[b][d].set=a[b][0].data}},fillVertical:{available:function(b,a){return 1<a.length&&1<a[0].length},option:function(b,a){return b.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(b,a,c){b=0;for(c=a.length;b<c;b++)for(var d=0,e=
|
---|
42 | a[b].length;d<e;d++)a[b][d].set=a[0][d].data}},cancel:{available:function(){return!1},option:function(b){return b.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}};m.version="2.3.4";m.defaults={alwaysAsk:!1,focus:null,columns:"",enable:!0,update:null,editor:null,vertical:!0,horizontal:!0};m.classes={btn:"btn"};var t=a.fn.dataTable.Api;t.register("autoFill()",function(){return this});t.register("autoFill().enabled()",function(){var b=this.context[0];return b.autoFill?b.autoFill.enabled():
|
---|
43 | !1});t.register("autoFill().enable()",function(b){return this.iterator("table",function(a){a.autoFill&&a.autoFill.enable(b)})});t.register("autoFill().disable()",function(){return this.iterator("table",function(a){a.autoFill&&a.autoFill.disable()})});a(e).on("preInit.dt.autofill",function(b,d,c){"dt"===b.namespace&&(b=d.oInit.autoFill,c=k.defaults.autoFill,b||c)&&(c=a.extend({},b,c),!1!==b&&new m(d,c))});k.AutoFill=m;return k.AutoFill=m});
|
---|