Skip to content

Commit

Permalink
Add a down arrow next to user name to show dropdown options and ensur…
Browse files Browse the repository at this point in the history
…e it works on all pages (fossasia#426)

* Fix toggle dropdown for pretixcontrol and pretixpresale

* Update code
  • Loading branch information
odkhang authored Nov 18, 2024
1 parent 27cc074 commit afb64c9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/pretix/control/templates/pretixcontrol/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<script type="text/javascript" src="{% static "lightbox/js/lightbox.min.js" %}"></script>
<script type="text/javascript" src="{% static "are-you-sure/jquery.are-you-sure.js" %}"></script>
<script type="text/javascript" src="{% static "pretixcontrol/js/ui/popover.js" %}"></script>
<script type="text/javascript" src="{% static "utils/js/utils.js" %}"></script>
{% endcompress %}
{{ html_head|safe }}

Expand Down
1 change: 1 addition & 0 deletions src/pretix/presale/templates/pretixpresale/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<meta name="theme-color" content="{{ settings.primary_color|default:"#2185d0" }}">
{% compress js %}
<script type="text/javascript" src="{% static "pretixpresale/js/ui/popover.js" %}"></script>
<script type="text/javascript" src="{% static "utils/js/utils.js" %}"></script>
{% endcompress %}
</head>
<body class="nojs" data-locale="{{ request.LANGUAGE_CODE }}" data-now="{% now "U.u" %}" data-datetimeformat="{{ js_datetime_format }}" data-timeformat="{{ js_time_format }}" data-dateformat="{{ js_date_format }}" data-datetimelocale="{{ js_locale }}" data-currency="{{ request.event.currency }}">
Expand Down
6 changes: 2 additions & 4 deletions src/pretix/static/pretixcontrol/js/ui/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ $(function () {
trigger: 'manual'

}
$('[data-toggle="popover-profile"]').popover(options).click(function(evt) {
$('[data-toggle="popover-profile"]').popover(options).click(function (evt) {
evt.stopPropagation();
$(this).popover('show');
$('[data-toggle="popover"]').popover('hide');

togglePopover(this);
})
})

Expand Down
5 changes: 2 additions & 3 deletions src/pretix/static/pretixpresale/js/ui/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ $(function () {
trigger: 'manual'

}
$('[data-toggle="popover-profile"]').popover(options).click(function(evt) {
$('[data-toggle="popover-profile"]').popover(options).click(function (evt) {
evt.stopPropagation();
$(this).popover('show');
$('[data-toggle="popover"]').popover('hide');
togglePopover(this);

// Ensure Organizer Area is hidden initially
$('.organizer-area').hide();
Expand Down
11 changes: 11 additions & 0 deletions src/pretix/static/utils/js/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function togglePopover(element) {
const popover = $(element).data('bs.popover');
const isVisible = popover.tip().hasClass('in');
$('[data-toggle="popover"]').popover('hide');

if (isVisible) {
$(element).popover('hide');
} else {
$(element).popover('show');
}
}

0 comments on commit afb64c9

Please sign in to comment.