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
CommentFileSizeAuthor
minimize.gif133 bytesMorgenstern
maximize.gif133 bytesMorgenstern
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Morgenstern’s picture

Bug described by mikesteff
Occasionally, the block doesn't expand across the regions, then disappears a few seconds later..

I have tested this on ...

  • MacOSX Chrome/FF/Safari
  • WinXP Chrome/FF
  • Ubuntu 10.04 FF

... 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!

mstef’s picture

Seems to be happening after 5-6 consecutive maximize/minimizes... I can't find a real pattern yet. (Ubuntu 9.10/Chrome)

mstef’s picture

Seems to be happening after 5-6 consecutive maximize/minimizes... I can't find a real pattern yet. (Ubuntu 9.10/Chrome)

Morgenstern’s picture

aaaah ... yeah ...
I got it :)
try to drag/move your widget by clicking on the maximize button.
seems like maximizing interferes with drag-action

pheraph’s picture

Hey, 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.

Morgenstern’s picture

all right I fixed both:
- no more bug when dragging the widget through maximize icon
- close icon is hidden when maximized

new javascript code:

    // Add maximize link to every portlet
    $boxes.find('.portlet-header .portlet-close').after('<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");
      
      // only fire this action if this widget isnt being dragged
      // see bug description at http://drupal.org/node/800468#comment-2982830
      if (!$(portlet).hasClass("ui-sortable-helper")) {
        // 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();
          
          // show close icon again
          $(portlet).find(".portlet-close").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();

          // hide close icon (you wont be able to return if you close the widget)
          $(portlet).find(".portlet-close").hide();
          
        }      
      }
    });
mstef’s picture

Nice work. Will evaluate and add tonight.

mstef’s picture

Note 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...

mstef’s picture

Another 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..

Morgenstern’s picture

Well 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.

mstef’s picture

Yea. 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

Michsk’s picture

this maximizing is nice. But i would like to see the boxes that are not maximized to be placed under the maximized block.

Morgenstern’s picture

So 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:

          // show columns again
          $(homebox).find(".homebox-column").show();

and

          // hide columns - only show maximized content place (including maximized widget)
          $(homebox).find(".homebox-column").hide();
Morgenstern’s picture

ToDo / 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.

  • Saving the state of maximized widgets
  • Optionally showing all other widgets below maximized widget
mstef’s picture

I 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.

mstef’s picture

There'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

mstef’s picture

OK 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?

Morgenstern’s picture

mikesteff 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.

mstef’s picture

Now 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

mstef’s picture

Uh oh...UI alert.. You can remove maximized widgets via the list drop down!

I'll have to make the widget disabled while maximized..

Michsk’s picture

if 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.

mstef’s picture

I 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...?

mstef’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Fixed
mstef’s picture

Status: Fixed » Needs work

BUG: Code assumes that the "close" icon is present. Blocks can be "unclosable" - so the close icon might not be present.

$boxes.find('.portlet-header .portlet-close').after('.......
mstef’s picture

Status: Needs work » Fixed

Fixed. The minus icon will always be there, so lets go before that..

// Add maximize link to every portlet
$boxes.find('.portlet-header .portlet-minus').before('<span class="portlet-icon portlet-maximize"></span>');    

Committed to 2.x-dev: http://drupal.org/cvs?commit=370284

Status: Fixed » Closed (fixed)

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