Пример #1
0
function fsi_styles()
{
    if (!wpdev_fsi_should_display()) {
        return false;
    }
    $opacity = get_option('fsi_opacity');
    if (empty($opacity) || !is_numeric($opacity) || $opacity > 100) {
        $opacity = 100;
    }
    $fsi_animation = get_option('fsi_animation');
    ?>
<style type="text/css">
html, body { 
    height: 100%;
}
#fsi-full-bg {
    position: fixed; top: 0; left: 0;width:100%; height:100%;
    z-index:-10;
    
}

#fsi-full-bg img { position: fixed; top: 0; left: 0; z-index:-9; opacity:0}
#fsi-full-bg img:first-child{opacity:1;}
.fsi-full-bg-full-width { width: 100%; }
.fsi-full-bg-full-height { height: 100%; }
#fsi-full-bg-overlay { 
    position:fixed; 
    top:0; 
    left:0;
    height:100%; 
    width:100%; 
    z-index:-9;
    background:url(<?php 
    echo FSI_PLUGIN_URL;
    ?>
/images/dot_overlay.png) repeat;
}
<?php 
    /*if(!$fsi_animation)
      echo '#fsi-full-bg img:first-child{opacity:1}';*/
    ?>
</style>
<?php 
}
function fsi_full_screen_images()
{
    $images = get_option('fsi_images');
    if (empty($images)) {
        return;
    }
    global $post;
    if (is_page() && get_post_meta($post->ID, 'fsi_fs_images', true)) {
        $images = array();
        for ($i = 0; $i < WPDS_NUM_ADD_IMAGES; $i++) {
            if (has_fsi_bg_image($post->ID, $i)) {
                $images[] = the_fsi_bg_image_url($post->ID, $i);
            }
        }
    }
    if (get_option('fsi_random')) {
        shuffle($images);
    }
    if (wpdev_fsi_should_display()) {
        ?>
    <div id="fsi-full-bg">
    <?php 
        for ($i = 0; $i < count($images); $i++) {
            if (empty($images[$i])) {
                continue;
            }
            ?>
            <img src="<?php 
            echo $images[$i];
            ?>
" />
    <?php 
        }
        ?>
    </div>
<?php 
        if (get_option('fsi_overlay') == 1) {
            echo '<div id="fsi-full-bg-overlay"></div>';
        }
    }
}
Пример #3
0
function fsi_scripts()
{
    if (!wpdev_fsi_should_display()) {
        return false;
    }
    $opacity = get_option('fsi_opacity');
    if (empty($opacity) || !is_numeric($opacity) || $opacity > 100) {
        $opacity = 100;
    }
    global $post;
    $fsi_animation = get_option('fsi_animation');
    if (is_page() && get_post_meta($post->ID, 'fsi_fs_images', true)) {
        $fsi_animation = get_post_meta($post->ID, 'fsi_fs_images_slideshow', true);
    }
    $animationDelay = get_option('fsi_animation_delay');
    if (empty($animationDelay) || !is_numeric($animationDelay) || $animationDelay < 1) {
        $animationDelay = 4;
    }
    $animationDuration = get_option('fsi_animation_duration');
    if (empty($animationDuration) || !is_numeric($animationDuration) || $animationDuration < 1) {
        $animationDuration = 5;
    }
    ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
    <?php 
    if ($fsi_animation) {
        ?>
        window.fsi_interval = setInterval(fsi_slideshow,<?php 
        echo $animationDelay * 1000;
        ?>
);
   <?php 
    }
    ?>
       function fsi_slideshow(){
            $('#fsi-full-bg img.fsi_active').animate({opacity:0},<?php 
    echo $animationDuration * 100;
    ?>
, function(){
                $(this).removeClass('fsi_active');
            })
            if($('#fsi-full-bg img.fsi_active').next().length>0)
                $('#fsi-full-bg img.fsi_active').next().animate({opacity:<?php 
    echo $opacity / 100;
    ?>
},<?php 
    echo $animationDuration * 100;
    ?>
).addClass('fsi_active');
            else
                $('#fsi-full-bg img:first').animate({opacity:<?php 
    echo $opacity / 100;
    ?>
},<?php 
    echo $animationDuration * 100;
    ?>
).addClass('fsi_active');

        }
	var fsi_theWindow = $(window);
	
        function fsi_resize_images() {
		
            $("#fsi-full-bg img").load(function(){
                var imgWidth = $(this).width();
                var imgHeight = $(this).height();;
                var aspectRatio =  imgWidth/ imgHeight;

                if(imgWidth < fsi_theWindow.width() || imgHeight < fsi_theWindow.height()  ){
                    if(imgWidth < fsi_theWindow.width() ) {

                        $(this).css('left','50%');
                        $(this).css('margin-left','-'+imgWidth/2+'px');

                    }
                    if(imgHeight < fsi_theWindow.height() ) {

                        $(this).css('top','50%');
                        $(this).css('margin-top','-'+imgHeight/2+'px');

                    }
                }else {
                    if ( (fsi_theWindow.width() / fsi_theWindow.height()) < aspectRatio ) {
                        $(this)
                            .removeClass()
                            .addClass('fsi-full-bg-full-height');
                        $(this).css('left','50%');
                        $(this).css('margin-left','-'+$(this).width()/2+'px');
                    } else {
                        $(this)
                            .removeClass()
                            .addClass('fsi-full-bg-full-width');
                        $(this).css('top','50%');
                        $(this).css('margin-top','-'+$(this).height()/2+'px');
                    }
                }
                // if first image is loaded.. start slideshow
                if($('#fsi-full-bg img:first')[0] == $(this)[0] ) {
                    $(this).animate({opacity:<?php 
    echo $opacity / 100;
    ?>
},100).addClass('fsi_active');    
                }
            });
            //fsi_theWindow.resize(resizeBg);
            
            
	}
	fsi_resize_images();
	

});
</script>
<?php 
}