diff --git a/bower.json b/bower.json index d45c7f8..623a799 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ng-tasty", - "version": "0.2.2-rc.1", + "version": "0.2.2", "homepage": "https://github.com/Zizzamia/ng-tasty", "authors": [ "@zizzamia" diff --git a/ng-tasty-tpls.js b/ng-tasty-tpls.js index 81ac077..1377159 100644 --- a/ng-tasty-tpls.js +++ b/ng-tasty-tpls.js @@ -2,11 +2,11 @@ * ng-tasty * https://github.com/Zizzamia/ng-tasty - * Version: 0.2.2-rc.1 - 2014-08-07 + * Version: 0.2.2 - 2014-08-07 * License: MIT */ angular.module("ngTasty", ["ngTasty.tpls", "ngTasty.table"]); -angular.module("ngTasty.tpls", ["template/table/tasty-head.html","template/table/tasty-pagination.html"]); +angular.module("ngTasty.tpls", ["template/table/head.html","template/table/pagination.html"]); /** * @ngdoc directive * @name tastyTable @@ -167,7 +167,7 @@ angular.module('ngTasty.table', []) restrict: 'AE', require: '^tastyTable', scope: {}, - templateUrl: 'template/table/tasty-head.html', + templateUrl: 'template/table/head.html', link: function (scope, element, attrs, tastyTable) { 'use strict'; var cleanFieldName, setFields, init; @@ -252,7 +252,7 @@ angular.module('ngTasty.table', []) restrict: 'AE', require: '^tastyTable', scope: {}, - templateUrl: 'template/table/tasty-pagination.html', + templateUrl: 'template/table/pagination.html', link: function (scope, element, attrs, tastyTable) { 'use strict'; var getPage, setCount, setPaginationRange, @@ -373,50 +373,50 @@ angular.module('ngTasty.table', []) } }; }); -angular.module("template/table/tasty-head.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("template/table/tasty-head.html", - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""); +angular.module('template/table/head.html', []).run(['$templateCache', function($templateCache) { + $templateCache.put('template/table/head.html', + '\n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ''); }]); -angular.module("template/table/tasty-pagination.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("template/table/tasty-pagination.html", - "
\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "

Page \n" + - " of ,\n" + - " of entries

\n" + - "
\n" + - "
"); +angular.module('template/table/pagination.html', []).run(['$templateCache', function($templateCache) { + $templateCache.put('template/table/pagination.html', + '
\n' + + '
\n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + '

Page \n' + + ' of ,\n' + + ' of entries

