Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
A
admin_toolbar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
admin_toolbar
Commits
65815b91
Commit
65815b91
authored
Dec 14, 2017
by
kkuhnen
Committed by
emerya
Dec 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2929053
by kkuhnen, eme, adriancid: admin_toolbar.js should use Drupal behaviors
parent
cb0fb1f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
45 deletions
+48
-45
js/admin_toolbar.js
js/admin_toolbar.js
+48
-45
No files found.
js/admin_toolbar.js
View file @
65815b91
(
function
(
$
)
{
$
(
document
).
ready
(
function
()
{
$
(
'
a.toolbar-icon
'
).
removeAttr
(
'
title
'
);
Drupal
.
behaviors
.
adminToolbar
=
{
attach
:
function
(
context
,
settings
)
{
$
(
'
.toolbar-tray-horizontal li.menu-item--expanded, .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item
'
).
hoverIntent
({
over
:
function
()
{
// At the current depth, we should delete all "hover-intent" classes.
// Other wise we get unwanted behaviour where menu items are expanded while already in hovering other ones.
$
(
this
).
parent
().
find
(
'
li
'
).
removeClass
(
'
hover-intent
'
);
$
(
this
).
addClass
(
'
hover-intent
'
);
},
out
:
function
()
{
$
(
this
).
removeClass
(
'
hover-intent
'
);
},
timeout
:
250
});
// Make the toolbar menu navigable with keyboard.
$
(
'
ul.toolbar-menu li.menu-item--expanded a
'
).
on
(
'
focusin
'
,
function
()
{
$
(
'
li.menu-item--expanded
'
).
removeClass
(
'
hover-intent
'
);
$
(
this
).
parents
(
'
li.menu-item--expanded
'
).
addClass
(
'
hover-intent
'
);
});
$
(
'
ul.toolbar-menu li.menu-item a
'
).
keydown
(
function
(
e
)
{
if
((
e
.
shiftKey
&&
(
e
.
keyCode
||
e
.
which
)
==
9
))
{
if
(
$
(
this
).
parent
(
'
.menu-item
'
).
prev
().
hasClass
(
'
menu-item--expanded
'
))
{
$
(
this
).
parent
(
'
.menu-item
'
).
prev
().
addClass
(
'
hover-intent
'
);
$
(
'
a.toolbar-icon
'
,
context
).
removeAttr
(
'
title
'
);
$
(
'
.toolbar-tray-horizontal li.menu-item--expanded, .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item
'
,
context
).
hoverIntent
({
over
:
function
()
{
// At the current depth, we should delete all "hover-intent" classes.
// Other wise we get unwanted behaviour where menu items are expanded while already in hovering other ones.
$
(
this
).
parent
().
find
(
'
li
'
).
removeClass
(
'
hover-intent
'
);
$
(
this
).
addClass
(
'
hover-intent
'
);
},
out
:
function
()
{
$
(
this
).
removeClass
(
'
hover-intent
'
);
},
timeout
:
250
});
// Make the toolbar menu navigable with keyboard.
$
(
'
ul.toolbar-menu li.menu-item--expanded a
'
,
context
).
on
(
'
focusin
'
,
function
()
{
$
(
'
li.menu-item--expanded
'
,
context
).
removeClass
(
'
hover-intent
'
);
$
(
this
).
parents
(
'
li.menu-item--expanded
'
).
addClass
(
'
hover-intent
'
);
});
$
(
'
ul.toolbar-menu li.menu-item a
'
,
context
).
keydown
(
function
(
e
)
{
if
((
e
.
shiftKey
&&
(
e
.
keyCode
||
e
.
which
)
==
9
))
{
if
(
$
(
this
).
parent
(
'
.menu-item
'
).
prev
().
hasClass
(
'
menu-item--expanded
'
))
{
$
(
this
).
parent
(
'
.menu-item
'
).
prev
().
addClass
(
'
hover-intent
'
);
}
}
}
});
$
(
'
.toolbar-menu:first-child > .menu-item:not(.menu-item--expanded) a, .toolbar-tab > a
'
).
on
(
'
focusin
'
,
function
()
{
$
(
'
.menu-item--expanded
'
).
removeClass
(
'
hover-intent
'
);
});
$
(
'
.toolbar-menu:first-child > .menu-item
'
).
on
(
'
hover
'
,
function
()
{
$
(
this
,
'
a
'
).
css
(
"
background: #fff;
"
);
});
$
(
'
ul:not(.toolbar-menu)
'
).
on
({
mousemove
:
function
()
{
$
(
'
li.menu-item--expanded
'
).
removeClass
(
'
hover-intent
'
);
},
hover
:
function
()
{
$
(
'
li.menu-item--expanded
'
).
removeClass
(
'
hover-intent
'
);
}
});
});
$
(
'
.toolbar-menu:first-child > .menu-item:not(.menu-item--expanded) a, .toolbar-tab > a
'
,
context
).
on
(
'
focusin
'
,
function
()
{
$
(
'
.menu-item--expanded
'
).
removeClass
(
'
hover-intent
'
);
});
$
(
'
.toolbar-menu:first-child > .menu-item
'
,
context
).
on
(
'
hover
'
,
function
()
{
$
(
this
,
'
a
'
).
css
(
"
background: #fff;
"
);
});
$
(
'
ul:not(.toolbar-menu)
'
,
context
).
on
({
mousemove
:
function
()
{
$
(
'
li.menu-item--expanded
'
).
removeClass
(
'
hover-intent
'
);
},
hover
:
function
()
{
$
(
'
li.menu-item--expanded
'
).
removeClass
(
'
hover-intent
'
);
}
});
});
}
};
})(
jQuery
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment