実行結果
設置サンプルのソース
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>Displaying source code with Ajax | 設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/content/lib/jquery/photoShoot/jquery.photoShoot-1.0.js"></script>
<script type="text/javascript">
$(function() {
/* This code is executed after the DOM has been completely loaded */
// Assigning the jQuery object to a variable for speed:
var main = $('#main');
// Setting the width of the photoshoot area to
// 1024 px or the width of the document - whichever is smallest:
main.width(Math.min(1024,$(document).width()));
// Creating an array with four possible backgrounds and their sizes:
var pics = new Array(
{ url:'http://farm4.static.flickr.com/3639/3664935712_94ca67b18b_b.jpg', size:{x:1024,y:576}},
{ url:'http://farm4.static.flickr.com/3220/3664935670_b94968ccbc_b.jpg', size:{x:1024,y:576}},
{ url:'http://farm4.static.flickr.com/3394/3664935528_16fff63afc_b.jpg', size:{x:1024,y:576}}
);
// Choosing a random picture to be passed to the PhotoShoot jQuery plug-in:
var bg = pics[parseInt(Math.random()*3)];
// Creating an options object (try tweeking the variables):
var opts = {
image : bg.url,
onClick : shoot,
opacity : 0.8,
blurLevel : 4
}
// Converting the #main div to a photoShoot stage:
main.photoShoot(opts);
// Adding the album holder to the stage:
$('<div class="album">').html('<div class="slide" />').appendTo(main);
// Our own shoot function (it is passed as onClick to the options array above):
function shoot(position){
// This function is called by the plug-in when the button is pressed
// Setting the overlay's div to white will create the illusion of a camera flash:
main.find('.overlay').css('background-color','white');
// The flash will last for 100 milliseconds (a tenth of the second):
setTimeout(function(){main.find('.overlay').css('background-color','')},100);
// Creating a new shot image:
var newShot = $('<div class="shot">').width(150).height(100);
newShot.append( $('<img src="'+bg.url+'" width="'+(bg.size.x/2)+'" height="'+(bg.size.y/2)+'" />').css('margin',-position.top*0.5+'px 0 0 -'+position.left*0.5+'px') );
// Removing the fourth shot (the count starts from 0):
$('.shot').eq(3).remove();
// Adding the newly created shot to the album div, but moved 160px to the right.
// We start an animation to slide it in view:
newShot.css('margin-right',-160).prependTo('.album .slide').animate({marginRight:0},'slow');
}
});
</script>
<!-- CSS -->
<style type="text/css">
#main{
/* This div is converted to a photoShoot stage by the Photo Shoot plug-in */
margin:0;
width:1024px; height:576px;
position:relative;
overflow:hidden;
}
.shot{
/* These contain a scaled down version of the background image: */
border:3px solid #fcfcfc;
float:right;
position:relative;
margin-left:10px;
overflow:hidden;
/* Adding a CSS3 shadow below the shots: */
-moz-box-shadow:0 0 2px black;
-webkit-box-shadow:0 0 2px black;
box-shadow:0 0 2px black;
}
.shot img{
display:block;
}
.album{
/* This div holds the shots */
bottom:50px; right:20px;
overflow:hidden;
position:absolute;
width:490px; height:110px;
}
.album .slide {
/* The slide div is contained in album */
width:700px; height:110px;
position:relative;
left:-210px;
}
/* カーソル */
.container{
overflow:hidden;
cursor:url("/content/lib/jquery/photoShoot/blank.cur"),default;
position:relative;
}
.container.googleChrome{
cursor: url("/content/lib/jquery/photoShoot/blank_google_chrome.cur"),default;
}
.overlay{
position:absolute;
top:0; left:0;
width:100%; height:100%;
background:black;
}
.viewFinder{
position:absolute;
top:0; left:0;
}
.blur{
position:absolute;
top:0; left:0;
}
</style>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1>設置サンプル</h1>
<p>【参照】<a href='http://tutorialzine.com/2010/02/jquery-photoshoot-plugin/'>jQuery PhotoShoot Plugin</a></p>
<!-- CODE -->
<div id="main"></div>
<!-- / CODE -->
</div>
</body>
</html>