@@ -229,229 +229,3 @@ angular.module('ui.bootstrap.pagination', [])
229
229
}
230
230
} ;
231
231
} ] ) ;
232
-
233
- /* Deprecated Pagination Below */
234
-
235
- angular . module ( 'ui.bootstrap.pagination' )
236
- . value ( '$paginationSuppressWarning' , false )
237
- . controller ( 'PaginationController' , [ '$scope' , '$attrs' , '$parse' , '$log' , '$paginationSuppressWarning' , function ( $scope , $attrs , $parse , $log , $paginationSuppressWarning ) {
238
- if ( ! $paginationSuppressWarning ) {
239
- $log . warn ( 'PaginationController is now deprecated. Use UibPaginationController instead.' ) ;
240
- }
241
-
242
- var self = this ,
243
- ngModelCtrl = { $setViewValue : angular . noop } , // nullModelCtrl
244
- setNumPages = $attrs . numPages ? $parse ( $attrs . numPages ) . assign : angular . noop ;
245
-
246
- this . init = function ( ngModelCtrl_ , config ) {
247
- ngModelCtrl = ngModelCtrl_ ;
248
- this . config = config ;
249
-
250
- ngModelCtrl . $render = function ( ) {
251
- self . render ( ) ;
252
- } ;
253
-
254
- if ( $attrs . itemsPerPage ) {
255
- $scope . $parent . $watch ( $parse ( $attrs . itemsPerPage ) , function ( value ) {
256
- self . itemsPerPage = parseInt ( value , 10 ) ;
257
- $scope . totalPages = self . calculateTotalPages ( ) ;
258
- } ) ;
259
- } else {
260
- this . itemsPerPage = config . itemsPerPage ;
261
- }
262
-
263
- $scope . $watch ( 'totalItems' , function ( ) {
264
- $scope . totalPages = self . calculateTotalPages ( ) ;
265
- } ) ;
266
-
267
- $scope . $watch ( 'totalPages' , function ( value ) {
268
- setNumPages ( $scope . $parent , value ) ; // Readonly variable
269
-
270
- if ( $scope . page > value ) {
271
- $scope . selectPage ( value ) ;
272
- } else {
273
- ngModelCtrl . $render ( ) ;
274
- }
275
- } ) ;
276
- } ;
277
-
278
- this . calculateTotalPages = function ( ) {
279
- var totalPages = this . itemsPerPage < 1 ? 1 : Math . ceil ( $scope . totalItems / this . itemsPerPage ) ;
280
- return Math . max ( totalPages || 0 , 1 ) ;
281
- } ;
282
-
283
- this . render = function ( ) {
284
- $scope . page = parseInt ( ngModelCtrl . $viewValue , 10 ) || 1 ;
285
- } ;
286
-
287
- $scope . selectPage = function ( page , evt ) {
288
- if ( evt ) {
289
- evt . preventDefault ( ) ;
290
- }
291
-
292
- var clickAllowed = ! $scope . ngDisabled || ! evt ;
293
- if ( clickAllowed && $scope . page !== page && page > 0 && page <= $scope . totalPages ) {
294
- if ( evt && evt . target ) {
295
- evt . target . blur ( ) ;
296
- }
297
- ngModelCtrl . $setViewValue ( page ) ;
298
- ngModelCtrl . $render ( ) ;
299
- }
300
- } ;
301
-
302
- $scope . getText = function ( key ) {
303
- return $scope [ key + 'Text' ] || self . config [ key + 'Text' ] ;
304
- } ;
305
-
306
- $scope . noPrevious = function ( ) {
307
- return $scope . page === 1 ;
308
- } ;
309
-
310
- $scope . noNext = function ( ) {
311
- return $scope . page === $scope . totalPages ;
312
- } ;
313
- } ] )
314
- . directive ( 'pagination' , [ '$parse' , 'uibPaginationConfig' , '$log' , '$paginationSuppressWarning' , function ( $parse , paginationConfig , $log , $paginationSuppressWarning ) {
315
- return {
316
- restrict : 'EA' ,
317
- scope : {
318
- totalItems : '=' ,
319
- firstText : '@' ,
320
- previousText : '@' ,
321
- nextText : '@' ,
322
- lastText : '@' ,
323
- ngDisabled :'='
324
- } ,
325
- require : [ 'pagination' , '?ngModel' ] ,
326
- controller : 'PaginationController' ,
327
- controllerAs : 'pagination' ,
328
- templateUrl : function ( element , attrs ) {
329
- return attrs . templateUrl || 'template/pagination/pagination.html' ;
330
- } ,
331
- replace : true ,
332
- link : function ( scope , element , attrs , ctrls ) {
333
- if ( ! $paginationSuppressWarning ) {
334
- $log . warn ( 'pagination is now deprecated. Use uib-pagination instead.' ) ;
335
- }
336
- var paginationCtrl = ctrls [ 0 ] , ngModelCtrl = ctrls [ 1 ] ;
337
-
338
- if ( ! ngModelCtrl ) {
339
- return ; // do nothing if no ng-model
340
- }
341
-
342
- // Setup configuration parameters
343
- var maxSize = angular . isDefined ( attrs . maxSize ) ? scope . $parent . $eval ( attrs . maxSize ) : paginationConfig . maxSize ,
344
- rotate = angular . isDefined ( attrs . rotate ) ? scope . $parent . $eval ( attrs . rotate ) : paginationConfig . rotate ;
345
- scope . boundaryLinks = angular . isDefined ( attrs . boundaryLinks ) ? scope . $parent . $eval ( attrs . boundaryLinks ) : paginationConfig . boundaryLinks ;
346
- scope . directionLinks = angular . isDefined ( attrs . directionLinks ) ? scope . $parent . $eval ( attrs . directionLinks ) : paginationConfig . directionLinks ;
347
-
348
- paginationCtrl . init ( ngModelCtrl , paginationConfig ) ;
349
-
350
- if ( attrs . maxSize ) {
351
- scope . $parent . $watch ( $parse ( attrs . maxSize ) , function ( value ) {
352
- maxSize = parseInt ( value , 10 ) ;
353
- paginationCtrl . render ( ) ;
354
- } ) ;
355
- }
356
-
357
- // Create page object used in template
358
- function makePage ( number , text , isActive ) {
359
- return {
360
- number : number ,
361
- text : text ,
362
- active : isActive
363
- } ;
364
- }
365
-
366
- function getPages ( currentPage , totalPages ) {
367
- var pages = [ ] ;
368
-
369
- // Default page limits
370
- var startPage = 1 , endPage = totalPages ;
371
- var isMaxSized = angular . isDefined ( maxSize ) && maxSize < totalPages ;
372
-
373
- // recompute if maxSize
374
- if ( isMaxSized ) {
375
- if ( rotate ) {
376
- // Current page is displayed in the middle of the visible ones
377
- startPage = Math . max ( currentPage - Math . floor ( maxSize / 2 ) , 1 ) ;
378
- endPage = startPage + maxSize - 1 ;
379
-
380
- // Adjust if limit is exceeded
381
- if ( endPage > totalPages ) {
382
- endPage = totalPages ;
383
- startPage = endPage - maxSize + 1 ;
384
- }
385
- } else {
386
- // Visible pages are paginated with maxSize
387
- startPage = ( ( Math . ceil ( currentPage / maxSize ) - 1 ) * maxSize ) + 1 ;
388
-
389
- // Adjust last page if limit is exceeded
390
- endPage = Math . min ( startPage + maxSize - 1 , totalPages ) ;
391
- }
392
- }
393
-
394
- // Add page number links
395
- for ( var number = startPage ; number <= endPage ; number ++ ) {
396
- var page = makePage ( number , number , number === currentPage ) ;
397
- pages . push ( page ) ;
398
- }
399
-
400
- // Add links to move between page sets
401
- if ( isMaxSized && ! rotate ) {
402
- if ( startPage > 1 ) {
403
- var previousPageSet = makePage ( startPage - 1 , '...' , false ) ;
404
- pages . unshift ( previousPageSet ) ;
405
- }
406
-
407
- if ( endPage < totalPages ) {
408
- var nextPageSet = makePage ( endPage + 1 , '...' , false ) ;
409
- pages . push ( nextPageSet ) ;
410
- }
411
- }
412
-
413
- return pages ;
414
- }
415
-
416
- var originalRender = paginationCtrl . render ;
417
- paginationCtrl . render = function ( ) {
418
- originalRender ( ) ;
419
- if ( scope . page > 0 && scope . page <= scope . totalPages ) {
420
- scope . pages = getPages ( scope . page , scope . totalPages ) ;
421
- }
422
- } ;
423
- }
424
- } ;
425
- } ] )
426
-
427
- . directive ( 'pager' , [ 'uibPagerConfig' , '$log' , '$paginationSuppressWarning' , function ( pagerConfig , $log , $paginationSuppressWarning ) {
428
- return {
429
- restrict : 'EA' ,
430
- scope : {
431
- totalItems : '=' ,
432
- previousText : '@' ,
433
- nextText : '@' ,
434
- ngDisabled : '='
435
- } ,
436
- require : [ 'pager' , '?ngModel' ] ,
437
- controller : 'PaginationController' ,
438
- controllerAs : 'pagination' ,
439
- templateUrl : function ( element , attrs ) {
440
- return attrs . templateUrl || 'template/pagination/pager.html' ;
441
- } ,
442
- replace : true ,
443
- link : function ( scope , element , attrs , ctrls ) {
444
- if ( ! $paginationSuppressWarning ) {
445
- $log . warn ( 'pager is now deprecated. Use uib-pager instead.' ) ;
446
- }
447
- var paginationCtrl = ctrls [ 0 ] , ngModelCtrl = ctrls [ 1 ] ;
448
-
449
- if ( ! ngModelCtrl ) {
450
- return ; // do nothing if no ng-model
451
- }
452
-
453
- scope . align = angular . isDefined ( attrs . align ) ? scope . $parent . $eval ( attrs . align ) : pagerConfig . align ;
454
- paginationCtrl . init ( ngModelCtrl , pagerConfig ) ;
455
- }
456
- } ;
457
- } ] ) ;
0 commit comments