1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- document . addEventListener ( 'DOMContentLoaded' , function ( ) {
16- var migrationInfoAccepted = window . localStorage . getItem ( 'migrationInfoAccepted' )
17- if ( migrationInfoAccepted != 'true' ) {
18- var migrationBar = document . getElementById ( 'migration-info' )
19- migrationBar . style . display = 'flex' ;
20- document . documentElement . classList . add ( "has-navbar-banner-top" )
21- var migrationButton = document . getElementById ( 'migration-button' )
22- migrationButton . addEventListener ( 'click' , function ( ) {
23- window . localStorage . setItem ( 'migrationInfoAccepted' , true )
24- migrationBar . style . display = 'none' ;
25- document . documentElement . classList . remove ( "has-navbar-banner-top" )
26- } )
27- }
28-
15+ function addNavBarBurgers ( ) {
2916 var $navbarBurgers = Array . prototype . slice . call ( document . querySelectorAll ( '.navbar-burger' ) , 0 )
3017 if ( $navbarBurgers . length > 0 ) {
3118 $navbarBurgers . forEach ( function ( el ) {
@@ -37,7 +24,22 @@ document.addEventListener('DOMContentLoaded', function () {
3724 } )
3825 } )
3926 }
27+ }
28+
29+ function addAnchor ( element ) {
30+ element . insertAdjacentHTML ( 'beforeend' ,
31+ `<a class="header-hash" href="#${ element . id } " ariaLabel="Anchor">#</a>` )
32+ }
33+
34+ function addAnchors ( ) {
35+ var headers = document . querySelectorAll (
36+ '.docs-content h2[id], .docs-content h3[id], .docs-content h4[id], .docs-content h5[id], .docs-content h6[id]' )
37+ if ( headers ) {
38+ headers . forEach ( addAnchor )
39+ }
40+ }
4041
42+ function addTabs ( ) {
4143 const tabs = [ ...document . querySelectorAll ( '.tabs li' ) ]
4244 const tabContent = [ ...document . querySelectorAll ( '.tab-content section' ) ]
4345 const activeClass = 'is-active'
@@ -102,4 +104,26 @@ document.addEventListener('DOMContentLoaded', function () {
102104 }
103105
104106 init ( )
107+ }
108+
109+ function addMigrationBar ( ) {
110+ var migrationInfoAccepted = window . localStorage . getItem ( 'migrationInfoAccepted' )
111+ if ( migrationInfoAccepted != 'true' ) {
112+ var migrationBar = document . getElementById ( 'migration-info' )
113+ migrationBar . style . display = 'flex' ;
114+ document . documentElement . classList . add ( "has-navbar-banner-top" )
115+ var migrationButton = document . getElementById ( 'migration-button' )
116+ migrationButton . addEventListener ( 'click' , function ( ) {
117+ window . localStorage . setItem ( 'migrationInfoAccepted' , true )
118+ migrationBar . style . display = 'none' ;
119+ document . documentElement . classList . remove ( "has-navbar-banner-top" )
120+ } )
121+ }
122+ }
123+
124+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
125+ addAnchors ( )
126+ addMigrationBar ( )
127+ addNavBarBurgers ( )
128+ addTabs ( )
105129} )
0 commit comments