Move most javascript to calendar.js

This commit is contained in:
Bart Visscher 2011-09-16 17:50:55 +02:00
parent 45d42a9654
commit 2a84f7f07c
5 changed files with 33 additions and 46 deletions

View File

@ -179,9 +179,12 @@ Calendar={
alert('Unknown view:'+view);
break;
}
$('#'+this.currentview).show();
$('#'+this.currentview + "_radio").addClass('active');
this.updateView();
$(document).ready(function() {
$('#'+Calendar.UI.currentview).show();
$('#'+Calendar.UI.currentview + "_radio")
.addClass('active');
Calendar.UI.updateView()
});
},
updateDate:function(direction){
if(direction == 'forward' && this.current.forward) {
@ -277,6 +280,21 @@ Calendar={
.click(this.editEvent);
eventcontainer.append(event_holder);
},
startEventDialog:function(){
Calendar.UI.lockTime();
$( "#from" ).datepicker({
dateFormat : 'dd-mm-yy'
});
$( "#to" ).datepicker({
dateFormat : 'dd-mm-yy'
});
$('#event').dialog({
width : 500,
close : function(event, ui) {
$(this).dialog('destroy').remove();
}
});
},
newEvent:function(selector, time){
var date_info = $(selector).data('date_info');
var dayofmonth = date_info.getDate();
@ -294,14 +312,7 @@ Calendar={
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
$('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/neweventform.php?d=' + date + '&t=' + time, function(){
$('#event').dialog({
width : 500,
close : function(event, ui) {
$(this).dialog('destroy').remove();
}
});
});
$('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/neweventform.php?d=' + date + '&t=' + time, Calendar.UI.startEventDialog);
}
},
editEvent:function(event){
@ -312,14 +323,7 @@ Calendar={
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
$('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/editeventform.php?id=' + id, function(){
$('#event').dialog({
width : 500,
close : function(event, ui) {
$(this).dialog('destroy').remove();
}
});
});
$('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/editeventform.php?id=' + id, Calendar.UI.startEventDialog);
}
},
validateEventForm:function(url){
@ -420,6 +424,11 @@ Calendar={
.removeClass('disabled');
}
},
showCalDAVUrl:function(username, calname){
$('#caldav_url').val(totalurl + '/' + username + '/' + calname);
$('#caldav_url').show();
$("#caldav_url_close").show();
},
Calendar:{
overview:function(){
if($('#choosecalendar_dialog').dialog('isOpen') == true){
@ -846,4 +855,3 @@ $(document).ready(function(){
});
//event vars
Calendar.UI.loadEvents();

View File

@ -37,6 +37,9 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur
Calendar.UI.cws_label = "<?php echo $l->t("Weeks");?>";
Calendar.UI.more_before = String('<?php echo $l->t('More before {startdate}') ?>');
Calendar.UI.more_after = String('<?php echo $l->t('More after {enddate}') ?>');
//use last view as default on the next
Calendar.UI.setCurrentView("<?php echo OC_Preferences::getValue(OC_USER::getUser(), "calendar", "currentview", "onemonthview") ?>");
var totalurl = "<?php echo OC_Helper::linkTo('calendar', 'caldav.php', null, true) . '/calendars'; ?>";
</script>
<div id="sysbox"></div>
<div id="controls">
@ -166,10 +169,3 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur
<?php echo $l->t("There was a fail, while parsing the file."); ?>
</div>
<!-- End of Dialogs -->
<script type="text/javascript">
<?php
//use last view as default on the next
echo "Calendar.UI.setCurrentView(\"" . OC_Preferences::getValue(OC_USER::getUser(), "calendar", "currentview", "onemonthview") . "\");\n";
?>
</script>

View File

@ -17,15 +17,7 @@ for($i = 0; $i < count($option_calendars); $i++){
</tr>
<tr>
<td colspan="4">
<p style="margin: 0 auto;width: 90%;"><input style="display:none;width: 90%;float: left;" type="text" id="caldav_url" onmouseover="document.getElementById('caldav_url').select();" title="<?php echo $l->t("CalDav Link"); ?>"><img id="caldav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="../../core/img/actions/delete.svg" alt="close" onclick="document.getElementById('caldav_url').style.display = 'none';document.getElementById('caldav_url_close').style.display = 'none';"/></p>
<p style="margin: 0 auto;width: 90%;"><input style="display:none;width: 90%;float: left;" type="text" id="caldav_url" onmouseover="$('#caldav_url').select();" title="<?php echo $l->t("CalDav Link"); ?>"><img id="caldav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="../../core/img/actions/delete.svg" alt="close" onclick="$('#caldav_url').hide();$('#caldav_url_close').hide();"/></p>
</td>
</tr>
</table>
<script type="text/javascript">
var totalurl = "<?php echo ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].OC::$WEBROOT.'/apps/calendar/caldav.php/calendars'; ?>";
function showcaldavurl(username, calname){
document.getElementById("caldav_url").value = totalurl + "/" + username + "/" + calname;
document.getElementById("caldav_url").style.display = "block";
document.getElementById("caldav_url_close").style.display = "block";
}
</script>

View File

@ -1,4 +1,4 @@
<?php
echo "<td width=\"20px\"><input id=\"active_" . $_['calendar']["id"] . "\" type=\"checkbox\" onClick=\"Calendar.UI.Calendar.activation(this, " . $_['calendar']["id"] . ")\"" . ($_['calendar']["active"] ? ' checked="checked"' : '') . "></td>";
echo "<td><label for=\"active_" . $_['calendar']["id"] . "\">" . $_['calendar']["displayname"] . "</label></td>";
echo "<td width=\"20px\"><a href=\"#\" onclick=\"showcaldavurl('" . OC_User::getUser() . "', '" . $_['calendar']["uri"] . "');\" title=\"" . $l->t("CalDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?calid=" . $_['calendar']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td>";
echo "<td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.showCalDAVUrl('" . OC_User::getUser() . "', '" . $_['calendar']["uri"] . "');\" title=\"" . $l->t("CalDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?calid=" . $_['calendar']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td>";

View File

@ -85,12 +85,3 @@
<td><textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo $_['description'] ?></textarea></td>
</tr>
</table>
<script type="text/javascript">
Calendar.UI.lockTime();
$( "#from" ).datepicker({
dateFormat : 'dd-mm-yy'
});
$( "#to" ).datepicker({
dateFormat : 'dd-mm-yy'
});
</script>