forked from zestedesavoir/zds-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajouter la copie du permalien dans le menu dropdown des messages
- Loading branch information
Migwel
committed
May 26, 2023
1 parent
445eb9d
commit a5a1707
Showing
3 changed files
with
60 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(function() { | ||
'use strict' | ||
|
||
$('.topic-message').on('click', "[data-ajax-input='copy-hyperlink']", function(e) { | ||
e.stopPropagation() | ||
e.preventDefault() | ||
navigator.clipboard.writeText($(this).attr("data-message-url")); | ||
Check failure on line 7 in assets/js/topic-message.js
|
||
const dropdown = e.target.closest(".dropdown") | ||
dropdown.removeAttribute('open') | ||
}) | ||
|
||
$('.topic-message').on('click', "[data-ajax-input='mark-message-as-useful']", function(e) { | ||
const $button = $(this) | ||
const $form = $button.parents('form:first') | ||
const $message = $form.parents('article') | ||
const $usefulText = $message.find("[data-ajax-output='mark-message-as-useful']") | ||
const csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val() | ||
|
||
const $desktopText = $button.find('.desktop') | ||
const $mobileText = $button.find('.until-desktop') | ||
|
||
$.ajax({ | ||
url: $form.attr('action'), | ||
type: 'POST', | ||
data: { | ||
csrfmiddlewaretoken: csrfmiddlewaretoken | ||
}, | ||
success: function() { | ||
$message.toggleClass('helpful') | ||
$usefulText.toggleClass('hidden') | ||
$button.blur() | ||
|
||
// Toggle both mobile and desktop texts | ||
if ($desktopText.length !== 0 && $mobileText.length !== 0) { | ||
const currentDesktopText = $desktopText.text() | ||
const currentMobileText = $mobileText.text() | ||
|
||
$desktopText.text($button.data('content-on-click')) | ||
$mobileText.text($button.data('content-on-click-mobile')) | ||
|
||
$button.data('content-on-click', currentDesktopText) | ||
$button.data('content-on-click-mobile', currentMobileText) | ||
} else { | ||
$button.toggleText('content-on-click') | ||
} | ||
} | ||
}) | ||
|
||
e.stopPropagation() | ||
e.preventDefault() | ||
}) | ||
})(jQuery) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters