panel.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Feature Panel | 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="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  8. <script src="http://jcrop-dev.tapmodo.com/Jcrop/js/jquery.color.js"></script>
  9. <script type="text/javascript">
  10. var cb, filter;
  11. jQuery(function($){
  12. var $targ = $('#target');
  13. var $easing = $('#easing');
  14. $('#target').Jcrop({
  15. animEasing: 'easeOutQuart',
  16. bgOpacity: .35,
  17. linked: false,
  18. multi: true
  19. },function(){
  20. this.container.addClass('jcrop-dark jcrop-hl-active');
  21. interface_load(this);
  22. });
  23. function interface_load(obj){
  24. cb = obj;
  25. cb.newSelection();
  26. cb.setSelect([ 147, 55, 456, 390 ]);
  27. cb.refresh();
  28. // Hack a "special" selection...
  29. var logosel = cb.newSelection().update($.Jcrop.wrapFromXywh([73,268,400,100]));
  30. $.extend(logosel,{
  31. special: true, // custom value used in our local script here
  32. bgColor: '#999',
  33. bgOpacity: 0.8,
  34. canResize: false,
  35. canDelete: false
  36. });
  37. logosel.element.prepend('<img src="http://tapmodo.com/img/tapmodo-official.png" style="position:absolute;background-color:white;width:100%;height:100%;" />');
  38. logosel.aspectRatio = 400/100;
  39. logosel.refresh();
  40. cb.ui.multi[1].focus();
  41. // Select an interesting easing function
  42. $easing[0].selectedIndex = 24;
  43. // Set up the easing function select element event
  44. cb.opt.animEasing = $easing.change(function(e){
  45. var $targ = $(e.target);
  46. cb.opt.animEasing = $targ.val();
  47. e.preventDefault();
  48. cb.ui.selection.animateTo([Math.random()*300,Math.random()*200,(Math.random()*540)+50,(Math.random()*340)+60]);
  49. }).val();
  50. $('#filter-selections input').attr('checked',false);
  51. $('#page-interface').on('startselect',function(e){
  52. e.preventDefault();
  53. });
  54. /**
  55. *
  56. */
  57. cb.container.on('cropfocus cropblur cropstart cropend',function(e){
  58. var sel = $(e.target).data('selection');
  59. switch(e.type){
  60. case 'cropfocus':
  61. $('#can_size')[0].checked = sel.canResize?true:false;
  62. $('#can_delete')[0].checked = sel.canDelete?true:false;
  63. $('#can_drag')[0].checked = sel.canDrag?true:false;
  64. $('#set_minsize')[0].checked = (sel.minSize[0]>8)?true:false;
  65. $('#set_maxsize')[0].checked = (sel.maxSize[0])?true:false;
  66. $('#set_bounds')[0].checked = (sel.edge.n)?true:false;
  67. $('#is_linked')[0].disabled = sel.special?true:false;
  68. $('#is_linked')[0].checked = sel.linked?true:false;
  69. $('#shading-tools a')[0].disabled = sel.special?true:false;
  70. $('#shading-tools a')[sel.special?'addClass':'removeClass']('disabled');
  71. $('#ar-links').find('.active').removeClass('active');
  72. if (sel.aspectRatio) {
  73. if (!$('#ar-links').find('[data-value="'+sel.aspectRatio+'"]').addClass('active').length)
  74. $('#ar-lock').addClass('active');
  75. } else $('#ar-free').addClass('active');
  76. }
  77. });
  78. $('#aspect_ratio').on('change',function(e){
  79. var s = cb.ui.selection;
  80. var b = s.get();
  81. s.aspectRatio = e.target.checked? b.w/b.h : 0;
  82. s.refresh();
  83. });
  84. $('#is_linked').on('change',function(e){
  85. cb.ui.selection.linked = e.target.checked;
  86. });
  87. $('#selection-options').on('change','[data-filter-toggle]',function(e){
  88. var tog = $(e.target).data('filter-toggle');
  89. var o = { };
  90. o[tog] = e.target.checked? true: false;
  91. cb.setOptions(o);
  92. });
  93. var cycle_colors = [
  94. 'red',
  95. 'blue',
  96. 'gray',
  97. 'yellow',
  98. 'orange',
  99. 'green',
  100. 'white'
  101. ];
  102. function random_coords() {
  103. return [
  104. Math.random()*300,
  105. Math.random()*200,
  106. (Math.random()*540)+50,
  107. (Math.random()*340)+60
  108. ];
  109. }
  110. $('#can_drag,#can_size,#can_delete,#enablesel,#multisel,#anim_mode').attr('checked','checked');
  111. $('#is_linked,#aspect_ratio').attr('checked',false);
  112. function anim_mode(){
  113. return document.getElementById('anim_mode').checked;
  114. }
  115. // A simple function to cleanup multiple spawned selections
  116. function run_cleanup(){
  117. var m = cb.ui.multi, s = cb.ui.selection;
  118. for(var i=0;i<m.length;i++)
  119. if (s !== m[i]) m[i].remove();
  120. cb.ui.multi = [ s ];
  121. s.center();
  122. s.focus();
  123. }
  124. // Animate button event
  125. $(document.body).on('click','[data-action]',function(e){
  126. var $targ = $(e.target);
  127. var action = $targ.data('action');
  128. switch(action){
  129. case 'set-maxsize':
  130. cb.setOptions({ maxSize: e.target.checked? [400,350]: [0,0] });
  131. break;
  132. case 'set-minsize':
  133. cb.setOptions({ minSize: e.target.checked? [60,60]: [8,8] });
  134. break;
  135. case 'set-bounds':
  136. if (e.target.checked){
  137. cb.setOptions({ edge: {
  138. n: 15,
  139. e: -20,
  140. s: -40,
  141. w: 28
  142. }});
  143. }
  144. else {
  145. cb.setOptions({ edge: {
  146. n: 0,
  147. e: 0,
  148. s: 0,
  149. w: 0
  150. }});
  151. }
  152. break;
  153. case 'set-image':
  154. $targ.parent().find('.active').removeClass('active');
  155. $targ.addClass('active');
  156. $('#target').attr('src','//jcrop-cdn.tapmodo.com/assets/images/'+$targ.data('image')+'-750.jpg');
  157. break;
  158. case 'set-ar':
  159. var value = $targ.data('value');
  160. $targ.parent().find('.active').removeClass('active');
  161. if (value == 'lock'){
  162. var b = cb.ui.selection.get();
  163. value = b.w / b.h;
  164. }
  165. $targ.addClass('active');
  166. cb.setOptions({ aspectRatio: value });
  167. break;
  168. case 'set-selmode':
  169. $targ.parent().find('.active').removeClass('active');
  170. $targ.addClass('active');
  171. switch($targ.data('mode')){
  172. case 'none':
  173. cb.container.addClass('jcrop-nodrag');
  174. cb.setOptions({ allowSelect: false });
  175. break;
  176. case 'single':
  177. cb.container.removeClass('jcrop-nodrag');
  178. cb.setOptions({ allowSelect: true, multi: false });
  179. break;
  180. case 'multi':
  181. cb.container.removeClass('jcrop-nodrag');
  182. cb.setOptions({ allowSelect: true, multi: true });
  183. break;
  184. }
  185. break;
  186. case 'enable-selections':
  187. cb.ui.stage.dragger.active = e.target.checked;
  188. break;
  189. case 'enable-multi':
  190. cb.ui.stage.dragger.multi = e.target.checked;
  191. break;
  192. case 'color-cycle':
  193. var cc = cycle_colors.shift();
  194. cb.setOptions({ bgColor: cc });
  195. cycle_colors.push(cc);
  196. break;
  197. case 'set-opacity':
  198. $targ.parent().find('.active').removeClass('active');
  199. $targ.addClass('active');
  200. cb.setOptions({ bgOpacity: $targ.data('opacity'), bgColor: 'black' });
  201. break;
  202. case 'cleanup-all':
  203. run_cleanup();
  204. break;
  205. case 'random-move':
  206. cb[anim_mode()?'animateTo':'setSelect'](random_coords());
  207. break;
  208. }
  209. }).on('keydown',function(e){
  210. if (e.keyCode == 8) e.preventDefault();
  211. }).on('selectstart',function(e){
  212. e.preventDefault();
  213. }).on('click','a[data-action]',function(e){
  214. e.preventDefault();
  215. });
  216. }
  217. });
  218. </script>
  219. <link rel="stylesheet" href="demo_files/main.css">
  220. <link rel="stylesheet" href="demo_files/demos.css">
  221. <link rel="stylesheet" href="../css/Jcrop.css">
  222. </head>
  223. <body>
  224. <div class="navbar navbar-fixed-top">
  225. <div class="navbar-inner">
  226. <div class="container">
  227. <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>
  228. <div class="nav-collapse collapse">
  229. <ul class="nav">
  230. <li class="active"><a href="./basic.html">Demos</a>
  231. </li>
  232. <li><a href="http://beta.jcrop.org/doc/">Docs</a>
  233. </li>
  234. <li><a href="http://beta.jcrop.org/contact/">Contact</a>
  235. </li>
  236. </ul>
  237. </div>
  238. </div>
  239. </div>
  240. </div>
  241. <div class="container">
  242. <div class="row">
  243. <div class="span12">
  244. <div class="jc-demo-box">
  245. <div class="page-header">
  246. <h1>Feature Panel</h1>
  247. </div>
  248. <div class="demo-nav menu-box">
  249. <h3>Jcrop Demos</h3>
  250. <ul class="links">
  251. <li><a href="basic.html">Hello World</a></li>
  252. <li><a href="thumbnail.html">Thumbnail Preview</a></li>
  253. <li><b>Feature Panel</b></li>
  254. <li><a href="coords.html">Dimensions</a></li>
  255. <li><a href="circle.html">Circles</a></li>
  256. </ul>
  257. </div>
  258. <div class="page-interface"><img src="http://jcrop-cdn.tapmodo.com/assets/images/sierra2-750.jpg" id="target">
  259. <div class="row-fluid">
  260. <div class="span4">
  261. <h5>Selection Properties</h5>
  262. <div id="selection-options">
  263. <label class="checkbox">
  264. <input type="checkbox" data-filter-toggle="canDrag" id="can_drag">Draggable
  265. </label>
  266. <label class="checkbox">
  267. <input type="checkbox" data-filter-toggle="canResize" id="can_size">Resizable
  268. </label>
  269. <label class="checkbox">
  270. <input type="checkbox" data-filter-toggle="canDelete" id="can_delete">Deletable
  271. </label>
  272. </div>
  273. <label class="checkbox">
  274. <input type="checkbox" data-action="set-bounds" id="set_bounds">Enable boundary
  275. </label>
  276. <label class="checkbox">
  277. <input type="checkbox" data-action="set-minsize" id="set_minsize">Minimum Size
  278. </label>
  279. <label class="checkbox">
  280. <input type="checkbox" data-action="set-maxsize" id="set_maxsize">Maximum Size
  281. </label>
  282. </div>
  283. <div class="span4">
  284. <h5>Aspect Ratio</h5>
  285. <div class="btn-toolbar"><span id="ar-links" class="btn-group"><a href="#" data-action="set-ar" data-value="0" id="ar-free" class="btn active btn-small">Free</a><a href="#" data-action="set-ar" data-value="lock" id="ar-lock" class="btn btn-small">Lock</a><a href="#" data-action="set-ar" data-value="1.4" class="btn btn-small">Wide</a><a href="#" data-action="set-ar" data-value=".8" class="btn btn-small">Tall</a></span></div>
  286. <h5>Shading</h5>
  287. <div id="shading-tools" class="btn-toolbar"><a href="#" data-action="color-cycle" class="btn btn-small">Color</a><span class="btn-group"><a href="#" data-action="set-opacity" data-opacity=".35" class="btn active btn-small">Light</a><a href="#" data-action="set-opacity" data-opacity=".55" class="btn btn-small">Medium</a><a href="#" data-action="set-opacity" data-opacity=".75" class="btn btn-small">Dark</a></span></div>
  288. <h5>Animation</h5>
  289. <label class="checkbox">
  290. <input type="checkbox" id="anim_mode">Enable Animation
  291. </label>
  292. <select data-action="update-easing" id="easing" class="select">
  293. <option>linear</option>
  294. <option>swing</option>
  295. <option>easeInOutQuad</option>
  296. <option>easeInQuad</option>
  297. <option>easeOutQuad</option>
  298. <option>easeInOutExpo</option>
  299. <option>easeInExpo</option>
  300. <option>easeOutExpo</option>
  301. <option>easeInOutSine</option>
  302. <option>easeInSine</option>
  303. <option>easeOutSine</option>
  304. <option>easeOutBounce</option>
  305. <option>easeInOutCirc</option>
  306. <option>easeInCirc</option>
  307. <option>easeOutCirc</option>
  308. <option>easeInOutCubic</option>
  309. <option>easeInCubic</option>
  310. <option>easeOutCubic</option>
  311. <option>easeOutElastic</option>
  312. <option>easeInOutBack</option>
  313. <option>easeInBack</option>
  314. <option>easeOutBack</option>
  315. <option>easeInOutQuart</option>
  316. <option>easeInQuart</option>
  317. <option>easeOutQuart</option>
  318. <option>easeInOutQuint</option>
  319. <option>easeInQuint</option>
  320. <option>easeOutQuint</option>
  321. </select>
  322. </div>
  323. <div class="span4">
  324. <h5>Current Selection</h5>
  325. <label class="checkbox">
  326. <input type="checkbox" data-filter-toggle="ratio" id="is_linked">Linked Selection
  327. </label>
  328. <div class="btn-toolbar"><a href="#" data-action="random-move" id="moveselection" class="btn btn-small">Move</a><a href="#" data-action="cleanup-all" class="btn btn-small">Cleanup</a></div>
  329. <h5>New Selections</h5>
  330. <div class="btn-toolbar"><span class="btn-group"><a href="#" data-action="set-selmode" data-mode="none" class="btn btn-small">None</a><a href="#" data-action="set-selmode" data-mode="single" class="btn btn-small">Single</a><a href="#" data-action="set-selmode" data-mode="multi" class="btn active btn-small">Multi</a></span></div>
  331. <h5>Test Image</h5>
  332. <div class="btn-toolbar"><span class="btn-group"><a href="#" data-action="set-image" data-image="sierra" class="btn btn-small">Sierra1</a><a href="#" data-action="set-image" data-image="sierra2" class="btn active btn-small">Sierra2</a><a href="#" data-action="set-image" data-image="market" class="btn btn-small">Market</a></span></div>
  333. </div>
  334. </div>
  335. </div>
  336. <div class="tapmodo-footer"><a href="http://tapmodo.com" class="tapmodo-logo segment">tapmodo.com</a>
  337. <div class="segment"><b>&copy; 2008-2013 Tapmodo Interactive LLC</b>
  338. <div>Jcrop is free software released under <a href="../MIT-LICENSE.txt">MIT License</a></div>
  339. </div>
  340. </div>
  341. <div class="clearfix"></div>
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. </body>
  347. </html>