mirror of
https://github.com/10h30/trestle.git
synced 2026-07-11 18:56:07 +09:00
Merge pull request #2 from BraadMartin/dev
Switch to using $ instead of jQuery within functions.
This commit is contained in:
+38
-40
@@ -7,81 +7,81 @@
|
||||
*/
|
||||
|
||||
// Executes when the document is ready
|
||||
jQuery(document).ready(function() {
|
||||
jQuery(document).ready(function( $ ) {
|
||||
|
||||
// Get PHP vars passed via wp_localize_script()
|
||||
trestleEqualColsBreakpoint = trestle_vars.trestle_equal_cols_breakpoint;
|
||||
trestleEqualHeightCols = trestle_vars.trestle_equal_height_cols;
|
||||
|
||||
// Remove .no-jquery body class
|
||||
jQuery('body').removeClass('no-jquery');
|
||||
$('body').removeClass('no-jquery');
|
||||
|
||||
// External Links
|
||||
var h = window.location.host.toLowerCase();
|
||||
jQuery('[href^="http"]').not('[href*="' + h + '"]').addClass('external-link').attr("target", "_blank");
|
||||
$('[href^="http"]').not('[href*="' + h + '"]').addClass('external-link').attr("target", "_blank");
|
||||
|
||||
// Add classes to different types of links
|
||||
jQuery('a[href^="mailto:"]').addClass('email-link');
|
||||
jQuery('a[href*=".pdf"]').attr({"target":"_blank"}).addClass('pdf-link');
|
||||
jQuery('a[href*=".doc"]').attr({"target":"_blank"}).addClass('doc-link');
|
||||
jQuery('a').has('img').addClass('image-link');
|
||||
$('a[href^="mailto:"]').addClass('email-link');
|
||||
$('a[href*=".pdf"]').attr({"target":"_blank"}).addClass('pdf-link');
|
||||
$('a[href*=".doc"]').attr({"target":"_blank"}).addClass('doc-link');
|
||||
$('a').has('img').addClass('image-link');
|
||||
|
||||
// Add classes to parts of lists
|
||||
jQuery('li:last-child').addClass('last');
|
||||
jQuery('li:first-child').addClass('first');
|
||||
jQuery('ul, ol').parent('li').addClass('parent');
|
||||
$('li:last-child').addClass('last');
|
||||
$('li:first-child').addClass('first');
|
||||
$('ul, ol').parent('li').addClass('parent');
|
||||
|
||||
// Mobile header toggle buttons
|
||||
jQuery('.site-header .title-area').after('<div class="toggle-buttons" />');
|
||||
jQuery('.site-header .widget-area, .nav-primary').each(function(i) {
|
||||
var target = jQuery(this);
|
||||
$('.site-header .title-area').after('<div class="toggle-buttons" />');
|
||||
$('.site-header .widget-area, .nav-primary').each(function(i) {
|
||||
var target = $(this);
|
||||
|
||||
var buttonClass = 'toggle-button';
|
||||
|
||||
// Add classes of target element
|
||||
var targetClass = target.attr('class').split(/\s+/);
|
||||
jQuery.each(targetClass, function(index,value) {
|
||||
$.each(targetClass, function(index,value) {
|
||||
buttonClass += ' targets-' + value;
|
||||
});
|
||||
|
||||
if ( jQuery(this).is( 'nav' ) ) {
|
||||
if ( $(this).is( 'nav' ) ) {
|
||||
buttonClass += ' nav-toggle';
|
||||
}
|
||||
|
||||
// Add toggle buttons to header
|
||||
jQuery('.toggle-buttons').prepend('<a id="toggle-button-' + i + '" class="' + buttonClass + '" href="#">Toggle</a>');
|
||||
$('.toggle-buttons').prepend('<a id="toggle-button-' + i + '" class="' + buttonClass + '" href="#">Toggle</a>');
|
||||
|
||||
// Add target class to nav and widget areas
|
||||
target.addClass('toggle-target-' + i );
|
||||
});
|
||||
|
||||
// Toggle widget areas and primary nav
|
||||
jQuery('.site-header .toggle-button').click( function( event ) {
|
||||
$('.site-header .toggle-button').click( function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
var button = jQuery(this);
|
||||
var target = jQuery( '.toggle-target-' + button.attr('id').match(/\d+/) );
|
||||
var button = $(this);
|
||||
var target = $( '.toggle-target-' + button.attr('id').match(/\d+/) );
|
||||
|
||||
// Toggle buttons
|
||||
button.toggleClass('open');
|
||||
jQuery('.site-header .toggle-button').not(button).removeClass('open');
|
||||
$('.site-header .toggle-button').not(button).removeClass('open');
|
||||
|
||||
// Toggle targets
|
||||
target.toggleClass('open');
|
||||
jQuery('[class*="toggle-target"]').not(target).removeClass('open');
|
||||
$('[class*="toggle-target"]').not(target).removeClass('open');
|
||||
});
|
||||
|
||||
// Mobile navigation icons
|
||||
var closedIcon = '+';
|
||||
var openIcon = '-';
|
||||
|
||||
jQuery('.nav-primary').find('.genesis-nav-menu .parent:not(.current-menu-item, .current_page_item, .current_page_parent, .current_page_ancestor) > a').after('<a class="sub-icon" href="#">' + closedIcon + '</a>');
|
||||
jQuery('.nav-primary').find('.genesis-nav-menu .parent.current-menu-item > a, .genesis-nav-menu .parent.current_page_item > a, .genesis-nav-menu .parent.current_page_parent > a, .genesis-nav-menu .parent.current_page_ancestor > a').after('<a class="sub-icon" href="#">' + openIcon + '</a>');
|
||||
$('.nav-primary').find('.genesis-nav-menu .parent:not(.current-menu-item, .current_page_item, .current_page_parent, .current_page_ancestor) > a').after('<a class="sub-icon" href="#">' + closedIcon + '</a>');
|
||||
$('.nav-primary').find('.genesis-nav-menu .parent.current-menu-item > a, .genesis-nav-menu .parent.current_page_item > a, .genesis-nav-menu .parent.current_page_parent > a, .genesis-nav-menu .parent.current_page_ancestor > a').after('<a class="sub-icon" href="#">' + openIcon + '</a>');
|
||||
|
||||
// Mobile navigation expand/contract functionality
|
||||
jQuery('.sub-icon').click(function(event) {
|
||||
$('.sub-icon').click(function(event) {
|
||||
event.preventDefault();
|
||||
var icon = jQuery(this);
|
||||
var icon = $(this);
|
||||
icon.next('ul').slideToggle().toggleClass('open');
|
||||
if ( icon.text().indexOf( closedIcon ) !== -1 )
|
||||
icon.text(openIcon);
|
||||
@@ -89,16 +89,16 @@ jQuery(document).ready(function() {
|
||||
icon.text(closedIcon);
|
||||
});
|
||||
|
||||
jQuery('.widget-area-toggle').click(function(event) {
|
||||
$('.widget-area-toggle').click(function(event) {
|
||||
event.preventDefault();
|
||||
var button = jQuery(this);
|
||||
var button = $(this);
|
||||
button.toggleClass('open');
|
||||
button.next('.widget-area').slideToggle();
|
||||
});
|
||||
|
||||
// Equal height homepage cols
|
||||
jQuery('.equal-height-genesis-extender-cols .ez-home-container-area').each(function() {
|
||||
jQuery(this).children('.widget-area').equalHeights(null,null,trestleEqualColsBreakpoint);
|
||||
$('.equal-height-genesis-extender-cols .ez-home-container-area').each(function() {
|
||||
$(this).children('.widget-area').equalHeights(null,null,trestleEqualColsBreakpoint);
|
||||
});
|
||||
|
||||
|
||||
@@ -106,13 +106,11 @@ jQuery(document).ready(function() {
|
||||
|
||||
|
||||
// Executes when complete page is fully loaded, including all frames, objects, and images
|
||||
jQuery(window).load(function() {
|
||||
jQuery(window).load(function( $ ) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Equal Heights Plugin
|
||||
*
|
||||
@@ -134,18 +132,18 @@ jQuery(window).load(function() {
|
||||
* Example 4: jQuery(".cols").equalHeights(null, null,768); Only resize columns above 768px viewport
|
||||
*
|
||||
*/
|
||||
(function(jQuery) {
|
||||
jQuery.fn.equalHeights = function(minHeight, maxHeight, breakPoint) {
|
||||
(function( $ ) {
|
||||
$.fn.equalHeights = function(minHeight, maxHeight, breakPoint) {
|
||||
var items = this;
|
||||
breakPoint = breakPoint || 0;
|
||||
|
||||
// Bind functionality to appropriate events
|
||||
jQuery(window).on('load orientationchange resize equalheights', function() {
|
||||
$(window).on('load orientationchange resize equalheights', function() {
|
||||
tallest = (minHeight) ? minHeight : 0;
|
||||
items.each(function() {
|
||||
jQuery(this).height('auto');
|
||||
if(jQuery(this).outerHeight() > tallest) {
|
||||
tallest = jQuery(this).outerHeight();
|
||||
$(this).height('auto');
|
||||
if($(this).outerHeight() > tallest) {
|
||||
tallest = $(this).outerHeight();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -163,10 +161,10 @@ jQuery(window).load(function() {
|
||||
if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
|
||||
console.log(tallest);
|
||||
return items.each(function() {
|
||||
jQuery(this).height(tallest);
|
||||
$(this).height(tallest);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
||||
Reference in New Issue
Block a user