-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar-calendar.php
118 lines (107 loc) · 4.46 KB
/
sidebar-calendar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
$keywords = !empty( $_GET['keywords'] ) ? $_GET['keywords'] : '';
$datefilter = !empty( $_GET['dates'] ) ? $_GET['dates'] : '';
$location = !empty( $_GET['location'] ) ? $location = $_GET['location'] : '';
?>
<aside id="sidebar">
<section id="eventfilters">
<h2>Event <strong>Filters</strong></h2>
<form action="<?php bloginfo('siteurl'); ?>/calendar/" id="eventcalfilterform" method="get" onReset="clearFilters()">
<section id="eventcalkeywordfilter">
<label for="keywords">Keywords</label>
<input type="text" id="eventcalkeywords" name="keywords" value="<?php echo $keywords; ?>" />
</section>
<section id="eventcaldatefilter">
<label for="dates">Date</label>
<input type="hidden" id="eventcaldates" name="dates" value="<?php echo $datefilter; ?>" />
<div id="eventcaldatepicker">
<div id="datepickeryears">
<div class="placeholder">
<span id="prevyear"><i class="far fa-fw fa-arrow-circle-left"></i></span>
</div><!-- .placeholder -->
<span id="datepickeryear" class="text-xl"><input id="yearvalue" type="text" disabled="true" /></span>
<div class="placeholder">
<span id="nextyear"><i class="far fa-fw fa-arrow-circle-right"></i></span>
</div><!-- .placeholder -->
</div><!-- #datepickeryears -->
<div id="datepickermonths"></div>
<script type="text/javascript">
var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
window.d = new Date();
if ( $('#eventcaldates').val() ) {
var olddate = new Date( parseInt($('#eventcaldates').val()) );
var year = olddate.getFullYear();
var month = olddate.getMonth();
var dateFiltered = true;
} else {
var year = d.getFullYear();
var month = d.getMonth();
};
$('#yearvalue').val(year).change();
if ( $('#yearvalue').val() >= d.getFullYear() - 1 ) {
$('#prevyear').fadeIn();
}
if ( $('#yearvalue').val() <= d.getFullYear() + 1 ) {
$('#nextyear').fadeIn();
}
for (var i = 0; i < monthNames.length; i++ ) {
$('#datepickermonths').append('<div data-month=' + i + '>' + monthNames[i].substr(0,3) + '</div>');
};
if ( dateFiltered ) {
$('#datepickermonths div[data-month=' + month + ']').addClass('filteredmonth', 500);
};
$('#prevyear').click( function() {
var newYear = parseInt( $('#yearvalue').val() ) - 1;
$('#yearvalue').val(newYear).change();
});
$('#nextyear').click( function() {
var newYear = parseInt( $('#yearvalue').val() ) + 1;
$('#yearvalue').val(newYear).change();
});
$('#yearvalue').change( function() {
if ( $(this).val() <= d.getFullYear() - 2 ) {
$('#prevyear').fadeOut();
} else {
$('#prevyear').fadeIn();
}
if ( $(this).val() >= d.getFullYear() + 2 ) {
$('#nextyear').fadeOut();
} else {
$('#nextyear').fadeIn();
}
if ( $(this).val() == year ) {
$('div[data-month=' + month + ']').addClass('filteredmonth', 500);
} else {
$('div[data-month=' + month + ']').removeClass('filteredmonth', 500);
}
});
$('#datepickermonths div').click( function() {
if ( year == $('#yearvalue').val() && month == $(this).attr('data-month') ) {
$(this).removeClass('filteredmonth', 500);
year = "";
month = "";
$('#eventcaldates').val('');
} else {
year = $('#yearvalue').val();
month = $(this).attr('data-month');
$('.filteredmonth').removeClass('filteredmonth', 500);
$(this).addClass('filteredmonth', 500);
var newdate = new Date((parseInt(month)+1) + ' 1, ' + year);
$('#eventcaldates').val(newdate.getTime());
}
});
function clearFilters(){
$('#eventcalkeywords').val("");
$('#eventcaldates').val("");
$('form#eventcalfilterform').submit();
}
</script>
</div>
</section>
<section id="eventcalbuttons" class="space-top-1x">
<input type="submit" id="eventcalfiltersubmit" value="Search" class="btn btn-red mr-3" />
<input type="button" id="eventcalfilterclear" value="Clear" onClick="clearFilters()" class="btn btn-outline-dark" />
</section><!-- #eventcalbuttons -->
</form>
</section>
</aside>