media.upload.js 916 B

123456789101112131415161718192021222324252627282930
  1. (function ($) {
  2. namespace('Drupal.media.browser.plugin');
  3. Drupal.media.browser.plugin.upload = function (mediaBrowser, options) {
  4. return {
  5. /* Abstract */
  6. init: function () {
  7. tabset = mediaBrowser.getTabset();
  8. tabset.tabs('add', '#upload', Drupal.t('Upload'));
  9. mediaBrowser.listen('tabs.show', function (e, id) {
  10. if (id == 'upload') {
  11. // We only need to set this once.
  12. // We probably could set it upon load.
  13. if (mediaBrowser.getActivePanel().html() == '') {
  14. mediaBrowser.getActivePanel().html(options.uploadForm);
  15. }
  16. }
  17. });
  18. }
  19. };
  20. };
  21. // For now, I guess self registration makes sense.
  22. // Really though, we should be doing it via drupal_add_js and some settings
  23. // from the drupal variable.
  24. // @todo: needs a review.
  25. Drupal.media.browser.register('upload', Drupal.media.browser.plugin.upload, {});
  26. })(jQuery);