mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 08:31:27 -05:00
Fix incorrect toggle
buttons (#23676)
Some of those are still Copy&Paste problems. This PR: * Only cleans the legacy incorrect code, doesn't change or improve the "action" logic. * Remove the redundant `$('.toggle.button').on('click')`, now `$('.show-panel.button').on('click')` handles that kinds of buttons Actually, there is only one correct "toggle button" in code, the one on the webhook page. No need to backport.
This commit is contained in:
parent
12fff36d05
commit
59eb660b1a
4 changed files with 11 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
<div class="ui dropdown tiny basic button icon-button" data-tooltip-content="{{.locale.Tr "repo.diff.options_button"}}">
|
<div class="ui dropdown tiny basic button icon-button" data-tooltip-content="{{.locale.Tr "repo.diff.options_button"}}">
|
||||||
{{svg "octicon-kebab-horizontal"}}
|
{{svg "octicon-kebab-horizontal"}}
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<a class="item tiny basic toggle button" id="show-file-list-btn">{{.locale.Tr "repo.diff.show_diff_stats"}}</a>
|
<a class="item" id="show-file-list-btn">{{.locale.Tr "repo.diff.show_diff_stats"}}</a>
|
||||||
{{if .Issue.Index}}
|
{{if .Issue.Index}}
|
||||||
<a class="item" href="{{$.RepoLink}}/pulls/{{.Issue.Index}}.patch" download="{{.Issue.Index}}.patch">{{.locale.Tr "repo.diff.download_patch"}}</a>
|
<a class="item" href="{{$.RepoLink}}/pulls/{{.Issue.Index}}.patch" download="{{.Issue.Index}}.patch">{{.locale.Tr "repo.diff.download_patch"}}</a>
|
||||||
<a class="item" href="{{$.RepoLink}}/pulls/{{.Issue.Index}}.diff" download="{{.Issue.Index}}.diff">{{.locale.Tr "repo.diff.download_diff"}}</a>
|
<a class="item" href="{{$.RepoLink}}/pulls/{{.Issue.Index}}.diff" download="{{.Issue.Index}}.diff">{{.locale.Tr "repo.diff.download_diff"}}</a>
|
||||||
|
|
|
@ -28,4 +28,4 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="ui tiny basic toggle button icon-button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}&whitespace={{$.WhitespaceBehavior}}" data-tooltip-content="{{if .IsSplitStyle}}{{.locale.Tr "repo.diff.show_unified_view"}}{{else}}{{.locale.Tr "repo.diff.show_split_view"}}{{end}}">{{if .IsSplitStyle}}{{svg "gitea-join"}}{{else}}{{svg "gitea-split"}}{{end}}</a>
|
<a class="ui tiny basic button icon-button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}&whitespace={{$.WhitespaceBehavior}}" data-tooltip-content="{{if .IsSplitStyle}}{{.locale.Tr "repo.diff.show_unified_view"}}{{else}}{{.locale.Tr "repo.diff.show_split_view"}}{{end}}">{{if .IsSplitStyle}}{{svg "gitea-join"}}{{else}}{{svg "gitea-split"}}{{end}}</a>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="text red">{{svg "octicon-alert"}}</span>
|
<span class="text red">{{svg "octicon-alert"}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
<a class="ui primary sha label toggle button" data-target="#info-{{.ID}}">{{.UUID}}</a>
|
<a class="ui primary sha label toggle button show-panel" data-panel="#info-{{.ID}}">{{.UUID}}</a>
|
||||||
<div class="ui right">
|
<div class="ui right">
|
||||||
<span class="text grey time">
|
<span class="text grey time">
|
||||||
{{.DeliveredString}}
|
{{.DeliveredString}}
|
||||||
|
|
|
@ -118,10 +118,6 @@ export function initGlobalCommon() {
|
||||||
|
|
||||||
$('.tabular.menu .item').tab();
|
$('.tabular.menu .item').tab();
|
||||||
|
|
||||||
$('.toggle.button').on('click', function () {
|
|
||||||
toggleElem($($(this).data('target')));
|
|
||||||
});
|
|
||||||
|
|
||||||
// prevent multiple form submissions on forms containing .loading-button
|
// prevent multiple form submissions on forms containing .loading-button
|
||||||
document.addEventListener('submit', (e) => {
|
document.addEventListener('submit', (e) => {
|
||||||
const btn = e.target.querySelector('.loading-button');
|
const btn = e.target.querySelector('.loading-button');
|
||||||
|
@ -310,8 +306,15 @@ export function initGlobalButtons() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.show-panel.button').on('click', function (e) {
|
$('.show-panel.button').on('click', function (e) {
|
||||||
|
// a '.show-panel.button' can show a panel, by `data-panel="selector"`
|
||||||
|
// if the button is a "toggle" button, it toggles the panel
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
showElem($(this).data('panel'));
|
const sel = $(this).attr('data-panel');
|
||||||
|
if (this.classList.contains('toggle')) {
|
||||||
|
toggleElem(sel);
|
||||||
|
} else {
|
||||||
|
showElem(sel);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.hide-panel.button').on('click', function (e) {
|
$('.hide-panel.button').on('click', function (e) {
|
||||||
|
|
Loading…
Reference in a new issue