Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
notification_system
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
notification_system
Commits
6af00c10
Commit
6af00c10
authored
1 year ago
by
Robert Phillips
Committed by
Bryan Sharpe
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3412588
: Replace jquery.once dependencies
parent
ba3aa9fd
No related branches found
No related tags found
1 merge request
!18
Issue #3412588: Replace jquery.once dependencies.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/notifications-block.js
+27
-25
27 additions, 25 deletions
js/notifications-block.js
notification_system.libraries.yml
+1
-0
1 addition, 0 deletions
notification_system.libraries.yml
with
28 additions
and
25 deletions
js/notifications-block.js
+
27
−
25
View file @
6af00c10
...
...
@@ -2,8 +2,8 @@
Drupal
.
behaviors
.
notificationSystemBlock
=
{
attach
:
function
(
context
,
settings
)
{
$
(
'
.notification-block
'
,
context
).
once
(
'
loadNotifications
'
).
e
ach
(
function
()
{
var
$block
=
$
(
this
);
once
(
'
loadNotifications
'
,
'
.notification-block
'
,
context
).
forE
ach
(
function
(
element
)
{
var
$block
=
$
(
element
);
// Lazy load data for the notification block.
var
$placeholder
=
$block
.
find
(
'
.notification-block__placeholder
'
);
...
...
@@ -39,29 +39,31 @@
function
addEventListeners
(
$context
)
{
// Mark as Read.
$context
.
find
(
'
.notification-markasread-trigger
'
).
once
(
'
markAsRead
'
).
click
(
function
(
e
)
{
var
$button
=
$
(
this
);
var
markAsReadEndpoint
=
drupalSettings
.
notificationSystem
.
markAsReadEndpointUrl
;
var
providerId
=
$button
.
data
(
'
notification-provider
'
);
var
notificationId
=
$button
.
data
(
'
notification-id
'
);
markAsReadEndpoint
=
markAsReadEndpoint
.
replace
(
'
PROVIDER_ID
'
,
providerId
);
markAsReadEndpoint
=
markAsReadEndpoint
.
replace
(
'
NOTIFICATION_ID
'
,
notificationId
);
$
.
ajax
({
url
:
markAsReadEndpoint
,
type
:
'
GET
'
,
}).
done
(
function
(
data
)
{
var
$notificationItem
=
$button
.
parents
(
'
.notification-item
'
);
$notificationItem
.
addClass
(
'
is-read
'
);
updateCounters
();
}).
fail
(
function
(
data
)
{
if
(
data
.
responseJSON
.
hasOwnProperty
(
'
message
'
))
{
console
.
error
(
'
Error while marking notification as read:
'
+
data
.
responseJSON
.
message
);
}
else
{
console
.
error
(
'
Unknown error while marking notification as read.
'
);
}
once
(
'
markAsRead
'
,
'
.notification-markasread-trigger
'
,
$context
[
0
]).
forEach
(
function
(
element
)
{
$
(
element
).
click
(
function
(
e
)
{
var
$button
=
$
(
this
);
var
markAsReadEndpoint
=
drupalSettings
.
notificationSystem
.
markAsReadEndpointUrl
;
var
providerId
=
$button
.
data
(
'
notification-provider
'
);
var
notificationId
=
$button
.
data
(
'
notification-id
'
);
markAsReadEndpoint
=
markAsReadEndpoint
.
replace
(
'
PROVIDER_ID
'
,
providerId
);
markAsReadEndpoint
=
markAsReadEndpoint
.
replace
(
'
NOTIFICATION_ID
'
,
notificationId
);
$
.
ajax
({
url
:
markAsReadEndpoint
,
type
:
'
GET
'
,
}).
done
(
function
(
data
)
{
var
$notificationItem
=
$button
.
parents
(
'
.notification-item
'
);
$notificationItem
.
addClass
(
'
is-read
'
);
updateCounters
();
}).
fail
(
function
(
data
)
{
if
(
data
.
responseJSON
.
hasOwnProperty
(
'
message
'
))
{
console
.
error
(
'
Error while marking notification as read:
'
+
data
.
responseJSON
.
message
);
}
else
{
console
.
error
(
'
Unknown error while marking notification as read.
'
);
}
});
});
});
}
...
...
This diff is collapsed.
Click to expand it.
notification_system.libraries.yml
+
1
−
0
View file @
6af00c10
...
...
@@ -8,4 +8,5 @@ notifications_block:
dependencies
:
-
core/jquery
-
core/drupalSettings
-
core/once
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment