From 6fa84e30ac0b6b65e740882356971f61b903992d Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Sun, 12 Jan 2014 15:53:37 +0100 Subject: [PATCH 01/22] Relocated controls, custom datepicker styling. --- .gitignore | 1 + css/style.css | 122 ++++++++++++++++++++++++++++++++++- js/calendar.js | 3 +- nbproject/project.properties | 5 ++ nbproject/project.xml | 9 +++ templates/calendar.php | 47 +++++++++----- 6 files changed, 168 insertions(+), 19 deletions(-) create mode 100644 .gitignore create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9ee866037 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/calendar/nbproject/private \ No newline at end of file diff --git a/css/style.css b/css/style.css index af0c72d41..9014139f2 100644 --- a/css/style.css +++ b/css/style.css @@ -23,7 +23,7 @@ bottom: 0; right: 0; left: 0; - top: 43px; + top: 0; } #listview {margin: 0; padding: 10px; background: #EEEEEE;} #listview #more_before, #listview #more_after {border: 1px solid #1a1a1a; width:25em;padding: 3px;text-align: center;} @@ -275,3 +275,123 @@ button.category{margin:0 3px;} background-repeat: no-repeat; background-position: center; } + +#app-navigation { + width: 250px; +} + +#app-settings { + width: 249px; +} + +#navigation-list li { + min-height: 44px; + padding: 6px; +} +#navigation-list form { + width: 100%; +} + +#navigation-list input[type=button], #navigation-list button { + height: 34px; + padding: 8px; + margin: 0; +} + +#onedayview_radio { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-right: 0; +} + +#oneweekview_radio { + border-radius: 0; +} + +#onemonthview_radio { + border-top-left-radius: 0; + border-bottom-left-radius: 0; + border-left: 0; +} + +#datecontrol_current { + float: left; + width: 168px; + height: 26px; + padding-top: 6px; + background-color: white; + border: 1px solid rgba(190, 190, 190, 0.9); + border-radius: 3px; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + color: rgb(85, 85, 85); + font-weight: bold; + text-align: center; + overflow: hidden; +} + +#datecontrol_left { + border-radius: 0; + border-left: 0; +} + +#datecontrol_right { + border-top-left-radius: 0; + border-bottom-left-radius: 0; + border-left: 0; +} + +#datecontrol_today { + float: right; +} + +#datecontrol_date select { + padding: 0; +} + +#datecontrol_date .ui-datepicker-prev { + position: relative; + float: left; +} + +#datecontrol_date .ui-datepicker-next { + position: relative; + float: left; +} + +#datecontrol_date ui-datepicker-inline, +#datecontrol_date .ui-widget-header, +#datecontrol_date .ui-datepicker-title, +#datecontrol_date .ui-datepicker-prev, +#datecontrol_date .ui-datepicker-next, +#datecontrol_date .ui-widget-content { + background: 0; + border: 0; + margin: 0; + padding: 0; + color: rgb(85, 85, 85); + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +#datecontrol_date .ui-datepicker-inline { + width: 100%; +} + +#datecontrol_date table a { + text-align: center; +} + +#datecontrol_date table thead th { + padding-top: 0px; +} + +#datecontrol_date .ui-datepicker-month, +#datecontrol_date .ui-datepicker-year, +#datecontrol_date .ui-datepicker-prev, +#datecontrol_date .ui-datepicker-next, +#datecontrol_date .ui-datepicker-current { + display: none; +} \ No newline at end of file diff --git a/js/calendar.js b/js/calendar.js index 80637d73f..873a6e2ac 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -874,7 +874,8 @@ $(document).ready(function(){ dayNamesShort: dayNamesShort, allDayText: allDayText, viewDisplay: function(view) { - $('#datecontrol_date').val($('

').html(view.title).text()); + $('#datecontrol_current').html($('

').html(view.title).text()); + $( "#datecontrol_date" ).datepicker("setDate", $('#fullcalendar').fullCalendar('getDate')); if (view.name != defaultView) { $.post(OC.filePath('calendar', 'ajax', 'changeview.php'), {v:view.name}); defaultView = view.name; diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 000000000..8274ffdeb --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,5 @@ +config.folder= +file.reference.apps-calendar=. +files.encoding=UTF-8 +site.root.folder=${file.reference.apps-calendar} +test.folder= diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 000000000..a2fa7657d --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.web.clientproject + + + calendar + + + diff --git a/templates/calendar.php b/templates/calendar.php index a71b50eec..289486f9c 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -1,23 +1,36 @@

