thumbnail.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Thumbnail Preview | Jcrop Demos</title>
  5. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  6. <script src="../js/Jcrop.js"></script>
  7. <script type="text/javascript">
  8. jQuery(function($){
  9. // Create a scope-wide variable to hold the Thumbnailer instance
  10. var thumbnail;
  11. // Instantiate Jcrop
  12. $('#target').Jcrop({
  13. aspectRatio: 1,
  14. setSelect: [ 175, 100, 400, 300 ]
  15. },function(){
  16. var jcrop_api = this;
  17. thumbnail = new $.Jcrop.component.Thumbnailer(jcrop_api,{ width: 130, height: 130 });
  18. });
  19. // Wire up the auto-hide checkbox/toggle
  20. $('#autohide').attr('checked',false).on('change',function(e){
  21. var chk = this.checked;
  22. if (thumbnail) {
  23. thumbnail.autoHide = chk? true: false;
  24. thumbnail[chk?'hide':'show']();
  25. }
  26. });
  27. });
  28. </script>
  29. <link rel="stylesheet" href="demo_files/main.css">
  30. <link rel="stylesheet" href="demo_files/demos.css">
  31. <link rel="stylesheet" href="../css/Jcrop.css">
  32. <style>
  33. .jcrop-thumb {
  34. top: -25px;
  35. right: 20px;
  36. border: 1px black solid;
  37. }
  38. #text-inputs { margin: 10px 8px 0; }
  39. .input-group { margin-right: 1.5em; }
  40. .nav-box { width: 748px; padding: 0 !important; margin: 4px 0; background-color: #f8f8f7; }
  41. </style>
  42. </head>
  43. <body>
  44. <div class="navbar navbar-fixed-top">
  45. <div class="navbar-inner">
  46. <div class="container">
  47. <button type="button" data-toggle="collapse" data-target="nav-collapse" class="btn btn-navbar"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a href="../" class="brand">Jcrop</a>
  48. <div class="nav-collapse collapse">
  49. <ul class="nav">
  50. <li class="active"><a href="./basic.html">Demos</a>
  51. </li>
  52. <li><a href="http://beta.jcrop.org/doc/">Docs</a>
  53. </li>
  54. <li><a href="http://beta.jcrop.org/contact/">Contact</a>
  55. </li>
  56. </ul>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="container">
  62. <div class="row">
  63. <div class="span12">
  64. <div class="jc-demo-box">
  65. <div class="page-header">
  66. <h1>Thumbnail Preview</h1>
  67. </div>
  68. <div class="demo-nav menu-box">
  69. <h3>Jcrop Demos</h3>
  70. <ul class="links">
  71. <li><a href="basic.html">Hello World</a></li>
  72. <li><b>Thumbnail Preview</b></li>
  73. <li><a href="panel.html">Feature Panel</a></li>
  74. <li><a href="coords.html">Dimensions</a></li>
  75. <li><a href="circle.html">Circles</a></li>
  76. </ul>
  77. </div>
  78. <div id="interface" class="page-interface"><img src="http://jcrop-dist.tapmodo.com/assets/images/sierra2-750.jpg" crossOrigin="anonymous" id="target">
  79. <div style="margin-top:0.7em">
  80. <label class="checkbox">
  81. <input type="checkbox" id="autohide"><b>Auto-hide Thumbnail Preview</b>
  82. </label>
  83. </div>
  84. </div>
  85. <h3>Built-in Preview Support</h3><p><strong>Thumbnail previews just got much easier!</strong> Used to be, if you wanted to
  86. include a dynamic preview with Jcrop, you had to write client code.
  87. A number of people had difficulty adapting that code to their needs.
  88. No more! Now just attach a Thumbnailer object. Pass in the Jcrop instance,
  89. desired width, and height, and you&#39;re done.</p>
  90. <h5>Invocation Code (for this demo)</h5>
  91. <pre><code>$(&#39;#target&#39;).Jcrop({
  92. aspectRatio: 1,
  93. setSelect: [ 175, 100, 400, 300 ]
  94. },function(){
  95. var jcrop_api = this;
  96. new $.Jcrop.component.Thumbnailer(jcrop_api,{ width: 130, height: 130 });
  97. });</code></pre>
  98. <p>The constructor takes a reference to the Jcrop instance, and allows
  99. passage of various options such as initial width and height.</p>
  100. <h5>Customize Position and Styling with CSS</h5>
  101. <pre><code>.jcrop-thumb {
  102. top: -25px;
  103. right: 20px;
  104. border: 1px black solid;
  105. }</code></pre>
  106. <p>The absolutely-positioned, sized thumbnail is appended to the Jcrop
  107. instance container automatically. It can then be positioned relatively
  108. to the container by using top/left/bottom/right CSS values. Styling
  109. such as a border or a box shadow can be added if desired.</p>
  110. <h3>Additional Features</h3>
  111. <ul><li>Can be locked to an individual Selection object.</li><li>Can be resized using <code>resize(w,h)</code> method.</li></ul>
  112. <div class="tapmodo-footer"><a href="http://tapmodo.com" class="tapmodo-logo segment">tapmodo.com</a>
  113. <div class="segment"><b>&copy; 2008-2013 Tapmodo Interactive LLC</b>
  114. <div>Jcrop is free software released under <a href="../MIT-LICENSE.txt">MIT License</a></div>
  115. </div>
  116. </div>
  117. <div class="clearfix"></div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </body>
  123. </html>