move js of template to the bottom of the page and migrate toggle js to jquery

yslow states that loading of page is faster when js is at the bottom
This commit is contained in:
Reinier Balt 2009-03-30 23:01:17 +02:00
parent f0e5c3841d
commit 33e96dd42e
2 changed files with 34 additions and 34 deletions

View file

@ -21,33 +21,6 @@
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => "RSS feed of next actions"}) %>
<link rel="search" type="application/opensearchdescription+xml" title="Tracks" href="<%= search_plugin_path %>" />
<script type="text/javascript">
jQuery(document).ready(function() { /* main menu */
jQuery('ul.sf-menu').superfish({
delay: 250,
animation: {opacity:'show',height:'show'},
autoArrows: false,
dropShadows: false,
speed: 'fast'
});
jQuery('ul.sf-item-menu').superfish({ /* context menu */
delay: 100,
animation: {opacity:'show',height:'show'},
autoArrows: false,
dropShadows: false,
speed: 'fast',
onBeforeShow: function() { /* highlight todo */
$(this.parent().parent().parent()).addClass("sf-item-selected");
},
onHide: function() { /* remove hightlight from todo */
$(this.parent().parent().parent()).removeClass("sf-item-selected");
}
});
Nifty("div#todo_new_action_container","normal");
if ($('flash').visible()) { new Effect.Fade("flash",{duration:5.0}); }
});
</script>
<title><%= @page_title %></title>
</head>
@ -62,10 +35,8 @@
</h1>
</div>
<div id="minilinks">
<%= link_to_function("Toggle notes", nil, {:accesskey => "S", :title => "Toggle all notes", :id => "toggle-notes-nav"}) do |page|
page.select('body .todo_notes').each { |e| e.toggle }
end
-%>&nbsp;|&nbsp;
<%= link_to("Toggle notes", "#", {:accesskey => "S", :title => "Toggle all notes", :id => "toggle-notes-nav"}) %>
&nbsp;|&nbsp;
<%= link_to "Logout (#{current_user.display_name}) »", logout_path %>
</div>
<div id="navcontainer">
@ -118,5 +89,36 @@
</div>
<%= render :partial => "shared/footer" %>
<script type="text/javascript">
jQuery(document).ready(function() { /* main menu */
jQuery('ul.sf-menu').superfish({
delay: 250,
animation: {opacity:'show',height:'show'},
autoArrows: false,
dropShadows: false,
speed: 'fast'
});
jQuery('ul.sf-item-menu').superfish({ /* context menu */
delay: 100,
animation: {opacity:'show',height:'show'},
autoArrows: false,
dropShadows: false,
speed: 'fast',
onBeforeShow: function() { /* highlight todo */
$(this.parent().parent().parent()).addClass("sf-item-selected");
},
onHide: function() { /* remove hightlight from todo */
$(this.parent().parent().parent()).removeClass("sf-item-selected");
}
});
/* for toggle notes link in mininav */
jQuery("#toggle-notes-nav").click(function () { jQuery(".todo_notes").toggle(); });
/* show the notes of a todo */
jQuery(".show_notes").click(function () { jQuery(this).next().toggle("fast"); return false; });
Nifty("div#todo_new_action_container","normal");
if ($('flash').visible()) { new Effect.Fade("flash",{duration:5.0}); }
});
</script>
</body>
</html>

View file

@ -1,7 +1,5 @@
<%= link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_notes', :title => 'Show notes'}) %>
<% apply_behavior 'a.show_notes:click', :prevent_default => true do |page, element|
element.next('.todo_notes').toggle
end -%>
<div class="todo_notes" id="<%= dom_id(item, 'notes') %>" style="display:none">
<%= sanitize(markdown( auto_link(item.notes)) ) %>
</div>