Using jquery button. Now called showDownloaded (defaults to on)

This commit is contained in:
Mark McDowall 2012-02-22 11:52:31 -08:00
parent d0f7833ac8
commit fc087fde9f
1 changed files with 22 additions and 17 deletions

View File

@ -9,7 +9,8 @@
<style> <style>
.gridControls { .gridControls {
float: right; float: right;
padding: 0px 5px 25px 0px; padding: 0px 5px 20px 0px;
visibility: hidden;
} }
</style> </style>
} }
@ -20,7 +21,8 @@
} }
<div class="gridControls"> <div class="gridControls">
@Html.CheckBox("hideDownloaded") Hide Downloaded @Html.CheckBox("showDownloaded", true)
<label for="showDownloaded">Show Downloaded</label>
</div> </div>
<table class="seriesTable"> <table class="seriesTable">
@ -130,45 +132,48 @@
@section Scripts{ @section Scripts{
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
var cookieValue = $.cookie("hideDownloaded"); var cookieValue = $.cookie("showDownloaded");
if (cookieValue == "true") { if (cookieValue == "false") {
$('#hideDownloaded').attr('checked', true); $('#showDownloaded').attr('checked', false);
toggleDownloaded(true); toggleDownloaded(false);
} }
else { else {
$('#hideDownloaded').attr('checked', false); $('#showDownloaded').attr('checked', true);
toggleDownloaded(false); toggleDownloaded(true);
} }
$('#showDownloaded').button();
$('.gridControls').css('visibility', 'visible');
}); });
$('#hideDownloaded').on('change', function () { $('#showDownloaded').on('change', function () {
var checked = $(this).attr('checked'); var checked = $(this).attr('checked');
toggleDownloaded(checked); toggleDownloaded(checked);
toggleHideDownloadedCookie(checked); toggleHideDownloadedCookie(checked);
}); });
function toggleDownloaded(hide) { function toggleDownloaded(show) {
var ready = $('.statusImage[title="Ready"]'); var ready = $('.statusImage[title="Ready"]');
ready.each(function () { ready.each(function () {
if (hide) { if (show) {
$(this).parents('tr').hide(); $(this).parents('tr').show();
} }
else { else {
$(this).parents('tr').show(); $(this).parents('tr').hide();
} }
}); });
} }
function toggleHideDownloadedCookie(hide) { function toggleHideDownloadedCookie(show) {
if (hide) if (show)
$.cookie("hideDownloaded", true, { expires: 365 }); $.cookie("showDownloaded", true, { expires: 365 });
else else
$.cookie("hideDownloaded", false, { expires: 365 }); $.cookie("showDownloaded", false, { expires: 365 });
} }
</script> </script>
} }