Skip to content

Commit

Permalink
Add a quick setting control to switch the adjust absolute mode height…
Browse files Browse the repository at this point in the history
… setting
  • Loading branch information
abe33 committed Apr 26, 2016
1 parent 17e02f4 commit 94d3be1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/minimap-quick-settings-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class MinimapQuickSettingsElement {
this.li({class: 'separator', outlet: 'separator'})
this.li({class: 'code-highlights', outlet: 'codeHighlights'}, 'code-highlights')
this.li({class: 'absolute-mode', outlet: 'absoluteMode'}, 'absolute-mode')
this.li({class: 'adjust-absolute-mode-height', outlet: 'adjustAbsoluteModeHeight'}, 'adjust-absolute-mode-height')
})
this.div({class: 'btn-group'}, () => {
this.button({class: 'btn btn-default', outlet: 'onLeftButton'}, 'On Left')
Expand Down Expand Up @@ -101,6 +102,17 @@ export default class MinimapQuickSettingsElement {
atom.config.set('minimap.absoluteMode', !atom.config.get('minimap.absoluteMode'))
})

subs.add(this.subscribeTo(this.adjustAbsoluteModeHeight, {
'mousedown': (e) => {
e.preventDefault()
atom.config.set('minimap.adjustAbsoluteModeHeight', !atom.config.get('minimap.adjustAbsoluteModeHeight'))
}
}))

this.itemsActions.set(this.adjustAbsoluteModeHeight, () => {
atom.config.set('minimap.adjustAbsoluteModeHeight', !atom.config.get('minimap.adjustAbsoluteModeHeight'))
})

subs.add(this.subscribeTo(this.hiddenInput, {
'focusout': (e) => { this.destroy() }
}))
Expand All @@ -127,6 +139,10 @@ export default class MinimapQuickSettingsElement {
this.absoluteMode.classList.toggle('active', bool)
}))

subs.add(atom.config.observe('minimap.adjustAbsoluteModeHeight', (bool) => {
this.adjustAbsoluteModeHeight.classList.toggle('active', bool)
}))

subs.add(atom.config.observe('minimap.displayMinimapOnLeft', (bool) => {
this.onLeftButton.classList.toggle('selected', bool)
this.onRightButton.classList.toggle('selected', !bool)
Expand Down
19 changes: 18 additions & 1 deletion spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,7 @@ describe('MinimapElement', () => {
})

it('creates one list item for each registered plugin', () => {
expect(quickSettingsElement.querySelectorAll('li').length).toEqual(5)
expect(quickSettingsElement.querySelectorAll('li').length).toEqual(6)
})

it('selects the first item of the list', () => {
Expand Down Expand Up @@ -1920,6 +1920,22 @@ describe('MinimapElement', () => {
expect(atom.config.get('minimap.absoluteMode')).toEqual(!initial)
})
})

describe('on the adjust absolute mode height item', () => {
let [initial] = []
beforeEach(() => {
initial = atom.config.get('minimap.adjustAbsoluteModeHeight')
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:move-down')
atom.commands.dispatch(quickSettingsElement, 'core:confirm')
})

it('toggles the code highlights on the minimap element', () => {
expect(atom.config.get('minimap.adjustAbsoluteModeHeight')).toEqual(!initial)
})
})
})

describe('core:move-down', () => {
Expand Down Expand Up @@ -1965,6 +1981,7 @@ describe('MinimapElement', () => {
beforeEach(() => {
atom.commands.dispatch(quickSettingsElement, 'core:move-up')
atom.commands.dispatch(quickSettingsElement, 'core:move-up')
atom.commands.dispatch(quickSettingsElement, 'core:move-up')
})

it('moves past the separator', () => {
Expand Down

0 comments on commit 94d3be1

Please sign in to comment.