PageSourceSearch

https://www.bonneville-la-louvet.fr/wp-content/plugins/Krea3Calend…/js/jquery.calendario.js?ver=7.1.2

js bonneville-la-louvet.fr collected 2026-10-03 17:52:07 UTC 10,494 bytes, 406 lines download raw bytes

1/**
2 * jquery.calendario.js v1.0.0
3 * http://www.codrops.com
4 *
5 * Licensed under the MIT license.
6 * http://www.opensource.org/licenses/mit-license.php
7 * 
8 * Copyright 2012, Codrops
9 * http://www.codrops.com
10 */
11;( function( $, window, undefined ) {
12	
13	'use strict';
14
15	$.Calendario = function( options, element ) {
16		
17		this.$el = $( element );
18		this._init( options );
19		
20	};
21
22	// the options
23	$.Calendario.defaults = {
24		/*
25		you can also pass:
26		month : initialize calendar with this month (1-12). Default is today.
27		year : initialize calendar with this year. Default is today.
28		caldata : initial data/content for the calendar.
29		caldata format:
30		{
31			'MM-DD-YYYY' : 'HTML Content',
32			'MM-DD-YYYY' : 'HTML Content',
33			'MM-DD-YYYY' : 'HTML Content'
34			...
35		}
36		*/
37		weeks : [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
38		weekabbrs : [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
39		months : [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
40		monthabbrs : [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
41		// choose between values in options.weeks or options.weekabbrs
42		displayWeekAbbr : false,
43		// choose between values in options.months or options.monthabbrs
44		displayMonthAbbr : false,
45		// left most day in the calendar
46		// 0 - Sunday, 1 - Monday, ... , 6 - Saturday
47		startIn : 1,
48		onDayClick : function( $el, $content, dateProperties ) { return false; }
49	};
50
51	$.Calendario.prototype = {
52
53		_init : function( options ) {
54			
55			// options
56			this.options = $.extend( true, {}, $.Calendario.defaults, options );
57
58			this.today = new Date();
59			this.month = ( isNaN( this.options.month ) || this.options.month == null) ? this.today.getMonth() : this.options.month - 1;
60			this.year = ( isNaN( this.options.year ) || this.options.year == null) ? this.today.getFullYear() : this.options.year;
61			this.caldata = this.options.caldata || {};
62			this._generateTemplate();
63			this._initEvents();
64
65		},
66		_initEvents : function() {
67
68			var self = this;
69
70			this.$el.on( 'click.calendario', 'div.fc-row > div', function() {
71
72				var $cell = $( this ),
73					idx = $cell.index(),
74					$content = $cell.children( 'div' ),
75					dateProp = {
76						day : $cell.children( 'span.fc-date' ).text(),
77						month : self.month + 1,
78						monthname : self.options.displayMonthAbbr ? self.options.monthabbrs[ self.month ] : self.options.months[ self.month ],
79						year : self.year,
80						weekday : idx + self.options.startIn,
81						weekdayname : self.options.weeks[ idx + self.options.startIn ]
82					};
83
84				if( dateProp.day ) {
85					self.options.onDayClick( $cell, $content, dateProp );
86				}
87
88			} );
89
90		},
91		// Calendar logic based on http://jszen.blogspot.pt/2007/03/how-to-build-simple-calendar-with.html
92		_generateTemplate : function( callback ) {
93
94			var head = this._getHead(),
95				body = this._getBody(),
96				rowClass;
97
98			switch( this.rowTotal ) {
99				case 4 : rowClass = 'fc-four-rows'; break;
100				case 5 : rowClass = 'fc-five-rows'; break;
101				case 6 : rowClass = 'fc-six-rows'; break;
102			}
103
104			this.$cal = $( '<div class="fc-calendar ' + rowClass + '">' ).append( head, body );
105
106			this.$el.find( 'div.fc-calendar' ).remove().end().append( this.$cal );
107
108			if( callback ) { callback.call(); }
109
110		},
111		_getHead : function() {
112
113			var html = '<div class="fc-head">';
114		
115			for ( var i = 0; i <= 6; i++ ) {
116
117				var pos = i + this.options.startIn,
118					j = pos > 6 ? pos - 6 - 1 : pos;
119
120				html += '<div>';
121				html += this.options.displayWeekAbbr ? this.options.weekabbrs[ j ] : this.options.weeks[ j ];
122				html += '</div>';
123
124			}
125
126			html += '</div>';
127
128			return html;
129
130		},
131		_getBody : function() {
132
133			var d = new Date( this.year, this.month + 1, 0 ),
134				// number of days in the month
135				monthLength = d.getDate(),
136				firstDay = new Date( this.year, this.month, 1 );
137
138			// day of the week
139			this.startingDay = firstDay.getDay();
140
141			var html = '<div class="fc-body"><div class="fc-row">',
142				// fill in the days
143				day = 1;
144
145			var now = new Date();
146			var mois    = now.getMonth();
147			var jour    = now.getDate();
148			var annee   = now.getFullYear();
149
150			// this loop is for weeks (rows)
151			for ( var i = 0; i < 7; i++ ) {
152
153				// this loop is for weekdays (cells)
154				for ( var j = 0; j <= 6; j++ ) {
155
156					var pos = this.startingDay - this.options.startIn,
157						p = pos < 0 ? 6 + pos + 1 : pos,
158						inner = '',
159						today = this.month === this.today.getMonth() && this.year === this.today.getFullYear() && day === this.today.getDate(),
160						content = '';
161					
162					if ( day <= monthLength && ( i > 0 || j >= p ) ) {
163						if(day < jour && this.month == mois && this.year == annee ){
164							inner = '';
165							console.log("ici" + day + this.month + this.year );
166						}else{
167							inner += '<span class="fc-date">' + day + '</span><span class="fc-weekday">' + this.options.weekabbrs[ j + this.options.startIn > 6 ? j + this.options.startIn - 6 - 1 : j + this.options.startIn ] + '</span>';
168						}
169						
170						// this day is:
171						var strdate = ( this.month + 1 < 10 ? '0' + ( this.month + 1 ) : this.month + 1 ) + '-' + ( day < 10 ? '0' + day : day ) + '-' + this.year,
172							dayData = this.caldata[ strdate ];
173
174						if( dayData ) {
175							content = dayData;
176						}
177
178						if( content !== '' ) {
179							//inner += '<div class="complet">' + content + '</div>';
180						}
181
182						++day;
183
184					}
185					else {
186						today = false;
187					}
188
189					var cellClasses = today ? 'fc-today ' : '';
190					if( content !== '' ) {
191						//if(day <= jour && this.month == mois){
192                        if(day <= jour && this.month == mois && this.year <= annee){
193							cellClasses = "";
194						}else{
195							if(content == "complet")
196								cellClasses += 'fc-content complet';
197							else
198								cellClasses += 'fc-content attente';
199						}
200						
201					}
202
203					html += cellClasses !== '' ? '<div class="' + cellClasses + '">' : '<div>';
204					html += inner;
205					html += '</div>';
206
207				}
208
209				// stop making rows if we've run out of days
210				if (day > monthLength) {
211					this.rowTotal = i + 1;
212					break;
213				} 
214				else {
215					html += '</div><div class="fc-row">';
216				}
217
218			}
219			html += '</div></div>';
220
221			return html;
222
223		},
224		// based on http://stackoverflow.com/a/8390325/989439
225		_isValidDate : function( date ) {
226
227			date = date.replace(/-/gi,'');
228			var month = parseInt( date.substring( 0, 2 ), 10 ),
229				day = parseInt( date.substring( 2, 4 ), 10 ),
230				year = parseInt( date.substring( 4, 8 ), 10 );
231
232			if( ( month < 1 ) || ( month > 12 ) ) {
233				return false;
234			}
235			else if( ( day < 1 ) || ( day > 31 ) )  {
236				return false;
237			}
238			else if( ( ( month == 4 ) || ( month == 6 ) || ( month == 9 ) || ( month == 11 ) ) && ( day > 30 ) )  {
239				return false;
240			}
241			else if( ( month == 2 ) && ( ( ( year % 400 ) == 0) || ( ( year % 4 ) == 0 ) ) && ( ( year % 100 ) != 0 ) && ( day > 29 ) )  {
242				return false;
243			}
244			else if( ( month == 2 ) && ( ( year % 100 ) == 0 ) && ( day > 29 ) )  {
245				return false;
246			}
247
248			return {
249				day : day,
250				month : month,
251				year : year
252			};
253
254		},
255		_move : function( period, dir, callback ) {
256
257			if( dir === 'previous' ) {
258				
259				if( period === 'month' ) {
260					this.year = this.month > 0 ? this.year : --this.year;
261					this.month = this.month > 0 ? --this.month : 11;
262				}
263				else if( period === 'year' ) {
264					this.year = --this.year;
265				}
266
267			}
268			else if( dir === 'next' ) {
269
270				if( period === 'month' ) {
271					this.year = this.month < 11 ? this.year : ++this.year;
272					this.month = this.month < 11 ? ++this.month : 0;
273				}
274				else if( period === 'year' ) {
275					this.year = ++this.year;
276				}
277
278			}
279
280			this._generateTemplate( callback );
281
282		},
283		/************************* 
284		******PUBLIC METHODS *****
285		**************************/
286		getYear : function() {
287			return this.year;
288		},
289		getMonth : function() {
290			return this.month + 1;
291		},
292		getMonthName : function() {
293			return this.options.displayMonthAbbr ? this.options.monthabbrs[ this.month ] : this.options.months[ this.month ];
294		},
295		// gets the cell's content div associated to a day of the current displayed month
296		// day : 1 - [28||29||30||31]
297		getCell : function( day ) {
298
299			var row = Math.floor( ( day + this.startingDay - this.options.startIn ) / 7 ),
300				pos = day + this.startingDay - this.options.startIn - ( row * 7 ) - 1;
301
302			return this.$cal.find( 'div.fc-body' ).children( 'div.fc-row' ).eq( row ).children( 'div' ).eq( pos ).children( 'div' );
303
304		},
305		setData : function( caldata ) {
306
307			caldata = caldata || {};
308			$.extend( this.caldata, caldata );
309			this._generateTemplate();
310
311		},
312		// goes to today's month/year
313		gotoNow : function( callback ) {
314
315			this.month = this.today.getMonth();
316			this.year = this.today.getFullYear();
317			this._generateTemplate( callback );
318
319		},
320		// goes to month/year
321		goto : function( month, year, callback ) {
322
323			this.month = month;
324			this.year = year;
325			this._generateTemplate( callback );
326
327		},
328		gotoPreviousMonth : function( callback ) {
329			this._move( 'month', 'previous', callback );
330		},
331		gotoPreviousYear : function( callback ) {
332			this._move( 'year', 'previous', callback );
333		},
334		gotoNextMonth : function( callback ) {
335			this._move( 'month', 'next', callback );
336		},
337		gotoNextYear : function( callback ) {
338			this._move( 'year', 'next', callback );
339		}
340
341	};
342	
343	var logError = function( message ) {
344
345		if ( window.console ) {
346
347			window.console.error( message );
348		
349		}
350
351	};
352	
353	$.fn.calendario = function( options ) {
354
355		var instance = $.data( this, 'calendario' );
356		
357		if ( typeof options === 'string' ) {
358			
359			var args = Array.prototype.slice.call( arguments, 1 );
360			
361			this.each(function() {
362			
363				if ( !instance ) {
364
365					logError( "cannot call methods on calendario prior to initialization; " +
366					"attempted to call method '" + options + "'" );
367					return;
368				
369				}
370				
371				if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
372
373					logError( "no such method '" + options + "' for calendario instance" );
374					return;
375				
376				}
377				
378				instance[ options ].apply( instance, args );
379			
380			});
381		
382		} 
383		else {
384		
385			this.each(function() {
386				
387				if ( instance ) {
388
389					instance._init();
390				
391				}
392				else {
393
394					instance = $.data( this, 'calendario', new $.Calendario( options, this ) );
395				
396				}
397
398			});
399		
400		}
401		
402		return instance;
403		
404	};
405	
406} )( jQuery, window );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.