mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-06 04:52:21 +00:00
Merge pull request #1068 from sharelatex/jel-link-to-tab
Fix .link-to-tab when link within a tab GitOrigin-RevId: b2d5482771caef5abc4afa4d270f64598f72f0d7
This commit is contained in:
parent
f442fd65e3
commit
fd8b7fbb6c
1 changed files with 11 additions and 6 deletions
|
@ -5,9 +5,6 @@ define [
|
||||||
restrict: "A"
|
restrict: "A"
|
||||||
require: "tabset"
|
require: "tabset"
|
||||||
link: (scope, el, attrs, tabset) ->
|
link: (scope, el, attrs, tabset) ->
|
||||||
linksToTabs = document.querySelectorAll(".link-to-tab");
|
|
||||||
_clickLinkToTab = (event) ->
|
|
||||||
_makeActive(event.currentTarget.getAttribute("href").replace('#', ''))
|
|
||||||
|
|
||||||
_makeActive = (hash) ->
|
_makeActive = (hash) ->
|
||||||
if hash? and hash != ""
|
if hash? and hash != ""
|
||||||
|
@ -17,14 +14,22 @@ define [
|
||||||
matchingTab.select()
|
matchingTab.select()
|
||||||
el.children()[0].scrollIntoView({ behavior: "smooth" })
|
el.children()[0].scrollIntoView({ behavior: "smooth" })
|
||||||
|
|
||||||
for link in linksToTabs
|
|
||||||
link.addEventListener("click", _clickLinkToTab)
|
|
||||||
|
|
||||||
scope.$applyAsync () ->
|
scope.$applyAsync () ->
|
||||||
# for page load
|
# for page load
|
||||||
hash = $location.hash()
|
hash = $location.hash()
|
||||||
_makeActive(hash)
|
_makeActive(hash)
|
||||||
|
|
||||||
|
# for links within page to a tab
|
||||||
|
# this needs to be within applyAsync because there could be a link
|
||||||
|
# within a tab to another tab
|
||||||
|
linksToTabs = document.querySelectorAll(".link-to-tab");
|
||||||
|
_clickLinkToTab = (event) ->
|
||||||
|
_makeActive(event.currentTarget.getAttribute("href").replace('#', ''))
|
||||||
|
|
||||||
|
if linksToTabs
|
||||||
|
for link in linksToTabs
|
||||||
|
link.addEventListener("click", _clickLinkToTab)
|
||||||
|
|
||||||
App.directive "bookmarkableTab", ($location) ->
|
App.directive "bookmarkableTab", ($location) ->
|
||||||
restrict: "A"
|
restrict: "A"
|
||||||
require: "tab"
|
require: "tab"
|
||||||
|
|
Loading…
Reference in a new issue