1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
//<script type="text/javascript">
elgg.provide('elgg.event_calendar');
elgg.event_calendar.init = function () {
$('.event_calendar_paged_checkbox').click(elgg.event_calendar.handlePagedPersonalCalendarToggle);
$('.event-calendar-personal-calendar-toggle').click(elgg.event_calendar.handleDisplayPagePersonalCalendarToggle);
$('#event-calendar-region').change(elgg.event_calendar.handleRegionChange);
$('#event-calendar-ical-link').click(elgg.event_calendar.handleIcalPopup);
$('.event-calendar-repeating-unselected').each(elgg.event_calendar.setRepeatingClass);
$('.event-calendar-repeating-unselected').live('click',elgg.event_calendar.handleRepeatingSelect);
$('.event-calendar-repeating-selected').live('click',elgg.event_calendar.handleRepeatingUnselect);
$('#event-calendar-edit').submit(elgg.event_calendar.handleEditFormSubmit);
var all_day_field = $('[name="all_day"][type="checkbox"]');
if (all_day_field.is(':checked')) {
$('[name="start_time"]').val(0);
$('[name="start_time"]').attr('disabled','disabled');
$('[name="end_time"]').val(0);
$('[name="end_time"]').attr('disabled','disabled');
}
all_day_field.change(elgg.event_calendar.handleAllDayField);
}
elgg.event_calendar.handleAllDayField = function(e) {
var field = $('[name="start_time"]');
if (field.attr('disabled') == 'disabled') {
field.removeAttr('disabled');
} else {
field.attr('disabled','disabled');
}
field = $('[name="end_time"]');
if (field.attr('disabled') == 'disabled') {
field.removeAttr('disabled');
} else {
field.attr('disabled','disabled');
}
}
elgg.event_calendar.handleEditFormSubmit = function(e) {
if ($.trim($('[name="title"]').val()) == '') {
alert(elgg.echo('event_calendar:edit_form:error:missing_title'));
e.preventDefault();
}
}
elgg.event_calendar.setRepeatingClass = function(e) {
var id = $(this).attr('id');
if ($("[name='"+id+"-value']").val() == 1) {
$(this).removeClass('event-calendar-repeating-unselected');
$(this).addClass('event-calendar-repeating-selected');
}
}
elgg.event_calendar.handleRepeatingSelect = function(e) {
$(this).removeClass('event-calendar-repeating-unselected');
$(this).addClass('event-calendar-repeating-selected');
var id = $(this).attr('id');
$("[name='"+id+"-value']").val(1);
}
elgg.event_calendar.handleRepeatingUnselect = function(e) {
$(this).removeClass('event-calendar-repeating-selected');
$(this).addClass('event-calendar-repeating-unselected');
var id = $(this).attr('id');
$("[name='"+id+"-value']").val(0);
}
elgg.event_calendar.handleRegionChange = function(e) {
url = $('#event-calendar-region-url-start').val()+"/"+escape($('#event-calendar-region').val());
elgg.forward(url);
}
elgg.event_calendar.handleIcalPopup = function(e) {
var message = elgg.echo('event_calendar:ical_popup_message')+"\n"+this.href;
alert(message);
return false;
}
elgg.event_calendar.handlePagedPersonalCalendarToggle = function() {
guid = parseInt($(this).attr('id').substring('event_calendar_paged_checkbox_'.length));
elgg.event_calendar.togglePagedPersonalCalendar(guid);
}
elgg.event_calendar.togglePagedPersonalCalendar = function(guid) {
elgg.action('event_calendar/toggle_personal_calendar',
{
data: {event_guid: guid},
success: function (res) {
var success = res.success;
var msg = res.message;
if (success) {
elgg.system_message(msg,2000);
} else {
elgg.register_error(msg,2000);
}
//$('#event_calendar_paged_messages').html(msg);
if (!success) {
// action failed so toggle checkbox
$("#event_calendar_paged_checkbox_"+guid).attr('checked',!$("#event_calendar_paged_checkbox_"+guid).attr('checked'));
}
}
}
);
}
elgg.event_calendar.handleDisplayPagePersonalCalendarToggle = function() {
var guidBit = $(this).attr('id').substring('event_calendar_user_data_'.length);
var guids = guidBit.split('_');
var event_guid = parseInt(guids[0]);
var user_guid = parseInt(guids[1]);
elgg.event_calendar.toggleDisplayPagePersonalCalendar(event_guid,user_guid);
}
elgg.event_calendar.toggleDisplayPagePersonalCalendar = function(event_guid,user_guid) {
elgg.action('event_calendar/toggle_personal_calendar',
{
data: {event_guid: event_guid,user_guid: user_guid, other: 'yes'},
success: function (res) {
var success = res.success;
var msg = res.message;
if (success) {
var button_text = res.button_text;
$('#event_calendar_user_data_'+event_guid+'_'+user_guid).val(button_text);
//elgg.system_message(msg,2000);
} else {
elgg.register_error(msg,2000);
}
}
}
);
}
elgg.register_hook_handler('init', 'system', elgg.event_calendar.init);
//</script>
|