From patchwork Tue Nov 29 09:37:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zygmunt Krynicki X-Patchwork-Id: 5342 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 47F1C23E17 for ; Tue, 29 Nov 2011 09:37:22 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 39977A18066 for ; Tue, 29 Nov 2011 09:37:22 +0000 (UTC) Received: by faao24 with SMTP id o24so877536faa.11 for ; Tue, 29 Nov 2011 01:37:22 -0800 (PST) Received: by 10.152.104.1 with SMTP id ga1mr30633850lab.40.1322559441943; Tue, 29 Nov 2011 01:37:21 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs32660lal; Tue, 29 Nov 2011 01:37:21 -0800 (PST) Received: by 10.227.198.213 with SMTP id ep21mr30520369wbb.18.1322559434673; Tue, 29 Nov 2011 01:37:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id fz5si17898797wbb.25.2011.11.29.01.37.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Nov 2011 01:37:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RVK7m-0007Em-AO for ; Tue, 29 Nov 2011 09:37:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 485B2E0435 for ; Tue, 29 Nov 2011 09:37:14 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-server X-Launchpad-Branch: ~linaro-validation/lava-server/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 293 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-server/trunk] Rev 293: Fix the menu and sub-menu pop-up sizing behavior. Message-Id: <20111129093714.13982.29715.launchpad@ackee.canonical.com> Date: Tue, 29 Nov 2011 09:37:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14399"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 53d638f3a268fe5e8a83cc74c29e50f001db7ba5 ------------------------------------------------------------ revno: 293 committer: Zygmunt Krynicki branch nick: lava-server timestamp: Fri 2011-11-18 15:53:14 +0100 message: Fix the menu and sub-menu pop-up sizing behavior. Apart from properly taking into account for the width of the border don't force the width to something that would not fit the contents anyway. Simplify and document the algorithm and reasoning. modified: lava_server/templates/layouts/content.html --- lp:lava-server https://code.launchpad.net/~linaro-validation/lava-server/trunk You are subscribed to branch lp:lava-server. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-server/trunk/+edit-subscription === modified file 'lava_server/templates/layouts/content.html' --- lava_server/templates/layouts/content.html 2011-11-18 13:57:11 +0000 +++ lava_server/templates/layouts/content.html 2011-11-18 14:53:14 +0000 @@ -137,6 +137,11 @@ // the default link action from firing event.preventDefault(); + // Find the sub menu + var self = $(this); + current_menu = self; + current_sub_menu = self.next(".lava-panel-menu"); + // The top absolute position of the menu. // Defaults to the bottom border of the panel // with the border size (2px) substracted to make @@ -145,35 +150,19 @@ // The left absolute position of the menu. // defaults to the offset of the indicator span - var _left = $(this).offset().left - - // Check how much horizontal space we have so that the menu - // does not resize the page. The idea is to get the width of - // the panel and remove the left offset of the indicator box. - // If the box would be squeezed (smaller than minimum size) then - // let's keep the size to minimum and move the left offset - // to compensate; - var avail_width = $("#lava-panel").outerWidth(true) - $(this).offset().left; - - var orig_width = $(this).next(".lava-panel-menu").width(); - var menu_width = $(this).outerWidth(false); - var sub_menu_width = $(this).next(".lava-panel-menu").outerWidth(true); - var _width = menu_width - 4; - - // Center the sub-menu if it is wider than the menu itself - if (sub_menu_width > menu_width) { - _left -= (sub_menu_width - menu_width) / 2; - _width = sub_menu_width; - } - // Relocate the sub-menu if we ran out of space - if (_width > avail_width) { - _width = sub_menu_width; - _left = $("#lava-panel").outerWidth(true) - sub_menu_width - 4; - } - // Show the sub menu - var self = $(this); - current_menu = self; - current_sub_menu = self.next(".lava-panel-menu"); + var _left = $(this).offset().left; + + // Same with the right menu, the right margin + var _width = $(this).width(); + + // Adjust the width to consider the border of the pop-up menu. + var width_adj = current_sub_menu.outerWidth() - current_sub_menu.width(); + _width -= width_adj; + + // Don't set the width if it would make the menu too short. + if (_width < current_sub_menu.width()) { + _width = null; + } // Add an 'active' class to the current menu, this showes up as a nice gradient current_menu