Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/blob/utils.js')
-rw-r--r--app/assets/javascripts/blob/utils.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/app/assets/javascripts/blob/utils.js b/app/assets/javascripts/blob/utils.js
index bbc061dd36e..b2400a4b224 100644
--- a/app/assets/javascripts/blob/utils.js
+++ b/app/assets/javascripts/blob/utils.js
@@ -1,16 +1,18 @@
-import Editor from '~/editor/source_editor';
+import { getBaseURL } from '~/lib/utils/url_utility';
-export function initSourceEditor({ el, ...args }) {
- const editor = new Editor({
- scrollbar: {
- alwaysConsumeMouseWheel: false,
- },
- });
+const blameLinesPerPage = document.querySelector('.js-per-page')?.dataset?.blamePerPage;
- return editor.createInstance({
- el,
- ...args,
- });
-}
+export const getPageParamValue = (lineNum, blamePerPage = blameLinesPerPage) => {
+ if (!blamePerPage) return '';
+ const page = Math.ceil(parseInt(lineNum, 10) / parseInt(blamePerPage, 10));
+ return page <= 1 ? '' : page;
+};
+
+export const getPageSearchString = (path, page) => {
+ if (!page) return '';
+ const url = new URL(path, getBaseURL());
+ url.searchParams.set('page', page);
+ return url.search;
+};
export default () => ({});