Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In #794728: Re-engineering & Improving Home Box (Exportables, Performance, Features, etc) we discussed the feature of maximizing portlets, so that they temporarily fill the whole homebox space. The following code adresses this feature.
Javascript (in homebox.js > Drupal.behaviors.homebox)
// Add maximize link to every portlet
$boxes.find('.portlet-header .portlet-close').before('<span class="portlet-icon portlet-maximize"></span>')
// Attach click event to maximize icon
$boxes.find('.portlet-header .portlet-maximize').click(function() {
// references to active portlet and its homebox
var portlet = $(this).parents(".homebox-portlet");
var homebox = $(this).parents("#homebox");
// check if we're maximizing or minimizing the portlet
if ($(portlet).hasClass("portlet-maximized")) {
// minimizing portlet
// move this portlet to its original place (remembered with placeholder)
$(portlet).insertBefore($(homebox).find(".homebox-maximized-placeholder"))
.toggleClass("portlet-maximized");
// remove placeholder
$(homebox).find(".homebox-maximized-placeholder").remove();
// show columns again
$(homebox).find(".homebox-column").show();
} else {
// maximizing portlet
// add a place for maximized content (if not available, yet)
if ($(homebox).find(".homebox-maximized").length == 0) {
$(homebox).find(".homebox-column:first").before("<div class=\"homebox-maximized\"></div>");
}
// add the portlet to maximized content place and create a placeholder (for minimizing back to its place)
$(portlet)
.before("<div class=\"homebox-maximized-placeholder\"></div>")
.appendTo($(this).parents("#homebox").find(".homebox-maximized"))
.toggleClass("portlet-maximized");
// hide columns - only show maximized content place (including maximized widget)
$(homebox).find(".homebox-column").hide();
}
});
CSS (in homebox.css)
.portlet-maximize {
background: url(images/maximize.gif);
}
.portlet-maximized {
clear: both;
}
.portlet-maximized .portlet-maximize {
background: url(images/minimize.gif);
}
Images
both attached images have to be put into /homebox/images directory.
Bugs/Issues
- at http://drupal.org/node/794728#comment-2973740 mikesteff reported that Occasionally, the block doesn't expand across the regions, then disappears a few seconds later..
I wasn't able to reproduce it. Anyone to confirm this issue? I've been testing it with Chrome,Safari,Firefox on Mac
Comment | File | Size | Author |
---|---|---|---|
minimize.gif | 133 bytes | Morgenstern | |
maximize.gif | 133 bytes | Morgenstern |
Comments
Comment #1
Morgenstern CreditAttribution: Morgenstern commentedBug described by mikesteff
Occasionally, the block doesn't expand across the regions, then disappears a few seconds later..
I have tested this on ...
... without being able to reproduce the bug.
Anyone please register at http://www.dashboard.helgemorgenstern.de and try to reproduce this bug (simply try to maximize/minimize some widgets on the frontpage dashboard). Thanks!
Comment #2
mstef CreditAttribution: mstef commentedSeems to be happening after 5-6 consecutive maximize/minimizes... I can't find a real pattern yet. (Ubuntu 9.10/Chrome)
Comment #3
mstef CreditAttribution: mstef commentedSeems to be happening after 5-6 consecutive maximize/minimizes... I can't find a real pattern yet. (Ubuntu 9.10/Chrome)
Comment #4
Morgenstern CreditAttribution: Morgenstern commentedaaaah ... yeah ...
I got it :)
try to drag/move your widget by clicking on the maximize button.
seems like maximizing interferes with drag-action
Comment #5
pheraph CreditAttribution: pheraph commentedHey, just figured it out, too! (too slow...) :-)
Another problem: Maybe it would be a good idea to hide the close button when a box is maximized? I had to reload the page after I closed a maximized box.
Comment #6
Morgenstern CreditAttribution: Morgenstern commentedall right I fixed both:
- no more bug when dragging the widget through maximize icon
- close icon is hidden when maximized
new javascript code:
Comment #7
mstef CreditAttribution: mstef commentedNice work. Will evaluate and add tonight.
Comment #8
mstef CreditAttribution: mstef commentedNote to self: Make sure to deal with/hide the new "Save settings" button while a portlet is maximized..
Hmm..would it change the data if saved while maximized? I think so...
Comment #9
mstef CreditAttribution: mstef commentedAnother note, it looks like your site has trouble saving if a maximize action occurs. Not a big deal, because my version only saves when the 'save' button is pressed..
Comment #10
Morgenstern CreditAttribution: Morgenstern commentedWell I actually just thought of maximizing widgets as a temporary way to get your widget more space. So I haven't built any saving stuff for it yet. But I guess it should be rather easy to do so. Probably it's best to wait for your code including the 'save' button and add saving of maximized widgets on top of that.
Comment #11
mstef CreditAttribution: mstef commentedYea. My guess is to disable the 'save' button while things are maximizing. I'll most likely get all of this done tonight, plus a few other things..
Nice work again..I love it
Comment #12
Michsk CreditAttribution: Michsk commentedthis maximizing is nice. But i would like to see the boxes that are not maximized to be placed under the maximized block.
Comment #13
Morgenstern CreditAttribution: Morgenstern commentedSo we'll probably get a general admin settings page for homebox in the future I guess. We could make this an optional setting then as in my opinion that's a matter of taste and some people probably would like to have only the maximized widget available. I'll start a feature collection for maximized widgets in a second comment.
A quick solution would be leaving out these lines:
and
Comment #14
Morgenstern CreditAttribution: Morgenstern commentedToDo / Features
This is a list of request features for Maximized Widgets. I'll update this list in case any of new feature requests or solved features.
Comment #15
mstef CreditAttribution: mstef commentedI vote against #12. Maximizing, by what we're all used to, is taking over the screen (press the maximize button on your browser now). Doing what was suggested in #12, then means that we have to be able to save widgets while maximized, with little widgets under it - sounds like a mess. This should be purely a UI function, as it stands now.
Comment #16
mstef CreditAttribution: mstef commentedThere's a problem, and it's not your fault. I had to fix the CSS in the module prior to your work. It's causing the region not to stretch fullscreen.
See #797500: CSS For Column Widths Done Incorrectly
Comment #17
mstef CreditAttribution: mstef commentedOK that's fixed..
I am noticing a buggish thing now; after bringing in the maximize code..
Sometimes the region(s) load too short for the boxes on initial page load now...any ideas?
Comment #18
Morgenstern CreditAttribution: Morgenstern commentedmikesteff is right! Maximized widgets should take the whole screen by default. That's what users expect.
#17: Yeah I noticed this buggy behaviour on my sandbox, too. However I thought it's being caused only by those experimental external widgets I use there.
Comment #19
mstef CreditAttribution: mstef commentedNow I can't get it to recreate...ah we'll see..
I got my CVS account, so you should have the current 2.x code soon..
Thanks again for your help
Comment #20
mstef CreditAttribution: mstef commentedUh oh...UI alert.. You can remove maximized widgets via the list drop down!
I'll have to make the widget disabled while maximized..
Comment #21
Michsk CreditAttribution: Michsk commentedif you keep the other widgets open you will not have the above problem. I agree that maximizing your browser window (for example) you expect it to take over your screen, but this is not what happens with widget windows we do not use the whole screen. Another thing is that most widgets are not so big as you can see in the example. When we maximize them they stretch but they are not long and because of that we get a lot of white screen underneath. Another thing is that when we keep them beneath, in the future we could let them communicate trough ajax. Le'ts say trough one maximized widget you add content and in a recent content widget you get to see your node, just a little example.
And i really would like to see the other widgets beneat, i can imagine users wanting to standard have one widget maximized but have the others also in there screen.
Comment #22
mstef CreditAttribution: mstef commentedI understand what you're saying. But I have to still disagree. No one would want to maximize a widget that was tiny to begin with. You'd want to maximize something like a views table loaded with data. Putting things under it just seems to complicate matters. I think "maximize" should be simple and should be exactly what it means - just focus on the select block. IF you're using all huge blocks, create a single column Home Box...?
Comment #23
mstef CreditAttribution: mstef commentedComment #24
mstef CreditAttribution: mstef commentedBUG: Code assumes that the "close" icon is present. Blocks can be "unclosable" - so the close icon might not be present.
Comment #25
mstef CreditAttribution: mstef commentedFixed. The minus icon will always be there, so lets go before that..
Committed to 2.x-dev: http://drupal.org/cvs?commit=370284