BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c9f11db2
Commit
c9f11db2
authored
Apr 20, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make shortcuts work when sidebar is collapsed
parent
a4592434
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
36 deletions
+54
-36
right_sidebar.js.coffee
app/assets/javascripts/right_sidebar.js.coffee
+46
-19
shortcuts_issuable.coffee
app/assets/javascripts/shortcuts_issuable.coffee
+7
-16
_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-1
No files found.
app/assets/javascripts/right_sidebar.js.coffee
View file @
c9f11db2
class
@
Sidebar
constructor
:
(
currentUser
)
->
@
sidebar
=
$
(
'aside'
)
@
addEventListeners
()
addEventListeners
:
->
$
(
'aside'
).
on
(
'click'
,
'.sidebar-collapsed-icon'
,
@
sidebarCollapseClicked
)
$
(
'.dropdown'
).
on
(
'hidden.gl.dropdown'
,
@
sidebarDropdownHidden
)
_this
=
@
@
sidebar
.
on
'click'
,
'.sidebar-collapsed-icon'
,
(
e
)
->
e
.
preventDefault
()
$block
=
$
(
@
).
closest
(
'.block'
)
_this
.
openDropdown
(
$block
);
$
(
'.dropdown'
).
on
'hidden.gl.dropdown'
,
(
e
)
->
e
.
preventDefault
()
$block
=
$
(
@
).
closest
(
'.block'
)
_this
.
sidebarDropdownHidden
(
$block
)
$
(
'.dropdown'
).
on
(
'loading.gl.dropdown'
,
@
sidebarDropdownLoading
)
$
(
'.dropdown'
).
on
(
'loaded.gl.dropdown'
,
@
sidebarDropdownLoaded
)
...
...
@@ -30,26 +40,44 @@ class @Sidebar
else
i
.
show
()
openDropdown
:
(
blockOrName
)
->
$block
=
if
_
.
isString
(
blockOrName
)
then
@
getBlock
(
blockOrName
)
else
blockOrName
sidebarCollapseClicked
:
(
e
)
->
e
.
preventDefault
()
$block
=
$
(
@
).
closest
(
'.block'
)
$block
.
find
(
'.edit-link'
).
trigger
(
'click'
)
$
(
'aside'
)
.
find
(
'.gutter-toggle'
)
.
trigger
(
'click'
)
$editLink
=
$block
.
find
(
'.edit-link'
)
if
not
@
isOpen
()
@
setCollapseAfterUpdate
(
$block
)
@
toggleSidebar
(
'open'
)
if
$editLink
.
length
$editLink
.
trigger
(
'click'
)
$block
.
addClass
(
'collapse-after-update'
)
$
(
'.page-with-sidebar'
).
addClass
(
'with-overlay'
)
setCollapseAfterUpdate
:
(
$block
)
->
$block
.
addClass
(
'collapse-after-update'
)
$
(
'.page-with-sidebar'
).
addClass
(
'with-overlay'
)
sidebarDropdownHidden
:
(
e
)
->
$block
=
$
(
@
).
closest
(
'.block'
)
sidebarDropdownHidden
:
(
$block
)
->
if
$block
.
hasClass
(
'collapse-after-update'
)
$block
.
removeClass
(
'collapse-after-update'
)
$
(
'.page-with-sidebar'
).
removeClass
(
'with-overlay'
)
$
(
'aside'
)
.
find
(
'.gutter-toggle'
)
.
trigger
(
'click'
)
\ No newline at end of file
@
toggleSidebar
(
'hide'
)
triggerOpenSidebar
:
->
@
sidebar
.
find
(
'.js-sidebar-toggle'
)
.
trigger
(
'click'
)
toggleSidebar
:
(
action
=
'toggle'
)
->
if
action
is
'toggle'
@
triggerOpenSidebar
()
if
action
is
'open'
@
triggerOpenSidebar
()
if
not
@
isOpen
()
if
action
is
'hide'
@
triggerOpenSidebar
()
is
@
isOpen
()
isOpen
:
->
@
sidebar
.
is
(
'.right-sidebar-expanded'
)
getBlock
:
(
name
)
->
@
sidebar
.
find
(
".block.
#{
name
}
"
)
app/assets/javascripts/shortcuts_issuable.coffee
View file @
c9f11db2
...
...
@@ -4,18 +4,8 @@
class
@
ShortcutsIssuable
extends
ShortcutsNavigation
constructor
:
(
isMergeRequest
)
->
super
()
Mousetrap
.
bind
(
'a'
,
->
$
(
'.block.assignee .edit-link'
).
trigger
(
'click'
)
return
false
)
Mousetrap
.
bind
(
'm'
,
->
$
(
'.block.milestone .edit-link'
).
trigger
(
'click'
)
return
false
)
Mousetrap
.
bind
(
'r'
,
=>
@
replyWithSelectedText
()
return
false
)
Mousetrap
.
bind
(
'a'
,
@
openSidebarDropdown
.
bind
(
@
,
'assignee'
))
Mousetrap
.
bind
(
'm'
,
@
openSidebarDropdown
.
bind
(
@
,
'milestone'
))
Mousetrap
.
bind
(
'j'
,
=>
@
prevIssue
()
return
false
...
...
@@ -28,10 +18,7 @@ class @ShortcutsIssuable extends ShortcutsNavigation
@
editIssue
()
return
false
)
Mousetrap
.
bind
(
'l'
,
=>
$
(
'.block.labels .edit-link'
).
trigger
(
'click'
)
return
false
)
Mousetrap
.
bind
(
'l'
,
@
openSidebarDropdown
.
bind
(
@
,
'labels'
))
if
isMergeRequest
@
enabledHelp
.
push
(
'.hidden-shortcut.merge_requests'
)
...
...
@@ -74,3 +61,7 @@ class @ShortcutsIssuable extends ShortcutsNavigation
editIssue
:
->
$editBtn
=
$
(
'.issuable-edit'
)
Turbolinks
.
visit
(
$editBtn
.
attr
(
'href'
))
openSidebarDropdown
:
(
name
)
->
sidebar
.
openDropdown
(
name
)
return
false
app/views/shared/issuable/_sidebar.html.haml
View file @
c9f11db2
...
...
@@ -153,4 +153,4 @@
new
LabelsSelect
();
new
IssuableContext
(
'
#{
escape_javascript
(
current_user
.
to_json
(
only:
[
:username
,
:id
,
:name
]))
}
'
);
new
Subscription
(
'.subscription'
)
new
Sidebar
();
sidebar
=
new
Sidebar
();
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