While using the overlay window, the document title remains the same. This is quite bothersome if you use multiple windows while administrating the website. For instance:

- Browse to your homepage after a clean install.
- The document title (and thus the browser window title) reads Welcome to [Site name].
- Open the admin section (overlay opens) but the document title remains the same.
- Open some more admin sections in new windows or new tabs. All the windows have the same title, even if one overlays shows the Modules page and the other shows the Content page.

Currently, the page title is already added to the iframe title (for usability). IMHO this should be added to the document title as well.
See the screenshot to see what the patch does.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BarisW’s picture

Status: Active » Needs review

Forgot to set the status :)

Kiphaas7’s picture

Status: Needs review » Needs work

Good idea, and needs to be fixed!

+    
+    // Store the original document title
+    self.$originalTitle = $(document).attr('title');
 
     // Add title to close button features for accessibility.
     self.$dialogTitlebar.find('.ui-dialog-titlebar-close').attr('title', Drupal.t('Close'));
@@ -455,6 +458,9 @@ Drupal.overlay.bindChild = function (ifr
   self.$dialogTitlebar.find('.ui-dialog-title').focus();
   // Add a title attribute to the iframe for accessibility.
   self.$iframe.attr('title', Drupal.t('@title dialog', { '@title': iframeTitle }));
+  
+  // Update the page title
+  document.title = self.$iframe.attr('title') + ' | ' + self.$originalTitle;
 
   // Remove any existing shortcut button markup in the title section.
   self.$dialogTitlebar.find('.add-or-remove-shortcuts').remove();

Lots of whitespaces on your newlines, those need to be removed. Also, in the code, the iframe title attribute is set, which you are retrieving in your patch. That's a DOM manipulation, and those are costly (even though it is performed on a cached object). It would be better to save the Drupal.t('@title dialog', { '@title': iframeTitle }) in a separate variable, and use it for both setting the iframe attr title, and the document title.

document.title = self.$iframe.attr('title') + ' | ' + self.$originalTitle;

Both the iframe title and the original title? Isn't the iframe title the title of the loaded page? So isn't this somehow duplicating parts and creating an unnecessarily long title? Or is the iframe title something else...

Also, you aren't setting the title back when the overlay gets closed....

BarisW’s picture

Status: Needs work » Needs review

Thanks for your thorough review!

Attached is a new patch where I altered your suggestions:

- I save the title in a separate variable
- The document title now equals the iframe title, so I don't attach the original title anymore
- The original title gets restored when the overlay is closed.

Let me know what you think!

BarisW’s picture

Forgot to add the patch :)

Georg’s picture

Successfully tested patch from #4 on:

IE8
Firefox 3.6.3
Safari 4.0.5
Opera 10.10
IE6
Chrome 4.1.249.1045 (42898)

It even works after translating it into German. ^^

Kiphaas7’s picture

Nice to have a test report! I think that there are still some rogue spaces on your newlines in the patch :). Other than that, it looks good. Again, haven't tried it because my dev pc is still broken.

BarisW’s picture

So, what makes this a RBTC? And can we still get this in D7?

Kiphaas7’s picture

If at least 1 other person tests it, and then sets it RTBC.....

jpmckinney’s picture

Status: Needs review » Reviewed & tested by the community

Code looks good, and #5 confirms it works in popular browsers.

BarisW’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
22.5 KB

Hmm, I just found out that the HTML code needs to be stripped out first.
This is more like a new bug that that is has something do do with this issue.

However, it would be small enough to keep it into this commit I guess.

The problem arises when the page title uses HTML tags.
We need to strip out the HTML tags from the iFrameTitle.

var iframeTitle = self.$iframeDocument.attr('title');

See the attachment.

BarisW’s picture

My previous screenshot isn't really clear. I'll add another one.
The article is called 'Test', see this attachment.

jpmckinney’s picture

BarisW, I don't understand what bug you're talking about.

We should not strip HTML tags from the iframe title. Sometimes we want that.

jpmckinney’s picture

Status: Needs work » Reviewed & tested by the community

Please don't CNW an RBTC patch if what you think "needs work" is something you consider to be a new bug that deserves its own issue.

BarisW’s picture

Ok, apologies. I agree with you, I will start another issue for this bug.
Let's get this one in first :)

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs review

Cool patch, but do we really want to put the word "dialog" in every page title like that? That seems like jargon to me. Instead of "Structure dialog", "Content dialog", etc, don't we rather want "Structure | My Site", "Content | My Site", etc (i.e., the same title they would see without the overlay)? I think it's somewhat important to keep the name of the site in there...

For the issue of HTML in the iframe title, see #725734: Overlay doesn't escape any page titles (residual cleanup) where that is being handled. That might help here as well, since it provides a mechanism to pass data about the title from the child window to the parent window's JS.

BarisW’s picture

Issue tags: +overlay, +D7UX usability
FileSize
1.7 KB

Guys,

a new patch. It now only sets the document title the same as the page title.
So instead of 'Modules dialog' it's just plain 'Modules'.

Let's get this puppy committed, as it really is a big usability improvement.

Georg’s picture

FileSize
61.85 KB

looks simple enough.

The only thing that bothers me now: html is displayed in the title. Would it be possible, to not display html? If there is no way to do this, I'd RTBC this.

tstoeckler’s picture

Without whitespace and adds the missing periods at the end of comments.
I stripped the HTML using a regex stolen from Drupal.ajaxError in drupal.js.
I have no clue whether the regex is too permissive or insecure or whatever, but testing the page in #17 now displays the title correctly.

tstoeckler’s picture

I just noticed that regarding the page title, there is already an issue for that, or at least a related issue. I'll let someone who has spent more than 15 minutes in overlay's code decide whether to fix it here or there or whatever.
#725734: Overlay doesn't escape any page titles (residual cleanup)

casey’s picture

A document with a <title> containing html elements is invalid. So it shouldn't be fixed here.

tstoeckler’s picture

All right. This is #16 without whitespace and with periods.

casey’s picture

I think you should change $originalTitle to originalTitle (we use $variable for jquery objects).

$(document).attr('title') should be document.title; The title element is no attribute of document (which isnt even an element). Besides, document.title is totally crossbrowser.

I know $(document).attr('title') is currently also used for var iframeTitle, but I changed that in #668640: Overlay shouldn't be based on jQuery UI Dialog.

tstoeckler’s picture

Incorporates #22.
Untested.

casey’s picture

FileSize
1.31 KB

Things need to be done a little different as #668640: Overlay shouldn't be based on jQuery UI Dialog landed.

David_Rothstein’s picture

This still has the problem that it puts HTML in the page title, and (as per #15) doesn't use the full Drupal page title (missing the "... | My Site Name" part).

However, when combined with the latest patch at #725734: Overlay doesn't escape any page titles (residual cleanup) it seems to work perfectly, so we might be good to go here as long as both of them get in :)

casey’s picture

RTBC?

aspilicious’s picture

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

Yup, agreed with RTBC. The code looks good and it now works perfectly!

BarisW’s picture

Agree, looks good. Thanks for the help ;)

casey’s picture

Still applies.

BarisW’s picture

And still appplies. Get this puppy committed please :)

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -overlay, -D7UX usability

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