-
-
- - -    - -
-
- - -
-
- - - - -
+
+ +
+
+ +
+
+ Test 123 +
+
From cd700e637e29272cc6af656331d6814fa8b868d8 Mon Sep 17 00:00:00 2001 From: Jan ten Bokkel <> Date: Wed, 15 Jan 2014 14:05:32 +0100 Subject: [PATCH 02/22] Add expand/collapse animation to datepicker. --- .gitignore | 3 ++- css/style.css | 26 +++++++++++++++++--------- js/calendar.js | 4 ++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 9ee866037..4d02d1680 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/calendar/nbproject/private \ No newline at end of file +/calendar/nbproject/private +/nbproject/private/ \ No newline at end of file diff --git a/css/style.css b/css/style.css index 9014139f2..ce002e79e 100644 --- a/css/style.css +++ b/css/style.css @@ -283,11 +283,6 @@ button.category{margin:0 3px;} #app-settings { width: 249px; } - -#navigation-list li { - min-height: 44px; - padding: 6px; -} #navigation-list form { width: 100%; } @@ -295,10 +290,14 @@ button.category{margin:0 3px;} #navigation-list input[type=button], #navigation-list button { height: 34px; padding: 8px; - margin: 0; + margin-top: 6px; + margin-left: 0px; + margin-right: 0px; + margin-bottom: 0px; } -#onedayview_radio { +#navigation-list #onedayview_radio { + margin-left: 6px; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; @@ -316,8 +315,10 @@ button.category{margin:0 3px;} #datecontrol_current { float: left; - width: 168px; + width: 169px; height: 26px; + margin-top: 6px; + margin-left: 6px; padding-top: 6px; background-color: white; border: 1px solid rgba(190, 190, 190, 0.9); @@ -331,18 +332,25 @@ button.category{margin:0 3px;} } #datecontrol_left { + margin-top: 6px; border-radius: 0; border-left: 0; } #datecontrol_right { + margin-top: 6px; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; } -#datecontrol_today { +#navigation-list #datecontrol_today { float: right; + margin-right: 6px; +} + +#datecontrol_date { + margin: 6px 6px 0 6px; } #datecontrol_date select { diff --git a/js/calendar.js b/js/calendar.js index 873a6e2ac..03570d669 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -953,6 +953,10 @@ $(document).ready(function(){ $('#datecontrol_right').click(function(){ $('#fullcalendar').fullCalendar('next'); }); + $('#datecontrol_current').click(function() { + $('#datecontrol_date').slideToggle(500); + }); + $('#datecontrol_date').hide(); Calendar.UI.Share.init(); Calendar.UI.Drop.init(); $('#choosecalendar .generalsettings').on('click keydown', function(event) { From 2fac2fe3218a98f3fa2dba6153f71cbcb6da7a4e Mon Sep 17 00:00:00 2001 From: Jan ten Bokkel <> Date: Mon, 20 Jan 2014 13:55:43 +0100 Subject: [PATCH 03/22] Additional styling for calendar navbar. --- css/style.css | 47 ++++++++ js/calendar.js | 28 ++++- templates/calendar.php | 127 +++++++++++++++++++- templates/part.choosecalendar.rowfields.php | 85 +++++++------ templates/part.editcalendar.php | 42 +++---- 5 files changed, 256 insertions(+), 73 deletions(-) diff --git a/css/style.css b/css/style.css index ce002e79e..74971304f 100644 --- a/css/style.css +++ b/css/style.css @@ -285,6 +285,7 @@ button.category{margin:0 3px;} } #navigation-list form { width: 100%; + margin-bottom: 3px; } #navigation-list input[type=button], #navigation-list button { @@ -402,4 +403,50 @@ button.category{margin:0 3px;} #datecontrol_date .ui-datepicker-next, #datecontrol_date .ui-datepicker-current { display: none; +} + +#app-navigation li { + min-height: 44px; +} + +#app-navigation li:nth-child(2) { + min-height: 0; +} + +#app-navigation li .action { + width: 16px; + height: 16px; + margin-left: 2px; + background-size: auto; +} + +#app-navigation label { + vertical-align: text-bottom; +} + +#app-navigation input[type=checkbox] { + margin-left: 6px; + margin-top: 13px; +} + +#app-navigation .utils { + position: relative; + padding: 13px 7px 0 0; + float: right; +} + +#app-navigation li[data-id]:hover { + background-color: rgb(221, 221, 221); +} + +#newCalendar:before { + position: absolute; + content: '+'; + font-weight: bold; + font-size: 150%; + left: 7px; +} + +#newCalendar { + padding-left: 23px !important; } \ No newline at end of file diff --git a/js/calendar.js b/js/calendar.js index 03570d669..de0cc3cfa 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -455,7 +455,7 @@ Calendar={ var tr = $(document.createElement('tr')) .load(OC.filePath('calendar', 'ajax/calendar', 'new.form.php'), function(){Calendar.UI.Calendar.colorPicker(this)}); - $(object).closest('tr').after(tr).hide(); + $("#navigation-list").append(tr); }, edit:function(object, calendarid){ var tr = $(document.createElement('tr')) @@ -957,11 +957,29 @@ $(document).ready(function(){ $('#datecontrol_date').slideToggle(500); }); $('#datecontrol_date').hide(); + $('#app-settings-header').on('click keydown',function(event) { + if(wrongKey(event)) { + return; + } + var bodyListener = function(e) { + if($('#app-settings').find($(e.target)).length === 0) { + $('#app-settings').switchClass('open', ''); + } + }; + if($('#app-settings').hasClass('open')) { + $('#app-settings').switchClass('open', ''); + $('body').unbind('click', bodyListener); + } else { + $('#app-settings').switchClass('', 'open'); + $('body').bind('click', bodyListener); + } + }); Calendar.UI.Share.init(); Calendar.UI.Drop.init(); - $('#choosecalendar .generalsettings').on('click keydown', function(event) { - event.preventDefault(); - OC.appSettings({appid:'calendar', loadJS:true, cache:false, scriptName:'settingswrapper.php'}); - }); $('#fullcalendar').fullCalendar('option', 'height', $(window).height() - $('#controls').height() - $('#header').height() - 15); }); + +var wrongKey = function(event) { + return ((event.type === 'keydown' || event.type === 'keypress') + && (event.keyCode !== 32 && event.keyCode !== 13)); +}; \ No newline at end of file diff --git a/templates/calendar.php b/templates/calendar.php index 289486f9c..0d0af142a 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -22,15 +22,136 @@ --> +
  • + t('New Calendar')) ?> +
  • + + "); + $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); + $tmpl->assign('calendar', $option_calendars[$i]); + if ($option_calendars[$i]['userid'] != OCP\User::getUser()) { + $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $option_calendars[$i]['id']); + $shared = true; + } else { + $shared = false; + } + $tmpl->assign('shared', $shared); + $tmpl->printpage(); + print_unescaped(""); + } + ?> +

    ">

    + +
    - +
    - Test 123 +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + + +
    + +
    + +
    + +    +
    + +
    + +
    + +
    +
    +

    t('URLs')); ?>

    +
    + t('Calendar CalDAV syncing addresses')); ?> (t('more info')); ?>) +
    +
    t('Primary address (Kontact et al)')); ?>
    +
    +
    t('iOS/OS X')); ?>
    +
    +
    t('Read only iCalendar link(s)')); ?>
    +
    + +
    + +
    +
    +
    +
    -
    +
    diff --git a/templates/part.choosecalendar.rowfields.php b/templates/part.choosecalendar.rowfields.php index cd6294dfc..f7f9bcff4 100644 --- a/templates/part.choosecalendar.rowfields.php +++ b/templates/part.choosecalendar.rowfields.php @@ -1,38 +1,47 @@ - - - > - - - - - - - - - - - - - - - - - - - - - - - - - - - + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/part.editcalendar.php b/templates/part.editcalendar.php index 22764babb..809104008 100644 --- a/templates/part.editcalendar.php +++ b/templates/part.editcalendar.php @@ -6,30 +6,18 @@ * See the COPYING-README file. */ ?> -t("Edit calendar")); ?>" colspan="6"> - - - - - - - - - - - -
    t('Displayname')) ?> - -
    t('Calendar color')) ?> - -
    -" value="t("Save") : $l->t("Submit")); ?>"> -" value="t("Cancel")); ?>"> - +
  • t("Edit calendar")); ?>" colspan="6"> + + + + + " value="t("Save") : $l->t("Submit")); ?>"> + " value="t("Cancel")); ?>"> +
  • From e875ef5960ffbfbf2023c603395126bd48386d2e Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Fri, 24 Jan 2014 16:11:02 +0100 Subject: [PATCH 04/22] Fixed settings --- index.php | 4 ++ js/settings.js | 3 - settings.php | 17 ------ templates/calendar.php | 2 +- templates/settings.php | 131 ----------------------------------------- 5 files changed, 5 insertions(+), 152 deletions(-) delete mode 100644 settings.php delete mode 100644 templates/settings.php diff --git a/index.php b/index.php index f7213648c..b348880a4 100644 --- a/index.php +++ b/index.php @@ -40,8 +40,12 @@ OCP\Util::addscript('calendar','jquery.multi-autocomplete'); OCP\Util::addscript('','tags'); OCP\Util::addscript('calendar','on-event'); +OCP\Util::addscript('calendar','settings'); OCP\App::setActiveNavigationEntry('calendar_index'); $tmpl = new OCP\Template('calendar', 'calendar', 'user'); +$timezone=OCP\Config::getUserValue(OCP\USER::getUser(),'calendar','timezone',''); +$tmpl->assign('timezone',$timezone); +$tmpl->assign('timezones',DateTimeZone::listIdentifiers()); if(array_key_exists('showevent', $_GET)) { $tmpl->assign('showevent', $_GET['showevent']); diff --git a/js/settings.js b/js/settings.js index dabd1cd56..e3ca098de 100644 --- a/js/settings.js +++ b/js/settings.js @@ -4,7 +4,6 @@ $(document).ready(function(){ $.post( OC.filePath('calendar', 'ajax/settings', 'settimezone.php'), post, function(data){return;}); return false; }); - $('#timezone').chosen(); $('#timeformat').change( function(){ var data = $('#timeformat').serialize(); $.post( OC.filePath('calendar', 'ajax/settings', 'settimeformat.php'), data, function(data){ @@ -29,7 +28,6 @@ $(document).ready(function(){ }); $.getJSON(OC.filePath('calendar', 'ajax/settings', 'timeformat.php'), function(jsondata, status) { $('#' + jsondata.timeformat).attr('selected',true); - $('#timeformat').chosen(); $('#timeformat_chzn').css('width', '100px'); }); $.getJSON(OC.filePath('calendar', 'ajax/settings', 'gettimezonedetection.php'), function(jsondata, status){ @@ -39,7 +37,6 @@ $(document).ready(function(){ }); $.getJSON(OC.filePath('calendar', 'ajax/settings', 'getfirstday.php'), function(jsondata, status) { $('#' + jsondata.firstday).attr('selected',true); - $('#firstday').chosen(); $('#firstday_chzn').css('width', '100px'); }); $('#cleancalendarcache').click(function(){ diff --git a/settings.php b/settings.php deleted file mode 100644 index f56351804..000000000 --- a/settings.php +++ /dev/null @@ -1,17 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -$tmpl = new OCP\Template( 'calendar', 'settings'); -$timezone=OCP\Config::getUserValue(OCP\USER::getUser(),'calendar','timezone',''); -$tmpl->assign('timezone',$timezone); -$tmpl->assign('timezones',DateTimeZone::listIdentifiers()); -$tmpl->assign('calendars', OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()), false); - -OCP\Util::addscript('calendar','settings'); - -$tmpl->printPage(); \ No newline at end of file diff --git a/templates/calendar.php b/templates/calendar.php index 0d0af142a..aa0586be0 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -61,7 +61,7 @@ - -

    t('Your calendars')); ?>:

    - - "); - $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); - $tmpl->assign('calendar', $option_calendars[$i]); - if ($option_calendars[$i]['userid'] != OCP\User::getUser()) { - $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $option_calendars[$i]['id']); - $shared = true; - } else { - $shared = false; - } - $tmpl->assign('shared', $shared); - $tmpl->printpage(); - print_unescaped(""); - } - ?> - - - - - - -
    - -
    -

    ">

    -

    - - -

    t('General')); ?>

    -
    - - - - - - - - - - - - - - - - - - - - - -
    - -    - - -
    -    - - -   - -
    - -    - - -
    - -    - - -
    - -    - - -
    -
    -

    t('URLs')); ?>

    -
    - t('Calendar CalDAV syncing addresses')); ?> (t('more info')); ?>) -
    -
    t('Primary address (Kontact et al)')); ?>
    -
    -
    t('iOS/OS X')); ?>
    -
    -
    t('Read only iCalendar link(s)')); ?>
    -
    - -
    - -
    -
    -
    - From 6e459404b8345a062ffada3d06b9953636dc908b Mon Sep 17 00:00:00 2001 From: jbtbnl <> Date: Tue, 4 Feb 2014 20:33:59 +0100 Subject: [PATCH 05/22] Work in progress for #269. --- css/style.css | 28 ++++++++++++++++++++++- js/calendar.js | 40 +++++++++++++++++++-------------- templates/part.editcalendar.php | 13 +++++------ 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/css/style.css b/css/style.css index 74971304f..736c980e3 100644 --- a/css/style.css +++ b/css/style.css @@ -285,7 +285,6 @@ button.category{margin:0 3px;} } #navigation-list form { width: 100%; - margin-bottom: 3px; } #navigation-list input[type=button], #navigation-list button { @@ -449,4 +448,31 @@ button.category{margin:0 3px;} #newCalendar { padding-left: 23px !important; +} + +#newcalendar_dialog, #editcalendar_dialog { + margin: 6px; + margin-top: 0px; +} + +#newcalendar_dialog input[type=text], #editcalendar_dialog input[type=text] { + height: 18px; + width: 172px; + float: left; + margin: 0; + margin-top: 6px; + margin-bottom: 6px; + padding-top: 7px; + padding-bottom: 7px; + border: 1px solid rgba(190, 190, 190, 0.9); + border-right: 0; + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +#newcalendar_dialog #editCalendar-submit, #editcalendar_dialog #editCalendar-submit { + float: left; + margin-bottom: 6px; + border-top-left-radius: 0; + border-bottom-left-radius: 0; } \ No newline at end of file diff --git a/js/calendar.js b/js/calendar.js index de0cc3cfa..4b441b96c 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -452,16 +452,20 @@ Calendar={ }); }, newCalendar:function(object){ - var tr = $(document.createElement('tr')) + var div = $(document.createElement('div')) .load(OC.filePath('calendar', 'ajax/calendar', 'new.form.php'), - function(){Calendar.UI.Calendar.colorPicker(this)}); - $("#navigation-list").append(tr); + function(){ + Calendar.UI.Calendar.colorPicker(this); + $('#displayname_new').focus(); + }); + $('#newCalendar').after(div); + $('#newCalendar').css('display', 'none'); }, edit:function(object, calendarid){ - var tr = $(document.createElement('tr')) + var li = $(document.createElement('li')) .load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php'), {calendarid: calendarid}, function(){Calendar.UI.Calendar.colorPicker(this)}); - $(object).closest('tr').after(tr).hide(); + $(object).closest('li').after(li).hide(); }, deleteCalendar:function(calid){ var check = confirm("Do you really want to delete this calendar?"); @@ -473,10 +477,8 @@ Calendar={ if (data.status == 'success'){ var url = 'ajax/events.php?calendar_id='+calid; $('#fullcalendar').fullCalendar('removeEventSource', url); - $('#choosecalendar_dialog').dialog('destroy').remove(); - Calendar.UI.Calendar.overview(); - $('#calendar tr[data-id="'+calid+'"]').fadeOut(400,function(){ - $('#calendar tr[data-id="'+calid+'"]').remove(); + $('#navigation-list li[data-id="'+calid+'"]').fadeOut(400,function(){ + $('#navigation-list li[data-id="'+calid+'"]').remove(); }); $('#fullcalendar').fullCalendar('refetchEvents'); } @@ -485,11 +487,7 @@ Calendar={ }, submit:function(button, calendarid){ var displayname = $.trim($("#displayname_"+calendarid).val()); - //var active = $("#edit_active_"+calendarid+":checked").length; - var active =0; - if( $("#edit_active_"+calendarid).is(':checked') ){ - active =1; - } + var active = $("#active_"+calendarid).attr("checked") ? 1 : 0; var description = $("#description_"+calendarid).val(); var calendarcolor = $("#calendarcolor_"+calendarid).val(); @@ -509,11 +507,18 @@ Calendar={ $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor }, function(data){ if(data.status == 'success'){ - $(button).closest('tr').prev().html(data.page).show().next().remove(); $('#fullcalendar').fullCalendar('removeEventSource', data.eventSource.url); $('#fullcalendar').fullCalendar('addEventSource', data.eventSource); if (calendarid == 'new'){ - $('#calendar > table:first').append(''); + $('#newcalendar_dialog').parent().remove(); + $("#newCalendar").css('display', ''); + alert(JSON.stringify(data)); + var li = $(document.createElement('li')).append(data.page); + $("#navigation-list").append(li); + } + else { + $('#editcalendar_dialog').parent().remove(); + $('#navigation-list li[data-id="'+calendarid+'"]').html(data.page).show(); } }else{ $("#displayname_"+calendarid).css('background-color', '#FF2626'); @@ -524,7 +529,8 @@ Calendar={ }, 'json'); }, cancel:function(button, calendarid){ - $(button).closest('tr').prev().show().next().remove(); + $('#newcalendar_dialog').parent().remove(); + $("#newCalendar").css('display', ''); }, colorPicker:function(container){ // based on jquery-colorpicker at jquery.webspirited.com diff --git a/templates/part.editcalendar.php b/templates/part.editcalendar.php index 809104008..b86ea1d7a 100644 --- a/templates/part.editcalendar.php +++ b/templates/part.editcalendar.php @@ -6,10 +6,11 @@ * See the COPYING-README file. */ ?> -
  • t("Edit calendar")); ?>" colspan="6"> - - - +
    t("Edit calendar")); ?>" colspan="6"> + + + " value="t("Save") : $l->t("Submit")); ?>"> + - " value="t("Save") : $l->t("Submit")); ?>"> - " value="t("Cancel")); ?>"> -
  • + From 6ba17af5e2b476bf3157726c958f34467d531494 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Fri, 28 Feb 2014 13:48:16 +0100 Subject: [PATCH 06/22] Update gitignore --- .gitignore | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4d02d1680..b05862155 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,50 @@ -/calendar/nbproject/private -/nbproject/private/ \ No newline at end of file +# just sane ignores +.*.sw[po] +*.bak +*.BAK +*~ +*.orig +*.class +.cvsignore +Thumbs.db +*.py[co] +_darcs/* +CVS/* +.svn/* +RCS/* +*.backup* + +# kdevelop +.kdev +*.kdev4 +*.kate-swp + +# kate editor +.kateproject* + +# Lokalize +*lokalize* + +# eclipse +.project +.settings + +# netbeans +nbproject + +# phpStorm +.idea +*.iml + +# geany +*.geany + +# Cloud9IDE +.settings.xml +.c9revisions + +# vim ex mode +.vimrc + +# Mac OS +.DS_Store \ No newline at end of file From 553ef552ce3ed5ee86ea5c10565fb5824be914bb Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Fri, 28 Feb 2014 14:06:04 +0100 Subject: [PATCH 07/22] Remove netbeans project folder --- nbproject/project.properties | 5 ----- nbproject/project.xml | 9 --------- 2 files changed, 14 deletions(-) delete mode 100644 nbproject/project.properties delete mode 100644 nbproject/project.xml diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 8274ffdeb..000000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,5 +0,0 @@ -config.folder= -file.reference.apps-calendar=. -files.encoding=UTF-8 -site.root.folder=${file.reference.apps-calendar} -test.folder= diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index a2fa7657d..000000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - org.netbeans.modules.web.clientproject - - - calendar - - - From b93010c995473da8408050bfc4edddc574189d65 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Mon, 3 Mar 2014 12:12:28 +0100 Subject: [PATCH 08/22] HTML fixes and automatically close new calendar form. --- js/calendar.js | 10 ++++++++++ templates/calendar.php | 11 +++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index b1e40c9f4..d9f360228 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -462,6 +462,16 @@ Calendar={ Calendar.UI.Calendar.colorPicker(this); $('#displayname_new').focus(); }); + + var bodyListener = function(e) { + if($('#newcalendar_dialog').find($(e.target)).length === 0) { + $('#newcalendar_dialog').parent().remove(); + $("#newCalendar").css('display', ''); + $('body').unbind('click', bodyListener); + } + }; + $('body').bind('click', bodyListener); + $('#newCalendar').after(div); $('#newCalendar').css('display', 'none'); }, diff --git a/templates/calendar.php b/templates/calendar.php index aa0586be0..d9c1163df 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -17,10 +17,6 @@ -
  • t('New Calendar')) ?> @@ -43,7 +39,10 @@ print_unescaped("
  • "); } ?> -

    ">

    +
  • + "> + +
  • @@ -117,7 +116,7 @@ - + From df7b6175c3bdf6b9d235def7c0323110f8250443 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Tue, 4 Mar 2014 14:42:16 +0100 Subject: [PATCH 09/22] Redesign of calendar create and edit dialog --- css/style.css | 3 ++- js/calendar.js | 11 ++++++++++- templates/part.choosecalendar.rowfields.php | 4 ++-- templates/part.editcalendar.php | 2 +- templates/part.import.php | 2 +- templates/part.showevent.php | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/css/style.css b/css/style.css index 736c980e3..1404aaa6f 100644 --- a/css/style.css +++ b/css/style.css @@ -457,7 +457,7 @@ button.category{margin:0 3px;} #newcalendar_dialog input[type=text], #editcalendar_dialog input[type=text] { height: 18px; - width: 172px; + width: 191px; float: left; margin: 0; margin-top: 6px; @@ -471,6 +471,7 @@ button.category{margin:0 3px;} } #newcalendar_dialog #editCalendar-submit, #editcalendar_dialog #editCalendar-submit { + width: 32px; float: left; margin-bottom: 6px; border-top-left-radius: 0; diff --git a/js/calendar.js b/js/calendar.js index fe496fd7b..dbffa3b17 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -487,6 +487,16 @@ Calendar={ var li = $(document.createElement('li')) .load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php'), {calendarid: calendarid}, function(){Calendar.UI.Calendar.colorPicker(this)}); + + var bodyListener = function(e) { + if($('#editcalendar_dialog').find($(e.target)).length === 0) { + $(object).closest('li').before(li).show(); + $('#editcalendar_dialog').parent().remove(); + $('body').unbind('click', bodyListener); + } + }; + $('body').bind('click', bodyListener); + $(object).closest('li').after(li).hide(); }, deleteCalendar:function(calid){ @@ -534,7 +544,6 @@ Calendar={ if (calendarid == 'new'){ $('#newcalendar_dialog').parent().remove(); $("#newCalendar").css('display', ''); - alert(JSON.stringify(data)); var li = $(document.createElement('li')).append(data.page); $("#navigation-list").append(li); } diff --git a/templates/part.choosecalendar.rowfields.php b/templates/part.choosecalendar.rowfields.php index f7f9bcff4..06afbe25b 100644 --- a/templates/part.choosecalendar.rowfields.php +++ b/templates/part.choosecalendar.rowfields.php @@ -7,9 +7,9 @@ - + title="t('Share Calendar')) ?>" style="background-image: url();"> diff --git a/templates/part.editcalendar.php b/templates/part.editcalendar.php index b86ea1d7a..c8b76cadf 100644 --- a/templates/part.editcalendar.php +++ b/templates/part.editcalendar.php @@ -9,7 +9,7 @@
    t("Edit calendar")); ?>" colspan="6"> - " value="t("Save") : $l->t("Submit")); ?>"> + "> +
    t("Description"));?>: - +
    From 90fc9dc24a5f8dab5b7de5aa6fafd40df1cba3e3 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Tue, 4 Mar 2014 14:55:03 +0100 Subject: [PATCH 10/22] Fixes #305 --- 3rdparty/fullcalendar/css/fullcalendar.css | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/3rdparty/fullcalendar/css/fullcalendar.css b/3rdparty/fullcalendar/css/fullcalendar.css index 2df45443d..b80319dc9 100644 --- a/3rdparty/fullcalendar/css/fullcalendar.css +++ b/3rdparty/fullcalendar/css/fullcalendar.css @@ -263,11 +263,6 @@ a.fc-event { text-decoration: none; } -a.fc-event, -.fc-event-draggable { - cursor: pointer; - } - .fc-rtl .fc-event { text-align: right; } @@ -281,6 +276,12 @@ a.fc-event, .fc-event-time, .fc-event-title { padding: 0 1px; + cursor: pointer; + } + +.fc-event-time:hover, +.fc-event-title:hover { + text-decoration: underline; } .fc .ui-resizable-handle { From 29d796fcff984850a71badbbd708ea88a4b86845 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Tue, 4 Mar 2014 15:57:18 +0100 Subject: [PATCH 11/22] Fix issues with elements not fitting in the with of the navigation bar --- css/style.css | 17 ++++++++++++++++- templates/calendar.php | 5 ++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/css/style.css b/css/style.css index 1404aaa6f..278f1429e 100644 --- a/css/style.css +++ b/css/style.css @@ -16,7 +16,14 @@ #parsingfail_dialog{display: none;} #dialog_holder {display: none;} -#loading { display: none;margin: 0;padding:0;margin-top:5px;} +#loading { + position: absolute; + top: 3px; + left: 2px; + display: none; + margin: 0; + padding: 0; +} #fullcalendar { position: relative; @@ -294,6 +301,7 @@ button.category{margin:0 3px;} margin-left: 0px; margin-right: 0px; margin-bottom: 0px; + font-weight: normal; } #navigation-list #onedayview_radio { @@ -332,18 +340,25 @@ button.category{margin:0 3px;} } #datecontrol_left { + width: 33px; margin-top: 6px; border-radius: 0; border-left: 0; } #datecontrol_right { + width: 33px; margin-top: 6px; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; } +#navigation-list { + /* fix for scrollbar issues in app-navigation after expansion of datepicker */ + overflow: initial !important; +} + #navigation-list #datecontrol_today { float: right; margin-right: 6px; diff --git a/templates/calendar.php b/templates/calendar.php index d9c1163df..6708cc6bb 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -8,14 +8,13 @@
  • -
    +
  •    -
  • @@ -152,6 +151,6 @@
  • -
    +
    From 9e2a2b46106dc18e6f4a3ad1bc3b13cf963bc49f Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Wed, 5 Mar 2014 13:11:51 +0100 Subject: [PATCH 12/22] Color coded calendar checkboxes. Refs #332 #77 --- css/style.css | 71 +++++++++++++++------ js/calendar.js | 6 ++ templates/part.choosecalendar.rowfields.php | 26 ++++---- 3 files changed, 73 insertions(+), 30 deletions(-) diff --git a/css/style.css b/css/style.css index 278f1429e..f539e0601 100644 --- a/css/style.css +++ b/css/style.css @@ -354,11 +354,6 @@ button.category{margin:0 3px;} border-left: 0; } -#navigation-list { - /* fix for scrollbar issues in app-navigation after expansion of datepicker */ - overflow: initial !important; -} - #navigation-list #datecontrol_today { float: right; margin-right: 6px; @@ -427,13 +422,6 @@ button.category{margin:0 3px;} min-height: 0; } -#app-navigation li .action { - width: 16px; - height: 16px; - margin-left: 2px; - background-size: auto; -} - #app-navigation label { vertical-align: text-bottom; } @@ -443,12 +431,6 @@ button.category{margin:0 3px;} margin-top: 13px; } -#app-navigation .utils { - position: relative; - padding: 13px 7px 0 0; - float: right; -} - #app-navigation li[data-id]:hover { background-color: rgb(221, 221, 221); } @@ -491,4 +473,57 @@ button.category{margin:0 3px;} margin-bottom: 6px; border-top-left-radius: 0; border-bottom-left-radius: 0; +} + +.activeCalendar { + display: none; +} + +.calendarCheckbox { + margin-left: 6px; + margin-top: 13px; + margin-bottom: -1px; + display: inline-block; + width: 11px; + height: 11px; + border-width: 1px; + border-style: solid; + border-color: black; +} + +.calendarCheckbox.unchecked { + background: rgba(0, 0, 0, 0) !important; + border-color: #aaa; +} + +.calendarLabel { + display: block; + height: 44px; +} + +#app-navigation .utils { + display: inline-block; + height: 44px; + padding: 0 5px 0 0; +} + +#app-navigation .utils > * { + display: inline-block; + line-height: 44px; + height: 44px; + width: 20px; +} + +#app-navigation .utils .action a img { + display: inline-block; + line-height: 44px; + height: 16px; + width: 16px; + padding: 14px 2px 14px 2px ; +} + +.utils #dropdown { + margin-right: 0px; + width: 224px; + top: 44px; } \ No newline at end of file diff --git a/js/calendar.js b/js/calendar.js index dbffa3b17..00ae36bf9 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -441,6 +441,12 @@ Calendar={ }, activation:function(checkbox, calendarid) { + if(checkbox.checked?1:0) { + $('#checkbox_'+calendarid).removeClass('unchecked'); + } + else { + $('#checkbox_'+calendarid).addClass('unchecked'); + } Calendar.UI.loading(true); $.post(OC.filePath('calendar', 'ajax/calendar', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 }, function(data) { diff --git a/templates/part.choosecalendar.rowfields.php b/templates/part.choosecalendar.rowfields.php index 06afbe25b..4a37e08b6 100644 --- a/templates/part.choosecalendar.rowfields.php +++ b/templates/part.choosecalendar.rowfields.php @@ -1,19 +1,21 @@ - - > - + - +
    + \ No newline at end of file From 9c320a05994edad2aefa72955e3fd283bb9c3d76 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Wed, 5 Mar 2014 14:07:05 +0100 Subject: [PATCH 13/22] Fix window resize --- 3rdparty/fullcalendar/js/fullcalendar.js | 12 +++++------- css/style.css | 9 +++++---- js/calendar.js | 11 +++-------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/3rdparty/fullcalendar/js/fullcalendar.js b/3rdparty/fullcalendar/js/fullcalendar.js index 0d43e5866..1ea5e40af 100644 --- a/3rdparty/fullcalendar/js/fullcalendar.js +++ b/3rdparty/fullcalendar/js/fullcalendar.js @@ -449,7 +449,7 @@ function Calendar(element, options, eventSources) { suggestedViewHeight = options.contentHeight; } else if (options.height) { - suggestedViewHeight = options.height - (headerElement ? headerElement.height() : 0) - vsides(content); + suggestedViewHeight = options.height() - (headerElement ? headerElement.height() : 0) - vsides(content); } else { suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5)); @@ -475,12 +475,10 @@ function Calendar(element, options, eventSources) { var uid = ++resizeUID; setTimeout(function() { // add a delay if (uid == resizeUID && !ignoreWindowResize && elementVisible()) { - if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) { - ignoreWindowResize++; // in case the windowResize callback changes the height - updateSize(); - currentView.trigger('windowResize', _element); - ignoreWindowResize--; - } + ignoreWindowResize++; // in case the windowResize callback changes the height + updateSize(); + currentView.trigger('windowResize', _element); + ignoreWindowResize--; } }, 200); }else{ diff --git a/css/style.css b/css/style.css index f539e0601..8749667b9 100644 --- a/css/style.css +++ b/css/style.css @@ -25,7 +25,12 @@ padding: 0; } +body { + overflow: hidden; +} + #fullcalendar { + overflow: auto; position: relative; bottom: 0; right: 0; @@ -145,10 +150,6 @@ button.category{margin:0 3px;} cursor: pointer; } -#fullcalendar{ - overflow: auto; -} - .ui-timepicker-hour-cell *, .ui-timepicker-minute-cell *{ text-overflow: clip !important; } diff --git a/js/calendar.js b/js/calendar.js index 00ae36bf9..ba85269de 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -753,12 +753,6 @@ function ListView(element, calendar) { t.setWidth=setWidth; t.clearEvents=clearEvents; - function setHeight(height, dateChanged) { - } - - function setWidth(width) { - } - function clearEvents() { this.reportEventClear(); } @@ -967,7 +961,6 @@ $(document).ready(function(){ $('#fullcalendar').fullCalendar('gotoDate', date); } }); - fillWindow($('#content')); $(OC.Tags).on('change', function(event, data) { if(data.type === 'event') { @@ -1019,7 +1012,9 @@ $(document).ready(function(){ }); Calendar.UI.Share.init(); Calendar.UI.Drop.init(); - $('#fullcalendar').fullCalendar('option', 'height', $(window).height() - $('#controls').height() - $('#header').height() - 15); + $('#fullcalendar').fullCalendar('option', 'height', function() { + return $(window).height() - $('#controls').height() - $('#header').height(); + }); // Save the eventSource for shared events. for (var i in eventSources) { if (eventSources[i].url.substr(-13) === 'shared_events') { From aca02549a00d5f7716c3164b3121521c02d49040 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Sat, 8 Mar 2014 10:59:18 +0100 Subject: [PATCH 14/22] Don't use tables for settings --- css/style.css | 10 +-- templates/calendar.php | 166 ++++++++++++++++------------------------- 2 files changed, 67 insertions(+), 109 deletions(-) diff --git a/css/style.css b/css/style.css index 8749667b9..5198b9f59 100644 --- a/css/style.css +++ b/css/style.css @@ -5,7 +5,6 @@ * See the COPYING-README file. */ -#view { float: left; font-size: 12px; height: 100%;} #datecontrol {text-align: center;} #datecontrol_date_label {margin: 0; padding: 0; font-size: 12px;} #choosecalendar {margin-right: 10px; float: right; font-size: 12px;} @@ -291,6 +290,10 @@ button.category{margin:0 3px;} #app-settings { width: 249px; } +#app-settings input, #app-settings select { + margin-left: 0; + margin-right: 0; +} #navigation-list form { width: 100%; } @@ -427,11 +430,6 @@ button.category{margin:0 3px;} vertical-align: text-bottom; } -#app-navigation input[type=checkbox] { - margin-left: 6px; - margin-top: 13px; -} - #app-navigation li[data-id]:hover { background-color: rgb(221, 221, 221); } diff --git a/templates/calendar.php b/templates/calendar.php index 6708cc6bb..0f4c6e9b9 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -46,110 +46,70 @@
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    - - -
    - -
    - -
    - -    -
    - -
    - -
    - -
    -
    -

    t('URLs')); ?>

    -
    - t('Calendar CalDAV syncing addresses')); ?> (t('more info')); ?>) -
    -
    t('Primary address (Kontact et al)')); ?>
    -
    -
    t('iOS/OS X')); ?>
    -
    -
    t('Read only iCalendar link(s)')); ?>
    -
    - + +
    +
    +
      +
    • + + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    +
    +
    +
    From e5c1304ea9ab67ec141126722db2d3a37e07b25c Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Sat, 8 Mar 2014 11:26:01 +0100 Subject: [PATCH 15/22] Fixes button issues? --- css/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/css/style.css b/css/style.css index 5198b9f59..c52d89ba7 100644 --- a/css/style.css +++ b/css/style.css @@ -300,7 +300,6 @@ button.category{margin:0 3px;} #navigation-list input[type=button], #navigation-list button { height: 34px; - padding: 8px; margin-top: 6px; margin-left: 0px; margin-right: 0px; From fca6b77ee1f268f8ddc841369b99e59be1cc978c Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Sat, 8 Mar 2014 11:42:13 +0100 Subject: [PATCH 16/22] Fix space between calendar list and new calendar entry --- css/style.css | 4 ++++ js/calendar.js | 1 + templates/calendar.php | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/css/style.css b/css/style.css index c52d89ba7..1fcb0ae02 100644 --- a/css/style.css +++ b/css/style.css @@ -524,4 +524,8 @@ button.category{margin:0 3px;} margin-right: 0px; width: 224px; top: 44px; +} + +#navigation-list #caldav_url_entry { + min-height: 0; } \ No newline at end of file diff --git a/js/calendar.js b/js/calendar.js index ba85269de..659ccd111 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -552,6 +552,7 @@ Calendar={ $("#newCalendar").css('display', ''); var li = $(document.createElement('li')).append(data.page); $("#navigation-list").append(li); + $('#caldav_url_entry').appendTo("#navigation-list"); } else { $('#editcalendar_dialog').parent().remove(); diff --git a/templates/calendar.php b/templates/calendar.php index 0f4c6e9b9..96a405d9e 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -38,7 +38,7 @@ print_unescaped(""); } ?> -
  • +
  • ">
  • From b27834d861a1d138e2c21a3f2fdbace53747d1fc Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Sat, 8 Mar 2014 11:48:26 +0100 Subject: [PATCH 17/22] Fix hidden calendar becoming visible after editing. --- js/calendar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index 659ccd111..d2e8d274f 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -545,8 +545,10 @@ Calendar={ $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor }, function(data){ if(data.status == 'success'){ - $('#fullcalendar').fullCalendar('removeEventSource', data.eventSource.url); - $('#fullcalendar').fullCalendar('addEventSource', data.eventSource); + if(active) { + $('#fullcalendar').fullCalendar('removeEventSource', data.eventSource.url); + $('#fullcalendar').fullCalendar('addEventSource', data.eventSource); + } if (calendarid == 'new'){ $('#newcalendar_dialog').parent().remove(); $("#newCalendar").css('display', ''); From fa76f1d1f05a26a1c46d38d86456d691f35ccb75 Mon Sep 17 00:00:00 2001 From: jbtbnl Date: Wed, 19 Mar 2014 12:11:09 +0100 Subject: [PATCH 18/22] Fix checkbox for calendars without color --- js/calendar.js | 2 +- templates/part.choosecalendar.rowfields.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index d2e8d274f..5f9fe8b2b 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -470,7 +470,7 @@ Calendar={ } }, newCalendar:function(object){ - var div = $(document.createElement('div')) + var div = $('
    ') .load(OC.filePath('calendar', 'ajax/calendar', 'new.form.php'), function(){ Calendar.UI.Calendar.colorPicker(this); diff --git a/templates/part.choosecalendar.rowfields.php b/templates/part.choosecalendar.rowfields.php index 4a37e08b6..5775798ff 100644 --- a/templates/part.choosecalendar.rowfields.php +++ b/templates/part.choosecalendar.rowfields.php @@ -1,7 +1,7 @@
    -
    +
    From b18a659315af1ae00a590e320c0766d271d1e386 Mon Sep 17 00:00:00 2001 From: libasys Date: Mon, 24 Mar 2014 15:40:28 +0100 Subject: [PATCH 21/22] Updating to fullcalendar 1.6.4 Update calendar.js to 1.6.4 Adding timeline Feature Fixing repeating options problem Adding currentDay view datepicker Small css additions and Fixes --- 3rdparty/fullcalendar/css/fullcalendar.css | 27 +- 3rdparty/fullcalendar/js/fullcalendar.js | 3684 +++++++++++------- 3rdparty/fullcalendar/js/fullcalendar.min.js | 6 +- 3rdparty/fullcalendar/js/gcal.js | 2 +- css/style.css | 23 +- js/calendar.js | 93 +- 6 files changed, 2331 insertions(+), 1504 deletions(-) diff --git a/3rdparty/fullcalendar/css/fullcalendar.css b/3rdparty/fullcalendar/css/fullcalendar.css index b80319dc9..92fe47f20 100644 --- a/3rdparty/fullcalendar/css/fullcalendar.css +++ b/3rdparty/fullcalendar/css/fullcalendar.css @@ -1,5 +1,5 @@ /*! - * FullCalendar v1.6.1 Stylesheet + * FullCalendar v1.6.4 Stylesheet * Docs & License: http://arshaw.com/fullcalendar/ * (c) 2013 Adam Shaw */ @@ -102,10 +102,11 @@ html .fc, .fc-content { clear: both; + zoom: 1; /* for IE7, gives accurate coordinates for [un]freezeContentHeight */ } .fc-view { - width: 100%; /* needed for view switching (when view is absolute) */ + width: 100%; overflow: hidden; } @@ -120,7 +121,7 @@ html .fc, } .fc-state-highlight { /* today cell */ /* TODO: add .fc-today to */ - background: #ffa; + background: #fcf8e3; } .fc-cell-overlay { /* semi-transparent rectangle while dragging */ @@ -250,6 +251,15 @@ html .fc, /* Global Event Styles ------------------------------------------------------------------------*/ + +.fc-event-container > * { + z-index: 8; + } + +.fc-event-container > .ui-draggable-dragging, +.fc-event-container > .ui-resizable-resizing { + z-index: 9; + } .fc-event { border: 1px solid #3a87ad; /* default BORDER color */ @@ -263,6 +273,11 @@ a.fc-event { text-decoration: none; } +a.fc-event, +.fc-event-draggable { + cursor: pointer; + } + .fc-rtl .fc-event { text-align: right; } @@ -276,12 +291,6 @@ a.fc-event { .fc-event-time, .fc-event-title { padding: 0 1px; - cursor: pointer; - } - -.fc-event-time:hover, -.fc-event-title:hover { - text-decoration: underline; } .fc .ui-resizable-handle { diff --git a/3rdparty/fullcalendar/js/fullcalendar.js b/3rdparty/fullcalendar/js/fullcalendar.js index 1ea5e40af..41c50856c 100644 --- a/3rdparty/fullcalendar/js/fullcalendar.js +++ b/3rdparty/fullcalendar/js/fullcalendar.js @@ -1,5 +1,5 @@ /*! - * FullCalendar v1.6.1 + * FullCalendar v1.6.4 * Docs & License: http://arshaw.com/fullcalendar/ * (c) 2013 Adam Shaw */ @@ -86,7 +86,9 @@ var defaults = { //selectable: false, unselectAuto: true, - dropAccept: '*' + dropAccept: '*', + + handleWindowResize: true }; @@ -113,7 +115,7 @@ var rtlDefaults = { ;; -var fc = $.fullCalendar = { version: "1.6.1" }; +var fc = $.fullCalendar = { version: "1.6.4" }; var fcViews = fc.views = {}; @@ -141,7 +143,8 @@ $.fn.fullCalendar = function(options) { } return this; } - + + options = options || {}; // would like to have this logic in EventManager, but needs to happen before options are recursively extended var eventSources = options.eventSources || []; @@ -225,10 +228,8 @@ function Calendar(element, options, eventSources) { var content; var tm; // for making theme classes var currentView; - var viewInstances = {}; var elementOuterWidth; var suggestedViewHeight; - var absoluteViewElement; var resizeUID = 0; var ignoreWindowResize = 0; var date = new Date(); @@ -247,11 +248,11 @@ function Calendar(element, options, eventSources) { function render(inc) { if (!content) { initialRender(); - }else{ + } + else if (elementVisible()) { + // mainly for the public API calcSize(); - markSizesDirty(); - markEventsDirty(); - renderView(inc); + _renderView(inc); } } @@ -268,15 +269,22 @@ function Calendar(element, options, eventSources) { if (options.theme) { element.addClass('ui-widget'); } + content = $("
    ") .prependTo(element); + header = new Header(t, options); headerElement = header.render(); if (headerElement) { element.prepend(headerElement); } + changeView(options.defaultView); - $(window).resize(windowResize); + + if (options.handleWindowResize) { + $(window).resize(windowResize); + } + // needed for IE in a 0x0 iframe, b/c when it is resized, never triggers a windowResize if (!bodyVisible()) { lateRender(); @@ -296,21 +304,27 @@ function Calendar(element, options, eventSources) { function destroy() { + + if (currentView) { + trigger('viewDestroy', currentView, currentView, currentView.element); + currentView.triggerEventDestroy(); + } + $(window).unbind('resize', windowResize); + header.destroy(); content.remove(); element.removeClass('fc fc-rtl ui-widget'); } - function elementVisible() { - return _element.offsetWidth !== 0; + return element.is(':visible'); } function bodyVisible() { - return $('body')[0].offsetWidth !== 0; + return $('body').is(':visible'); } @@ -318,138 +332,102 @@ function Calendar(element, options, eventSources) { /* View Rendering -----------------------------------------------------------------------------*/ - // TODO: improve view switching (still weird transition in IE, and FF has whiteout problem) - + function changeView(newViewName) { if (!currentView || newViewName != currentView.name) { - ignoreWindowResize++; // because setMinHeight might change the height before render (and subsequently setSize) is reached + _changeView(newViewName); + } + } + + + function _changeView(newViewName) { + ignoreWindowResize++; + if (currentView) { + trigger('viewDestroy', currentView, currentView, currentView.element); unselect(); - - var oldView = currentView; - var newViewElement; - - if (oldView) { - (oldView.beforeHide || noop)(); // called before changing min-height. if called after, scroll state is reset (in Opera) - setMinHeight(content, content.height()); - oldView.element.hide(); - }else{ - setMinHeight(content, 1); // needs to be 1 (not 0) for IE7, or else view dimensions miscalculated - } - content.css('overflow', 'hidden'); - - currentView = viewInstances[newViewName]; - if (currentView) { - currentView.element.show(); - }else{ - currentView = viewInstances[newViewName] = new fcViews[newViewName]( - newViewElement = absoluteViewElement = - $("
    ") - .appendTo(content), - t // the calendar object - ); - } - - if (oldView) { - header.deactivateButton(oldView.name); - } - header.activateButton(newViewName); - - renderView(); // after height has been set, will make absoluteViewElement's position=relative, then set to null - - content.css('overflow', ''); - if (oldView) { - setMinHeight(content, 1); - } - - if (!newViewElement) { - (currentView.afterShow || noop)(); // called after setting min-height/overflow, so in final scroll state (for Opera) - } - - ignoreWindowResize--; + currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event + freezeContentHeight(); + currentView.element.remove(); + header.deactivateButton(currentView.name); } + + header.activateButton(newViewName); + + currentView = new fcViews[newViewName]( + $("
    ") + .appendTo(content), + t // the calendar object + ); + + renderView(); + unfreezeContentHeight(); + + ignoreWindowResize--; } - - - + + function renderView(inc) { - if (elementVisible()) { - ignoreWindowResize++; // because renderEvents might temporarily change the height before setSize is reached + if ( + !currentView.start || // never rendered before + inc || date < currentView.start || date >= currentView.end // or new date range + ) { + if (elementVisible()) { + _renderView(inc); + } + } + } + + + function _renderView(inc) { // assumes elementVisible + ignoreWindowResize++; + if (currentView.start) { // already been rendered? + trigger('viewDestroy', currentView, currentView, currentView.element); unselect(); - - if (suggestedViewHeight === undefined) { - calcSize(); - } - - var forceEventRender = false; - if (!currentView.start || inc || date < currentView.start || date >= currentView.end) { - // view must render an entire new date range (and refetch/render events) - currentView.render(date, inc || 0); // responsible for clearing events - setSize(true); - forceEventRender = true; - } - else if (currentView.sizeDirty) { - // view must resize (and rerender events) - currentView.clearEvents(); - setSize(); - forceEventRender = true; - } - else if (currentView.eventsDirty) { - currentView.clearEvents(); - forceEventRender = true; - } - currentView.sizeDirty = false; - currentView.eventsDirty = false; - updateEvents(forceEventRender); - - elementOuterWidth = element.outerWidth(); - - header.updateTitle(currentView.title); - var today = new Date(); - if (today >= currentView.start && today < currentView.end) { - header.disableButton('today'); - }else{ - header.enableButton('today'); - } - - ignoreWindowResize--; - currentView.trigger('viewDisplay', _element); + clearEvents(); } + + freezeContentHeight(); + currentView.render(date, inc || 0); // the view's render method ONLY renders the skeleton, nothing else + setSize(); + unfreezeContentHeight(); + (currentView.afterRender || noop)(); + + updateTitle(); + updateTodayButton(); + + trigger('viewRender', currentView, currentView, currentView.element); + currentView.trigger('viewDisplay', _element); // deprecated + + ignoreWindowResize--; + + getAndRenderEvents(); } - + /* Resizing -----------------------------------------------------------------------------*/ function updateSize() { - markSizesDirty(); if (elementVisible()) { + unselect(); + clearEvents(); calcSize(); setSize(); - unselect(); - currentView.clearEvents(); - currentView.renderEvents(events); - currentView.sizeDirty = false; + renderEvents(); } } - function markSizesDirty() { - $.each(viewInstances, function(i, inst) { - inst.sizeDirty = true; - }); - } - - - function calcSize() { + function calcSize() { // assumes elementVisible if (options.contentHeight) { suggestedViewHeight = options.contentHeight; } else if (options.height) { - suggestedViewHeight = options.height() - (headerElement ? headerElement.height() : 0) - vsides(content); + suggestedViewHeight = options.height - (headerElement ? headerElement.height() : 0) - vsides(content); } else { suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5)); @@ -457,15 +435,20 @@ function Calendar(element, options, eventSources) { } - function setSize(dateChanged) { // todo: dateChanged? - ignoreWindowResize++; - currentView.setHeight(suggestedViewHeight, dateChanged); - if (absoluteViewElement) { - absoluteViewElement.css('position', 'relative'); - absoluteViewElement = null; + function setSize() { // assumes elementVisible + + if (suggestedViewHeight === undefined) { + calcSize(); // for first time + // NOTE: we don't want to recalculate on every renderView because + // it could result in oscillating heights due to scrollbars. } - currentView.setWidth(content.width(), dateChanged); + + ignoreWindowResize++; + currentView.setHeight(suggestedViewHeight); + currentView.setWidth(content.width()); ignoreWindowResize--; + + elementOuterWidth = element.outerWidth(); } @@ -475,10 +458,12 @@ function Calendar(element, options, eventSources) { var uid = ++resizeUID; setTimeout(function() { // add a delay if (uid == resizeUID && !ignoreWindowResize && elementVisible()) { - ignoreWindowResize++; // in case the windowResize callback changes the height - updateSize(); - currentView.trigger('windowResize', _element); - ignoreWindowResize--; + if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) { + ignoreWindowResize++; // in case the windowResize callback changes the height + updateSize(); + currentView.trigger('windowResize', _element); + ignoreWindowResize--; + } } }, 200); }else{ @@ -492,52 +477,85 @@ function Calendar(element, options, eventSources) { /* Event Fetching/Rendering -----------------------------------------------------------------------------*/ + // TODO: going forward, most of this stuff should be directly handled by the view + + + function refetchEvents() { // can be called as an API method + clearEvents(); + fetchAndRenderEvents(); + } + + + function rerenderEvents(modifiedEventID) { // can be called as an API method + clearEvents(); + renderEvents(modifiedEventID); + } + + + function renderEvents(modifiedEventID) { // TODO: remove modifiedEventID hack + if (elementVisible()) { + currentView.setEventData(events); // for View.js, TODO: unify with renderEvents + currentView.renderEvents(events, modifiedEventID); // actually render the DOM elements + currentView.trigger('eventAfterAllRender'); + } + } + + + function clearEvents() { + currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event + currentView.clearEvents(); // actually remove the DOM elements + currentView.clearEventData(); // for View.js, TODO: unify with clearEvents + } - - // fetches events if necessary, rerenders events if necessary (or if forced) - function updateEvents(forceRender) { + + function getAndRenderEvents() { if (!options.lazyFetching || isFetchNeeded(currentView.visStart, currentView.visEnd)) { - refetchEvents(); + fetchAndRenderEvents(); } - else if (forceRender) { - rerenderEvents(); + else { + renderEvents(); } } - - - function refetchEvents() { - fetchEvents(currentView.visStart, currentView.visEnd); // will call reportEvents + + + function fetchAndRenderEvents() { + fetchEvents(currentView.visStart, currentView.visEnd); + // ... will call reportEvents + // ... which will call renderEvents } - + // called when event data arrives function reportEvents(_events) { events = _events; - rerenderEvents(); + renderEvents(); } - - + + // called when a single event's data has been changed function reportEventChange(eventID) { rerenderEvents(eventID); } - - - // attempts to rerenderEvents - function rerenderEvents(modifiedEventID) { - markEventsDirty(); - if (elementVisible()) { - currentView.clearEvents(); - currentView.renderEvents(events, modifiedEventID); - currentView.eventsDirty = false; - } + + + + /* Header Updating + -----------------------------------------------------------------------------*/ + + + function updateTitle() { + header.updateTitle(currentView.title); } - - - function markEventsDirty() { - $.each(viewInstances, function(i, inst) { - inst.eventsDirty = true; - }); + + + function updateTodayButton() { + var today = new Date(); + if (today >= currentView.start && today < currentView.end) { + header.disableButton('today'); + } + else { + header.enableButton('today'); + } } @@ -618,6 +636,29 @@ function Calendar(element, options, eventSources) { function getDate() { return cloneDate(date); } + + + + /* Height "Freezing" + -----------------------------------------------------------------------------*/ + + + function freezeContentHeight() { + content.css({ + width: '100%', + height: content.height(), + overflow: 'hidden' + }); + } + + + function unfreezeContentHeight() { + content.css({ + width: '', + height: '', + overflow: '' + }); + } @@ -978,7 +1019,22 @@ function EventManager(options, _sources) { var success = source.success; var error = source.error; var complete = source.complete; - var data = $.extend({}, source.data || {}); + + // retrieve any outbound GET/POST $.ajax data from the options + var customData; + if ($.isFunction(source.data)) { + // supplied as a function that returns a key/value object + customData = source.data(); + } + else { + // supplied as a straight key/value object + customData = source.data; + } + + // use a copy of the custom data so we can modify the parameters + // and not affect the passed-in object. + var data = $.extend({}, customData || {}); + var startParam = firstDefined(source.startParam, options.startParam); var endParam = firstDefined(source.endParam, options.endParam); if (startParam) { @@ -987,6 +1043,7 @@ function EventManager(options, _sources) { if (endParam) { data[endParam] = Math.round(+rangeEnd / 1000); } + pushLoading(); $.ajax($.extend({}, ajaxDefaults, source, { data: data, @@ -1086,7 +1143,7 @@ function EventManager(options, _sources) { e.className = event.className; e.editable = event.editable; e.color = event.color; - e.backgroudColor = event.backgroudColor; + e.backgroundColor = event.backgroundColor; e.borderColor = event.borderColor; e.textColor = event.textColor; normalizeEvent(e); @@ -1159,14 +1216,14 @@ function EventManager(options, _sources) { function pushLoading() { if (!loadingLevel++) { - trigger('loading', null, true); + trigger('loading', null, true, getView()); } } function popLoading() { if (!--loadingLevel) { - trigger('loading', null, false); + trigger('loading', null, false, getView()); } } @@ -1345,15 +1402,6 @@ function zeroDate() { // returns a Date with time 00:00:00 and dateOfMonth=1 } -function skipWeekend(date, inc, excl) { - inc = inc || 1; - while (!date.getDay() || (excl && date.getDay()==1 || !excl && date.getDay()==6)) { - addDays(date, inc); - } - return date; -} - - function dayDiff(d1, d2) { // d1 - d2 return Math.round((cloneDate(d1, true) - cloneDate(d2, true)) / DAY_MS); } @@ -1609,8 +1657,8 @@ fc.dateFormatters = dateFormatters; /* thanks jQuery UI (https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js) * * Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. - * @param date Date - the date to get the week for - * @return number - the number of the week within the year that contains this date + * `date` - the date to get the week for + * `number` - the number of the week within the year that contains this date */ function iso8601Week(date) { var time; @@ -1647,95 +1695,7 @@ function exclEndDay(event) { function _exclEndDay(end, allDay) { end = cloneDate(end); return allDay || end.getHours() || end.getMinutes() ? addDays(end, 1) : clearTime(end); -} - - -function segCmp(a, b) { - return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start); -} - - -function segsCollide(seg1, seg2) { - return seg1.end > seg2.start && seg1.start < seg2.end; -} - - - -/* Event Sorting ------------------------------------------------------------------------------*/ - - -// event rendering utilities -function sliceSegs(events, visEventEnds, start, end) { - var segs = [], - i, len=events.length, event, - eventStart, eventEnd, - segStart, segEnd, - isStart, isEnd; - for (i=0; i start && eventStart < end) { - if (eventStart < start) { - segStart = cloneDate(start); - isStart = false; - }else{ - segStart = eventStart; - isStart = true; - } - if (eventEnd > end) { - segEnd = cloneDate(end); - isEnd = false; - }else{ - segEnd = eventEnd; - isEnd = true; - } - segs.push({ - event: event, - start: segStart, - end: segEnd, - isStart: isStart, - isEnd: isEnd, - msLength: segEnd - segStart - }); - } - } - return segs.sort(segCmp); -} - - -// event rendering calculation utilities -function stackSegs(segs) { - var levels = [], - i, len = segs.length, seg, - j, collide, k; - for (i=0; i") + $("
    ") .appendTo(element); } - - function buildTable(showNumbers) { - var html = ''; - var i, j; + function buildTable() { + var html = buildTableHTML(); + + if (table) { + table.remove(); + } + table = $(html).appendTo(element); + + head = table.find('thead'); + headCells = head.find('.fc-day-header'); + body = table.find('tbody'); + bodyRows = body.find('tr'); + bodyCells = body.find('.fc-day'); + bodyFirstCells = bodyRows.find('td:first-child'); + + firstRowCellInners = bodyRows.eq(0).find('.fc-day > div'); + firstRowCellContentInners = bodyRows.eq(0).find('.fc-day-content > div'); + + markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's + markFirstLast(bodyRows); // marks first+last td's + bodyRows.eq(0).addClass('fc-first'); + bodyRows.filter(':last').addClass('fc-last'); + + bodyCells.each(function(i, _cell) { + var date = cellToDate( + Math.floor(i / colCnt), + i % colCnt + ); + trigger('dayRender', t, date, $(_cell)); + }); + + dayBind(bodyCells); + } + + + + /* HTML Building + -----------------------------------------------------------*/ + + + function buildTableHTML() { + var html = + "" + + buildHeadHTML() + + buildBodyHTML() + + "
    "; + + return html; + } + + + function buildHeadHTML() { var headerClass = tm + "-widget-header"; - var contentClass = tm + "-widget-content"; - var month = t.start.getMonth(); - var today = clearTime(new Date()); - var cellDate; // not to be confused with local function. TODO: better names - var cellClasses; - var cell; + var html = ''; + var col; + var date; - html += "" + - "" + - ""; + html += ""; if (showWeekNumbers) { - html += ""; } - for (i=0; i"; + for (col=0; col" + + htmlEscape(formatDate(date, colFormat)) + + ""; } - html += "" + - "" + - ""; + html += ""; + + return html; + } + + + function buildBodyHTML() { + var contentClass = tm + "-widget-content"; + var html = ''; + var row; + var col; + var date; + + html += ""; + + for (row=0; row" + - "
    " + - ""; + date = cellToDate(row, 0); + html += + "
    "; } - for (j=0; j" + - "
    "; - if (showNumbers) { - html += "
    " + cellDate.getDate() + "
    "; - } - html += "
    " + - "
     
    " + - "
    " + - "
    " + - ""; + for (col=0; col"; - lockHeight(); // the unlock happens later, in setHeight()... - if (table) { - table.remove(); - } - table = $(html).appendTo(element); + html += "
    "; - head = table.find('thead'); - headCells = head.find('.fc-day-header'); - body = table.find('tbody'); - bodyRows = body.find('tr'); - bodyCells = body.find('.fc-day'); - bodyFirstCells = bodyRows.find('td:first-child'); - bodyCellTopInners = bodyRows.eq(0).find('.fc-day-content > div'); - - markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's - markFirstLast(bodyRows); // marks first+last td's - bodyRows.eq(0).addClass('fc-first'); - bodyRows.filter(':last').addClass('fc-last'); - - if (showWeekNumbers) { - head.find('.fc-week-number').text(weekNumberTitle); + return html; + } + + + function buildCellHTML(date) { + var contentClass = tm + "-widget-content"; + var month = t.start.getMonth(); + var today = clearTime(new Date()); + var html = ''; + var classNames = [ + 'fc-day', + 'fc-' + dayIDs[date.getDay()], + contentClass + ]; + + if (date.getMonth() != month) { + classNames.push('fc-other-month'); + } + if (+date == +today) { + classNames.push( + 'fc-today', + tm + '-state-highlight' + ); + } + else if (date < today) { + classNames.push('fc-past'); + } + else { + classNames.push('fc-future'); } - headCells.each(function(i, _cell) { - var date = indexDate(i); - $(_cell).text(formatDate(date, colFormat)); - }); + html += + "" + + "
    "; - if (showWeekNumbers) { - body.find('.fc-week-number > div').each(function(i, _cell) { - var weekStart = _cellDate(i, 0); - $(_cell).text(formatDate(weekStart, weekNumberFormat)); - }); + if (showNumbers) { + html += "
    " + date.getDate() + "
    "; } - - bodyCells.each(function(i, _cell) { - var date = indexDate(i); - trigger('dayRender', t, date, $(_cell)); - }); - dayBind(bodyCells); + html += + "
    " + + "
     
    " + + "
    " + + "
    " + + ""; + + return html; } - + + + + /* Dimensions + -----------------------------------------------------------*/ function setHeight(height) { @@ -2414,19 +2420,19 @@ function BasicView(element, calendar, viewName) { bodyFirstCells.each(function(i, _cell) { if (i < rowCnt) { cell = $(_cell); - setMinHeight( - cell.find('> div'), + cell.find('> div').css( + 'min-height', (i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell) ); } }); - unlockHeight(); } function setWidth(width) { viewWidth = width; + colPositions.clear(); colContentPositions.clear(); weekNumberWidth = 0; @@ -2461,35 +2467,30 @@ function BasicView(element, calendar, viewName) { /* Semi-transparent Overlay Helpers ------------------------------------------------------*/ - - + // TODO: should be consolidated with AgendaView's methods + + function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive + if (refreshCoordinateGrid) { coordinateGrid.build(); } - var rowStart = cloneDate(t.visStart); - var rowEnd = addDays(cloneDate(rowStart), colCnt); - for (var i=0; i" + - "
    " + - ""; - - if (showWeekNumbers) { - s += ""; - } - - for (i=0; i"; // fc- needed for setDayID - } - s += - "" + - "" + - "" + - "" + - "" + - ""; - for (i=0; i" + // fc- needed for setDayID - "
    " + - "
    " + - "
     
    " + - "
    " + - "
    " + - ""; - } - s += - "
    " + - "" + - "" + - "
    "; + html += + "" + + htmlEscape(weekNumberTitle) + + "
    " + + "
    " + + htmlEscape(formatDate(date, weekNumberFormat)) + + "
    " + + "
    "; - } - else { - s += "  
      
    "; - dayTable = $(s).appendTo(element); - dayHead = dayTable.find('thead'); - dayHeadCells = dayHead.find('th').slice(1, -1); - dayBody = dayTable.find('tbody'); - dayBodyCells = dayBody.find('td').slice(0, -1); - dayBodyCellInners = dayBodyCells.find('div.fc-day-content div'); - dayBodyFirstCell = dayBodyCells.eq(0); - dayBodyFirstCellStretcher = dayBodyFirstCell.find('> div'); - - markFirstLast(dayHead.add(dayHead.find('tr'))); - markFirstLast(dayBody.add(dayBody.find('tr'))); - - axisFirstCells = dayHead.find('th:first'); - gutterCells = dayTable.find('.fc-agenda-gutter'); + buildDayTable(); slotLayer = $("
    ") @@ -3154,7 +2947,7 @@ function AgendaView(element, calendar, viewName) { if (opt('allDaySlot')) { daySegmentContainer = - $("
    ") + $("
    ") .appendTo(slotLayer); s = @@ -3172,9 +2965,6 @@ function AgendaView(element, calendar, viewName) { dayBind(allDayRow.find('td')); - axisFirstCells = axisFirstCells.add(allDayTable.find('th:first')); - gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter')); - slotLayer.append( "
    " + "
    " + @@ -3191,13 +2981,13 @@ function AgendaView(element, calendar, viewName) { $("
    ") .appendTo(slotLayer); - slotContent = + slotContainer = $("
    ") .appendTo(slotScroller); slotSegmentContainer = - $("
    ") - .appendTo(slotContent); + $("
    ") + .appendTo(slotContainer); s = "" + @@ -3223,64 +3013,183 @@ function AgendaView(element, calendar, viewName) { s += "" + "
    "; - slotTable = $(s).appendTo(slotContent); - slotTableFirstInner = slotTable.find('div:first'); + slotTable = $(s).appendTo(slotContainer); slotBind(slotTable.find('td')); + } + + + + /* Build Day Table + -----------------------------------------------------------------------*/ + + + function buildDayTable() { + var html = buildDayTableHTML(); + + if (dayTable) { + dayTable.remove(); + } + dayTable = $(html).appendTo(element); + + dayHead = dayTable.find('thead'); + dayHeadCells = dayHead.find('th').slice(1, -1); // exclude gutter + dayBody = dayTable.find('tbody'); + dayBodyCells = dayBody.find('td').slice(0, -1); // exclude gutter + dayBodyCellInners = dayBodyCells.find('> div'); + dayBodyCellContentInners = dayBodyCells.find('.fc-day-content > div'); + + dayBodyFirstCell = dayBodyCells.eq(0); + dayBodyFirstCellStretcher = dayBodyCellInners.eq(0); - axisFirstCells = axisFirstCells.add(slotTable.find('th:first')); + markFirstLast(dayHead.add(dayHead.find('tr'))); + markFirstLast(dayBody.add(dayBody.find('tr'))); + + // TODO: now that we rebuild the cells every time, we should call dayRender } - - - - function updateCells() { - var i; - var headCell; - var bodyCell; + + + function buildDayTableHTML() { + var html = + "" + + buildDayTableHeadHTML() + + buildDayTableBodyHTML() + + "
    "; + + return html; + } + + + function buildDayTableHeadHTML() { + var headerClass = tm + "-widget-header"; var date; - var today = clearTime(new Date()); + var html = ''; + var weekText; + var col; + + html += + "" + + ""; if (showWeekNumbers) { - var weekText = formatDate(colDate(0), weekNumberFormat); + date = cellToDate(0, 0); + weekText = formatDate(date, weekNumberFormat); if (rtl) { - weekText = weekText + weekNumberTitle; + weekText += weekNumberTitle; } else { weekText = weekNumberTitle + weekText; } - dayHead.find('.fc-week-number').text(weekText); + html += + "" + + htmlEscape(weekText) + + ""; + } + else { + html += " "; } - for (i=0; i" + + htmlEscape(formatDate(date, colFormat)) + + ""; } + + html += + " " + + "" + + ""; + + return html; } - - - - function setHeight(height, dateChanged) { - if (height === undefined) { - height = viewHeight; - } - viewHeight = height; - slotTopCache = {}; - - var headHeight = dayBody.position().top; - var allDayHeight = slotScroller.position().top; // including divider - var bodyHeight = Math.min( // total body height, including borders - height - headHeight, // when scrollbars + + + function buildDayTableBodyHTML() { + var headerClass = tm + "-widget-header"; // TODO: make these when updateOptions() called + var contentClass = tm + "-widget-content"; + var date; + var today = clearTime(new Date()); + var col; + var cellsHTML; + var cellHTML; + var classNames; + var html = ''; + + html += + "" + + "" + + " "; + + cellsHTML = ''; + + for (col=0; col" + + "
    " + + "
    " + + "
     
    " + + "
    " + + "
    " + + ""; + + cellsHTML += cellHTML; + } + + html += cellsHTML; + html += + " " + + "" + + ""; + + return html; + } + + + // TODO: data-date on the cells + + + + /* Dimensions + -----------------------------------------------------------------------*/ + + + function setHeight(height) { + if (height === undefined) { + height = viewHeight; + } + viewHeight = height; + slotTopCache = {}; + + var headHeight = dayBody.position().top; + var allDayHeight = slotScroller.position().top; // including divider + var bodyHeight = Math.min( // total body height, including borders + height - headHeight, // when scrollbars slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border ); - + dayBodyFirstCellStretcher .height(bodyHeight - vsides(dayBodyFirstCell)); @@ -3288,21 +3197,25 @@ function AgendaView(element, calendar, viewName) { slotScroller.height(bodyHeight - allDayHeight - 1); - slotHeight = slotTableFirstInner.height() + 1; // +1 for border + // the stylesheet guarantees that the first row has no border. + // this allows .height() to work well cross-browser. + slotHeight = slotTable.find('tr:first').height() + 1; // +1 for bottom border snapRatio = opt('slotMinutes') / snapMinutes; snapHeight = slotHeight / snapRatio; - - if (dateChanged) { - resetScroll(); - } } - function setWidth(width) { viewWidth = width; + colPositions.clear(); colContentPositions.clear(); + + var axisFirstCells = dayHead.find('th:first'); + if (allDayTable) { + axisFirstCells = axisFirstCells.add(allDayTable.find('th:first')); + } + axisFirstCells = axisFirstCells.add(slotTable.find('th:first')); axisWidth = 0; setOuterWidth( @@ -3314,8 +3227,12 @@ function AgendaView(element, calendar, viewName) { axisWidth ); + var gutterCells = dayTable.find('.fc-agenda-gutter'); + if (allDayTable) { + gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter')); + } + var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7) - //slotTable.width(slotTableWidth); gutterWidth = slotScroller.width() - slotTableWidth; if (gutterWidth) { @@ -3337,6 +3254,10 @@ function AgendaView(element, calendar, viewName) { + /* Scrolling + -----------------------------------------------------------------------*/ + + function resetScroll() { var d0 = zeroDate(); var scrollDate = cloneDate(d0); @@ -3348,15 +3269,10 @@ function AgendaView(element, calendar, viewName) { scroll(); setTimeout(scroll, 0); // overrides any previous scroll state made by the browser } - - - function beforeHide() { - savedScrollTop = slotScroller.scrollTop(); - } - - - function afterShow() { - slotScroller.scrollTop(savedScrollTop); + + + function afterRender() { // after the view has been freshly rendered and sized + resetScroll(); } @@ -3380,7 +3296,7 @@ function AgendaView(element, calendar, viewName) { function slotClick(ev) { if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth)); - var date = colDate(col); + var date = cellToDate(0, col); var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data if (rowMatch) { var mins = parseInt(rowMatch[1]) * opt('slotMinutes'); @@ -3398,26 +3314,26 @@ function AgendaView(element, calendar, viewName) { /* Semi-transparent Overlay Helpers -----------------------------------------------------*/ - + // TODO: should be consolidated with BasicView's methods + + + function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive - function renderDayOverlay(startDate, endDate, refreshCoordinateGrid) { // endDate is exclusive if (refreshCoordinateGrid) { coordinateGrid.build(); } - var visStart = cloneDate(t.visStart); - var startCol, endCol; - if (rtl) { - startCol = dayDiff(endDate, visStart)*dis+dit+1; - endCol = dayDiff(startDate, visStart)*dis+dit+1; - }else{ - startCol = dayDiff(startDate, visStart); - endCol = dayDiff(endDate, visStart); - } - startCol = Math.max(0, startCol); - endCol = Math.min(colCnt, endCol); - if (startCol < endCol) { + + var segments = rangeToSegments(overlayStart, overlayEnd); + + for (var i=0; i= 0 && col < colCnt) { // only works when times are on same day - var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords + var rect = coordinateGrid.rect(0, col, 0, col, slotContainer); // only for horizontal coords var top = timePosition(startDate, startDate); var bottom = timePosition(startDate, endDate); if (bottom > top) { // protect against selections that are entirely before or after visible range @@ -3633,10 +3533,9 @@ function AgendaView(element, calendar, viewName) { var helperRes = helperOption(startDate, endDate); if (helperRes) { rect.position = 'absolute'; - rect.zIndex = 8; selectionHelper = $(helperRes) .css(rect) - .appendTo(slotContent); + .appendTo(slotContainer); } }else{ rect.isStart = true; // conside rect a "seg" now @@ -3655,7 +3554,7 @@ function AgendaView(element, calendar, viewName) { } if (selectionHelper) { slotBind(selectionHelper); - slotContent.append(selectionHelper); + slotContainer.append(selectionHelper); setOuterWidth(selectionHelper, rect.width, true); // needs to be after appended setOuterHeight(selectionHelper, rect.height, true); } @@ -3682,15 +3581,15 @@ function AgendaView(element, calendar, viewName) { var dates; hoverListener.start(function(cell, origCell) { clearSelection(); - if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) { - var d1 = cellDate(origCell); - var d2 = cellDate(cell); + if (cell && cell.col == origCell.col && !getIsCellAllDay(cell)) { + var d1 = realCellToDate(origCell); + var d2 = realCellToDate(cell); dates = [ d1, addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes d2, addMinutes(cloneDate(d2), snapMinutes) - ].sort(cmp); + ].sort(dateCompare); renderSlotSelection(dates[0], dates[3]); }else{ dates = null; @@ -3707,10 +3606,10 @@ function AgendaView(element, calendar, viewName) { }); } } - - + + function reportDayClick(date, allDay, ev) { - trigger('dayClick', dayBodyCells[dayOfWeekCol(date.getDay())], date, allDay, ev); + trigger('dayClick', dayBodyCells[dateToCell(date).col], date, allDay, ev); } @@ -3723,10 +3622,10 @@ function AgendaView(element, calendar, viewName) { hoverListener.start(function(cell) { clearOverlays(); if (cell) { - if (cellIsAllDay(cell)) { + if (getIsCellAllDay(cell)) { renderCellOverlay(cell.row, cell.col, cell.row, cell.col); }else{ - var d1 = cellDate(cell); + var d1 = realCellToDate(cell); var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes')); renderSlotOverlay(d1, d2); } @@ -3739,10 +3638,10 @@ function AgendaView(element, calendar, viewName) { var cell = hoverListener.stop(); clearOverlays(); if (cell) { - trigger('drop', _dragElement, cellDate(cell), cellIsAllDay(cell), ev, ui); + trigger('drop', _dragElement, realCellToDate(cell), getIsCellAllDay(cell), ev, ui); } } - + } @@ -3754,22 +3653,17 @@ function AgendaEventRenderer() { // exports t.renderEvents = renderEvents; - t.compileDaySegs = compileDaySegs; // for DayEventRenderer t.clearEvents = clearEvents; t.slotSegHtml = slotSegHtml; - t.bindDaySeg = bindDaySeg; // imports DayEventRenderer.call(t); var opt = t.opt; var trigger = t.trigger; - //var setOverflowHidden = t.setOverflowHidden; var isEventDraggable = t.isEventDraggable; var isEventResizable = t.isEventResizable; var eventEnd = t.eventEnd; - var reportEvents = t.reportEvents; - var reportEventClear = t.reportEventClear; var eventElementHandlers = t.eventElementHandlers; var setHeight = t.setHeight; var getDaySegmentContainer = t.getDaySegmentContainer; @@ -3778,15 +3672,15 @@ function AgendaEventRenderer() { var getMaxMinute = t.getMaxMinute; var getMinMinute = t.getMinMinute; var timePosition = t.timePosition; + var getIsCellAllDay = t.getIsCellAllDay; var colContentLeft = t.colContentLeft; var colContentRight = t.colContentRight; - var renderDaySegs = t.renderDaySegs; - var resizableDayEvent = t.resizableDayEvent; // TODO: streamline binding architecture + var cellToDate = t.cellToDate; var getColCnt = t.getColCnt; var getColWidth = t.getColWidth; var getSnapHeight = t.getSnapHeight; var getSnapMinutes = t.getSnapMinutes; - var getBodyContent = t.getBodyContent; + var getSlotContainer = t.getSlotContainer; var reportEventElement = t.reportEventElement; var showEvents = t.showEvents; var hideEvents = t.hideEvents; @@ -3794,10 +3688,15 @@ function AgendaEventRenderer() { var eventResize = t.eventResize; var renderDayOverlay = t.renderDayOverlay; var clearOverlays = t.clearOverlays; + var renderDayEvents = t.renderDayEvents; var calendar = t.calendar; var formatDate = calendar.formatDate; var formatDates = calendar.formatDates; - + + + // overrides + t.draggableDayEvent = draggableDayEvent; + /* Rendering @@ -3805,7 +3704,6 @@ function AgendaEventRenderer() { function renderEvents(events, modifiedEventId) { - reportEvents(events); var i, len=events.length, dayEvents=[], slotEvents=[]; @@ -3816,68 +3714,96 @@ function AgendaEventRenderer() { slotEvents.push(events[i]); } } + if (opt('allDaySlot')) { - renderDaySegs(compileDaySegs(dayEvents), modifiedEventId); + renderDayEvents(dayEvents, modifiedEventId); setHeight(); // no params means set to viewHeight } + renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId); - trigger('eventAfterAllRender'); } function clearEvents() { - reportEventClear(); getDaySegmentContainer().empty(); getSlotSegmentContainer().empty(); } - - - function compileDaySegs(events) { - var levels = stackSegs(sliceSegs(events, $.map(events, exclEndDay), t.visStart, t.visEnd)), - i, levelCnt=levels.length, level, - j, seg, - segs=[]; - for (i=0; i start && eventStart < end) { + if (eventStart < start) { + segStart = cloneDate(start); + isStart = false; + }else{ + segStart = eventStart; + isStart = true; + } + if (eventEnd > end) { + segEnd = cloneDate(end); + isEnd = false; + }else{ + segEnd = eventEnd; + isEnd = true; + } + segs.push({ + event: event, + start: segStart, + end: segEnd, + isStart: isStart, + isEnd: isEnd + }); + } + } + return segs.sort(compareSlotSegs); + } + + function slotEventEnd(event) { if (event.end) { return cloneDate(event.end); @@ -3888,38 +3814,29 @@ function AgendaEventRenderer() { // renders events in the 'time slots' at the bottom + // TODO: when we refactor this, when user returns `false` eventRender, don't have empty space + // TODO: refactor will include using pixels to detect collisions instead of dates (handy for seg cmp) function renderSlotSegs(segs, modifiedEventId) { var i, segCnt=segs.length, seg, event, - classes, - top, bottom, - colI, levelI, forward, - leftmost, - availWidth, - outerWidth, + top, + bottom, + columnLeft, + columnRight, + columnWidth, + width, left, - html='', + right, + html = '', eventElements, eventElement, triggerRes, - vsideCache={}, - hsideCache={}, - key, val, titleElement, height, slotSegmentContainer = getSlotSegmentContainer(), - rtl, dis, dit, - colCnt = getColCnt(); - - if (rtl = opt('isRTL')) { - dis = -1; - dit = colCnt - 1; - }else{ - dis = 1; - dit = 0; - } + isRTL = opt('isRTL'); // calculate position/dimensions, create html for (i=0; i" + "
    " + "
    " + htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) + "
    " + "
    " + - htmlEscape(event.title) + + htmlEscape(event.title || '') + "
    " + "
    " + "
    "; @@ -4071,18 +4007,6 @@ function AgendaEventRenderer() { } - function bindDaySeg(event, eventElement, seg) { - if (isEventDraggable(event)) { - draggableDayEvent(event, eventElement, seg.isStart); - } - if (seg.isEnd && isEventResizable(event)) { - resizableDayEvent(event, eventElement, seg); - } - eventElementHandlers(event, eventElement); - // needs to be after, because resizableDayEvent might stopImmediatePropagation on click - } - - function bindSlotSeg(event, eventElement, seg) { var timeElement = eventElement.find('div.fc-event-time'); if (isEventDraggable(event)) { @@ -4101,32 +4025,34 @@ function AgendaEventRenderer() { // when event starts out FULL-DAY + // overrides DayEventRenderer's version because it needs to account for dragging elements + // to and from the slot area. - function draggableDayEvent(event, eventElement, isStart) { + function draggableDayEvent(event, eventElement, seg) { + var isStart = seg.isStart; var origWidth; var revert; - var allDay=true; + var allDay = true; var dayDelta; - var dis = opt('isRTL') ? -1 : 1; var hoverListener = getHoverListener(); var colWidth = getColWidth(); var snapHeight = getSnapHeight(); var snapMinutes = getSnapMinutes(); var minMinute = getMinMinute(); eventElement.draggable({ - zIndex: 9, opacity: opt('dragOpacity', 'month'), // use whatever the month view was using revertDuration: opt('dragRevertDuration'), start: function(ev, ui) { trigger('eventDragStart', eventElement, event, ev, ui); hideEvents(event, eventElement); origWidth = eventElement.width(); - hoverListener.start(function(cell, origCell, rowDelta, colDelta) { + hoverListener.start(function(cell, origCell) { clearOverlays(); if (cell) { - //setOverflowHidden(true); revert = false; - dayDelta = colDelta * dis; + var origDate = cellToDate(0, origCell.col); + var date = cellToDate(0, cell.col); + dayDelta = dayDiff(date, origDate); if (!cell.row) { // on full-days renderDayOverlay( @@ -4157,7 +4083,6 @@ function AgendaEventRenderer() { revert = revert || (allDay && !dayDelta); }else{ resetElement(); - //setOverflowHidden(false); revert = true; } eventElement.draggable('option', 'revert', revert); @@ -4176,14 +4101,13 @@ function AgendaEventRenderer() { // changed! var minuteDelta = 0; if (!allDay) { - minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / snapHeight) + minuteDelta = Math.round((eventElement.offset().top - getSlotContainer().offset().top) / snapHeight) * snapMinutes + minMinute - (event.start.getHours() * 60 + event.start.getMinutes()); } eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui); } - //setOverflowHidden(false); } }); function resetElement() { @@ -4201,79 +4125,147 @@ function AgendaEventRenderer() { // when event starts out IN TIMESLOTS function draggableSlotEvent(event, eventElement, timeElement) { - var origPosition; - var allDay=false; - var dayDelta; - var minuteDelta; - var prevMinuteDelta; - var dis = opt('isRTL') ? -1 : 1; - var hoverListener = getHoverListener(); + var coordinateGrid = t.getCoordinateGrid(); var colCnt = getColCnt(); var colWidth = getColWidth(); var snapHeight = getSnapHeight(); var snapMinutes = getSnapMinutes(); + + // states + var origPosition; // original position of the element, not the mouse + var origCell; + var isInBounds, prevIsInBounds; + var isAllDay, prevIsAllDay; + var colDelta, prevColDelta; + var dayDelta; // derived from colDelta + var minuteDelta, prevMinuteDelta; + eventElement.draggable({ - zIndex: 9, scroll: false, - grid: [colWidth, snapHeight], + grid: [ colWidth, snapHeight ], axis: colCnt==1 ? 'y' : false, opacity: opt('dragOpacity'), revertDuration: opt('dragRevertDuration'), start: function(ev, ui) { + trigger('eventDragStart', eventElement, event, ev, ui); hideEvents(event, eventElement); + + coordinateGrid.build(); + + // initialize states origPosition = eventElement.position(); + origCell = coordinateGrid.cell(ev.pageX, ev.pageY); + isInBounds = prevIsInBounds = true; + isAllDay = prevIsAllDay = getIsCellAllDay(origCell); + colDelta = prevColDelta = 0; + dayDelta = 0; minuteDelta = prevMinuteDelta = 0; - hoverListener.start(function(cell, origCell, rowDelta, colDelta) { - eventElement.draggable('option', 'revert', !cell); - clearOverlays(); - if (cell) { - dayDelta = colDelta * dis; - if (opt('allDaySlot') && !cell.row) { - // over full days - if (!allDay) { - // convert to temporary all-day event - allDay = true; - timeElement.hide(); - eventElement.draggable('option', 'grid', null); - } - renderDayOverlay( - addDays(cloneDate(event.start), dayDelta), - addDays(exclEndDay(event), dayDelta) - ); - }else{ - // on slots - resetElement(); - } - } - }, ev, 'drag'); + }, drag: function(ev, ui) { - minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes; - if (minuteDelta != prevMinuteDelta) { - if (!allDay) { - updateTimeText(minuteDelta); + + // NOTE: this `cell` value is only useful for determining in-bounds and all-day. + // Bad for anything else due to the discrepancy between the mouse position and the + // element position while snapping. (problem revealed in PR #55) + // + // PS- the problem exists for draggableDayEvent() when dragging an all-day event to a slot event. + // We should overhaul the dragging system and stop relying on jQuery UI. + var cell = coordinateGrid.cell(ev.pageX, ev.pageY); + + // update states + isInBounds = !!cell; + if (isInBounds) { + isAllDay = getIsCellAllDay(cell); + + // calculate column delta + colDelta = Math.round((ui.position.left - origPosition.left) / colWidth); + if (colDelta != prevColDelta) { + // calculate the day delta based off of the original clicked column and the column delta + var origDate = cellToDate(0, origCell.col); + var col = origCell.col + colDelta; + col = Math.max(0, col); + col = Math.min(colCnt-1, col); + var date = cellToDate(0, col); + dayDelta = dayDiff(date, origDate); } + + // calculate minute delta (only if over slots) + if (!isAllDay) { + minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes; + } + } + + // any state changes? + if ( + isInBounds != prevIsInBounds || + isAllDay != prevIsAllDay || + colDelta != prevColDelta || + minuteDelta != prevMinuteDelta + ) { + + updateUI(); + + // update previous states for next time + prevIsInBounds = isInBounds; + prevIsAllDay = isAllDay; + prevColDelta = colDelta; prevMinuteDelta = minuteDelta; } + + // if out-of-bounds, revert when done, and vice versa. + eventElement.draggable('option', 'revert', !isInBounds); + }, stop: function(ev, ui) { - var cell = hoverListener.stop(); + clearOverlays(); trigger('eventDragStop', eventElement, event, ev, ui); - if (cell && (dayDelta || minuteDelta || allDay)) { - // changed! - eventDrop(this, event, dayDelta, allDay ? 0 : minuteDelta, allDay, ev, ui); - }else{ - // either no change or out-of-bounds (draggable has already reverted) - resetElement(); + + if (isInBounds && (isAllDay || dayDelta || minuteDelta)) { // changed! + eventDrop(this, event, dayDelta, isAllDay ? 0 : minuteDelta, isAllDay, ev, ui); + } + else { // either no change or out-of-bounds (draggable has already reverted) + + // reset states for next time, and for updateUI() + isInBounds = true; + isAllDay = false; + colDelta = 0; + dayDelta = 0; + minuteDelta = 0; + + updateUI(); eventElement.css('filter', ''); // clear IE opacity side-effects - eventElement.css(origPosition); // sometimes fast drags make event revert to wrong position - updateTimeText(0); + + // sometimes fast drags make event revert to wrong position, so reset. + // also, if we dragged the element out of the area because of snapping, + // but the *mouse* is still in bounds, we need to reset the position. + eventElement.css(origPosition); + showEvents(event, eventElement); } } }); + + function updateUI() { + clearOverlays(); + if (isInBounds) { + if (isAllDay) { + timeElement.hide(); + eventElement.draggable('option', 'grid', null); // disable grid snapping + renderDayOverlay( + addDays(cloneDate(event.start), dayDelta), + addDays(exclEndDay(event), dayDelta) + ); + } + else { + updateTimeText(minuteDelta); + timeElement.css('display', ''); // show() was causing display=inline + eventElement.draggable('option', 'grid', [colWidth, snapHeight]); // re-enable grid snapping + } + } + } + function updateTimeText(minuteDelta) { var newStart = addMinutes(cloneDate(event.start), minuteDelta); var newEnd; @@ -4282,14 +4274,7 @@ function AgendaEventRenderer() { } timeElement.text(formatDates(newStart, newEnd, opt('timeFormat'))); } - function resetElement() { - // convert back to original slot-event - if (allDay) { - timeElement.css('display', ''); // show() was causing display=inline - eventElement.draggable('option', 'grid', [colWidth, snapHeight]); - allDay = false; - } - } + } @@ -4310,7 +4295,6 @@ function AgendaEventRenderer() { start: function(ev, ui) { snapDelta = prevSnapDelta = 0; hideEvents(event, eventElement); - eventElement.css('z-index', 9); trigger('eventResizeStart', this, event, ev, ui); }, resize: function(ev, ui) { @@ -4333,7 +4317,6 @@ function AgendaEventRenderer() { if (snapDelta) { eventResize(this, event, 0, snapMinutes*snapDelta, ev, ui); }else{ - eventElement.css('z-index', 8); showEvents(event, eventElement); // BUG: if event was really short, need to put title back in span } @@ -4345,23 +4328,211 @@ function AgendaEventRenderer() { } -function countForwardSegs(levels) { - var i, j, k, level, segForward, segBack; - for (i=levels.length-1; i>0; i--) { - level = levels[i]; - for (j=0; j seg2.start && seg1.start < seg2.end; +} + + +// A cmp function for determining which forward segment to rely on more when computing coordinates. +function compareForwardSlotSegs(seg1, seg2) { + // put higher-pressure first + return seg2.forwardPressure - seg1.forwardPressure || + // put segments that are closer to initial edge first (and favor ones with no coords yet) + (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) || + // do normal sorting... + compareSlotSegs(seg1, seg2); +} + + +// A cmp function for determining which segment should be closer to the initial edge +// (the left edge on a left-to-right calendar). +function compareSlotSegs(seg1, seg2) { + return seg1.start - seg2.start || // earlier start time goes first + (seg2.end - seg2.start) - (seg1.end - seg1.start) || // tie? longer-duration goes first + (seg1.event.title || '').localeCompare(seg2.event.title); // tie? alphabetically by title +} + ;; @@ -4376,13 +4547,13 @@ function View(element, calendar, viewName) { t.name = viewName; t.opt = opt; t.trigger = trigger; - //t.setOverflowHidden = setOverflowHidden; t.isEventDraggable = isEventDraggable; t.isEventResizable = isEventResizable; - t.reportEvents = reportEvents; + t.setEventData = setEventData; + t.clearEventData = clearEventData; t.eventEnd = eventEnd; t.reportEventElement = reportEventElement; - t.reportEventClear = reportEventClear; + t.triggerEventDestroy = triggerEventDestroy; t.eventElementHandlers = eventElementHandlers; t.showEvents = showEvents; t.hideEvents = hideEvents; @@ -4400,16 +4571,16 @@ function View(element, calendar, viewName) { // locals - var eventsByID = {}; - var eventElements = []; - var eventElementsByID = {}; + var eventsByID = {}; // eventID mapped to array of events (there can be multiple b/c of repeating events) + var eventElementsByID = {}; // eventID mapped to array of jQuery elements + var eventElementCouples = []; // array of objects, { event, element } // TODO: unify with segment system var options = calendar.options; function opt(name, viewNameOverride) { var v = options[name]; - if (typeof v == 'object') { + if ($.isPlainObject(v)) { return smartProperty(v, viewNameOverride || viewName); } return v; @@ -4423,26 +4594,37 @@ function View(element, calendar, viewName) { ); } - - /* - function setOverflowHidden(bool) { - element.css('overflow', bool ? 'hidden' : ''); - } - */ - + + + /* Event Editable Boolean Calculations + ------------------------------------------------------------------------------*/ + function isEventDraggable(event) { - return isEventEditable(event) && !opt('disableDragging'); + var source = event.source || {}; + return firstDefined( + event.startEditable, + source.startEditable, + opt('eventStartEditable'), + event.editable, + source.editable, + opt('editable') + ) + && !opt('disableDragging'); // deprecated } function isEventResizable(event) { // but also need to make sure the seg.isEnd == true - return isEventEditable(event) && !opt('disableResizing'); - } - - - function isEventEditable(event) { - return firstDefined(event.editable, (event.source || {}).editable, opt('editable')); + var source = event.source || {}; + return firstDefined( + event.durationEditable, + source.durationEditable, + opt('eventDurationEditable'), + event.editable, + source.editable, + opt('editable') + ) + && !opt('disableResizing'); // deprecated } @@ -4451,8 +4633,7 @@ function View(element, calendar, viewName) { ------------------------------------------------------------------------------*/ - // report when view receives new events - function reportEvents(events) { // events are already normalized at this point + function setEventData(events) { // events are already normalized at this point eventsByID = {}; var i, len=events.length, event; for (i=0; i