/** * * jQuery calendar widget/large view plugin with Bootstrap compatibility * * * * **/ var oshimenId; var oshimenUrl; (function(factory) { if(typeof define === 'function' && define.amd) { define(['jquery'], factory); } else { factory(jQuery); } }(function($) { oshimenId = parseInt($("#oshimenTitleId").attr('data-oshimen_id')); oshimenUrl = $("#oshimenTitleId").attr('data-oshimen_image'); var defaults = { todayButton: false, // Show the button to reset to today's date? showInput: true, // Show input weekStart: 0, // Start day of the week. 0 is Sunday, 6 for Saturday, 1 for Monday (default) widget: true, cellRatio: 1, format: 'd/m/y', footer: true, dayHeader: true, mode: 'widget', // 'widget' (default), 'tiny', 'popup', 'page' animDuration: 200, transition: '', url: '', category: null, data: null, tableClasses: 'table table-condensed', hidden: true, setOnMonthChange: true, condensed: false }; var now = new Date(); var selectedDate, monthCursor; var category=null; var months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']; var shortMonths = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var shortDays = ['日', '月', '火', '水', '木', '金', '土']; var dayImage = ['day_sun', 'day_mon', 'day_tue', 'day_wed', 'day_thr', 'day_fri', 'day_sat']; var iconImage = ['icon_cd']; var monthEvent = null, monthEventArticle=null,oshimenMonthEvent=null; var iconSelectionCategory = 2; var response; var tableHeight; // Get the number of days in the current month (or next month if delta == 1, or prev month if delta == -1, etc) Date.prototype.daysInMonth = function(delta) { delta = delta === undefined ? 0 : delta; return new Date(this.getFullYear(), this.getMonth() + 1 + delta, 0).getDate(); } Date.prototype.isDay = function(day) { if(day === undefined) { day = new Date(); } return this.getFullYear()==day.getFullYear() && this.getMonth()==day.getMonth() && this.getDate()==day.getDate(); } Date.prototype.isValid = function() { return Object.prototype.toString.call(this) === "[object Date]" && !isNaN(this.getTime()); } $.fn.get_monthEvent = function(){ return monthEvent; }; $.fn.get_oshimenMonthEvent = function(){ return oshimenMonthEvent; }; $.fn.get_monthEventArticle = function(){ return monthEventArticle ; }; $.fn.main_calendar = function(method) { // Private methods var pMethods = { drawCalendar: function(selectedDateTemp, replace) { var options = $(this).data('options'); var inputDate; if(options['data']!=null && options['data']!=''){ inputDate = new Date(''+ options['data']); }else{ inputDate = now; } selectedDate = selectedDateTemp || inputDate; if(replace !== undefined && replace == true) { this.empty(); } pMethods.drawHeader(selectedDate, options).appendTo(this); var month = pMethods.drawMonth(selectedDate, options).addClass('current'); $('
').addClass('main_calendar-month').html(month).appendTo(this); $(this).data('main_calendar', true); $(this).data('date', selectedDate); $(this).data('element', this); return this; }, drawPopupCalendar: function(selectedDate, replace) { var options = $(this).data('options'); selectedDate = selectedDate || now; var container, calendar; if($(this).parent('.main_calendar-popup-wrapper').length) { container = $(this).parent(); calendar = $(this).parent().find('.main_calendar-popup'); calendar.empty(); } else { container = $('
').addClass('main_calendar-popup-wrapper'); calendar = $('
') .addClass('main_calendar main_calendar-popup') .width($(this).outerWidth(true)); $(this).wrap(container); } $(this).after(calendar); if(options.hidden) { calendar.hide(); } pMethods.drawHeader(selectedDate, options).appendTo(calendar); var month = pMethods .drawMonth(selectedDate, options) .addClass('current'); $('
') .addClass('main_calendar-month') .html(month) .appendTo(calendar); calendar.data('main_calendar', true); calendar.data('date', selectedDate); calendar.data('element', this); calendar.data('options', options); $(this).parent().wrap($('
').addClass('main_calendar-affix')); return this; }, drawHeader: function(date, options) { var header = $('
').addClass('main_calendar-header'); var monthNames = options.shortMonths ? shortMonths : months; var lastMonth = date.getMonth()-1; var path= ''; if(lastMonth<0){ lastMonth =11; } var nextMonth = date.getMonth()+1; if(nextMonth>11){ nextMonth = 0; } if( getLocale() == 'en_US' ){ monthNames = shortMonths; path = '
' + monthNames[date.getMonth()]+ ' ' + date.getFullYear() + ' ' + 'schedule
'; } else { monthNames = months; path ='
'+ date.getFullYear() +'年'+ monthNames[date.getMonth()] + 'の月間スケジュール
' } //prev month button var leftDiv = $('
').appendTo(header); $('