summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-09-16 17:06:57 +0200
committerBart Visscher <bartv@thisnet.nl>2011-09-16 17:06:57 +0200
commit45d42a96549e8661bb18c5f8d407641d5362240a (patch)
treeef958463d66b752ba30549ef7252bd003eea83b6
parent73d3dc91fdcd106eedb73caa1f970b59f2814c71 (diff)
downloadnextcloud-server-45d42a96549e8661bb18c5f8d407641d5362240a.tar.gz
nextcloud-server-45d42a96549e8661bb18c5f8d407641d5362240a.zip
Move validateEventForm function and fix success handling
-rw-r--r--apps/calendar/ajax/editevent.php4
-rw-r--r--apps/calendar/js/calendar.js79
-rw-r--r--apps/calendar/templates/part.editevent.php2
-rw-r--r--apps/calendar/templates/part.newevent.php2
4 files changed, 43 insertions, 44 deletions
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php
index d8dae7a324b..aef2e6f78b4 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/editevent.php
@@ -24,7 +24,7 @@ if(!OC_USER::isLoggedIn()) {
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){
//show validate errors
- $errarr["error"] = "true";
+ $errarr['status'] = 'error';
echo json_encode($errarr);
exit;
}else{
@@ -48,6 +48,6 @@ if($errarr){
$calendar = OC_Calendar_Calendar::findCalendar($request['calendar']);
OC_Calendar_Object::moveToCalendar($id, $cal);
}
- echo json_encode(array("success"=>"true"));
+ echo json_encode(array('status' => 'success'));
}
?>
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index d18a9573742..c0629bab625 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -322,6 +322,45 @@ Calendar={
});
}
},
+ validateEventForm:function(url){
+ var post = $( "#event_form" ).serialize();
+ $("#errorbox").html("");
+ $.post(url, post,
+ function(data){
+ if(data.status == "error"){
+ var output = "Missing fields: <br />";
+ if(data.title == "true"){
+ output = output + "Title<br />";
+ }
+ if(data.cal == "true"){
+ output = output + "Calendar<br />";
+ }
+ if(data.from == "true"){
+ output = output + "From Date<br />";
+ }
+ if(data.fromtime == "true"){
+ output = output + "From Time<br />";
+ }
+ if(data.to == "true"){
+ output = output + "To Date<br />";
+ }
+ if(data.totime == "true"){
+ output = output + "To Time<br />";
+ }
+ if(data.endbeforestart == "true"){
+ output = "The event ends before it starts!";
+ }
+ if(data.dberror == "true"){
+ output = "There was a database fail!";
+ }
+ $("#errorbox").html(output);
+ } else
+ if(data.status == 'success'){
+ $('#event').dialog('destroy').remove();
+ Calendar.UI.loadEvents();
+ }
+ },"json");
+ },
createEventPopup:function(e){
var popup = $(this).data('popup');
if (!popup){
@@ -808,43 +847,3 @@ $(document).ready(function(){
//event vars
Calendar.UI.loadEvents();
-function validate_event_form(url){
- var post = $( "#event_form" ).serialize();
- $("#errorbox").html("");
- $.post(url, post,
- function(data){
- if(data.error == "true"){
- var output = "Missing fields: <br />";
- if(data.title == "true"){
- output = output + "Title<br />";
- }
- if(data.cal == "true"){
- output = output + "Calendar<br />";
- }
- if(data.from == "true"){
- output = output + "From Date<br />";
- }
- if(data.fromtime == "true"){
- output = output + "From Time<br />";
- }
- if(data.to == "true"){
- output = output + "To Date<br />";
- }
- if(data.totime == "true"){
- output = output + "To Time<br />";
- }
- if(data.endbeforestart == "true"){
- output = "The event ends before it starts!";
- }
- if(data.dberror == "true"){
- output = "There was a database fail!";
- }
- $("#errorbox").html(output);
- }else{
- window.location.reload();
- }
- if(data.success == true){
- location.reload();
- }
- },"json");
-}
diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php
index 8c6053dc88a..859828216b8 100644
--- a/apps/calendar/templates/part.editevent.php
+++ b/apps/calendar/templates/part.editevent.php
@@ -4,7 +4,7 @@
<?php echo $this->inc("part.eventform"); ?>
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
<span id="actions">
- <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="validate_event_form('ajax/editevent.php');">
+ <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');">
</span>
</form>
</div>
diff --git a/apps/calendar/templates/part.newevent.php b/apps/calendar/templates/part.newevent.php
index 2c8ba7b907d..b1e2a5eab84 100644
--- a/apps/calendar/templates/part.newevent.php
+++ b/apps/calendar/templates/part.newevent.php
@@ -3,7 +3,7 @@
<?php echo $this->inc("part.eventform"); ?>
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
<span id="actions">
- <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="validate_event_form('ajax/newevent.php');">
+ <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/newevent.php');">
</span>
</form>
</div>