Вход Регистрация
Файл: CloudBox-main/CloudBox/admin_assets/js/jquery.calendario.js
Строк: 388
<?php
/**
 * jquery.calendario.js v1.0.0
 * http://www.codrops.com
 *
 * Licensed under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2012, Codrops
 * http://www.codrops.com
 */
;
(function ($, 
windowundefined) {

    
'use strict';

    $.
Calendario = function (optionselement) {

        
this.$el = $(element);
        
this._init(options);

    };

    
// the options
    
$.Calendario.defaults = {
        
/*
         you can also pass:
         month : initialize calendar with this month (1-12). Default is today.
         year : initialize calendar with this year. Default is today.
         caldata : initial data/content for the calendar.
         caldata format:
         {
         'MM-DD-YYYY' : 'HTML Content',
         'MM-DD-YYYY' : 'HTML Content',
         'MM-DD-YYYY' : 'HTML Content'
         ...
         }
         */
        
weeks: [ 'Sunday''Monday''Tuesday''Wednesday''Thursday''Friday''Saturday' ],
        
weekabbrs: [ 'Sun''Mon''Tue''Wed''Thu''Fri''Sat' ],
        
months: [ 'January''February''March''April''May''June''July''August''September''October''November''December' ],
        
monthabbrs: [ 'Jan''Feb''Mar''Apr''May''Jun''Jul''Aug''Sep''Oct''Nov''Dec' ],
        
// choose between values in options.weeks or options.weekabbrs
        
displayWeekAbbrfalse,
        
// choose between values in options.months or options.monthabbrs
        
displayMonthAbbrfalse,
        
// left most day in the calendar
        // 0 - Sunday, 1 - Monday, ... , 6 - Saturday
        
startIn1,
        
onDayClick: function ($el$contentdateProperties) {
            return 
false;
        }
    };

    $.
Calendario.prototype = {

        
_init: function (options) {

            
// options
            
this.options = $.extend(true, {}, $.Calendario.defaultsoptions);

            
this.today = new Date();
            
this.month = ( isNaN(this.options.month) || this.options.month == null) ? this.today.getMonth() : this.options.month 1;
            
this.year = ( isNaN(this.options.year) || this.options.year == null) ? this.today.getFullYear() : this.options.year;
            
this.caldata this.options.caldata || {};
            
this._generateTemplate();
            
this._initEvents();

        },
        
_initEvents: function () {

            var 
self this;

            
this.$el.on('click.calendario''div.fc-row > div', function () {

                var 
$cell = $(this),
                    
idx $cell.index(),
                    
$content $cell.children('div'),
                    
dateProp = {
                        
day$cell.children('span.fc-date').text(),
                        
monthself.month 1,
                        
monthnameself.options.displayMonthAbbr self.options.monthabbrsself.month ] : self.options.monthsself.month ],
                        
yearself.year,
                        
weekdayidx self.options.startIn,
                        
weekdaynameself.options.weeksidx self.options.startIn ]
                    };

                if (
dateProp.day) {
                    
self.options.onDayClick($cell$contentdateProp);
                }

            });

        },
        
// Calendar logic based on http://jszen.blogspot.pt/2007/03/how-to-build-simple-calendar-with.html
        
_generateTemplate: function (callback) {

            var 
head this._getHead(),
                
body this._getBody(),
                
rowClass;

            switch (
this.rowTotal) {
                case 
:
                    
rowClass 'fc-four-rows';
                    break;
                case 
:
                    
rowClass 'fc-five-rows';
                    break;
                case 
:
                    
rowClass 'fc-six-rows';
                    break;
            }

            
this.$cal = $('<div class="fc-calendar ' rowClass '">').append(headbody);

            
this.$el.find('div.fc-calendar').remove().end().append(this.$cal);

            if (
callback) {
                
callback.call();
            }

        },
        
_getHead: function () {

            var 
html '<div class="fc-head">';

            for (var 
0<= 6i++) {

                var 
pos this.options.startIn,
                    
pos pos pos;

                
html += '<div>';
                
html += this.options.displayWeekAbbr this.options.weekabbrs] : this.options.weeks];
                
html += '</div>';

            }

            
html += '</div>';

            return 
html;

        },
        
_getBody: function () {

            var 
= new Date(this.yearthis.month 10),
            
// number of days in the month
                
monthLength d.getDate(),
                
firstDay = new Date(this.yearthis.month1);

            
// day of the week
            
this.startingDay firstDay.getDay();

            var 
html '<div class="fc-body"><div class="fc-row">',
            
// fill in the days
                
day 1;

            
// this loop is for weeks (rows)
            
for (var 07i++) {

                
// this loop is for weekdays (cells)
                
for (var 0<= 6j++) {

                    var 
pos this.startingDay this.options.startIn,
                        
pos pos pos,
                        
inner '',
                        
today this.month === this.today.getMonth() && this.year === this.today.getFullYear() && day === this.today.getDate(),
                        
content '';

                    if (
day <= monthLength && ( || >= )) {

                        
inner += '<span class="fc-date">' day '</span><span class="fc-weekday">' this.options.weekabbrsthis.options.startIn this.options.startIn this.options.startIn ] + '</span>';

                        
// this day is:
                        
var strdate = ( this.month 10 '0' + ( this.month ) : this.month ) + '-' + ( day 10 '0' day day ) + '-' this.year,
                            
dayData this.caldatastrdate ];

                        if (
dayData) {
                            
content dayData;
                        }

                        if (
content !== '') {
                            
inner += '<div>' content '</div>';
                        }

                        ++
day;

                    }
                    else {
                        
today false;
                    }

                    var 
cellClasses today 'fc-today ' '';
                    if (
content !== '') {
                        
cellClasses += 'fc-content';
                    }

                    
html += cellClasses !== '' '<div class="' cellClasses '">' '<div>';
                    
html += inner;
                    
html += '</div>';

                }

                
