jQuery(document).ready(function($) {
";
_sf_js_init_foundation_code();
echo "
}); //end no conflict wrapper
";
}
add_action('wp_footer', '_sf_js_init_foundation');
endif; //! _sf_js_init_foundation
/**
*Infinite Scroll
* Method from: http://wptheming.com/2012/03/infinite-scroll-to-wordpress-theme/
*/
/* DISABLED DUE TO INFINITE SCROLL INCOMPATIBILITY
//first test to see if we need infinite scroll:
if ( (get_theme_mod( '_sf_inf-scroll' ) == '' ) && (! get_theme_mod( '_sf_masonry' ) == '' ) ) :
if (! function_exists('_sf_scripts_infScroll') ) :
function _sf_scripts_infScroll() {
wp_register_script( 'infinite_scroll', get_template_directory_uri() . '/lib/js/jquery.infinitescroll.min.js', array('jquery'), false, false );
wp_enqueue_script('infinite_scroll');
}
add_action( 'wp_enqueue_scripts', '_sf_scripts_infScroll' );
endif; //! _sf_scripts exists_infScroll
if (! function_exists('_sf_js_init_infScroll_code') ) :
function _sf_js_init_infScroll_code() { ?>
var infinite_scroll = {
loading: {
img: "/images/ajax-loader.gif",
msgText: "",
finishedMsg: ""
},
"nextSelector":"#nav-below .nav-previous a",
"navSelector":"#nav-below",
"itemSelector":"article",
"contentSelector":"#content"
};
jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll );
';
_sf_js_init_infScroll_code();
echo '
';
}
add_action('wp_footer', '_sf_js_init_infScroll', 10);
endif; //! _sf_js_init_infScroll
endif; //we need infscroll
*/
/**
* Masonry
*
* since 1.1.0 using Masonry 3.0.1
* since 1.1.4 using imagesLoaded
*
* @since 1.1.4
*/
//first check if masonry is being used, if so do all the things we need, if not fuck it.
if ( get_theme_mod( '_sf_masonry' ) == '' ) :
if (! function_exists('_sf_scripts_masonry') ) :
function _sf_scripts_masonry() {
//deregister built in jQuery since it is old.
wp_deregister_script('jquery-masonry');
wp_enqueue_script('imagesLoaded', get_template_directory_uri().'/lib/js/imagesloaded.pkgd.min.js', false, null, true);
wp_enqueue_script('jquery-masonry', get_template_directory_uri().'/lib/js/masonry.pkgd.min.js', array('jquery', 'imagesLoaded'), null, true );
}
add_action( 'wp_enqueue_scripts', '_sf_scripts_masonry' );
endif; //! _sf_scripts_masonry exists
if (! function_exists('_sf_js_init_masonry_code') ) :
function _sf_js_init_masonry_code() {
echo "
var container = document.querySelector('#masonry-loop');
var msnry;
// initialize Masonry after all images have loaded
imagesLoaded( container, function() {
msnry = new Masonry( container, {
itemSelector: '.masonry-entry'
});
});
";
}
endif; // if ! _sf_js_init_masonry_code exists
if (! function_exists('_sf_js_init_masonry') ) :
function _sf_js_init_masonry() {
echo "
";
}
add_action('wp_footer', '_sf_js_init_masonry');
endif; //! _sf_js_init_masonry
/**
* Optionally Disable Masonry For Mobile
*
* @since 1.1.4
*/
if ( ! function_exists('_sf_masonry_mobile') ) :
function _sf_masonry_mobile() {
remove_action( 'wp_footer', '_sf_js_init_masonry' );
remove_action( 'wp_enqueue_scripts', '_sf_scripts_masonry' );
}
if ( wp_is_mobile() && get_theme_mod ('_sf_masonry_mobile') == '' ) {
add_action('init', '_sf_masonry_mobile');
}
endif; // ! _sf_masonry_mobile exists
endif; //do we need masonry?
//
/**
* Ajax Menus
* method from: http://wptheming.com/2011/12/ajax-themes/
* For _sf_js_init_ajaxMenus:
* @params (since 1.1.0) (all optional) (all default = true) - $infScroll, $masonry, $backstretch
* If set to false, script will not be reinitialized.
*/
if (! function_exists('_sf_scripts_ajaxMenus') ) :
function _sf_scripts_ajaxMenus() {
if ( get_theme_mod( '_sf_ajax' ) == '' ) :
wp_deregister_script('historyjs');
wp_register_script( 'historyjs', get_template_directory_uri(). '/lib/js/jquery.history.js', array( 'jquery' ), '1.7.1' );
wp_enqueue_script( 'historyjs' );
endif; // get_theme_mod( '_sf_ajax' ) == ''
}
add_action( 'wp_enqueue_scripts', '_sf_scripts_ajaxMenus' );
endif; //! _sf_scripts exists
if (! function_exists('_sf_js_init_ajaxMenus') ) :
function _sf_js_init_ajaxMenus($infScroll = true, $masonry = true, $backstretch = true) {
echo'
';
}
add_action('wp_footer', '_sf_js_init_ajaxMenus');
endif; //! _sf_js_init_ajaxMenus
/**
* Backstretch
*/
//get urls of background images. Doing this first to test if they have a value in the big if statement that is about to happen.
$body_img_url = get_theme_mod('body_bg_img');
$header_img_url = get_theme_mod('header_bg_img');
$content_img_url = get_theme_mod('content_bg_img');
if (
//if we're using full screen background image, and one is set (which btw may be the default one.)
get_theme_mod( 'body_bg_choice' ) == ''
//or we're using a background image for the header and and one is set
|| ! get_theme_mod( 'header_bg_choice' ) == '' && ! $header_img_url == ''
//or we're using a background image for the content area and and one is set
|| ! get_theme_mod( 'content_bg_choice' ) == '' && ! $content_img_url == ''
) :
if (! function_exists('_sf_scripts_backstretch') ) :
function _sf_scripts_backstretch() {
wp_enqueue_script('backstretch', get_template_directory_uri().'/lib/js/jquery.backstretch.min.js');
}
add_action( 'wp_enqueue_scripts', '_sf_scripts_backstretch' );
endif; //! _sf_scripts exists
if (! function_exists('_sf_js_init_backstretch') ) :
function _sf_js_init_backstretch($use = '') {
if ( get_theme_mod('body_bg_img') == '' ) {
$body_img_url = get_template_directory_uri().'/images/bg.jpg';
}
else {
$body_img_url = get_theme_mod('body_bg_img');
}
$header_img_url = get_theme_mod('header_bg_img');
$content_img_url = get_theme_mod('content_bg_img');
//$use = 'reinit' in the ajax menu callback, so we don't get style tags in the middle of that.
if (! $use == 'reinit') {
echo '';
}
}
add_action('wp_footer', '_sf_js_init_backstretch');
endif; //! _sf_js_init_backstretch
endif; //the big one.
if (! function_exists('_sf_style') ) :
function _sf_style() {
wp_enqueue_style( '_sf-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', '_sf_style' );
endif; //! _sf_style exists
endif; // ! is_admin
/**
* Other scripts
*/
//extra description/ insturctions in themes.php
if (! function_exists('_sf_extraDesc') ):
function _sf_extraDesc($hook) {
if( 'themes.php' != $hook )
return;
wp_enqueue_script( 'extra-desc', get_template_directory_uri().'/lib/js/extra-desc.js' );
}
add_action( 'admin_enqueue_scripts', '_sf_extraDesc' );
endif; //! _sf_extraDesc exists