Skip to content

Commit

Permalink
Add control over absolute mode in the quick settings popup
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Jun 5, 2015
1 parent 2fa132f commit 1ae73d9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
11 changes: 10 additions & 1 deletion lib/minimap-quick-settings-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class MinimapQuickSettingsElement extends HTMLElement
@input type: 'text', class: 'hidden-input', outlet: 'hiddenInput'
@ol class: 'list-group mark-active', outlet: 'list', =>
@li class: 'separator', outlet: 'separator'
@li class: '', outlet: 'codeHighlights', 'code-highlights'
@li class: 'code-highlights', outlet: 'codeHighlights', 'code-highlights'
@li class: 'absolute-mode', outlet: 'absoluteMode', 'absolute-mode'
@div class: 'btn-group', =>
@button class: 'btn btn-default', outlet: 'onLeftButton', 'On Left'
@button class: 'btn btn-default', outlet: 'onRightButton', 'On Right'
Expand Down Expand Up @@ -54,6 +55,14 @@ class MinimapQuickSettingsElement extends HTMLElement
@itemsActions.set @codeHighlights, =>
atom.config.set('minimap.displayCodeHighlights', !@minimap.displayCodeHighlights)

@subscriptions.add @subscribeTo @absoluteMode,
'mousedown': (e) =>
e.preventDefault()
atom.config.set('minimap.absoluteMode', !atom.config.get('minimap.absoluteMode'))

@itemsActions.set @absoluteMode, =>
atom.config.set('minimap.absoluteMode', !atom.config.get('minimap.absoluteMode'))

@subscriptions.add @subscribeTo @hiddenInput,
'focusout': (e) =>
@destroy()
Expand Down
30 changes: 26 additions & 4 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ describe 'MinimapElement', ->
expect(minimapElement.classList.contains('absolute')).toBeTruthy()

describe 'when minimap.displayMinimapOnLeft setting is true', ->
it 'also adds a left class to the minmap element', ->
it 'also adds a left class to the minimap element', ->
atom.config.set('minimap.displayMinimapOnLeft', true)
expect(minimapElement.classList.contains('absolute')).toBeTruthy()
expect(minimapElement.classList.contains('left')).toBeTruthy()
Expand Down Expand Up @@ -957,7 +957,7 @@ describe 'MinimapElement', ->

describe 'clicking on the code highlight item', ->
beforeEach ->
item = quickSettingsElement.querySelector('li:last-child')
item = quickSettingsElement.querySelector('li.code-highlights')
mousedown(item)

it 'toggles the code highlights on the minimap element', ->
Expand All @@ -966,6 +966,15 @@ describe 'MinimapElement', ->
it 'requests an update', ->
expect(minimapElement.frameRequested).toBeTruthy()

describe 'clicking on the absolute mode item', ->
beforeEach ->
item = quickSettingsElement.querySelector('li.absolute-mode')
mousedown(item)

it 'toggles the absolute-mode setting', ->
expect(atom.config.get('minimap.absoluteMode')).toBeTruthy()
expect(minimapElement.absoluteMode).toBeTruthy()

describe 'clicking on the on left button', ->
beforeEach ->
item = quickSettingsElement.querySelector('.btn:first-child')
Expand Down Expand Up @@ -1055,7 +1064,7 @@ describe 'MinimapElement', ->
quickSettingsElement = workspaceElement.querySelector('minimap-quick-settings')

it 'creates one list item for each registered plugin', ->
expect(quickSettingsElement.querySelectorAll('li').length).toEqual(4)
expect(quickSettingsElement.querySelectorAll('li').length).toEqual(5)

it 'selects the first item of the list', ->
expect(quickSettingsElement.querySelector('li.selected:first-child')).toExist()
Expand Down Expand Up @@ -1085,6 +1094,18 @@ describe 'MinimapElement', ->
it 'toggles the code highlights on the minimap element', ->
expect(minimapElement.displayCodeHighlights).toEqual(not initial)

describe 'on the absolute mode item', ->
[initial] = []
beforeEach ->
initial = atom.config.get('minimap.absoluteMode')
atom.commands.dispatch quickSettingsElement, 'core:move-down'
atom.commands.dispatch quickSettingsElement, 'core:move-down'
atom.commands.dispatch quickSettingsElement, 'core:move-down'
atom.commands.dispatch quickSettingsElement, 'core:confirm'

it 'toggles the code highlights on the minimap element', ->
expect(atom.config.get('minimap.absoluteMode')).toEqual(not initial)

describe 'core:move-down', ->
beforeEach ->
atom.commands.dispatch quickSettingsElement, 'core:move-down'
Expand All @@ -1097,7 +1118,7 @@ describe 'MinimapElement', ->
atom.commands.dispatch quickSettingsElement, 'core:move-down'

it 'moves past the separator', ->
expect(quickSettingsElement.querySelector('li.selected:last-child')).toExist()
expect(quickSettingsElement.querySelector('li.code-highlights.selected')).toExist()

describe 'then core:move-up', ->
beforeEach ->
Expand All @@ -1116,6 +1137,7 @@ describe 'MinimapElement', ->
describe 'reaching a separator', ->
beforeEach ->
atom.commands.dispatch quickSettingsElement, 'core:move-up'
atom.commands.dispatch quickSettingsElement, 'core:move-up'

it 'moves past the separator', ->
expect(quickSettingsElement.querySelector('li.selected:nth-child(2)')).toExist()
Expand Down

0 comments on commit 1ae73d9

Please sign in to comment.