This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmf_gig_calendar_admin.js
142 lines (121 loc) · 3.9 KB
/
mf_gig_calendar_admin.js
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//$().ready(function() {
jQuery(document).ready(function( $ ) {
/*
$(".datepicker").datepicker({ // Show the 'close' and 'today' buttons
showButtonPanel: true,
closeText: objectL10n.closeText,
currentText: objectL10n.currentText,
monthNames: objectL10n.monthNames,
monthNamesShort: objectL10n.monthNamesShort,
dayNames: objectL10n.dayNames,
dayNamesShort: objectL10n.dayNamesShort,
dayNamesMin: objectL10n.dayNamesMin,
firstDay: objectL10n.firstDay,
isRTL: objectL10n.isRTL,
dateFormat: 'yy-mm-dd',
onSelect: function(dates) {
if ($("#multi").is(':checked')) {
// check the end day is greater
if ($("#start_date").val() > $("#end_date").val()) {
$("#end_date").val($("#start_date").val());
}
}
else {
// single day! make em match
$("#end_date").val($("#start_date").val());
}
}
});
if ($("#start_date").val() == $("#end_date").val()) {
$("#end_date_row").hide();
}
else {
$("#multi").attr('checked', true);
}
$("#multi").click(function() {
if (this.checked) {
$("#end_date").val($("#start_date").val());
$("#end_date_row").fadeIn();
}
else {
$("#end_date_row").fadeOut();
$("#end_date").val($("#start_date").val());
}
});
*/
$(".mfgig-datepicker").datepicker({
currentText: objectL10n.currentText,
monthNames: objectL10n.monthNames,
monthNamesShort: objectL10n.monthNamesShort,
dayNames: objectL10n.dayNames,
dayNamesShort: objectL10n.dayNamesShort,
dayNamesMin: objectL10n.dayNamesMin,
firstDay: objectL10n.firstDay,
isRTL: objectL10n.isRTL,
dateFormat: 'yy-mm-dd',
defaultDate: $("#start_date").val(),
numberOfMonths: 2,
beforeShowDay: function(date) {
var date1 = $.datepicker.parseDate('yy-mm-dd', $("#start_date").val());
var date2 = $.datepicker.parseDate('yy-mm-dd', $("#end_date").val());
return [true, date1 && ((date.getTime() == date1.getTime()) || (date2 && date >= date1 && date <= date2)) ? "dp-highlight" : ""];
},
onSelect: function(dateText, inst) {
var date1 = $.datepicker.parseDate('yy-mm-dd', $("#start_date").val());
var date2 = $.datepicker.parseDate('yy-mm-dd', $("#end_date").val());
var selectedDate = $.datepicker.parseDate('yy-mm-dd', dateText);
if (!date1 || date2) {
$("#start_date").val(dateText);
$("#end_date").val("");
$(this).datepicker();
} else if( selectedDate < date1 ) {
$("#end_date").val( $("#start_date").val() );
$("#start_date").val( dateText );
$(this).datepicker();
} else {
$("#end_date").val(dateText);
$(this).datepicker();
}
}
});
$("#start_date, #end_date").blur(function() {
$(".mfgig-datepicker").datepicker( "setDate", $("#start_date").val() );
$(".mfgig-datepicker").datepicker( "setDate", $("#end_date").val() );
});
// form validation
required = ["title", "start_date"];
// If using an ID other than #email or #error then replace it here
errornotice = $("#mfgigcal_error_message");
$("#edit_event_form").submit(function(){
//Validate required fields
for (i=0;i<required.length;i++) {
var input = $('#'+required[i]);
if (input.val() == "") {
input.addClass("needsfilled");
$(".required").css({'color' : 'red', 'font-weight' : 'bold'});
errornotice.fadeIn(750);
} else {
input.removeClass("needsfilled");
}
}
//if any inputs on the page have the class 'needsfilled' the form will not submit
if ($(":input").hasClass("needsfilled")) {
return false;
} else {
errornotice.hide();
return true;
}
});
// Clears any fields in the form when the user clicks on them
$(":input").focus(function(){
if ($(this).hasClass("needsfilled") ) {
$(this).val("");
$(this).removeClass("needsfilled");
}
});
});
function mfgigcal_DeleteEvent(id) {
if (confirm("Are you sure you want to delete this event from you the database? This is a permanent action.")) {
document.location.href = "?page=mf_gig_calendar&id=" + id + "&action=delete";
}
}