diff --git a/src/paging.js b/src/paging.js index 249d7c2..32fc022 100644 --- a/src/paging.js +++ b/src/paging.js @@ -18,7 +18,7 @@ angular.module('bw.paging', []).directive('paging', function () { * Feel free to tweak / fork values for your application */ var regex = /\{page\}/g; - + /** * The angular return value required for the directive @@ -31,7 +31,7 @@ angular.module('bw.paging', []).directive('paging', function () { // Assign the angular link function link: fieldLink, - + // Assign the angular directive template HTML template: fieldTemplate, @@ -60,9 +60,11 @@ angular.module('bw.paging', []).directive('paging', function () { textTitleFirst: '@', textTitleLast: '@', textTitleNext: '@', - textTitlePrev: '@' + textTitlePrev: '@', + defaultLiClass: '@', + defaultAClass: '@', } - + }; @@ -80,12 +82,12 @@ angular.module('bw.paging', []).directive('paging', function () { build(scope, attrs); }); } - - + + /** - * Create our template html + * Create our template html * We use a function to figure out how to handle href correctly - * + * * @param {object} el - Angular link element * @param {object} attrs - Angular link attribute */ @@ -95,14 +97,14 @@ angular.module('bw.paging', []).directive('paging', function () { 'title="{{Item.title}}" ' + 'data-ng-class="Item.liClass" ' + 'data-ng-repeat="Item in List"> ' + - ''+ + 'data-ng-bind="Item.value">'+ ' ' + '' + - '' + '' } @@ -117,14 +119,14 @@ angular.module('bw.paging', []).directive('paging', function () { scope.List = []; scope.Hide = false; - + scope.page = parseInt(scope.page) || 1; scope.total = parseInt(scope.total) || 0; scope.adjacent = parseInt(scope.adjacent) || 2; scope.pgHref = scope.pgHref || ''; scope.dots = scope.dots || '...'; - + scope.ulClass = scope.ulClass || 'pagination'; scope.activeClass = scope.activeClass || 'active'; scope.disabledClass = scope.disabledClass || 'disabled'; @@ -133,17 +135,17 @@ angular.module('bw.paging', []).directive('paging', function () { scope.textLast = scope.textLast || '>>'; scope.textNext = scope.textNext || '>'; scope.textPrev = scope.textPrev || '<'; - + scope.textFirstClass = scope.textFirstClass || ''; scope.textLastClass= scope.textLastClass || ''; scope.textNextClass = scope.textNextClass || ''; scope.textPrevClass = scope.textPrevClass || ''; scope.textTitlePage = scope.textTitlePage || 'Page {page}'; - scope.textTitleFirst = scope.textTitleFirst || 'First Page'; - scope.textTitleLast = scope.textTitleLast || 'Last Page'; - scope.textTitleNext = scope.textTitleNext || 'Next Page'; - scope.textTitlePrev = scope.textTitlePrev || 'Previous Page'; + scope.textTitleFirst = scope.textTitleFirst || 'First Page'; + scope.textTitleLast = scope.textTitleLast || 'Last Page'; + scope.textTitleNext = scope.textTitleNext || 'Next Page'; + scope.textTitlePrev = scope.textTitlePrev || 'Previous Page'; scope.hideIfEmpty = evalBoolAttribute(scope, attrs.hideIfEmpty); scope.showPrevNext = evalBoolAttribute(scope, attrs.showPrevNext); @@ -156,7 +158,7 @@ angular.module('bw.paging', []).directive('paging', function () { /** * A helper to perform our boolean eval on attributes * This allows flexibility in the attribute for strings and variables in scope - * + * * @param {Object} scope - The local directive scope object * @param {Object} value - The attribute value of interest */ @@ -212,7 +214,7 @@ angular.module('bw.paging', []).directive('paging', function () { return; } - // Block if we are forcing disabled + // Block if we are forcing disabled if(scope.isDisabled) { return; @@ -266,19 +268,19 @@ angular.module('bw.paging', []).directive('paging', function () { if(scope.showFirstLast){ alpha = { value: scope.textFirst, - title: scope.textTitleFirst, + title: scope.textTitleFirst, aClass: scope.textFirstClass, page: 1 - }; + }; } if(scope.showPrevNext){ beta = { value: scope.textPrev, - title: scope.textTitlePrev, + title: scope.textTitlePrev, aClass: scope.textPrevClass, page: prevPage - }; + }; } } else { @@ -289,37 +291,37 @@ angular.module('bw.paging', []).directive('paging', function () { if(scope.showPrevNext){ alpha = { value: scope.textNext, - title: scope.textTitleNext, + title: scope.textTitleNext, aClass: scope.textNextClass, page: nextPage - }; + }; } - + if(scope.showFirstLast){ beta = { value: scope.textLast, - title: scope.textTitleLast, + title: scope.textTitleLast, aClass: scope.textLastClass, page: pageCount - }; + }; } - + } // Create the Add Item Function var buildItem = function (item, disabled) { return { title: item.title, - aClass: item.aClass, + aClass: item.aClass + ' ' + scope.defaultAClass, value: item.aClass ? '' : item.value, - liClass: disabled ? scope.disabledClass : '', + liClass: (disabled ? scope.disabledClass : '') + ' ' + scope.defaultLiClass, pgHref: disabled ? '' : scope.pgHref.replace(regex, item.page), action: function () { if (!disabled) { internalAction(scope, item.page); } } - }; + }; }; // Force disabled if specified @@ -330,13 +332,13 @@ angular.module('bw.paging', []).directive('paging', function () { // Add alpha items if(alpha){ var alphaItem = buildItem(alpha, disabled); - scope.List.push(alphaItem); + scope.List.push(alphaItem); } - + // Add beta items if(beta){ var betaItem = buildItem(beta, disabled); - scope.List.push(betaItem); + scope.List.push(betaItem); } } @@ -350,13 +352,13 @@ angular.module('bw.paging', []).directive('paging', function () { * @param {Object} scope - The local directive scope object */ function addRange(start, finish, scope) { - + // Add our items where i is the page number var i = 0; for (i = start; i <= finish; i++) { var pgHref = scope.pgHref.replace(regex, i); - var liClass = scope.page == i ? scope.activeClass : ''; + var liClass = (scope.page == i ? scope.activeClass : '') + ' ' + scope.defaultLiClass; // Handle items that are affected by disabled if(scope.isDisabled){ @@ -370,6 +372,7 @@ angular.module('bw.paging', []).directive('paging', function () { title: scope.textTitlePage.replace(regex, i), liClass: liClass, pgHref: pgHref, + aClass: scope.defaultAClass, action: function () { internalAction(scope, this.value); } @@ -387,6 +390,7 @@ angular.module('bw.paging', []).directive('paging', function () { function addDots(scope) { scope.List.push({ value: scope.dots, + aClass: scope.defaultAClass, liClass: scope.disabledClass }); }