From 0f6a7dadb9529e901aee6c21769813672fa784e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Fri, 9 Jan 2015 15:04:43 +0100 Subject: [PATCH] Bug #1859: Detect scroll movement on codeblocks of the wiki --- app/coffee/modules/wiki/main.coffee | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/coffee/modules/wiki/main.coffee b/app/coffee/modules/wiki/main.coffee index 0354feb5..ebf20a6c 100644 --- a/app/coffee/modules/wiki/main.coffee +++ b/app/coffee/modules/wiki/main.coffee @@ -276,6 +276,12 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $ promise.finally -> $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) -> # We want to dettect the a inside the div so we use the target and # not the currentTarget @@ -283,6 +289,12 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $ return if not isEditable() return if target.is('a') return if getSelectedText() + if target.is('pre') + prevPos = target.data("scroll-pos") + target.data("scroll-pos", null) + if prevPos != target[0].scrollLeft + return + switchToEditMode() $el.on "click", ".save", debounce 2000, ->