Merge pull request #548 from taigaio/issue/2518/wiki-toc-links

Allow to include anchor links in the wiki pages
stable
Alejandro 2015-06-25 01:17:44 -07:00
commit 6c3bf5e7a0
3 changed files with 22 additions and 1 deletions

View File

@ -547,7 +547,7 @@ module.directive("tgEditableSubject", ["$rootScope", "$tgRepo", "$tgConfirm", "$
############################################################################# #############################################################################
## Editable subject directive ## Editable description directive
############################################################################# #############################################################################
EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template) -> EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template) ->
@ -593,6 +593,13 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading,
$el.find('.view-description').hide() $el.find('.view-description').hide()
$el.find('textarea').focus() $el.find('textarea').focus()
$el.on "click", "a", (event) ->
target = angular.element(event.target)
href = target.attr('href')
if href.indexOf("#") == 0
event.preventDefault()
$('body').scrollTop($(href).offset().top)
$el.on "click", ".save", (e) -> $el.on "click", ".save", (e) ->
e.preventDefault() e.preventDefault()

View File

@ -382,6 +382,13 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
target = angular.element(event.currentTarget) target = angular.element(event.currentTarget)
save(target) save(target)
$el.on "click", "a", (event) ->
target = angular.element(event.target)
href = target.attr('href')
if href.indexOf("#") == 0
event.preventDefault()
$('body').scrollTop($(href).offset().top)
$el.on "click", ".show-more", (event) -> $el.on "click", ".show-more", (event) ->
event.preventDefault() event.preventDefault()

View File

@ -243,6 +243,13 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
promise.finally -> promise.finally ->
$loading.finish($el.find('.save-container')) $loading.finish($el.find('.save-container'))
$el.on "click", "a", (event) ->
target = angular.element(event.target)
href = target.attr('href')
if href.indexOf("#") == 0
event.preventDefault()
$('body').scrollTop($(href).offset().top)
$el.on "mousedown", ".view-wiki-content", (event) -> $el.on "mousedown", ".view-wiki-content", (event) ->
target = angular.element(event.target) target = angular.element(event.target)
return if not isEditable() return if not isEditable()