diff --git a/lib/minimap-quick-settings-element.coffee b/lib/minimap-quick-settings-element.coffee index d5c579a6..980b9676 100644 --- a/lib/minimap-quick-settings-element.coffee +++ b/lib/minimap-quick-settings-element.coffee @@ -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' @@ -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() diff --git a/spec/minimap-element-spec.coffee b/spec/minimap-element-spec.coffee index 72e573d6..b4cbb54d 100644 --- a/spec/minimap-element-spec.coffee +++ b/spec/minimap-element-spec.coffee @@ -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() @@ -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', -> @@ -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') @@ -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() @@ -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' @@ -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 -> @@ -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()