diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-15 09:09:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-15 09:09:22 +0300 |
commit | 61a8928ff0db524d6e13193820fdee65c76d3919 (patch) | |
tree | a9c786adeccfdcc945c6fe0064b7f74d741a5966 /app/assets/javascripts/feature_highlight | |
parent | a9a80bf446bb0c1f09d81e3b6d393a9015da030d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/feature_highlight')
3 files changed, 4 insertions, 95 deletions
diff --git a/app/assets/javascripts/feature_highlight/feature_highlight.js b/app/assets/javascripts/feature_highlight/feature_highlight.js deleted file mode 100644 index 124be35f6ca..00000000000 --- a/app/assets/javascripts/feature_highlight/feature_highlight.js +++ /dev/null @@ -1,59 +0,0 @@ -import $ from 'jquery'; -import { togglePopover, mouseenter, debouncedMouseleave } from '../shared/popover'; -import { getSelector, inserted } from './feature_highlight_helper'; - -export function setupFeatureHighlightPopover(id, debounceTimeout = 300) { - const $selector = $(getSelector(id)); - const $parent = $selector.parent(); - const $popoverContent = $parent.siblings('.feature-highlight-popover-content'); - const hideOnScroll = togglePopover.bind($selector, false); - - $selector - // Set up popover - .data('content', $popoverContent.prop('outerHTML')) - .popover({ - html: true, - // Override the existing template to add custom CSS classes - template: ` - <div class="popover feature-highlight-popover" role="tooltip"> - <div class="arrow"></div> - <div class="popover-body"></div> - </div> - `, - }) - .on('mouseenter', mouseenter) - .on('mouseleave', debouncedMouseleave(debounceTimeout)) - .on('inserted.bs.popover', inserted) - .on('show.bs.popover', () => { - window.addEventListener('scroll', hideOnScroll, { once: true }); - }) - // Display feature highlight - .removeAttr('disabled'); -} - -const getPriority = (e) => parseInt(e.dataset.highlightPriority, 10) || 0; - -export function findHighestPriorityFeature() { - let priorityFeature; - - const sortedFeatureEls = [].slice - .call(document.querySelectorAll('.js-feature-highlight')) - .sort((a, b) => getPriority(b) - getPriority(a)); - - const [priorityFeatureEl] = sortedFeatureEls; - if (priorityFeatureEl) { - priorityFeature = priorityFeatureEl.dataset.highlight; - } - - return priorityFeature; -} - -export function highlightFeatures() { - const priorityFeature = findHighestPriorityFeature(); - - if (priorityFeature) { - setupFeatureHighlightPopover(priorityFeature); - } - - return priorityFeature; -} diff --git a/app/assets/javascripts/feature_highlight/feature_highlight_helper.js b/app/assets/javascripts/feature_highlight/feature_highlight_helper.js index 0f460a83c07..7b4bed69fb8 100644 --- a/app/assets/javascripts/feature_highlight/feature_highlight_helper.js +++ b/app/assets/javascripts/feature_highlight/feature_highlight_helper.js @@ -1,15 +1,12 @@ -import $ from 'jquery'; -import { deprecatedCreateFlash as Flash } from '../flash'; -import LazyLoader from '../lazy_loader'; +import { deprecatedCreateFlash as Flash } from '~/flash'; import axios from '../lib/utils/axios_utils'; import { __ } from '../locale'; -import { togglePopover } from '../shared/popover'; export const getSelector = (highlightId) => `.js-feature-highlight[data-highlight=${highlightId}]`; -export function dismiss(highlightId) { - axios - .post(this.attr('data-dismiss-endpoint'), { +export function dismiss(endpoint, highlightId) { + return axios + .post(endpoint, { feature_name: highlightId, }) .catch(() => @@ -19,21 +16,4 @@ export function dismiss(highlightId) { ), ), ); - - togglePopover.call(this, false); - this.hide(); -} - -export function inserted() { - const popoverId = this.getAttribute('aria-describedby'); - const highlightId = this.dataset.highlight; - const $popover = $(this); - const dismissWrapper = dismiss.bind($popover, highlightId); - - $(`#${popoverId} .dismiss-feature-highlight`).on('click', dismissWrapper); - - const lazyImg = $(`#${popoverId} .feature-highlight-illustration`)[0]; - if (lazyImg) { - LazyLoader.loadImage(lazyImg); - } } diff --git a/app/assets/javascripts/feature_highlight/feature_highlight_options.js b/app/assets/javascripts/feature_highlight/feature_highlight_options.js deleted file mode 100644 index c5553f0243f..00000000000 --- a/app/assets/javascripts/feature_highlight/feature_highlight_options.js +++ /dev/null @@ -1,12 +0,0 @@ -import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; -import { highlightFeatures } from './feature_highlight'; - -export default function domContentLoaded() { - if (bp.getBreakpointSize() === 'xl') { - highlightFeatures(); - return true; - } - return false; -} - -document.addEventListener('DOMContentLoaded', domContentLoaded); |