lib_photosresize.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (C) 2009-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  2. //
  3. // This program is free software; you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation; either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. // or see https://www.gnu.org/
  16. //
  17. // \file htdocs/lib/lib_photoresize.js
  18. // \brief File that include javascript functions for croping feature
  19. //
  20. /* Enable jcrop plugin onto id cropbox */
  21. jQuery(function() {
  22. jQuery('#cropbox').Jcrop({
  23. onSelect: updateCoords,
  24. onChange: updateCoords
  25. });
  26. });
  27. /* Update fields that store new size */
  28. function updateCoords(c)
  29. {
  30. //alert(parseInt(jQuery("#ratioforcrop").val()));
  31. ratio=1;
  32. if (parseInt(jQuery("#ratioforcrop").val()) > 0) ratio = parseInt(jQuery("#ratioforcrop").val());
  33. //console.log(ratio);
  34. jQuery('#x').val(Math.ceil(c.x * ratio));
  35. jQuery('#y').val(Math.ceil(c.y * ratio));
  36. jQuery('#x2').val(Math.ceil(c.x2 * ratio));
  37. jQuery('#y2').val(Math.ceil(c.y2 * ratio));
  38. jQuery('#w').val(Math.ceil(c.w * ratio));
  39. jQuery('#h').val(Math.ceil(c.h * ratio));
  40. };