Resizing.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>Plupload: Client-side image resizing</title>
  6. <script src="../loader.js"></script>
  7. <script type="text/javascript">
  8. QUnit.config.reorder = false;
  9. QUnit.config.autostart = false;
  10. QUnit.config.testTimeout = 10000;
  11. FileHash.init({
  12. files: ['files/01.min.js', 'files/02.min.js'],
  13. onready: function() {
  14. QUnit.start();
  15. }
  16. });
  17. o.Env.swf_url = "../../js/flash/Moxie.swf";
  18. o.Env.xap_url = "../../js/silverlight/Moxie.xap";
  19. module("Client-side image resizing");
  20. test("Enable or disable client-side resizing in BeforeUpload", function() {
  21. var up = new plupload.Uploader({
  22. runtimes: 'test',
  23. browse_button: 'qunit-fixture',
  24. url: "Plupload/upload.php",
  25. required_features: true,
  26. resize: {
  27. width: 50,
  28. height: 50
  29. }
  30. });
  31. up.bind('PostInit', function() {
  32. var files = files = FileHash.getRuntimeFiles();
  33. up.addFile(files[0]);
  34. });
  35. up.bind('Error', function() {
  36. start();
  37. ok(false, "Plupload cannot be initialized.");
  38. });
  39. stop();
  40. up.init();
  41. up.bind('FilesAdded', function() {
  42. up.start();
  43. });
  44. up.bind('BeforeUpload', function() {
  45. start();
  46. deepEqual(up.getOption('resize'), {
  47. height: 50,
  48. width: 50,
  49. crop: false,
  50. preserve_headers: true
  51. }, "Check resize options prior to any action.");
  52. up.setOption('resize', {
  53. width: 60,
  54. height: 60,
  55. crop: true
  56. });
  57. deepEqual(up.getOption('resize'), {
  58. height: 60,
  59. width: 60,
  60. crop: true,
  61. preserve_headers: true
  62. }, "Check resize options after they were changed.");
  63. up.setOption('resize', false);
  64. equal(up.getOption('resize'), false,
  65. "Check resize options after they were disabled.");
  66. deepEqual(up.getOption('required_features'), {
  67. select_file: true,
  68. select_multiple: true,
  69. send_binary_string: true,
  70. use_http_method: "POST"
  71. }, "Test what required_features are set.");
  72. });
  73. });
  74. </script>
  75. </head>
  76. <body>
  77. <div id="qunit"></div>
  78. <div id="qunit-fixture" style="position: relative; top: 0 !important; left: 0 !important; width: 100%; height: 9px;"></div>
  79. </body>
  80. </html>