This repository has been archived by the owner on May 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathtrNgGrid.min.js
1 lines (1 loc) · 27.5 KB
/
trNgGrid.min.js
1
!function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define(["require","exports","angular"],e)}(function(e,t){"use strict";var i,r=e("angular");!function(e){function t(e,t,i,r){var n=t.startSymbol(),l=t.endSymbol();e.get(i)||("{{"!==n&&(r=r.replace(/\{\{/g,n+" ")),"}}"!==l&&(r=r.replace(/\}\}/g," "+l)),e.put(i,r))}function i(i,r){t(i,r,e.cellHeaderTemplateId,'<div class="'+e.headerCellCssClass+'" ng-switch="isCustomized"> <div ng-switch-when="true"> <div ng-transclude=""></div> </div> <div ng-switch-default> <div class="'+e.columnTitleCssClass+'"> {{columnTitle |'+e.translateFilter+":gridOptions.locale}} <div "+e.columnSortDirectiveAttribute+'=""></div> </div> <div '+e.columnFilterDirectiveAttribute+'=""></div> </div></div>'),t(i,r,e.cellBodyTemplateId,'<div ng-attr-class="'+e.bodyCellCssClass+' text-{{columnOptions.displayAlign}}" ng-switch="isCustomized"> <div ng-switch-when="true"> <div ng-transclude=""></div> </div> <div ng-switch-default>{{gridDisplayItem[columnOptions.displayFieldName]}}</div></div>'),t(i,r,e.columnFilterTemplateId,'<div ng-show="(gridOptions.enableFiltering&&columnOptions.enableFiltering!==false)||columnOptions.enableFiltering" class="'+e.columnFilterCssClass+'"> <div class="'+e.columnFilterInputWrapperCssClass+'"> <input class="form-control input-sm" type="text" ng-model="columnOptions.filter" ng-keypress="speedUpAsyncDataRetrieval($event)"></input> </div></div>'),t(i,r,e.columnSortTemplateId,"<div ng-attr-title=\"{{'Sort'|"+e.translateFilter+':gridOptions.locale}}" ng-show="(gridOptions.enableSorting&&columnOptions.enableSorting!==false)||columnOptions.enableSorting" ng-click="toggleSorting(columnOptions.fieldName)" class="'+e.columnSortCssClass+'" > <div ng-class="{\''+e.columnSortActiveCssClass+"':gridOptions.orderBy==columnOptions.fieldName,'"+e.columnSortInactiveCssClass+"':gridOptions.orderBy!=columnOptions.fieldName,'"+e.columnSortNormalOrderCssClass+"':gridOptions.orderBy==columnOptions.fieldName&&!gridOptions.orderByReverse,'"+e.columnSortReverseOrderCssClass+"':gridOptions.orderBy==columnOptions.fieldName&&gridOptions.orderByReverse}\" > </div></div>"),t(i,r,e.cellFooterTemplateId,'<div class="'+e.footerCssClass+'" ng-switch="isCustomized"> <div ng-switch-when="true"> <div ng-transclude=""></div> </div> <div ng-switch-default> <span '+e.globalFilterDirectiveAttribute+'=""></span> <span '+e.pagerDirectiveAttribute+'=""></span> </div></div>'),t(i,r,e.footerGlobalFilterTemplateId,'<span ng-show="gridOptions.enableFiltering" class="pull-left form-group"> <input class="form-control" type="text" ng-model="gridOptions.filterBy" ng-keypress="speedUpAsyncDataRetrieval($event)" ng-attr-placeholder="{{\'Search\'|'+e.translateFilter+':gridOptions.locale}}"></input></span>'),t(i,r,e.footerPagerTemplateId,'<span class="pull-right form-group"> <ul class="pagination"> <li ng-class="{disabled:!pageCanGoBack}" ng-if="extendedControlsActive"> <a href="" ng-click="pageCanGoBack&&navigateToPage(0)" ng-attr-title="{{\'First Page\'|'+e.translateFilter+':gridOptions.locale}}"> <span>«</span> </a> </li> <li ng-class="{disabled:!pageCanGoBack}" ng-if="extendedControlsActive"> <a href="" ng-click="pageCanGoBack&&navigateToPage(gridOptions.currentPage - 1)" ng-attr-title="{{\'Previous Page\'|'+e.translateFilter+':gridOptions.locale}}"> <span>‹</span> </a> </li> <li ng-if="pageSelectionActive" ng-repeat="pageIndex in pageIndexes track by $index" ng-class="{disabled:pageIndex===null, active:pageIndex===gridOptions.currentPage}"> <span ng-if="pageIndex===null">...</span> <a href="" ng-click="navigateToPage(pageIndex)" ng-if="pageIndex!==null" ng-attr-title="{{\'Page\'|'+e.translateFilter+':gridOptions.locale}}">{{pageIndex+1}}</a> </li> <li ng-class="{disabled:!pageCanGoForward}" ng-if="extendedControlsActive"> <a href="" ng-click="pageCanGoForward&&navigateToPage(gridOptions.currentPage + 1)" ng-attr-title="{{\'Next Page\'|'+e.translateFilter+':gridOptions.locale}}"> <span>›</span> </a> </li> <li ng-class="{disabled:!pageCanGoForward}" ng-if="extendedControlsActive"> <a href="" ng-click="pageCanGoForward&&navigateToPage(lastPageIndex)" ng-attr-title="{{\'Last Page\'|'+e.translateFilter+':gridOptions.locale}}"> <span>»</span> </a> </li> <li class="disabled" style="white-space: nowrap;"> <span ng-hide="totalItemsCount">{{\'No items to display\'|'+e.translateFilter+":gridOptions.locale}}</span> <span ng-show=\"totalItemsCount\"> {{startItemIndex+1}} - {{endItemIndex+1}} {{'displayed'|"+e.translateFilter+":gridOptions.locale}} <span>, {{totalItemsCount}} {{'in total'|"+e.translateFilter+":gridOptions.locale}}</span> </span > </li> </ul></span>")}!function(e){e[e.None=0]="None",e[e.SingleRow=1]="SingleRow",e[e.MultiRow=2]="MultiRow",e[e.MultiRowWithKeyModifiers=3]="MultiRowWithKeyModifiers"}(e.SelectionMode||(e.SelectionMode={}));var n=e.SelectionMode;if(!window)throw"trNgGrid cannot be used in the current environment";window.TrNgGrid=e,e.defaultColumnOptionsTemplate={cellWidth:null,cellHeight:null,displayAlign:null,displayFormat:null,displayName:null,filter:null,enableFiltering:null,enableSorting:null},e.defaultColumnOptions={},e.translations={},e.debugMode=!1;var l=!1,s="trNgGrid";e.sortFilter=s+"SortFilter",e.dataPagingFilter=s+"DataPagingFilter",e.translateFilter=s+"TranslateFilter",e.translationDateFormat=s+"DateFormat",e.dataFormattingFilter=s+"DataFormatFilter";var o="trNgGridBody",a="tr-ng-grid-body",d="field-name",c="data-field-name",g="is-customized",p="trNgGridFooterCell",u="tr-ng-grid-footer-cell",m="trNgGridFooterCellTemplate",f="tr-ng-grid-footer-cell-template";e.cellFooterTemplateId=m+".html";var h="trNgGridGlobalFilter";e.globalFilterDirectiveAttribute="tr-ng-grid-global-filter",e.footerGlobalFilterTemplateId=h+".html";var v="trNgGridPager";e.pagerDirectiveAttribute="tr-ng-grid-pager",e.footerPagerTemplateId=v+".html";var I="trNgGridHeaderCell",y="tr-ng-grid-header-cell",O="trNgGridHeaderCellTemplate",C="tr-ng-grid-header-cell-template";e.cellHeaderTemplateId=O+".html";var F="trNgGridBodyCell",D="tr-ng-grid-body-cell",S="trNgGridBodyCellTemplate",b="tr-ng-grid-body-cell-template";e.cellBodyTemplateId=S+".html";var w="trNgGridColumnSort";e.columnSortDirectiveAttribute="tr-ng-grid-column-sort",e.columnSortTemplateId=w+".html";var x="trNgGridColumnFilter";e.columnFilterDirectiveAttribute="tr-ng-grid-column-filter",e.columnFilterTemplateId=x+".html";var T=function(e,t){t=t.toUpperCase();for(var i=e.children(),n=0;n<i.length;n++){var l=i[n];if(l.tagName==t)return r.element(l)}return null},P=function(e,t,i,n){var l=[],s=t.slice(0);return r.forEach(e,function(e){for(var t=null,i=0;!t&&i<s.length;i++)t=s[i],t.fieldName===e.fieldName?s.splice(i,1):t=null;t?l.push(t):l.push(e)}),(i||n)&&r.forEach(s,function(e){(i&&e.fieldName||n&&!e.fieldName)&&l.push(e)}),l},N=function(e,t,i,n){if(i){var l=e.children(),s=r.element(l[0]);if(1!==l.length||!s.attr(n)){e.empty();var o=r.element("<div></div>").attr(n,"");e.append(o),r.forEach(l,function(e){o.append(r.element(e))})}}else e.empty(),e.append(r.element("<div></div>").attr(n,""))},$=function(){function e(e,t){this.parent=e,this.cellElement=t,this.fieldName=t.attr(d)||t.attr(c);var i=t.children();this.isStandardColumn=0===i.length}return e}(),A=function(){function e(e,t,i,r,n){this.sectionTagName=e,this.sectionDirectiveAttribute=t,this.rowDirectiveAttribute=i,this.cellTagName=r,this.cellDirectiveAttribute=n,this.cellTagName=this.cellTagName.toUpperCase(),this.cells=null}return e.prototype.configureSection=function(e,t){var i=this,n=this.getSectionElement(e,!0);n.empty(),n.removeAttr("ng-non-bindable");var l=P(t,this.cells,!1,!1),s=this.getTemplatedRowElement(n,!0);return r.forEach(l,function(e,t){var n,l=e;n=l.parent===i&&l.cellElement?l.cellElement.clone(!0):r.element("<table><"+i.cellTagName+"></"+i.cellTagName+"></table>").find(i.cellTagName),i.cellDirectiveAttribute&&n.attr(i.cellDirectiveAttribute,t),e.isStandardColumn||n.attr(g,"true"),e.fieldName&&n.attr(d,e.fieldName),n.attr("ng-style","{'width':columnOptions.cellWidth,'height':columnOptions.cellHeight}"),s.append(n)}),n},e.prototype.extractPartialColumnDefinitions=function(){return this.cells},e.prototype.discoverTemplates=function(e){var t=this;this.cells=[],this.cellRow=null;var i=this.getTemplatedRowElement(this.getSectionElement(e,!1),!1);i&&(this.cellRow=r.element(i.clone()),this.cellRow.empty(),r.forEach(i.children(),function(e,i){if(e=r.element(e),e[0].tagName===t.cellTagName.toUpperCase()){var n=e.clone();t.cells.push(new $(t,n))}}))},e.prototype.getSectionElement=function(e,t){var i=null;return e&&(i=T(e,this.sectionTagName)),!i&&t&&(i=r.element("<table><"+this.sectionTagName+"></"+this.sectionTagName+"></table>").find(this.sectionTagName),e&&e.append(i)),i&&t&&this.sectionDirectiveAttribute&&i.attr(this.sectionDirectiveAttribute,""),i},e.prototype.getTemplatedRowElement=function(e,t){var i=null;return e&&(i=T(e,"tr")),!i&&t&&(i=this.cellRow?r.element(this.cellRow.clone()):r.element("<table><tr></tr></table>").find("tr"),e&&e.append(i)),i&&t&&this.rowDirectiveAttribute&&i.attr(this.rowDirectiveAttribute,""),i},e}(),B=function(){function t(e,t,r,n,s){this.$compile=e,this.$parse=t,this.$timeout=r,l||(i(n,s),l=!0)}return t.prototype.setupGrid=function(t,i,r){return this.gridOptions=i,this.isInServerSideMode=r,t.gridOptions=i,t.TrNgGrid=e,i.gridColumnDefs=[],void 0===i.locale&&(i.locale="en"),void 0===i.selectionMode&&(i.selectionMode=n[n.MultiRow]),void 0===i.filterByFields&&(i.filterByFields={}),void 0===i.enableFiltering&&(i.enableFiltering=!0),void 0===i.enableSorting&&(i.enableSorting=!0),void 0===i.onDataRequiredDelay&&(i.onDataRequiredDelay=1e3),void 0===i.selectedItems&&(i.selectedItems=[]),void 0===i.currentPage&&(i.currentPage=0),this.setupServerSideModeTriggers(t),this.setupDataFilteringTriggers(t),this.setupDataFormattingTriggers(t),this.setupDataSelectionTriggers(t),t},t.prototype.setupDataFilteringTriggers=function(e){var t=this,i=!1;if(this.scheduleDataFiltering=function(){i||(e.$evalAsync(function(){i=!1,t.computeFilteredItems(e)}),i=!0)},!this.isInServerSideMode){var r=!0;e.$watchCollection("[gridOptions.filterBy,gridOptions.filterByFields,gridOptions.orderBy,gridOptions.orderByReverse,gridOptions.pageItems]",function(e,i){r?r=!1:(t.gridOptions.currentPage=0,t.scheduleDataFiltering())}),e.$watch("gridOptions.currentPage",function(e,i){e!==i&&t.scheduleDataFiltering()})}},t.prototype.setupDataFormattingTriggers=function(t){var i=this,n=!1;this.scheduleDataFormatting=function(){n||(t.$evalAsync(function(){n=!1,i.computeFormattedItems(t)}),n=!0)};var l="[gridOptions.items,gridOptions.gridColumnDefs.length";r.forEach(t.gridOptions.gridColumnDefs,function(e){if(e.displayFormat&&"."!=e.displayFormat[0]){var t=e.displayFormat.split("|");r.forEach(t,function(e){var t=e.split(":");t.length>1&&r.forEach(t.slice(1),function(e){e=e.trim(),e&&"gridItem"!==e&&"gridDisplayItem"!==e&&(l+=","+e)})})}}),l+="]",e.debugMode&&this.log("re-formatting is set to watch for changes in "+l),t.$watch(l,function(){return i.scheduleDataFormatting()},!0)},t.prototype.setupServerSideModeTriggers=function(t){var i=this;if(this.isInServerSideMode){var r=null,n=!1,l=!1,s=!1,o=function(){r&&(i.$timeout.cancel(r),r=null)},a=function(){e.debugMode&&i.log("Preparing to request data - server side mode"),o();var r=function(){t.$applyAsync(function(){n=!1;try{e.debugMode&&i.log("Requesting data - server side mode"),i.gridOptions.onDataRequired(i.gridOptions)}catch(t){throw e.debugMode&&i.log("Data retrieval failed "+t),t}})};s?t.$evalAsync(function(){e.debugMode&&i.log("Resetting the page index - server side mode"),t.gridOptions.currentPage=0,s=!1,r()}):r()};this.scheduleServerSideModeDataRetrieval=function(){n||(o(),r=i.$timeout(function(){r=null,n=!0,a()},i.gridOptions.onDataRequiredDelay,!0),l&&i.speedUpServerSideModeDataRetrieval())},this.speedUpServerSideModeDataRetrieval=function(e){e&&13!=e.keyCode||(r?(l=!1,o(),n=!0,a()):l=!0)},t.$watch("gridOptions.currentPage",function(t,r){t!==r&&(e.debugMode&&i.log("Changes detected in the current page index in server-side mode. Scheduling data retrieval..."),i.scheduleServerSideModeDataRetrieval())});var d=!0;t.$watchCollection("[gridOptions.filterBy, gridOptions.filterByFields, gridOptions.orderBy, gridOptions.orderByReverse, gridOptions.pageItems]",function(t,r){d?d=!1:(0!==i.gridOptions.currentPage&&(e.debugMode&&i.log("Changes detected in parameters in server-side mode. Requesting a page index reset..."),s=!0),e.debugMode&&i.log("Changes detected in parameters in server-side mode. Scheduling data retrieval..."),i.scheduleServerSideModeDataRetrieval())}),this.scheduleServerSideModeDataRetrieval(),this.speedUpServerSideModeDataRetrieval()}else this.speedUpServerSideModeDataRetrieval=function(e){};t.speedUpAsyncDataRetrieval=function(e){return i.speedUpServerSideModeDataRetrieval(e)}},t.prototype.setupDataSelectionTriggers=function(e){var t=this;e.$watch("gridOptions.selectionMode",function(e,i){if(e!==i)switch(e){case n[n.None]:t.gridOptions.selectedItems.splice(0);break;case n[n.SingleRow]:t.gridOptions.selectedItems.length>1&&t.gridOptions.selectedItems.splice(1)}})},t.prototype.setColumnOptions=function(e,t){var i=this.gridOptions.gridColumnDefs[e];if(!i)throw"Invalid grid column options found for column index "+e+". Please report this error.";t=r.extend(t,i),this.gridOptions.gridColumnDefs[e]=t},t.prototype.toggleSorting=function(e){this.gridOptions.orderBy!=e?this.gridOptions.orderBy=e:this.gridOptions.orderByReverse=!this.gridOptions.orderByReverse,this.speedUpServerSideModeDataRetrieval()},t.prototype.toggleItemSelection=function(e,t,i){if(this.gridOptions.selectionMode!==n[n.None])switch(this.gridOptions.selectionMode){case n[n.MultiRowWithKeyModifiers]:if(i.ctrlKey||i.shiftKey||i.metaKey){if(i.ctrlKey||i.metaKey){var r=this.gridOptions.selectedItems.indexOf(t);r>=0?this.gridOptions.selectedItems.splice(r,1):this.gridOptions.selectedItems.push(t)}else if(i.shiftKey){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var l=window.getSelection();l.removeAllRanges()}var s,o=this.gridOptions.selectedItems[this.gridOptions.selectedItems.length-1];for(s=0;s<e.length&&e[s].$$_gridItem!==o;s++);s>=e.length&&(s=0);var a;for(a=0;a<e.length&&e[a].$$_gridItem!==t;a++);if(a>=e.length)throw"Invalid selection on a key modifier selection mode";if(s>a){var d=s;s=a,a=d}for(var c=s;a>=c;c++){var g=e[c].$$_gridItem;this.gridOptions.selectedItems.indexOf(g)<0&&this.gridOptions.selectedItems.push(g)}}}else{var r=this.gridOptions.selectedItems.indexOf(t);this.gridOptions.selectedItems.splice(0),0>r&&this.gridOptions.selectedItems.push(t)}break;case n[n.SingleRow]:var r=this.gridOptions.selectedItems.indexOf(t);this.gridOptions.selectedItems.splice(0),0>r&&this.gridOptions.selectedItems.push(t);break;case n[n.MultiRow]:var r=this.gridOptions.selectedItems.indexOf(t);r>=0?this.gridOptions.selectedItems.splice(r,1):this.gridOptions.selectedItems.push(t)}},t.prototype.discoverTemplates=function(e){this.templatedHeader=new A("thead",null,null,"th",y),this.templatedBody=new A("tbody",a,null,"td",D),this.templatedFooter=new A("tfoot",null,null,"td",u),this.templatedHeader.discoverTemplates(e),this.templatedFooter.discoverTemplates(e),this.templatedBody.discoverTemplates(e)},t.prototype.getSafeFieldName=function(e){return e.replace(/[^a-zA-Z0-9]/g,"_")},t.prototype.configureTableStructure=function(t,i,n){var l=this;try{if(i.empty(),n){var s=n;this.$timeout(function(){s.$destroy()}),n=null}var o=t.$new();this.columnDefsItemsWatcherDeregistration&&(this.columnDefsItemsWatcherDeregistration(),this.columnDefsItemsWatcherDeregistration=null),this.columnDefsFieldsWatcherDeregistration&&(this.columnDefsFieldsWatcherDeregistration(),this.columnDefsFieldsWatcherDeregistration=null),this.columnDefsFieldsWatcherDeregistration=o.$watch("gridOptions.fields",function(e,n){r.equals(e,n)||l.configureTableStructure(t,i,o)},!0);var d=this.templatedHeader.extractPartialColumnDefinitions(),c=this.templatedBody.extractPartialColumnDefinitions(),g=this.templatedFooter.extractPartialColumnDefinitions(),p=[],u=this.gridOptions.fields;if(u)r.forEach(this.gridOptions.fields,function(e){e&&p.push({isStandardColumn:!0,fieldName:e})}),p=P(p,d,!1,!0),p=P(p,c,!1,!0);else if(d.length>0)p=P(d,c,!0,!0);else{if(!this.gridOptions.items||0==this.gridOptions.items.length)return void(this.columnDefsItemsWatcherDeregistration=o.$watch("gridOptions.items.length",function(e,r){e&&l.configureTableStructure(t,i,o)}));for(var m in this.gridOptions.items[0])p.push({isStandardColumn:!0,fieldName:m});p=P(p,c,!0,!0)}0==g.length&&g.push({isStandardColumn:!0}),r.forEach(p,function(e){if(e.fieldName){var t=e.fieldName;e.displayFieldName=l.getSafeFieldName(t);var i;i="["===t[0]?t:t.replace(/^([^\.]+)/g,'["$1"]'),e.fieldExtractionExpression=i}}),this.gridOptions.gridColumnDefs=p;var f=this.templatedHeader.configureSection(i,p),h=this.templatedFooter.configureSection(i,g),v=this.templatedBody.configureSection(i,p),I=this.templatedBody.getTemplatedRowElement(v);this.templatedHeader.getTemplatedRowElement(f);v.attr(a,""),I.attr("ng-click","toggleItemSelection(gridItem, $event)"),I.attr("ng-repeat","gridDisplayItem in filteredItems"),I.attr("ng-init","gridItem=gridDisplayItem.$$_gridItem;"+I.attr("ng-init"));var y=I.attr("ng-class");y=(y||"").replace(/^(\s*\{?)(.*?)(\}?\s*)$/,"{'"+e.rowSelectedCssClass+"':gridOptions.selectedItems.indexOf(gridItem) >= 0, $2}"),I.attr("ng-class",y),this.$compile(f)(o),this.$compile(h)(o),this.$compile(v)(o)}catch(O){throw e.debugMode&&this.log("Fixing table structure failed with error "+O),O}},t.prototype.computeFormattedItems=function(t){var i=t.gridOptions.items||[];e.debugMode&&this.log("formatting items of length "+i.length);try{for(var r=t.formattedItems=t.formattedItems||[],n=t.gridOptions.gridColumnDefs,l=0;l<i.length;l++){for(var s,o=i[l],a={gridItem:o};r.length>i.length&&(s=r[l]).$$_gridItem!==o;)r.splice(l,1);l<r.length?(s=r[l],s.$$_gridItem!==o&&(s={$$_gridItem:o},r[l]=s)):(s={$$_gridItem:o},r.push(s));for(var d=0;d<n.length;d++){var c;try{var g=n[d];if(g.displayFieldName&&g.fieldExtractionExpression){var p=g.displayFormat;p&&"."!==p[0]&&"|"!==p[0]&&"["!==p[0]&&(p=" | "+p),s[g.displayFieldName]=t.$eval("gridItem"+g.fieldExtractionExpression+(p||""),a)}}catch(u){e.debugMode&&this.log("Field evaluation failed for <"+(c||"unknown")+"> with error "+u)}}}r.length>i.length&&r.splice(i.length,r.length-i.length),this.scheduleDataFiltering()}catch(u){throw e.debugMode&&this.log("Failed to format items "+u),u}},t.prototype.extractDataItems=function(e){var t;if(e){t=new Array(e.length);for(var i=0;i<e.length;i++)t[i]=e[i].$$_gridItem}else t=[];return t},t.prototype.computeFilteredItems=function(t){try{if(this.isInServerSideMode)t.filteredItems=t.formattedItems;else{if(t.filterByDisplayFields={},t.gridOptions.filterByFields)for(var i in t.gridOptions.filterByFields)t.filterByDisplayFields[this.getSafeFieldName(i)]=t.gridOptions.filterByFields[i];e.debugMode&&this.log("filtering items of length "+(t.formattedItems?t.formattedItems.length:0)),t.filteredItems=t.$eval("formattedItems | filter:gridOptions.filterBy | filter:filterByDisplayFields | "+e.sortFilter+":gridOptions"),t.gridOptions.filteredItems&&(t.gridOptions.filteredItems=this.extractDataItems(t.filteredItems)),t.filteredItems=t.$eval("filteredItems | "+e.dataPagingFilter+":gridOptions")}t.gridOptions.filteredItemsPage&&(t.gridOptions.filteredItemsPage=this.extractDataItems(t.filteredItems))}catch(r){throw e.debugMode&&this.log("Failed to filter items "+r),r}},t.prototype.linkAttrs=function(e,t){var i=function(e,i){if("undefined"!=typeof i){switch(i){case"true":i=!0;break;case"false":i=!1}t[e]=i}};for(var r in t)i(r,e[r]),function(t){e.$observe(t,function(e){return i(t,e)})}(r)},t.prototype.log=function(e){console.log(s+"("+(new Date).getTime()+"): "+e)},t}();r.module("trNgGrid",[]).directive(s,[function(){return{restrict:"A",scope:{items:"=",selectedItems:"=?",filteredItems:"=?",filteredItemsPage:"=?",filterBy:"=?",filterByFields:"=?",orderBy:"=?",orderByReverse:"=?",pageItems:"=?",currentPage:"=?",totalItems:"=?",enableFiltering:"=?",enableSorting:"=?",selectionMode:"@",locale:"@",onDataRequired:"&",onDataRequiredDelay:"=?",fields:"=?"},controller:["$compile","$parse","$timeout","$templateCache","$interpolate",B],compile:function(t,i){return r.forEach(t.children(),function(e){e=r.element(e),e.attr("ng-non-bindable","")}),{pre:function(e,t,i,r,n){r.discoverTemplates(t)},post:function(t,i,r,n,l){i.addClass(e.tableCssClass);var s=t.$parent.$new();n.setupGrid(s,t,!!r.onDataRequired),n.configureTableStructure(s,i),t.$on("$destroy",function(){s.$destroy(),e.debugMode&&n.log("grid scope destroyed")})}}}}}]).directive(I,[function(){var t=function(e){if(e.columnOptions.displayName)e.columnTitle=e.columnOptions.displayName;else if(e.columnOptions.fieldName){var t=e.columnOptions.fieldName.replace(/^([^\a-zA-Z]*)([\a-zA-Z0-9]*)(.*)/g,"$2"),i=t.split(/(?=[A-Z])/);i.length&&i[0].length&&(i[0]=i[0][0].toLocaleUpperCase()+i[0].substr(1)),e.columnTitle=i.join(" ")}else e.columnTitle=""};return{restrict:"A",require:"^"+s,scope:!0,compile:function(i,n){var l="true"==n.isCustomized;return N(i,n,l,C),{pre:function(i,n,s,o,a){var d=parseInt(s[I]),c=r.extend(i.gridOptions.gridColumnDefs[d],e.defaultColumnOptionsTemplate,e.defaultColumnOptions);o.linkAttrs(s,c),i.columnOptions=c,i.isCustomized=l,i.toggleSorting=function(e){o.toggleSorting(e)},i.$watch("columnOptions.displayName",function(){t(i)});var g=!1;i.$watch("gridOptions.filterByFields['"+c.fieldName+"']",function(e,t){c.filter!==e&&(c.filter=e),g||(i.$watch("columnOptions.filter",function(e,t){i.gridOptions.filterByFields[c.fieldName]!==e&&(e?i.gridOptions.filterByFields[c.fieldName]=e:delete i.gridOptions.filterByFields[c.fieldName],i.gridOptions.filterByFields=r.extend({},i.gridOptions.filterByFields))}),g=!0)})}}}}}]).directive(O,[function(){return{restrict:"A",templateUrl:e.cellHeaderTemplateId,transclude:!0,replace:!0}}]).directive(o,[function(){return{restrict:"A",require:"^"+s,scope:!0,compile:function(e,t){return{pre:function(e,t,i,r){e.toggleItemSelection=function(t,i){r.toggleItemSelection(e.filteredItems,t,i)}}}}}}]).directive(F,[function(){return{restrict:"A",require:"^"+s,scope:!0,compile:function(e,t){var i="true"==t.isCustomized;return N(e,t,i,b),{pre:function(e,t,r,n,l){e.columnOptions=e.gridOptions.gridColumnDefs[parseInt(r[F])],e.gridItem=e.gridDisplayItem.$$_gridItem,e.isCustomized=i}}}}}]).directive(S,[function(){return{restrict:"A",templateUrl:e.cellBodyTemplateId,transclude:!0,replace:!0}}]).directive(p,[function(){return{restrict:"A",require:"^"+s,scope:!0,compile:function(e,t){var i="true"==t.isCustomized;return N(e,t,i,f),{pre:function(e,t,r,n,l){e.isCustomized=i,t.attr("colspan",e.gridOptions.gridColumnDefs.length)}}}}}]).directive(m,[function(){return{restrict:"A",templateUrl:e.cellFooterTemplateId,transclude:!0,replace:!0}}]).directive(w,[function(){return{restrict:"A",replace:!0,templateUrl:e.columnSortTemplateId}}]).directive(x,[function(){return{restrict:"A",replace:!0,templateUrl:e.columnFilterTemplateId}}]).directive(h,[function(){return{restrict:"A",scope:!1,templateUrl:e.footerGlobalFilterTemplateId}}]).directive(v,[function(){var t=function(t,i){if(t.totalItemsCount="undefined"!=typeof t.gridOptions.totalItems&&null!=t.gridOptions.totalItems?t.gridOptions.totalItems:t.gridOptions.items?t.gridOptions.items.length:0,t.isPaged=!!t.gridOptions.pageItems&&t.gridOptions.pageItems<t.totalItemsCount,t.extendedControlsActive=!1,t.lastPageIndex=t.totalItemsCount&&t.isPaged?Math.floor(t.totalItemsCount/t.gridOptions.pageItems)+(t.totalItemsCount%t.gridOptions.pageItems?0:-1):0,t.gridOptions.currentPage>t.lastPageIndex&&(e.debugMode&&i.log("The current page index falls outside of the range of items. Either the attached parameter has a wrong value or the total items count is not properly set in server side mode."),t.gridOptions.currentPage=t.lastPageIndex),t.startItemIndex=t.isPaged?t.gridOptions.pageItems*t.gridOptions.currentPage:0,t.endItemIndex=t.isPaged?t.startItemIndex+t.gridOptions.pageItems-1:t.totalItemsCount-1,t.endItemIndex>=t.totalItemsCount&&(t.endItemIndex=t.totalItemsCount-1),t.endItemIndex<t.startItemIndex&&(t.endItemIndex=t.startItemIndex),t.pageCanGoBack=t.isPaged&&t.gridOptions.currentPage>0,t.pageCanGoForward=t.isPaged&&t.gridOptions.currentPage<t.lastPageIndex,t.pageIndexes=t.pageIndexes||[],t.pageIndexes.splice(0),t.isPaged)if(t.lastPageIndex+1>e.defaultPagerMinifiedPageCountThreshold){t.extendedControlsActive=!0;var r=Math.floor(e.defaultPagerMinifiedPageCountThreshold/2),n=t.gridOptions.currentPage-r,l=t.gridOptions.currentPage+r;0>n?(l+=-n,n=0):l>t.lastPageIndex&&(n-=l-t.lastPageIndex,l=t.lastPageIndex),n>0&&(t.pageIndexes.push(null),n++);var s=!1;l<t.lastPageIndex&&(s=!0,l--);for(var o=n;l>=o;o++)t.pageIndexes.push(o);s&&t.pageIndexes.push(null)}else{t.extendedControlsActive=!1;for(var o=0;o<=t.lastPageIndex;o++)t.pageIndexes.push(o)}t.pageSelectionActive=t.pageIndexes.length>1,t.navigateToPage=function(e){t.gridOptions.currentPage=e,t.speedUpAsyncDataRetrieval()},t.switchPageSelection=function(e,i){t.pageSelectionActive=i,e&&(e.preventDefault(),e.stopPropagation())}};return{restrict:"A",scope:!0,require:"^"+s,templateUrl:e.footerPagerTemplateId,replace:!0,compile:function(e,i){return{pre:function(e,i,r,n){t(e,n)},post:function(e,i,r,n){e.$watchCollection("[gridOptions.currentPage, gridOptions.items.length, gridOptions.totalItems, gridOptions.pageItems]",function(i,r){t(e,n)})}}}}}]).filter(e.sortFilter,["$filter","$parse",function(e,t){return function(i,r){if(!r.orderBy||!r.gridColumnDefs)return i;for(var n=null,l=0;l<r.gridColumnDefs.length&&(n=r.gridColumnDefs[l]).fieldName!==r.orderBy;n=null,l++);if(!n)return i;var s=e("orderBy")(i,function(e){var i=void 0;if(n.fieldExtractionExpression)try{i=t("item.$$_gridItem"+n.fieldExtractionExpression)({item:e})}catch(r){}if(void 0===i)try{i=t('item["'+n.displayFieldName+'"]')({item:e})}catch(r){}return i},r.orderByReverse);return s}}]).filter(e.dataPagingFilter,function(){return function(e,t){if(e&&(t.totalItems=e.length),!t.pageItems||!e||0==e.length)return e;t.currentPage||(t.currentPage=0);var i=t.currentPage*t.pageItems;i>=e.length&&(t.currentPage=0,i=0);var r=t.currentPage*t.pageItems+t.pageItems;return e.slice(i,r)}}).filter(e.translateFilter,["$filter","$injector",function(t,i){return function(r,n){var l=null;if(!n)throw"Language identifier is not set";if(r instanceof Date){var s=t(e.translateFilter)(e.translationDateFormat,n);return s&&s!==e.translationDateFormat?l=t("date")(r,s):r}for(var o=n.split(/[-_]/),a=o.length;a>0&&!l;a--){var d=o.slice(0,a).join("-"),c=e.translations[d];c&&(l=c[r])}if(!l&&i.has("translateFilter"))try{l=t("translate")(r)}catch(g){}return l||(l=r),l}}]).run(function(){e.tableCssClass="tr-ng-grid table table-bordered table-hover",e.cellCssClass="tr-ng-cell",e.headerCellCssClass="tr-ng-column-header "+e.cellCssClass,e.bodyCellCssClass=e.cellCssClass,e.columnTitleCssClass="tr-ng-title",e.columnSortCssClass="tr-ng-sort",e.columnFilterCssClass="tr-ng-column-filter",e.columnFilterInputWrapperCssClass="",e.columnSortActiveCssClass="tr-ng-sort-active text-info",e.columnSortInactiveCssClass="tr-ng-sort-inactive text-muted glyphicon glyphicon-chevron-down",e.columnSortReverseOrderCssClass="tr-ng-sort-order-reverse glyphicon glyphicon-chevron-down",e.columnSortNormalOrderCssClass="tr-ng-sort-order-normal glyphicon glyphicon-chevron-up",e.rowSelectedCssClass="active",e.footerCssClass="tr-ng-grid-footer form-inline"}).run(function(){e.defaultColumnOptions.displayAlign="left",e.defaultPagerMinifiedPageCountThreshold=3})}(i=t.TrNgGrid||(t.TrNgGrid={}))});