Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Commit 7613543

Browse files
committed
change recurrence to button
1 parent 429365c commit 7613543

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

addEvent-json.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function getDatesInRange($dateFromString, $dateToString, $dow, $dowNum) {
4545
$end = explode(" ", $_POST['end']);
4646

4747
// if event is recurrence
48-
if ($_POST['recurrence'] == 'true') {
48+
if ($_POST['recurrence']) {
4949
// initialize vars
5050
$dateFromString = $start[0];
5151
$endDate = $_POST['endDate'];
@@ -80,7 +80,7 @@ function getDatesInRange($dateFromString, $dateToString, $dow, $dowNum) {
8080
$extra = array(
8181
'id' => ++$last_item_id,
8282
'rid' => $last_item_rid+1,
83-
'recurrence' => $_POST['recurrence'],
83+
'recurrence' => 'true',
8484
'title' => $_POST['title'],
8585
'description' => $_POST['description'],
8686
'start' => $_POST['start'],
@@ -105,7 +105,7 @@ function getDatesInRange($dateFromString, $dateToString, $dow, $dowNum) {
105105
// add date to array
106106
$extra = array(
107107
'id' => ++$last_item_id,
108-
'recurrence' => $_POST['recurrence'],
108+
'recurrence' => 'false',
109109
'title' => $_POST['title'],
110110
'description' => $_POST['description'],
111111
'start' => $_POST['start'],

index-json.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,24 @@
124124
<input type="text" name="description" class="form-control" id="description" placeholder="Description">
125125
</div>
126126
</div>
127-
<div class="form-group">
128-
<label for="recurrence" class="col-sm-12 control-label">Recurrence</label>
127+
<div class="form-group">
128+
<label class="col-sm-12 control-label">Recurrence</label>
129129
<div class="col-sm-12">
130-
<select name="recurrence" class="form-control" id="recurrence">
131-
<option id="false" selected="selected" value="false">no</option>
132-
<option id="true" value="true">yes</option>
133-
</select>
130+
<label class="recurrence label-off" for="rec" id="recurrence">Enable
131+
<input class="nocheckbox" type="checkbox" id="rec" name="recurrence" value="recurrence"></label>
134132
</div>
135133
</div>
136134
</div>
137135
<script>
138-
$('#recurrence').change(function () {
139-
if ($(this).val() === 'true') {
136+
$('#rec').change(function () {
137+
var self = $(this);
138+
var aValue = self.attr("value");
139+
if ( $(self).is(':checked') ) {
140140
$('#recurrence-form').show();
141+
$("." + aValue).removeClass('label-off').addClass('label-on');
141142
} else {
142143
$('#recurrence-form').hide();
144+
$("." + aValue).removeClass('label-on').addClass('label-off');
143145
}
144146
});
145147
</script>

0 commit comments

Comments
 (0)