mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 11:36:20 +05:30
Happy New Year!
The ported version of Twenty Fifteen and Twenty Sixteen include with the package. Maintenance and bugs fixes.
This commit is contained in:
parent
767d43dbd0
commit
a273a4faf7
72 changed files with 17132 additions and 30 deletions
178
themes/twentyfifteen/js/functions.js
Normal file
178
themes/twentyfifteen/js/functions.js
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
/* global screenReaderText */
|
||||
/**
|
||||
* Theme functions file.
|
||||
*
|
||||
* Contains handlers for navigation and widget area.
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
var $body, $window, $sidebar, adminbarOffset, top = false,
|
||||
bottom = false, windowWidth, windowHeight, lastWindowPos = 0,
|
||||
topOffset = 0, bodyHeight, sidebarHeight, resizeTimer,
|
||||
secondary, button;
|
||||
|
||||
function initMainNavigation( container ) {
|
||||
// Add dropdown toggle that display child menu items.
|
||||
container.find( '.item.dropdown > a' ).after( '<button class="dropdown-toggle-button" aria-expanded="false">' + screenReaderText.expand + '</button>' );
|
||||
|
||||
// Toggle buttons and submenu items with active children menu items.
|
||||
container.find( '.item.dropdown.active > button' ).addClass( 'toggle-on' );
|
||||
container.find( '.item.dropdown.active > .subnav' ).addClass( 'toggled-on' );
|
||||
|
||||
container.find( '.dropdown-toggle-button' ).click( function( e ) {
|
||||
var _this = $( this );
|
||||
e.preventDefault();
|
||||
_this.toggleClass( 'toggle-on' );
|
||||
_this.next( '.children, .sub-menu, .subnav, .dropdown-menu' ).toggleClass( 'toggled-on' );
|
||||
_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
|
||||
_this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
|
||||
} );
|
||||
}
|
||||
initMainNavigation( $( '.main-navigation' ) );
|
||||
|
||||
// Re-initialize the main navigation when it is updated, persisting any existing submenu expanded states.
|
||||
$( document ).on( 'customize-preview-menu-refreshed', function( e, params ) {
|
||||
if ( 'primary' === params.wpNavMenuArgs.theme_location ) {
|
||||
initMainNavigation( params.newContainer );
|
||||
|
||||
// Re-sync expanded states from oldContainer.
|
||||
params.oldContainer.find( '.dropdown-toggle-button.toggle-on' ).each(function() {
|
||||
var containerId = $( this ).parent().prop( 'id' );
|
||||
$( params.newContainer ).find( '#' + containerId + ' > .dropdown-toggle-button' ).triggerHandler( 'click' );
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
secondary = $( '#secondary' );
|
||||
button = $( '.site-branding' ).find( '.secondary-toggle' );
|
||||
|
||||
// Enable menu toggle for small screens.
|
||||
( function() {
|
||||
var menu, widgets, social;
|
||||
if ( ! secondary || ! button ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide button if there are no widgets and the menus are missing or empty.
|
||||
menu = secondary.find( '.nav-menu' );
|
||||
widgets = secondary.find( '#widget-area' );
|
||||
social = secondary.find( '#social-navigation' );
|
||||
if ( ! widgets.length && ! social.length && ( ! menu || ! menu.children().length ) ) {
|
||||
button.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
button.on( 'click.twentyfifteen', function() {
|
||||
secondary.toggleClass( 'toggled-on' );
|
||||
secondary.trigger( 'resize' );
|
||||
$( this ).toggleClass( 'toggled-on' );
|
||||
if ( $( this, secondary ).hasClass( 'toggled-on' ) ) {
|
||||
$( this ).attr( 'aria-expanded', 'true' );
|
||||
secondary.attr( 'aria-expanded', 'true' );
|
||||
} else {
|
||||
$( this ).attr( 'aria-expanded', 'false' );
|
||||
secondary.attr( 'aria-expanded', 'false' );
|
||||
}
|
||||
} );
|
||||
} )();
|
||||
|
||||
/**
|
||||
* @summary Add or remove ARIA attributes.
|
||||
* Uses jQuery's width() function to determine the size of the window and add
|
||||
* the default ARIA attributes for the menu toggle if it's visible.
|
||||
* @since Twenty Fifteen 1.1
|
||||
*/
|
||||
function onResizeARIA() {
|
||||
if ( 955 > $window.width() ) {
|
||||
button.attr( 'aria-expanded', 'false' );
|
||||
secondary.attr( 'aria-expanded', 'false' );
|
||||
button.attr( 'aria-controls', 'secondary' );
|
||||
} else {
|
||||
button.removeAttr( 'aria-expanded' );
|
||||
secondary.removeAttr( 'aria-expanded' );
|
||||
button.removeAttr( 'aria-controls' );
|
||||
}
|
||||
}
|
||||
|
||||
// Sidebar scrolling.
|
||||
function resize() {
|
||||
windowWidth = $window.width();
|
||||
|
||||
if ( 955 > windowWidth ) {
|
||||
top = bottom = false;
|
||||
$sidebar.removeAttr( 'style' );
|
||||
}
|
||||
}
|
||||
|
||||
function scroll() {
|
||||
var windowPos = $window.scrollTop();
|
||||
|
||||
if ( 955 > windowWidth ) {
|
||||
return;
|
||||
}
|
||||
|
||||
sidebarHeight = $sidebar.height();
|
||||
windowHeight = $window.height();
|
||||
bodyHeight = $body.height();
|
||||
|
||||
if ( sidebarHeight + adminbarOffset > windowHeight ) {
|
||||
if ( windowPos > lastWindowPos ) {
|
||||
if ( top ) {
|
||||
top = false;
|
||||
topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
|
||||
$sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
|
||||
} else if ( ! bottom && windowPos + windowHeight > sidebarHeight + $sidebar.offset().top && sidebarHeight + adminbarOffset < bodyHeight ) {
|
||||
bottom = true;
|
||||
$sidebar.attr( 'style', 'position: fixed; bottom: 0;' );
|
||||
}
|
||||
} else if ( windowPos < lastWindowPos ) {
|
||||
if ( bottom ) {
|
||||
bottom = false;
|
||||
topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
|
||||
$sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
|
||||
} else if ( ! top && windowPos + adminbarOffset < $sidebar.offset().top ) {
|
||||
top = true;
|
||||
$sidebar.attr( 'style', 'position: fixed;' );
|
||||
}
|
||||
} else {
|
||||
top = bottom = false;
|
||||
topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
|
||||
$sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
|
||||
}
|
||||
} else if ( ! top ) {
|
||||
top = true;
|
||||
$sidebar.attr( 'style', 'position: fixed;' );
|
||||
}
|
||||
|
||||
lastWindowPos = windowPos;
|
||||
}
|
||||
|
||||
function resizeAndScroll() {
|
||||
resize();
|
||||
scroll();
|
||||
}
|
||||
|
||||
$( document ).ready( function() {
|
||||
$body = $( document.body );
|
||||
$window = $( window );
|
||||
$sidebar = $( '#sidebar' ).first();
|
||||
adminbarOffset = $( '#toolbar' ).height();
|
||||
|
||||
$window
|
||||
.on( 'scroll.twentyfifteen', scroll )
|
||||
.on( 'load.twentyfifteen', onResizeARIA )
|
||||
.on( 'resize.twentyfifteen', function() {
|
||||
clearTimeout( resizeTimer );
|
||||
resizeTimer = setTimeout( resizeAndScroll, 500 );
|
||||
onResizeARIA();
|
||||
} );
|
||||
$sidebar.on( 'click.twentyfifteen keydown.twentyfifteen', 'button', resizeAndScroll );
|
||||
|
||||
resizeAndScroll();
|
||||
|
||||
for ( var i = 1; i < 6; i++ ) {
|
||||
setTimeout( resizeAndScroll, 100 * i );
|
||||
}
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
9
themes/twentyfifteen/js/html5.js
Normal file
9
themes/twentyfifteen/js/html5.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
||||
*/
|
||||
|
||||
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
|
||||
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}</style>";
|
||||
c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
|
||||
"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);
|
||||
if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);
|
||||
2
themes/twentyfifteen/js/jquery-migrate.js
vendored
Normal file
2
themes/twentyfifteen/js/jquery-migrate.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
themes/twentyfifteen/js/jquery.js
vendored
Normal file
4
themes/twentyfifteen/js/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
26
themes/twentyfifteen/js/skip-link-focus-fix.js
Normal file
26
themes/twentyfifteen/js/skip-link-focus-fix.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Makes "skip to content" link work correctly in IE9, Chrome, and Opera
|
||||
* for better accessibility.
|
||||
*
|
||||
* @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
|
||||
*/
|
||||
|
||||
( function() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
|
||||
if ( ( ua.indexOf( 'webkit' ) > -1 || ua.indexOf( 'opera' ) > -1 || ua.indexOf( 'msie' ) > -1 ) &&
|
||||
document.getElementById && window.addEventListener ) {
|
||||
|
||||
window.addEventListener( 'hashchange', function() {
|
||||
var element = document.getElementById( location.hash.substring( 1 ) );
|
||||
|
||||
if ( element ) {
|
||||
if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.nodeName ) ) {
|
||||
element.tabIndex = -1;
|
||||
}
|
||||
|
||||
element.focus();
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
} )();
|
||||
Loading…
Add table
Add a link
Reference in a new issue