The media browser popup is an ugly default jQuery dialog.

Issues

- Empty title bar that only shows on tabbed view, not media format form

- Always visible but not always applicable OK and Cancel buttons

- Positioned top left

- Doesn't resize based on tab switch

Comments

james.elliott’s picture

StatusFileSize
new1.42 KB

This patch is a beginning of styling changes for this. The proper dependencies for jQuery UI dialog aren't in the system.module so positioning can't be fixed until #836700: Upgrade to jQuery UI 1.8 doesn't include proper dependencies for dialog is committed.

JacobSingh’s picture

The reason we put the titlebar back is there jquery dialog has a bug where you can lose your buttons. I'm not sure exactly what causes it, but their div becomes display:none which basically means you have to refresh the page, which means you lose your story :(

But I guess we should fix that too, so maybe re-introducing that bug will help us feel inspired to cleanup the button mess.

james.elliott’s picture

The reason I removed the title bar was because it didn't show on the media-format-form and it looked better.

I also spent some time last night playing with passing events and data in and out of the iframe so we can maintain that impenetrable insulation from style bleed. In which case we could use buttons inside the frame to fire the functions currently attached to the ok and cancel buttons. That way we don't need to have them displayed when they are irrelevant, such as with the upload and from url tabs.

JacobSingh’s picture

Cool, would love to see what you work up. The scary thing there is that then the iframe is ref'ing stuff outside of it. This means it won't work on its own (for instance if it is used in admin/content/media).

Also, it wouldn't work if it was embedded in a page, etc. I'm okay with forgoing some flexibility for now for usability though.

My general goal is:

The media browser plugins have no knowledge of
the iframe they are contained in
the iframe has no knowledge of
the dialog it is contained in
the dialog has no knowledge of
the popup code which calls it
the popup code has no knowledge of
call sites who launch the browser (like media as a field, wysiwyg, the link on the admin screen, etc).

We can bleed these, but especially the wall between the call sites and the popup code needs to be totally insulated IMO.

Best,
Jacob

james.elliott’s picture

StatusFileSize
new1.08 KB

New patch that doesn't apply the fixed positioning

james.elliott’s picture

StatusFileSize
new1.51 KB

New patch that addresses a problem with short browser windows and the media popup dialog. Without it, the tabs can be hidden behind the toolbar without any way of scrolling to them.

james.elliott’s picture

StatusFileSize
new7.57 KB
new4.85 KB

Here is a new patch to the latest Media. In this patch I've moved the dialog to the center, and hidden the "Ok" and "Cancel" buttons. The iframe will now add Submit and Cancel buttons where applicable to the forms and they replace the buttons on the jQuery dialog.

I plan on rerolling this patch soon after some refactoring of the browser to step away from the iframes and towards an ajax multi-part form.

james.elliott’s picture

hmmm the bottom one is the patch to test. The first shouldn't be there.

JacobSingh’s picture

Status: Active » Needs work

There is no select button on the library AFAICT.

JacobSingh’s picture

Also, needs a cancel button of some sort.

JacobSingh’s picture

okay, so I get it, there is a bug here. IT doesn't work w/ wyswiyg.

JacobSingh’s picture

Status: Needs work » Needs review

And then it started working... and I don't know why.

#morewhiskey

JacobSingh’s picture

Status: Needs review » Needs work

I really, really like how this patch makes the browser look.

I don't like how the code does it though.

Adding the fake buttons is a clever way to try to be non-intrusive in the form, but it's a kinda funky architecture, isn't it? I'm not saying I have a magic bullet "clean" solution, but I feel like we should do some more work here... Perhaps a cleaner way to start (For now) is to just add the buttons to the forms themselves in PHP. It means they won't be re-usable and it's kinda ugly in its own way, but less so IMO.

-J

james.elliott’s picture

Injecting the buttons via PHP and attaching javascript actions doesn't seem to be much more clean to me. If we didn't have the onus of attaching the javascript handlers, then I would say that added the buttons via php was cleaner in that they would be added despite javascript faults elsewhere.

james.elliott’s picture

StatusFileSize
new7.31 KB

New patch as the old one wouldn't apply cleanly to the CVS HEAD of the module

james.elliott’s picture

StatusFileSize
new7.84 KB

Another patch that should play nicer with other jquery ui dialogs

aspilicious’s picture

Could we add some screenshots? Please?

james.elliott’s picture

StatusFileSize
new7.4 KB

Patch reroll, there was a double chunk in there somehow.

Screenshot:
http://skitch.com/jameselliott/dixed/content-d7-test

effulgentsia’s picture

Status: Needs work » Needs review
StatusFileSize
new9.27 KB

#18 is an unholy hack, but let's face it, so is much of media browser javascript. Maybe the whole thing can be refactored some day, but until then, #18 is an improvement to HEAD. I discussed this with James, and each decision in the patch has a logical reason for being there, and the end result is to bring the media browser into closer compliance with Drupal UI standards.

Jacob #13:

Adding the fake buttons is a clever way to try to be non-intrusive in the form, but it's a kinda funky architecture, isn't it? I'm not saying I have a magic bullet "clean" solution, but I feel like we should do some more work here... Perhaps a cleaner way to start (For now) is to just add the buttons to the forms themselves in PHP. It means they won't be re-usable and it's kinda ugly in its own way, but less so IMO.

James #14:

Injecting the buttons via PHP and attaching javascript actions doesn't seem to be much more clean to me.

I agree with James. The #18 patch has the correct separation of what's in PHP and what's in JS. The JS respects the presence of a real submit button (if any) added by PHP. It injects additional buttons, if needed, whose only purpose is to trigger JS code.

What's hacky in #18 is that the media module has JS code to add "ok" and "cancel" buttons that it hides, and also to add "submit" and "cancel" buttons whose only purpose is to route control to the hidden buttons. Ugly, but apparently necessary to get around cross-IFRAME scripting issues. I'm attaching a patch that has no code change relative to #18, but adds comments to explain the non-intuitive JS code.

@James: if you're happy with the comments, please commit.

This code has been well tested by people with sites on drupalgardens.com.

effulgentsia’s picture

Title: The media browser popup needs better styling » OK and Cancel buttons on a different line than "upload"/"submit" buttons violates Drupal UI standards
Category: feature » bug

.

james.elliott’s picture

The comments clearly explain the reasoning behind the changes. I also like that you separated out the dialog('destroy'); as well

Committed patch from #19

effulgentsia’s picture

Status: Needs review » Fixed

Thanks. By the way, the change to dialog('destroy') was in #18, so I can't take credit for that :)

Status: Fixed » Closed (fixed)

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