@@ -290,10 +290,12 @@ var RefreshTokenView = Backbone.View.extend({
290
290
// hide it
291
291
$ ( '.moreInformation' , this . el ) . hide ( 'fast' ) ;
292
292
$ ( '.toggleMoreInformation i' , this . el ) . attr ( 'class' , 'icon-chevron-right' ) ;
293
+ $ ( '.moreInformationContainer' , this . el ) . removeClass ( 'alert' ) . removeClass ( 'alert-info' ) . addClass ( 'muted' ) ;
293
294
} else {
294
295
// show it
295
296
$ ( '.moreInformation' , this . el ) . show ( 'fast' ) ;
296
297
$ ( '.toggleMoreInformation i' , this . el ) . attr ( 'class' , 'icon-chevron-down' ) ;
298
+ $ ( '.moreInformationContainer' , this . el ) . addClass ( 'alert' ) . addClass ( 'alert-info' ) . removeClass ( 'muted' ) ;
297
299
}
298
300
299
301
} ,
@@ -314,7 +316,9 @@ var TokenListView = Backbone.View.extend({
314
316
tagName : 'span' ,
315
317
316
318
events :{
317
- "click .refresh-table" :"refreshTable"
319
+ "click .refresh-table" :"refreshTable" ,
320
+ 'page .paginator-access' :'changePageAccess' ,
321
+ 'page .paginator-refresh' :'changePageRefresh'
318
322
} ,
319
323
320
324
load :function ( callback ) {
@@ -344,6 +348,28 @@ var TokenListView = Backbone.View.extend({
344
348
345
349
} ,
346
350
351
+ changePageAccess :function ( event , num ) {
352
+ $ ( '.paginator-access' , this . el ) . bootpag ( { page : num } ) ;
353
+ $ ( '#access-token-table tbody tr' , this . el ) . each ( function ( index , element ) {
354
+ if ( Math . ceil ( ( index + 1 ) / 10 ) != num ) {
355
+ $ ( element ) . hide ( ) ;
356
+ } else {
357
+ $ ( element ) . show ( ) ;
358
+ }
359
+ } ) ;
360
+ } ,
361
+
362
+ changePageRefresh :function ( event , num ) {
363
+ $ ( '.paginator-refresh' , this . el ) . bootpag ( { page : num } ) ;
364
+ $ ( '#refresh-token-table tbody tr' , this . el ) . each ( function ( index , element ) {
365
+ if ( Math . ceil ( ( index + 1 ) / 10 ) != num ) {
366
+ $ ( element ) . hide ( ) ;
367
+ } else {
368
+ $ ( element ) . show ( ) ;
369
+ }
370
+ } ) ;
371
+ } ,
372
+
347
373
refreshTable :function ( e ) {
348
374
e . preventDefault ( ) ;
349
375
$ ( '#loadingbox' ) . sheet ( 'show' ) ;
@@ -387,19 +413,49 @@ var TokenListView = Backbone.View.extend({
387
413
388
414
var _self = this ;
389
415
390
- _ . each ( this . model . access . models , function ( token ) {
416
+ // set up pagination
417
+ var numPagesAccess = Math . ceil ( this . model . access . length / 10 ) ;
418
+ if ( numPagesAccess > 1 ) {
419
+ $ ( '.paginator-access' , this . el ) . show ( ) ;
420
+ $ ( '.paginator-access' , this . el ) . bootpag ( {
421
+ total : numPagesAccess ,
422
+ page : 1
423
+ } ) ;
424
+ } else {
425
+ $ ( '.paginator-access' , this . el ) . hide ( ) ;
426
+ }
427
+
428
+ _ . each ( this . model . access . models , function ( token , index ) {
391
429
// look up client
392
430
var client = _self . options . clientList . getByClientId ( token . get ( 'clientId' ) ) ;
393
-
394
- $ ( '#access-token-table' , _self . el ) . append ( new AccessTokenView ( { model : token , client : client , systemScopeList : _self . options . systemScopeList } ) . render ( ) . el ) ;
431
+ var element = new AccessTokenView ( { model : token , client : client , systemScopeList : _self . options . systemScopeList } ) . render ( ) . el ;
432
+ $ ( '#access-token-table' , _self . el ) . append ( element ) ;
433
+ if ( Math . ceil ( ( index + 1 ) / 10 ) != 1 ) {
434
+ $ ( element ) . hide ( ) ;
435
+ }
395
436
396
437
} ) ;
397
438
398
- _ . each ( this . model . refresh . models , function ( token ) {
439
+ // set up pagination
440
+ var numPagesRefresh = Math . ceil ( this . model . refresh . length / 10 ) ;
441
+ if ( numPagesRefresh > 1 ) {
442
+ $ ( '.paginator-refresh' , this . el ) . show ( ) ;
443
+ $ ( '.paginator-refresh' , this . el ) . bootpag ( {
444
+ total : numPagesRefresh ,
445
+ page : 1
446
+ } ) ;
447
+ } else {
448
+ $ ( '.paginator-refresh' , this . el ) . hide ( ) ;
449
+ }
450
+
451
+ _ . each ( this . model . refresh . models , function ( token , index ) {
399
452
// look up client
400
453
var client = _self . options . clientList . getByClientId ( token . get ( 'clientId' ) ) ;
401
-
402
- $ ( '#refresh-token-table' , _self . el ) . append ( new RefreshTokenView ( { model : token , client : client , systemScopeList : _self . options . systemScopeList } ) . render ( ) . el ) ;
454
+ var element = new RefreshTokenView ( { model : token , client : client , systemScopeList : _self . options . systemScopeList } ) . render ( ) . el ;
455
+ $ ( '#refresh-token-table' , _self . el ) . append ( element ) ;
456
+ if ( Math . ceil ( ( index + 1 ) / 10 ) != 1 ) {
457
+ $ ( element ) . hide ( ) ;
458
+ }
403
459
404
460
} ) ;
405
461
0 commit comments