make sure that new/updated todos also get the behavior enabled for toggling notes

This commit is contained in:
Reinier Balt 2009-03-31 09:56:23 +02:00
parent 33e96dd42e
commit 480af3a2ab
5 changed files with 27 additions and 11 deletions

View file

@ -115,7 +115,7 @@
/* for toggle notes link in mininav */ /* for toggle notes link in mininav */
jQuery("#toggle-notes-nav").click(function () { jQuery(".todo_notes").toggle(); }); jQuery("#toggle-notes-nav").click(function () { jQuery(".todo_notes").toggle(); });
/* show the notes of a todo */ /* show the notes of a todo */
jQuery(".show_notes").click(function () { jQuery(this).next().toggle("fast"); return false; }); TodoBehavior.enableToggleNotes();
Nifty("div#todo_new_action_container","normal"); Nifty("div#todo_new_action_container","normal");
if ($('flash').visible()) { new Effect.Fade("flash",{duration:5.0}); } if ($('flash').visible()) { new Effect.Fade("flash",{duration:5.0}); }
}); });

View file

@ -20,6 +20,8 @@ if @saved
page.visual_effect :highlight, dom_id(@todo), :duration => 3 page.visual_effect :highlight, dom_id(@todo), :duration => 3
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
end end
# make sure the behavior of the new/updated todo is enabled
page << "TodoBehavior.enableToggleNotes()"
page['tickler-empty-nd'].hide if source_view_is :deferred page['tickler-empty-nd'].hide if source_view_is :deferred
end end
else else

View file

@ -47,3 +47,5 @@ if @saved
else else
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this action from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation") page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this action from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
end end
# make sure the behavior of the new/updated todo is enabled
page << "TodoBehavior.enableToggleNotes()"

View file

@ -6,7 +6,8 @@ if @saved
status_message = 'Added new context / ' + status_message if @new_context_created status_message = 'Added new context / ' + status_message if @new_context_created
page.notify :notice, status_message, 5.0 page.notify :notice, status_message, 5.0
# update auto completer arrays for edit form in right column, only for pages with that form # update auto completer arrays for edit form in right column, only for pages
# with that form
unless source_view_is_one_of(:calendar) unless source_view_is_one_of(:calendar)
page << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}; contextAutoCompleter.changed = true" if @new_context_created page << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}; contextAutoCompleter.changed = true" if @new_context_created
page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true" if @new_project_created page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true" if @new_project_created
@ -123,7 +124,8 @@ if @saved
else else
logger.error "unexpected source_view '#{params[:_source_view]}'" logger.error "unexpected source_view '#{params[:_source_view]}'"
end end
# make sure the behavior of the new/updated todo is enabled
page << "TodoBehavior.enableToggleNotes()"
else else
page.show 'error_status' page.show 'error_status'
page.replace_html 'error_status', "#{error_messages_for('todo')}" page.replace_html 'error_status', "#{error_messages_for('todo')}"

View file

@ -19,6 +19,7 @@ var Login = {
new CookieManager().setCookie('preferred_auth', 'database'); new CookieManager().setCookie('preferred_auth', 'database');
} }
} }
var TracksForm = { var TracksForm = {
toggle: function(toggleDivId, formContainerId, formId, hideLinkText, hideLinkTitle, showLinkText, showLinkTitle) { toggle: function(toggleDivId, formContainerId, formId, hideLinkText, hideLinkTitle, showLinkText, showLinkTitle) {
$(formContainerId).toggle(); $(formContainerId).toggle();
@ -85,6 +86,13 @@ var TracksForm = {
} }
} }
var TodoBehavior = {
enableToggleNotes: function() {
jQuery(".show_notes").click(function () {
jQuery(this).next().toggle("fast"); return false;
});
}
}
// uncomment the next four lines for easier debugging with FireBug // uncomment the next four lines for easier debugging with FireBug
// Ajax.Responders.register({ // Ajax.Responders.register({
// onException: function(source, exception) { // onException: function(source, exception) {
@ -96,7 +104,9 @@ var TracksForm = {
Event.observe(window, 'load', function() { Event.observe(window, 'load', function() {
$A(document.getElementsByClassName('alert')).each(function(o) { $A(document.getElementsByClassName('alert')).each(function(o) {
o.opacity = 100.0 o.opacity = 100.0
Effect.Fade(o, {duration: 8.0}) Effect.Fade(o, {
duration: 8.0
})
}); });
}); });
@ -106,7 +116,7 @@ Event.observe(window, 'load', function() {
*/ */
CookieManager = Class.create(); CookieManager = Class.create();
CookieManager.prototype = CookieManager.prototype =
{ {
BROWSER_IS_IE: BROWSER_IS_IE:
(document.all (document.all
&& window.ActiveXObject && window.ActiveXObject