[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonmenu.pm mydesk.tab

raeburn raeburn at source.lon-capa.org
Fri May 18 10:27:12 EDT 2012


raeburn		Fri May 18 14:27:12 2012 EDT

  Modified files:              
    /loncom/interface	mydesk.tab lonmenu.pm loncommon.pm 
  Log:
  - Primary menu.
    - replace separate 'Preferences, Portfolio, Feeds' items with sub-menu
      (uses :hover pseudo-class; works for IE7+,FF,Safari,Chrome,Opera) 
      shown when hovering over 'Personal' item.
      - To do: add support for IE6 via jQuery. 
    - Shorter menu can accommodate longer course titles without need for 
      wrapping.
  
  
-------------- next part --------------
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.150 loncom/interface/mydesk.tab:1.151
--- loncom/interface/mydesk.tab:1.150	Tue May 15 01:41:27 2012
+++ loncom/interface/mydesk.tab	Fri May 18 14:27:11 2012
@@ -14,20 +14,39 @@
 #   - nonewmsg: only display if there aren't any new messages
 #   - roles: show Roles instead of Courses
 #   - courses: show Courses instead of Roles
-# prim:link:icon:alt:text:condition
-prim:/adm/about.html:/adm/lonIcons/minilogo.gif:LON-CAPA Logo:About:public
-prim:/adm/menu:::Home:
-prim:/adm/communicate:::Messages:nonewmsg
-prim:/adm/communicate:::New Messages:newmsg
-prim:/adm/preferences:::Preferences:
-prim:/adm/portfolio:::Portfolio:
-prim:/adm/[domain]/[user]/_rss.html:::Feeds:
-prim:/adm/roles:::Roles:roles
-prim:/adm/roles:::Courses:courses
-prim:/adm/helpdesk:::Help:onlypublic
-prim:/adm/roles:::Log In:onlypublic
-prim::::Help:
-prim:/adm/logout:::Logout:
+# prim:link:icon:alt:text:condition:
+prim:/adm/about.html:/adm/lonIcons/minilogo.gif:LON-CAPA Logo:About:public:
+prim:/adm/menu:::Home::
+prim:/adm/communicate:::Messages:nonewmsg:
+prim:/adm/communicate:::New Messages:newmsg:
+prim::::Personal::
+prim:/adm/roles:::Roles:roles:
+prim:/adm/roles:::Courses:courses:
+prim:/adm/helpdesk:::Help:onlypublic:
+prim:/adm/roles:::Log In:onlypublic:
+prim::::Help::
+prim:/adm/logout:::Logout::
+
+# primary sub-menu links
+# Apache::lonmenu::primary_menu() generates a sub-menus from these elements
+# primsub: item belongs to primary sub-menu
+# parent: name of primary menu item, for which this is a sub-menu
+# link: references the url
+# text: link text
+# condition: when to show link, primary_menu() will act based on this
+#   possible conditions:
+#   - empty: link displayed if user is authenticated
+#   - portfolio: link displayed if portfolio access
+#   - blogs: link displayed if blog access
+#   - wishlist: link displayed if user has privileges to use Stored Links
+#   - reqcrs: link displayed if user can request Course or Community creation
+# primsub:parent:link:text:condition
+primsub:Personal:/adm/preferences:Preferences:
+primsub:Personal:/adm/portfolio:Portfolio:portfolio
+primsub:Personal:/adm/wishlist:Stored Links:wishlist
+primsub:Personal:/adm/announcements:Calendar:
+primsub:Personal:/adm/[domain]/[user]/_rss.html:Feeds:blog
+primsub:Personal:/adm/requestcourse:Course Requests:reqcrs
 
 # secondary menu links
 # Apache::lonmenu::secondary_menu() generates a menu from these elements
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.370 loncom/interface/lonmenu.pm:1.371
--- loncom/interface/lonmenu.pm:1.370	Tue May 15 01:41:27 2012
+++ loncom/interface/lonmenu.pm	Fri May 18 14:27:11 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.370 2012/05/15 01:41:27 raeburn Exp $
+# $Id: lonmenu.pm,v 1.371 2012/05/18 14:27:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -26,8 +26,6 @@
 # http://www.lon-capa.org/
 #
 #
-# There is one parameter controlling the action of this module:
-#
 
 =head1 NAME
 
@@ -35,7 +33,8 @@
 
 =head1 SYNOPSIS
 
-Coordinates the response to clicking an image.
+Loads contents of /home/httpd/lonTabs/mydesk.tab, 
+used to generate inline menu, and Main Menu page. 
 
 This is part of the LearningOnline Network with CAPA project
 described at http://www.lon-capa.org.
@@ -74,10 +73,19 @@
 =item @primary_menu
 
 The elements of this array reference arrays that are made up of the components
-of those lines of mydesk.tab that start with prim.
+of those lines of mydesk.tab that start with prim:.
 It is used by primary_menu() to generate the corresponding menu.
 It gets filled in the BEGIN block of this module.
 
+=item %primary_sub_menu
+
+The keys of this hash reference are the names of items in the primary_menu array 
+which have sub-menus.  For each key, the corresponding value is a reference to
+an array containing components extracted from lines in mydesk.tab which begin
+with primsub:.
+This hash, which is used by primary_menu to generate sub-menus, is populated in
+the BEGIN block.
+
 =item @secondary_menu
 
 The elements of this array reference arrays that are made up of the components
@@ -129,6 +137,9 @@
 
 =item utilityfunctions()
 
+Output from this routine is a number of javascript functions called by
+items in the inline menu, and in some cases items in the Main Menu page. 
+
 =item serverform()
 
 =item constspaceform()
@@ -159,7 +170,7 @@
 use Apache::lonwishlist();
 
 use vars qw(@desklines %category_names %category_members %category_positions 
-            $readdesk @primary_menu @secondary_menu);
+            $readdesk @primary_menu %primary_submenu @secondary_menu);
 
 my @inlineremote;
 
@@ -182,7 +193,7 @@
 
 # primary_menu() evaluates @primary_menu and returns XHTML for the menu
 # that contains following links:
-# About, Message, Roles, Help, Logout
+# About, Message, Personal, Roles, Help, Logout
 # @primary_menu is filled within the BEGIN block of this module with 
 # entries from mydesk.tab
 sub primary_menu {
@@ -212,8 +223,53 @@
         next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted
                 && !&Apache::loncommon::show_course(); ##
         
-            
-        if ($$menuitem[3] eq 'Help') { # special treatment for helplink
+        my $title = $menuitem->[3];
+        if (defined($primary_submenu{$title})) {
+            my ($link,$target,$numsub);
+            if ($menuitem->[0] ne '') {
+                $link = $menuitem->[0];
+                $target = '_top';
+            } else {
+                $link = '#';
+            }
+            if (ref($primary_submenu{$title}) eq 'ARRAY') {
+                $numsub = @{$primary_submenu{$title}};
+                if ($numsub) {
+                    $title =
+                        '<span class="LC_nobreak">'.$title.
+                        '<span class="LC_fontsize_small">'.
+                        '▼</span></span>';
+                }
+            }
+            $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.$title.'</a>';
+            if ($numsub) {
+                $menu .= '<ul>';
+                foreach my $item (@{$primary_submenu{$menuitem->[3]}}) {
+                    if (ref($item) eq 'ARRAY') {
+                        if ($item->[2] eq 'wishlist') {
+                            next unless ((&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) ||
+                                         (&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/")));
+                        } elsif ($item->[2] eq 'reqcrs') {
+                            next unless(&check_for_rcrs());
+                        } elsif (($item->[2] eq 'portfolio') ||
+                                 ($item->[2] eq 'blog')) {
+                            if (!&Apache::lonnet::usertools_access(
+                                    $env{'user.name'},
+                                    $env{'user.domain'},
+                                    $item->[2],undef,'tools')) {
+                                next;
+                            }
+                        }
+                        $menu .= '<li style="margin:0;padding:0">'.
+                                 '<a href="'.$item->[0].
+                                 '" style="padding:0 0 0 10px">'.
+                                 $item->[1].'</a></li>';
+                    }
+                }
+                $menu .= '</ul>';
+            }
+            $menu .= '</li>';
+        } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
             if ($public) {
                 my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                 my $defdom = &Apache::lonnet::default_login_domain();
@@ -1687,6 +1743,9 @@
                     } elsif ($configline=~/^prim\:/) {
                         my @entries = (split(/\:/, $configline))[1..5];
                         push @primary_menu, \@entries;
+                    } elsif ($configline=~/^primsub\:/) {
+                        my ($parent, at entries) = (split(/\:/, $configline))[1..4];
+                        push (@{$primary_submenu{$parent}},\@entries);
                     } elsif ($configline=~/^scnd\:/) {
                         my @entries = (split(/\:/, $configline))[1..5];
                         push @secondary_menu, \@entries; 
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075 loncom/interface/loncommon.pm:1.1076
--- loncom/interface/loncommon.pm:1.1075	Wed May  9 20:17:47 2012
+++ loncom/interface/loncommon.pm	Fri May 18 14:27:11 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1075 2012/05/09 20:17:47 raeburn Exp $
+# $Id: loncommon.pm,v 1.1076 2012/05/18 14:27:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6446,6 +6446,7 @@
 ol.LC_primary_menu {
   float: right;
   margin: 0;
+  padding: 0;
   background-color: $pgbg_or_bgcolor;
 }
 
@@ -6454,9 +6455,46 @@
 }
 
 ol.LC_primary_menu li {
-  display: inline;
-  padding: 5px 5px 0 10px;
+  color: RGB(80, 80, 80);
+  vertical-align: middle;
+  text-align: left;
+  list-style: none;
+  float: left;
+}
+
+ol.LC_primary_menu li a {
+  display: block;
+  margin: 0;
+  padding: 0 5px 0 10px;
+  text-decoration: none;
+}
+
+ol.LC_primary_menu li ul {
+  display: none;
+  width: 10em;
+  background-color: $data_table_light;
+}
+
+ol.LC_primary_menu li:hover ul, ol.LC_primary_menu li.hover ul {
+  display: block;
+  position: absolute;
+  margin: 0;
+  padding: 0;
+}
+
+ol.LC_primary_menu li:hover li, ol.LC_primary_menu li.hover li {
+  font-size: 90%;
   vertical-align: top;
+  float: none;
+}
+
+ol.LC_primary_menu li:hover li a, ol.LC_primary_menu li.hover li a {
+  background-color:$data_table_light
+}
+
+ol.LC_primary_menu li li a:hover {
+   color:$button_hover;
+   background-color:$data_table_dark;
 }
 
 ol.LC_primary_menu li img {


More information about the LON-CAPA-cvs mailing list