mirror of
https://github.com/picocms/pico-theme.git
synced 2025-07-23 10:01:58 +02:00
Extract default theme from picocms/Pico repo
This repo is a copy of the picocms/Pico repo (https://github.com/picocms/Pico) at commit 82a342ba445122182b898a2c1800f03c8d16f18c with rewritten history. Only commits which are relevant for the themes/default/ directory (82a342ba44/themes/default/
) were preserved. The command used to create this repo can be found at http://stackoverflow.com/a/37037151. Pico is licensed under the MIT License (82a342ba44/LICENSE.md
).
This commit is contained in:
70
js/pico.js
Normal file
70
js/pico.js
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Pico's Default Theme - JavaScript helper
|
||||
*
|
||||
* Pico is a stupidly simple, blazing fast, flat file CMS.
|
||||
*
|
||||
* @author Daniel Rudolf
|
||||
* @link http://picocms.org
|
||||
* @license http://opensource.org/licenses/MIT The MIT License
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
function main()
|
||||
{
|
||||
// capability CSS classes
|
||||
document.documentElement.className = 'js';
|
||||
|
||||
// wrap tables
|
||||
var tables = document.querySelectorAll('#main > .container > table');
|
||||
for (var i = 0; i < tables.length; i++) {
|
||||
if (!/\btable-responsive\b/.test(tables[i].parentElement.className)) {
|
||||
var tableWrapper = document.createElement('div');
|
||||
tableWrapper.className = 'table-responsive';
|
||||
|
||||
tables[i].parentElement.insertBefore(tableWrapper, tables[i]);
|
||||
tableWrapper.appendChild(tables[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// responsive menu
|
||||
var menu = document.getElementById('nav'),
|
||||
menuToggle = document.getElementById('nav-toggle'),
|
||||
toggleMenuEvent = function (event) {
|
||||
if (event.type === 'keydown') {
|
||||
if ((event.keyCode != 13) && (event.keyCode != 32)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if (menuToggle.getAttribute('aria-expanded') === 'false') {
|
||||
menuToggle.setAttribute('aria-expanded', 'true');
|
||||
utils.slideDown(menu, null, function () {
|
||||
if (event.type === 'keydown') {
|
||||
menu.focus();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
menuToggle.setAttribute('aria-expanded', 'false');
|
||||
utils.slideUp(menu);
|
||||
}
|
||||
},
|
||||
onResizeEvent = function () {
|
||||
if (utils.isElementVisible(menuToggle)) {
|
||||
menu.className = 'hidden';
|
||||
menuToggle.addEventListener('click', toggleMenuEvent);
|
||||
menuToggle.addEventListener('keydown', toggleMenuEvent);
|
||||
} else {
|
||||
menu.className = '';
|
||||
menu.removeAttribute('data-slide-id');
|
||||
menuToggle.removeEventListener('click', toggleMenuEvent);
|
||||
menuToggle.removeEventListener('keydown', toggleMenuEvent);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('resize', onResizeEvent);
|
||||
onResizeEvent();
|
||||
}
|
||||
|
||||
main();
|
Reference in New Issue
Block a user