Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
32448265
Commit
32448265
authored
Nov 20, 2016
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert pager.js to es6 syntax
parent
23a8b687
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
36 deletions
+28
-36
app/assets/javascripts/pager.js.es6
app/assets/javascripts/pager.js.es6
+28
-36
No files found.
app/assets/javascripts/pager.js.es6
View file @
32448265
/* eslint-disable func-names, space-before-function-paren, object-shorthand, quotes, no-undef, prefer-template, wrap-iife, comma-dangle, no-return-assign, no-else-return, consistent-return, no-unused-vars, padded-blocks, max-len */
(() => {
(function() {
const Pager = {
this.Pager = {
init(limit, preload, disable, callback) {
init: function(limit, preload, disable, callback) {
this.limit = limit != null ? limit : 0;
this.limit = limit != null ? limit : 0;
this.disable = disable != null ? disable : false;
this.disable = disable != null ? disable : false;
this.callback = callback != null ? callback : $.noop;
this.callback = callback != null ? callback : $.noop;
...
@@ -12,53 +11,46 @@
...
@@ -12,53 +11,46 @@
} else {
} else {
this.offset = this.limit;
this.offset = this.limit;
}
}
return
this.initLoadMore();
this.initLoadMore();
},
},
getOld
: function
() {
getOld() {
this.loading.show();
this.loading.show();
return $.ajax({
$.ajax({
type: "GET",
type: 'GET',
url: $(".content_list").data('href') || location.href,
url: $('.content_list').data('href') || window.location.href,
data: "limit=" + this.limit + "&offset=" + this.offset,
data: `limit=${this.limit}&offset=${this.offset}`,
complete: (function(_this) {
complete: () => this.loading.hide(),
return function() {
success: (data) => {
return _this.loading.hide();
};
})(this),
success: function(data) {
Pager.append(data.count, data.html);
Pager.append(data.count, data.html);
return
Pager.callback();
Pager.callback();
},
},
dataType:
"json"
dataType:
'json',
});
});
},
},
append
: function
(count, html) {
append(count, html) {
$(
".content_list"
).append(html);
$(
'.content_list'
).append(html);
if (count > 0) {
if (count > 0) {
return
this.offset += count;
this.offset += count;
} else {
} else {
return
this.disable = true;
this.disable = true;
}
}
},
},
initLoadMore
: function
() {
initLoadMore() {
$(document).unbind('scroll');
$(document).unbind('scroll');
return
$(document).endlessScroll({
$(document).endlessScroll({
bottomPixels: 400,
bottomPixels: 400,
fireDelay: 1000,
fireDelay: 1000,
fireOnce: true,
fireOnce: true,
ceaseFire: function() {
ceaseFire: () => Pager.disable !== true,
return Pager.disable;
callback: () => {
},
if (!this.loading.is(':visible')) {
callback: (function(_this) {
this.loading.show();
return function(i) {
Pager.getOld();
if (!_this.loading.is(':visible')) {
_this.loading.show();
return Pager.getOld();
}
}
};
},
})(this)
});
});
}
}
,
};
};
}).call(this);
window.Pager = Pager;
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment