--- loncom/interface/lonmenu.pm 2012/05/22 11:18:26 1.373 +++ loncom/interface/lonmenu.pm 2012/05/29 19:40:44 1.381 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.373 2012/05/22 11:18:26 bisitz Exp $ +# $Id: lonmenu.pm,v 1.381 2012/05/29 19:40:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -115,6 +115,18 @@ entries from mydesk.tab Same as primary_menu() but operates on @secondary_menu. +=item create_submenu() + +Creates XHTML for unordered list of sub-menu items which belong to a +particular top-level menu item. Uses hover pseudo class in css to display +dropdown list when mouse hovers over top-level item. Support for IE6 +(no hover psuedo class) via LC_hoverable class for
  • tag for top- +level item, which employs jQuery to handle behavior on mouseover. + +Inputs: 4 - (a) link and (b) target for anchor href in top level item, + (c) title for text wrapped by anchor tag in top level item. + (d) reference to array of arrays of sub-menu items. + =item innerregister() This gets called in order to register a URL in the body of the document @@ -225,51 +237,32 @@ sub primary_menu { my $title = $menuitem->[3]; if (defined($primary_submenu{$title})) { - my ($link,$target,$numsub); + my ($link,$target); if ($menuitem->[0] ne '') { $link = $menuitem->[0]; $target = '_top'; } else { $link = '#'; } + my @primsub; if (ref($primary_submenu{$title}) eq 'ARRAY') { - $numsub = @{$primary_submenu{$title}}; - if ($numsub) { - $title = - ''.&mt($title). - ''. - '▼'; - } - } - $menu .= '
  • '. - ''.$title.''; - if ($numsub) { - $menu .= ''; } - $menu .= '
  • '; } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink if ($public) { my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; @@ -326,6 +319,7 @@ sub secondary_menu { ? "/$env{'request.course.sec'}" : ''); my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); + my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec); @@ -354,7 +348,7 @@ sub secondary_menu { next if $$menuitem[4] eq 'cst' && !$canmodifyuser; next if $$menuitem[4] eq 'ncst' - && $canmodifyuser; + && ($canmodifyuser || !$canviewroster); next if $$menuitem[4] eq 'mgr' && !$canmgr; next if $$menuitem[4] eq 'nmgr' @@ -405,6 +399,37 @@ sub secondary_menu { return ""; } +sub create_submenu { + my ($link,$target,$title,$submenu) = @_; + return unless (ref($submenu) eq 'ARRAY'); + my $disptarget; + if ($target ne '') { + $disptarget = ' target="'.$target.'"'; + } + my $menu = '
  • '. + ''. + ''.&mt($title). + ''. + ' ▼'. + '
  • '; + return $menu; +} + sub innerregister { my ($forcereg,$bread_crumbs) = @_; my $const_space = ($env{'request.state'} eq 'construct'); @@ -725,7 +750,7 @@ ENDMENUITEMS if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F') { # wishlist is only available for users with access to resource-pool $menuitems .= (<'.$pic.''; + } else { + $inlineremote[$idx] = ''.$pic. ''.$top.' '; + } } return ''; } @@ -1158,6 +1202,27 @@ END } +sub countdown_toggle_js { + return <<"END"; + +function toggleCountdown() { + var countdownid = document.getElementById('duedatecountdown'); + var currstyle = countdownid.style.display; + if (currstyle == 'inline') { + countdownid.style.display = 'none'; + document.getElementById('ddcountcollapse').innerHTML=''; + document.getElementById('ddcountexpand').innerHTML='◄ '; + } else { + countdownid.style.display = 'inline'; + document.getElementById('ddcountcollapse').innerHTML='► '; + document.getElementById('ddcountexpand').innerHTML=''; + } + return; +} + +END +} + sub utilityfunctions { my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); if ($currenturl =~ m{^/adm/wrapper/ext/} @@ -1192,6 +1257,8 @@ sub utilityfunctions { my $esc_url=&escape($currenturl); my $esc_symb=&escape($currentsymb); + my $countdown = &countdown_toggle_js(); + return (< 1) { + my $first_access=&Apache::lonnet::get_first_access($interval[1]); + if ($first_access > 0) { + if ($first_access+$interval[0] > time) { + $hastimeleft = 1; + } + } + } + if (($duedate && $duedate > time) || + (!$duedate && $hastimeleft)) { + my ($collapse,$expand,$alttxt,$title,$currdisp); + if (@interval > 1 && $hastimeleft) { + $currdisp = 'inline'; + $collapse = '► '; + } else { + $currdisp = 'none'; + $expand = '◄ '; + } + unless ($env{'environment.icons'} eq 'iconsonly') { + $alttxt = &mt('Timer'); + $title = $alttxt.' '; + } + my $desc = &mt('Countdown to due date/time'); + return < + +$collapse + + + +$expand +$alttxt$title +END + } + } + return; +} + # ================================================================ Main Program BEGIN {