Fixed width theme backgrounds larger than popup windows

Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
Number of replies: 36
I am having a problem with my 960 fixed width theme and was was wondering if anyone else working with fixed-width could help.

Popup windows are not displaying correctly (see picture). The popups are set at definite widths that are smaller than my theme. I have been able to hack my CSS for most of these pupup windows - For example - messaging. However, the scales and files popups are presenting a particular problem. If I hack the CSS to not display my background and center my content on that background - the attributes also apply to the non-popup pages (I hope that makes sense!)

In other words, the same ID's that I would use to eliminate the fixed-width on the popups is eliminating the width on my main page.

For example - here's the CSS I would use:

body#course-scales,
#course-scales#page {
width:auto !important;
background:#fff !important;
}

It not only takes away the fixed width from the popup, but the general scales page entirely.

The same problem occurs for my files page (more of an issue)

Does anyone know of a solution - namely where I would alter the popup sizes???

Or - has anyone successfully gotten over this hurdle?

Attached Image - popup as it appears.
Attachment Picture_1.png
Average of ratings: -
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by David Scotson -

Without getting into the deeper issues, the CSS you posted is incorrect, I think:

body#course-scales,
#course-scales#page {
    width:auto !important;
    background:#fff !important;
}

The second line (#course-scales#page) is missing a space before the second #. That might solve your problem. You might want to try validating your CSS to try and catch any other typos that might be affecting things.

There's certainly no reason why you shouldn't be able to specify different widths for different pages, identified by their body#id (except for maybe Chat which is a bit weird with it's javascript generated page).

In reply to David Scotson

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
David - that's my fault. Typing error in the forum. Correct in my style sheet.

Here's my general issue. I can get the width and background to correct for popups, but in doing so I lose all width and background for all pages of the same id. For example, both the "Course Files" popup and the "Course Files" non-popup have the id #files-index.

What would make my life easier is if the popups had different ids. Alas, they do not.

Attached is a screen shot of what I don't want to happen when I include the code

body#files-index,
#files-index #page {
width:auto !important;
background:#fff !important
}

Attachment Picture_2.png
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
Here is a screenshot of what happens to my files menu in the popup if I leave the above code out:

I'm being forced to choose between one flaw or the other. This is what I was hoping to remedy. It seems minor, but when so much time goes into presentation ... I hate to leave something so apparent.
Attachment Picture_3.png
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Patrick,

If that can be any consolation wink, I am having the same problem on my fixed width orangechoc theme. Your analysis is correct. Unfortunately, there is no way - in Moodle, at present time - for a css to know whether it's being applied to an ordinary Moodle course window or to a popup window. This is why, as you say "the same ID's that I would use to eliminate the fixed-width on the popups is eliminating the width on my main page."

Again I agree with your request (in your further post) that "What would make my life easier is if the popups had different ids".

David, have you looked into this problem in your Kubrick theme, which is also a fixed-width theme?

Conclusion

Moodle core system should provide a special body#id = popup or something like that so CSS files would be able to apply different styles to ordinary Moodle windows and to popup ones...

Joseph

In reply to Joseph Rézeau

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
Thanks Joseph - the confirmation is useful!

Another conclusion would be some degree of control over the size of each popup window that could be kept in each individual theme folder??
In reply to Joseph Rézeau

Re: Fixed width theme backgrounds larger than popup windows

by David Scotson -

In Kubrick I do nothing, since I hadn't noticed this particular problem. However looking at it now I can see that although the problem is there, it is pretty much disguised because of the particular size and color of Kubrick theme.

Interestingly, Kubrick doesn't have headers in pop-ups, possibly because of code in header.html that looks like this:

