-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pagination on changes page
- Loading branch information
Showing
7 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
(function() { | ||
"use strict"; | ||
|
||
var nsot = window.nsot = nsot || {}; | ||
|
||
nsot.Pager = function(offset, limit, total, $location) { | ||
this.offset = offset; | ||
this.limit = limit; | ||
this.total = total; | ||
this.$location = $location; | ||
|
||
this.page = (offset + limit) / limit; | ||
this.numPages = Math.ceil(total/limit); | ||
|
||
this.hasFirst = function(){ | ||
return this.offset !== 0; | ||
} | ||
|
||
this.hasPrevious = function(){ | ||
return this.offset !== 0; | ||
} | ||
|
||
this.hasNext = function(){ | ||
return this.offset + this.limit < this.total; | ||
} | ||
|
||
this.hasLast = function(){ | ||
return this.offset + this.limit < this.total; | ||
} | ||
|
||
this.firstPage = function(){ | ||
return 0; | ||
} | ||
|
||
this.previousPage = function(){ | ||
return this.offset - this.limit; | ||
} | ||
|
||
this.nextPage = function(){ | ||
return this.offset + this.limit; | ||
} | ||
|
||
this.lastPage = function(){ | ||
return (this.numPages - 1) * this.limit; | ||
} | ||
|
||
this.firstPageUrl = function(){ | ||
return "?" + $.param(_.defaults( | ||
{"offset": this.firstPage()}, | ||
this.$location.search() | ||
)); | ||
} | ||
|
||
this.previousPageUrl = function(){ | ||
return "?" + $.param(_.defaults( | ||
{"offset": this.previousPage()}, | ||
this.$location.search() | ||
)); | ||
} | ||
|
||
this.nextPageUrl = function(){ | ||
return "?" + $.param(_.defaults( | ||
{"offset": this.nextPage()}, | ||
this.$location.search() | ||
)); | ||
} | ||
|
||
this.lastPageUrl = function(){ | ||
return "?" + $.param(_.defaults( | ||
{"offset": this.lastPage()}, | ||
this.$location.search() | ||
)); | ||
} | ||
} | ||
|
||
nsot.Limiter = function(limit, $location) { | ||
|
||
this.name = "Limit" | ||
this.current = limit; | ||
this.values = [10, 25, 50, 100]; | ||
this.$location = $location; | ||
|
||
this.getUrl = function(value){ | ||
return "?" + $.param(_.defaults( | ||
{"limit": value}, this.$location.search() | ||
)); | ||
} | ||
} | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="btn-group"> | ||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> | ||
<span ng-if="ctxtObj.current">[[ctxtObj.name]]: [[ctxtObj.current]]</span> | ||
<span ng-if="!ctxtObj.current">[[ctxtObj.name]]</span> | ||
<span class="caret"></span> | ||
</button> | ||
<ul class="dropdown-menu" role="menu"> | ||
<li ng-repeat="value in ctxtObj.values"> | ||
<a ng-href="[[ctxtObj.getUrl(value)]]">[[value]]</a> | ||
</li> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div ng-if="pager.limit" class="btn-group" style="padding-right: 10px;"> | ||
|
||
|
||
<a ng-disabled="!pager.hasFirst()" class="btn btn-default" ng-href="[[pager.firstPageUrl()]]"> | ||
<i class="fa fa-angle-double-left"></i> | ||
</a> | ||
|
||
<a ng-disabled="!pager.hasPrevious()" class="btn btn-default" ng-href="[[pager.previousPageUrl()]]"> | ||
<i class="fa fa-angle-left"></i> | ||
</a> | ||
|
||
<a class="btn btn-default disabled">Page [[pager.page]] of [[pager.numPages]]</a> | ||
|
||
<a ng-disabled="!pager.hasNext()" class="btn btn-default" ng-href="[[pager.nextPageUrl()]]"> | ||
<i class="fa fa-angle-right"></i> | ||
</a> | ||
|
||
<a ng-disabled="!pager.hasLast()" class="btn btn-default" ng-href="[[pager.lastPageUrl()]]"> | ||
<i class="fa fa-angle-double-right"></i> | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters