mirror of https://github.com/gophish/gophish
4 lines
9.1 KiB
JavaScript
4 lines
9.1 KiB
JavaScript
|
/*! ngTable v0.3.2 by Vitalii Savchuk([email protected]) - https://github.com/esvit/ng-table - New BSD License */
|
||
|
|
||
|
!function(a,b){return"function"==typeof define&&define.amd?void define(["angular"],function(a){return b(a)}):b(a)}(angular||null,function(a){var b=a.module("ngTable",[]);b.factory("ngTableParams",["$q","$log",function(b,c){var d=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},e=function(e,f){var g=this;this.data=[],this.parameters=function(b,e){if(e=e||!1,a.isDefined(b)){for(var f in b){var g=b[f];if(e&&f.indexOf("[")>=0){for(var i=f.split(/\[(.*)\]/).reverse(),j="",k=0,l=i.length;l>k;k++){var m=i[k];if(""!==m){var n=g;g={},g[j=m]=d(n)?parseFloat(n):n}}"sorting"===j&&(h[j]={}),h[j]=a.extend(h[j]||{},g[j])}else h[f]=d(b[f])?parseFloat(b[f]):b[f]}return c.debug&&c.debug("ngTable: set parameters",h),this}return h},this.settings=function(b){return a.isDefined(b)?(a.isArray(b.data)&&(b.total=b.data.length),i=a.extend(i,b),c.debug&&c.debug("ngTable: set settings",i),this):i},this.page=function(b){return a.isDefined(b)?this.parameters({page:b}):h.page},this.total=function(b){return a.isDefined(b)?this.settings({total:b}):i.total},this.count=function(b){return a.isDefined(b)?this.parameters({count:b,page:1}):h.count},this.filter=function(b){return a.isDefined(b)?this.parameters({filter:b}):h.filter},this.sorting=function(b){if(2==arguments.length){var c={};return c[b]=arguments[1],this.parameters({sorting:c}),this}return a.isDefined(b)?this.parameters({sorting:b}):h.sorting},this.isSortBy=function(b,c){return a.isDefined(h.sorting[b])&&h.sorting[b]==c},this.orderBy=function(){var a=[];for(var b in h.sorting)a.push(("asc"===h.sorting[b]?"+":"-")+b);return a},this.getData=function(b,c){b.resolve(a.isArray(this.data)&&a.isObject(c)?this.data.slice((c.page()-1)*c.count(),c.page()*c.count()):[])},this.getGroups=function(d,e){var f=b.defer();f.promise.then(function(b){var f={};a.forEach(b,function(b){var c=a.isFunction(e)?e(b):b[e];f[c]=f[c]||{data:[]},f[c].value=c,f[c].data.push(b)});var g=[];for(var h in f)g.push(f[h]);c.debug&&c.debug("ngTable: refresh groups",g),d.resolve(g)}),this.getData(f,g)},this.generatePagesArray=function(a,b,c){var d,e,f,g,h,i;if(d=11,i=[],h=Math.ceil(b/c),h>1){i.push({type:"prev",number:Math.max(1,a-1),active:a>1}),i.push({type:"first",number:1,active:a>1}),f=Math.round((d-5)/2),g=Math.max(2,a-f),e=Math.min(h-1,a+2*f-(a-g)),g=Math.max(2,g-(2*f-(e-g)));for(var j=g;e>=j;)i.push(j===g&&2!==j||j===e&&j!==h-1?{type:"more",active:!1}:{type:"page",number:j,active:a!==j}),j++;i.push({type:"last",number:h,active:a!==h}),i.push({type:"next",number:Math.min(h,a+1),active:h>a})}return i},this.url=function(b){b=b||!1;var c=b?[]:{};for(key in h)if(h.hasOwnProperty(key)){var d=h[key],e=encodeURIComponent(key);if("object"==typeof d){for(var f in d)if(!a.isUndefined(d[f])&&""!==d[f]){var g=e+"["+encodeURIComponent(f)+"]";b?c.push(g+"="+d[f]):c[g]=d[f]}}else a.isFunction(d)||a.isUndefined(d)||""===d||(b?c.push(e+"="+encodeURIComponent(d)):c[e]=encodeURIComponent(d))}return c},this.reload=function(){var a=b.defer(),d=this;i.$loading=!0,i.groupBy?i.getGroups(a,i.groupBy,this):i.getData(a,this),c.debug&&c.debug("ngTable: reload data"),a.promise.then(function(a){i.$loading=!1,c.debug&&c.debug("ngTable: current scope",i.$scope),d.data=i.groupBy?i.$scope.$groups=a:i.$scope.$data=a,i.$scope.pages=d.generatePagesArray(d.page(),d.total(),d.count())})},this.reloadPages=function(){var a=this;i.$scope.pages=a.generatePagesArray(a.page(),a.total(),a.count())};var h=this.$params={page:1,count:1,filter:{},sorting:{},group:{},groupBy:null},i={$scope:null,$loading:!1,data:null,total:0,counts:[10,25,50,100],getGroups:this.getGroups,getData:this.getData};return this.settings(f),this.parameters(e,!0),this};return e}]);var c=["$scope","ngTableParams","$q",function(a,b){a.$loading=!1,a.params||(a.params=new b),a.params.settings().$scope=a,a.$watch("params.$params",function(){a.params.settings().$scope=a,a.params.reload()},!0),a.sortBy=function(b,c){var d=a.parse(b.sortable);if(d){var e=a.params.sorting()&&a.params.sorting()[d]&&"desc"===a.params.sorting()[d],f=c.ctrlKey?a.params.sorting():{};f[d]=e?"asc":"desc",a.params.parameters({sortin
|
||
|
//# sourceMappingURL=ng-table.map
|