coords.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Dimensions | 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 src="/Jcrop/js/jquery.color.js"></script>
  8. <script type="text/javascript">
  9. var cb, filter;
  10. jQuery(function($){
  11. // Create a new Selection object extended from Selection
  12. var CoordsSel = function(){ };
  13. // Set the custom selection's prototype object to be an instance
  14. // of the built-in Selection object
  15. CoordsSel.prototype = new $.Jcrop.component.Selection;
  16. // Then we can continue extending it
  17. $.extend(CoordsSel.prototype,{
  18. attach: function(){
  19. // Prepend an element to Selection.element (selection container)
  20. this.coords = $('<div> x </div>').addClass('jcrop-coords');
  21. this.element.prepend(this.coords);
  22. },
  23. redraw: function(b){
  24. // Call original redraw() method first, with arguments
  25. $.Jcrop.component.Selection.prototype.redraw.call(this,b);
  26. // Update coordinates
  27. this.coords.html(this.last.w+' &times '+this.last.h);
  28. return this;
  29. }
  30. });
  31. // Now set it as the component that is used for new selections
  32. $('#target').Jcrop({
  33. selectionComponent: CoordsSel,
  34. bgColor: 'rgb(145,176,241)',
  35. bgOpacity: 0.5
  36. },function(){
  37. this.container.addClass('jcrop-hl-active');
  38. interface_load(this);
  39. });
  40. function interface_load(obj){
  41. cb = obj;
  42. cb.newSelection().update($.Jcrop.wrapFromXywh([ 147, 55, 456, 390 ])).refresh();
  43. //cb.ui.selection.removeFilter(cb.filter.shader);
  44. cb.ui.selection.refresh();
  45. function random_coords() {
  46. return [
  47. Math.random()*300,
  48. Math.random()*200,
  49. (Math.random()*540)+50,
  50. (Math.random()*340)+60
  51. ];
  52. }
  53. // Animate button event
  54. $(document.body).on('click','[data-action]',function(e){
  55. var $targ = $(e.target);
  56. var action = $targ.data('action');
  57. switch(action){
  58. case 'random-move':
  59. cb.ui.selection.animateTo(random_coords());
  60. break;
  61. }
  62. cb.ui.selection.refresh();
  63. }).on('selectstart',function(e){
  64. e.preventDefault();
  65. }).on('click','a[data-action]',function(e){
  66. e.preventDefault();
  67. });
  68. }
  69. $.Jcrop.component.CoordsSel = CoordsSel;
  70. });
  71. </script>
  72. <link rel="stylesheet" href="demo_files/main.css">
  73. <link rel="stylesheet" href="demo_files/demos.css">
  74. <link rel="stylesheet" href="../css/Jcrop.css">
  75. <style type="text/css">
  76. .jcrop-border {
  77. background: rgba(0,0,0,0.8);
  78. }
  79. .jcrop-handle {
  80. border-color: rgba(0,0,0,0.8);
  81. }
  82. .jcrop-coords {
  83. display: none;
  84. position: absolute;
  85. bottom: -24px;
  86. right: 7px;
  87. color: rgba(255, 255, 255, 0.8);
  88. padding: 1px 4px 0;
  89. font-size: 10px;
  90. white-space: nowrap;
  91. font-family: "Lucida Console", Monaco, monospace;
  92. background: rgba(0, 0, 0, 0.8);
  93. -webkit-border-radius: 4px;
  94. -moz-border-radius: 4px;
  95. border-radius: 4px;
  96. }
  97. .jcrop-current .jcrop-coords {
  98. display: block;
  99. }
  100. </style>
  101. </head>
  102. <body>
  103. <div class="navbar navbar-fixed-top">
  104. <div class="navbar-inner">
  105. <div class="container">
  106. <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>
  107. <div class="nav-collapse collapse">
  108. <ul class="nav">
  109. <li class="active"><a href="./basic.html">Demos</a>
  110. </li>
  111. <li><a href="http://beta.jcrop.org/doc/">Docs</a>
  112. </li>
  113. <li><a href="http://beta.jcrop.org/contact/">Contact</a>
  114. </li>
  115. </ul>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="container">
  121. <div class="row">
  122. <div class="span12">
  123. <div class="jc-demo-box">
  124. <div class="page-header">
  125. <h1>Dimensions</h1>
  126. </div>
  127. <div class="demo-nav menu-box">
  128. <h3>Jcrop Demos</h3>
  129. <ul class="links">
  130. <li><a href="basic.html">Hello World</a></li>
  131. <li><a href="thumbnail.html">Thumbnail Preview</a></li>
  132. <li><a href="panel.html">Feature Panel</a></li>
  133. <li><b>Dimensions</b></li>
  134. <li><a href="circle.html">Circles</a></li>
  135. </ul>
  136. </div>
  137. <div class="page-interface"><img src="http://jcrop-cdn.tapmodo.com/assets/images/sierra-750.jpg" id="target">
  138. <div class="btn-toolbar"><a href="#" data-action="random-move" id="moveselection" class="btn btn-small">Move</a></div>
  139. </div>
  140. <div class="tapmodo-footer"><a href="http://tapmodo.com" class="tapmodo-logo segment">tapmodo.com</a>
  141. <div class="segment"><b>&copy; 2008-2013 Tapmodo Interactive LLC</b>
  142. <div>Jcrop is free software released under <a href="../MIT-LICENSE.txt">MIT License</a></div>
  143. </div>
  144. </div>
  145. <div class="clearfix"></div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </body>
  151. </html>