Commit 8796d17a authored by Mike Greiling's avatar Mike Greiling

remove IIFEs in preparation for ES module refactor

parent 1585608b
/* eslint-disable no-param-reassign */ const MAX_MESSAGE_LENGTH = 500;
const MESSAGE_CELL_SELECTOR = '.abuse-reports .message';
((global) => { class AbuseReports {
const MAX_MESSAGE_LENGTH = 500;
const MESSAGE_CELL_SELECTOR = '.abuse-reports .message';
class AbuseReports {
constructor() { constructor() {
$(MESSAGE_CELL_SELECTOR).each(this.truncateLongMessage); $(MESSAGE_CELL_SELECTOR).each(this.truncateLongMessage);
$(document) $(document)
...@@ -34,7 +31,7 @@ ...@@ -34,7 +31,7 @@
$messageCellElement.text(`${originalMessage.substr(0, (MAX_MESSAGE_LENGTH - 3))}...`); $messageCellElement.text(`${originalMessage.substr(0, (MAX_MESSAGE_LENGTH - 3))}...`);
} }
} }
} }
global.AbuseReports = AbuseReports; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.AbuseReports = AbuseReports;
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
/* global Pager */ /* global Pager */
/* global Cookies */ /* global Cookies */
((global) => { class Activities {
class Activities {
constructor() { constructor() {
Pager.init(20, true, false, this.updateTooltips); Pager.init(20, true, false, this.updateTooltips);
$('.event-filter-link').on('click', (e) => { $('.event-filter-link').on('click', (e) => {
...@@ -31,7 +30,7 @@ ...@@ -31,7 +30,7 @@
$sender.closest('li').toggleClass('active'); $sender.closest('li').toggleClass('active');
} }
} }
global.Activities = Activities; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.Activities = Activities;
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, no-unused-vars, no-else-return, prefer-arrow-callback, camelcase, quotes, comma-dangle, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, no-unused-vars, no-else-return, prefer-arrow-callback, camelcase, quotes, comma-dangle, max-len */
(function() { window.Admin = (function() {
this.Admin = (function() {
function Admin() { function Admin() {
var modal, showBlacklistType; var modal, showBlacklistType;
$('input#user_force_random_password').on('change', function(elem) { $('input#user_force_random_password').on('change', function(elem) {
...@@ -60,5 +59,4 @@ ...@@ -60,5 +59,4 @@
} }
return Admin; return Admin;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, quotes, object-shorthand, camelcase, no-var, comma-dangle, prefer-arrow-callback, quote-props, no-param-reassign, max-len */ /* eslint-disable func-names, space-before-function-paren, quotes, object-shorthand, camelcase, no-var, comma-dangle, prefer-arrow-callback, quote-props, no-param-reassign, max-len */
(function() { var Api = {
var Api = {
groupsPath: "/api/:version/groups.json", groupsPath: "/api/:version/groups.json",
groupPath: "/api/:version/groups/:id.json", groupPath: "/api/:version/groups/:id.json",
namespacesPath: "/api/:version/namespaces.json", namespacesPath: "/api/:version/namespaces.json",
...@@ -144,7 +143,6 @@ ...@@ -144,7 +143,6 @@
} }
return url.replace(':version', gon.api_version); return url.replace(':version', gon.api_version);
} }
}; };
window.Api = Api; window.Api = Api;
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, prefer-arrow-callback, no-var, one-var, one-var-declaration-per-line, no-else-return, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, prefer-arrow-callback, no-var, one-var, one-var-declaration-per-line, no-else-return, max-len */
(function() {
this.Aside = (function() { window.Aside = (function() {
function Aside() { function Aside() {
$(document).off("click", "a.show-aside"); $(document).off("click", "a.show-aside");
$(document).on("click", 'a.show-aside', function(e) { $(document).on("click", 'a.show-aside', function(e) {
...@@ -21,5 +21,4 @@ ...@@ -21,5 +21,4 @@
} }
return Aside; return Aside;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-param-reassign, quotes, prefer-template, no-var, one-var, no-unused-vars, one-var-declaration-per-line, no-void, consistent-return, no-empty, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-param-reassign, quotes, prefer-template, no-var, one-var, no-unused-vars, one-var-declaration-per-line, no-void, consistent-return, no-empty, max-len */
(function() {
this.Autosave = (function() { window.Autosave = (function() {
function Autosave(field, key) { function Autosave(field, key) {
this.field = field; this.field = field;
if (key.join != null) { if (key.join != null) {
...@@ -58,5 +58,4 @@ ...@@ -58,5 +58,4 @@
}; };
return Autosave; return Autosave;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, quotes, no-shadow, prefer-arrow-callback, prefer-template, consistent-return, no-return-assign, new-parens, no-param-reassign, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, quotes, no-shadow, prefer-arrow-callback, prefer-template, consistent-return, no-return-assign, new-parens, no-param-reassign, max-len */
(function() { var Breakpoints = (function() {
var Breakpoints = (function() {
var BreakpointInstance, instance; var BreakpointInstance, instance;
function Breakpoints() {} function Breakpoints() {}
...@@ -60,13 +59,8 @@ ...@@ -60,13 +59,8 @@
}; };
return Breakpoints; return Breakpoints;
})(); })();
$((function(_this) { $(() => { window.bp = Breakpoints.get(); });
return function() {
return _this.bp = Breakpoints.get();
};
})(this));
window.Breakpoints = Breakpoints; window.Breakpoints = Breakpoints;
}).call(window);
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, no-else-return, object-shorthand, comma-dangle, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, no-else-return, object-shorthand, comma-dangle, max-len */
(function() {
$(function() { $(function() {
var previewPath; var previewPath;
$('input#broadcast_message_color').on('input', function() { $('input#broadcast_message_color').on('input', function() {
var previewColor; var previewColor;
...@@ -30,5 +30,4 @@ ...@@ -30,5 +30,4 @@
}); });
} }
}); });
}); });
}).call(window);
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-use-before-define, no-param-reassign, quotes, yoda, no-else-return, consistent-return, comma-dangle, object-shorthand, prefer-template, one-var, one-var-declaration-per-line, no-unused-vars, max-len, vars-on-top */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-use-before-define, no-param-reassign, quotes, yoda, no-else-return, consistent-return, comma-dangle, object-shorthand, prefer-template, one-var, one-var-declaration-per-line, no-unused-vars, max-len, vars-on-top */
/* global Breakpoints */ /* global Breakpoints */
(function() { var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }; var AUTO_SCROLL_OFFSET = 75;
var AUTO_SCROLL_OFFSET = 75; var DOWN_BUILD_TRACE = '#down-build-trace';
var DOWN_BUILD_TRACE = '#down-build-trace';
this.Build = (function() { window.Build = (function() {
Build.timeout = null; Build.timeout = null;
Build.state = null; Build.state = null;
...@@ -281,5 +280,4 @@ ...@@ -281,5 +280,4 @@
}; };
return Build; return Build;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, prefer-arrow-callback, no-unused-vars, no-return-assign, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, prefer-arrow-callback, no-unused-vars, no-return-assign, max-len */
(function() {
this.BuildArtifacts = (function() { window.BuildArtifacts = (function() {
function BuildArtifacts() { function BuildArtifacts() {
this.disablePropagation(); this.disablePropagation();
this.setupEntryClick(); this.setupEntryClick();
...@@ -22,5 +22,4 @@ ...@@ -22,5 +22,4 @@
}; };
return BuildArtifacts; return BuildArtifacts;
})(); })();
}).call(window);
(() => {
window.gl = window.gl || {};
class CILintEditor { window.gl = window.gl || {};
class CILintEditor {
constructor() { constructor() {
this.editor = window.ace.edit('ci-editor'); this.editor = window.ace.edit('ci-editor');
this.textarea = document.querySelector('#content'); this.textarea = document.querySelector('#content');
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
this.textarea.value = content; this.textarea.value = content;
}); });
} }
} }
gl.CILintEditor = CILintEditor; gl.CILintEditor = CILintEditor;
})();
/* eslint-disable func-names, space-before-function-paren, wrap-iife */ /* eslint-disable func-names, space-before-function-paren, wrap-iife */
/* global CommitFile */ /* global CommitFile */
(function() { window.Commit = (function() {
this.Commit = (function() {
function Commit() { function Commit() {
$('.files .diff-file').each(function() { $('.files .diff-file').each(function() {
return new CommitFile(this); return new CommitFile(this);
...@@ -10,5 +9,4 @@ ...@@ -10,5 +9,4 @@
} }
return Commit; return Commit;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, consistent-return, no-return-assign, no-param-reassign, one-var, no-var, one-var-declaration-per-line, no-unused-vars, prefer-template, object-shorthand, comma-dangle, max-len, prefer-arrow-callback */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, consistent-return, no-return-assign, no-param-reassign, one-var, no-var, one-var-declaration-per-line, no-unused-vars, prefer-template, object-shorthand, comma-dangle, max-len, prefer-arrow-callback */
/* global Pager */ /* global Pager */
(function() { window.CommitsList = (function() {
this.CommitsList = (function() {
var CommitsList = {}; var CommitsList = {};
CommitsList.timer = null; CommitsList.timer = null;
...@@ -64,5 +63,4 @@ ...@@ -64,5 +63,4 @@
}; };
return CommitsList; return CommitsList;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, object-shorthand, consistent-return, no-unused-vars, comma-dangle, vars-on-top, prefer-template, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, object-shorthand, consistent-return, no-unused-vars, comma-dangle, vars-on-top, prefer-template, max-len */
(function() {
this.Compare = (function() { window.Compare = (function() {
function Compare(opts) { function Compare(opts) {
this.opts = opts; this.opts = opts;
this.source_loading = $(".js-source-loading"); this.source_loading = $(".js-source-loading");
...@@ -87,5 +87,4 @@ ...@@ -87,5 +87,4 @@
}; };
return Compare; return Compare;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */ /* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */
(function() { window.CompareAutocomplete = (function() {
this.CompareAutocomplete = (function() {
function CompareAutocomplete() { function CompareAutocomplete() {
this.initDropdown(); this.initDropdown();
} }
...@@ -65,5 +64,4 @@ ...@@ -65,5 +64,4 @@
}; };
return CompareAutocomplete; return CompareAutocomplete;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, camelcase, one-var-declaration-per-line, no-else-return, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, camelcase, one-var-declaration-per-line, no-else-return, max-len */
(function() {
this.ConfirmDangerModal = (function() { window.ConfirmDangerModal = (function() {
function ConfirmDangerModal(form, text) { function ConfirmDangerModal(form, text) {
var project_path, submit; var project_path, submit;
this.form = form; this.form = form;
...@@ -27,5 +27,4 @@ ...@@ -27,5 +27,4 @@
} }
return ConfirmDangerModal; return ConfirmDangerModal;
})(); })();
}).call(window);
/* eslint-disable class-methods-use-this, object-shorthand, no-unused-vars, no-use-before-define, no-new, max-len, no-restricted-syntax, guard-for-in, no-continue */ /* eslint-disable class-methods-use-this, object-shorthand, no-unused-vars, no-use-before-define, no-new, max-len, no-restricted-syntax, guard-for-in, no-continue */
/* jshint esversion: 6 */
require('./lib/utils/common_utils'); require('./lib/utils/common_utils');
(() => { const gfmRules = {
const gfmRules = {
// The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert // The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert
// GitLab Flavored Markdown (GFM) to HTML. // GitLab Flavored Markdown (GFM) to HTML.
// These handlers consequently convert that same HTML to GFM to be copied to the clipboard. // These handlers consequently convert that same HTML to GFM to be copied to the clipboard.
...@@ -271,9 +269,9 @@ require('./lib/utils/common_utils'); ...@@ -271,9 +269,9 @@ require('./lib/utils/common_utils');
return `| ${cells.join(' | ')} |`; return `| ${cells.join(' | ')} |`;
}, },
}, },
}; };
class CopyAsGFM { class CopyAsGFM {
constructor() { constructor() {
$(document).on('copy', '.md, .wiki', this.handleCopy); $(document).on('copy', '.md, .wiki', this.handleCopy);
$(document).on('paste', '.js-gfm-input', this.handlePaste); $(document).on('paste', '.js-gfm-input', this.handlePaste);
...@@ -355,10 +353,9 @@ require('./lib/utils/common_utils'); ...@@ -355,10 +353,9 @@ require('./lib/utils/common_utils');
return clonedParentNode.innerText || clonedParentNode.textContent; return clonedParentNode.innerText || clonedParentNode.textContent;
} }
} }
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.CopyAsGFM = CopyAsGFM; window.gl.CopyAsGFM = CopyAsGFM;
new CopyAsGFM(); new CopyAsGFM();
})();
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, prefer-template, quotes, no-unused-vars, prefer-arrow-callback, max-len */ /* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, prefer-template, quotes, no-unused-vars, prefer-arrow-callback, max-len */
/* global Clipboard */
window.Clipboard = require('vendor/clipboard'); import Clipboard from 'vendor/clipboard';
(function() { var genericError, genericSuccess, showTooltip;
var genericError, genericSuccess, showTooltip;
genericSuccess = function(e) { genericSuccess = function(e) {
showTooltip(e.trigger, 'Copied'); showTooltip(e.trigger, 'Copied');
// Clear the selection and blur the trigger so it loses its border // Clear the selection and blur the trigger so it loses its border
e.clearSelection(); e.clearSelection();
return $(e.trigger).blur(); return $(e.trigger).blur();
}; };
// Safari doesn't support `execCommand`, so instead we inform the user to // Safari doesn't support `execCommand`, so instead we inform the user to
// copy manually. // copy manually.
// //
// See http://clipboardjs.com/#browser-support // See http://clipboardjs.com/#browser-support
genericError = function(e) { genericError = function(e) {
var key; var key;
if (/Mac/i.test(navigator.userAgent)) { if (/Mac/i.test(navigator.userAgent)) {
key = '⌘'; // Command key = '⌘'; // Command
...@@ -25,9 +23,9 @@ window.Clipboard = require('vendor/clipboard'); ...@@ -25,9 +23,9 @@ window.Clipboard = require('vendor/clipboard');
key = 'Ctrl'; key = 'Ctrl';
} }
return showTooltip(e.trigger, "Press " + key + "-C to copy"); return showTooltip(e.trigger, "Press " + key + "-C to copy");
}; };
showTooltip = function(target, title) { showTooltip = function(target, title) {
var $target = $(target); var $target = $(target);
var originalTitle = $target.data('original-title'); var originalTitle = $target.data('original-title');
...@@ -37,13 +35,12 @@ window.Clipboard = require('vendor/clipboard'); ...@@ -37,13 +35,12 @@ window.Clipboard = require('vendor/clipboard');
.tooltip('show') .tooltip('show')
.attr('title', originalTitle) .attr('title', originalTitle)
.tooltip('fixTitle'); .tooltip('fixTitle');
}; };
$(function() { $(function() {
var clipboard; var clipboard;
clipboard = new Clipboard('[data-clipboard-target], [data-clipboard-text]'); clipboard = new Clipboard('[data-clipboard-target], [data-clipboard-text]');
clipboard.on('success', genericSuccess); clipboard.on('success', genericSuccess);
return clipboard.on('error', genericError); return clipboard.on('error', genericError);
}); });
}).call(window);
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, comma-dangle, prefer-template, quotes, no-param-reassign, wrap-iife, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, comma-dangle, prefer-template, quotes, no-param-reassign, wrap-iife, max-len */
/* global Api */ /* global Api */
(function (w) { class CreateLabelDropdown {
class CreateLabelDropdown {
constructor ($el, namespacePath, projectPath) { constructor ($el, namespacePath, projectPath) {
this.$el = $el; this.$el = $el;
this.namespacePath = namespacePath; this.namespacePath = namespacePath;
...@@ -122,11 +121,7 @@ ...@@ -122,11 +121,7 @@
} }
}); });
} }
} }
if (!w.gl) {
w.gl = {};
}
gl.CreateLabelDropdown = CreateLabelDropdown; window.gl = window.gl || {};
})(window); gl.CreateLabelDropdown = CreateLabelDropdown;
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
require('./lib/utils/url_utility'); require('./lib/utils/url_utility');
(() => { const UNFOLD_COUNT = 20;
const UNFOLD_COUNT = 20; let isBound = false;
let isBound = false;
class Diff { class Diff {
constructor() { constructor() {
const $diffFile = $('.files .diff-file'); const $diffFile = $('.files .diff-file');
$diffFile.singleFileDiff(); $diffFile.singleFileDiff();
...@@ -123,8 +122,7 @@ require('./lib/utils/url_utility'); ...@@ -123,8 +122,7 @@ require('./lib/utils/url_utility');
.addClass('hll'); .addClass('hll');
} }
} }
} }
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.Diff = Diff; window.gl.Diff = Diff;
})();
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
require('./preview_markdown'); require('./preview_markdown');
(function() { window.DropzoneInput = (function() {
this.DropzoneInput = (function() {
function DropzoneInput(form) { function DropzoneInput(form) {
var $mdArea, alertAttr, alertClass, appendToTextArea, btnAlert, child, closeAlertMessage, closeSpinner, divAlert, divHover, divSpinner, dropzone, form_dropzone, form_textarea, getFilename, handlePaste, iconPaperclip, iconSpinner, insertToTextArea, isImage, max_file_size, pasteText, project_uploads_path, showError, showSpinner, uploadFile, uploadProgress; var $mdArea, alertAttr, alertClass, appendToTextArea, btnAlert, child, closeAlertMessage, closeSpinner, divAlert, divHover, divSpinner, dropzone, form_dropzone, form_textarea, getFilename, handlePaste, iconPaperclip, iconSpinner, insertToTextArea, isImage, max_file_size, pasteText, project_uploads_path, showError, showSpinner, uploadFile, uploadProgress;
Dropzone.autoDiscover = false; Dropzone.autoDiscover = false;
...@@ -216,5 +215,4 @@ require('./preview_markdown'); ...@@ -216,5 +215,4 @@ require('./preview_markdown');
} }
return DropzoneInput; return DropzoneInput;
})(); })();
}).call(window);
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
/* global dateFormat */ /* global dateFormat */
/* global Pikaday */ /* global Pikaday */
(function(global) { class DueDateSelect {
class DueDateSelect {
constructor({ $dropdown, $loading } = {}) { constructor({ $dropdown, $loading } = {}) {
const $dropdownParent = $dropdown.closest('.dropdown'); const $dropdownParent = $dropdown.closest('.dropdown');
const $block = $dropdown.closest('.block'); const $block = $dropdown.closest('.block');
...@@ -156,9 +155,9 @@ ...@@ -156,9 +155,9 @@
return this.$loading.fadeOut(); return this.$loading.fadeOut();
}); });
} }
} }
class DueDateSelectors { class DueDateSelectors {
constructor() { constructor() {
this.initMilestoneDatePicker(); this.initMilestoneDatePicker();
this.initIssuableSelect(); this.initIssuableSelect();
...@@ -198,7 +197,7 @@ ...@@ -198,7 +197,7 @@
}); });
}); });
} }
} }
global.DueDateSelectors = DueDateSelectors; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.DueDateSelectors = DueDateSelectors;
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
/* global FilesCommentButton */ /* global FilesCommentButton */
/* global notes */ /* global notes */
(function() { let $commentButtonTemplate;
let $commentButtonTemplate; var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
this.FilesCommentButton = (function() { window.FilesCommentButton = (function() {
var COMMENT_BUTTON_CLASS, EMPTY_CELL_CLASS, LINE_COLUMN_CLASSES, LINE_CONTENT_CLASS, LINE_HOLDER_CLASS, LINE_NUMBER_CLASS, OLD_LINE_CLASS, TEXT_FILE_SELECTOR, UNFOLDABLE_LINE_CLASS; var COMMENT_BUTTON_CLASS, EMPTY_CELL_CLASS, LINE_COLUMN_CLASSES, LINE_CONTENT_CLASS, LINE_HOLDER_CLASS, LINE_NUMBER_CLASS, OLD_LINE_CLASS, TEXT_FILE_SELECTOR, UNFOLDABLE_LINE_CLASS;
COMMENT_BUTTON_CLASS = '.add-diff-note'; COMMENT_BUTTON_CLASS = '.add-diff-note';
...@@ -126,9 +125,9 @@ ...@@ -126,9 +125,9 @@
}; };
return FilesCommentButton; return FilesCommentButton;
})(); })();
$.fn.filesCommentButton = function() { $.fn.filesCommentButton = function() {
$commentButtonTemplate = $('<button name="button" type="submit" class="add-diff-note js-add-diff-note-button" title="Add a comment to this line"><i class="fa fa-comment-o"></i></button>'); $commentButtonTemplate = $('<button name="button" type="submit" class="add-diff-note js-add-diff-note-button" title="Add a comment to this line"><i class="fa fa-comment-o"></i></button>');
if (!(this && (this.parent().data('can-create-note') != null))) { if (!(this && (this.parent().data('can-create-note') != null))) {
...@@ -139,5 +138,4 @@ ...@@ -139,5 +138,4 @@
return $.data(this, 'filesCommentButton', new FilesCommentButton($(this))); return $.data(this, 'filesCommentButton', new FilesCommentButton($(this)));
} }
}); });
}; };
}).call(window);
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Makes search request for content when user types a value in the search input. * Makes search request for content when user types a value in the search input.
* Updates the html content of the page with the received one. * Updates the html content of the page with the received one.
*/ */
export default class FilterableList { export default class FilterableList {
constructor(form, filter, holder) { constructor(form, filter, holder) {
this.filterForm = form; this.filterForm = form;
......
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, no-param-reassign, quotes, quote-props, prefer-template, comma-dangle, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, no-param-reassign, quotes, quote-props, prefer-template, comma-dangle, max-len */
(function() {
this.Flash = (function() { window.Flash = (function() {
var hideFlash; var hideFlash;
hideFlash = function() { hideFlash = function() {
...@@ -38,5 +38,4 @@ ...@@ -38,5 +38,4 @@
} }
return Flash; return Flash;
})(); })();
}).call(window);
...@@ -5,16 +5,13 @@ import emojiAliases from 'emojis/aliases.json'; ...@@ -5,16 +5,13 @@ import emojiAliases from 'emojis/aliases.json';
import { glEmojiTag } from '~/behaviors/gl_emoji'; import { glEmojiTag } from '~/behaviors/gl_emoji';
// Creates the variables for setting up GFM auto-completion // Creates the variables for setting up GFM auto-completion
(function() { window.gl = window.gl || {};
if (window.gl == null) {
window.gl = {};
}
function sanitize(str) { function sanitize(str) {
return str.replace(/<(?:.|\n)*?>/gm, ''); return str.replace(/<(?:.|\n)*?>/gm, '');
} }
window.gl.GfmAutoComplete = { window.gl.GfmAutoComplete = {
dataSources: {}, dataSources: {},
defaultLoadingData: ['loading'], defaultLoadingData: ['loading'],
cachedData: {}, cachedData: {},
...@@ -390,5 +387,4 @@ import { glEmojiTag } from '~/behaviors/gl_emoji'; ...@@ -390,5 +387,4 @@ import { glEmojiTag } from '~/behaviors/gl_emoji';
return dataToInspect && return dataToInspect &&
(dataToInspect === loadingState || dataToInspect.name === loadingState); (dataToInspect === loadingState || dataToInspect.name === loadingState);
} }
}; };
}).call(window);
/* eslint-disable func-names, space-before-function-paren, no-var, one-var, one-var-declaration-per-line, prefer-rest-params, max-len, vars-on-top, wrap-iife, no-unused-vars, quotes, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, comma-dangle, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func, no-mixed-operators */ /* eslint-disable func-names, space-before-function-paren, no-var, one-var, one-var-declaration-per-line, prefer-rest-params, max-len, vars-on-top, wrap-iife, no-unused-vars, quotes, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, comma-dangle, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func, no-mixed-operators */
/* global fuzzaldrinPlus */ /* global fuzzaldrinPlus */
(function() { var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote,
var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote,
bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }, bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; },
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i += 1) { if (i in this && this[i] === item) return i; } return -1; }; indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i += 1) { if (i in this && this[i] === item) return i; } return -1; };
GitLabDropdownFilter = (function() { GitLabDropdownFilter = (function() {
var ARROW_KEY_CODES, BLUR_KEYCODES, HAS_VALUE_CLASS; var ARROW_KEY_CODES, BLUR_KEYCODES, HAS_VALUE_CLASS;
BLUR_KEYCODES = [27, 40]; BLUR_KEYCODES = [27, 40];
...@@ -135,9 +134,9 @@ ...@@ -135,9 +134,9 @@
}; };
return GitLabDropdownFilter; return GitLabDropdownFilter;
})(); })();
GitLabDropdownRemote = (function() { GitLabDropdownRemote = (function() {
function GitLabDropdownRemote(dataEndpoint, options) { function GitLabDropdownRemote(dataEndpoint, options) {
this.dataEndpoint = dataEndpoint; this.dataEndpoint = dataEndpoint;
this.options = options; this.options = options;
...@@ -187,9 +186,9 @@ ...@@ -187,9 +186,9 @@
}; };
return GitLabDropdownRemote; return GitLabDropdownRemote;
})(); })();
GitLabDropdown = (function() { GitLabDropdown = (function() {
var ACTIVE_CLASS, FILTER_INPUT, INDETERMINATE_CLASS, LOADING_CLASS, PAGE_TWO_CLASS, NON_SELECTABLE_CLASSES, SELECTABLE_CLASSES, CURSOR_SELECT_SCROLL_PADDING, currentIndex; var ACTIVE_CLASS, FILTER_INPUT, INDETERMINATE_CLASS, LOADING_CLASS, PAGE_TWO_CLASS, NON_SELECTABLE_CLASSES, SELECTABLE_CLASSES, CURSOR_SELECT_SCROLL_PADDING, currentIndex;
LOADING_CLASS = "is-loading"; LOADING_CLASS = "is-loading";
...@@ -838,13 +837,12 @@ ...@@ -838,13 +837,12 @@
}; };
return GitLabDropdown; return GitLabDropdown;
})(); })();
$.fn.glDropdown = function(opts) { $.fn.glDropdown = function(opts) {
return this.each(function() { return this.each(function() {
if (!$.data(this, 'glDropdown')) { if (!$.data(this, 'glDropdown')) {
return $.data(this, 'glDropdown', new GitLabDropdown(this, opts)); return $.data(this, 'glDropdown', new GitLabDropdown(this, opts));
} }
}); });
}; };
}).call(window);
/* eslint-disable no-param-reassign */ /**
((global) => {
/*
* This class overrides the browser's validation error bubbles, displaying custom * This class overrides the browser's validation error bubbles, displaying custom
* error messages for invalid fields instead. To begin validating any form, add the * error messages for invalid fields instead. To begin validating any form, add the
* class `gl-show-field-errors` to the form element, and ensure error messages are * class `gl-show-field-errors` to the form element, and ensure error messages are
...@@ -41,22 +39,22 @@ ...@@ -41,22 +39,22 @@
* // Error message now injected here * // Error message now injected here
* </form> * </form>
* *
* */ */
/* /**
* Regex Patterns in use: * Regex Patterns in use:
* *
* Only alphanumeric: : "[a-zA-Z0-9]+" * Only alphanumeric: : "[a-zA-Z0-9]+"
* No special characters : "[a-zA-Z0-9-_]+", * No special characters : "[a-zA-Z0-9-_]+",
* *
* */ */
const errorMessageClass = 'gl-field-error'; const errorMessageClass = 'gl-field-error';
const inputErrorClass = 'gl-field-error-outline'; const inputErrorClass = 'gl-field-error-outline';
const errorAnchorSelector = '.gl-field-error-anchor'; const errorAnchorSelector = '.gl-field-error-anchor';
const ignoreInputSelector = '.gl-field-error-ignore'; const ignoreInputSelector = '.gl-field-error-ignore';
class GlFieldError { class GlFieldError {
constructor({ input, formErrors }) { constructor({ input, formErrors }) {
this.inputElement = $(input); this.inputElement = $(input);
this.inputDomElement = this.inputElement.get(0); this.inputDomElement = this.inputElement.get(0);
...@@ -158,7 +156,7 @@ ...@@ -158,7 +156,7 @@
this.scopedSiblings.hide(); this.scopedSiblings.hide();
this.fieldErrorElement.hide(); this.fieldErrorElement.hide();
} }
} }
global.GlFieldError = GlFieldError; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.GlFieldError = GlFieldError;
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
require('./gl_field_error'); require('./gl_field_error');
((global) => { const customValidationFlag = 'gl-field-error-ignore';
const customValidationFlag = 'gl-field-error-ignore';
class GlFieldErrors { class GlFieldErrors {
constructor(form) { constructor(form) {
this.form = $(form); this.form = $(form);
this.state = { this.state = {
...@@ -22,7 +21,7 @@ require('./gl_field_error'); ...@@ -22,7 +21,7 @@ require('./gl_field_error');
this.state.inputs = this.form.find(validateSelectors).toArray() this.state.inputs = this.form.find(validateSelectors).toArray()
.filter((input) => !input.classList.contains(customValidationFlag)) .filter((input) => !input.classList.contains(customValidationFlag))
.map((input) => new global.GlFieldError({ input, formErrors: this })); .map((input) => new window.gl.GlFieldError({ input, formErrors: this }));
this.form.on('submit', this.catchInvalidFormSubmit); this.form.on('submit', this.catchInvalidFormSubmit);
} }
...@@ -42,7 +41,7 @@ require('./gl_field_error'); ...@@ -42,7 +41,7 @@ require('./gl_field_error');
const firstInvalid = this.state.inputs.filter((input) => !input.inputDomElement.validity.valid)[0]; const firstInvalid = this.state.inputs.filter((input) => !input.inputDomElement.validity.valid)[0];
firstInvalid.inputElement.focus(); firstInvalid.inputElement.focus();
} }
} }
global.GlFieldErrors = GlFieldErrors; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.GlFieldErrors = GlFieldErrors;
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
/* global DropzoneInput */ /* global DropzoneInput */
/* global autosize */ /* global autosize */
(() => { window.gl = window.gl || {};
const global = window.gl || (window.gl = {});
function GLForm(form) { function GLForm(form) {
this.form = form; this.form = form;
this.textarea = this.form.find('textarea.js-gfm-input'); this.textarea = this.form.find('textarea.js-gfm-input');
// Before we start, we should clean up any previous data for this form // Before we start, we should clean up any previous data for this form
...@@ -14,15 +13,15 @@ ...@@ -14,15 +13,15 @@
// Setup the form // Setup the form
this.setupForm(); this.setupForm();
this.form.data('gl-form', this); this.form.data('gl-form', this);
} }
GLForm.prototype.destroy = function() { GLForm.prototype.destroy = function() {
// Clean form listeners // Clean form listeners
this.clearEventListeners(); this.clearEventListeners();
return this.form.data('gl-form', null); return this.form.data('gl-form', null);
}; };
GLForm.prototype.setupForm = function() { GLForm.prototype.setupForm = function() {
var isNewForm; var isNewForm;
isNewForm = this.form.is(':not(.gfm-form)'); isNewForm = this.form.is(':not(.gfm-form)');
this.form.removeClass('js-new-note-form'); this.form.removeClass('js-new-note-form');
...@@ -42,9 +41,9 @@ ...@@ -42,9 +41,9 @@
this.form.find('.js-note-discard').hide(); this.form.find('.js-note-discard').hide();
this.form.show(); this.form.show();
if (this.isAutosizeable) this.setupAutosize(); if (this.isAutosizeable) this.setupAutosize();
}; };
GLForm.prototype.setupAutosize = function () { GLForm.prototype.setupAutosize = function () {
this.textarea.off('autosize:resized') this.textarea.off('autosize:resized')
.on('autosize:resized', this.setHeightData.bind(this)); .on('autosize:resized', this.setHeightData.bind(this));
...@@ -55,13 +54,13 @@ ...@@ -55,13 +54,13 @@
autosize(this.textarea); autosize(this.textarea);
this.textarea.css('resize', 'vertical'); this.textarea.css('resize', 'vertical');
}, 0); }, 0);
}; };
GLForm.prototype.setHeightData = function () { GLForm.prototype.setHeightData = function () {
this.textarea.data('height', this.textarea.outerHeight()); this.textarea.data('height', this.textarea.outerHeight());
}; };
GLForm.prototype.destroyAutosize = function () { GLForm.prototype.destroyAutosize = function () {
const outerHeight = this.textarea.outerHeight(); const outerHeight = this.textarea.outerHeight();
if (this.textarea.data('height') === outerHeight) return; if (this.textarea.data('height') === outerHeight) return;
...@@ -71,22 +70,21 @@ ...@@ -71,22 +70,21 @@
this.textarea.data('height', outerHeight); this.textarea.data('height', outerHeight);
this.textarea.outerHeight(outerHeight); this.textarea.outerHeight(outerHeight);
this.textarea.css('max-height', window.outerHeight); this.textarea.css('max-height', window.outerHeight);
}; };
GLForm.prototype.clearEventListeners = function() { GLForm.prototype.clearEventListeners = function() {
this.textarea.off('focus'); this.textarea.off('focus');
this.textarea.off('blur'); this.textarea.off('blur');
return gl.text.removeListeners(this.form); return gl.text.removeListeners(this.form);
}; };
GLForm.prototype.addEventListeners = function() { GLForm.prototype.addEventListeners = function() {
this.textarea.on('focus', function() { this.textarea.on('focus', function() {
return $(this).closest('.md-area').addClass('is-focused'); return $(this).closest('.md-area').addClass('is-focused');
}); });
return this.textarea.on('blur', function() { return this.textarea.on('blur', function() {
return $(this).closest('.md-area').removeClass('is-focused'); return $(this).closest('.md-area').removeClass('is-focused');
}); });
}; };
global.GLForm = GLForm; window.gl.GLForm = GLForm;
})();
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, one-var, one-var-declaration-per-line, no-useless-escape, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, one-var, one-var-declaration-per-line, no-useless-escape, max-len */
(function() {
this.GroupAvatar = (function() { window.GroupAvatar = (function() {
function GroupAvatar() { function GroupAvatar() {
$('.js-choose-group-avatar-button').on("click", function() { $('.js-choose-group-avatar-button').on("click", function() {
var form; var form;
...@@ -16,5 +16,4 @@ ...@@ -16,5 +16,4 @@
} }
return GroupAvatar; return GroupAvatar;
})(); })();
}).call(window);
/* eslint-disable func-names, object-shorthand, comma-dangle, wrap-iife, space-before-function-paren, no-param-reassign, max-len */ /* eslint-disable func-names, object-shorthand, comma-dangle, wrap-iife, space-before-function-paren, no-param-reassign, max-len */
(function(global) { class GroupLabelSubscription {
class GroupLabelSubscription {
constructor(container) { constructor(container) {
const $container = $(container); const $container = $(container);
this.$dropdown = $container.find('.dropdown'); this.$dropdown = $container.find('.dropdown');
...@@ -47,7 +46,7 @@ ...@@ -47,7 +46,7 @@
this.$subscribeButtons.toggleClass('hidden'); this.$subscribeButtons.toggleClass('hidden');
this.$unsubscribeButtons.toggleClass('hidden'); this.$unsubscribeButtons.toggleClass('hidden');
} }
} }
global.GroupLabelSubscription = GroupLabelSubscription; window.gl = window.gl || {};
})(window.gl || (window.gl = {})); window.gl.GroupLabelSubscription = GroupLabelSubscription;
/* eslint-disable func-names, space-before-function-paren, no-var, wrap-iife, one-var, camelcase, one-var-declaration-per-line, quotes, object-shorthand, prefer-arrow-callback, comma-dangle, consistent-return, yoda, prefer-rest-params, prefer-spread, no-unused-vars, prefer-template, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, wrap-iife, one-var, camelcase, one-var-declaration-per-line, quotes, object-shorthand, prefer-arrow-callback, comma-dangle, consistent-return, yoda, prefer-rest-params, prefer-spread, no-unused-vars, prefer-template, max-len */
/* global Api */ /* global Api */
(function() { var slice = [].slice;
var slice = [].slice;
this.GroupsSelect = (function() { window.GroupsSelect = (function() {
function GroupsSelect() { function GroupsSelect() {
$('.ajax-groups-select').each((function(_this) { $('.ajax-groups-select').each((function(_this) {
return function(i, select) { return function(i, select) {
...@@ -67,5 +66,4 @@ ...@@ -67,5 +66,4 @@
}; };
return GroupsSelect; return GroupsSelect;
})(); })();
}).call(window);
/* eslint-disable wrap-iife, func-names, space-before-function-paren, prefer-arrow-callback, no-var, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var */
(function() {
$(document).on('todo:toggle', function(e, count) { $(document).on('todo:toggle', function(e, count) {
var $todoPendingCount = $('.todos-pending-count'); var $todoPendingCount = $('.todos-pending-count');
$todoPendingCount.text(gl.text.highCountTrim(count)); $todoPendingCount.text(gl.text.highCountTrim(count));
$todoPendingCount.toggleClass('hidden', count === 0); $todoPendingCount.toggleClass('hidden', count === 0);
}); });
})();
...@@ -206,21 +206,20 @@ import './visibility_select'; ...@@ -206,21 +206,20 @@ import './visibility_select';
import './wikis'; import './wikis';
import './zen_mode'; import './zen_mode';
(function () { document.addEventListener('beforeunload', function () {
document.addEventListener('beforeunload', function () {
// Unbind scroll events // Unbind scroll events
$(document).off('scroll'); $(document).off('scroll');
// Close any open tooltips // Close any open tooltips
$('.has-tooltip, [data-toggle="tooltip"]').tooltip('destroy'); $('.has-tooltip, [data-toggle="tooltip"]').tooltip('destroy');
}); });
window.addEventListener('hashchange', gl.utils.handleLocationHash); window.addEventListener('hashchange', gl.utils.handleLocationHash);
window.addEventListener('load', function onLoad() { window.addEventListener('load', function onLoad() {
window.removeEventListener('load', onLoad, false); window.removeEventListener('load', onLoad, false);
gl.utils.handleLocationHash(); gl.utils.handleLocationHash();
}, false); }, false);
$(function () { $(function () {
var $body = $('body'); var $body = $('body');
var $document = $(document); var $document = $(document);
var $window = $(window); var $window = $(window);
...@@ -390,5 +389,4 @@ import './zen_mode'; ...@@ -390,5 +389,4 @@ import './zen_mode';
new Aside(); new Aside();
gl.utils.initTimeagoTimeout(); gl.utils.initTimeagoTimeout();
}); });
}).call(window);
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