<?php if ($home || $heading) {   ?>
    <div id="header">
     etc.

If that php does actually mean "everywhere but pop-ups" (which I seem to recall being the point, since the big Kubrick header looked a bit ridiculous in small pop-up windows) then you could use it to add a pop-up class to the body tag.

Other options include code fiddling e.g. finding the code that sets the width of these pop-ups ( e.g. mod/resource/type/file/file.html) and setting it to the same width as your theme or adding a javascript to your header that detects that width and changes it.

In reply to David Scotson

Re: Fixed width theme backgrounds larger than popup windows

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi David,

> Interestingly, Kubrick doesn't have headers in pop-ups, possibly because of code in header.html that looks like this:
<?php if ($home || $heading) { ?>
<div id="header">
etc.
If that php does actually mean "everywhere but pop-ups" ...

Sorry, but Kubrick does have headers in pop-ups (see attached screen shot of Glossary popup window); and the php code above certainly does not mean everywhere but pop-ups, because - again- Moodle has no way to tell "ordinary" windows from popup ones.

Can you confirm this? I am using Kubrick dated 19/10/2005, the latest I have got. Did you make a specific version for Moodle 1.6? What about making Kubrick available in the Moodle Themes database?

All the best,

Joseph

Attachment image-0000.jpg
In reply to Joseph Rézeau

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
For those looking for a fix to this problem, I'll post what I have done to eliminate the fixed-width in popups when possible, and then tell where to hack the script to resize the other two. smile

First, here is the big and ugly CSS that has gathered to get rid of my background image and the fixed-width for the following popup windows.  These render quite well and do not mess with any other page. This is where I was when starting this thread.

#message-history #page,
#message-user #page,
body#message-user,
body#message-history,
body#message-messages,
body#message-index,
body#message-send,
#message-index #page,
body#course-info,
#course-info #page,
#help #page,
body#help,
body#mod-resource-view,
#mod-resource-view #page,
#mod-glossary-showentry #page,
#course-group #page,
body#course-group {
  width:auto !important;
  background:#fff !important;
}

I'm not saying this is the best way to go about things, but it got the job done for me.

To alter the size of the scales popup window (necessary):
  1. Open: yourmoodle/course/scales.php.
  2. Find "width=???,height=???" in line 434 and replace the default sizes to fit the needs of your theme.
To alter the size of the Files popup window (necessary):
  1. Open: yourmoodle/mod/resource/type/file/file.html (thanks, David!).
  2. Replace ???, ??? in line 39 to your desired height and width, respectively.
The above should take care of all popups that I know of (in 1.6).
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
Note that this will not take care of all popups! I have since found a bunch that are still rendering too small for my fixed-width theme. I have not yet fixed them, but when I do I will post the hacks in this thread.
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Gary Weinstein -

Dear Patrick, following our discussion on your own support site at NewSchoolLearning, and my desire to set a minimum width for main pages, where do I apply the above CSS code in your elegance theme.

Regards ... Gary

In reply to Gary Weinstein

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
Here's the rub, Gary: This may not be plug-n-play for the theme you are trying to use it on. Fixed-width themes have trade-offs and require considerable testing and re-adjusting. Nevertheless, you could possibly try adding the above code to the bottom of any one of the CSS files currently being called up in config.php.

In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Gary Weinstein -

Dear Patrick, as always I appreciate your thoughts and considerations on this matter as well as your continued support.

Regards ... Gary

In reply to Joseph Rézeau

Re: Fixed width theme backgrounds larger than popup windows

by David Scotson -
Ah, it's only the file pop-up that doesn't have any header div outputted! One more oddity for the file.

Regarding Kubrick, to be honest it was never meant as a theme as such, more as living documentation of all the various work arounds needed to theme Moodle in a meaningful way, and that would need to be fixed in later versions of Moodle to make themeing Moodle easier (meaning: possible for mere mortals).

The idea was that by starting with something designed with no knowledge of Moodle, and trying very hard to make it work exactly as envisioned you'd hit all the snags you'd subconsciously avoid if you worked within Moodle's confines. Unfortunately that grew to became a very big list and it's simply too much effort to keep it updated as things change and new modules get added.

You could compromise in various places, as I've done for the theme I'm developing for my institution (which is usually on display here: http://learn.gla.ac.uk/moodle/stable15/) because I have no way of knowing which modules and add-ons will be used with it, and if you try to get clever with the theme there's a good chance they'll simply break in odd corner cases. While I'll happily make those compromises for a working theme as part of my job, it rather takes the fun, and to a great extent the point, out of themeing Moodle for it's own sake, rather than for a specific installation.

I'm hoping to show off some ideas I have for rethinking the way Moodle is themed at MoodleMoot UK and I'm trying to add the various nuggets of Moodle theme wisdom (stripey tables, fixed width stuff, hiding icons) contained within Kubrick to the Themes section of the Moodle Docs wiki as and when I get a chance so it will live on in that way, via any themes that take advantage of those ideas.
In reply to David Scotson

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
David -

You make clear a point that I've thought many times. My fixed-width theme works only because of work-arounds, hacks, and compromise. This is fine because my installation is specific and I know who my users will be. Releasing it to the public would mean justifying a lot of strange CSS to a lot of people!

I would gladly create another fixed-width theme for another institution. However, I wouldn't want to make one for all to use.
In reply to Joseph Rézeau

Re: The header.html problem has fixed

by ChanHan Hy -
Hi,

Thanks you very much for your tips.
It's a useful information.

Please kindly keep it here.

Thanks,

Best regards,
Han
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Jit San Chia -

Hi,

I have just downloaded and used "Funky" theme which is also a fixed width theme. I did notice the fixed width problem with popups like the messaging window.

What I did to resolve the problem is to use javascript in header.html and footer.html to determine the width of the current window, then decide to write or not to write the <div>s that specify the fixed width in the theme.

Not sure if the fixed width in your theme is implemented the same way as "funky". For "funky", the fixed widths and page borders are applied by a few extra <div>s in the header.html and footer.html, namely <div class=wrapper>, <div id=page-top>, <div id=page-middle> and <div id=page-bottom>. So simply not using these <div>s with small popup windows solves the problem.

Hope this is helpful in one way or another : )

In reply to Jit San Chia

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
This sounds like an ideal start. However, have you considered what the effect will be for individuals with javascript disabled?

Also, could you share your altered header.html file with us?
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Jit San Chia -
Hi Patrick,

This is the part of the header.html that I altered:
------------------------------------------
<center>
<div id="page">
<div class="wrapper">
<div id="page-top"></div>
<div id="page-middle">

<?php //Accessibility: warning: ALT text will need editing if logo changes. 'headermain' is now H1, see theme/standard/styles_layout.css: .headermain
if ($home) { // This is what gets printed on the home page only
?>
--------------------------------------------

The red ones are what I referred to as extra <div>s.
I changed it to read as:

--------------------------------------------
<center>
<div id="page">
<script language="javascript">
if (document.body.clientWidth >= 900) {
document.write('<div class="wrapper"><div id="page-top"></div><div id="page-middle">');
}
</script>
<?php //Accessibility: warning: ALT text will need editing if logo changes. 'headermain' is now H1, see theme/standard/styles_layout.css: .headermain
if ($home) { // This is what gets printed on the home page only
?>
--------------------------------------------

I am using IE 7, so document.body.clientWidth works for me. I believe for some other browsers, you may need to use window.innerWidth or document.documentElement.clientWidth

I did the same for <div id="page-bottom"> in footer.html

You are right about browsers that disable javascript, they will not see the theme properly at all : )
In reply to Jit San Chia

Re: Fixed width theme backgrounds larger than popup windows

by Jit San Chia -
I think you can use <noscript> to get that covered though : )
But the original fixed width problem will stay with them : )
In reply to Jit San Chia

