aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Jardine <kevinjardine@yahoo.com>2012-05-29 18:09:16 +0200
committerKevin Jardine <kevinjardine@yahoo.com>2012-05-29 18:09:16 +0200
commit321fbfdb059e39b921e13ba034855b019981fa44 (patch)
tree14c7483b68774e40fc2dd3bb73e412e426a5ebd7
parentf22f6fd7a985b773bce95accf5172cdc2524575c (diff)
downloadelgg-321fbfdb059e39b921e13ba034855b019981fa44.tar.gz
elgg-321fbfdb059e39b921e13ba034855b019981fa44.tar.bz2
added click on calendar to preselect new event date
-rw-r--r--models/model.php17
-rw-r--r--start.php2
-rw-r--r--views/default/event_calendar/css.php4
-rw-r--r--views/default/event_calendar/full_calendar_view.php39
4 files changed, 55 insertions, 7 deletions
diff --git a/models/model.php b/models/model.php
index b53471a44..d25c8dca3 100644
--- a/models/model.php
+++ b/models/model.php
@@ -1533,7 +1533,7 @@ function event_calendar_get_page_content_list($page_type,$container_guid,$start_
return elgg_view_page($title,$body);
}
-function event_calendar_get_page_content_edit($page_type,$guid) {
+function event_calendar_get_page_content_edit($page_type,$guid,$start_date='') {
elgg_load_js('elgg.event_calendar');
$vars = array();
$vars['id'] = 'event-calendar-edit';
@@ -1575,7 +1575,7 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
$body_vars['group_guid'] = $guid;
elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$guid);
elgg_push_breadcrumb(elgg_echo('event_calendar:add_event_title'));
- $body_vars['form_data'] = event_calendar_prepare_edit_form_vars(NULL,$page_type);
+ $body_vars['form_data'] = event_calendar_prepare_edit_form_vars(NULL,$page_type,$start_date);
$content = elgg_view_form('event_calendar/edit', $vars, $body_vars);
} else {
$content = elgg_echo('event_calendar:no_group');
@@ -1585,7 +1585,7 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
elgg_push_breadcrumb(elgg_echo('event_calendar:add_event_title'));
- $body_vars['form_data'] = event_calendar_prepare_edit_form_vars(NULL,$page_type);
+ $body_vars['form_data'] = event_calendar_prepare_edit_form_vars(NULL,$page_type,$start_date);
$content = elgg_view_form('event_calendar/edit', $vars, $body_vars);
}
@@ -1604,20 +1604,25 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
* @param ElggObject $event
* @return array
*/
-function event_calendar_prepare_edit_form_vars($event = NULL, $page_type = '') {
+function event_calendar_prepare_edit_form_vars($event = NULL, $page_type = '', $start_date = '') {
// input names => defaults
$now = time();
$iso_date = date('Y-m-d',$now);
$now_midnight = strtotime($iso_date);
+ if ($start_date) {
+ $start_date = strtotime($start_date);
+ } else {
+ $start_date = $now+60*60;
+ }
$start_time = floor(($now-$now_midnight)/60) + 60;
$start_time = floor($start_time/5)*5;
$values = array(
'title' => NULL,
'description' => NULL,
'venue' => NULL,
- 'start_date' => $now+60*60,
- 'end_date' => $now+2*60*60,
+ 'start_date' => $start_date,
+ 'end_date' => $start_date+60*60,
'start_time' => $start_time,
'end_time' => $start_time + 60,
'spots' => NULL,
diff --git a/start.php b/start.php
index 9d3d45e4d..8c8bba19b 100644
--- a/start.php
+++ b/start.php
@@ -202,7 +202,7 @@ function event_calendar_page_handler($page) {
gatekeeper();
$group_guid = 0;
}
- echo event_calendar_get_page_content_edit($page_type,$group_guid);
+ echo event_calendar_get_page_content_edit($page_type,$group_guid,$page[2]);
break;
case 'edit':
gatekeeper();
diff --git a/views/default/event_calendar/css.php b/views/default/event_calendar/css.php
index 9461a7fe9..b1e17e4df 100644
--- a/views/default/event_calendar/css.php
+++ b/views/default/event_calendar/css.php
@@ -275,3 +275,7 @@ li.event-calendar-filter-menu-show-only {
clear: both;
margin-bottom: 5px;
}
+
+.event-calendar-date-selected {
+ background-color: #DDDDFF;
+}
diff --git a/views/default/event_calendar/full_calendar_view.php b/views/default/event_calendar/full_calendar_view.php
index d7b6d97a2..d86a3ac27 100644
--- a/views/default/event_calendar/full_calendar_view.php
+++ b/views/default/event_calendar/full_calendar_view.php
@@ -15,6 +15,28 @@ handleEventClick = function(event) {
}
};
+handleDayClick = function(date,allDay,jsEvent,view) {
+ var iso = getISODate(date);
+ var link = $('.elgg-menu-item-event-calendar-0add').find('a').attr('href');
+ var ss = link.split('/');
+ var link = $('.elgg-menu-item-event-calendar-0add').find('a').attr('href');
+ var ss = link.split('/');
+ var last_ss = ss[ss.length-1];
+ var group_guid;
+ if (last_ss == 'add') {
+ group_guid = 0;
+ } else if (last_ss.split('-').length == 3) {
+ group_guid = ss[ss.length-2];
+ } else {
+ group_guid = last_ss;
+ }
+ var url = elgg.get_site_url();
+ $('.elgg-menu-item-event-calendar-0add').find('a').attr('href',url+'event_calendar/add/'+group_guid+'/'+iso);
+ $('.elgg-menu-item-event-calendar-1schedule').find('a').attr('href',url+'event_calendar/schedule/'+group_guid+'/'+iso);
+ $('.fc-widget-content').removeClass('event-calendar-date-selected');
+ $(this).addClass('event-calendar-date-selected');
+}
+
handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) {
if (!confirm("<?php echo elgg_echo('event_calendar:are_you_sure'); ?>")) {
@@ -54,6 +76,22 @@ handleGetEvents = function(start, end, callback) {
callback(events);
}
});
+ // reset date links and classes
+ $('.fc-widget-content').removeClass('event-calendar-date-selected');
+ var link = $('.elgg-menu-item-event-calendar-0add').find('a').attr('href');
+ var ss = link.split('/');
+ var last_ss = ss[ss.length-1];
+ var group_guid;
+ if (last_ss == 'add') {
+ group_guid = 0;
+ } else if (last_ss.split('-').length == 3) {
+ group_guid = ss[ss.length-2];
+ } else {
+ group_guid = last_ss;
+ }
+ var url = elgg.get_site_url();
+ $('.elgg-menu-item-event-calendar-0add').find('a').attr('href',url+'event_calendar/add/'+group_guid);
+ $('.elgg-menu-item-event-calendar-1schedule').find('a').attr('href',url+'event_calendar/schedule/'+group_guid);
}
$(document).ready(function() {
@@ -69,6 +107,7 @@ $(document).ready(function() {
slotMinutes: 15,
eventDrop: handleEventDrop,
eventClick: handleEventClick,
+ dayClick: handleDayClick,
events: handleGetEvents
});
});