media.fromurl.js 895 B

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