Merge pull request #230 from taigaio/bug/1859/detect-scroll-movement

Bug #1859: Detect scroll movement on codeblocks of the wiki
stable
Juanfran 2015-01-12 14:56:00 +01:00
commit 5b6a1d5c10
1 changed files with 12 additions and 0 deletions

View File

@ -276,6 +276,12 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
promise.finally -> promise.finally ->
$loading.finish($el.find('.save-container')) $loading.finish($el.find('.save-container'))
$el.on "mousedown", ".view-wiki-content", (event) ->
# Prepare the scroll movement detection
target = angular.element(event.target)
if target.is('pre')
target.data("scroll-pos", target[0].scrollLeft)
$el.on "mouseup", ".view-wiki-content", (event) -> $el.on "mouseup", ".view-wiki-content", (event) ->
# We want to dettect the a inside the div so we use the target and # We want to dettect the a inside the div so we use the target and
# not the currentTarget # not the currentTarget
@ -283,6 +289,12 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
return if not isEditable() return if not isEditable()
return if target.is('a') return if target.is('a')
return if getSelectedText() return if getSelectedText()
if target.is('pre')
prevPos = target.data("scroll-pos")
target.data("scroll-pos", null)
if prevPos != target[0].scrollLeft
return
switchToEditMode() switchToEditMode()
$el.on "click", ".save", debounce 2000, -> $el.on "click", ".save", debounce 2000, ->