123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- <script type="text/javascript">
- function checkLength( o, n, min, max ) {
- if ( o.val().length > max || o.val().length < min ) {
- o.addClass( "ui-state-error" );
- updateTips( "Length of " + n + " must be between " +
- min + " and " + max + "." );
- return false;
- } else {
- return true;
- }
- }
- function clean_user_select() {
-
- $('#users_to_send_id')
- .find('option')
- .removeAttr('selected')
- .end();
- }
- var region_value = '{$region_value}';
- $(document).ready(function() {
-
-
- var date = new Date();
- var d = date.getDate();
- var m = date.getMonth();
- var y = date.getFullYear();
-
- $("#dialog-form").dialog({
- autoOpen: false,
- modal : false,
- width : 550,
- height : 450,
- zIndex: 20000
- });
-
- $("#simple-dialog-form").dialog({
- autoOpen: false,
- modal : false,
- width : 550,
- height : 450,
- zIndex: 20000
- });
- var title = $( "#title" ),
- content = $( "#content" ),
- allFields = $( [] ).add( title ).add( content ), tips = $(".validateTips");
- $('#users_to_send_id').bind('change', function() {
-
- var selected_counts = $("#users_to_send_id option:selected").size();
-
-
-
- $("#users_to_send_id").trigger("liszt:updated");
-
-
-
-
-
- if ($("#users_to_send_id option[value='everyone']").attr('selected') == 'selected') {
-
-
-
- }
- });
-
- $.datepicker.setDefaults( $.datepicker.regional[region_value] );
-
- var calendar = $('#calendar').fullCalendar({
- header: {
- left: 'today prev,next',
- center: 'title',
- right: 'month,agendaWeek,agendaDay',
- },
- {if $use_google_calendar == 1 }
- eventSources: [
- '{$google_calendar_url}',
- {
- className: 'gcal-event',
- }
- ],
- {/if}
-
- buttonText: {$button_text},
- monthNames: {$month_names},
- monthNamesShort:{$month_names_short},
- dayNames: {$day_names},
- dayNamesShort: {$day_names_short},
- firstHour: 8,
- firstDay: 1,
- selectable : true,
- selectHelper: true,
-
- viewDisplay: function(view) {
-
- var api = $('.qtip').qtip('api');
- if (api) {
- api.destroy();
-
- }
- },
-
- select: function(start, end, allDay, jsEvent, view) {
-
- var start_date = Math.round(start.getTime() / 1000);
- var end_date = Math.round(end.getTime() / 1000);
-
- $('#visible_to_input').show();
- $('#add_as_announcement_div').show();
- $('#visible_to_read_only').hide();
-
-
- clean_user_select();
-
-
-
-
-
- $("#users_to_send_id").trigger("liszt:updated");
-
- if ({$can_add_events} == 1) {
- var url = '{$web_agenda_ajax_url}&a=add_event&start='+start_date+'&end='+end_date+'&all_day='+allDay+'&view='+view.name;
-
- var start_date_value = $.datepicker.formatDate('{$js_format_date}', start);
- var end_date_value = $.datepicker.formatDate('{$js_format_date}', end);
-
- $('#start_date').html(start_date_value + " " + start.toTimeString().substr(0, 8));
-
- if (view.name != 'month') {
- $('#start_date').html(start_date_value + " " + start.toTimeString().substr(0, 8));
- if (start.toDateString() == end.toDateString()) {
- $('#end_date').html(' - '+end.toTimeString().substr(0, 8));
- } else {
- $('#end_date').html(' - '+start_date_value+" " + end.toTimeString().substr(0, 8));
- }
- } else {
- $('#start_date').html(start_date_value);
- $('#end_date').html(' ');
- }
- $('#color_calendar').html('{$type_label}');
- $('#color_calendar').removeClass('group_event');
- $('#color_calendar').addClass('label_tag');
- $('#color_calendar').addClass('{$type}_event');
-
- allFields.removeClass( "ui-state-error" );
- $("#dialog-form").dialog("open");
-
- $("#dialog-form").dialog({
- buttons: {
- {"Add"|get_lang}: function() {
- var bValid = true;
- bValid = bValid && checkLength( title, "title", 1, 255 );
-
-
- var params = $("#add_event_form").serialize();
- $.ajax({
- url: url+'&'+params,
- success:function(data) {
- calendar.fullCalendar("refetchEvents");
- calendar.fullCalendar("rerenderEvents");
- $("#dialog-form").dialog("close");
- }
- });
- },
- },
- close: function() {
- $("#title").attr('value', '');
- $("#content").attr('value', '');
- }
- });
-
- return false;
- calendar.fullCalendar('unselect');
- }
- },
- eventRender: function(event, element) {
- if (event.attachment) {
- element.qtip({
- hide: {
- delay: 2000
- },
- content: event.attachment,
- position: { at:'top right' , my:'bottom right'},
- }).removeData('qtip');
-
- }
-
- if (event.description) {
- element.qtip({
- hide: {
- delay: 2000
- },
- content: event.description,
- position: { at:'top left' , my:'bottom left'},
- });
- }
-
- },
- eventClick: function(calEvent, jsEvent, view) {
-
- var start_date = Math.round(calEvent.start.getTime() / 1000);
- if (calEvent.allDay == 1) {
- var end_date = '';
- } else {
- var end_date = '';
- if (calEvent.end && calEvent.end != '') {
- var end_date = Math.round(calEvent.end.getTime() / 1000);
- }
- }
-
- if (calEvent.editable) {
-
- $('#visible_to_input').hide();
- $('#add_as_announcement_div').hide();
-
- {if $type != 'admin'}
- $('#visible_to_read_only').show();
- $("#visible_to_read_only_users").html(calEvent.sent_to);
- {/if}
-
- $('#color_calendar').html('{$type_label}');
- $('#color_calendar').addClass('label_tag');
- $('#color_calendar').removeClass('course_event');
- $('#color_calendar').removeClass('personal_event');
- $('#color_calendar').removeClass('group_event');
- $('#color_calendar').addClass(calEvent.type+'_event');
-
- $('#start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
- if (end_date != '') {
- $('#end_date').html(' '+calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear());
- }
- $("#title").attr('value', calEvent.title);
- $("#content").attr('value', calEvent.description);
-
- allFields.removeClass( "ui-state-error" );
-
- $("#dialog-form").dialog("open");
-
- var url = '{$web_agenda_ajax_url}&a=edit_event&id='+calEvent.id+'&start='+start_date+'&end='+end_date+'&all_day='+calEvent.allDay+'&view='+view.name;
- var delete_url = '{$web_agenda_ajax_url}&a=delete_event&id='+calEvent.id;
-
- $("#dialog-form").dialog({
- buttons: {
- {"Edit"|get_lang} : function() {
-
- var bValid = true;
- bValid = bValid && checkLength( title, "title", 1, 255 );
-
-
- var params = $("#add_event_form").serialize();
- $.ajax({
- url: url+'&'+params,
- success:function() {
- calEvent.title = $("#title").val();
- calEvent.start = calEvent.start;
- calEvent.end = calEvent.end;
- calEvent.allDay = calEvent.allDay;
- calEvent.description = $("#content").val();
-
- calendar.fullCalendar('updateEvent',
- calEvent,
- true
- );
-
- $("#dialog-form").dialog("close");
- }
- });
- },
- {"Delete"|get_lang}: function() {
- $.ajax({
- url: delete_url,
- success:function() {
- calendar.fullCalendar('removeEvents',
- calEvent
- );
- calendar.fullCalendar("refetchEvents");
- calendar.fullCalendar("rerenderEvents");
- $("#dialog-form").dialog( "close" );
- }
- });
- }
- },
- close: function() {
- $("#title").attr('value', '');
- $("#content").attr('value', '');
- }
- });
- } else {
-
- $('#simple_start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
- if (end_date != '') {
- $('#simple_start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear() +" - "+calEvent.start.toLocaleTimeString());
- $('#simple_end_date').html(' '+calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear() +" - "+calEvent.end.toLocaleTimeString());
- }
-
- $("#simple_title").html(calEvent.title);
- $("#simple_content").html(calEvent.description);
- $("#simple-dialog-form").dialog("open");
-
-
- $("#simple-dialog-form").dialog({
- buttons: {
- {"Export"|get_lang} : function() {
-
-
- var params = $("#add_event_form").serialize();
- $.ajax({
- url: url+'&'+params,
- success:function() {
- calEvent.title = $("#title").val();
- calEvent.start = calEvent.start;
- calEvent.end = calEvent.end;
- calEvent.allDay = calEvent.allDay;
- calEvent.description = $("#content").val();
-
- calendar.fullCalendar('updateEvent',
- calEvent,
- true
- );
-
- $("#dialog-form").dialog("close");
- }
- });
- },
- {"Export"|get_lang}: function() {
- $.ajax({
- url: delete_url,
- success:function() {
- calendar.fullCalendar('removeEvents',
- calEvent
- );
- calendar.fullCalendar("refetchEvents");
- calendar.fullCalendar("rerenderEvents");
- $("#dialog-form").dialog( "close" );
- }
- });
- }
- },
- close: function() {
-
- }
- });
-
- }
- },
- editable: true,
- events: "{$web_agenda_ajax_url}&a=get_events",
- eventDrop: function(event, day_delta, minute_delta, all_day, revert_func) {
- $.ajax({
- url: '{$web_agenda_ajax_url}',
- data: {
- a:'move_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
- }
- });
- },
- axisFormat: 'HH(:mm)',
- timeFormat: 'HH:mm{ - HH:mm}',
- loading: function(bool) {
- if (bool) $('#loading').show();
- else $('#loading').hide();
- }
- });
- });
- </script>
- <div id="simple-dialog-form" style="display:none;">
- <div style="width:500px">
- <form name="form-simple" class="form-vertical" >
- <div class="control-group">
- <label class="control-label"><b>{"Date"|get_lang}</b></label>
- <div class="controls">
- <span id="simple_start_date"></span><span id="simple_end_date"></span>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label"><b>{"Title"|get_lang}</b></label>
- <div class="controls">
- <div id="simple_title"></div>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label"><b>{"Description"|get_lang}</b></label>
- <div class="controls">
- <div id="simple_content"></div>
- </div>
- </div>
- </form>
- </div>
- </div>
- <div id="dialog-form" style="display:none;">
- <div style="width:500px">
- <form class="form-horizontal" id="add_event_form" name="form">
-
- {if !empty($visible_to) }
- <div id="visible_to_input" class="control-group">
- <label class="control-label" for="date">{"To"|get_lang}</label>
- <div class="controls">
- {$visible_to}
- </div>
- </div>
- {/if}
-
- <div id="visible_to_read_only" class="control-group" style="display:none">
- <label class="control-label" for="date">{"To"|get_lang}</label>
- <div class="controls">
- <div id="visible_to_read_only_users"></div>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="date">{"Agenda"|get_lang}</label>
- <div class="controls">
- <div id="color_calendar"></div>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="date">{"Date"|get_lang}</label>
- <div class="controls">
- <span id="start_date"></span><span id="end_date"></span>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="name">{"Title"|get_lang}</label>
- <div class="controls">
- <input type="text" name="title" id="title" size="40" />
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="name">{"Description"|get_lang}</label>
- <div class="controls">
- <textarea name="content" id="content" cols="40" rows="7"></textarea>
- </div>
- </div>
-
- {if $type == 'course'}
- <div id="add_as_announcement_div">
- <div class="control-group">
- <label class="control-label" for="name"></label>
- <div class="controls">
- <input type="checkbox" name="add_as_annonuncement" id="add_as_annonuncement" />
- <label for="add_as_annonuncement">{"AddAsAnnouncement"|get_lang}</label>
- </div>
- </div>
- </div>
- {/if}
- </form>
- </div>
- </div>
- <div id='loading' style='margin-left:150px;position:absolute;display:none'>{"Loading"|get_lang}...</div>
- <div id='calendar'></div>
|