Commit 91ecca1a7acc15f859b34164c4025ef355653ec6

Authored by Antonio Terceiro
1 parent 4096f649

Fix menus in old layout

(ActionItem1608)
app/views/layouts/application.rhtml
... ... @@ -9,7 +9,6 @@
9 9 <%= yield(:feeds) %>
10 10  
11 11 <%= noosfero_javascript %>
12   - <%= javascript_include_tag 'menu', 'auto-open-menu', 'menu-config', :cache => 'cache-menu' %>
13 12 <%= theme_javascript %>
14 13  
15 14 <%=
... ... @@ -88,9 +87,6 @@
88 87 <% end %>
89 88 <%= render :file => 'shared/assets_menu' %>
90 89 </div><!-- id='navigation_bar' -->
91   - <script type="text/javascript">
92   - prepareMenu('navigation_bar', { timeout: 1000 });
93   - </script>
94 90  
95 91 <div id="language-selector">
96 92 <%= language_chooser(:element => 'dropdown') %>
... ...
app/views/shared/assets_menu.rhtml
... ... @@ -7,9 +7,3 @@
7 7 </div><!-- fim id="assets_menu_list" -->
8 8 <div id="assets_menu_layout_iten"></div>
9 9 </div><!-- fim id="assets_menu" -->
10   -
11   -<script type="text/javascript">
12   - if ( assetsMenu.autoOpen ) {
13   - setAutoOpenMenu( $("assets_menu") );
14   - }
15   -</script>
... ...
app/views/shared/user_menu.rhtml
1 1 <div id="user_menu" class="top_extra_menu AOM_paddingBottom_6">
2 2  
3   - <% if logged_in? %>
  3 + <div id='user'>
  4 + <div class='logged-in' style='display: none'>
4 5  
5 6 <div id="user_menu_head">
6   - <img src="<%=
7   - (current_user.person.image)?
8   - current_user.person.image.public_filename(:icon) : "/images/icons-bar/photo.png"
9   - %>" alt="<%= current_user.name %> Icon-Photo" title="" height="20" border="0"/>
10   - <span><%= _("%s's Menu") % current_user.person.short_name %> </span>
  7 + <%= image_tag 'icons-app/person-icon.png', :alt => "%{login} icon photo", :height => "20", :border => "0" %>
  8 + <span><%= _("%s's Menu") % '%{login}' %> </span>
11 9 </div>
12 10  
13 11 <div id="user_menu_ul">
14 12 <ul>
15 13  
16 14 <li>
17   - <%= link_to( '<span class="icon-menu-home"></span>' + __('My Home Page'), user.url)%>
  15 + <%= link_to( '<span class="icon-menu-home"></span>' + __('My Home Page'), '/%{login}')%>
18 16 </li>
19 17  
20 18 <li>
21   - <%= link_to('<span class="icon-menu-my-groups"></span>' + _('My groups'), { :controller => 'memberships', :profile => user.identifier, :action => 'index' }) %>
  19 + <%= link_to('<span class="icon-menu-my-groups"></span>' + _('My groups'), '/myprofile/%{login}/memberships') %>
22 20 </li>
23 21  
24 22 <li>
25   - <%= lightbox_link_to('<span class="icon-new"></span>' + _('New article'), user.admin_url.merge(:controller => 'cms', :action => 'new')) %>
  23 + <%= lightbox_link_to('<span class="icon-new"></span>' + _('New article'), '/myprofile/%{login}/cms/new') %>
26 24 </li>
27 25  
28   - <% for enterprise in user.enterprises %>
29   - <li><%= link_to('<span class="icon-menu-enterprise"></span>' + (_('Manage %s') % enterprise.short_name), { :controller => 'profile_editor', :profile => enterprise.identifier, :action => 'index' }) %></li>
30   - <% end %>
  26 + <%# for enterprise in user.enterprises %>
  27 + <li><%# link_to('<span class="icon-menu-enterprise"></span>' + (_('Manage %s') % enterprise.short_name), { :controller => 'profile_editor', :profile => enterprise.identifier, :action => 'index' }) #%></li>
  28 + <%# end %>
31 29  
32 30 <!-- li><a href="#"><span class="icon-menu-blog"></span> Meu Blog</a></li -->
33 31  
34   - <% if MailConf.enabled? && current_user.enable_email %>
  32 + <%# if MailConf.enabled? && current_user.enable_email %>
