// Intialisierungen der DatePicker UI Elemente // Deutsche Sprache Laden //= require jquery.ui.datepicker-de var MONTHPICKER_MONTH_NAMES = ['Jan.', 'Feb.', 'März', 'April', 'Mai', 'Juni', 'Juli', 'Aug.', 'Sep.', 'Okt.', 'Nov.', 'Dez.'] // DatePicker in calenders#index initDatepickerIconBoxCalendersIndex = function(){ $("#datepicker-calendars-index").datepicker({ onSelect: function(date, inst){ remote_function("/calenders/index/"+ PARAMS_ID + "?start_date="+date, 'calendar-container'); } }); $(".datepicker-icon-box.calendars-index").click(function(){ $("#datepicker-calendars-index").datepicker('show'); }); } // DateTimePicker / Loader für freie Räume für calenders#form initDateTimePickerCalendersForm = function(){ $('#datepicker-calendars-form').datetimepicker({ controlType: 'select', hourText: 'Stunde', minuteText: 'Minute', currentText: 'Jetzt', closeText: 'Fertig' }); $("#calender-datetime-select :input").change(function(){ loadRoomDataForCalendersForm(); }); $(".datepicker-box.calendars-form").click(function(){ $("#datepicker-calendars-form").datepicker('show'); }); } loadRoomDataForCalendersForm = function(){ if(jQuery("#calender-datetime-select :input.datepicker-widget").val() == ""){ alert("Bitte wählen Sie ein Datum aus.") }else{ jQuery.ajax({ beforeSend:function(request){ }, success:function(request){jQuery('#room_select').html(request);}, data: jQuery("#calender-datetime-select :input").serialize() + '&authenticity_token=' + AUTH_TOKEN, type:'post', url:'/calenders/get_free_rooms' }); } } // Bereich Backoffice Umsatz initDatePickerTarifBeginn = function(){ $("[id^=datepicker-tarif-beginn]").each(function(){ uid = $(this).attr('id').split("-")[3] $(this).datepicker({ onSelect: function(date, inst){ remote_function("/tarif/backoffice_beginn_set/"+ uid + "?tarif_beginn="+date, 'beginn_'+uid, 'tiny'); } }); }); } // Datepicker für monthly_stepper initMonthlyStepper = function(){ $("#monthly-stepper").monthpicker( { startYear: <%= 2009 %>, finalYear: <%= Time.now.year %>, monthNames: MONTHPICKER_MONTH_NAMES } ); $("#monthly-stepper").bind('monthpicker-click-month', function(){ month_value = $("#monthly-stepper").val().split("/")[0]; year_value = $("#monthly-stepper").val().split("/")[1]; // Replace URL Placeholder raw_url = raw_url.replace(".YYYY.", year_value); raw_url = raw_url.replace(".MM.", month_value); window.location = raw_url; }); } initDefaultDatepicker = function(){ $("input.<%= DEFAULT_DATEPICKER_SELECTOR %>").each(function(){ $(this).datepicker({changeYear: true, yearRange: '1930:<%= Time.now.year+80 %>', hideIfNoPrevNextType: false}) cur_date = $(this).attr("<%= HTML_DATA_CURRENT_DATE %>") || "" if(cur_date != ""){ y = parseInt(cur_date.split("-")[0]); m = parseInt(cur_date.split("-")[1])-1; d = parseInt(cur_date.split("-")[2]); real_date = new Date(y,m,d); $(this).datepicker("setDate", real_date); } }); initDefaultDateTimepicker(); } initDefaultDateTimepicker = function(){ $("input.<%= DEFAULT_DATETIMEPICKER_SELECTOR %>").each(function(){ $(this).datetimepicker({changeYear: true, yearRange: '1930:<%= Time.now.year+80 %>', hideIfNoPrevNextType: false, controlType: 'select', hourText: "Std.", minuteText: "Min.", closeText: 'OK', stepMinute: 10}) cur_date = $(this).attr("<%= HTML_DATA_CURRENT_DATE %>") || "" if(cur_date != ""){ var regex = /(\d{2})\.(\d{2})\.(\d{4}) - (\d{2}):(\d{2})/; var dateArray = regex.exec(cur_date); var real_date = new Date( (+dateArray[3]), (+dateArray[2])-1, // Careful, month starts at 0! (+dateArray[1]), (+dateArray[4]), (+dateArray[5]), 0 ); $(this).datetimepicker("setDate", real_date); } }); } initDefaultMonthpicker = function(){ $("input.<%= DEFAULT_MONTHPICKER_SELECTOR %>").each(function(){ $(this).monthpicker( { startYear: 1930, finalYear: <%= Time.now.year+80 %>, monthNames: MONTHPICKER_MONTH_NAMES } ) $(this).bind('monthpicker-click-month', function(){ if($(this).val().match("/") != null){ old_val = ($(this).val().split("/")); $(this).val("01."+old_val[0]+"."+old_val[1]); return true } }); }); } initDatePickers = function(){ initDefaultDatepicker(); initDefaultMonthpicker(); }