JSONP.js 756 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * JSONP.js
  3. *
  4. * Copyright, Moxiecode Systems AB
  5. * Released under LGPL License.
  6. *
  7. * License: http://www.tinymce.com/license
  8. * Contributing: http://www.tinymce.com/contributing
  9. */
  10. define("tinymce/util/JSONP", [
  11. "tinymce/dom/DOMUtils"
  12. ], function(DOMUtils) {
  13. return {
  14. callbacks: {},
  15. count: 0,
  16. send: function(settings) {
  17. var self = this, dom = DOMUtils.DOM, count = settings.count !== undefined ? settings.count : self.count;
  18. var id = 'tinymce_jsonp_' + count;
  19. self.callbacks[count] = function(json) {
  20. dom.remove(id);
  21. delete self.callbacks[count];
  22. settings.callback(json);
  23. };
  24. dom.add(dom.doc.body, 'script', {
  25. id: id,
  26. src: settings.url,
  27. type: 'text/javascript'
  28. });
  29. self.count++;
  30. }
  31. };
  32. });