tutorial2.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Basic Handler | Jcrop Demo</title>
  5. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  6. <script src="../js/jquery.min.js"></script>
  7. <script src="../js/jquery.Jcrop.js"></script>
  8. <script type="text/javascript">
  9. jQuery(function($){
  10. var jcrop_api;
  11. $('#target').Jcrop({
  12. onChange: showCoords,
  13. onSelect: showCoords,
  14. onRelease: clearCoords
  15. },function(){
  16. jcrop_api = this;
  17. });
  18. $('#coords').on('change','input',function(e){
  19. var x1 = $('#x1').val(),
  20. x2 = $('#x2').val(),
  21. y1 = $('#y1').val(),
  22. y2 = $('#y2').val();
  23. jcrop_api.setSelect([x1,y1,x2,y2]);
  24. });
  25. });
  26. // Simple event handler, called from onChange and onSelect
  27. // event handlers, as per the Jcrop invocation above
  28. function showCoords(c)
  29. {
  30. $('#x1').val(c.x);
  31. $('#y1').val(c.y);
  32. $('#x2').val(c.x2);
  33. $('#y2').val(c.y2);
  34. $('#w').val(c.w);
  35. $('#h').val(c.h);
  36. };
  37. function clearCoords()
  38. {
  39. $('#coords input').val('');
  40. };
  41. </script>
  42. <link rel="stylesheet" href="demo_files/main.css" type="text/css" />
  43. <link rel="stylesheet" href="demo_files/demos.css" type="text/css" />
  44. <link rel="stylesheet" href="../css/jquery.Jcrop.css" type="text/css" />
  45. </head>
  46. <body>
  47. <div class="container">
  48. <div class="row">
  49. <div class="span12">
  50. <div class="jc-demo-box">
  51. <div class="page-header">
  52. <ul class="breadcrumb first">
  53. <li><a href="../index.html">Jcrop</a> <span class="divider">/</span></li>
  54. <li><a href="../index.html">Demos</a> <span class="divider">/</span></li>
  55. <li class="active">Basic Handler</li>
  56. </ul>
  57. <h1>Basic Handler</h1>
  58. </div>
  59. <!-- This is the image we're attaching Jcrop to -->
  60. <img src="demo_files/sago.jpg" id="target" alt="[Jcrop Example]" />
  61. <!-- This is the form that our event handler fills -->
  62. <form id="coords"
  63. class="coords"
  64. onsubmit="return false;"
  65. action="http://example.com/post.php">
  66. <div class="inline-labels">
  67. <label>X1 <input type="text" size="4" id="x1" name="x1" /></label>
  68. <label>Y1 <input type="text" size="4" id="y1" name="y1" /></label>
  69. <label>X2 <input type="text" size="4" id="x2" name="x2" /></label>
  70. <label>Y2 <input type="text" size="4" id="y2" name="y2" /></label>
  71. <label>W <input type="text" size="4" id="w" name="w" /></label>
  72. <label>H <input type="text" size="4" id="h" name="h" /></label>
  73. </div>
  74. </form>
  75. <div class="description">
  76. <p>
  77. <b>An example with a basic event handler.</b> Here we've tied
  78. several form values together with a simple event handler invocation.
  79. The result is that the form values are updated in real-time as
  80. the selection is changed using Jcrop's <em>onChange</em> handler.
  81. </p>
  82. <p>
  83. That's how easily Jcrop can be integrated into a traditional web form!
  84. </p>
  85. </div>
  86. <div class="tapmodo-footer">
  87. <a href="http://tapmodo.com" class="tapmodo-logo segment">tapmodo.com</a>
  88. <div class="segment"><b>&copy; 2008-2013 Tapmodo Interactive LLC</b><br />
  89. Jcrop is free software released under <a href="../MIT-LICENSE.txt">MIT License</a>
  90. </div>
  91. </div>
  92. <div class="clearfix"></div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </body>
  98. </html>