Commit a18a7c52 authored by Hugh Davenport's avatar Hugh Davenport Committed by Gerrit Code Review
Browse files

Merge "Remember current page when changing limit (Bug #1017280)"

parents f29ebbc1 7022d96a
......@@ -65,6 +65,7 @@ var Paginator = function(id, datatable, script, extradata) {
// If there is a form for choosing page size(page limit)
if (setlimitform) {
var setlimitselect = getFirstElementByTagAndClassName('select', 'pagination', setlimitform);
var currentoffset = getFirstElementByTagAndClassName('input', 'currentoffset', setlimitform);
connect (setlimitselect, 'onchange', function(e) {
e.stop();
......@@ -75,7 +76,8 @@ var Paginator = function(id, datatable, script, extradata) {
else {
url += "?";
}
url += this.name + "=" + this.value;
url += setlimitselect.name + "=" + setlimitselect.value;
url += "&" + currentoffset.name + "=" + currentoffset.value;
location.assign(url);
});
}
......@@ -86,6 +88,7 @@ var Paginator = function(id, datatable, script, extradata) {
// If there is a form for choosing page size(page limit)
if (setlimitform) {
var setlimitselect = getFirstElementByTagAndClassName('select', 'pagination', setlimitform);
var currentoffset = getFirstElementByTagAndClassName('input', 'currentoffset', setlimitform);
connect (setlimitselect, 'onchange', function(e) {
e.stop();
......@@ -94,6 +97,7 @@ var Paginator = function(id, datatable, script, extradata) {
var queryData = [];
if (loc != -1) {
queryData = parseQueryString(url.substring(loc + 1, url.length));
queryData.offset = currentoffset.value;
queryData.setlimit = "1";
queryData.limit = setlimitselect.value;
queryData.extradata = serializeJSON(self.extraData);
......
......@@ -3408,6 +3408,7 @@ function build_pagination($params) {
'<select id="setlimitselect" class="pagination" name="limit"> '.
join(' ', $strlimitoptions) .
'</select>
<input class="currentoffset" type="hidden" name="' . $params['offsetname'] . '" value="' . $params['offset'] . '"/>
<input class="pagination js-hidden" type="submit" name="submit" value="' . get_string('change') . '"/>
</form>';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment