cut.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php defined('InShopNC') or exit('Access Invalid!');?>
  2. <div class="eject_con">
  3. <div id="warning"></div>
  4. <form action="index.php?act=cut&op=pic_cut" id="form_cut" method="post">
  5. <input type="hidden" name="form_submit" value="ok" />
  6. <input type="hidden" id="x" name="x" value="<?php echo $_GET['x'];?>" />
  7. <input type="hidden" id="x1" name="x1" />
  8. <input type="hidden" id="y1" name="y1" />
  9. <input type="hidden" id="x2" name="x2" />
  10. <input type="hidden" id="y2" name="y2" />
  11. <input type="hidden" id="w" name="w" />
  12. <input type="hidden" id="h" name="h" />
  13. <input type="hidden" id="url" name="url" value="<?php echo $_GET['url'];?>" />
  14. <input type="hidden" id="filename" name="filename" value="<?php echo $_GET['filename'];?>" />
  15. <div class="pic-cut-<?php echo $_GET['x'];?>">
  16. <div class="work-title"><?php echo $lang['cut_working_area'];?></div>
  17. <div class="work-layer">
  18. <p><img id="nccropbox" src="<?php echo $_GET['url'];?>"/></p>
  19. </div>
  20. <div class="thumb-title"><?php echo $lang['cut_preview'];?></div>
  21. <div class="thumb-layer">
  22. <p><img id="preview" src="<?php echo $_GET['url'];?>"/></p>
  23. </div>
  24. <div class="cut-help">
  25. <h4><?php echo $lang['cut_help'];?></h4>
  26. <p><?php echo $lang['cut_help_tips'];?></p>
  27. </div>
  28. <div class="bottom">
  29. <a class="submit-btn" nctype="submit-btn" href="Javascript: void(0)"><?php echo $lang['cut_submit'];?></a>
  30. </div>
  31. </div>
  32. </form>
  33. </div>
  34. <script type="text/javascript">
  35. function showPreview(coords)
  36. {
  37. if (parseInt(coords.w) > 0){
  38. var rx = <?php echo $_GET['x'];?> / coords.w;
  39. var ry = <?php echo $_GET['y'];?> / coords.h;
  40. $('#preview').css({
  41. width: Math.round(rx * <?php echo $output['width'];?>) + 'px',
  42. height: Math.round(ry * <?php echo $output['height'];?>) + 'px',
  43. marginLeft: '-' + Math.round(rx * coords.x) + 'px',
  44. marginTop: '-' + Math.round(ry * coords.y) + 'px'
  45. });
  46. }
  47. $('#x1').val(coords.x);
  48. $('#y1').val(coords.y);
  49. $('#x2').val(coords.x2);
  50. $('#y2').val(coords.y2);
  51. $('#w').val(coords.w);
  52. $('#h').val(coords.h);
  53. }
  54. $(function(){
  55. $('.dialog_head').css('margin-top','0px');
  56. $('.page').css('padding-top','0px');
  57. $('.dialog_close_button').remove();
  58. $('#nccropbox').Jcrop({
  59. aspectRatio:1,
  60. setSelect: [ 0, 0, <?php echo $_GET['x'];?>, <?php echo $_GET['y'];?> ],
  61. minSize:[50, 50],
  62. allowSelect:0,
  63. onChange: showPreview,
  64. onSelect: showPreview
  65. });
  66. $('a[nctype="submit-btn"]').click(function(){
  67. var x1 = $('#x1').val();
  68. var y1 = $('#y1').val();
  69. var x2 = $('#x2').val();
  70. var y2 = $('#y2').val();
  71. var w = $('#w').val();
  72. var h = $('#h').val();
  73. if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){
  74. alert("You must make a selection first");
  75. return false;
  76. }
  77. var d=$('#form_cut').serialize();
  78. $.post('index.php?act=cut&op=pic_cut',d,function(data){
  79. call_back(data);
  80. DialogManager.close('cutpic');
  81. });
  82. });
  83. });
  84. </script>