Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/browse/browse-utils.js
/** | /** | ||||
* Copyright (C) 2018 The Software Heritage developers | * Copyright (C) 2018 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
import {BREAKPOINT_SM} from 'utils/constants'; | |||||
$(document).ready(() => { | $(document).ready(() => { | ||||
$('.dropdown-submenu a.dropdown-item').on('click', e => { | $('.dropdown-submenu a.dropdown-item').on('click', e => { | ||||
$(e.target).next('div').toggle(); | $(e.target).next('div').toggle(); | ||||
if ($(e.target).next('div').css('display') !== 'none') { | if ($(e.target).next('div').css('display') !== 'none') { | ||||
$(e.target).focus(); | $(e.target).focus(); | ||||
} else { | } else { | ||||
$(e.target).blur(); | $(e.target).blur(); | ||||
} | } | ||||
e.stopPropagation(); | e.stopPropagation(); | ||||
e.preventDefault(); | e.preventDefault(); | ||||
}); | }); | ||||
$('.swh-popover-toggler').popover({ | $('.swh-popover-toggler').popover({ | ||||
boundary: 'viewport', | boundary: 'viewport', | ||||
container: 'body', | container: 'body', | ||||
html: true, | html: true, | ||||
placement: function() { | placement: function() { | ||||
const width = $(window).width(); | const width = $(window).width(); | ||||
if (width < 768) { | if (width < BREAKPOINT_SM) { | ||||
return 'top'; | return 'top'; | ||||
} else { | } else { | ||||
return 'right'; | return 'right'; | ||||
} | } | ||||
}, | }, | ||||
template: `<div class="popover" role="tooltip"> | template: `<div class="popover" role="tooltip"> | ||||
<div class="arrow"></div> | <div class="arrow"></div> | ||||
<h3 class="popover-header"></h3> | <h3 class="popover-header"></h3> | ||||
Show All 35 Lines |