実行結果
設置サンプルのソース
<!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>jQuery plugin : Crop | 設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript" src="/content/lib/jquery/jquery.crop.js"></script>
<script type="text/javascript">
$(function() {
$('#crop').submit(function() {
var t = this;
$(this).trigger('reset'); // fiddle to reset the image for the demo
var img = $('img');
img.crop({ height: t.height.value, width: t.width.value })
return false;
}).bind('reset', function() {
var img = $('img');
var resetImg = document.createElement('img');
resetImg.src = 'http://farm4.static.flickr.com/3141/2973155055_385036c286_o.png';
resetImg.height = '240';
resetImg.width = '320';
resetImg.alt = resetImg.title = "クリスピー・クリーム・ドーナツ";
img[0].parentNode.replaceChild(resetImg, img[0]);
});
});
</script>
<!-- CSS -->
<style type="text/css">
textarea { width:80%;}
fieldset { border:1px solid #ccc; padding:1em; margin:0 0 20px 0; }
legend { color:#ccc; font-size:120%; }
input, textarea { font-size:125%; padding:7px; border:1px solid #999; }
label { font-weight:bold; display:block; margin-top:10px; }
img { margin:5px; }
</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><a href='http://remysharp.com/2007/03/19/a-few-more-jquery-plugins-crop-labelover-and-pluck/'>jQuery plugin: Crop</a> | 設置サンプル</h1>
<!-- CODE -->
<form action="" id="crop">
<fieldset>
<legend>Crop Control</legend>
<input type="submit" name="crop" value="Crop Image" />
<input type="reset" name="reset" value="Reset Image" id="reset" />
<label for="height">Height: </label><input type="text" name="height" value="200" id="height" /> px
<label for="width">Width: </label><input type="text" name="width" value="200" id="width" /> px
</fieldset>
<div class="clear"></div>
</form>
<a href="http://www.flickr.com/photos/22559849@N06/2973155055/" title="クリスピー・クリーム・ドーナツ by php_javascript_room, on Flickr"><img src="http://farm4.static.flickr.com/3141/2973155055_385036c286_o.png" width="320" height="240" alt="クリスピー・クリーム・ドーナツ" /></a>
<!-- / CODE -->
</div>
</body>
</html>