Created
January 8, 2018 14:33
-
-
Save mistergraphx/4c0e6f2dc8f0cf12b94384e09d7086e8 to your computer and use it in GitHub Desktop.
Spip - Dateur : exclure des jours et les WE du datepicker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript'>/*<![CDATA[*/ | |
function date_picker_options(){ | |
return { | |
buttonText: '<:afficher_calendrier|texte_script:>', | |
buttonImage: '#CHEMIN_IMAGE{calendrier-16.png}', | |
buttonImageOnly: true, | |
closeText: '<:bouton_fermer|texte_script:>', | |
prevText: '<:precedent|texte_script:>', | |
nextText: '<:suivant|texte_script:>', | |
currentText: '<:date_aujourdhui|texte_script:>', | |
closeText: '<:bouton_fermer|texte_script:>', | |
monthNames: [ | |
'<:date_mois_1|texte_script:>','<:date_mois_2|texte_script:>','<:date_mois_3|texte_script:>','<:date_mois_4|texte_script:>','<:date_mois_5|texte_script:>','<:date_mois_6|texte_script:>', | |
'<:date_mois_7|texte_script:>','<:date_mois_8|texte_script:>','<:date_mois_9|texte_script:>','<:date_mois_10|texte_script:>','<:date_mois_11|texte_script:>','<:date_mois_12|texte_script:>'], | |
monthNamesShort: [ | |
'<:date_mois_1_abbr|texte_script:>','<:date_mois_2_abbr|texte_script:>','<:date_mois_3_abbr|texte_script:>','<:date_mois_4_abbr|texte_script:>','<:date_mois_5_abbr|texte_script:>','<:date_mois_6_abbr|texte_script:>', | |
'<:date_mois_7_abbr|texte_script:>','<:date_mois_8_abbr|texte_script:>','<:date_mois_9_abbr|texte_script:>','<:date_mois_10_abbr|texte_script:>','<:date_mois_11_abbr|texte_script:>','<:date_mois_12_abbr|texte_script:>'], | |
dayNames: [ | |
'<:date_jour_1|texte_script:>','<:date_jour_2|texte_script:>','<:date_jour_3|texte_script:>','<:date_jour_4|texte_script:>', | |
'<:date_jour_5|texte_script:>','<:date_jour_6|texte_script:>','<:date_jour_7|texte_script:>'], | |
dayNamesShort: [ | |
'<:date_jour_1_abbr|texte_script:>','<:date_jour_2_abbr|texte_script:>','<:date_jour_3_abbr|texte_script:>','<:date_jour_4_abbr|texte_script:>', | |
'<:date_jour_5_abbr|texte_script:>','<:date_jour_6_abbr|texte_script:>','<:date_jour_7_abbr|texte_script:>'], | |
dayNamesMin: [ | |
'<:date_jour_1_initiale|texte_script:>','<:date_jour_2_initiale|texte_script:>','<:date_jour_3_initiale|texte_script:>','<:date_jour_4_initiale|texte_script:>', | |
'<:date_jour_5_initiale|texte_script:>','<:date_jour_6_initiale|texte_script:>','<:date_jour_7_initiale|texte_script:>'], | |
dateFormat: 'dd/mm/yy', | |
firstDay: 1, | |
changeMonth: true, | |
changeYear: true, | |
showOtherMonths: true, | |
selectOtherMonths: true, | |
yearRange: "c-60:c+40", | |
beforeShowDay: nationalDays | |
}; | |
} | |
function date_picker_init(){ | |
jQuery('input.date').not('.datePicker') | |
.addClass('datePicker').each(function(){ | |
var options = {showOn: 'button'}; | |
if (jQuery(this).attr('data-startDate')) | |
options.minDate = jQuery(this).attr('data-startDate'); | |
if (jQuery(this).attr('data-endDate')) | |
options.maxDate = jQuery(this).attr('data-endDate'); | |
if (jQuery(this).attr('data-yearRange')) | |
options.yearRange = jQuery(this).attr('data-yearRange'); | |
jQuery(this) | |
.datepicker(jQuery.extend(date_picker_options(),options)) | |
.trigger('datePickerLoaded'); | |
}); | |
jQuery("input.heure").not('.timePicker').addClass('timePicker').timePicker({step:#ENV{heure_pas,30}}); | |
} | |
natDays = [ | |
[1, 26, 'au'], | |
[2, 6, 'nz'], | |
[3, 17, 'ie'], | |
[4, 27, 'za'], [5, 25, 'ar'], [6, 6, 'se'], | |
[7, 4, 'us'], [8, 17, 'id'], [9, 7, 'br'], | |
[10, 1, 'cn'], [11, 22, 'lb'], [12, 12, 'ke'] | |
]; | |
function nationalDays(date) { | |
for (i = 0; i < natDays.length; i++) { | |
if (date.getMonth() == natDays[i][0] - 1 | |
&& date.getDate() == natDays[i][1]) { | |
return [false, natDays[i][2] + '_day']; | |
} | |
} | |
return [true, '']; | |
} | |
function noWeekendsOrHolidays(date) { | |
var noWeekend = $.datepicker.noWeekends(date); | |
if (noWeekend[0]) { | |
return nationalDays(date); | |
} else { | |
return noWeekend; | |
} | |
} | |
var date_picker_loading; | |
if (window.jQuery){ | |
jQuery(function(){ | |
if (jQuery('input.date,input.heure').length | |
&& typeof date_picker_loading=="undefined"){ | |
date_picker_loading = jQuery.getScript('[(#PRODUIRE{fond=formulaires/dateur/jquery.dateur.js}|timestamp)]'); | |
date_picker_loading.done(function(){ | |
date_picker_init(); | |
onAjaxLoad(date_picker_init); | |
}) | |
} | |
}); | |
} | |
/*]]>*/</script> | |
<style type="text/css"> | |
[(#INCLURE{formulaires/dateur/time_picker.css}|compacte{css})] | |
img.ui-datepicker-trigger { display: inline-block; padding: 0; margin: 0; margin-[(#ENV{lang}|lang_dir|choixsiegal{ltr,left,right})]: -19px; vertical-align: middle; z-index:2 } | |
div.time-picker {font-size:11px; width:5em; /* needed for IE */} | |
.formulaire_spip input.date {width:9em;padding-[(#ENV{lang}|lang_dir|choixsiegal{ltr,right,left})]:25px;} | |
.formulaire_spip input.heure {width:7em;} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment