Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript > Bibliothèques & Frameworks > jQuery
jQuery Forum d'entraide sur le framework jQuery. Avant de poster : Tutoriels jQuery, FAQ jQuery, Tous les tutoriels JavaScript, Toutes les FAQ JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 16/11/2010, 17h48   #1
Invité de passage
 
panda panda
Inscription : novembre 2010
Messages : 4
Détails du profil
Informations personnelles :
Nom : panda panda

Informations forums :
Inscription : novembre 2010
Messages : 4
Points : 0
Points : 0
Par défaut UI Datepicker. Fermer certains jours du calendrier

Bonjour,
Je cherche a griser certains jours, dans un datepicker Jquery.
Exemple, uniquement le dimanche et d'autre jours ponctuels.
Y a t il des méthodes pour ca ?

Je sais comment bloquer les jours précédent une date ou suivant une date.
Ou les weekends mais pas uniquement des jours ponctuels.
Merci d'avance.
Cordialement.
pandalighton est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/11/2010, 09h34   #2
Membre éclairé
 
sébastien courjean
Inscription : novembre 2010
Messages : 204
Détails du profil
Informations personnelles :
Nom : sébastien courjean
Localisation : France, Indre et Loire (Centre)

Informations forums :
Inscription : novembre 2010
Messages : 204
Points : 319
Points : 319
J'ai regardé les méthodes, options et évènements disponible, en effet tu peux dire une minDate et maxDate, interdire weekend, mais pas une date précise. Je pense que tu devrais donc développer une fonction supplémentaire qui cacherait une date sur le principe de la fonction qui cache pour minDate sauf que là c'est que pour une date.
scourjean est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/11/2010, 13h46   #3
Membre Expert
 
Inscription : décembre 2006
Messages : 2 048
Détails du profil
Informations forums :
Inscription : décembre 2006
Messages : 2 048
Points : 1 087
Points : 1 087
Bonjour.

J'avais posé une question de ce genre sur ce forum à danielhagnoul qui a fait ceci.
rambc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/11/2010, 14h03   #4
Invité de passage
 
panda panda
Inscription : novembre 2010
Messages : 4
Détails du profil
Informations personnelles :
Nom : panda panda

Informations forums :
Inscription : novembre 2010
Messages : 4
Points : 0
Points : 0
Oui je suis déja en train de suivre cette piste la.
Merci je vais voir ce que j'arrive à faire.
pandalighton est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/11/2010, 15h08   #5
Invité de passage
 
panda panda
Inscription : novembre 2010
Messages : 4
Détails du profil
Informations personnelles :
Nom : panda panda

Informations forums :
Inscription : novembre 2010
Messages : 4
Points : 0
Points : 0
J'arrive a peux près a me dépatouiller pour faire ce que je veux mais encore un problème. Le css ne s'applique pas bien pour les jours spéciaux.
En gros le background-color reste celui du theme, et on voit seulement un liseré de la bonne couleur.

J'importe un theme avec:
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css" type="text/css" />

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="description" content="jQeury UI Datepicker. Personnalisation d'une vue fixe. Exemple." />
	<meta name="keywords" content="jQuery UI, Datepicker, personnalisation, 'vue fixe', 'personnalisation d'une vue fixe', jQuery" />
	<meta name="Author" content="Daniel Hagnoul" />
	<title>Personnalisation d'une vue fixe du Datepicker</title>
 
 
	<script type='text/javascript' src='http://www.lighton-delice.com/includes/jquery.js'></script>
		<script type='text/javascript' src='http://www.lighton-delice.com/includes/jquery.lightbox.js'></script>
 
		<script type='text/javascript' src='http://www.lighton-delice.com/includes/jquery.cookie.js'></script>
		<script type='text/javascript' src='http://www.lighton-delice.com/includes/jquery.scrollTo.js'></script>
		<script type='text/javascript' src='http://www.lighton-delice.com/includes/jquery.selectboxes.js'></script>
		<script type='text/javascript' src='http://www.lighton-delice.com/includes/jquery.ajaxform.js'></script>
		<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js'></script>
		<script type='text/javascript' src='http://www.lighton-delice.com/includes/ui.selectmenu.js'></script>
 
		<link href="http://www.lighton-delice.com/style/v1/core.css" rel="stylesheet" type="text/css"/>
		<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css" type="text/css" />
		<link rel="stylesheet" type="text/css" href="http://www.lighton-delice.com/style/jquery.lightbox-0.5.css" media="screen" />
 
 
	<style type="text/css">
		/* Planning */
 
		div#planning {
			width:730px; /* par essai et erreurs, le datepicker ne tient pas compte des div parents. */
			padding:12px;
			text-align:left;
		}
		div#planning div#titre {
			margin-bottom:12px;
			text-align:center;
			font-weight:bold;
		}		
		div#planning div#datepicker {
			font-size:1.1em; /* datepicker interprète la largeur à sa façon ! */
		}
		div#planning div#affiche {
			margin-top:12px;
			text-align:center;
			font-weight:bold;
		}
 
		/* Dialogues */
 
		div.dialog {
			font-size:0.9em;
		}
		div.dialog p {
			margin:6px;
		}
 
		/* Couleurs de dates */
 
		.important {
			background-color:#FF0000;
			/* pour les réunions */
			/* modifie le td, ce qui provoque un effet de bordure autour de la date choisie */
			/* sert de marqueur pour color:#FF0000; */
		}
		.lundiMercredi {
			/* pour les lundis et les mercredis */
			/* rien, sert de marqueur pour color:#33CC00; */
		}
		.reserver {
 
			/* pour réserver la salle des jeux */
			/* rien, sert de marqueur pour color:#0033CC; */
		}
	</style>
 
	<script type="text/javascript">
	(function($){
		var nomJours = ["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"];
		var nomMois = ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"];
 
		var vacances = [[8, 12, 2010],[9, 12, 2010],[10, 12, 2010],[11, 12, 2010]];
		var dimanches = [[7, 11, 2010],[14, 11, 2010],[21, 11, 2010],[28, 11, 2010],[5, 12, 2010],[12, 12, 2010],[19, 12, 2010],[26, 12, 2010]];
		var promotions = [[9, 11, 2010],[12, 8, 2010],[17, 9, 2010],[22, 10, 2010],[26, 11, 2010],[22, 12, 2010]];
		var reserver = [[8, 12, 2010],[9, 12, 2010],[10, 12, 2010],[11, 12, 2010]];
 
		setDays = function(day, month, year) {
			var result = [true, '', ''];	//par défaut, on affiche la date
			var boolVacances = false;
			var boolpromotion = false;
			//var boolLundiMercredi = false;
			var boolDimanches = false;
			var rl = 0;
			var i = 0;
 
			/*
			* Les données peuvent contenir, par erreur, des chevauchements de dates !
			* Priorité des événements : Vacances > promotion > LundiMercredi > Reserver !
			* Évite l'ajout de la "class" d'un événement non prioritaire !
			*/
 
			if (dimanches != null) {
				rl = dimanches.length;
 
				for (i = 0; i < rl; i++) {
					if ((day == dimanches[i][0]) && (month == dimanches[i][1] - 1) && (year == dimanches[i][2])) {
						result = [false, '', "Pas de livraison le dimanche"];
						boolDimanches = true;
					}
				}
			}
 
			if (vacances != null) {
				rl = vacances.length;
 
				for (i = 0; i < rl; i++) {
					if ((day == vacances[i][0]) && (month == vacances[i][1] - 1) && (year == vacances[i][2])) {
						result = [false, '', "On est en vacances !"];
						boolVacances = true;
					}
				}
			}
 
			if (vacances != null) {
				rl = vacances.length;
 
				for (i = 0; i < rl; i++) {
					if ((day == vacances[i][0]) && (month == vacances[i][1] - 1) && (year == vacances[i][2])) {
						result = [false, '', "On est en vacances !"];
						boolVacances = true;
					}
				}
			}
 
			if ((!boolVacances) && (promotions != null)) {
				rl = promotions.length;
 
				for (i = 0; i < rl; i++) {
					if ((day == promotions[i][0]) && (month == promotions[i][1] - 1) && (year == promotions[i][2])) {
						result = [true, "important", "Promotion !"];
						boolpromotion = true;
					}
				}
			}
 
			//getDay() retourne un entier correspondant au jour de la semaine
			// 0 (dimanche), 1 (lundi), 2 (mardi), 3 (mercredi), 4 (jeudi), 5 (vendredi), 6 (samedi)
 
			var jourSemaine = new Date(year, month, day).getDay();	
			return result;
		}
 
			selectedDay = function(day, month, year) {
			var boolpromotion = false;
			var rl = 0;
			var i = 0;
 
			/*
			* Les données peuvent contenir, par erreur, des chevauchements de dates !
			* Priorité des événements : Vacances > promotion > LundiMercredi > Reserver !
			* Ici on ne s'occupe pas des jours de vacances puisque l'utilisateur ne peut pas les choisir !
			*/
 
			//getDay() retourne un entier correspondant au jour de la semaine
			// 0 (dimanche), 1 (lundi), 2 (mardi), 3 (mercredi), 4 (jeudi), 5 (vendredi), 6 (samedi)
			var jourSemaine = new Date(year, month, day).getDay();
 
			$("#affiche").html("<p>Vous avez sélectionné le " +
													nomJours[jourSemaine] + " " + day + " " + nomMois[month] + " " + year + "</p>");
 
			if (promotions != null) {
				rl = promotions.length;
 
				for (i = 0; i < rl; i++) {
					if ((day == promotions[i][0]) && (month == promotions[i][1] - 1) && (year == promotions[i][2])) {
						$("#important").dialog("open");
						boolpromotion = true;
					}
				}
			}
 
		}
 
		jQuery(function($){
			$.datepicker.regional['fr'] = {
				closeText: 'Fermer',
				prevText: '&#x3c;Préc',
				nextText: 'Suiv&#x3e;',
				currentText: 'Courant',
				monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
				'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
				monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
				'Jul','Aoû','Sep','Oct','Nov','Déc'],
				dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
				dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
				dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
				weekHeader: 'Sm',
				dateFormat: 'dd-mm-yy',
				firstDay: 1,
				isRTL: false,
				showMonthAfterYear: false,
				yearSuffix: ''};
			$.datepicker.setDefaults($.datepicker.regional['fr']);
		});
 
 
		$(document).ready(function(){
 
			$("#important").dialog({
				autoOpen: false,
				height: 240,
				width: 400,
				modal: true,
				overlay: {
					backgroundColor: '#000000',
					opacity: 0.5
				},
				buttons: {
					'Fermer': function() {
						$(this).dialog('close');
					}
				},
				close: function() {
					// pour colorer les dates choisies chaque fois que le datepicker se redessine !
					$("#datepicker").mouseenter();
				}
			});	
 
			$("#datepicker").datepicker({
				numberOfMonths:1,
				stepMonths:1,
				showButtonPanel: true,
				currentText: "Aujourd'hui",
				nextText: "Suivant",
				prevText: "Précédent",
				minDate: new Date(), //du 1 juillet 2010
				maxDate:'+1M', 
 
				beforeShowDay: function(date) {
					//var noWeekend = $.datepicker.noWeekends(date); //samedi et dimanche non sélectionable !
					var noWeekend = [true, '', '']; // on garde le samedi et le dimanche !
 
					if (noWeekend[0]) {
						return setDays(date.getDate(), date.getMonth(), date.getFullYear());
					} else {
						return noWeekend;
					}
 
 
					/*
					* Si parmi les dates à colorer il y a des samedis ou des dimanches alors
					* mettez en commentaire tout ce qui précède et remplacez-le par :
					* return setDays(date.getDate(), date.getMonth(), date.getFullYear());
					*/
				},
				onSelect: function(dateText) {
					//le format de dateText est donné par l'option dateFormat
					//transforme la date donnée au format texte (08082010) en day (8), month (7), year (2010)
					selectedDay(
						parseInt(dateText.slice(0,2),10),
						parseInt(dateText.slice(3,5),10)-1,
						parseInt(dateText.slice(6),10)
					);
				}
			});
 
			/*
			* Bricolage indispensable pour colorer les dates choisies
			* chaque fois que le datepicker se redessine !
			*/
			$("#datepicker").bind("mouseenter", function(){
				if ($("td.important > a", this).eq(0).css("color") != "#FF0000") {
					$("td.important > a", this).css("color","#FF0000");
					$("td.important > a", this).css("background-color","red");
				}
			});
		});	//fin document ready
 
		$(window).load(function(){
			$("#datepicker").mouseenter();
		});	//fin window ready
	})(jQuery);
	</script>
