fix #1245 by managing pages with more than one project in a list

Update still looks ugly. I'd like to see things more seperated for project list page and review page. Todo!
This commit is contained in:
Reinier Balt 2012-03-29 21:14:48 +02:00
parent af10e74017
commit ff4a376ee9
3 changed files with 18 additions and 14 deletions

View file

@ -3,8 +3,8 @@ function html_for_edit_form() {
}
function show_edit_form() {
$('div#<%=dom_id(@project, 'edit')%>').html(html_for_edit_form());
$('div#<%=dom_id(@project, 'edit')%>').fadeIn(500);
$('div.project-edit-current div#<%=dom_id(@project, 'edit')%>').html(html_for_edit_form());
$('div.project-edit-current div#<%=dom_id(@project, 'edit')%>').fadeIn(500);
$('div#project_name').editable('disable');
}
@ -12,12 +12,10 @@ function set_focus() {
$('input.project-name').focus();
}
function replace_project_with_edit_form() {
$('div#<%=dom_id(@project)%>').fadeOut(250, function() {
$('div.project-edit-current div#<%=dom_id(@project)%>').fadeOut(250, function() {
show_edit_form();
set_focus();
enable_rich_interaction();
});
}

View file

@ -24,6 +24,7 @@ function update_project_list_page() {
ProjectListPage.update_all_states_count(<%=@active_projects_count%>, <%=@hidden_projects_count%>, <%=@completed_projects_count%>);
ProjectListPage.show_or_hide_all_state_containers(<%= @show_active_projects %>, <%= @show_hidden_projects %>, <%= @show_completed_projects %>);
TracksForm.set_project_name_and_default_project_name("<%= escape_javascript(@project.name)%>");
$('div.project-edit-current').removeClass('project-edit-current');
}
function update_project_page() {
@ -44,7 +45,9 @@ function remove_project_edit_form() {
<%-
# do not remove() edit form as this will remove the DIV that is needed to replace with the new form, so only empty the DIV
-%>
$('#<%=dom_id(@project, 'edit')%>').hide(500, function() {$('#<%=dom_id(@project, 'edit')%>').html("<!- empty ->");} );
$('#<%=dom_id(@project, 'edit')%>').hide(500, function() {
$('#<%=dom_id(@project, 'edit')%>').html("<!- empty ->");
});
}
function update_and_show_project_settings() {
@ -53,17 +56,18 @@ function update_and_show_project_settings() {
}
function replace_project_form_with_updated_project() {
$('#<%=dom_id(@project, 'container')%>').fadeOut(250, function() {
$('div#<%=dom_id(@project, 'container')%>').each(function(index, elem) {
$(this).fadeOut(250, function() {
<%
# first add the updated project after the old one, then remove old one
# using html() does not work, because it will replace the _content_ of
# first add the updated project after the old one, then remove old one.
# Using html() does not work, because it will replace the _content_ of
# the container instead of the container itself, i.e. you will get
# a container within a container which will break drag-and-drop sorting
-%>
$('#<%=dom_id(@project, 'container')%>').after(html_for_project_listing());
$('#<%=dom_id(@project, 'container')%>').remove();
$(this).after(html_for_project_listing());
$(this).remove();
$('#<%=dom_id(@project, 'container')%>').fadeIn(500);
});
})});
}
function remove_and_re_add_project() {

View file

@ -770,6 +770,7 @@ var ProjectListPage = {
/* set behavior for edit project settings link in both projects list page and project page */
$("a.project_edit_settings").live('click', function (evt) {
$(this).parent().parent().addClass('project-edit-current'); /* mark project in list */
get_with_ajax_and_block_element(this.href, $(this).parent().parent());
return false;
});
@ -785,6 +786,7 @@ var ProjectListPage = {
$('form.edit-project-form a.negative').live('click', function(){
$('div#project_name').editable('enable');
$(this).parents('.edit-form').fadeOut(200, function () {
$(this).parents('.project-edit-current').removeClass('project-edit-current');
$(this).parents('.list').find('.project').fadeIn(500);
$(this).parents('.container').find('.item-show').fadeIn(500);
})