mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Create bookmarkable tabs directive.
This commit is contained in:
parent
baf8b599d7
commit
399a9ed604
2 changed files with 30 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
App.directive "bookmarkableTabset", ($location, _) ->
|
||||
restrict: "A"
|
||||
require: "tabset"
|
||||
link: (scope, el, attrs, tabset) ->
|
||||
scope.$applyAsync () ->
|
||||
hash = $location.hash()
|
||||
if hash?
|
||||
matchingTab = _.find tabset.tabs, (tab) ->
|
||||
tab.bookmarkableTabId == hash
|
||||
if matchingTab?
|
||||
matchingTab.select()
|
||||
|
||||
App.directive "bookmarkableTab", ($location) ->
|
||||
restrict: "A"
|
||||
require: "tab"
|
||||
link: (scope, el, attrs, tab) ->
|
||||
tabScope = el.isolateScope()
|
||||
tabId = attrs.bookmarkableTab
|
||||
if tabScope? and tabId? and tabId != ""
|
||||
tabScope.bookmarkableTabId = tabId
|
||||
tabScope.$watch "active", (isActive, wasActive) ->
|
||||
if isActive and !wasActive
|
||||
$location.hash tabId
|
||||
|
||||
|
||||
|
|
@ -37,6 +37,7 @@ define [
|
|||
"directives/selectAll"
|
||||
"directives/maxHeight"
|
||||
"directives/creditCards"
|
||||
"directives/bookmarkableTabset"
|
||||
"services/queued-http"
|
||||
"services/validateCaptcha"
|
||||
"filters/formatDate"
|
||||
|
|
Loading…
Reference in a new issue