|
@@ -1,35 +1,22 @@
|
|
|
-/* eslint-disable
|
|
|
|
|
- max-len,
|
|
|
|
|
- no-undef,
|
|
|
|
|
-*/
|
|
|
|
|
-// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
|
-// Fix any style issues and re-enable lint.
|
|
|
|
|
-/*
|
|
|
|
|
- * decaffeinate suggestions:
|
|
|
|
|
- * DS101: Remove unnecessary use of Array.from
|
|
|
|
|
- * DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
- * DS207: Consider shorter variations of null checks
|
|
|
|
|
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
|
- */
|
|
|
|
|
define(['base'], function(App) {
|
|
define(['base'], function(App) {
|
|
|
App.directive('bookmarkableTabset', ($location, _) => ({
|
|
App.directive('bookmarkableTabset', ($location, _) => ({
|
|
|
restrict: 'A',
|
|
restrict: 'A',
|
|
|
require: 'tabset',
|
|
require: 'tabset',
|
|
|
link(scope, el, attrs, tabset) {
|
|
link(scope, el, attrs, tabset) {
|
|
|
const _makeActive = function(hash) {
|
|
const _makeActive = function(hash) {
|
|
|
- if (hash != null && hash !== '') {
|
|
|
|
|
|
|
+ if (hash && hash !== '') {
|
|
|
const matchingTab = _.find(
|
|
const matchingTab = _.find(
|
|
|
tabset.tabs,
|
|
tabset.tabs,
|
|
|
tab => tab.bookmarkableTabId === hash
|
|
tab => tab.bookmarkableTabId === hash
|
|
|
)
|
|
)
|
|
|
- if (matchingTab != null) {
|
|
|
|
|
|
|
+ if (matchingTab) {
|
|
|
matchingTab.select()
|
|
matchingTab.select()
|
|
|
return el.children()[0].scrollIntoView({ behavior: 'smooth' })
|
|
return el.children()[0].scrollIntoView({ behavior: 'smooth' })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return scope.$applyAsync(function() {
|
|
|
|
|
|
|
+ scope.$applyAsync(function() {
|
|
|
// for page load
|
|
// for page load
|
|
|
const hash = $location.hash()
|
|
const hash = $location.hash()
|
|
|
_makeActive(hash)
|
|
_makeActive(hash)
|
|
@@ -38,11 +25,16 @@ define(['base'], function(App) {
|
|
|
// this needs to be within applyAsync because there could be a link
|
|
// this needs to be within applyAsync because there could be a link
|
|
|
// within a tab to another tab
|
|
// within a tab to another tab
|
|
|
const linksToTabs = document.querySelectorAll('.link-to-tab')
|
|
const linksToTabs = document.querySelectorAll('.link-to-tab')
|
|
|
- const _clickLinkToTab = event =>
|
|
|
|
|
- _makeActive(event.currentTarget.getAttribute('href').replace('#', ''))
|
|
|
|
|
|
|
+ const _clickLinkToTab = event => {
|
|
|
|
|
+ const hash = event.currentTarget
|
|
|
|
|
+ .getAttribute('href')
|
|
|
|
|
+ .split('#')
|
|
|
|
|
+ .pop()
|
|
|
|
|
+ _makeActive(hash)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (linksToTabs) {
|
|
if (linksToTabs) {
|
|
|
- return Array.from(linksToTabs).map(link =>
|
|
|
|
|
|
|
+ Array.from(linksToTabs).map(link =>
|
|
|
link.addEventListener('click', _clickLinkToTab)
|
|
link.addEventListener('click', _clickLinkToTab)
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -50,15 +42,15 @@ define(['base'], function(App) {
|
|
|
}
|
|
}
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
- return App.directive('bookmarkableTab', $location => ({
|
|
|
|
|
|
|
+ App.directive('bookmarkableTab', $location => ({
|
|
|
restrict: 'A',
|
|
restrict: 'A',
|
|
|
require: 'tab',
|
|
require: 'tab',
|
|
|
link(scope, el, attrs, tab) {
|
|
link(scope, el, attrs, tab) {
|
|
|
const tabScope = el.isolateScope()
|
|
const tabScope = el.isolateScope()
|
|
|
const tabId = attrs.bookmarkableTab
|
|
const tabId = attrs.bookmarkableTab
|
|
|
- if (tabScope != null && tabId != null && tabId !== '') {
|
|
|
|
|
|
|
+ if (tabScope && tabId && tabId !== '') {
|
|
|
tabScope.bookmarkableTabId = tabId
|
|
tabScope.bookmarkableTabId = tabId
|
|
|
- return tabScope.$watch('active', function(isActive, wasActive) {
|
|
|
|
|
|
|
+ tabScope.$watch('active', function(isActive, wasActive) {
|
|
|
if (isActive && !wasActive && $location.hash() !== tabId) {
|
|
if (isActive && !wasActive && $location.hash() !== tabId) {
|
|
|
return $location.hash(tabId)
|
|
return $location.hash(tabId)
|
|
|
}
|
|
}
|