AMD.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>Plupload: Test AMD</title>
  6. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  7. <script src="//code.jquery.com/qunit/qunit-1.14.0.js"></script>
  8. <script src="../js/testrunner/reporter.js"></script>
  9. <script src="../js/require.js"></script>
  10. <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css">
  11. <script type="text/javascript">
  12. var matches = document.location.search.match(/src=(min|dev)/);
  13. var mode = matches ? matches[1] : 'min';
  14. requirejs.config({
  15. "baseUrl": "../../js/",
  16. "paths": {
  17. "moxie": "moxie",
  18. "plupload": "plupload." + mode
  19. }
  20. });
  21. module("AMD", {
  22. setup: function() {
  23. $('#qunit-fixture').html('<div id="uploader" />');
  24. this.options = {
  25. browse_button: 'uploader',
  26. drop_element: 'uploader',
  27. container: 'qunit-fixture',
  28. url: "Plupload/upload.php"
  29. };
  30. this.up = null;
  31. },
  32. teardown: function() {
  33. if (this.up) {
  34. this.up.destroy();
  35. }
  36. }
  37. });
  38. test("test AMD loader", function() {
  39. var self = this;
  40. QUnit.stop();
  41. require(['moxie', 'plupload'], function(moxie, plupload) {
  42. self.up = new plupload.Uploader(self.options);
  43. self.up.bind('Init', function() {
  44. QUnit.start();
  45. ok(true, "Plupload loaded and initialised.");
  46. ok(/^moxie_event_target_/.test(moxie.runtime.Runtime.getGlobalEventTarget()),
  47. "Global event target has been redifined.");
  48. });
  49. self.up.init();
  50. });
  51. });
  52. </script>
  53. </head>
  54. <body>
  55. <div id="qunit"></div>
  56. <div id="qunit-fixture" style="position: relative; top: 0 !important; left: 0 !important; width: 100%; height: 9px;"></div>
  57. </body>
  58. </html>