Re: Fixed width theme backgrounds larger than popup windows

by Gary Weinstein -

Dear Jit, thanks for your suggested workaround.  As I am a novice in PHP, JS, CSS etc, I would appreciate full details of the Funky theme changes to study before I make changes to the Elegance theme.

Thanks and regards ... Gary

In reply to Gary Weinstein

Re: Fixed width theme backgrounds larger than popup windows

by Jit San Chia -

Hi Gary,

Please see my reply to Julian. Hope the attached files are helpful to you.

In reply to Jit San Chia

Re: Fixed width theme backgrounds larger than popup windows

by Julian Ridden -
Once you have it working in Funky, can you send me your modified files so I can update the distro. Thanks

Julian
In reply to Julian Ridden

Re: Fixed width theme backgrounds larger than popup windows

by Jit San Chia -

Hi Julian,

Attached is the zip that contains the modified header.html and footer.html

Should work fine on all major not-so-old browsers. For browsers that has javascript turned off, it's just back to the original state, so they don't gain anything, don't lose anything : )

Again, many thanks for the very nice theme!

Thanks also to Patrick for reminding me that there are people who disable javascript in their browsers : )

In reply to Jit San Chia

Re: Fixed width theme backgrounds larger than popup windows

by tom rhodes -
hey, i notice this thread is getting a little bit old smile

Patrick: what are your latest workarounds for these issues?

plus in general, is there still no way to know through the php whether a page is a pop up or not?


In reply to tom rhodes

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
This appears to be in the works for 1.9.1:

http://tracker.moodle.org/browse/MDL-12093?focusedCommentId=44640#action_44640

I am simply patiently waiting.

The only other option is to completely restyle all windows that may potentially be a popup.

This is problematic for the resource popups, so I have completely restyled them.

For example, here is my school site:

