什么放在jQuery(文档).ready(function()

时间:2012-10-19 02:06:20

标签: javascript jquery html css wordpress

一直想尝试在WordPress中运行javascript库,但我不太清楚要在.ready(函数)中放入什么才能运行库。 jQuery函数的原始页面位于:http://manos.malihu.gr/simple-jquery-fullscreen-image-gallery/2

我认为我需要运行一些将运行整个javascript文件的函数,但我不太确定该函数可能是什么。很抱歉这么新,但非常感谢任何帮助!

function malihu_gallery() {
if (!is_admin()) {

    // Enqueue Malihu Gallery JavaScript
    wp_register_script('malihu-jquery-image-gallery', get_template_directory_uri(). '/js/malihu-jquery-image-gallery.js', array('jquery'), 1.0, true );
    wp_enqueue_script('malihu-jquery-image-gallery'); 

    // Enqueue Malihu Gallery Stylesheet
    wp_register_style( 'malihu-style', get_template_directory_uri() . '/CSS/malihu_gallery.css', 'all' );
    wp_enqueue_style('malihu-style' );

    function gallery_settings () { ?>
    <script type="text/javascript">
        jQuery(document).ready(function() {
            // What do I put in here?
        });
    </script><?php
    }
  }
}

add_action('init', 'malihu_gallery');

1 个答案:

答案 0 :(得分:0)

我猜,根据实际代码的有限视图,应该在该空间中设置/修改这组变量:

//config
//set default images view mode
$defaultViewMode="full"; //full, normal, original
$tsMargin=30; //first and last thumbnail margin (for better cursor interaction) 
$scrollEasing=600; //scroll easing amount (0 for no easing) 
$scrollEasingType="easeOutCirc"; //scroll easing type 
$thumbnailsContainerOpacity=0.8; //thumbnails area default opacity
$thumbnailsContainerMouseOutOpacity=0; //thumbnails area opacity on mouse out
$thumbnailsOpacity=0.6; //thumbnails default opacity
$nextPrevBtnsInitState="show"; //next/previous image buttons initial state ("hide" or "show")
$keyboardNavigation="on"; //enable/disable keyboard navigation ("on" or "off")

当然,这假设这些变量尚未在'/js/malihu-jquery-image-gallery.js'文件中设置。