Commit 35c8fd55 authored by Jacob Schatz's avatar Jacob Schatz

Update to jQuery 3.

parent 86c9c93d
...@@ -312,7 +312,7 @@ class AwardsHandler { ...@@ -312,7 +312,7 @@ class AwardsHandler {
} }
getAwardUrl() { getAwardUrl() {
return this.getVotesBlock().data('award-url'); return this.getVotesBlock().data('awardUrl');
} }
checkMutuality(votesBlock, emoji) { checkMutuality(votesBlock, emoji) {
......
...@@ -2,7 +2,7 @@ import Clipboard from 'clipboard'; ...@@ -2,7 +2,7 @@ import Clipboard from 'clipboard';
function showTooltip(target, title) { function showTooltip(target, title) {
const $target = $(target); const $target = $(target);
const originalTitle = $target.data('original-title'); const originalTitle = $target.data('originalTitle');
if (!$target.data('hideTooltip')) { if (!$target.data('hideTooltip')) {
$target $target
......
...@@ -43,7 +43,7 @@ $(document).on('keydown.quick_submit', '.js-quick-submit', (e) => { ...@@ -43,7 +43,7 @@ $(document).on('keydown.quick_submit', '.js-quick-submit', (e) => {
const $form = $(e.target).closest('form'); const $form = $(e.target).closest('form');
const $submitButton = $form.find('input[type=submit], button[type=submit]').first(); const $submitButton = $form.find('input[type=submit], button[type=submit]').first();
if (!$submitButton.attr('disabled')) { if (!$submitButton.prop('disabled')) {
$submitButton.trigger('click', [e]); $submitButton.trigger('click', [e]);
if (!isInIssuePage()) { if (!isInIssuePage()) {
......
...@@ -40,7 +40,7 @@ $.fn.requiresInput = function requiresInput() { ...@@ -40,7 +40,7 @@ $.fn.requiresInput = function requiresInput() {
// based on the option selected // based on the option selected
function hideOrShowHelpBlock(form) { function hideOrShowHelpBlock(form) {
const selected = $('.js-select-namespace option:selected'); const selected = $('.js-select-namespace option:selected');
if (selected.length && selected.data('options-parent') === 'groups') { if (selected.length && selected.data('optionsParent') === 'groups') {
form.find('.help-block').hide(); form.find('.help-block').hide();
} else if (selected.length) { } else if (selected.length) {
form.find('.help-block').show(); form.find('.help-block').show();
......
...@@ -10,10 +10,10 @@ $(() => { ...@@ -10,10 +10,10 @@ $(() => {
const deleteBlobForm = $('.js-delete-blob-form'); const deleteBlobForm = $('.js-delete-blob-form');
if (editBlobForm.length) { if (editBlobForm.length) {
const urlRoot = editBlobForm.data('relative-url-root'); const urlRoot = editBlobForm.data('relativeUrlRoot');
const assetsPath = editBlobForm.data('assets-prefix'); const assetsPath = editBlobForm.data('assetsPrefix');
const blobLanguage = editBlobForm.data('blob-language'); const blobLanguage = editBlobForm.data('blobLanguage');
const currentAction = $('.js-file-title').data('current-action'); const currentAction = $('.js-file-title').data('currentAction');
new EditBlob(`${urlRoot}${assetsPath}`, blobLanguage, currentAction); new EditBlob(`${urlRoot}${assetsPath}`, blobLanguage, currentAction);
new NewCommitForm(editBlobForm); new NewCommitForm(editBlobForm);
......
...@@ -59,7 +59,7 @@ export default class EditBlob { ...@@ -59,7 +59,7 @@ export default class EditBlob {
if (paneId === '#preview') { if (paneId === '#preview') {
this.$toggleButton.hide(); this.$toggleButton.hide();
axios.post(currentLink.data('preview-url'), { axios.post(currentLink.data('previewUrl'), {
content: this.editor.getValue(), content: this.editor.getValue(),
}) })
.then(({ data }) => { .then(({ data }) => {
......
...@@ -25,7 +25,7 @@ $(document).off('created.label').on('created.label', (e, label) => { ...@@ -25,7 +25,7 @@ $(document).off('created.label').on('created.label', (e, label) => {
gl.issueBoards.newListDropdownInit = () => { gl.issueBoards.newListDropdownInit = () => {
$('.js-new-board-list').each(function () { $('.js-new-board-list').each(function () {
const $this = $(this); const $this = $(this);
new CreateLabelDropdown($this.closest('.dropdown').find('.dropdown-new-label'), $this.data('namespace-path'), $this.data('project-path')); new CreateLabelDropdown($this.closest('.dropdown').find('.dropdown-new-label'), $this.data('namespacePath'), $this.data('projectPath'));
$this.glDropdown({ $this.glDropdown({
data(term, callback) { data(term, callback) {
......
...@@ -13,6 +13,6 @@ import 'bootstrap-sass/assets/javascripts/bootstrap/popover'; ...@@ -13,6 +13,6 @@ import 'bootstrap-sass/assets/javascripts/bootstrap/popover';
// custom jQuery functions // custom jQuery functions
$.fn.extend({ $.fn.extend({
disable() { return $(this).attr('disabled', 'disabled').addClass('disabled'); }, disable() { return $(this).prop('disabled', true).addClass('disabled'); },
enable() { return $(this).removeAttr('disabled').removeClass('disabled'); }, enable() { return $(this).prop('disabled', false).removeClass('disabled'); },
}); });
...@@ -13,7 +13,7 @@ export default class Compare { ...@@ -13,7 +13,7 @@ export default class Compare {
$dropdown = $(dropdown); $dropdown = $(dropdown);
return $dropdown.glDropdown({ return $dropdown.glDropdown({
selectable: true, selectable: true,
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('fieldName'),
filterable: true, filterable: true,
id: function(obj, $el) { id: function(obj, $el) {
return $el.data('id'); return $el.data('id');
......
...@@ -9,7 +9,7 @@ export default function initCompareAutocomplete() { ...@@ -9,7 +9,7 @@ export default function initCompareAutocomplete() {
$dropdown = $(this); $dropdown = $(this);
selected = $dropdown.data('selected'); selected = $dropdown.data('selected');
const $dropdownContainer = $dropdown.closest('.dropdown'); const $dropdownContainer = $dropdown.closest('.dropdown');
const $fieldInput = $(`input[name="${$dropdown.data('field-name')}"]`, $dropdownContainer); const $fieldInput = $(`input[name="${$dropdown.data('fieldName')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer); const $filterInput = $('input[type="search"]', $dropdownContainer);
$dropdown.glDropdown({ $dropdown.glDropdown({
data: function(term, callback) { data: function(term, callback) {
...@@ -25,7 +25,7 @@ export default function initCompareAutocomplete() { ...@@ -25,7 +25,7 @@ export default function initCompareAutocomplete() {
selectable: true, selectable: true,
filterable: true, filterable: true,
filterRemote: true, filterRemote: true,
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('fieldName'),
filterInput: 'input[type="search"]', filterInput: 'input[type="search"]',
renderRow: function(ref) { renderRow: function(ref) {
var link; var link;
......
...@@ -68,7 +68,7 @@ export default class Diff { ...@@ -68,7 +68,7 @@ export default class Diff {
} }
const file = $target.parents('.diff-file'); const file = $target.parents('.diff-file');
const link = file.data('blob-diff-path'); const link = file.data('blobDiffPath');
const view = file.data('view'); const view = file.data('view');
const params = { since, to, bottom, offset, unfold, view }; const params = { since, to, bottom, offset, unfold, view };
...@@ -121,7 +121,7 @@ export default class Diff { ...@@ -121,7 +121,7 @@ export default class Diff {
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
diffViewType() { diffViewType() {
return $('.inline-parallel-buttons a.active').data('view-type'); return $('.inline-parallel-buttons a.active').data('viewType');
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
lineNumbers(line) { lineNumbers(line) {
......
...@@ -17,9 +17,9 @@ class DueDateSelect { ...@@ -17,9 +17,9 @@ class DueDateSelect {
this.$value = $block.find('.value'); this.$value = $block.find('.value');
this.$valueContent = $block.find('.value-content'); this.$valueContent = $block.find('.value-content');
this.$sidebarValue = $('.js-due-date-sidebar-value', $block); this.$sidebarValue = $('.js-due-date-sidebar-value', $block);
this.fieldName = $dropdown.data('field-name'); this.fieldName = $dropdown.data('fieldName');
this.abilityName = $dropdown.data('ability-name'); this.abilityName = $dropdown.data('abilityName');
this.issueUpdateURL = $dropdown.data('issue-update'); this.issueUpdateURL = $dropdown.data('issueUpdate');
this.rawSelectedDate = null; this.rawSelectedDate = null;
this.displayedDate = null; this.displayedDate = null;
......
...@@ -25,7 +25,7 @@ export default { ...@@ -25,7 +25,7 @@ export default {
if (!this.userCanCreateNote) { if (!this.userCanCreateNote) {
// data-can-create-note is an empty string when true, otherwise undefined // data-can-create-note is an empty string when true, otherwise undefined
this.userCanCreateNote = $diffFile.closest(DIFF_CONTAINER_SELECTOR).data('can-create-note') === ''; this.userCanCreateNote = $diffFile.closest(DIFF_CONTAINER_SELECTOR).data('canCreateNote') === '';
} }
this.isParallelView = Cookies.get('diff_view') === 'parallel'; this.isParallelView = Cookies.get('diff_view') === 'parallel';
......
...@@ -485,7 +485,7 @@ GitLabDropdown = (function() { ...@@ -485,7 +485,7 @@ GitLabDropdown = (function() {
$target = $(e.target); $target = $(e.target);
if ($target && !$target.hasClass('dropdown-menu-close') && if ($target && !$target.hasClass('dropdown-menu-close') &&
!$target.hasClass('dropdown-menu-close-icon') && !$target.hasClass('dropdown-menu-close-icon') &&
!$target.data('is-link')) { !$target.data('isLink')) {
e.stopPropagation(); e.stopPropagation();
return false; return false;
} else { } else {
......
...@@ -12,7 +12,7 @@ export default class GLForm { ...@@ -12,7 +12,7 @@ export default class GLForm {
this.destroy(); this.destroy();
// Setup the form // Setup the form
this.setupForm(); this.setupForm();
this.form.data('gl-form', this); this.form.data('glForm', this);
} }
destroy() { destroy() {
...@@ -21,7 +21,7 @@ export default class GLForm { ...@@ -21,7 +21,7 @@ export default class GLForm {
if (this.autoComplete) { if (this.autoComplete) {
this.autoComplete.destroy(); this.autoComplete.destroy();
} }
this.form.data('gl-form', null); this.form.data('glForm', null);
} }
setupForm() { setupForm() {
......
...@@ -11,7 +11,7 @@ export default class GpgBadges { ...@@ -11,7 +11,7 @@ export default class GpgBadges {
badges.html('<i class="fa fa-spinner fa-spin"></i>'); badges.html('<i class="fa fa-spinner fa-spin"></i>');
const params = parseQueryStringIntoObject(form.serialize()); const params = parseQueryStringIntoObject(form.serialize());
return axios.get(form.data('signatures-path'), { params }) return axios.get(form.data('signaturesPath'), { params })
.then(({ data }) => { .then(({ data }) => {
data.signatures.forEach((signature) => { data.signatures.forEach((signature) => {
badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html); badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html);
......
...@@ -7,8 +7,8 @@ export default function groupsSelect() { ...@@ -7,8 +7,8 @@ export default function groupsSelect() {
window.GROUP_SELECT_PER_PAGE = 20; window.GROUP_SELECT_PER_PAGE = 20;
$('.ajax-groups-select').each(function setAjaxGroupsSelect2() { $('.ajax-groups-select').each(function setAjaxGroupsSelect2() {
const $select = $(this); const $select = $(this);
const allAvailable = $select.data('all-available'); const allAvailable = $select.data('allAvailable');
const skipGroups = $select.data('skip-groups') || []; const skipGroups = $select.data('skipGroups') || [];
$select.select2({ $select.select2({
placeholder: 'Search for a group', placeholder: 'Search for a group',
multiple: $select.hasClass('multiselect'), multiple: $select.hasClass('multiselect'),
......
...@@ -6,8 +6,8 @@ export default class IntegrationSettingsForm { ...@@ -6,8 +6,8 @@ export default class IntegrationSettingsForm {
this.$form = $(formSelector); this.$form = $(formSelector);
// Form Metadata // Form Metadata
this.canTestService = this.$form.data('can-test'); this.canTestService = this.$form.data('canTest');
this.testEndPoint = this.$form.data('test-url'); this.testEndPoint = this.$form.data('testUrl');
// Form Child Elements // Form Child Elements
this.$serviceToggle = this.$form.find('#service_active'); this.$serviceToggle = this.$form.find('#service_active');
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
taskListUpdateSuccess(data) { taskListUpdateSuccess(data) {
try { try {
this.checkForSpam(data); this.checkForSpam(data);
this.closeRecaptcha();
} catch (error) { } catch (error) {
if (error && error.name === 'SpamError') this.openRecaptcha(); if (error && error.name === 'SpamError') this.openRecaptcha();
} }
......
export default function issueStatusSelect() { export default function issueStatusSelect() {
$('.js-issue-status').each((i, el) => { $('.js-issue-status').each((i, el) => {
const fieldName = $(el).data('field-name'); const fieldName = $(el).data('fieldName');
return $(el).glDropdown({ return $(el).glDropdown({
selectable: true, selectable: true,
fieldName, fieldName,
......
...@@ -25,19 +25,19 @@ export default class LabelsSelect { ...@@ -25,19 +25,19 @@ export default class LabelsSelect {
$dropdown = $(dropdown); $dropdown = $(dropdown);
$dropdownContainer = $dropdown.closest('.labels-filter'); $dropdownContainer = $dropdown.closest('.labels-filter');
$toggleText = $dropdown.find('.dropdown-toggle-text'); $toggleText = $dropdown.find('.dropdown-toggle-text');
namespacePath = $dropdown.data('namespace-path'); namespacePath = $dropdown.data('namespacePath');
projectPath = $dropdown.data('project-path'); projectPath = $dropdown.data('projectPath');
labelUrl = $dropdown.data('labels'); labelUrl = $dropdown.data('labels');
issueUpdateURL = $dropdown.data('issueUpdate'); issueUpdateURL = $dropdown.data('issueUpdate');
selectedLabel = $dropdown.data('selected'); selectedLabel = $dropdown.data('selected');
if ((selectedLabel != null) && !$dropdown.hasClass('js-multiselect')) { if ((selectedLabel != null) && !$dropdown.hasClass('js-multiselect')) {
selectedLabel = selectedLabel.split(','); selectedLabel = selectedLabel.split(',');
} }
showNo = $dropdown.data('show-no'); showNo = $dropdown.data('showNo');
showAny = $dropdown.data('show-any'); showAny = $dropdown.data('showAny');
showMenuAbove = $dropdown.data('showMenuAbove'); showMenuAbove = $dropdown.data('showMenuAbove');
defaultLabel = $dropdown.data('default-label'); defaultLabel = $dropdown.data('defaultLabel');
abilityName = $dropdown.data('ability-name'); abilityName = $dropdown.data('abilityName');
$selectbox = $dropdown.closest('.selectbox'); $selectbox = $dropdown.closest('.selectbox');
$block = $selectbox.closest('.block'); $block = $selectbox.closest('.block');
$form = $dropdown.closest('form, .js-issuable-update'); $form = $dropdown.closest('form, .js-issuable-update');
...@@ -45,11 +45,11 @@ export default class LabelsSelect { ...@@ -45,11 +45,11 @@ export default class LabelsSelect {
$sidebarLabelTooltip = $block.find('.js-sidebar-labels-tooltip'); $sidebarLabelTooltip = $block.find('.js-sidebar-labels-tooltip');
$value = $block.find('.value'); $value = $block.find('.value');
$loading = $block.find('.block-loading').fadeOut(); $loading = $block.find('.block-loading').fadeOut();
fieldName = $dropdown.data('field-name'); fieldName = $dropdown.data('fieldName');
useId = $dropdown.is('.js-issuable-form-dropdown, .js-filter-bulk-update, .js-label-sidebar-dropdown'); useId = $dropdown.is('.js-issuable-form-dropdown, .js-filter-bulk-update, .js-label-sidebar-dropdown');
propertyName = useId ? 'id' : 'title'; propertyName = useId ? 'id' : 'title';
initialSelected = $selectbox initialSelected = $selectbox
.find('input[name="' + $dropdown.data('field-name') + '"]') .find('input[name="' + $dropdown.data('fieldName') + '"]')
.map(function () { .map(function () {
return this.value; return this.value;
}).get(); }).get();
...@@ -268,7 +268,7 @@ export default class LabelsSelect { ...@@ -268,7 +268,7 @@ export default class LabelsSelect {
return defaultLabel; return defaultLabel;
} }
}, },
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('fieldName'),
id: function(label) { id: function(label) {
if (label.id <= 0) return label.title; if (label.id <= 0) return label.title;
......
...@@ -4,7 +4,7 @@ import initFlyOutNav from './fly_out_nav'; ...@@ -4,7 +4,7 @@ import initFlyOutNav from './fly_out_nav';
function hideEndFade($scrollingTabs) { function hideEndFade($scrollingTabs) {
$scrollingTabs.each(function scrollTabsLoop() { $scrollingTabs.each(function scrollTabsLoop() {
const $this = $(this); const $this = $(this);
$this.siblings('.fade-right').toggleClass('scrolling', $this.width() < $this.prop('scrollWidth')); $this.siblings('.fade-right').toggleClass('scrolling', Math.round($this.width()) < $this.prop('scrollWidth'));
}); });
} }
......
...@@ -138,7 +138,7 @@ textUtils.init = function(form) { ...@@ -138,7 +138,7 @@ textUtils.init = function(form) {
return $('.js-md', form).off('click').on('click', function() { return $('.js-md', form).off('click').on('click', function() {
var $this; var $this;
$this = $(this); $this = $(this);
return self.updateText($this.closest('.md-area').find('textarea'), $this.data('md-tag'), $this.data('md-block'), !$this.data('md-prepend')); return self.updateText($this.closest('.md-area').find('textarea'), $this.data('mdTag'), $this.data('mdBlock'), !$this.data('mdPrepend'));
}); });
}; };
......
...@@ -83,7 +83,7 @@ LineHighlighter.prototype.clickHandler = function(event) { ...@@ -83,7 +83,7 @@ LineHighlighter.prototype.clickHandler = function(event) {
var current, lineNumber, range; var current, lineNumber, range;
event.preventDefault(); event.preventDefault();
this.clearHighlight(); this.clearHighlight();
lineNumber = $(event.target).closest('a').data('line-number'); lineNumber = $(event.target).closest('a').data('lineNumber');
current = this.hashToRange(this._hash); current = this.hashToRange(this._hash);
if (!(current[0] && event.shiftKey)) { if (!(current[0] && event.shiftKey)) {
// If there's no current selection, or there is but Shift wasn't held, // If there's no current selection, or there is but Shift wasn't held,
......
...@@ -220,7 +220,7 @@ $(() => { ...@@ -220,7 +220,7 @@ $(() => {
$document.on('click', '.js-confirm-danger', (e) => { $document.on('click', '.js-confirm-danger', (e) => {
const btn = $(e.target); const btn = $(e.target);
const form = btn.closest('form'); const form = btn.closest('form');
const text = btn.data('confirm-danger-message'); const text = btn.data('confirmDangerMessage');
e.preventDefault(); e.preventDefault();
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
......
...@@ -19,7 +19,7 @@ export default class Members { ...@@ -19,7 +19,7 @@ export default class Members {
isSelectable(selected, $el) { isSelectable(selected, $el) {
return !$el.hasClass('is-active'); return !$el.hasClass('is-active');
}, },
fieldName: $btn.data('field-name'), fieldName: $btn.data('fieldName'),
id(selected, $el) { id(selected, $el) {
return $el.data('id'); return $el.data('id');
}, },
...@@ -51,7 +51,7 @@ export default class Members { ...@@ -51,7 +51,7 @@ export default class Members {
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
getMemberListItems($el) { getMemberListItems($el) {
const $memberListItem = $el.is('.member') ? $el : $(`#${$el.data('el-id')}`); const $memberListItem = $el.is('.member') ? $el : $(`#${$el.data('elId')}`);
return { return {
$memberListItem, $memberListItem,
......
...@@ -361,7 +361,7 @@ export default class MergeRequestTabs { ...@@ -361,7 +361,7 @@ export default class MergeRequestTabs {
} }
diffViewType() { diffViewType() {
return $('.inline-parallel-buttons a.active').data('view-type'); return $('.inline-parallel-buttons a.active').data('viewType');
} }
isDiffAction(action) { isDiffAction(action) {
......
...@@ -24,19 +24,19 @@ export default class MilestoneSelect { ...@@ -24,19 +24,19 @@ export default class MilestoneSelect {
$els.each((i, dropdown) => { $els.each((i, dropdown) => {
let collapsedSidebarLabelTemplate, milestoneLinkNoneTemplate, milestoneLinkTemplate, selectedMilestone, selectedMilestoneDefault; let collapsedSidebarLabelTemplate, milestoneLinkNoneTemplate, milestoneLinkTemplate, selectedMilestone, selectedMilestoneDefault;
const $dropdown = $(dropdown); const $dropdown = $(dropdown);
const projectId = $dropdown.data('project-id'); const projectId = $dropdown.data('projectId');
const milestonesUrl = $dropdown.data('milestones'); const milestonesUrl = $dropdown.data('milestones');
const issueUpdateURL = $dropdown.data('issueUpdate'); const issueUpdateURL = $dropdown.data('issueUpdate');
const showNo = $dropdown.data('show-no'); const showNo = $dropdown.data('showNo');
const showAny = $dropdown.data('show-any'); const showAny = $dropdown.data('showAny');
const showMenuAbove = $dropdown.data('showMenuAbove'); const showMenuAbove = $dropdown.data('showMenuAbove');
const showUpcoming = $dropdown.data('show-upcoming'); const showUpcoming = $dropdown.data('showUpcoming');
const showStarted = $dropdown.data('show-started'); const showStarted = $dropdown.data('showStarted');
const useId = $dropdown.data('use-id'); const useId = $dropdown.data('useId');
const defaultLabel = $dropdown.data('default-label'); const defaultLabel = $dropdown.data('defaultLabel');
const defaultNo = $dropdown.data('default-no'); const defaultNo = $dropdown.data('defaultNo');
const issuableId = $dropdown.data('issuable-id'); const issuableId = $dropdown.data('issuableId');
const abilityName = $dropdown.data('ability-name'); const abilityName = $dropdown.data('abilityName');
const $selectBox = $dropdown.closest('.selectbox'); const $selectBox = $dropdown.closest('.selectbox');
const $block = $selectBox.closest('.block'); const $block = $selectBox.closest('.block');
const $sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon'); const $sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon');
...@@ -114,7 +114,7 @@ export default class MilestoneSelect { ...@@ -114,7 +114,7 @@ export default class MilestoneSelect {
} }
}, },
defaultLabel: defaultLabel, defaultLabel: defaultLabel,
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('fieldName'),
text: milestone => _.escape(milestone.title), text: milestone => _.escape(milestone.title),
id: (milestone) => { id: (milestone) => {
if (!useId && !$dropdown.is('.js-issuable-form-dropdown')) { if (!useId && !$dropdown.is('.js-issuable-form-dropdown')) {
...@@ -166,7 +166,7 @@ export default class MilestoneSelect { ...@@ -166,7 +166,7 @@ export default class MilestoneSelect {
} }
if (boardsStore) { if (boardsStore) {
boardsStore[$dropdown.data('field-name')] = selected.name; boardsStore[$dropdown.data('fieldName')] = selected.name;
e.preventDefault(); e.preventDefault();
} else if ($dropdown.hasClass('js-filter-submit') && (isIssueIndex || isMRIndex)) { } else if ($dropdown.hasClass('js-filter-submit') && (isIssueIndex || isMRIndex)) {
return Issuable.filterResults($dropdown.closest('form')); return Issuable.filterResults($dropdown.closest('form'));
......
...@@ -219,7 +219,7 @@ export default class Notes { ...@@ -219,7 +219,7 @@ export default class Notes {
} }
editNote = $textarea.closest('.note'); editNote = $textarea.closest('.note');
if (editNote.length) { if (editNote.length) {
originalText = $textarea.closest('form').data('original-note'); originalText = $textarea.closest('form').data('originalNote');
newText = $textarea.val(); newText = $textarea.val();
if (originalText !== newText) { if (originalText !== newText) {
if (!confirm('Are you sure you want to cancel editing this comment?')) { if (!confirm('Are you sure you want to cancel editing this comment?')) {
...@@ -609,9 +609,9 @@ export default class Notes { ...@@ -609,9 +609,9 @@ export default class Notes {
*/ */
addDiscussionNote($form, note, isNewDiffComment) { addDiscussionNote($form, note, isNewDiffComment) {
if ($form.attr('data-resolve-all') != null) { if ($form.attr('data-resolve-all') != null) {
var projectPath = $form.data('project-path'); var projectPath = $form.data('projectPath');
var discussionId = $form.data('discussion-id'); var discussionId = $form.data('discussionId');
var mergeRequestId = $form.data('noteable-iid'); var mergeRequestId = $form.data('noteableIid');
if (ResolveService != null) { if (ResolveService != null) {
ResolveService.toggleResolveForDiscussion(mergeRequestId, discussionId); ResolveService.toggleResolveForDiscussion(mergeRequestId, discussionId);
...@@ -751,7 +751,7 @@ export default class Notes { ...@@ -751,7 +751,7 @@ export default class Notes {
form.removeClass('current-note-edit-form'); form.removeClass('current-note-edit-form');
form.find('.js-finish-edit-warning').hide(); form.find('.js-finish-edit-warning').hide();
// Replace markdown textarea text with original note text. // Replace markdown textarea text with original note text.
return form.find('.js-note-text').val(form.find('form.edit-note').data('original-note')); return form.find('.js-note-text').val(form.find('form.edit-note').data('originalNote'));
} }
/** /**
...@@ -776,7 +776,7 @@ export default class Notes { ...@@ -776,7 +776,7 @@ export default class Notes {
var $note, $notes; var $note, $notes;
$note = $(el); $note = $(el);
$notes = $note.closest('.discussion-notes'); $notes = $note.closest('.discussion-notes');
const discussionId = $('.notes', $notes).data('discussion-id'); const discussionId = $('.notes', $notes).data('discussionId');
if (typeof gl.diffNotesCompileComponents !== 'undefined') { if (typeof gl.diffNotesCompileComponents !== 'undefined') {
if (gl.diffNoteApps[noteElId]) { if (gl.diffNoteApps[noteElId]) {
...@@ -897,7 +897,7 @@ export default class Notes { ...@@ -897,7 +897,7 @@ export default class Notes {
// DiffNote // DiffNote
form.find('#note_position').val(dataHolder.attr('data-position')); form.find('#note_position').val(dataHolder.attr('data-position'));
form.find('.js-note-discard').show().removeClass('js-note-discard').addClass('js-close-discussion-note-form').text(form.find('.js-close-discussion-note-form').data('cancel-text')); form.find('.js-note-discard').show().removeClass('js-note-discard').addClass('js-close-discussion-note-form').text(form.find('.js-close-discussion-note-form').data('cancelText'));
form.find('.js-note-target-close').remove(); form.find('.js-note-target-close').remove();
form.find('.js-note-new-discussion').remove(); form.find('.js-note-new-discussion').remove();
this.setupNoteForm(form); this.setupNoteForm(form);
...@@ -1037,7 +1037,7 @@ export default class Notes { ...@@ -1037,7 +1037,7 @@ export default class Notes {
removeDiscussionNoteForm(form) { removeDiscussionNoteForm(form) {
var glForm, row; var glForm, row;
row = form.closest('tr'); row = form.closest('tr');
glForm = form.data('gl-form'); glForm = form.data('glForm');
glForm.destroy(); glForm.destroy();
form.find('.js-note-text').data('autosave').reset(); form.find('.js-note-text').data('autosave').reset();
// show the reply button (will only work for replies) // show the reply button (will only work for replies)
...@@ -1122,8 +1122,8 @@ export default class Notes { ...@@ -1122,8 +1122,8 @@ export default class Notes {
return discardbtn.show(); return discardbtn.show();
} }
} else { } else {
reopentext = reopenbtn.data('original-text'); reopentext = reopenbtn.data('originalText');
closetext = closebtn.data('original-text'); closetext = closebtn.data('originalText');
if (reopenbtn.text() !== reopentext) { if (reopenbtn.text() !== reopentext) {
reopenbtn.text(reopentext); reopenbtn.text(reopentext);
} }
...@@ -1150,9 +1150,9 @@ export default class Notes { ...@@ -1150,9 +1150,9 @@ export default class Notes {
var $originalContentEl = $note.find('.original-note-content'); var $originalContentEl = $note.find('.original-note-content');
var originalContent = $originalContentEl.text().trim(); var originalContent = $originalContentEl.text().trim();
var postUrl = $originalContentEl.data('post-url'); var postUrl = $originalContentEl.data('postUrl');
var targetId = $originalContentEl.data('target-id'); var targetId = $originalContentEl.data('targetId');
var targetType = $originalContentEl.data('target-type'); var targetType = $originalContentEl.data('targetType');
this.glForm = new GLForm($editForm.find('form'), this.enableGFM); this.glForm = new GLForm($editForm.find('form'), this.enableGFM);
...@@ -1513,9 +1513,9 @@ export default class Notes { ...@@ -1513,9 +1513,9 @@ export default class Notes {
// If comment intends to resolve discussion, do the same. // If comment intends to resolve discussion, do the same.
if (isDiscussionResolve) { if (isDiscussionResolve) {
$form $form
.attr('data-discussion-id', $submitBtn.data('discussion-id')) .attr('data-discussion-id', $submitBtn.data('discussionId'))
.attr('data-resolve-all', 'true') .attr('data-resolve-all', 'true')
.attr('data-project-path', $submitBtn.data('project-path')); .attr('data-project-path', $submitBtn.data('projectPath'));
} }
// Show final note element on UI // Show final note element on UI
...@@ -1587,7 +1587,7 @@ export default class Notes { ...@@ -1587,7 +1587,7 @@ export default class Notes {
this.addNoteError($form); this.addNoteError($form);
}); });
return $closeBtn.text($closeBtn.data('original-text')); return $closeBtn.text($closeBtn.data('originalText'));
} }
/** /**
...@@ -1642,7 +1642,7 @@ export default class Notes { ...@@ -1642,7 +1642,7 @@ export default class Notes {
this.updateNoteError(); this.updateNoteError();
}); });
return $closeBtn.text($closeBtn.data('original-text')); return $closeBtn.text($closeBtn.data('originalText'));
} }
} }
......
...@@ -3,11 +3,11 @@ import Flash from './flash'; ...@@ -3,11 +3,11 @@ import Flash from './flash';
export default function notificationsDropdown() { export default function notificationsDropdown() {
$(document).on('click', '.update-notification', function updateNotificationCallback(e) { $(document).on('click', '.update-notification', function updateNotificationCallback(e) {
e.preventDefault(); e.preventDefault();
if ($(this).is('.is-active') && $(this).data('notification-level') === 'custom') { if ($(this).is('.is-active') && $(this).data('notificationLevel') === 'custom') {
return; return;
} }
const notificationLevel = $(this).data('notification-level'); const notificationLevel = $(this).data('notificationLevel');
const form = $(this).parents('.notification-form:first'); const form = $(this).parents('.notification-form:first');
form.find('.js-notification-loading').toggleClass('fa-bell fa-spin fa-spinner'); form.find('.js-notification-loading').toggleClass('fa-bell fa-spin fa-spinner');
......
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
}, },
initLoadMore() { initLoadMore() {
$(document).unbind('scroll'); $(document).off('scroll');
$(document).endlessScroll({ $(document).endlessScroll({
bottomPixels: ENDLESS_SCROLL_BOTTOM_PX, bottomPixels: ENDLESS_SCROLL_BOTTOM_PX,
fireDelay: ENDLESS_SCROLL_FIRE_DELAY_MS, fireDelay: ENDLESS_SCROLL_FIRE_DELAY_MS,
......
...@@ -15,21 +15,21 @@ export default class AbuseReports { ...@@ -15,21 +15,21 @@ export default class AbuseReports {
const $messageCellElement = $(this); const $messageCellElement = $(this);
const reportMessage = $messageCellElement.text(); const reportMessage = $messageCellElement.text();
if (reportMessage.length > MAX_MESSAGE_LENGTH) { if (reportMessage.length > MAX_MESSAGE_LENGTH) {
$messageCellElement.data('original-message', reportMessage); $messageCellElement.data('originalMessage', reportMessage);
$messageCellElement.data('message-truncated', 'true'); $messageCellElement.data('messageTruncated', 'true');
$messageCellElement.text(truncate(reportMessage, MAX_MESSAGE_LENGTH)); $messageCellElement.text(truncate(reportMessage, MAX_MESSAGE_LENGTH));
} }
} }
toggleMessageTruncation() { toggleMessageTruncation() {
const $messageCellElement = $(this); const $messageCellElement = $(this);
const originalMessage = $messageCellElement.data('original-message'); const originalMessage = $messageCellElement.data('originalMessage');
if (!originalMessage) return; if (!originalMessage) return;
if ($messageCellElement.data('message-truncated') === 'true') { if ($messageCellElement.data('messageTruncated') === 'true') {
$messageCellElement.data('message-truncated', 'false'); $messageCellElement.data('messageTruncated', 'false');
$messageCellElement.text(originalMessage); $messageCellElement.text(originalMessage);
} else { } else {
$messageCellElement.data('message-truncated', 'true'); $messageCellElement.data('messageTruncated', 'true');
$messageCellElement.text(`${originalMessage.substr(0, (MAX_MESSAGE_LENGTH - 3))}...`); $messageCellElement.text(`${originalMessage.substr(0, (MAX_MESSAGE_LENGTH - 3))}...`);
} }
} }
......
...@@ -16,9 +16,9 @@ export default function adminInit() { ...@@ -16,9 +16,9 @@ export default function adminInit() {
$('input#user_force_random_password').on('change', function randomPasswordClick() { $('input#user_force_random_password').on('change', function randomPasswordClick() {
const $elems = $('#user_password, #user_password_confirmation'); const $elems = $('#user_password, #user_password_confirmation');
if ($(this).attr('checked')) { if ($(this).attr('checked')) {
$elems.val('').attr('disabled', true); $elems.val('').prop('disabled', true);
} else { } else {
$elems.removeAttr('disabled'); $elems.prop('disabled', false);
} }
}); });
......
...@@ -14,7 +14,7 @@ export default function initBroadcastMessagesForm() { ...@@ -14,7 +14,7 @@ export default function initBroadcastMessagesForm() {
$('div.broadcast-message-preview').css('color', previewColor); $('div.broadcast-message-preview').css('color', previewColor);
}); });
const previewPath = $('textarea#broadcast_message_message').data('preview-path'); const previewPath = $('textarea#broadcast_message_message').data('previewPath');
$('textarea#broadcast_message_message').on('input', _.debounce(function onMessageInput() { $('textarea#broadcast_message_message').on('input', _.debounce(function onMessageInput() {
const message = $(this).val(); const message = $(this).val();
......
...@@ -71,7 +71,7 @@ export default class Project { ...@@ -71,7 +71,7 @@ export default class Project {
selected = $dropdown.data('selected'); selected = $dropdown.data('selected');
return $dropdown.glDropdown({ return $dropdown.glDropdown({
data(term, callback) { data(term, callback) {
axios.get($dropdown.data('refs-url'), { axios.get($dropdown.data('refsUrl'), {
params: { params: {
ref: $dropdown.data('ref'), ref: $dropdown.data('ref'),
search: term, search: term,
...@@ -84,8 +84,8 @@ export default class Project { ...@@ -84,8 +84,8 @@ export default class Project {
filterable: true, filterable: true,
filterRemote: true, filterRemote: true,
filterByText: true, filterByText: true,
inputFieldName: $dropdown.data('input-field-name'), inputFieldName: $dropdown.data('inputFieldName'),
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('fieldName'),
renderRow: function(ref) { renderRow: function(ref) {
var li = refListItem.cloneNode(false); var li = refListItem.cloneNode(false);
......
...@@ -9,7 +9,7 @@ export default class Search { ...@@ -9,7 +9,7 @@ export default class Search {
this.searchInput = '.js-search-input'; this.searchInput = '.js-search-input';
this.searchClear = '.js-search-clear'; this.searchClear = '.js-search-clear';
this.groupId = $groupDropdown.data('group-id'); this.groupId = $groupDropdown.data('groupId');
this.eventListeners(); this.eventListeners();
$groupDropdown.glDropdown({ $groupDropdown.glDropdown({
...@@ -36,7 +36,7 @@ export default class Search { ...@@ -36,7 +36,7 @@ export default class Search {
return obj.full_name; return obj.full_name;
}, },
toggleLabel(obj) { toggleLabel(obj) {
return `${($groupDropdown.data('default-label'))} ${obj.full_name}`; return `${($groupDropdown.data('defaultLabel'))} ${obj.full_name}`;
}, },
clicked: () => Search.submitSearch(), clicked: () => Search.submitSearch(),
}); });
...@@ -69,7 +69,7 @@ export default class Search { ...@@ -69,7 +69,7 @@ export default class Search {
return obj.name_with_namespace; return obj.name_with_namespace;
}, },
toggleLabel(obj) { toggleLabel(obj) {
return `${($projectDropdown.data('default-label'))} ${obj.name_with_namespace}`; return `${($projectDropdown.data('defaultLabel'))} ${obj.name_with_namespace}`;
}, },
clicked: () => Search.submitSearch(), clicked: () => Search.submitSearch(),
}); });
......
...@@ -5,13 +5,13 @@ import ProjectSelectComboButton from './project_select_combo_button'; ...@@ -5,13 +5,13 @@ import ProjectSelectComboButton from './project_select_combo_button';
export default function projectSelect() { export default function projectSelect() {
$('.ajax-project-select').each(function(i, select) { $('.ajax-project-select').each(function(i, select) {
var placeholder; var placeholder;
const simpleFilter = $(select).data('simple-filter') || false; const simpleFilter = $(select).data('simpleFilter') || false;
this.groupId = $(select).data('group-id'); this.groupId = $(select).data('groupId');
this.includeGroups = $(select).data('include-groups'); this.includeGroups = $(select).data('includeGroups');
this.allProjects = $(select).data('all-projects') || false; this.allProjects = $(select).data('allProjects') || false;
this.orderBy = $(select).data('order-by') || 'id'; this.orderBy = $(select).data('orderBy') || 'id';
this.withIssuesEnabled = $(select).data('with-issues-enabled'); this.withIssuesEnabled = $(select).data('withIssuesEnabled');
this.withMergeRequestsEnabled = $(select).data('with-merge-requests-enabled'); this.withMergeRequestsEnabled = $(select).data('withMergeRequestsEnabled');
placeholder = "Search for project"; placeholder = "Search for project";
if (this.includeGroups) { if (this.includeGroups) {
......
...@@ -19,7 +19,7 @@ export default class PrometheusMetrics { ...@@ -19,7 +19,7 @@ export default class PrometheusMetrics {
this.$missingEnvVarMetricCount = this.$missingEnvVarPanel.find('.js-env-var-count'); this.$missingEnvVarMetricCount = this.$missingEnvVarPanel.find('.js-env-var-count');
this.$missingEnvVarMetricsList = this.$missingEnvVarPanel.find('.js-missing-var-metrics-list'); this.$missingEnvVarMetricsList = this.$missingEnvVarPanel.find('.js-missing-var-metrics-list');
this.activeMetricsEndpoint = this.$monitoredMetricsPanel.data('active-metrics'); this.activeMetricsEndpoint = this.$monitoredMetricsPanel.data('activeMetrics');
this.$panelToggle.on('click', e => this.handlePanelToggle(e)); this.$panelToggle.on('click', e => this.handlePanelToggle(e));
} }
......
...@@ -9,8 +9,8 @@ export default class ProtectedBranchAccessDropdown { ...@@ -9,8 +9,8 @@ export default class ProtectedBranchAccessDropdown {
$dropdown.glDropdown({ $dropdown.glDropdown({
data, data,
selectable: true, selectable: true,
inputId: $dropdown.data('input-id'), inputId: $dropdown.data('inputId'),
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('fieldName'),
toggleLabel(item, $el) { toggleLabel(item, $el) {
if ($el.is('.is-active')) { if ($el.is('.is-active')) {
return item.text; return item.text;
......
...@@ -59,7 +59,7 @@ export default class ProtectedBranchCreate { ...@@ -59,7 +59,7 @@ export default class ProtectedBranchCreate {
); );
this.savePreviousSelection($allowedToMergeInput.val(), $allowedToPushInput.val()); this.savePreviousSelection($allowedToMergeInput.val(), $allowedToPushInput.val());
this.$form.find('input[type="submit"]').attr('disabled', completedForm); this.$form.find('input[type="submit"]').prop('disabled', completedForm);
} }
static getProtectedBranches(term, callback) { static getProtectedBranches(term, callback) {
......
...@@ -41,11 +41,11 @@ export default class ProtectedBranchEdit { ...@@ -41,11 +41,11 @@ export default class ProtectedBranchEdit {
axios.patch(this.$wrap.data('url'), { axios.patch(this.$wrap.data('url'), {
protected_branch: { protected_branch: {
merge_access_levels_attributes: [{ merge_access_levels_attributes: [{
id: this.$allowedToMergeDropdown.data('access-level-id'), id: this.$allowedToMergeDropdown.data('accessLevelId'),
access_level: $allowedToMergeInput.val(), access_level: $allowedToMergeInput.val(),
}], }],
push_access_levels_attributes: [{ push_access_levels_attributes: [{
id: this.$allowedToPushDropdown.data('access-level-id'), id: this.$allowedToPushDropdown.data('accessLevelId'),
access_level: $allowedToPushInput.val(), access_level: $allowedToPushInput.val(),
}], }],
}, },
......
...@@ -9,8 +9,8 @@ export default class ProtectedTagAccessDropdown { ...@@ -9,8 +9,8 @@ export default class ProtectedTagAccessDropdown {
this.options.$dropdown.glDropdown({ this.options.$dropdown.glDropdown({
data: this.options.data, data: this.options.data,
selectable: true, selectable: true,
inputId: this.options.$dropdown.data('input-id'), inputId: this.options.$dropdown.data('inputId'),
fieldName: this.options.$dropdown.data('field-name'), fieldName: this.options.$dropdown.data('fieldName'),
toggleLabel(item, $el) { toggleLabel(item, $el) {
if ($el.is('.is-active')) { if ($el.is('.is-active')) {
return item.text; return item.text;
......
...@@ -39,7 +39,7 @@ export default class ProtectedTagCreate { ...@@ -39,7 +39,7 @@ export default class ProtectedTagCreate {
const $tagInput = this.$form.find('input[name="protected_tag[name]"]'); const $tagInput = this.$form.find('input[name="protected_tag[name]"]');
const $allowedToCreateInput = this.$form.find('#create_access_levels_attributes'); const $allowedToCreateInput = this.$form.find('#create_access_levels_attributes');
this.$form.find('input[type="submit"]').attr('disabled', !($tagInput.val() && $allowedToCreateInput.length)); this.$form.find('input[type="submit"]').prop('disabled', !($tagInput.val() && $allowedToCreateInput.length));
} }
static getProtectedTags(term, callback) { static getProtectedTags(term, callback) {
......
...@@ -31,7 +31,7 @@ export default class ProtectedTagEdit { ...@@ -31,7 +31,7 @@ export default class ProtectedTagEdit {
axios.patch(this.$wrap.data('url'), { axios.patch(this.$wrap.data('url'), {
protected_tag: { protected_tag: {
create_access_levels_attributes: [{ create_access_levels_attributes: [{
id: this.$allowedToCreateDropdownButton.data('access-level-id'), id: this.$allowedToCreateDropdownButton.data('accessLevelId'),
access_level: $allowedToCreateInput.val(), access_level: $allowedToCreateInput.val(),
}], }],
}, },
......
...@@ -6,7 +6,7 @@ class RefSelectDropdown { ...@@ -6,7 +6,7 @@ class RefSelectDropdown {
filterable: true, filterable: true,
filterByText: true, filterByText: true,
remote: false, remote: false,
fieldName: $dropdownButton.data('field-name'), fieldName: $dropdownButton.data('fieldName'),
filterInput: 'input[type="search"]', filterInput: 'input[type="search"]',
selectable: true, selectable: true,
isSelectable(branch, $el) { isSelectable(branch, $el) {
...@@ -24,7 +24,7 @@ class RefSelectDropdown { ...@@ -24,7 +24,7 @@ class RefSelectDropdown {
}); });
const $dropdownContainer = $dropdownButton.closest('.dropdown'); const $dropdownContainer = $dropdownButton.closest('.dropdown');
const $fieldInput = $(`input[name="${$dropdownButton.data('field-name')}"]`, $dropdownContainer); const $fieldInput = $(`input[name="${$dropdownButton.data('fieldName')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer); const $filterInput = $('input[type="search"]', $dropdownContainer);
$filterInput.on('keyup', (e) => { $filterInput.on('keyup', (e) => {
......
...@@ -76,8 +76,8 @@ Sidebar.prototype.toggleTodo = function(e) { ...@@ -76,8 +76,8 @@ Sidebar.prototype.toggleTodo = function(e) {
$('.js-issuable-todo').disable().addClass('is-loading'); $('.js-issuable-todo').disable().addClass('is-loading');
axios[ajaxType](url, { axios[ajaxType](url, {
issuable_id: $this.data('issuable-id'), issuable_id: $this.data('issuableId'),
issuable_type: $this.data('issuable-type'), issuable_type: $this.data('issuableType'),
}).then(({ data }) => { }).then(({ data }) => {
this.todoUpdateDone(data); this.todoUpdateDone(data);
}).catch(() => flash(`There was an error ${ajaxType === 'post' ? 'adding a' : 'deleting the'} todo.`)); }).catch(() => flash(`There was an error ${ajaxType === 'post' ? 'adding a' : 'deleting the'} todo.`));
...@@ -96,18 +96,18 @@ Sidebar.prototype.todoUpdateDone = function(data) { ...@@ -96,18 +96,18 @@ Sidebar.prototype.todoUpdateDone = function(data) {
$el.removeClass('is-loading') $el.removeClass('is-loading')
.enable() .enable()
.attr('aria-label', $el.data(`${attrPrefix}-text`)) .attr('aria-label', $el.data(`${attrPrefix}Text`))
.attr('data-delete-path', deletePath) .attr('data-delete-path', deletePath)
.attr('title', $el.data(`${attrPrefix}-text`)); .attr('title', $el.data(`${attrPrefix}Text`));
if ($el.hasClass('has-tooltip')) { if ($el.hasClass('has-tooltip')) {
$el.tooltip('fixTitle'); $el.tooltip('fixTitle');
} }
if ($el.data(`${attrPrefix}-icon`)) { if ($el.data(`${attrPrefix}Icon`)) {
$elText.html($el.data(`${attrPrefix}-icon`)); $elText.html($el.data(`${attrPrefix}Icon`));
} else { } else {
$elText.text($el.data(`${attrPrefix}-text`)); $elText.text($el.data(`${attrPrefix}Text`));
} }
}); });
}; };
......
...@@ -25,32 +25,32 @@ function setSearchOptions() { ...@@ -25,32 +25,32 @@ function setSearchOptions() {
if ($projectOptionsDataEl.length) { if ($projectOptionsDataEl.length) {
gl.projectOptions = gl.projectOptions || {}; gl.projectOptions = gl.projectOptions || {};
var projectPath = $projectOptionsDataEl.data('project-path'); var projectPath = $projectOptionsDataEl.data('projectPath');
gl.projectOptions[projectPath] = { gl.projectOptions[projectPath] = {
name: $projectOptionsDataEl.data('name'), name: $projectOptionsDataEl.data('name'),
issuesPath: $projectOptionsDataEl.data('issues-path'), issuesPath: $projectOptionsDataEl.data('issuesPath'),
issuesDisabled: $projectOptionsDataEl.data('issues-disabled'), issuesDisabled: $projectOptionsDataEl.data('issuesDisabled'),
mrPath: $projectOptionsDataEl.data('mr-path'), mrPath: $projectOptionsDataEl.data('mrPath'),
}; };
} }
if ($groupOptionsDataEl.length) { if ($groupOptionsDataEl.length) {
gl.groupOptions = gl.groupOptions || {}; gl.groupOptions = gl.groupOptions || {};
var groupPath = $groupOptionsDataEl.data('group-path'); var groupPath = $groupOptionsDataEl.data('groupPath');
gl.groupOptions[groupPath] = { gl.groupOptions[groupPath] = {
name: $groupOptionsDataEl.data('name'), name: $groupOptionsDataEl.data('name'),
issuesPath: $groupOptionsDataEl.data('issues-path'), issuesPath: $groupOptionsDataEl.data('issuesPath'),
mrPath: $groupOptionsDataEl.data('mr-path'), mrPath: $groupOptionsDataEl.data('mrPath'),
}; };
} }
if ($dashboardOptionsDataEl.length) { if ($dashboardOptionsDataEl.length) {
gl.dashboardOptions = { gl.dashboardOptions = {
issuesPath: $dashboardOptionsDataEl.data('issues-path'), issuesPath: $dashboardOptionsDataEl.data('issuesPath'),
mrPath: $dashboardOptionsDataEl.data('mr-path'), mrPath: $dashboardOptionsDataEl.data('mrPath'),
}; };
} }
} }
...@@ -61,9 +61,9 @@ export default class SearchAutocomplete { ...@@ -61,9 +61,9 @@ export default class SearchAutocomplete {
this.bindEventContext(); this.bindEventContext();
this.wrap = wrap || $('.search'); this.wrap = wrap || $('.search');
this.optsEl = optsEl || this.wrap.find('.search-autocomplete-opts'); this.optsEl = optsEl || this.wrap.find('.search-autocomplete-opts');
this.autocompletePath = autocompletePath || this.optsEl.data('autocomplete-path'); this.autocompletePath = autocompletePath || this.optsEl.data('autocompletePath');
this.projectId = projectId || (this.optsEl.data('autocomplete-project-id') || ''); this.projectId = projectId || (this.optsEl.data('autocompleteProjectId') || '');
this.projectRef = projectRef || (this.optsEl.data('autocomplete-project-ref') || ''); this.projectRef = projectRef || (this.optsEl.data('autocompleteProjectRef') || '');
this.dropdown = this.wrap.find('.dropdown'); this.dropdown = this.wrap.find('.dropdown');
this.dropdownToggle = this.wrap.find('.js-dropdown-search-toggle'); this.dropdownToggle = this.wrap.find('.js-dropdown-search-toggle');
this.dropdownContent = this.dropdown.find('.dropdown-content'); this.dropdownContent = this.dropdown.find('.dropdown-content');
......
...@@ -50,7 +50,7 @@ class SidebarMoveIssue { ...@@ -50,7 +50,7 @@ class SidebarMoveIssue {
const selectedProjectId = options.isMarking ? project.id : 0; const selectedProjectId = options.isMarking ? project.id : 0;
this.mediator.setMoveToProjectId(selectedProjectId); this.mediator.setMoveToProjectId(selectedProjectId);
this.$confirmButton.attr('disabled', !isValidProjectId(selectedProjectId)); this.$confirmButton.prop('disabled', !isValidProjectId(selectedProjectId));
}, },
}); });
} }
......
...@@ -18,7 +18,7 @@ export default class SingleFileDiff { ...@@ -18,7 +18,7 @@ export default class SingleFileDiff {
this.toggleDiff = this.toggleDiff.bind(this); this.toggleDiff = this.toggleDiff.bind(this);
this.content = $('.diff-content', this.file); this.content = $('.diff-content', this.file);
this.$toggleIcon = $('.diff-toggle-caret', this.file); this.$toggleIcon = $('.diff-toggle-caret', this.file);
this.diffForPath = this.content.find('[data-diff-for-path]').data('diff-for-path'); this.diffForPath = this.content.find('[data-diff-for-path]').data('diffForPath');
this.isOpen = !this.diffForPath; this.isOpen = !this.diffForPath;
if (this.diffForPath) { if (this.diffForPath) {
this.collapsedContent = this.content; this.collapsedContent = this.content;
......
import Flash from './flash'; import Flash from './flash';
import { __, s__ } from './locale'; import { __, s__ } from './locale';
import { spriteIcon } from './lib/utils/common_utils'; import { spriteIcon } from './lib/utils/common_utils';
import axios from './lib/utils/axios_utils';
export default class Star { export default class Star {
constructor() { constructor() {
$('.project-home-panel .toggle-star') $('.project-home-panel .toggle-star').on('click', function toggleStarClickCallback() {
.on('ajax:success', function handleSuccess(e, data) { const $this = $(this);
const $this = $(this); const $starSpan = $this.find('span');
const $starSpan = $this.find('span'); const $startIcon = $this.find('svg');
const $startIcon = $this.find('svg');
function toggleStar(isStarred) { axios.post($this.data('endpoint'))
.then(({ data }) => {
const isStarred = $starSpan.hasClass('starred');
$this.parent().find('.star-count').text(data.star_count); $this.parent().find('.star-count').text(data.star_count);
if (isStarred) { if (isStarred) {
$starSpan.removeClass('starred').text(s__('StarProject|Star')); $starSpan.removeClass('starred').text(s__('StarProject|Star'));
$startIcon.remove(); $startIcon.remove();
...@@ -21,12 +24,8 @@ export default class Star { ...@@ -21,12 +24,8 @@ export default class Star {
$startIcon.remove(); $startIcon.remove();
$this.prepend(spriteIcon('star')); $this.prepend(spriteIcon('star'));
} }
} })
.catch(() => Flash('Star toggle failed. Try again later.'));
toggleStar($starSpan.hasClass('starred')); });
})
.on('ajax:error', () => {
Flash('Star toggle failed. Try again later.', 'alert');
});
} }
} }
export default function subscriptionSelect() { export default function subscriptionSelect() {
$('.js-subscription-event').each((i, element) => { $('.js-subscription-event').each((i, element) => {
const fieldName = $(element).data('field-name'); const fieldName = $(element).data('fieldName');
return $(element).glDropdown({ return $(element).glDropdown({
selectable: true, selectable: true,
......
...@@ -40,7 +40,7 @@ export default class TaskList { ...@@ -40,7 +40,7 @@ export default class TaskList {
[this.fieldName]: $target.val(), [this.fieldName]: $target.val(),
}; };
return axios.patch($target.data('update-url') || $('form.js-issuable-update').attr('action'), patchData) return axios.patch($target.data('updateUrl') || $('form.js-issuable-update').attr('action'), patchData)
.then(({ data }) => this.onSuccess(data)) .then(({ data }) => this.onSuccess(data))
.catch(err => this.onError(err)); .catch(err => this.onError(err));
} }
......
...@@ -6,9 +6,9 @@ import TemplateSelector from '../blob/template_selector'; ...@@ -6,9 +6,9 @@ import TemplateSelector from '../blob/template_selector';
export default class IssuableTemplateSelector extends TemplateSelector { export default class IssuableTemplateSelector extends TemplateSelector {
constructor(...args) { constructor(...args) {
super(...args); super(...args);
this.projectPath = this.dropdown.data('project-path'); this.projectPath = this.dropdown.data('projectPath');
this.namespacePath = this.dropdown.data('namespace-path'); this.namespacePath = this.dropdown.data('namespacePath');
this.issuableType = this.$dropdownContainer.data('issuable-type'); this.issuableType = this.$dropdownContainer.data('issuableType');
this.titleInput = $(`#${this.issuableType}_title`); this.titleInput = $(`#${this.issuableType}_title`);
const initialQuery = { const initialQuery = {
......
...@@ -22,7 +22,7 @@ export default class UserCallout { ...@@ -22,7 +22,7 @@ export default class UserCallout {
const $currentTarget = $(e.currentTarget); const $currentTarget = $(e.currentTarget);
if (this.options.setCalloutPerProject) { if (this.options.setCalloutPerProject) {
Cookies.set(this.cookieName, 'true', { expires: 365, path: this.userCalloutBody.data('project-path') }); Cookies.set(this.cookieName, 'true', { expires: 365, path: this.userCalloutBody.data('projectPath') });
} else { } else {
Cookies.set(this.cookieName, 'true', { expires: 365 }); Cookies.set(this.cookieName, 'true', { expires: 365 });
} }
......
...@@ -34,23 +34,23 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -34,23 +34,23 @@ function UsersSelect(currentUser, els, options = {}) {
var options = {}; var options = {};
var $block, $collapsedSidebar, $dropdown, $loading, $selectbox, $value, abilityName, assignTo, assigneeTemplate, collapsedAssigneeTemplate, defaultLabel, defaultNullUser, firstUser, issueURL, selectedId, selectedIdDefault, showAnyUser, showNullUser, showMenuAbove; var $block, $collapsedSidebar, $dropdown, $loading, $selectbox, $value, abilityName, assignTo, assigneeTemplate, collapsedAssigneeTemplate, defaultLabel, defaultNullUser, firstUser, issueURL, selectedId, selectedIdDefault, showAnyUser, showNullUser, showMenuAbove;
$dropdown = $(dropdown); $dropdown = $(dropdown);
options.projectId = $dropdown.data('project-id'); options.projectId = $dropdown.data('projectId');
options.groupId = $dropdown.data('group-id'); options.groupId = $dropdown.data('groupId');
options.showCurrentUser = $dropdown.data('current-user'); options.showCurrentUser = $dropdown.data('currentUser');
options.todoFilter = $dropdown.data('todo-filter'); options.todoFilter = $dropdown.data('todoFilter');
options.todoStateFilter = $dropdown.data('todo-state-filter'); options.todoStateFilter = $dropdown.data('todoStateFilter');
options.perPage = $dropdown.data('per-page'); options.perPage = $dropdown.data('perPage');
showNullUser = $dropdown.data('null-user'); showNullUser = $dropdown.data('nullUser');
defaultNullUser = $dropdown.data('null-user-default'); defaultNullUser = $dropdown.data('nullUserDefault');
showMenuAbove = $dropdown.data('showMenuAbove'); showMenuAbove = $dropdown.data('showMenuAbove');
showAnyUser = $dropdown.data('any-user'); showAnyUser = $dropdown.data('anyUser');
firstUser = $dropdown.data('first-user'); firstUser = $dropdown.data('firstUser');
options.authorId = $dropdown.data('author-id'); options.authorId = $dropdown.data('authorId');
defaultLabel = $dropdown.data('default-label'); defaultLabel = $dropdown.data('defaultLabel');
issueURL = $dropdown.data('issueUpdate'); issueURL = $dropdown.data('issueUpdate');
$selectbox = $dropdown.closest('.selectbox'); $selectbox = $dropdown.closest('.selectbox');
$block = $selectbox.closest('.block'); $block = $selectbox.closest('.block');
abilityName = $dropdown.data('ability-name'); abilityName = $dropdown.data('abilityName');
$value = $block.find('.value'); $value = $block.find('.value');
$collapsedSidebar = $block.find('.sidebar-collapsed-user'); $collapsedSidebar = $block.find('.sidebar-collapsed-user');
$loading = $block.find('.block-loading').fadeOut(); $loading = $block.find('.block-loading').fadeOut();
...@@ -63,7 +63,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -63,7 +63,7 @@ function UsersSelect(currentUser, els, options = {}) {
const assignYourself = function () { const assignYourself = function () {
const unassignedSelected = $dropdown.closest('.selectbox') const unassignedSelected = $dropdown.closest('.selectbox')
.find(`input[name='${$dropdown.data('field-name')}'][value=0]`); .find(`input[name='${$dropdown.data('fieldName')}'][value=0]`);
if (unassignedSelected) { if (unassignedSelected) {
unassignedSelected.remove(); unassignedSelected.remove();
...@@ -72,7 +72,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -72,7 +72,7 @@ function UsersSelect(currentUser, els, options = {}) {
// Save current selected user to the DOM // Save current selected user to the DOM
const input = document.createElement('input'); const input = document.createElement('input');
input.type = 'hidden'; input.type = 'hidden';
input.name = $dropdown.data('field-name'); input.name = $dropdown.data('fieldName');
const currentUserInfo = $dropdown.data('currentUserInfo'); const currentUserInfo = $dropdown.data('currentUserInfo');
...@@ -96,7 +96,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -96,7 +96,7 @@ function UsersSelect(currentUser, els, options = {}) {
const getSelectedUserInputs = function() { const getSelectedUserInputs = function() {
return $selectbox return $selectbox
.find(`input[name="${$dropdown.data('field-name')}"]`); .find(`input[name="${$dropdown.data('fieldName')}"]`);
}; };
const getSelected = function() { const getSelected = function() {
...@@ -106,14 +106,14 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -106,14 +106,14 @@ function UsersSelect(currentUser, els, options = {}) {
}; };
const checkMaxSelect = function() { const checkMaxSelect = function() {
const maxSelect = $dropdown.data('max-select'); const maxSelect = $dropdown.data('maxSelect');
if (maxSelect) { if (maxSelect) {
const selected = getSelected(); const selected = getSelected();
if (selected.length > maxSelect) { if (selected.length > maxSelect) {
const firstSelectedId = selected[0]; const firstSelectedId = selected[0];
const firstSelected = $dropdown.closest('.selectbox') const firstSelected = $dropdown.closest('.selectbox')
.find(`input[name='${$dropdown.data('field-name')}'][value=${firstSelectedId}]`); .find(`input[name='${$dropdown.data('fieldName')}'][value=${firstSelectedId}]`);
firstSelected.remove(); firstSelected.remove();
emitSidebarEvent('sidebar.removeAssignee', { emitSidebarEvent('sidebar.removeAssignee', {
...@@ -158,7 +158,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -158,7 +158,7 @@ function UsersSelect(currentUser, els, options = {}) {
const currentUserInfo = $dropdown.data('currentUserInfo'); const currentUserInfo = $dropdown.data('currentUserInfo');
$dropdown.find('.dropdown-toggle-text').text(getMultiSelectDropdownTitle(currentUserInfo)).removeClass('is-default'); $dropdown.find('.dropdown-toggle-text').text(getMultiSelectDropdownTitle(currentUserInfo)).removeClass('is-default');
} else { } else {
const $input = $(`input[name="${$dropdown.data('field-name')}"]`); const $input = $(`input[name="${$dropdown.data('fieldName')}"]`);
$input.val(gon.current_user_id); $input.val(gon.current_user_id);
selectedId = $input.val(); selectedId = $input.val();
$dropdown.find('.dropdown-toggle-text').text(gon.current_user_fullname).removeClass('is-default'); $dropdown.find('.dropdown-toggle-text').text(gon.current_user_fullname).removeClass('is-default');
...@@ -293,10 +293,10 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -293,10 +293,10 @@ function UsersSelect(currentUser, els, options = {}) {
const selected = getSelected().filter(i => i !== 0); const selected = getSelected().filter(i => i !== 0);
if (selected.length > 0) { if (selected.length > 0) {
if ($dropdown.data('dropdown-header')) { if ($dropdown.data('dropdownHeader')) {
showDivider += 1; showDivider += 1;
users.splice(showDivider, 0, { users.splice(showDivider, 0, {
header: $dropdown.data('dropdown-header'), header: $dropdown.data('dropdownHeader'),
}); });
} }
...@@ -327,7 +327,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -327,7 +327,7 @@ function UsersSelect(currentUser, els, options = {}) {
fields: ['name', 'username'] fields: ['name', 'username']
}, },
selectable: true, selectable: true,
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('fieldName'),
toggleLabel: function(selected, el, glDropdown) { toggleLabel: function(selected, el, glDropdown) {
const inputValue = glDropdown.filterInput.val(); const inputValue = glDropdown.filterInput.val();
...@@ -362,7 +362,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -362,7 +362,7 @@ function UsersSelect(currentUser, els, options = {}) {
emitSidebarEvent('sidebar.saveAssignees'); emitSidebarEvent('sidebar.saveAssignees');
} }
if (!$dropdown.data('always-show-selectbox')) { if (!$dropdown.data('alwaysShowSelectbox')) {
$selectbox.hide(); $selectbox.hide();
// Recalculate where .value is because vue might have changed it // Recalculate where .value is because vue might have changed it
...@@ -373,7 +373,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -373,7 +373,7 @@ function UsersSelect(currentUser, els, options = {}) {
} }
}, },
multiSelect: $dropdown.hasClass('js-multiselect'), multiSelect: $dropdown.hasClass('js-multiselect'),
inputMeta: $dropdown.data('input-meta'), inputMeta: $dropdown.data('inputMeta'),
clicked: function(options) { clicked: function(options) {
const { $el, e, isMarking } = options; const { $el, e, isMarking } = options;
const user = options.selectedObj; const user = options.selectedObj;
...@@ -381,7 +381,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -381,7 +381,7 @@ function UsersSelect(currentUser, els, options = {}) {
if ($dropdown.hasClass('js-multiselect')) { if ($dropdown.hasClass('js-multiselect')) {
const isActive = $el.hasClass('is-active'); const isActive = $el.hasClass('is-active');
const previouslySelected = $dropdown.closest('.selectbox') const previouslySelected = $dropdown.closest('.selectbox')
.find("input[name='" + ($dropdown.data('field-name')) + "'][value!=0]"); .find("input[name='" + ($dropdown.data('fieldName')) + "'][value!=0]");
// Enables support for limiting the number of users selected // Enables support for limiting the number of users selected
// Automatically removes the first on the list if more users are selected // Automatically removes the first on the list if more users are selected
...@@ -400,7 +400,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -400,7 +400,7 @@ function UsersSelect(currentUser, els, options = {}) {
// Remove unassigned selection (if it was previously selected) // Remove unassigned selection (if it was previously selected)
const unassignedSelected = $dropdown.closest('.selectbox') const unassignedSelected = $dropdown.closest('.selectbox')
.find("input[name='" + ($dropdown.data('field-name')) + "'][value=0]"); .find("input[name='" + ($dropdown.data('fieldName')) + "'][value=0]");
if (unassignedSelected) { if (unassignedSelected) {
unassignedSelected.remove(); unassignedSelected.remove();
...@@ -408,7 +408,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -408,7 +408,7 @@ function UsersSelect(currentUser, els, options = {}) {
} else { } else {
if (previouslySelected.length === 0) { if (previouslySelected.length === 0) {
// Select unassigned because there is no more selected users // Select unassigned because there is no more selected users
this.addInput($dropdown.data('field-name'), 0, {}); this.addInput($dropdown.data('fieldName'), 0, {});
} }
// User unselected // User unselected
...@@ -440,7 +440,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -440,7 +440,7 @@ function UsersSelect(currentUser, els, options = {}) {
return; return;
} }
if ($el.closest('.add-issues-modal').length) { if ($el.closest('.add-issues-modal').length) {
gl.issueBoards.ModalStore.store.filter[$dropdown.data('field-name')] = user.id; gl.issueBoards.ModalStore.store.filter[$dropdown.data('fieldName')] = user.id;
} else if (handleClick) { } else if (handleClick) {
e.preventDefault(); e.preventDefault();
handleClick(user, isMarking); handleClick(user, isMarking);
...@@ -449,15 +449,15 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -449,15 +449,15 @@ function UsersSelect(currentUser, els, options = {}) {
} else if ($dropdown.hasClass('js-filter-submit')) { } else if ($dropdown.hasClass('js-filter-submit')) {
return $dropdown.closest('form').submit(); return $dropdown.closest('form').submit();
} else if (!$dropdown.hasClass('js-multiselect')) { } else if (!$dropdown.hasClass('js-multiselect')) {
selected = $dropdown.closest('.selectbox').find("input[name='" + ($dropdown.data('field-name')) + "']").val(); selected = $dropdown.closest('.selectbox').find("input[name='" + ($dropdown.data('fieldName')) + "']").val();
return assignTo(selected); return assignTo(selected);
} }
// Automatically close dropdown after assignee is selected // Automatically close dropdown after assignee is selected
// since CE has no multiple assignees // since CE has no multiple assignees
// EE does not have a max-select // EE does not have a max-select
if ($dropdown.data('max-select') && if ($dropdown.data('maxSelect') &&
getSelected().length === $dropdown.data('max-select')) { getSelected().length === $dropdown.data('maxSelect')) {
// Close the dropdown // Close the dropdown
$dropdown.dropdown('toggle'); $dropdown.dropdown('toggle');
} }
...@@ -469,7 +469,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -469,7 +469,7 @@ function UsersSelect(currentUser, els, options = {}) {
const $el = $(e.currentTarget); const $el = $(e.currentTarget);
const selected = getSelected(); const selected = getSelected();
if ($dropdown.hasClass('js-issue-board-sidebar') && selected.length === 0) { if ($dropdown.hasClass('js-issue-board-sidebar') && selected.length === 0) {
this.addInput($dropdown.data('field-name'), 0, {}); this.addInput($dropdown.data('fieldName'), 0, {});
} }
$el.find('.is-active').removeClass('is-active'); $el.find('.is-active').removeClass('is-active');
...@@ -485,7 +485,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -485,7 +485,7 @@ function UsersSelect(currentUser, els, options = {}) {
highlightSelected(selectedId); highlightSelected(selectedId);
} }
}, },
updateLabel: $dropdown.data('dropdown-title'), updateLabel: $dropdown.data('dropdownTitle'),
renderRow: function(user) { renderRow: function(user) {
var avatar, img, listClosingTags, listWithName, listWithUserName, username; var avatar, img, listClosingTags, listWithName, listWithUserName, username;
username = user.username ? "@" + user.username : ""; username = user.username ? "@" + user.username : "";
...@@ -533,15 +533,15 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -533,15 +533,15 @@ function UsersSelect(currentUser, els, options = {}) {
var firstUser, showAnyUser, showEmailUser, showNullUser; var firstUser, showAnyUser, showEmailUser, showNullUser;
var options = {}; var options = {};
options.skipLdap = $(select).hasClass('skip_ldap'); options.skipLdap = $(select).hasClass('skip_ldap');
options.projectId = $(select).data('project-id'); options.projectId = $(select).data('projectId');
options.groupId = $(select).data('group-id'); options.groupId = $(select).data('groupId');
options.showCurrentUser = $(select).data('current-user'); options.showCurrentUser = $(select).data('currentUser');
options.authorId = $(select).data('author-id'); options.authorId = $(select).data('authorId');
options.skipUsers = $(select).data('skip-users'); options.skipUsers = $(select).data('skipUsers');
showNullUser = $(select).data('null-user'); showNullUser = $(select).data('nullUser');
showAnyUser = $(select).data('any-user'); showAnyUser = $(select).data('anyUser');
showEmailUser = $(select).data('email-user'); showEmailUser = $(select).data('emailUser');
firstUser = $(select).data('first-user'); firstUser = $(select).data('firstUser');
return $(select).select2({ return $(select).select2({
placeholder: "Search for a user", placeholder: "Search for a user",
multiple: $(select).hasClass('multiselect'), multiple: $(select).hasClass('multiselect'),
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
return new GLForm($(this.$refs['gl-form']), this.enableAutocomplete); return new GLForm($(this.$refs['gl-form']), this.enableAutocomplete);
}, },
beforeDestroy() { beforeDestroy() {
const glForm = $(this.$refs['gl-form']).data('gl-form'); const glForm = $(this.$refs['gl-form']).data('glForm');
if (glForm) { if (glForm) {
glForm.destroy(); glForm.destroy();
} }
......
- if current_user - if current_user
= link_to toggle_star_project_path(@project), { class: 'btn star-btn toggle-star', method: :post, remote: true } do %button.btn.btn-default.star-btn.toggle-star{ type: "button", data: { endpoint: toggle_star_project_path(@project, :json) } }
- if current_user.starred?(@project) - if current_user.starred?(@project)
= sprite_icon('star') = sprite_icon('star')
%span.starred= _('Unstar') %span.starred= _('Unstar')
......
...@@ -149,6 +149,11 @@ feature 'Project > Members > Share with Group', :js do ...@@ -149,6 +149,11 @@ feature 'Project > Members > Share with Group', :js do
create(:group).add_owner(master) create(:group).add_owner(master)
visit project_settings_members_path(project) visit project_settings_members_path(project)
click_link 'Share with group'
find('.ajax-groups-select.select2-container')
execute_script 'GROUP_SELECT_PER_PAGE = 1;' execute_script 'GROUP_SELECT_PER_PAGE = 1;'
open_select2 '#link_group_id' open_select2 '#link_group_id'
end end
......
import 'jquery';
import 'jquery-ujs';
import AjaxLoadingSpinner from '~/ajax_loading_spinner'; import AjaxLoadingSpinner from '~/ajax_loading_spinner';
describe('Ajax Loading Spinner', () => { describe('Ajax Loading Spinner', () => {
......
...@@ -138,7 +138,7 @@ import '~/lib/utils/common_utils'; ...@@ -138,7 +138,7 @@ import '~/lib/utils/common_utils';
$thumbsUpEmoji = $votesBlock.find('[data-name=thumbsup]').parent(); $thumbsUpEmoji = $votesBlock.find('[data-name=thumbsup]').parent();
$thumbsUpEmoji.attr('data-title', 'sam'); $thumbsUpEmoji.attr('data-title', 'sam');
awardsHandler.userAuthored($thumbsUpEmoji); awardsHandler.userAuthored($thumbsUpEmoji);
return expect($thumbsUpEmoji.data("original-title")).toBe("You cannot vote on your own issue, MR and note"); return expect($thumbsUpEmoji.data("originalTitle")).toBe("You cannot vote on your own issue, MR and note");
}); });
it('should restore tooltip back to initial vote list', function() { it('should restore tooltip back to initial vote list', function() {
var $thumbsUpEmoji, $votesBlock; var $thumbsUpEmoji, $votesBlock;
...@@ -149,7 +149,7 @@ import '~/lib/utils/common_utils'; ...@@ -149,7 +149,7 @@ import '~/lib/utils/common_utils';
awardsHandler.userAuthored($thumbsUpEmoji); awardsHandler.userAuthored($thumbsUpEmoji);
jasmine.clock().tick(2801); jasmine.clock().tick(2801);
jasmine.clock().uninstall(); jasmine.clock().uninstall();
return expect($thumbsUpEmoji.data("original-title")).toBe("sam"); return expect($thumbsUpEmoji.data("originalTitle")).toBe("sam");
}); });
}); });
describe('::getAwardUrl', function() { describe('::getAwardUrl', function() {
...@@ -194,7 +194,7 @@ import '~/lib/utils/common_utils'; ...@@ -194,7 +194,7 @@ import '~/lib/utils/common_utils';
$thumbsUpEmoji.attr('data-title', 'sam, jerry, max, and andy'); $thumbsUpEmoji.attr('data-title', 'sam, jerry, max, and andy');
awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false);
$thumbsUpEmoji.tooltip(); $thumbsUpEmoji.tooltip();
return expect($thumbsUpEmoji.data("original-title")).toBe('You, sam, jerry, max, and andy'); return expect($thumbsUpEmoji.data("originalTitle")).toBe('You, sam, jerry, max, and andy');
}); });
return it('handles the special case where "You" is not cleanly comma seperated', function() { return it('handles the special case where "You" is not cleanly comma seperated', function() {
var $thumbsUpEmoji, $votesBlock, awardUrl; var $thumbsUpEmoji, $votesBlock, awardUrl;
...@@ -204,7 +204,7 @@ import '~/lib/utils/common_utils'; ...@@ -204,7 +204,7 @@ import '~/lib/utils/common_utils';
$thumbsUpEmoji.attr('data-title', 'sam'); $thumbsUpEmoji.attr('data-title', 'sam');
awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false);
$thumbsUpEmoji.tooltip(); $thumbsUpEmoji.tooltip();
return expect($thumbsUpEmoji.data("original-title")).toBe('You and sam'); return expect($thumbsUpEmoji.data("originalTitle")).toBe('You and sam');
}); });
}); });
describe('::removeYouToUserList', function() { describe('::removeYouToUserList', function() {
...@@ -217,7 +217,7 @@ import '~/lib/utils/common_utils'; ...@@ -217,7 +217,7 @@ import '~/lib/utils/common_utils';
$thumbsUpEmoji.addClass('active'); $thumbsUpEmoji.addClass('active');
awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false);
$thumbsUpEmoji.tooltip(); $thumbsUpEmoji.tooltip();
return expect($thumbsUpEmoji.data("original-title")).toBe('sam, jerry, max, and andy'); return expect($thumbsUpEmoji.data("originalTitle")).toBe('sam, jerry, max, and andy');
}); });
return it('handles the special case where "You" is not cleanly comma seperated', function() { return it('handles the special case where "You" is not cleanly comma seperated', function() {
var $thumbsUpEmoji, $votesBlock, awardUrl; var $thumbsUpEmoji, $votesBlock, awardUrl;
...@@ -228,7 +228,7 @@ import '~/lib/utils/common_utils'; ...@@ -228,7 +228,7 @@ import '~/lib/utils/common_utils';
$thumbsUpEmoji.addClass('active'); $thumbsUpEmoji.addClass('active');
awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false);
$thumbsUpEmoji.tooltip(); $thumbsUpEmoji.tooltip();
return expect($thumbsUpEmoji.data("original-title")).toBe('sam'); return expect($thumbsUpEmoji.data("originalTitle")).toBe('sam');
}); });
}); });
describe('::searchEmojis', () => { describe('::searchEmojis', () => {
......
...@@ -15,7 +15,7 @@ describe('requiresInput', () => { ...@@ -15,7 +15,7 @@ describe('requiresInput', () => {
}); });
it('enables submit when no field is required', () => { it('enables submit when no field is required', () => {
$('*[required=required]').removeAttr('required'); $('*[required=required]').prop('required', false);
$('.js-requires-input').requiresInput(); $('.js-requires-input').requiresInput();
expect(submitButton).not.toBeDisabled(); expect(submitButton).not.toBeDisabled();
}); });
......
import * as featureHighlightHelper from '~/feature_highlight/feature_highlight_helper'; import * as featureHighlightHelper from '~/feature_highlight/feature_highlight_helper';
import * as featureHighlight from '~/feature_highlight/feature_highlight'; import * as featureHighlight from '~/feature_highlight/feature_highlight';
import axios from '~/lib/utils/axios_utils';
import MockAdapter from 'axios-mock-adapter';
describe('feature highlight', () => { describe('feature highlight', () => {
beforeEach(() => { beforeEach(() => {
setFixtures(` setFixtures(`
<div> <div>
<div class="js-feature-highlight" data-highlight="test" data-highlight-priority="10" disabled> <div class="js-feature-highlight" data-highlight="test" data-highlight-priority="10" data-dismiss-endpoint="/test" disabled>
Trigger Trigger
</div> </div>
</div> </div>
...@@ -19,13 +21,21 @@ describe('feature highlight', () => { ...@@ -19,13 +21,21 @@ describe('feature highlight', () => {
}); });
describe('setupFeatureHighlightPopover', () => { describe('setupFeatureHighlightPopover', () => {
let mock;
const selector = '.js-feature-highlight[data-highlight=test]'; const selector = '.js-feature-highlight[data-highlight=test]';
beforeEach(() => { beforeEach(() => {
mock = new MockAdapter(axios);
mock.onGet('/test').reply(200);
spyOn(window, 'addEventListener'); spyOn(window, 'addEventListener');
spyOn(window, 'removeEventListener'); spyOn(window, 'removeEventListener');
featureHighlight.setupFeatureHighlightPopover('test', 0); featureHighlight.setupFeatureHighlightPopover('test', 0);
}); });
afterEach(() => {
mock.restore();
});
it('setup popover content', () => { it('setup popover content', () => {
const $popoverContent = $('.feature-highlight-popover-content'); const $popoverContent = $('.feature-highlight-popover-content');
const outerHTML = $popoverContent.prop('outerHTML'); const outerHTML = $popoverContent.prop('outerHTML');
...@@ -51,15 +61,6 @@ describe('feature highlight', () => { ...@@ -51,15 +61,6 @@ describe('feature highlight', () => {
}, 0); }, 0);
}); });
it('setup inserted.bs.popover', () => {
$(selector).trigger('mouseenter');
const popoverId = $(selector).attr('aria-describedby');
const spyEvent = spyOnEvent(`#${popoverId} .dismiss-feature-highlight`, 'click');
$(`#${popoverId} .dismiss-feature-highlight`).click();
expect(spyEvent).toHaveBeenTriggered();
});
it('setup show.bs.popover', () => { it('setup show.bs.popover', () => {
$(selector).trigger('show.bs.popover'); $(selector).trigger('show.bs.popover');
expect(window.addEventListener).toHaveBeenCalledWith('scroll', jasmine.any(Function)); expect(window.addEventListener).toHaveBeenCalledWith('scroll', jasmine.any(Function));
...@@ -75,9 +76,19 @@ describe('feature highlight', () => { ...@@ -75,9 +76,19 @@ describe('feature highlight', () => {
}); });
it('displays popover', () => { it('displays popover', () => {
expect($(selector).attr('aria-describedby')).toBeFalsy(); expect(document.querySelector(selector).getAttribute('aria-describedby')).toBeFalsy();
$(selector).trigger('mouseenter'); $(selector).trigger('mouseenter');
expect($(selector).attr('aria-describedby')).toBeTruthy(); expect(document.querySelector(selector).getAttribute('aria-describedby')).toBeTruthy();
});
it('toggles when clicked', () => {
$(selector).trigger('mouseenter');
const popoverId = $(selector).attr('aria-describedby');
const toggleSpy = spyOn(featureHighlightHelper.togglePopover, 'call');
$(`#${popoverId} .dismiss-feature-highlight`).click();
expect(toggleSpy).toHaveBeenCalled();
}); });
}); });
......
...@@ -64,8 +64,8 @@ describe('glDropdown', function describeDropdown() { ...@@ -64,8 +64,8 @@ describe('glDropdown', function describeDropdown() {
}); });
afterEach(() => { afterEach(() => {
$('body').unbind('keydown'); $('body').off('keydown');
this.dropdownContainerElement.unbind('keyup'); this.dropdownContainerElement.off('keyup');
}); });
it('should open on click', () => { it('should open on click', () => {
......
...@@ -23,7 +23,7 @@ describe('Merge request notes', () => { ...@@ -23,7 +23,7 @@ describe('Merge request notes', () => {
gl.utils.disableButtonIfEmptyField = _.noop; gl.utils.disableButtonIfEmptyField = _.noop;
window.project_uploads_path = 'http://test.host/uploads'; window.project_uploads_path = 'http://test.host/uploads';
$('body').attr('data-page', 'projects:merge_requests:show'); $('body').attr('data-page', 'projects:merge_requests:show');
window.gon.current_user_id = $('.note:last').data('author-id'); window.gon.current_user_id = $('.note:last').data('authorId');
return new Notes('', []); return new Notes('', []);
}); });
...@@ -76,7 +76,7 @@ describe('Merge request notes', () => { ...@@ -76,7 +76,7 @@ describe('Merge request notes', () => {
</form>`; </form>`;
setFixtures(diffsResponse.html + noteFormHtml); setFixtures(diffsResponse.html + noteFormHtml);
$('body').attr('data-page', 'projects:merge_requests:show'); $('body').attr('data-page', 'projects:merge_requests:show');
window.gon.current_user_id = $('.note:last').data('author-id'); window.gon.current_user_id = $('.note:last').data('authorId');
return new Notes('', []); return new Notes('', []);
}); });
......
...@@ -22,19 +22,19 @@ describe('Abuse Reports', () => { ...@@ -22,19 +22,19 @@ describe('Abuse Reports', () => {
it('should truncate long messages', () => { it('should truncate long messages', () => {
const $longMessage = findMessage('LONG MESSAGE'); const $longMessage = findMessage('LONG MESSAGE');
expect($longMessage.data('original-message')).toEqual(jasmine.anything()); expect($longMessage.data('originalMessage')).toEqual(jasmine.anything());
assertMaxLength($longMessage); assertMaxLength($longMessage);
}); });
it('should not truncate short messages', () => { it('should not truncate short messages', () => {
const $shortMessage = findMessage('SHORT MESSAGE'); const $shortMessage = findMessage('SHORT MESSAGE');
expect($shortMessage.data('original-message')).not.toEqual(jasmine.anything()); expect($shortMessage.data('originalMessage')).not.toEqual(jasmine.anything());
}); });
it('should allow clicking a truncated message to expand and collapse the full message', () => { it('should allow clicking a truncated message to expand and collapse the full message', () => {
const $longMessage = findMessage('LONG MESSAGE'); const $longMessage = findMessage('LONG MESSAGE');
$longMessage.click(); $longMessage.click();
expect($longMessage.data('original-message').length).toEqual($longMessage.text().length); expect($longMessage.data('originalMessage').length).toEqual($longMessage.text().length);
$longMessage.click(); $longMessage.click();
assertMaxLength($longMessage); assertMaxLength($longMessage);
}); });
......
...@@ -27,7 +27,7 @@ describe('New Project', () => { ...@@ -27,7 +27,7 @@ describe('New Project', () => {
}); });
it('does not change project path for disabled $projectImportUrl', () => { it('does not change project path for disabled $projectImportUrl', () => {
$projectImportUrl.attr('disabled', true); $projectImportUrl.prop('disabled', true);
projectNew.deriveProjectPathFromUrl($projectImportUrl); projectNew.deriveProjectPathFromUrl($projectImportUrl);
...@@ -36,7 +36,7 @@ describe('New Project', () => { ...@@ -36,7 +36,7 @@ describe('New Project', () => {
describe('for enabled $projectImportUrl', () => { describe('for enabled $projectImportUrl', () => {
beforeEach(() => { beforeEach(() => {
$projectImportUrl.attr('disabled', false); $projectImportUrl.prop('disabled', false);
}); });
it('does not change project path if it is set by user', () => { it('does not change project path if it is set by user', () => {
......
...@@ -78,7 +78,7 @@ describe('SidebarMoveIssue', () => { ...@@ -78,7 +78,7 @@ describe('SidebarMoveIssue', () => {
this.sidebarMoveIssue.onConfirmClicked(); this.sidebarMoveIssue.onConfirmClicked();
expect(this.mediator.moveIssue).toHaveBeenCalled(); expect(this.mediator.moveIssue).toHaveBeenCalled();
expect(this.$confirmButton.attr('disabled')).toBe('disabled'); expect(this.$confirmButton.prop('disabled')).toBeTruthy();
expect(this.$confirmButton.hasClass('is-loading')).toBe(true); expect(this.$confirmButton.hasClass('is-loading')).toBe(true);
}); });
...@@ -93,7 +93,7 @@ describe('SidebarMoveIssue', () => { ...@@ -93,7 +93,7 @@ describe('SidebarMoveIssue', () => {
// Wait for the move issue request to fail // Wait for the move issue request to fail
setTimeout(() => { setTimeout(() => {
expect(window.Flash).toHaveBeenCalled(); expect(window.Flash).toHaveBeenCalled();
expect(this.$confirmButton.attr('disabled')).toBe(undefined); expect(this.$confirmButton.prop('disabled')).toBeFalsy();
expect(this.$confirmButton.hasClass('is-loading')).toBe(false); expect(this.$confirmButton.hasClass('is-loading')).toBe(false);
done(); done();
}); });
...@@ -120,7 +120,7 @@ describe('SidebarMoveIssue', () => { ...@@ -120,7 +120,7 @@ describe('SidebarMoveIssue', () => {
this.$content.find('.js-move-issue-dropdown-item').eq(0).trigger('click'); this.$content.find('.js-move-issue-dropdown-item').eq(0).trigger('click');
expect(this.mediator.setMoveToProjectId).toHaveBeenCalledWith(0); expect(this.mediator.setMoveToProjectId).toHaveBeenCalledWith(0);
expect(this.$confirmButton.attr('disabled')).toBe('disabled'); expect(this.$confirmButton.prop('disabled')).toBeTruthy();
done(); done();
}, 0); }, 0);
}); });
......
/* eslint-disable jasmine/no-global-setup */ /* eslint-disable jasmine/no-global-setup */
import $ from 'jquery'; import $ from 'jquery';
import 'jasmine-jquery'; import 'vendor/jasmine-jquery';
import '~/commons'; import '~/commons';
import Vue from 'vue'; import Vue from 'vue';
...@@ -144,6 +144,9 @@ if (process.env.BABEL_ENV === 'coverage') { ...@@ -144,6 +144,9 @@ if (process.env.BABEL_ENV === 'coverage') {
describe('Uncovered files', function () { describe('Uncovered files', function () {
const sourceFiles = require.context('~', true, /\.js$/); const sourceFiles = require.context('~', true, /\.js$/);
$.holdReady(true);
sourceFiles.keys().forEach(function (path) { sourceFiles.keys().forEach(function (path) {
// ignore if there is a matching spec file // ignore if there is a matching spec file
if (testsContext.keys().indexOf(`${path.replace(/\.js$/, '')}_spec`) > -1) { if (testsContext.keys().indexOf(`${path.replace(/\.js$/, '')}_spec`) > -1) {
......
/* eslint-disable */
/*
Jasmine JQuery 3.0 patched version from this fork : https://github.com/cmrd-senya/jasmine-jquery/blob/jquery3/lib/jasmine-jquery.js
*/
/*!
Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
Version 2.1.1
https://github.com/velesin/jasmine-jquery
Copyright (c) 2010-2014 Wojciech Zawistowski, Travis Jeffery
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
(function (root, factory) {
if (typeof module !== 'undefined' && module.exports) {
factory(root, root.jasmine, require('jquery'));
} else {
factory(root, root.jasmine, root.jQuery);
}
}((function() {return this; })(), function (window, jasmine, $) { "use strict";
jasmine.spiedEventsKey = function (selector, eventName) {
for(var i = 0;; i++) {
var key = [eventName, i].toString()
if (data.spiedEvents[key] === undefined || data.spiedEvents[key].selector.is($(selector))) {
return key
}
}
}
jasmine.getFixtures = function () {
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
}
jasmine.getStyleFixtures = function () {
return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
}
jasmine.Fixtures = function () {
this.containerId = 'jasmine-fixtures'
this.fixturesCache_ = {}
this.fixturesPath = 'spec/javascripts/fixtures'
}
jasmine.Fixtures.prototype.set = function (html) {
this.cleanUp()
return this.createContainer_(html)
}
jasmine.Fixtures.prototype.appendSet= function (html) {
this.addToContainer_(html)
}
jasmine.Fixtures.prototype.preload = function () {
this.read.apply(this, arguments)
}
jasmine.Fixtures.prototype.load = function () {
this.cleanUp()
this.createContainer_(this.read.apply(this, arguments))
}
jasmine.Fixtures.prototype.appendLoad = function () {
this.addToContainer_(this.read.apply(this, arguments))
}
jasmine.Fixtures.prototype.read = function () {
var htmlChunks = []
, fixtureUrls = arguments
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
}
return htmlChunks.join('')
}
jasmine.Fixtures.prototype.clearCache = function () {
this.fixturesCache_ = {}
}
jasmine.Fixtures.prototype.cleanUp = function () {
$('#' + this.containerId).remove()
}
jasmine.Fixtures.prototype.sandbox = function (attributes) {
var attributesToSet = attributes || {}
return $('<div id="sandbox" />').attr(attributesToSet)
}
jasmine.Fixtures.prototype.createContainer_ = function (html) {
var container = $('<div>')
.attr('id', this.containerId)
.html(html)
$(document.body).append(container)
return container
}
jasmine.Fixtures.prototype.addToContainer_ = function (html){
var container = $(document.body).find('#'+this.containerId).append(html)
if (!container.length) {
this.createContainer_(html)
}
}
jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) {
if (typeof this.fixturesCache_[url] === 'undefined') {
this.loadFixtureIntoCache_(url)
}
return this.fixturesCache_[url]
}
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
var self = this
, url = this.makeFixtureUrl_(relativeUrl)
, htmlText = ''
, request = $.ajax({
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
cache: false,
url: url,
dataType: 'html',
success: function (data, status, $xhr) {
htmlText = $xhr.responseText
}
}).fail(function ($xhr, status, err) {
throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
})
var scripts = $($.parseHTML(htmlText, true)).find('script[src]') || [];
scripts.each(function(){
$.ajax({
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
cache: false,
dataType: 'script',
url: $(this).attr('src'),
success: function (data, status, $xhr) {
htmlText += '<script>' + $xhr.responseText + '</script>'
},
error: function ($xhr, status, err) {
throw new Error('Script could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
}
});
})
self.fixturesCache_[relativeUrl] = htmlText;
}
jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){
return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
}
jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
return this[methodName].apply(this, passedArguments)
}
jasmine.StyleFixtures = function () {
this.fixturesCache_ = {}
this.fixturesNodes_ = []
this.fixturesPath = 'spec/javascripts/fixtures'
}
jasmine.StyleFixtures.prototype.set = function (css) {
this.cleanUp()
this.createStyle_(css)
}
jasmine.StyleFixtures.prototype.appendSet = function (css) {
this.createStyle_(css)
}
jasmine.StyleFixtures.prototype.preload = function () {
this.read_.apply(this, arguments)
}
jasmine.StyleFixtures.prototype.load = function () {
this.cleanUp()
this.createStyle_(this.read_.apply(this, arguments))
}
jasmine.StyleFixtures.prototype.appendLoad = function () {
this.createStyle_(this.read_.apply(this, arguments))
}
jasmine.StyleFixtures.prototype.cleanUp = function () {
while(this.fixturesNodes_.length) {
this.fixturesNodes_.pop().remove()
}
}
jasmine.StyleFixtures.prototype.createStyle_ = function (html) {
var styleText = $('<div></div>').html(html).text()
, style = $('<style>' + styleText + '</style>')
this.fixturesNodes_.push(style)
$('head').append(style)
}
jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
jasmine.getJSONFixtures = function () {
return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
}
jasmine.JSONFixtures = function () {
this.fixturesCache_ = {}
this.fixturesPath = 'spec/javascripts/fixtures/json'
}
jasmine.JSONFixtures.prototype.load = function () {
this.read.apply(this, arguments)
return this.fixturesCache_
}
jasmine.JSONFixtures.prototype.read = function () {
var fixtureUrls = arguments
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
this.getFixtureData_(fixtureUrls[urlIndex])
}
return this.fixturesCache_
}
jasmine.JSONFixtures.prototype.clearCache = function () {
this.fixturesCache_ = {}
}
jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) {
if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url)
return this.fixturesCache_[url]
}
jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
var self = this
, url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
$.ajax({
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
cache: false,
dataType: 'json',
url: url,
success: function (data) {
self.fixturesCache_[relativeUrl] = data
},
error: function ($xhr, status, err) {
throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
}
})
}
jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
return this[methodName].apply(this, passedArguments)
}
jasmine.jQuery = function () {}
jasmine.jQuery.browserTagCaseIndependentHtml = function (html) {
return $('<div/>').append(html).html()
}
jasmine.jQuery.elementToString = function (element) {
return $(element).map(function () { return this.outerHTML; }).toArray().join(', ')
}
var data = {
spiedEvents: {}
, handlers: []
}
jasmine.jQuery.events = {
spyOn: function (selector, eventName) {
var handler = function (e) {
var calls = (typeof data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] !== 'undefined') ? data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = {
selector: $(selector),
args: jasmine.util.argsToArray(arguments),
calls: ++calls
}
}
$(selector).on(eventName, handler)
data.handlers.push(handler)
return {
selector: selector,
eventName: eventName,
handler: handler,
reset: function (){
delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
},
calls: {
count: function () {
return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ?
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0;
},
any: function () {
return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ?
!!data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : false;
}
}
}
},
args: function (selector, eventName) {
var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].args
if (!actualArgs) {
throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent."
}
return actualArgs
},
wasTriggered: function (selector, eventName) {
return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
},
wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) {
var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1)
if (Object.prototype.toString.call(expectedArgs) !== '[object Array]')
actualArgs = actualArgs[0]
return util.equals(actualArgs, expectedArgs, customEqualityTesters)
},
wasPrevented: function (selector, eventName) {
var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
, args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args
, e = args ? args[0] : undefined
return e && e.isDefaultPrevented()
},
wasStopped: function (selector, eventName) {
var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
, args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args
, e = args ? args[0] : undefined
return e && e.isPropagationStopped()
},
cleanUp: function () {
data.spiedEvents = {}
data.handlers = []
}
}
var hasProperty = function (actualValue, expectedValue) {
if (expectedValue === undefined)
return actualValue !== undefined
return actualValue === expectedValue
}
beforeEach(function () {
jasmine.addMatchers({
toHaveClass: function () {
return {
compare: function (actual, className) {
return { pass: $(actual).hasClass(className) }
}
}
},
toHaveCss: function () {
return {
compare: function (actual, css) {
var stripCharsRegex = /[\s;\"\']/g
for (var prop in css) {
var value = css[prop]
// see issue #147 on gh
;if ((value === 'auto') && ($(actual).get(0).style[prop] === 'auto')) continue
var actualStripped = $(actual).css(prop).replace(stripCharsRegex, '')
var valueStripped = value.replace(stripCharsRegex, '')
if (actualStripped !== valueStripped) return { pass: false }
}
return { pass: true }
}
}
},
toBeVisible: function () {
return {
compare: function (actual) {
return { pass: $(actual).is(':visible') }
}
}
},
toBeHidden: function () {
return {
compare: function (actual) {
return { pass: $(actual).is(':hidden') }
}
}
},
toBeSelected: function () {
return {
compare: function (actual) {
return { pass: $(actual).is(':selected') }
}
}
},
toBeChecked: function () {
return {
compare: function (actual) {
return { pass: $(actual).is(':checked') }
}
}
},
toBeEmpty: function () {
return {
compare: function (actual) {
return { pass: $(actual).is(':empty') }
}
}
},
toBeInDOM: function () {
return {
compare: function (actual) {
return { pass: $.contains(document.documentElement, $(actual)[0]) }
}
}
},
toExist: function () {
return {
compare: function (actual) {
return { pass: $(actual).length }
}
}
},
toHaveLength: function () {
return {
compare: function (actual, length) {
return { pass: $(actual).length === length }
}
}
},
toHaveAttr: function () {
return {
compare: function (actual, attributeName, expectedAttributeValue) {
return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) }
}
}
},
toHaveProp: function () {
return {
compare: function (actual, propertyName, expectedPropertyValue) {
return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) }
}
}
},
toHaveId: function () {
return {
compare: function (actual, id) {
return { pass: $(actual).attr('id') == id }
}
}
},
toHaveHtml: function () {
return {
compare: function (actual, html) {
return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) }
}
}
},
toContainHtml: function () {
return {
compare: function (actual, html) {
var actualHtml = $(actual).html()
, expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html)
return { pass: (actualHtml.indexOf(expectedHtml) >= 0) }
}
}
},
toHaveText: function () {
return {
compare: function (actual, text) {
var actualText = $(actual).text()
var trimmedText = $.trim(actualText)
if (text && $.isFunction(text.test)) {
return { pass: text.test(actualText) || text.test(trimmedText) }
} else {
return { pass: (actualText == text || trimmedText == text) }
}
}
}
},
toContainText: function () {
return {
compare: function (actual, text) {
var trimmedText = $.trim($(actual).text())
if (text && $.isFunction(text.test)) {
return { pass: text.test(trimmedText) }
} else {
return { pass: trimmedText.indexOf(text) != -1 }
}
}
}
},
toHaveValue: function () {
return {
compare: function (actual, value) {
return { pass: $(actual).val() === value }
}
}
},
toHaveData: function () {
return {
compare: function (actual, key, expectedValue) {
return { pass: hasProperty($(actual).data(key), expectedValue) }
}
}
},
toContainElement: function () {
return {
compare: function (actual, selector) {
return { pass: $(actual).find(selector).length }
}
}
},
toBeMatchedBy: function () {
return {
compare: function (actual, selector) {
return { pass: $(actual).filter(selector).length }
}
}
},
toBeDisabled: function () {
return {
compare: function (actual, selector) {
return { pass: $(actual).is(':disabled') }
}
}
},
toBeFocused: function (selector) {
return {
compare: function (actual, selector) {
return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement }
}
}
},
toHandle: function () {
return {
compare: function (actual, event) {
if ( !actual || actual.length === 0 ) return { pass: false };
var events = $._data($(actual).get(0), "events")
if (!events || !event || typeof event !== "string") {
return { pass: false }
}
var namespaces = event.split(".")
, eventType = namespaces.shift()
, sortedNamespaces = namespaces.slice(0).sort()
, namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
if (events[eventType] && namespaces.length) {
for (var i = 0; i < events[eventType].length; i++) {
var namespace = events[eventType][i].namespace
if (namespaceRegExp.test(namespace))
return { pass: true }
}
} else {
return { pass: (events[eventType] && events[eventType].length > 0) }
}
return { pass: false }
}
}
},
toHandleWith: function () {
return {
compare: function (actual, eventName, eventHandler) {
if ( !actual || actual.length === 0 ) return { pass: false };
var normalizedEventName = eventName.split('.')[0]
, stack = $._data($(actual).get(0), "events")[normalizedEventName]
for (var i = 0; i < stack.length; i++) {
if (stack[i].handler == eventHandler) return { pass: true }
}
return { pass: false }
}
}
},
toHaveBeenTriggeredOn: function () {
return {
compare: function (actual, selector) {
var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) }
result.message = result.pass ?
"Expected event " + $(actual) + " not to have been triggered on " + selector :
"Expected event " + $(actual) + " to have been triggered on " + selector
return result;
}
}
},
toHaveBeenTriggered: function (){
return {
compare: function (actual) {
var eventName = actual.eventName
, selector = actual.selector
, result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) }
result.message = result.pass ?
"Expected event " + eventName + " not to have been triggered on " + selector :
"Expected event " + eventName + " to have been triggered on " + selector
return result
}
}
},
toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) {
return {
compare: function (actual, selector, expectedArgs) {
var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual)
, result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) }
if (wasTriggered) {
var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1]
result.message = result.pass ?
"Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) :
"Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
} else {
// todo check on this
result.message = result.pass ?
"Expected event " + actual + " not to have been triggered on " + selector :
"Expected event " + actual + " to have been triggered on " + selector
}
return result
}
}
},
toHaveBeenPreventedOn: function () {
return {
compare: function (actual, selector) {
var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) }
result.message = result.pass ?
"Expected event " + actual + " not to have been prevented on " + selector :
"Expected event " + actual + " to have been prevented on " + selector
return result
}
}
},
toHaveBeenPrevented: function () {
return {
compare: function (actual) {
var eventName = actual.eventName
, selector = actual.selector
, result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) }
result.message = result.pass ?
"Expected event " + eventName + " not to have been prevented on " + selector :
"Expected event " + eventName + " to have been prevented on " + selector
return result
}
}
},
toHaveBeenStoppedOn: function () {
return {
compare: function (actual, selector) {
var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) }
result.message = result.pass ?
"Expected event " + actual + " not to have been stopped on " + selector :
"Expected event " + actual + " to have been stopped on " + selector
return result;
}
}
},
toHaveBeenStopped: function () {
return {
compare: function (actual) {
var eventName = actual.eventName
, selector = actual.selector
, result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) }
result.message = result.pass ?
"Expected event " + eventName + " not to have been stopped on " + selector :
"Expected event " + eventName + " to have been stopped on " + selector
return result
}
}
}
})
jasmine.getEnv().addCustomEqualityTester(function(a, b) {
if (a && b) {
if (a instanceof $ || jasmine.isDomNode(a)) {
var $a = $(a)
if (b instanceof $)
return $a.length == b.length && a.is(b)
return $a.is(b);
}
if (b instanceof $ || jasmine.isDomNode(b)) {
var $b = $(b)
if (a instanceof $)
return a.length == $b.length && $b.is(a)
return $(b).is(a);
}
}
})
jasmine.getEnv().addCustomEqualityTester(function (a, b) {
if (a instanceof $ && b instanceof $ && a.size() == b.size())
return a.is(b)
})
})
afterEach(function () {
jasmine.getFixtures().cleanUp()
jasmine.getStyleFixtures().cleanUp()
jasmine.jQuery.events.cleanUp()
})
window.readFixtures = function () {
return jasmine.getFixtures().proxyCallTo_('read', arguments)
}
window.preloadFixtures = function () {
jasmine.getFixtures().proxyCallTo_('preload', arguments)
}
window.loadFixtures = function () {
jasmine.getFixtures().proxyCallTo_('load', arguments)
}
window.appendLoadFixtures = function () {
jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
}
window.setFixtures = function (html) {
return jasmine.getFixtures().proxyCallTo_('set', arguments)
}
window.appendSetFixtures = function () {
jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
}
window.sandbox = function (attributes) {
return jasmine.getFixtures().sandbox(attributes)
}
window.spyOnEvent = function (selector, eventName) {
return jasmine.jQuery.events.spyOn(selector, eventName)
}
window.preloadStyleFixtures = function () {
jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
}
window.loadStyleFixtures = function () {
jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
}
window.appendLoadStyleFixtures = function () {
jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
}
window.setStyleFixtures = function (html) {
jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
}
window.appendSetStyleFixtures = function (html) {
jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
}
window.loadJSONFixtures = function () {
return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
}
window.getJSONFixture = function (url) {
return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
}
}));
...@@ -448,7 +448,7 @@ Controller = (function() { ...@@ -448,7 +448,7 @@ Controller = (function() {
Controller.prototype.insertContentFor = function($li) { Controller.prototype.insertContentFor = function($li) {
var data, tpl; var data, tpl;
tpl = this.getOpt('insertTpl'); tpl = this.getOpt('insertTpl');
data = $.extend({}, $li.data('item-data'), { data = $.extend({}, $li.data('itemData'), {
'atwho-at': this.at 'atwho-at': this.at
}); });
return this.callbacks("tplEval").call(this, tpl, data, "onInsert"); return this.callbacks("tplEval").call(this, tpl, data, "onInsert");
...@@ -824,7 +824,7 @@ EditableController = (function(superClass) { ...@@ -824,7 +824,7 @@ EditableController = (function(superClass) {
this.$inputor.focus(); this.$inputor.focus();
} }
suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0"; suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0";
data = $li.data('item-data'); data = $li.data('itemData');
this.query.el.removeClass('atwho-query').addClass('atwho-inserted').html(content).attr('data-atwho-at-query', "" + data['atwho-at'] + this.query.text); this.query.el.removeClass('atwho-query').addClass('atwho-inserted').html(content).attr('data-atwho-at-query', "" + data['atwho-at'] + this.query.text);
if (range = this._getRange()) { if (range = this._getRange()) {
range.setEndAfter(this.query.el[0]); range.setEndAfter(this.query.el[0]);
......
...@@ -125,4 +125,4 @@ ...@@ -125,4 +125,4 @@
} }
}; };
})(jQuery); })(jQuery);
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
(function($) { (function($) {
var fetchRequestResults, getRequestId, peekEnabled, updatePerformanceBar; var fetchRequestResults, getRequestId, peekEnabled, updatePerformanceBar;
getRequestId = function() { getRequestId = function() {
return $('#peek').data('request-id'); return $('#peek').data('requestId');
}; };
peekEnabled = function() { peekEnabled = function() {
return $('#peek').length; return $('#peek').length;
......
...@@ -4211,9 +4211,9 @@ jquery.waitforimages@^2.2.0: ...@@ -4211,9 +4211,9 @@ jquery.waitforimages@^2.2.0:
version "2.2.0" version "2.2.0"
resolved "https://registry.yarnpkg.com/jquery.waitforimages/-/jquery.waitforimages-2.2.0.tgz#63f23131055a1b060dc913e6d874bcc9b9e6b16b" resolved "https://registry.yarnpkg.com/jquery.waitforimages/-/jquery.waitforimages-2.2.0.tgz#63f23131055a1b060dc913e6d874bcc9b9e6b16b"
"jquery@>= 1.9.1", jquery@>=1.8.0, jquery@^2.2.4: "jquery@>= 1.9.1", jquery@>=1.8.0, jquery@^3.2.1:
version "2.2.4" version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.2.4.tgz#2c89d6889b5eac522a7eea32c14521559c6cbf02" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
js-base64@^2.1.9: js-base64@^2.1.9:
version "2.1.9" version "2.1.9"
......
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