Fixed Trac #449: properly reload the current selection when the list of Favorite Organizations is a paginated list.

SVN:trunk[1525]
This commit is contained in:
Denis Flaven
2011-08-26 10:34:54 +00:00
parent a3dc8ab3d7
commit dd9cb27971

View File

@@ -63,7 +63,20 @@ function DisplayPreferences($oP)
// All checked
$oP->add_ready_script(
<<<EOF
var pager = $('#user_prefs form .pager');
if (pager.length > 0)
{
console.log("PAGINATED display");
// paginated display, restore the selection
$(':input[name=selectionMode]', pager).val('negative');
$('#user_prefs table.listResults').trigger('load_selection');
}
else
{
console.log("Non-paginated display");
CheckAll('#user_prefs .listResults :checkbox:not(:disabled)', true);
}
EOF
);
}
@@ -72,15 +85,32 @@ EOF
$sChecked = implode('","', $aFavoriteOrgs);
$oP->add_ready_script(
<<<EOF
$('#user_prefs form :checkbox[name^=selectObject]').each( function()
var aChecked = ["$sChecked"];
var pager = $('#user_prefs form .pager');
if (pager.length > 0)
{
console.log("PAGINATED display");
// paginated display, restore the selection
$(':input[name=selectionMode]', pager).val('positive');
for (i=0; i<aChecked.length; i++)
{
var aChecked = ["$sChecked"];
if ($.inArray($(this).val(), aChecked) > -1)
pager.append('<input type="hidden" name="storedSelection[]" id="'+aChecked[i]+'" value="'+aChecked[i]+'"/>');
}
$('#user_prefs table.listResults').trigger('load_selection');
}
else
{
console.log("Non-paginated display");
$('#user_prefs form :checkbox[name^=selectObject]').each( function()
{
$(this).attr('checked', true);
$(this).trigger('change');
}
});
if ($.inArray($(this).val(), aChecked) > -1)
{
$(this).attr('checked', true);
$(this).trigger('change');
}
});
}
EOF
);
}}