@@ -40,6 +40,7 @@ angular.module('bw.paging', []).directive('paging', function () {
4040 page : '=' ,
4141 pageSize : '=' ,
4242 total : '=' ,
43+ disabled : '@' ,
4344 dots : '@' ,
4445 ulClass : '@' ,
4546 activeClass : '@' ,
@@ -75,7 +76,7 @@ angular.module('bw.paging', []).directive('paging', function () {
7576 function fieldLink ( scope , el , attrs ) {
7677
7778 // Hook in our watched items
78- scope . $watchCollection ( '[page,pageSize,total]' , function ( ) {
79+ scope . $watchCollection ( '[page,pageSize,total,disabled ]' , function ( ) {
7980 build ( scope , attrs ) ;
8081 } ) ;
8182 }
@@ -147,7 +148,8 @@ angular.module('bw.paging', []).directive('paging', function () {
147148 scope . hideIfEmpty = evalBoolAttribute ( scope , attrs . hideIfEmpty ) ;
148149 scope . showPrevNext = evalBoolAttribute ( scope , attrs . showPrevNext ) ;
149150 scope . showFirstLast = evalBoolAttribute ( scope , attrs . showFirstLast ) ;
150- scope . scrollTop = evalBoolAttribute ( scope , attrs . scrollTop )
151+ scope . scrollTop = evalBoolAttribute ( scope , attrs . scrollTop ) ;
152+ scope . isDisabled = evalBoolAttribute ( scope , attrs . disabled ) ;
151153 }
152154
153155
@@ -210,6 +212,12 @@ angular.module('bw.paging', []).directive('paging', function () {
210212 return ;
211213 }
212214
215+ // Block if we are forcing disabled
216+ if ( scope . isDisabled )
217+ {
218+ return ;
219+ }
220+
213221 // Update the page in scope
214222 scope . page = page ;
215223
@@ -301,11 +309,11 @@ angular.module('bw.paging', []).directive('paging', function () {
301309 // Create the Add Item Function
302310 var buildItem = function ( item , disabled ) {
303311 return {
304- value : item . aClass ? '' : item . value ,
305312 title : item . title ,
306- liClass : disabled ? scope . disabledClass : '' ,
307313 aClass : item . aClass ,
308- pgHref : scope . pgHref . replace ( regex , item . page ) ,
314+ value : item . aClass ? '' : item . value ,
315+ liClass : disabled ? scope . disabledClass : '' ,
316+ pgHref : disabled ? '' : scope . pgHref . replace ( regex , item . page ) ,
309317 action : function ( ) {
310318 if ( ! disabled ) {
311319 internalAction ( scope , item . page ) ;
@@ -314,6 +322,11 @@ angular.module('bw.paging', []).directive('paging', function () {
314322 } ;
315323 } ;
316324
325+ // Force disabled if specified
326+ if ( scope . isDisabled ) {
327+ disabled = true ;
328+ }
329+
317330 // Add alpha items
318331 if ( alpha ) {
319332 var alphaItem = buildItem ( alpha , disabled ) ;
@@ -341,11 +354,22 @@ angular.module('bw.paging', []).directive('paging', function () {
341354 // Add our items where i is the page number
342355 var i = 0 ;
343356 for ( i = start ; i <= finish ; i ++ ) {
357+
358+ var pgHref = scope . pgHref . replace ( regex , i ) ;
359+ var liClass = scope . page == i ? scope . activeClass : '' ;
360+
361+ // Handle items that are affected by disabled
362+ if ( scope . isDisabled ) {
363+ pgHref = '' ;
364+ liClass = scope . disabledClass ;
365+ }
366+
367+
344368 scope . List . push ( {
345369 value : i ,
346370 title : scope . textTitlePage . replace ( regex , i ) ,
347- liClass : scope . page == i ? scope . activeClass : '' ,
348- pgHref : scope . pgHref . replace ( regex , i ) ,
371+ liClass : liClass ,
372+ pgHref : pgHref ,
349373 action : function ( ) {
350374 internalAction ( scope , this . value ) ;
351375 }
0 commit comments