35 33 <li>
36   - <%= link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url(user.identifier, current_user.email_domain) %>
  34 + <%# link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url(user.identifier, current_user.email_domain) %>
37 35 </li>
38   - <% end %>
  36 + <%# end %>
39 37  
40 38 <li>
41   - <%= link_to('<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), { :controller => 'profile_editor', :action => 'index', :profile => user.identifier }, :id => 'link_edit_profile') %>
  39 + <%= link_to('<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), '/myprofile/%{login}', :id => 'link_edit_profile') %>
42 40 </li>
43 41  
44   - <% if user.is_admin?(environment) %>
45   - <li><%= link_to( '<span class="icon-menu-admin"></span>'+ _('Admin'),
  42 + <li class='admin-link' style='display: none'><%= link_to( '<span class="icon-menu-admin"></span>'+ _('Admin'),
46 43 {:controller => 'admin_panel' },
47 44 :id => 'link_admin_panel' ) %>
48 45 </li>
49   - <% end %>
50 46  
51 47 <li><%= link_to( '<span class="icon-menu-logout"></span>'+ _('Logout'),
52 48 {:controller => 'account', :action => 'logout'},
... ... @@ -56,7 +52,9 @@
56 52 </ul>
57 53 </div><!-- id="user_menu_ul" -->
58 54  
59   - <% else %>
  55 + </div> <!-- .logged-in -->
  56 +
  57 + <div class='not-logged-in' style='display: none'>
60 58  
61 59 <% if params[:controller] != 'account' || params[:action] != 'signup' %>
62 60 <% if theme_option( :menu_login ) == 'full_form' %>
... ... @@ -69,9 +67,8 @@
69 67 <% end %>
70 68 <% end %>
71 69  
72   - <% end %>
73   -
74   -</div><!-- fim id="user_menu" -->
  70 + </div><!-- #not-logged-in -->
75 71  
76   -<%= javascript_tag 'setAutoOpenMenu( $("user_menu") )' if theme_option( :menu_login ) != 'full_form' %>
  72 + </div><!-- #user -->
77 73  
  74 +</div><!-- fim id="user_menu" -->
... ...
public/images/icons-bar/photo.png

781 Bytes

public/javascripts/application.js
... ... @@ -444,7 +444,7 @@ jQuery(function($) {
444 444 $(this).find('a[href]').each(function() {
445 445 $(this).attr('href', $(this).attr('href').replace('%{login}', data.login))
446 446 });
447   - var html = $(this).html().replace('%{login}', data.login).replace('%{month}', data.since_month).replace('%{year}', data.since_year);
  447 + var html = $(this).html().replace(/%{login}/g, data.login).replace('%{month}', data.since_month).replace('%{year}', data.since_year);
448 448 $(this).html(html).fadeIn();
449 449 if (data.is_admin) {
450 450 $('#user .admin-link').show();
... ...
public/javascripts/auto-open-menu.js
... ... @@ -1,70 +0,0 @@
1   -
2   -function setAutoOpenMenu( menu ) {
3   -
4   - var mul = menu.getElementsByTagName("ul")[0];
5   - if ( !mul ) return false;
6   -
7   - mul.h = mul.clientHeight; // remember the current height to a faster animation
8   - mul.minSize = mul.clientHeight;
9   - var vli = mul.getElementsByTagName("li");
10   - mul.paddingBottom = parseInt( menu.className.replace( /^.*AOM_paddingBottom_([^\s]+).*$/, "$1" ) );
11   - mul.maxSize = ( vli.length * ( vli[1].offsetTop - vli[0].offsetTop ) );
12   - mul.inc = 1;
13   -
14   - window["autoOpenMenu-"+menu.id] = menu;
15   - menu.mul = mul;
16   -
17   - if ( mul.minSize == 1 ) {
18   - // Work arround bug for IE - ie sux - ie sux - ie sux - ie sux -ie sux -ie sux -ie sux - ie sux!!!
19   - mul.h = 3;
20   - setTimeout('m = window[\'autoOpenMenu-'+menu.id+'\']; m.onmouseout()', 10);
21   - }
22   -
23   - menu.isIE = ( navigator.appName.indexOf("Microsoft") > -1 );
24   -
25   - menu.onmouseover = function () {
26   - clearTimeout( this.timeoutClose );
27   - this.className = this.className.replace( / closed/g, "" );
28   - if ( !/menu-opened/.test(this.className) ) { this.className += " opened" }
29   - var mul = this.mul;
30   - mul.style.display = "block";
31   - if ( mul.paddingBottom ) mul.parentNode.style.paddingBottom = mul.paddingBottom +"px";
32   - if ( mul.h < mul.maxSize ) {
33   - mul.h += mul.inc;
34   - mul.inc += 2;
35   - mul.style.height = mul.h +"px";
36   - this.timeoutOpen = setTimeout( "window['autoOpenMenu-"+this.id+"'].onmouseover()", 33 );
37   - } else {
38   - mul.h = mul.maxSize;
39   - mul.style.height = mul.h +"px";
40   - mul.inc = 1;
41   - }
42   - }
43   -
44   - menu.onmouseout = function ( doIt, firstDoIt ) {
45   - clearTimeout( this.timeoutOpen );
46   - var mul = this.mul;
47   - if ( firstDoIt ) mul.inc = 1;
48   - if ( doIt == true ) {
49   - if ( mul.h > mul.minSize ) {
50   - mul.h -= mul.inc++;
51   - if ( mul.h < 0 ) mul.h = 0;
52   - if ( mul.h == 0 ) mul.style.display = "none";
53   - if ( this.isIE ) if ( mul.h < 1 ) mul.h = 1;
54   - mul.style.height = mul.h +"px";
55   - this.timeoutClose = setTimeout( "window['autoOpenMenu-"+this.id+"'].onmouseout(true)", 33 );
56   - } else {
57   - mul.h = mul.minSize;
58   - mul.style.height = mul.h +"px";
59   - if ( mul.paddingBottom ) mul.parentNode.style.paddingBottom = "0px";
60   - mul.inc = 2;
61   - this.className = this.className.replace( / opened/g, "" );
62   - this.className += " closed"
63   - }
64   - } else {
65   - // Work arround IE bug
66   - this.timeoutClose = setTimeout( "window['autoOpenMenu-"+this.id+"'].onmouseout(true, true)", 200 );
67   - }
68   - }
69   -
70   -}
public/javascripts/menu-config.js
... ... @@ -1,7 +0,0 @@
1   -
2   -// The configurable options are seted here and can be
3   -// replaced by specific theme scripts.
4   -
5   -assetsMenu = {
6   - autoOpen : true
7   -}
public/javascripts/menu.js
... ... @@ -1,129 +0,0 @@
1   -function prepareMenu(id, options) {
2   -
3   - window.menuCloseTimeout = options.timeout || 333;
4   -
5   - if ( document.all ) {
6   - // add a class for work arround msie's css bugs
7   - $(id).className += " msie";
8   - }
9   - $(id).className += " menuRoot";
10   -
11   - var zIndex = 10;
12   -
13   - $$("#" + id + " ul ul").each( function( ul ) { // para cada UL de sub-menu faça:
14   - // Pega o link que abre este sub-menu:
15   - var linkText = ul.parentNode.firstChild;
16   - // Retira espaço em branco sobrando nas bordas deste:
17   - linkText.nodeValue = linkText.nodeValue.replace( /^\s*|\s*$/g, "" );
18   -
19   - // Create a link to open this sub-menu:
20   - var link = document.createElement("a");
21   - link.href = "#";
22   - link.className = "linkSubMenu";
23   - linkText.parentNode.insertBefore( link, linkText );
24   - link.parentNode.style.zIndex = zIndex++;
25   - link.subMenu = ul;
26   - var span = document.createElement("span");
27   - span.appendChild( linkText );
28   - link.appendChild( span );
29   - ul.linkControle = link;
30   - link.openSubMenu =
31   - function ( isMouseClick ) {
32   - if( this.subMenu.style.display == "block" ) {
33   - if( isMouseClick ) {
34   - this.subMenu.style.display = "none";
35   - } else {
36   - clearTimeout(this.timeOutClose);
37   - clearTimeout(this.subMenu.timeOutClose);
38   - return false;
39   - }
40   - } else {
41   - if ( window.openedMenu ) window.openedMenu.closeSubMenu();
42   - window.openedMenu = this.subMenu;
43   - this.className += " menu-opened"
44   - this.subMenu.style.display = "block";
45   - clearTimeout(this.timeOutClose);
46   - clearTimeout(this.subMenu.timeOutClose);
47   - }
48   - }
49   - link.closeSubMenu =
50   - function(){
51   - this.subMenu.style.display = "none";
52   - //link.className = link.className.replace( / menu-opened/g, "" );
53   - this.className = this.className.replace( / menu-opened/g, "" );
54   - }
55   -
56   - //link.onclick = function(){ this.openSubMenu(true); return false }Is not working
57   -
58   - // onmouseout e onmouseover manipulam o menu para pessoas normais
59   - // onblur e onfocus manipulam o menu para pessoas que precisam navegar com tab
60   -
61   - link.onmouseover = link.onfocus =
62   - function () {
63   - this.openSubMenu(false);
64   - };
65   - link.onmouseout = link.onblur =
66   - function () {
67   - this.timeOutClose = setTimeout( this.closeSubMenu.bind(this), window.menuCloseTimeout );
68   - };
69   -
70   - //ul.closeSubMenu = function(){ this.style.display = "none" }
71   - ul.closeSubMenu = function(){ this.linkControle.closeSubMenu() }
72   -
73   - ul.onmouseover = ul.onfocus =
74   - function () {
75   - this.blurCalledByIEWorkArroundBug = false;
76   - clearTimeout(this.timeOutClose);
77   - clearTimeout(this.linkControle.timeOutClose);
78   - };
79   - ul.onmouseout = ul.onblur =
80   - function () {
81   - if ( this.blurCalledByIEWorkArroundBug ) { return false }
82   - this.blurCalledByIEWorkArroundBug = true;
83   - this.timeOutClose = setTimeout( this.closeSubMenu.bind(this), window.menuCloseTimeout );
84   - };
85   - });
86   -
87   -
88   - // **** begin of workaround for Microsoft Internet Explorer ****
89   - // MS IE sucks, BTW.
90   - if ( document.all ) {
91   - function forceUlFocusFromLink ( a ) {
92   - /*var stop = false;
93   - a.ancestors().each( function(el) {
94   - if ( el.id == "menu" ) { stop = true }
95   - if ( ! stop && el.onfocus ) { el.onfocus() }
96   - } );*/
97   - var el = a.parentNode;
98   - while ( / menuRoot/.test(el.className) ) el = el.parentNode;
99   - if ( el.onfocus ) { el.onfocus() }
100   - }
101   - function forceUlBlurFromLink ( a ) {
102   - /*var stop = false;
103   - a.ancestors().each( function(el) {
104   - if ( el.id == "menu" ) { stop = true }
105   - if ( ! stop && el.onblur ) { el.onblur() }
106   - } );*/
107   - var el = a.parentNode;
108   - while ( / menuRoot/.test(el.className) ) el = el.parentNode;
109   - if ( el.onblur ) { el.onblur() }
110   - }
111   - $$("#" + id + " ul ul a").each( function( a ) {
112   - // os links do sub menu forçarão o foco do ul
113   - if ( a.className == "linkSubMenu" ) {
114   - a.onfocus = function() {
115   - forceUlFocusFromLink(this);
116   - this.openSubMenu(false);
117   - };
118   - a.onblur = function() {
119   - forceUlBlurFromLink(this);
120   - this.timeOutClose = setTimeout( this.closeSubMenu.bind(this), window.menuCloseTimeout );
121   - };
122   - } else {
123   - a.onfocus = function() { forceUlFocusFromLink(this) };
124   - a.onblur = function() { forceUlBlurFromLink(this) };
125   - }
126   - });
127   - } // ** end of workaround for Microsoft Internet Explorer.
128   -
129   -}
public/stylesheets/application.css
... ... @@ -907,7 +907,6 @@ code input {
907 907  
908 908 #user_menu {
909 909 border: none; /* work arround IE Bug */
910   - background: transparent; /* work arround IE Bug */
911 910 }
912 911  
913 912 #user_menu_head {
... ... @@ -928,7 +927,6 @@ code input {
928 927 margin-left: 4px;
929 928 }
930 929 #user_menu a#link_login:hover {
931   - background: none;
932 930 }
933 931  
934 932 #user_box a#link_go_home {
... ...