</head>
<body>
	<div id="conteneur">
 
		<h1>jQuery UI Datepicker</h1>
		<p>&nbsp;</p>
		<div id="planning">
			<div id="titre">CAJQ : Club des Amis de jQuery<br />Planning des activités pour le second semestre</div>
 
			<input type="text" id="datepicker" name="datepicker"  />
			<!-- Attention : datepicker ne tient pas compte des div parents, voir le CSS. -->
			<div id="affiche"></div>
		</div>
 
		<div id="important" class="dialog" title="Réunion importante">
			<p>
				Promo au resto
			</p>
		</div>
 
	</div>
</body>
</html>
pandalighton est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/11/2010, 15h21   #6
Membre éclairé
 
sébastien courjean
Inscription : novembre 2010
Messages : 204
Détails du profil
Informations personnelles :
Nom : sébastien courjean
Localisation : France, Indre et Loire (Centre)

Informations forums :
Inscription : novembre 2010
Messages : 204
Points : 319
Points : 319
Ajoute ceci :
Code :
1
2
3
.important .ui-state-default{
			background:none;
		}
__________________
Sébastien Courjean
Développeur Web
scourjean@cyres.fr
http://www.cyres.fr/
scourjean est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/11/2010, 15h36   #7
Invité de passage
 
panda panda
Inscription : novembre 2010
Messages : 4
Détails du profil
Informations personnelles :
Nom : panda panda

Informations forums :
Inscription : novembre 2010
Messages : 4
Points : 0
Points : 0
Yep Merci ca marche nikel
pandalighton est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 15h37.


 
 
 
 
Partenaires

Hébergement Web