-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtabnav.html
More file actions
131 lines (106 loc) · 9.35 KB
/
Copy pathtabnav.html
File metadata and controls
131 lines (106 loc) · 9.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html>
<head>
<link rel="import" href="_loader.html" />
</head>
<body>
<template>
<style type="text/css">/*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px;line-height:1.5;color:#24292e;background-color:#fff}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}summary{display:list-item}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress,sub,sup{vertical-align:baseline}[hidden],template{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects;color:#0366d6;text-decoration:none}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline dotted}b,strong{font-weight:600}dfn{font-style:italic}h1{margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:90%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}svg:not(:root){overflow:hidden}kbd,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box}button,input,select,textarea{font:inherit;margin:0}optgroup{font-weight:700}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}*{box-sizing:border-box}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a:hover{text-decoration:underline}.rule,hr{height:0;margin:15px 0;overflow:hidden;background:0 0;border:0;border-bottom:1px solid #dfe2e5}.rule::after,.rule::before,hr::after,hr::before{display:table;content:""}.rule::after,hr::after{clear:both}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}button{cursor:pointer}h1,h2,h3,h4,h5,h6,p{margin-top:0;margin-bottom:0}h1,h2,h3,h4,h5,h6{font-size:32px;font-weight:600}h2,h3,h4,h5,h6{font-size:24px}h3,h4,h5,h6{font-size:20px}h4,h5,h6{font-size:16px}h5,h6{font-size:14px}h6{font-size:12px}p{margin-bottom:10px}blockquote{margin:0}ol,ul{padding-left:0}ol ol,ul ol{list-style-type:lower-roman}ol ol ol,ol ul ol,ul ol ol,ul ul ol{list-style-type:lower-alpha}dd{margin-left:0}code,pre,tt{font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px}ol,pre,ul{margin-top:0;margin-bottom:0}.octicon{vertical-align:text-bottom}</style>
<style type="text/css">.position-static{position:static!important}.position-relative{position:relative!important}.position-absolute{position:absolute!important}.position-fixed{position:fixed!important}.top-0{top:0!important}.right-0{right:0!important}.bottom-0{bottom:0!important}.left-0{left:0!important}.v-align-middle{vertical-align:middle!important}.v-align-top{vertical-align:top!important}.v-align-bottom{vertical-align:bottom!important}.v-align-text-top{vertical-align:text-top!important}.v-align-text-bottom{vertical-align:text-bottom!important}.v-align-baseline{vertical-align:baseline!important}.overflow-hidden{overflow:hidden!important}.overflow-scroll{overflow:scroll!important}.overflow-auto{overflow:auto!important}.clearfix::after,.clearfix::before{display:table;content:""}.clearfix::after{clear:both}.float-right{float:right!important}.float-left{float:left!important}.float-none{float:none!important}@media (min-width:544px){.float-sm-left{float:left!important}.float-sm-right{float:right!important}.float-sm-none{float:none!important}}@media (min-width:768px){.float-md-left{float:left!important}.float-md-right{float:right!important}.float-md-none{float:none!important}}@media (min-width:1012px){.float-lg-left{float:left!important}.float-lg-right{float:right!important}.float-lg-none{float:none!important}}@media (min-width:1280px){.float-xl-left{float:left!important}.float-xl-right{float:right!important}.float-xl-none{float:none!important}}.width-fit{max-width:100%!important}.width-full{width:100%!important}.height-full{height:100%!important}.min-width-0{min-width:0!important}.direction-rtl{direction:rtl!important}.direction-ltr{direction:ltr!important}@media (min-width:544px){.direction-sm-rtl{direction:rtl!important}.direction-sm-ltr{direction:ltr!important}}@media (min-width:768px){.direction-md-rtl{direction:rtl!important}.direction-md-ltr{direction:ltr!important}}@media (min-width:1012px){.direction-lg-rtl{direction:rtl!important}.direction-lg-ltr{direction:ltr!important}}@media (min-width:1280px){.direction-xl-rtl{direction:rtl!important}.direction-xl-ltr{direction:ltr!important}}.tabnav{margin-top:0;margin-bottom:15px;border-bottom:1px solid #d1d5da}.tabnav .Counter{margin-left:5px}.tabnav-tabs{margin-bottom:-1px}.tabnav-tab{display:inline-block;padding:8px 12px;font-size:14px;line-height:20px;color:#586069;text-decoration:none;background-color:transparent;border:1px solid transparent;border-bottom:0}.tabnav-tab.selected{color:#24292e;background-color:#fff;border-color:#d1d5da;border-radius:3px 3px 0 0}.tabnav-tab:focus,.tabnav-tab:hover{color:#24292e;text-decoration:none}.tabnav-extra{display:inline-block;padding-top:10px;font-size:12px;color:#586069}.tabnav-extra>.octicon{margin-right:2px}a.tabnav-extra:hover{color:#0366d6;text-decoration:none}.tabnav-btn,.tabnav-extra{margin-left:10px}</style>
<style type="text/css">
.tabnav {
min-height: 36px;
}
.tabnav-tabs {
text-align: left;
}
.tabnav-extra {
line-height: 20px;
}
</style>
</template>
<script>
(function() {
githubPrimer.registerElement('primer-tabnav', {
create: function (ownerDocument, document) {
var div = document.createElement('div');
div.classList.add('tabnav');
var nav = document.createElement('nav');
nav.classList.add('tabnav-tabs');
if (this.hasAttribute('aria-label')) {
nav.setAttribute('aria-label', this.getAttribute('aria-label'));
}
children = Array.from(this.children);
var shadowRoot = this.attachShadow({ mode: 'open' });
children.forEach((child, i) => {
if (child.tagName.toLowerCase() === "item") {
child.classList.add('tabnav-tab');
child.addEventListener('click', selectItemOnRootElement(nav));
nav.appendChild(child);
} else {
child.classList.add('float-right');
if (isTabnavExtra(child)) {
child.classList.add('tabnav-extra');
}
div.appendChild(child);
}
});
updateChildren(nav);
div.appendChild(nav);
shadowRoot.appendChild(div);
return shadowRoot;
}
});
function updateChildren(rootElement) {
Array.from(rootElement.children)
.forEach(child => {
if (isChildSelected(child)) {
child.classList.add('selected');
child.setAttribute('aria-current', 'page');
} else {
child.classList.remove('selected');
if (child.hasAttribute('aria-current')) {
child.removeAttribute('aria-current');
}
}
});
}
function selectItemOnRootElement(rootElement) {
return function(event) {
event.preventDefault();
event.stopPropagation();
target = event.target;
while (!target.classList.contains('tabnav-tab')) {
target = target.parentNode;
}
newSelection = target
// deselect existing
Array.from(rootElement.children)
.filter(child => child != newSelection)
.forEach(child => {
if (child.hasAttribute('selected')) {
child.removeAttribute('selected');
}
});
// select new item
newSelection.setAttribute('selected', true);
updateChildren(rootElement);
}
}
function isChildSelected(child) {
if (!child.hasAttribute('selected')) {
return false;
}
return (child.getAttribute('selected').toLowerCase() !== 'false');
}
function isTabnavExtra(child) {
if (child.hasAttribute('extra')) {
return !(child.getAttribute('extra').toLowerCase() === 'false');
}
return false
}
})();
</script>
</body>
</html>