// stop making rows if we've run out of days
                
if (day monthLength) {
                    
this.rowTotal 1;
                    break;
                }
                else {
                    
html += '</div><div class="fc-row">';
                }

            }
            
html += '</div></div>';

            return 
html;

        },
        
// based on http://stackoverflow.com/a/8390325/989439
        
_isValidDate: function (date) {

            
date date.replace(/-/gi'');
            var 
month parseInt(date.substring(02), 10),
                
day parseInt(date.substring(24), 10),
                
year parseInt(date.substring(48), 10);

            if (( 
month ) || ( month 12 )) {
                return 
false;
            }
            else if (( 
day ) || ( day 31 )) {
                return 
false;
            }
            else if (( ( 
month == ) || ( month == ) || ( month == ) || ( month == 11 ) ) && ( day 30 )) {
                return 
false;
            }
            else if (( 
month == ) && ( ( ( year 400 ) == 0) || ( ( year ) == ) ) && ( ( year 100 ) != ) && ( day 29 )) {
                return 
false;
            }
            else if (( 
month == ) && ( ( year 100 ) == ) && ( day 29 )) {
                return 
false;
            }

            return {
                
dayday,
                
monthmonth,
                
yearyear
            
};

        },
        
_move: function (perioddircallback) {

            if (
dir === 'previous') {

                if (
period === 'month') {
                    
this.year this.month this.year : --this.year;
                    
this.month this.month ? --this.month 11;
                }
                else if (
period === 'year') {
                    
this.year = --this.year;
                }

            }
            else if (
dir === 'next') {

                if (
period === 'month') {
                    
this.year this.month 11 this.year : ++this.year;
                    
this.month this.month 11 ? ++this.month 0;
                }
                else if (
period === 'year') {
                    
this.year = ++this.year;
                }

            }

            
this._generateTemplate(callback);

        },
        
/*************************
         ******PUBLIC METHODS *****
         **************************/
        
getYear: function () {
            return 
this.year;
        },
        
getMonth: function () {
            return 
this.month 1;
        },
        
getMonthName: function () {
            return 
this.options.displayMonthAbbr this.options.monthabbrsthis.month ] : this.options.monthsthis.month ];
        },
        
// gets the cell's content div associated to a day of the current displayed month
        // day : 1 - [28||29||30||31]
        
getCell: function (day) {

            var 
row Math.floor(( day this.startingDay this.options.startIn ) / 7),
                
pos day this.startingDay this.options.startIn - ( row ) - 1;

            return 
this.$cal.find('div.fc-body').children('div.fc-row').eq(row).children('div').eq(pos).children('div');

        },
        
setData: function (caldata) {

            
caldata caldata || {};
            $.
extend(this.caldatacaldata);
            
this._generateTemplate();

        },
        
// goes to today's month/year
        
gotoNow: function (callback) {

            
this.month this.today.getMonth();
            
this.year this.today.getFullYear();
            
this._generateTemplate(callback);

        },
        
// goes to month/year
        
goto: function (monthyearcallback) {

            
this.month month;
            
this.year year;
            
this._generateTemplate(callback);

        },
        
gotoPreviousMonth: function (callback) {
            
this._move('month''previous'callback);
        },
        
gotoPreviousYear: function (callback) {
            
this._move('year''previous'callback);
        },
        
gotoNextMonth: function (callback) {
            
this._move('month''next'callback);
        },
        
gotoNextYear: function (callback) {
            
this._move('year''next'callback);
        }

    };

    var 
logError = function (message) {

        if (
window.console) {

            
window.console.error(message);

        }

    };

    $.
fn.calendario = function (options) {

        var 
instance = $.data(this'calendario');

        if (
typeof options === 'string') {

            var 
args = Array.prototype.slice.call(arguments1);

            
this.each(function () {

                if (!
instance) {

                    
logError("cannot call methods on calendario prior to initialization; " +
                        
"attempted to call method '" options "'");
                    return;

                }

                if (!$.
isFunction(instance[options]) || options.charAt(0) === "_") {

                    
logError("no such method '" options "' for calendario instance");
                    return;

                }

                
instanceoptions ].apply(instanceargs);

            });

        }
        else {

            
this.each(function () {

                if (
instance) {

                    
instance._init();

                }
                else {

                    
instance = $.data(this'calendario', new $.Calendario(optionsthis));

                }

            });

        }

        return 
instance;

    };

})(
jQuerywindow);
?>
Онлайн: 1
Реклама