mirror of
https://github.com/picocms/pico-theme.git
synced 2025-08-04 15:57:53 +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:
3
js/modernizr-3.3.1-custom.min.js
vendored
Normal file
3
js/modernizr-3.3.1-custom.min.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/*! modernizr 3.3.1 (Custom Build) | MIT *
|
||||
* https://modernizr.com/download/?-classlist-csstransitions-requestanimationframe !*/
|
||||
!function(e,n,t){function r(e,n){return typeof e===n}function i(){var e,n,t,i,o,s,a;for(var f in y)if(y.hasOwnProperty(f)){if(e=[],n=y[f],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;t<n.options.aliases.length;t++)e.push(n.options.aliases[t].toLowerCase());for(i=r(n.fn,"function")?n.fn():n.fn,o=0;o<e.length;o++)s=e[o],a=s.split("."),1===a.length?Modernizr[a[0]]=i:(!Modernizr[a[0]]||Modernizr[a[0]]instanceof Boolean||(Modernizr[a[0]]=new Boolean(Modernizr[a[0]])),Modernizr[a[0]][a[1]]=i),C.push((i?"":"no-")+a.join("-"))}}function o(e){return e.replace(/([a-z])-([a-z])/g,function(e,n,t){return n+t.toUpperCase()}).replace(/^-/,"")}function s(e,n){return!!~(""+e).indexOf(n)}function a(e,n){return function(){return e.apply(n,arguments)}}function f(e,n,t){var i;for(var o in e)if(e[o]in n)return t===!1?e[o]:(i=n[e[o]],r(i,"function")?a(i,t||n):i);return!1}function l(){return"function"!=typeof n.createElement?n.createElement(arguments[0]):T?n.createElementNS.call(n,"http://www.w3.org/2000/svg",arguments[0]):n.createElement.apply(n,arguments)}function u(e){return e.replace(/([A-Z])/g,function(e,n){return"-"+n.toLowerCase()}).replace(/^ms-/,"-ms-")}function d(){var e=n.body;return e||(e=l(T?"svg":"body"),e.fake=!0),e}function p(e,t,r,i){var o,s,a,f,u="modernizr",p=l("div"),c=d();if(parseInt(r,10))for(;r--;)a=l("div"),a.id=i?i[r]:u+(r+1),p.appendChild(a);return o=l("style"),o.type="text/css",o.id="s"+u,(c.fake?c:p).appendChild(o),c.appendChild(p),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(n.createTextNode(e)),p.id=u,c.fake&&(c.style.background="",c.style.overflow="hidden",f=w.style.overflow,w.style.overflow="hidden",w.appendChild(c)),s=t(p,e),c.fake?(c.parentNode.removeChild(c),w.style.overflow=f,w.offsetHeight):p.parentNode.removeChild(p),!!s}function c(n,r){var i=n.length;if("CSS"in e&&"supports"in e.CSS){for(;i--;)if(e.CSS.supports(u(n[i]),r))return!0;return!1}if("CSSSupportsRule"in e){for(var o=[];i--;)o.push("("+u(n[i])+":"+r+")");return o=o.join(" or "),p("@supports ("+o+") { #modernizr { position: absolute; } }",function(e){return"absolute"==getComputedStyle(e,null).position})}return t}function m(e,n,i,a){function f(){d&&(delete P.style,delete P.modElem)}if(a=r(a,"undefined")?!1:a,!r(i,"undefined")){var u=c(e,i);if(!r(u,"undefined"))return u}for(var d,p,m,v,h,y=["modernizr","tspan","samp"];!P.style&&y.length;)d=!0,P.modElem=l(y.shift()),P.style=P.modElem.style;for(m=e.length,p=0;m>p;p++)if(v=e[p],h=P.style[v],s(v,"-")&&(v=o(v)),P.style[v]!==t){if(a||r(i,"undefined"))return f(),"pfx"==n?v:!0;try{P.style[v]=i}catch(g){}if(P.style[v]!=h)return f(),"pfx"==n?v:!0}return f(),!1}function v(e,n,t,i,o){var s=e.charAt(0).toUpperCase()+e.slice(1),a=(e+" "+_.join(s+" ")+s).split(" ");return r(n,"string")||r(n,"undefined")?m(a,n,i,o):(a=(e+" "+E.join(s+" ")+s).split(" "),f(a,n,t))}function h(e,n,r){return v(e,t,t,n,r)}var y=[],g={_version:"3.3.1",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){y.push({name:e,fn:n,options:t})},addAsyncTest:function(e){y.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=g,Modernizr=new Modernizr;var C=[],w=n.documentElement;Modernizr.addTest("classlist","classList"in w);var x="Moz O ms Webkit",_=g._config.usePrefixes?x.split(" "):[];g._cssomPrefixes=_;var S=function(n){var r,i=prefixes.length,o=e.CSSRule;if("undefined"==typeof o)return t;if(!n)return!1;if(n=n.replace(/^@/,""),r=n.replace(/-/g,"_").toUpperCase()+"_RULE",r in o)return"@"+n;for(var s=0;i>s;s++){var a=prefixes[s],f=a.toUpperCase()+"_"+r;if(f in o)return"@-"+a.toLowerCase()+"-"+n}return!1};g.atRule=S;var E=g._config.usePrefixes?x.toLowerCase().split(" "):[];g._domPrefixes=E;var T="svg"===w.nodeName.toLowerCase(),z={elem:l("modernizr")};Modernizr._q.push(function(){delete z.elem});var P={style:z.elem.style};Modernizr._q.unshift(function(){delete P.style}),g.testAllProps=v;var b=g.prefixed=function(e,n,t){return 0===e.indexOf("@")?S(e):(-1!=e.indexOf("-")&&(e=o(e)),n?v(e,n,t):v(e,"pfx"))};Modernizr.addTest("requestanimationframe",!!b("requestAnimationFrame",e),{aliases:["raf"]}),g.testAllProps=h,Modernizr.addTest("csstransitions",h("transition","all",!0)),i(),delete g.addTest,delete g.addAsyncTest;for(var L=0;L<Modernizr._q.length;L++)Modernizr._q[L]();e.Modernizr=Modernizr}(window,document);
|
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();
|
135
js/utils.js
Normal file
135
js/utils.js
Normal file
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
utils = {};
|
||||
|
||||
/**
|
||||
* Checks whether the client's browser is able to slide elements or not
|
||||
*
|
||||
* @return boolean TRUE when the browser supports sliding, FALSE otherwise
|
||||
*/
|
||||
utils.canSlide = function ()
|
||||
{
|
||||
return (Modernizr.classlist && Modernizr.requestanimationframe && Modernizr.csstransitions);
|
||||
};
|
||||
|
||||
/**
|
||||
* Slides a element up (i.e. hide a element by changing its height to 0px)
|
||||
*
|
||||
* @param HTMLElement element the element to slide up
|
||||
* @param function finishCallback function to call when the animation has
|
||||
* been finished (i.e. the element is hidden)
|
||||
* @param function startCallback function to call when the animation starts
|
||||
* @return void
|
||||
*/
|
||||
utils.slideUp = function (element, finishCallback, startCallback)
|
||||
{
|
||||
if (!utils.canSlide()) {
|
||||
if (startCallback) startCallback();
|
||||
element.className += (element.className !== '') ? ' hidden' : 'hidden';
|
||||
if (finishCallback) window.requestAnimationFrame(finishCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
element.style.height = element.clientHeight + 'px';
|
||||
|
||||
var slideId = parseInt(element.getAttribute('data-slide-id')) || 0;
|
||||
element.setAttribute('data-slide-id', ++slideId);
|
||||
|
||||
window.requestAnimationFrame(function () {
|
||||
element.classList.add('slide');
|
||||
|
||||
window.requestAnimationFrame(function () {
|
||||
element.style.height = '0px';
|
||||
|
||||
if (startCallback) {
|
||||
startCallback();
|
||||
}
|
||||
|
||||
window.setTimeout(function () {
|
||||
if (parseInt(element.getAttribute('data-slide-id')) !== slideId) return;
|
||||
|
||||
element.classList.add('hidden');
|
||||
element.classList.remove('slide');
|
||||
element.style.height = null;
|
||||
|
||||
if (finishCallback) {
|
||||
window.requestAnimationFrame(finishCallback);
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Slides a element down (i.e. show a hidden element)
|
||||
*
|
||||
* @param HTMLElement element the element to slide down
|
||||
* @param function finishCallback function to call when the animation has
|
||||
* been finished (i.e. the element is visible)
|
||||
* @param function startCallback function to call when the animation starts
|
||||
* @return void
|
||||
*/
|
||||
utils.slideDown = function (element, finishCallback, startCallback)
|
||||
{
|
||||
if (!utils.canSlide()) {
|
||||
if (startCallback) startCallback();
|
||||
element.className = element.className.replace(/\bhidden\b */g, '');
|
||||
if (finishCallback) window.requestAnimationFrame(finishCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
var cssRuleOriginalValue = element.clientHeight + 'px',
|
||||
slideId = parseInt(element.getAttribute('data-slide-id')) || 0;
|
||||
|
||||
element.setAttribute('data-slide-id', ++slideId);
|
||||
|
||||
element.style.height = null;
|
||||
element.classList.remove('hidden');
|
||||
element.classList.remove('slide');
|
||||
var cssRuleValue = element.clientHeight + 'px';
|
||||
|
||||
element.style.height = cssRuleOriginalValue;
|
||||
|
||||
window.requestAnimationFrame(function () {
|
||||
element.classList.add('slide');
|
||||
|
||||
window.requestAnimationFrame(function () {
|
||||
element.style.height = cssRuleValue;
|
||||
|
||||
if (startCallback) {
|
||||
startCallback();
|
||||
}
|
||||
|
||||
window.setTimeout(function () {
|
||||
if (parseInt(element.getAttribute('data-slide-id')) !== slideId) return;
|
||||
|
||||
element.classList.remove('slide');
|
||||
element.style.height = null;
|
||||
|
||||
if (finishCallback) {
|
||||
window.requestAnimationFrame(finishCallback);
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether a element is visible or not
|
||||
*
|
||||
* @param HTMLElement element the element to check
|
||||
* @return boolean TRUE when the element is visible, FALSE otherwise
|
||||
*/
|
||||
utils.isElementVisible = function (element)
|
||||
{
|
||||
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
||||
};
|
Reference in New Issue
Block a user