$.widget("ui.tabulator",{data:[],firstRender:!0,mouseDrag:!1,mouseDragWidth:!1,mouseDragElement:!1,mouseDragOut:!1,sortCurCol:null,sortCurDir:null,filterField:null,filterValue:null,filterType:null,options:{backgroundColor:"#888",borderColor:"#999",textSize:"14px",headerBackgroundColor:"#e6e6e6",headerTextColor:"#555",headerBorderColor:"#aaa",headerSeperatorColor:"#999",headerMargin:"4px",rowBackgroundColor:"#fff",rowBorderColor:"#aaa",rowTextColor:"#333",rowHoverBackground:"#bbb",colMinWidth:"40px",colResizable:!0,height:!1,fitColumns:!1,columns:[],sortable:!0,dateFormat:"dd/mm/yyyy",sortArrows:{active:"#666",inactive:"#bbb"},sortBy:"id",sortDir:"desc",groupBy:!1,groupHeader:function(t,e,o){return t+"("+e+" item)"},editBoxColor:"#1D68CD",rowFormatter:!1,addRowPos:"bottom",selectable:!0,ajaxURL:!1,showLoader:!0,loader:"
Loading Data
",loaderError:"Loading Error
",rowClick:function(){},rowAdded:function(){},rowEdit:function(){},rowDelete:function(){},rowContext:function(){},dataLoaded:function(){}},loaderDiv:$(""),_showLoader:function(t,e){t.options.showLoader&&($(".tabulator-loader-msg",t.loaderDiv).empty().append(e),$(".tabulator-loader-msg",t.loaderDiv).css({"margin-top":t.element.innerHeight()/2-$(".tabulator-loader-msg",t.loaderDiv).outerHeight()/2}),t.element.append(t.loaderDiv))},_hideLoader:function(t){$(".tablulator-loader",t.element).remove()},_create:function(){var t=this,e=t.options,o=t.element;e.textSize=isNaN(e.textSize)?e.textSize:e.textSize+"px",e.colMinWidth=isNaN(e.colMinWidth)?e.colMinWidth:e.colMinWidth+"px",e.textSizeNum=parseInt(e.textSize.replace("px","")),headerMargin=parseInt(e.headerMargin.replace("px","")),e.headerHeight=e.textSizeNum+2*headerMargin+2,e.height&&(e.height=isNaN(e.height)?e.height:e.height+"px",o.css({height:e.height})),o.addClass("tabulator"),o.css({position:"relative","box-sizing":"border-box","background-color":e.backgroundColor,border:"1px solid "+e.borderColor,overflow:"hidden"}),t.header=$(""),t.header.css({position:"relative","background-color":e.headerBackgroundColor,"border-bottom":"1px solid "+e.headerSeperatorColor,color:e.headerTextColor,"font-size":e.textSize,"font-weight":"bold","white-space":"nowrap","z-index":"1",overflow:"visible"}),t.tableHolder=$(""),t.tableHolder.css({position:"absolute","z-index":"1","min-height":"calc(100% - "+(e.headerHeight+1)+"px)","max-height":"calc(100% - "+(e.headerHeight+1)+"px)","white-space":"nowrap",overflow:"auto",width:"100%"}),t.tableHolder.scroll(function(){t.header.css({"margin-left":"-1"*$(this).scrollLeft()})}),t.table=$(""),t.table.css({position:"relative","font-size":e.textSize,"white-space":"nowrap","z-index":"1",display:"inline-block",overflow:"visible"});var r=$("");if(r.css({display:"inline-block",position:"absolute",top:"9px",right:"8px",width:0,height:0,"border-left":"6px solid transparent","border-right":"6px solid transparent","border-bottom":"6px solid "+e.sortArrows.inactive}),$.each(e.columns,function(o,r){if(r.index=o,r.sorter="undefined"==typeof r.sorter?"string":r.sorter,r.sortable="undefined"==typeof r.sortable?e.sortable:r.sortable,r.sortable="undefined"!=typeof r.field&&r.sortable,e.sortBy==r.field){var a=" data-sortdir='"+e.sortDir+"' ";t.sortCurCol=r,t.sortCurDir=e.sortDir}else var a="";var i=r.title?r.title:" ",n=$('");a.on("mousedown",function(e){t.mouseDrag=e.screenX,t.mouseDragWidth=$(this).closest(".tabulator-col").outerWidth(),t.mouseDragElement=$(this).closest(".tabulator-col")}),t.element.on("mousemove",function(e){t.mouseDrag&&(t.mouseDragElement.css({width:t.mouseDragWidth+(e.screenX-t.mouseDrag)}),t._resizeCol(t.mouseDragElement.data("index"),t.mouseDragElement.outerWidth()))}),t.element.on("mouseup",function(e){t.mouseDrag&&(e.stopPropagation(),e.stopImmediatePropagation(),t.mouseDragOut=!0,t._resizeCol(t.mouseDragElement.data("index"),t.mouseDragElement.outerWidth()),t.mouseDrag=!1,t.mouseDragWidth=!1,t.mouseDragElement=!1)}),a.on("mouseover",function(){$(this).css({cursor:"ew-resize"})}),$(".tabulator-col",t.header).append(a),$(".tabulator-col",t.header).on("mouseup",function(){})}o.on("editval",".tabulator-cell",function(e,o){$(this).is(":focus")&&$(this).blur(),t._cellDataChange($(this),o)}),o.on("editcancel",".tabulator-cell",function(e,o){t._cellDataChange($(this),$(this).data("value"))}),$(".tabulator-col[data-sortable=true]",t.header).css({"padding-right":"25px"}).data("sortdir","desc").on("mouseover",function(){$(this).css({cursor:"pointer","background-color":"rgba(0,0,0,.1)"})}).on("mouseout",function(){$(this).css({"background-color":"transparent"})}).append(r.clone()),t._colRender()},_setOption:function(t,e){$.Widget.prototype._setOption.apply(this,arguments)},_cellDataChange:function(t,e){var o=this,r=t.closest(".tabulator-row");t.data("value",e);var a=r.data("data");a[t.data("field")]=e,r.data("data",a),a.id&&(o.data[a.id]=a),t.html(o._formatCell(t.data("formatter"),e,a,t,r,t.data("formatterParams"))).css({padding:"4px"}),o.options.rowEdit(a.id,a,r),o._styleRows()},deleteRow:function(t){var e=this,o="number"==typeof t?t:t.data("data").id;e.data[o]&&e.data.splice(o,1),o?$("[data-id="+o+"]",e.element).remove():t.remove(),e._styleRows(),e._colRender(!e.firstRender),e._trigger("renderComplete"),e.options.rowDelete(o)},addRow:function(t){var e=this;t?t.id=t.id?t.id:0:t={id:0};var o=e._renderRow(t);"top"==e.options.addRowPos?e.table.prepend(o):e.table.append(o),e._styleRows(),e._colRender(!e.firstRender),e._trigger("renderComplete"),e.options.rowAdded(t)},getData:function(){var t=this,e=[];return t.data.forEach(function(t,o){e.push(t)}),$("[data-id=0]",t.element).each(function(){e.push($(this).data("data"))}),e},setData:function(t){this._trigger("dataLoading"),this._showLoader(this,this.options.loader),"string"==typeof t?0==t.indexOf("{")||0==t.indexOf("[")?this._parseData(jQuery.parseJSON(t)):this._getAjaxData(t):t?this._parseData(t):this.options.ajaxURL?this._getAjaxData(this.options.ajaxURL):this._parseData([])},clear:function(){this.table.empty(),this.data=[],this._renderTable()},setFilter:function(t,e,o){var r=this;r._trigger("filterStarted"),t?(r.filterField=t,r.filterType="undefined"==typeof o?"=":e,r.filterValue="undefined"==typeof o?e:o):(r.filterField=null,r.filterType=null,r.filterValue=null),this._renderTable()},clearFilter:function(){var t=this;t.filterField=null,t.filterType=null,t.filterValue=null,this._renderTable()},getFilter:function(){var t=this;if(t.filterField){var e={field:t.filterField,type:t.filterType,value:t.filterValue};return e}return!1},_parseData:function(t){var e=[];$.each(t,function(t,o){e[o.id]=o}),this.data=e,this.options.dataLoaded(t),this._renderTable()},_getAjaxData:function(t){var e=this;e.options;$.ajax({url:t,type:"GET",async:!0,dataType:"json",success:function(t){e._parseData(t)},error:function(t,o,r){console.log("Tablulator ERROR (ajax get): "+t.status+" - "+r),e._trigger("dataLoadError",t,r),e._showLoader(e,e.options.loaderError)}})},_renderTable:function(){var t=this,e=t.options;this._trigger("renderStarted"),t.table.hide(),t._showLoader(t,t.options.loader),t.table.empty(),t.data.forEach(function(o,r){if(!t.filterField||t.filterField&&t._filterRow(o)){var a=t._renderRow(o);if(e.groupBy){var i="function"==typeof e.groupBy?e.groupBy(o):o[e.groupBy],n=$(".tabulator-group[data-value='"+i+"']",t.table);0==n.length&&(n=t._renderGroup(i),t.table.append(n)),$(".tabulator-group-body",n).append(a)}else t.table.append(a)}}),e.groupBy&&($(".tabulator-group",t.table).each(function(){t._renderGroupHeader($(this))}),t._sortElement(t.table,{},"asc",!0)),t.table.css({"background-color":t.options.rowBackgroundColor,color:t.options.rowTextColor}),t._styleRows(),t.sortCurCol&&t._sorter(t.sortCurCol,t.sortCurDir),t.table.show(),t._colRender(!t.firstRender),t._hideLoader(t),t._trigger("renderComplete"),t.filterField&&t._trigger("filterComplete")},_renderGroup:function(t){var e=$("");return e},_renderGroupHeader:function(t){var e=this,o=$("");o.css({display:"inline-block","vertical-align":"middle",width:0,height:0,"margin-right":"10px","margin-left":"5px","border-left":"6px solid transparent","border-right":"6px solid transparent","border-top":"6px solid "+e.options.sortArrows.active}).data("show",!0).on("mouseover",function(){$(this).css({cursor:"pointer","background-color":"rgba(0,0,0,.1)"})}).on("mouseout",function(){$(this).css({"background-color":"transparent"})}).on("click",function(){$(this).data("show")?($(this).data("show",!1),$(this).closest(".tabulator-group").find(".tabulator-group-body").slideUp(),$(this).css({"margin-left":"8px","margin-right":"13px","border-top":"6px solid transparent","border-bottom":"6px solid transparent","border-right":"0","border-left":"6px solid "+e.options.sortArrows.active})):($(this).data("show",!0),$(this).closest(".tabulator-group").find(".tabulator-group-body").slideDown(),$(this).css({"margin-left":"5px","margin-right":"10px","border-left":"6px solid transparent","border-right":"6px solid transparent","border-top":"6px solid "+e.options.sortArrows.active,"border-bottom":"0"}))});var r=[];$(".tabulator-row",t).each(function(){r.push($(this).data("data"))}),$(".tabulator-group-header",t).css({background:"#ccc","font-weight":"bold",padding:"5px","border-bottom":"1px solid #999","border-top":"1px solid #999","box-sizing":"border-box"}).html(o).append(e.options.groupHeader(t.data("value"),$(".tabulator-row",t).length,r))},_filterRow:function(t){var e=this;if(!e.filterField)return!0;var o=t[e.filterField],r=e.filterValue;switch(e.filterType){case"=":return o==r;case"<":return o":return o>r;case">=":return o>=r;case"!=":return o!=r;case"like":return o.toLowerCase().indexOf(r.toLowerCase())>-1;default:return!1}return!1},_renderRow:function(t){var e=this,o=$('');return o.data("data",t),o.on("click",function(r){e._rowClick(r,o,t)}),o.on("contextmenu",function(r){e._rowContext(r,o,t)}),$.each(e.options.columns,function(r,a){var i="undefined"==typeof t[a.field]?"":t[a.field];"undefined"==typeof t[a.field]&&(t[a.field]="");var n="undefined"==typeof a.align?"left":a.align,l=a.editable||a.editor?"tabindex='0'":"",s=$("");s.css({"text-align":n,"box-sizing":"border-box",display:"inline-block","vertical-align":"middle","min-height":e.options.headerHeight+2,"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis",padding:"4px"});var d=!1;(a.editable||a.editor)&&(d=a.editor?a.editor:e.editors[a.formatter]?a.formatter:"input"),s.data("editor",d),s.data("formatter",a.formatter),s.data("formatterParams",a.formatterParams),s.html(e._formatCell(a.formatter,i,t,s,o,a.formatterParams)),"function"==typeof a.onClick?s.on("click",function(t){e._cellClick(t,s)}):s.data("editor")&&s.on("focus",function(t){t.stopPropagation(),s.css({padding:"0",border:"1px solid "+e.options.editBoxColor});var o="string"==typeof s.data("editor")?e.editors[s.data("editor")]:s.data("editor"),r=o(s,s.data("value"));s.empty(),s.append(r),s.children().click(function(t){t.stopPropagation()})}),o.append(s)}),o},dataCount:function(){return this.data.length},redraw:function(){var t=this;t.options.fitColumns&&t._colRender(),t.element.innerHeight()>0&&$(".tabulator-loader-msg",t.loaderDiv).css({"margin-top":t.element.innerHeight()/2-$(".tabulator-loader-msg",t.loaderDiv).outerHeight()/2})},_resizeCol:function(t,e){$(".tabulator-cell[data-index="+t+"], .tabulator-col[data-index="+t+"]",this.element).css({width:e})},_colRender:function(t){var e=this,o=e.options,r=(e.table,e.header,e.element);if(e.firstRender=!1,t&&!o.fitColumns)$.each(o.columns,function(t,e){n=$(".tabulator-col[data-index="+t+"]",r).outerWidth();var o=$(".tabulator-cell[data-index="+t+"]",r);o.css({width:n})});else if(o.fitColumns){e.options.fitColumns&&$(".tabulator-row",e.table).css({width:"100%"});var a=e.element.innerWidth(),i=o.columns.length,n=a/i,l=0,s=0;$.each(o.columns,function(t,e){if(e.width){var o="string"==typeof e.width?parseInt(e.width):e.width;l+=o,s++}});var d=Math.floor((a-l)/(i-s));if(d>=parseInt(o.colMinWidth))$.each(o.columns,function(t,e){var o=e.width?e.width:d,a=$(".tabulator-cell[data-index="+t+"], .tabulator-col[data-index="+t+"]",r);a.css({width:o})});else{var c=$(".tabulator-cell, .tabulator-col",r);c.css({width:n})}}else $.each(o.columns,function(t,e){var a=$(".tabulator-cell[data-index="+t+"], .tabulator-col[data-index="+t+"]",r);if(e.width)i=e.width;else{var i=0;a.each(function(){i=$(this).outerWidth()>i?$(this).outerWidth():i}),o.colMinWidth&&(i=ir?1:-1;for(o=o.match(s),r=r.match(s),n=o.length>r.length?r.length:o.length;li?1:-1;return o.length>r.length}},formatters:{plaintext:function(t,e,o,r,a,i){return t},money:function(t,e,o,r,a,i){for(var n=parseFloat(t).toFixed(2),n=n.split("."),l=n[0],s=n.length>1?"."+n[1]:"",d=/(\d+)(\d{3})/;d.test(l);)l=l.replace(d,"$1,$2");return l+s},email:function(t,e,o,r,a,i){return""+t+""},link:function(t,e,o,r,a,i){return""+t+""},tick:function(t,e,o,r,a,i){var n='';return t===!0||"true"===t||"True"===t||1===t?n:""},tickCross:function(t,e,o,r,a,i){var n='',l='';return t===!0||"true"===t||"True"===t||1===t?n:l},star:function(t,e,o,r,a,n){var l=n&&n.stars?n.stars:5,s=$("");t=parseInt(t)'),c=$('');for(i=1;i<=l;i++){var u=i<=t?d:c;s.append(u.clone())}return o.css({"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"}),s.html()},progress:function(t,e,o,r,a,i){var n=i&&i.max?i.max:100,l=i&&i.min?i.min:0,s=i&&i.color?i.color:"#2DC214";t=parseFloat(t)<=n?parseFloat(t):n,t=parseFloat(t)>=l?parseFloat(t):l;var d=(n-l)/100;return t=Math.round((t-l)/d),o.css({"min-width":"30px"}),""}},editors:{input:function(t,e){var o=$("");return o.css({border:"1px",background:"transparent",padding:"4px",width:"100%","box-sizing":"border-box"}).val(e),setTimeout(function(){o.focus()},100),o.on("change blur",function(e){t.trigger("editval",o.val())}),o.on("keydown",function(e){13==e.keyCode&&t.trigger("editval",o.val())}),o},star:function(t,e){var o=$("svg",t).length,r=$("svg:first",t).attr("width"),a=$("");e=parseInt(e)'),l=$('');for(i=1;i<=o;i++){var s=i<=e?n:l;a.append(s.clone())}var d=function(t){$(".tabulator-star-active",t.closest("div")).length!=t.prevAll("svg").length+1&&(t.prevAll("svg").replaceWith(n.clone()),t.nextAll("svg").replaceWith(l.clone()),t.replaceWith(n.clone()))};return a.on("mouseover","svg",function(t){t.stopPropagation(),d($(this))}),a.on("mouseover",function(t){$("svg",$(this)).replaceWith(l.clone())}),a.on("click",function(t){$(this).closest(".tabulator-cell").trigger("editval",0)}),a.on("click","svg",function(e){var o=$(this).prevAll("svg").length+1;t.trigger("editval",o)}),t.css({"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"}),t.on("blur",function(){$(this).trigger("editcancel")}),t.on("keydown",function(e){switch(e.keyCode){case 39:d($(".tabulator-star-inactive:first",a));break;case 37:var o=$(".tabulator-star-active:last",a).prev("svg");o.length?d(o):$("svg",a).replaceWith(l.clone());break;case 13:t.trigger("editval",$(".tabulator-star-active",a).length)}}),a},progress:function(t,e){var o=$("div",t).data("max"),r=$("div",t).data("min");e=parseFloat(e)<=o?parseFloat(e):o,e=parseFloat(e)>=r?parseFloat(e):r;var a=(o-r)/100;e=Math.round((e-r)/a),t.css({padding:"0 4px"});var i=function(){var e=a*Math.round(n.outerWidth()/(t.width()/100))+r;t.trigger("editval",e)},n=$(""),l=$("");return n.append(l),l.on("mousedown",function(t){n.data("mouseDrag",t.screenX),n.data("mouseDragWidth",n.outerWidth())}),l.on("mouseover",function(){$(this).css({cursor:"ew-resize"})}),t.on("mousemove",function(t){n.data("mouseDrag")&&n.css({width:n.data("mouseDragWidth")+(t.screenX-n.data("mouseDrag"))})}),t.on("mouseup",function(t){n.data("mouseDrag")&&(t.stopPropagation(),t.stopImmediatePropagation(),n.data("mouseDragOut",!0),n.data("mouseDrag",!1),n.data("mouseDragWidth",!1),i())}),t.on("keydown",function(e){switch(e.keyCode){case 39:n.css({width:n.width()+t.width()/100});break;case 37:n.css({width:n.width()-t.width()/100});break;case 13:i()}}),t.on("blur",function(){$(this).trigger("editcancel")}),n},tickCross:function(t,e){var o=$("");return o.css({border:"1px",background:"transparent","margin-top":"5px","box-sizing":"border-box"}).val(e),setTimeout(function(){o.focus()},100),e===!0||"true"===e||"True"===e||1===e?o.prop("checked",!0):o.prop("checked",!1),o.on("change blur",function(e){t.trigger("editval",o.is(":checked"))}),o.on("keydown",function(e){13==e.keyCode&&t.trigger("editval",o.is(":checked"))}),o},tick:function(t,e){var o=$("");return o.css({border:"1px",background:"transparent","margin-top":"5px","box-sizing":"border-box"}).val(e),setTimeout(function(){o.focus()},100),e===!0||"true"===e||"True"===e||1===e?o.prop("checked",!0):o.prop("checked",!1),o.on("change blur",function(e){t.trigger("editval",o.is(":checked"))}),o.on("keydown",function(e){13==e.keyCode&&t.trigger("editval",o.is(":checked"))}),o}},destroy:function(){}});
//# sourceMappingURL=tabulator.min.js.map