http://www.nilesschools.org/vikingnet

Here is my resource view styling (quite different):

http://www.nilesschools.org/vikingnet/mod/resource/view.php?id=2013

All fancy bits have been removed.

You can find more on this topic here.
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Mathieu Petit-Clair -
Picture of Core developers Picture of Moodle HQ Picture of MoodleCloud team Picture of Plugin developers Picture of Testers
Yeah, it's in the works, but it's really not there yet. The plan is to get this in 1.9, but it might be some time before it gets in.

Unfortunately, because of the nature of popups, this is not a trivial thing.. sad

Mat
In reply to Mathieu Petit-Clair

Re: Fixed width theme backgrounds larger than popup windows

by tom rhodes -
so, to some up, it's either javascript, or restyle all the pages that could be a popup?

for the latter how do you know which pages will be in a popup? and how do you then not use the header.html in the theme folder etc. for those pages?

In reply to tom rhodes

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
You can CSS hack everything in the header out of the window with something like this:

#mod-resource-view #header { display:none }

or

#help #header { display:none }


Start with what you can find, then whenever something new "pops up," add it to your hack list.

Keep in mind though that there is no way to differentiate between resource popups and resources that are not in popups, so some compromise will need to be made.
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Grant Swaim -
Patrick,

My site suffers from this issue and I am willing to mod the css so I can at least get the messaging popup working right. I have disabled messaging until I can get the popup working right.

I tried your example for the help file "#help #header { display:none }" and changed it for the messaging but could not get it to work.

Could you please expand a tad on how to implement this css hack? I am using the "Standard" theme. Do I add these lines to the layout css? Is this the correct syntax?

Thanks in advance for any help on this!
In reply to Grant Swaim

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
If you were to provide a link to your live site, or share with me your theme, I could give you a specific fix. However, assuming only that you have fixed the "page" ID (#page), the following should fix your issue with the messaging windows (and others):

#message-index #page,
#message-user #page,
#message-history #page,
#mod-glossary-showentry #page,
#help #page,
#course-info #page {
width:auto;
}

In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Grant Swaim -
Patrick,

Thanks for that information. The popup window content is now resizing to the popup window size and centering. I was controlling the width with "Wrap" so I modified your sample code accordingly. I am; however, still getting the site's header and footer in the popup window. The header image is 900px + wide so this still looks funky.

You can see the installation at digitalliteracyproject.com/lms. This site integrates (theme wise) with a WordPress blog using Brian Garner's Revolution theme. I originally themed the Moodle install with your "Modern" theme, but later decided to make the installation part of my CMSish looking WordPress blog. Feel free to look around. You should be able to enter the single "Test Course" as a guest.

I started with Moodle's Standard theme and have added some coding from the Revolution theme to make the integration. I am not versed in CSS and most of it has been a lot of trial and error. I have only made changes to the header, footer and CSS files which I have included these files in an attached zip file.

Thanks in advance on any help with the header/footer tweak!

In reply to Grant Swaim

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
The header should not be appearing on these pages. The reason it is appearing is because of the way you have edited your header.html file. You have omitted the PHP that tells Moodle what should appear on which pages.

I recommend looking closely at the standard theme header.html, and perhaps see my tutorial on adding a logo to a Moodle theme (only because it briefly explains the layout of header.html).
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Grant Swaim -
Patrick,

You are spot on. I went back and redid the header file with a little more restraint and got the header doing the right thing.

Thanks for your hard work and contributions to the community!
In reply to Patrick Malley

Re: Fixed width theme backgrounds larger than popup windows

by Jaap Marsman -
I'm hoping this topic is still active. I've been trying out the tweak here. I added the lines to styles-layout.css and even created a new styles-edu.css which I linked to in config.php

However, message windows still open in small screens. My question is, I've simply copied the code above. What should be the ID in the place of #page? Thanks!
In reply to Jaap Marsman

Re: Fixed width theme backgrounds larger than popup windows

by Ms. Royce -

Hello Jaap,

We had the same problem for a while. You can visit this link to see how we fixed the problem. However, we did not modify any of the page or body size in css because that always effected the popup window. This is how we made the fixed width change:  http://moodle.org/mod/forum/discuss.php?d=101102

Best wishes...

In reply to Mathieu Petit-Clair

Re: Fixed width theme backgrounds larger than popup windows

by Patrick Malley -
Thanks Mat,

I understand the difficulty of the task and will be patiently waiting.

Thanks for the update.