I see the above javascript error when I try to select an image from the media library. The popup then defaults to the first tab.

There was an attempt to fix this in passing in https://drupal.org/node/1957812 but this is a separate incompatibility so I'm filing as a separate issue. There is a patch on that issue that attempted to fix this in one place, but at least as of 7.x-2.0-alpha9 there are actually two places that need fixing (while maintaining support for older versions of jQuery UI).

Comments

ianthomas_uk’s picture

Status: Active » Needs review
StatusFileSize
new1.6 KB

Here's a patch, based on the patch and discussion in https://drupal.org/node/1957812

I've switched the version check around for forward compatibility and included jQuery UI 1.9 in the versions that get the new code (as the documentation shows this method was removed in 1.9).

I still don't see the media browser tab being selected, but that's because Drupal.media.browser.activeTab is always set to 0 in my testing. If that's not the correct behaviour, please file a followup issue - in my testing this patch does fix the js error and selects the tab that Drupal.media.browser.activeTab is set to.

killua99’s picture

Status: Needs review » Needs work
+++ b/js/media.browser.js
@@ -125,14 +125,21 @@ Drupal.media.browser.selectErrorTab = function() {
+        $('#media-browser-tabset').tabs('option', 'active', index); // jquery ui 1.9+

Could you write this with the Drupal CS? is terrible read this code.

https://drupal.org/node/172169
https://drupal.org/coding-standards#operators

ianthomas_uk’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB

Fair point. Here is the same patch using if/else.

aaron’s picture

I do not get the original behavior reported using jquery UI version 1-10-2. I do not know if that is because they have reverted the deprecated function or not.

ianthomas_uk’s picture

Are you sure that you're definitely using jQuery UI version 1.10 and that the patched lines are running? I've had another look at the documentation and while we can use both syntaxes in 1.9, I can't see anything to suggest that the select syntax will be supported in any future version of jQuery UI.

http://jqueryui.com/upgrade-guide/1.9/#deprecated-select-method
http://jqueryui.com/upgrade-guide/1.10/#removed-select-method-use-active...
http://jqueryui.com/changelog/

sylus’s picture

This fixed me receiving the same js error. And coincidentally when I first click on media browser the resize on first load actual fits all the content (instead of being cut off about 20px and working when tab back and forth).

I am using jQuery v1.8 and jQuery UI 1.10.2.

Tested on media according to:

projects[media][version] = 2.x-dev
projects[media][subdir] = contrib
projects[media][download][type] = git
projects[media][download][revision] = e2625ed
projects[media][download][branch] = 7.x-2.x
projects[media][patch][1411340] = http://drupal.org/files/media-resize_images_in_wysiwyg-1411340-75.patch
projects[media][patch][2071073] = http://drupal.org/files/media-warnings-creating-default-object-from-emtpy-value-2071073-1.patch
projects[media][patch][2089913] = http://drupal.org/files/media-2089913-3-no-such-method-select.patch
projects[media][patch][2093435] = http://drupal.org/files/2093435-media-js-dialog-issues.patch

I'd like to mark this as RTBC or should wait for more comments?

sylus’s picture

Status: Needs review » Reviewed & tested by the community
thijsvdanker’s picture

+1 RTBC. It fixes the warning and works as expected!

aaron’s picture

dave reid’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.31 KB

Seeing code duplicated made me think we should actually have a function that could be reused. Let's try this version out.

dave reid’s picture

Status: Needs review » Fixed

Tested and committed #10 to 7.x-2.x. http://drupalcode.org/project/media.git/commit/9b91d5d

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.