Move click gutter into the GutterComponent

This commit is contained in:
Ben Ogle 2014-06-09 14:11:41 -07:00
parent bae625a894
commit e59f242f19
3 changed files with 17 additions and 16 deletions

View File

@ -374,7 +374,8 @@ describe "EditorComponent", ->
expect(lineNumberHasClass(1, 'folded')).toBe false
it "does not fold when the line number node is clicked", ->
component.onClickGutter(buildClickEvent(component.lineNumberNodeForScreenRow(1)))
lineNumber = component.lineNumberNodeForScreenRow(1)
lineNumber.dispatchEvent(buildClickEvent(lineNumber))
expect(lineNumberHasClass(1, 'folded')).toBe false
describe "when decorations are used", ->

View File

@ -71,7 +71,7 @@ EditorComponent = React.createClass
div className: className, style: {fontSize, lineHeight, fontFamily}, tabIndex: -1,
GutterComponent {
ref: 'gutter', onClick: @onClickGutter, editor, renderedRowRange, maxLineNumberDigits, scrollTop,
ref: 'gutter', editor, renderedRowRange, maxLineNumberDigits, scrollTop,
scrollHeight, lineHeightInPixels, @pendingChanges, mouseWheelScreenRow,
decorations
}
@ -478,18 +478,6 @@ EditorComponent = React.createClass
@selectToMousePositionUntilMouseUp(event)
onClickGutter: (event) ->
{editor} = @props
{target} = event
lineNumber = target.parentNode
if target.classList.contains('icon-right') and lineNumber.classList.contains('foldable')
bufferRow = parseInt(lineNumber.getAttribute('data-buffer-row'))
if lineNumber.classList.contains('folded')
editor.unfoldBufferRow(bufferRow)
else
editor.foldBufferRow(bufferRow)
onStylesheetsChanged: (stylesheet) ->
@refreshScrollbars() if @containsScrollbarSelector(stylesheet)

View File

@ -14,9 +14,9 @@ GutterComponent = React.createClass
dummyLineNumberNode: null
render: ->
{scrollHeight, scrollTop, onClick} = @props
{scrollHeight, scrollTop} = @props
div className: 'gutter', onClick: onClick,
div className: 'gutter', onClick: @onClick,
div className: 'line-numbers', ref: 'lineNumbers', style:
height: scrollHeight
WebkitTransform: "translate3d(0px, #{-scrollTop}px, 0px)"
@ -180,6 +180,18 @@ GutterComponent = React.createClass
lineNumberNodeForScreenRow: (screenRow) ->
@lineNumberNodesById[@lineNumberIdsByScreenRow[screenRow]]
onClick: (event) ->
{editor} = @props
{target} = event
lineNumber = target.parentNode
if target.classList.contains('icon-right') and lineNumber.classList.contains('foldable')
bufferRow = parseInt(lineNumber.getAttribute('data-buffer-row'))
if lineNumber.classList.contains('folded')
editor.unfoldBufferRow(bufferRow)
else
editor.foldBufferRow(bufferRow)
# Created because underscore uses === not _.isEqual, which we need
contains = (array, target) ->
return false unless array?