Skip to content

Commit

Permalink
Add controls to toggle the position of the minimap
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Feb 11, 2015
1 parent e16c69c commit 6434c34
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/minimap-quick-settings-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class MinimapQuickSettingsElement extends HTMLElement
@ol class: 'list-group mark-active', outlet: 'list', =>
@li class: 'separator', outlet: 'separator'
@li class: '', outlet: 'codeHighlights', 'code-highlights'
@div class: 'btn-group', =>
@button class: 'btn btn-default', outlet: 'onLeftButton', 'On Left'
@button class: 'btn btn-default', outlet: 'onRightButton', 'On Right'

selectedItem: null

Expand Down Expand Up @@ -47,6 +50,20 @@ class MinimapQuickSettingsElement extends HTMLElement
'focusout': (e) =>
@destroy()

@subscriptions.add @subscribeTo @onLeftButton,
'mousedown': (e) ->
e.preventDefault()
atom.config.set('minimap.displayMinimapOnLeft', true)

@subscriptions.add @subscribeTo @onRightButton,
'mousedown': (e) ->
e.preventDefault()
atom.config.set('minimap.displayMinimapOnLeft', false)

@subscriptions.add atom.config.observe 'minimap.displayMinimapOnLeft', (bool) =>
@onLeftButton.classList.toggle('selected', bool)
@onRightButton.classList.toggle('selected', not bool)

@initList()

onDidDestroy: (callback) ->
Expand Down
16 changes: 16 additions & 0 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ describe 'MinimapElement', ->

quickSettingsElement = workspaceElement.querySelector('minimap-quick-settings')

it 'sets the on right button active', ->
expect(quickSettingsElement.querySelector('.btn.selected:last-child')).toExist()

describe 'clicking on the code highlight item', ->
beforeEach ->
item = quickSettingsElement.querySelector('li:last-child')
Expand All @@ -693,6 +696,19 @@ describe 'MinimapElement', ->
it 'requests an update', ->
expect(minimapElement.frameRequested).toBeTruthy()

describe 'clicking on the on left button', ->
beforeEach ->
item = quickSettingsElement.querySelector('.btn:first-child')
mousedown(item)

it 'toggles the displayMinimapOnLeft setting', ->
expect(atom.config.get('minimap.displayMinimapOnLeft')).toBeTruthy()

it 'changes the buttons activation state', ->
expect(quickSettingsElement.querySelector('.btn.selected:last-child')).not.toExist()
expect(quickSettingsElement.querySelector('.btn.selected:first-child')).toExist()


describe 'clicking on the open settings button again', ->
beforeEach ->
mousedown(openQuickSettings)
Expand Down
8 changes: 8 additions & 0 deletions styles/minimap.less
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,12 @@ minimap-quick-settings {
background: @background-color-highlight;
}
}

.btn-group {
width: 100%;

.btn {
width: 50%;
}
}
}

0 comments on commit 6434c34

Please sign in to comment.