\n' + + '
\n' + + '
'); }]); diff --git a/ng-tasty-tpls.min.js b/ng-tasty-tpls.min.js index 37e64d0..2584d49 100644 --- a/ng-tasty-tpls.min.js +++ b/ng-tasty-tpls.min.js @@ -1 +1 @@ -angular.module("ngTasty",["ngTasty.tpls","ngTasty.table"]),angular.module("ngTasty.tpls",["template/table/tasty-head.html","template/table/tasty-pagination.html"]),angular.module("ngTasty.table",[]).directive("tastyTable",["$timeout",function(){return{restrict:"A",scope:!0,controller:function(a){this.$scope=a},link:function(a,n,e){"use strict";var t;if(!e.resource)throw"AngularJS tastyTable directive: miss the resource attribute";if(!a[e.resource])throw"AngularJS tastyTable directive: the resource ("+e.resource+") callback it's undefined";a.query={page:"page",count:"count",sortBy:"sort-by",sortOrder:"sort-order"},a.header={columns:[]},a.rows=[],a.params={},a.thead=!1,a.pagination=!1,a.resourcePagination={},a.url="",a.setDirectivesValues=function(n){return n?(a.rows=n.rows,a.header={columns:n.header,sortBy:n.sortBy,sortOrder:n.sortOrder},void(a.resourcePagination=n.pagination)):!1},a.setProperty=function(a,n,e){return n[e]&&(a[e]=n[e]),a},a.joinObjects=function(n,e){for(var t in e)a.setProperty(n,e,t);return n},a.buildUrl=function(n,t){var i,r;return i={},a.thead&&(i=a.setProperty(i,n,"sortBy"),i=a.setProperty(i,n,"sortOrder")),a.pagination&&(i=a.setProperty(i,n,"page"),i=a.setProperty(i,n,"count")),e.filters&&(i=a.joinObjects(i,t)),Object.keys(i).map(function(n){return r=i[n],a.query[n]&&(n=a.query[n]),encodeURIComponent(n)+"="+encodeURIComponent(r)}).join("&")},t=function(a,n){var e;return function(){var t=this,i=arguments;clearTimeout(e),e=setTimeout(function(){e=null,a.apply(t,i)},n)}},a.updateResource=t(function(){a.url=a.buildUrl(a.params,a[e.filters]),a[e.resource](a.url).then(function(n){a.setDirectivesValues(n)})},100),a.initDirective=function(){a.params.sortBy=void 0,a.params.sortOrder="asc",a.params.page=1,a.params.count=5,a.updateResource()},e.filters&&a.$watch(e.filters,function(n,e){n!==e&&a.updateResource()},!0),a.$watch("params",function(n,e){n!==e&&a.updateResource()},!0),a.initDirective()}}}]).directive("tastyThead",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/tasty-head.html",link:function(a,n,e,t){"use strict";var i,r,s;t.$scope.thead=!0,t.$scope.params.thead=!0,a.fields={},s=!0,i=function(a){return a.replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase()},r=function(){var n,e;for(n=a.header.columns.length,e=0;n>e;e++)a.fields[a.header.columns[e].key]={width:100/n,sort:i(a.header.columns[e].key)};"dsc"===a.header.sortOrder&&(a.header.sortBy="-"+a.header.sortBy)},a.sortBy=function(n){var e;e=i(n.key),a.header.sortBy==e?(a.header.sortBy="-"+e,t.$scope.params.sortOrder="dsc"):(a.header.sortBy=e,t.$scope.params.sortOrder="asc"),t.$scope.params.sortBy=n.key},a.isSortUp=function(n){return void 0===a.fields[n.key]?!1:a.header.sortBy=="-"+a.fields[n.key].sort},a.isSortDown=function(n){return void 0===a.fields[n.key]?!1:a.header.sortBy==a.fields[n.key].sort},t.$scope.$watch("header",function(n,e){n&&n!==e&&(a.header=t.$scope.header,r())})}}}).directive("tastyPagination",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/tasty-pagination.html",link:function(a,n,e,t){"use strict";var i,r,s,o,p,g,c,u;t.$scope.pagination=!0,t.$scope.params.pagination=!0,a.numPaginations=5,a.pagListCount=[5,25,50,100],a.pagination={},a.pagMinRange=1,a.pagMaxRange=1,c=!0,u=function(a,n){var e;e=[],a=parseInt(a,10),n=parseInt(n,10);for(var t=a;n>t;t++)e.push(t);return e},i=function(a){t.$scope.params.page=a},r=function(n){var e;e=n*a.pagination.page,e>a.pagination.size&&(t.$scope.params.page=Math.ceil(a.pagination.size/n)),t.$scope.params.count=n},s=function(){var n;n=a.pagination.page,n>a.pagination.pages&&(n=a.pagination.pages),a.pagMinRange=n-2>0?n-2:1,a.pagMaxRange=n+2,a.pagination.page=n,g()},o=function(){return a.pagHideMinRange===!0||a.pagMinRange<1?!1:(a.pagMaxRange=a.pagMinRange,a.pagMinRange=a.pagMaxRange-a.numPaginations,void g())},p=function(){return a.pagHideMaxRange===!0||a.pagMaxRange>a.pagination.pages?!1:(a.pagMinRange=a.pagMaxRange,a.pagMaxRange=a.pagMinRange+a.numPaginations,a.pagMaxRange>a.pagination.pages&&(a.pagMaxRange=a.pagination.pages),a.pagMinRange=a.pagMaxRange-a.numPaginations,void g())},g=function(){a.pagMinRange=a.pagMinRange>0?a.pagMinRange:1,a.pagMaxRange=a.pagMinRange+a.numPaginations,a.pagMaxRange>a.pagination.pages&&(a.pagMaxRange=a.pagination.pages+1),a.pagHideMinRange=a.pagMinRange<=1,a.pagHideMaxRange=a.pagMaxRange>=a.pagination.pages,a.pagListCount=a.pagination.size<50?[5,25]:a.pagination.size<100?[5,25,50]:[5,25,50,100],a.rangePage=u(a.pagMinRange,a.pagMaxRange)},a.page={get:i,setCount:r,previous:o,remaining:p},t.$scope.$watch("resourcePagination",function(n,e){n&&n!==e&&(a.pagination={count:n.count,page:n.page,pages:n.pages,size:n.size},s())})}}}),angular.module("template/table/tasty-head.html",[]).run(["$templateCache",function(a){a.put("template/table/tasty-head.html",'\n \n \n \n \n \n')}]),angular.module("template/table/tasty-pagination.html",[]).run(["$templateCache",function(a){a.put("template/table/tasty-pagination.html",'
\n
\n
\n \n
\n
\n
\n \n
\n
\n

Page \n of ,\n of entries

\n
\n
')}]); \ No newline at end of file +angular.module("ngTasty",["ngTasty.tpls","ngTasty.table"]),angular.module("ngTasty.tpls",["template/table/head.html","template/table/pagination.html"]),angular.module("ngTasty.table",[]).directive("tastyTable",["$timeout",function(){return{restrict:"A",scope:!0,controller:function(a){this.$scope=a},link:function(a,n,e){"use strict";var t;if(!e.resource)throw"AngularJS tastyTable directive: miss the resource attribute";if(!a[e.resource])throw"AngularJS tastyTable directive: the resource ("+e.resource+") callback it's undefined";a.query={page:"page",count:"count",sortBy:"sort-by",sortOrder:"sort-order"},a.header={columns:[]},a.rows=[],a.params={},a.thead=!1,a.pagination=!1,a.resourcePagination={},a.url="",a.setDirectivesValues=function(n){return n?(a.rows=n.rows,a.header={columns:n.header,sortBy:n.sortBy,sortOrder:n.sortOrder},void(a.resourcePagination=n.pagination)):!1},a.setProperty=function(a,n,e){return n[e]&&(a[e]=n[e]),a},a.joinObjects=function(n,e){for(var t in e)a.setProperty(n,e,t);return n},a.buildUrl=function(n,t){var i,r;return i={},a.thead&&(i=a.setProperty(i,n,"sortBy"),i=a.setProperty(i,n,"sortOrder")),a.pagination&&(i=a.setProperty(i,n,"page"),i=a.setProperty(i,n,"count")),e.filters&&(i=a.joinObjects(i,t)),Object.keys(i).map(function(n){return r=i[n],a.query[n]&&(n=a.query[n]),encodeURIComponent(n)+"="+encodeURIComponent(r)}).join("&")},t=function(a,n){var e;return function(){var t=this,i=arguments;clearTimeout(e),e=setTimeout(function(){e=null,a.apply(t,i)},n)}},a.updateResource=t(function(){a.url=a.buildUrl(a.params,a[e.filters]),a[e.resource](a.url).then(function(n){a.setDirectivesValues(n)})},100),a.initDirective=function(){a.params.sortBy=void 0,a.params.sortOrder="asc",a.params.page=1,a.params.count=5,a.updateResource()},e.filters&&a.$watch(e.filters,function(n,e){n!==e&&a.updateResource()},!0),a.$watch("params",function(n,e){n!==e&&a.updateResource()},!0),a.initDirective()}}}]).directive("tastyThead",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/head.html",link:function(a,n,e,t){"use strict";var i,r,s;t.$scope.thead=!0,t.$scope.params.thead=!0,a.fields={},s=!0,i=function(a){return a.replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase()},r=function(){var n,e;for(n=a.header.columns.length,e=0;n>e;e++)a.fields[a.header.columns[e].key]={width:100/n,sort:i(a.header.columns[e].key)};"dsc"===a.header.sortOrder&&(a.header.sortBy="-"+a.header.sortBy)},a.sortBy=function(n){var e;e=i(n.key),a.header.sortBy==e?(a.header.sortBy="-"+e,t.$scope.params.sortOrder="dsc"):(a.header.sortBy=e,t.$scope.params.sortOrder="asc"),t.$scope.params.sortBy=n.key},a.isSortUp=function(n){return void 0===a.fields[n.key]?!1:a.header.sortBy=="-"+a.fields[n.key].sort},a.isSortDown=function(n){return void 0===a.fields[n.key]?!1:a.header.sortBy==a.fields[n.key].sort},t.$scope.$watch("header",function(n,e){n&&n!==e&&(a.header=t.$scope.header,r())})}}}).directive("tastyPagination",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/pagination.html",link:function(a,n,e,t){"use strict";var i,r,s,o,p,g,c,u;t.$scope.pagination=!0,t.$scope.params.pagination=!0,a.numPaginations=5,a.pagListCount=[5,25,50,100],a.pagination={},a.pagMinRange=1,a.pagMaxRange=1,c=!0,u=function(a,n){var e;e=[],a=parseInt(a,10),n=parseInt(n,10);for(var t=a;n>t;t++)e.push(t);return e},i=function(a){t.$scope.params.page=a},r=function(n){var e;e=n*a.pagination.page,e>a.pagination.size&&(t.$scope.params.page=Math.ceil(a.pagination.size/n)),t.$scope.params.count=n},s=function(){var n;n=a.pagination.page,n>a.pagination.pages&&(n=a.pagination.pages),a.pagMinRange=n-2>0?n-2:1,a.pagMaxRange=n+2,a.pagination.page=n,g()},o=function(){return a.pagHideMinRange===!0||a.pagMinRange<1?!1:(a.pagMaxRange=a.pagMinRange,a.pagMinRange=a.pagMaxRange-a.numPaginations,void g())},p=function(){return a.pagHideMaxRange===!0||a.pagMaxRange>a.pagination.pages?!1:(a.pagMinRange=a.pagMaxRange,a.pagMaxRange=a.pagMinRange+a.numPaginations,a.pagMaxRange>a.pagination.pages&&(a.pagMaxRange=a.pagination.pages),a.pagMinRange=a.pagMaxRange-a.numPaginations,void g())},g=function(){a.pagMinRange=a.pagMinRange>0?a.pagMinRange:1,a.pagMaxRange=a.pagMinRange+a.numPaginations,a.pagMaxRange>a.pagination.pages&&(a.pagMaxRange=a.pagination.pages+1),a.pagHideMinRange=a.pagMinRange<=1,a.pagHideMaxRange=a.pagMaxRange>=a.pagination.pages,a.pagListCount=a.pagination.size<50?[5,25]:a.pagination.size<100?[5,25,50]:[5,25,50,100],a.rangePage=u(a.pagMinRange,a.pagMaxRange)},a.page={get:i,setCount:r,previous:o,remaining:p},t.$scope.$watch("resourcePagination",function(n,e){n&&n!==e&&(a.pagination={count:n.count,page:n.page,pages:n.pages,size:n.size},s())})}}}),angular.module("template/table/head.html",[]).run(["$templateCache",function(a){a.put("template/table/head.html",'\n \n \n \n \n \n')}]),angular.module("template/table/pagination.html",[]).run(["$templateCache",function(a){a.put("template/table/pagination.html",'
\n
\n
\n \n
\n
\n
\n \n
\n
\n

Page \n of ,\n of entries

\n
\n
')}]); \ No newline at end of file diff --git a/ng-tasty.js b/ng-tasty.js index ac4c934..28f0425 100644 --- a/ng-tasty.js +++ b/ng-tasty.js @@ -2,7 +2,7 @@ * ng-tasty * https://github.com/Zizzamia/ng-tasty - * Version: 0.2.2-rc.1 - 2014-08-07 + * Version: 0.2.2 - 2014-08-07 * License: MIT */ angular.module("ngTasty", ["ngTasty.table"]); @@ -166,7 +166,7 @@ angular.module('ngTasty.table', []) restrict: 'AE', require: '^tastyTable', scope: {}, - templateUrl: 'template/table/tasty-head.html', + templateUrl: 'template/table/head.html', link: function (scope, element, attrs, tastyTable) { 'use strict'; var cleanFieldName, setFields, init; @@ -251,7 +251,7 @@ angular.module('ngTasty.table', []) restrict: 'AE', require: '^tastyTable', scope: {}, - templateUrl: 'template/table/tasty-pagination.html', + templateUrl: 'template/table/pagination.html', link: function (scope, element, attrs, tastyTable) { 'use strict'; var getPage, setCount, setPaginationRange, diff --git a/ng-tasty.min.js b/ng-tasty.min.js index bd2229f..ffbc6de 100644 --- a/ng-tasty.min.js +++ b/ng-tasty.min.js @@ -1 +1 @@ -angular.module("ngTasty",["ngTasty.table"]),angular.module("ngTasty.table",[]).directive("tastyTable",["$timeout",function(){return{restrict:"A",scope:!0,controller:function(e){this.$scope=e},link:function(e,a,n){"use strict";var t;if(!n.resource)throw"AngularJS tastyTable directive: miss the resource attribute";if(!e[n.resource])throw"AngularJS tastyTable directive: the resource ("+n.resource+") callback it's undefined";e.query={page:"page",count:"count",sortBy:"sort-by",sortOrder:"sort-order"},e.header={columns:[]},e.rows=[],e.params={},e.thead=!1,e.pagination=!1,e.resourcePagination={},e.url="",e.setDirectivesValues=function(a){return a?(e.rows=a.rows,e.header={columns:a.header,sortBy:a.sortBy,sortOrder:a.sortOrder},void(e.resourcePagination=a.pagination)):!1},e.setProperty=function(e,a,n){return a[n]&&(e[n]=a[n]),e},e.joinObjects=function(a,n){for(var t in n)e.setProperty(a,n,t);return a},e.buildUrl=function(a,t){var r,i;return r={},e.thead&&(r=e.setProperty(r,a,"sortBy"),r=e.setProperty(r,a,"sortOrder")),e.pagination&&(r=e.setProperty(r,a,"page"),r=e.setProperty(r,a,"count")),n.filters&&(r=e.joinObjects(r,t)),Object.keys(r).map(function(a){return i=r[a],e.query[a]&&(a=e.query[a]),encodeURIComponent(a)+"="+encodeURIComponent(i)}).join("&")},t=function(e,a){var n;return function(){var t=this,r=arguments;clearTimeout(n),n=setTimeout(function(){n=null,e.apply(t,r)},a)}},e.updateResource=t(function(){e.url=e.buildUrl(e.params,e[n.filters]),e[n.resource](e.url).then(function(a){e.setDirectivesValues(a)})},100),e.initDirective=function(){e.params.sortBy=void 0,e.params.sortOrder="asc",e.params.page=1,e.params.count=5,e.updateResource()},n.filters&&e.$watch(n.filters,function(a,n){a!==n&&e.updateResource()},!0),e.$watch("params",function(a,n){a!==n&&e.updateResource()},!0),e.initDirective()}}}]).directive("tastyThead",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/tasty-head.html",link:function(e,a,n,t){"use strict";var r,i,o;t.$scope.thead=!0,t.$scope.params.thead=!0,e.fields={},o=!0,r=function(e){return e.replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase()},i=function(){var a,n;for(a=e.header.columns.length,n=0;a>n;n++)e.fields[e.header.columns[n].key]={width:100/a,sort:r(e.header.columns[n].key)};"dsc"===e.header.sortOrder&&(e.header.sortBy="-"+e.header.sortBy)},e.sortBy=function(a){var n;n=r(a.key),e.header.sortBy==n?(e.header.sortBy="-"+n,t.$scope.params.sortOrder="dsc"):(e.header.sortBy=n,t.$scope.params.sortOrder="asc"),t.$scope.params.sortBy=a.key},e.isSortUp=function(a){return void 0===e.fields[a.key]?!1:e.header.sortBy=="-"+e.fields[a.key].sort},e.isSortDown=function(a){return void 0===e.fields[a.key]?!1:e.header.sortBy==e.fields[a.key].sort},t.$scope.$watch("header",function(a,n){a&&a!==n&&(e.header=t.$scope.header,i())})}}}).directive("tastyPagination",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/tasty-pagination.html",link:function(e,a,n,t){"use strict";var r,i,o,s,p,g,u,c;t.$scope.pagination=!0,t.$scope.params.pagination=!0,e.numPaginations=5,e.pagListCount=[5,25,50,100],e.pagination={},e.pagMinRange=1,e.pagMaxRange=1,u=!0,c=function(e,a){var n;n=[],e=parseInt(e,10),a=parseInt(a,10);for(var t=e;a>t;t++)n.push(t);return n},r=function(e){t.$scope.params.page=e},i=function(a){var n;n=a*e.pagination.page,n>e.pagination.size&&(t.$scope.params.page=Math.ceil(e.pagination.size/a)),t.$scope.params.count=a},o=function(){var a;a=e.pagination.page,a>e.pagination.pages&&(a=e.pagination.pages),e.pagMinRange=a-2>0?a-2:1,e.pagMaxRange=a+2,e.pagination.page=a,g()},s=function(){return e.pagHideMinRange===!0||e.pagMinRange<1?!1:(e.pagMaxRange=e.pagMinRange,e.pagMinRange=e.pagMaxRange-e.numPaginations,void g())},p=function(){return e.pagHideMaxRange===!0||e.pagMaxRange>e.pagination.pages?!1:(e.pagMinRange=e.pagMaxRange,e.pagMaxRange=e.pagMinRange+e.numPaginations,e.pagMaxRange>e.pagination.pages&&(e.pagMaxRange=e.pagination.pages),e.pagMinRange=e.pagMaxRange-e.numPaginations,void g())},g=function(){e.pagMinRange=e.pagMinRange>0?e.pagMinRange:1,e.pagMaxRange=e.pagMinRange+e.numPaginations,e.pagMaxRange>e.pagination.pages&&(e.pagMaxRange=e.pagination.pages+1),e.pagHideMinRange=e.pagMinRange<=1,e.pagHideMaxRange=e.pagMaxRange>=e.pagination.pages,e.pagListCount=e.pagination.size<50?[5,25]:e.pagination.size<100?[5,25,50]:[5,25,50,100],e.rangePage=c(e.pagMinRange,e.pagMaxRange)},e.page={get:r,setCount:i,previous:s,remaining:p},t.$scope.$watch("resourcePagination",function(a,n){a&&a!==n&&(e.pagination={count:a.count,page:a.page,pages:a.pages,size:a.size},o())})}}}); \ No newline at end of file +angular.module("ngTasty",["ngTasty.table"]),angular.module("ngTasty.table",[]).directive("tastyTable",["$timeout",function(){return{restrict:"A",scope:!0,controller:function(e){this.$scope=e},link:function(e,a,n){"use strict";var t;if(!n.resource)throw"AngularJS tastyTable directive: miss the resource attribute";if(!e[n.resource])throw"AngularJS tastyTable directive: the resource ("+n.resource+") callback it's undefined";e.query={page:"page",count:"count",sortBy:"sort-by",sortOrder:"sort-order"},e.header={columns:[]},e.rows=[],e.params={},e.thead=!1,e.pagination=!1,e.resourcePagination={},e.url="",e.setDirectivesValues=function(a){return a?(e.rows=a.rows,e.header={columns:a.header,sortBy:a.sortBy,sortOrder:a.sortOrder},void(e.resourcePagination=a.pagination)):!1},e.setProperty=function(e,a,n){return a[n]&&(e[n]=a[n]),e},e.joinObjects=function(a,n){for(var t in n)e.setProperty(a,n,t);return a},e.buildUrl=function(a,t){var r,i;return r={},e.thead&&(r=e.setProperty(r,a,"sortBy"),r=e.setProperty(r,a,"sortOrder")),e.pagination&&(r=e.setProperty(r,a,"page"),r=e.setProperty(r,a,"count")),n.filters&&(r=e.joinObjects(r,t)),Object.keys(r).map(function(a){return i=r[a],e.query[a]&&(a=e.query[a]),encodeURIComponent(a)+"="+encodeURIComponent(i)}).join("&")},t=function(e,a){var n;return function(){var t=this,r=arguments;clearTimeout(n),n=setTimeout(function(){n=null,e.apply(t,r)},a)}},e.updateResource=t(function(){e.url=e.buildUrl(e.params,e[n.filters]),e[n.resource](e.url).then(function(a){e.setDirectivesValues(a)})},100),e.initDirective=function(){e.params.sortBy=void 0,e.params.sortOrder="asc",e.params.page=1,e.params.count=5,e.updateResource()},n.filters&&e.$watch(n.filters,function(a,n){a!==n&&e.updateResource()},!0),e.$watch("params",function(a,n){a!==n&&e.updateResource()},!0),e.initDirective()}}}]).directive("tastyThead",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/head.html",link:function(e,a,n,t){"use strict";var r,i,o;t.$scope.thead=!0,t.$scope.params.thead=!0,e.fields={},o=!0,r=function(e){return e.replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase()},i=function(){var a,n;for(a=e.header.columns.length,n=0;a>n;n++)e.fields[e.header.columns[n].key]={width:100/a,sort:r(e.header.columns[n].key)};"dsc"===e.header.sortOrder&&(e.header.sortBy="-"+e.header.sortBy)},e.sortBy=function(a){var n;n=r(a.key),e.header.sortBy==n?(e.header.sortBy="-"+n,t.$scope.params.sortOrder="dsc"):(e.header.sortBy=n,t.$scope.params.sortOrder="asc"),t.$scope.params.sortBy=a.key},e.isSortUp=function(a){return void 0===e.fields[a.key]?!1:e.header.sortBy=="-"+e.fields[a.key].sort},e.isSortDown=function(a){return void 0===e.fields[a.key]?!1:e.header.sortBy==e.fields[a.key].sort},t.$scope.$watch("header",function(a,n){a&&a!==n&&(e.header=t.$scope.header,i())})}}}).directive("tastyPagination",function(){return{restrict:"AE",require:"^tastyTable",scope:{},templateUrl:"template/table/pagination.html",link:function(e,a,n,t){"use strict";var r,i,o,s,p,g,u,c;t.$scope.pagination=!0,t.$scope.params.pagination=!0,e.numPaginations=5,e.pagListCount=[5,25,50,100],e.pagination={},e.pagMinRange=1,e.pagMaxRange=1,u=!0,c=function(e,a){var n;n=[],e=parseInt(e,10),a=parseInt(a,10);for(var t=e;a>t;t++)n.push(t);return n},r=function(e){t.$scope.params.page=e},i=function(a){var n;n=a*e.pagination.page,n>e.pagination.size&&(t.$scope.params.page=Math.ceil(e.pagination.size/a)),t.$scope.params.count=a},o=function(){var a;a=e.pagination.page,a>e.pagination.pages&&(a=e.pagination.pages),e.pagMinRange=a-2>0?a-2:1,e.pagMaxRange=a+2,e.pagination.page=a,g()},s=function(){return e.pagHideMinRange===!0||e.pagMinRange<1?!1:(e.pagMaxRange=e.pagMinRange,e.pagMinRange=e.pagMaxRange-e.numPaginations,void g())},p=function(){return e.pagHideMaxRange===!0||e.pagMaxRange>e.pagination.pages?!1:(e.pagMinRange=e.pagMaxRange,e.pagMaxRange=e.pagMinRange+e.numPaginations,e.pagMaxRange>e.pagination.pages&&(e.pagMaxRange=e.pagination.pages),e.pagMinRange=e.pagMaxRange-e.numPaginations,void g())},g=function(){e.pagMinRange=e.pagMinRange>0?e.pagMinRange:1,e.pagMaxRange=e.pagMinRange+e.numPaginations,e.pagMaxRange>e.pagination.pages&&(e.pagMaxRange=e.pagination.pages+1),e.pagHideMinRange=e.pagMinRange<=1,e.pagHideMaxRange=e.pagMaxRange>=e.pagination.pages,e.pagListCount=e.pagination.size<50?[5,25]:e.pagination.size<100?[5,25,50]:[5,25,50,100],e.rangePage=c(e.pagMinRange,e.pagMaxRange)},e.page={get:r,setCount:i,previous:s,remaining:p},t.$scope.$watch("resourcePagination",function(a,n){a&&a!==n&&(e.pagination={count:a.count,page:a.page,pages:a.pages,size:a.size},o())})}}}); \ No newline at end of file diff --git a/template/table/head.html b/template/table/head.html new file mode 100644 index 0000000..89110a3 --- /dev/null +++ b/template/table/head.html @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/template/table/pagination.html b/template/table/pagination.html new file mode 100644 index 0000000..f8fa727 --- /dev/null +++ b/template/table/pagination.html @@ -0,0 +1,31 @@ +
+
+
+ +
+
+
+ +
+
+

Page + of , + of entries

+
+
\ No newline at end of file