Overview
Comment:Amélioration ergonomique des champs date pour les navigateurs qui ne gèrent pas le type date : on peut entrer la date au format dd/mm/YYYY
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e879dc5febb724581f53f883bc5295d2656655e6
User & Date: bohwaz on 2014-04-12 01:03:24
Other Links: manifest | tags
Context
2014-04-12
05:46
Un peu d'animation pour les longues tâches check-in: 587b766d75 user: bohwaz tags: trunk
01:03
Amélioration ergonomique des champs date pour les navigateurs qui ne gèrent pas le type date : on peut entrer la date au format dd/mm/YYYY check-in: e879dc5feb user: bohwaz tags: trunk
00:41
Restreindre les dates acceptées dans les champs persos check-in: 0c2ea2638c user: bohwaz tags: trunk
Changes

Modified src/templates/admin/_head.tpl from [0b1acce54b] to [c60ca22903].

    37     37           <li><a href="{$admin_url}">Connexion</a>
    38     38               <ul>
    39     39                   <li><a href="{$admin_url}password.php">Mot de passe perdu</a>
    40     40               </ul>
    41     41           </li>
    42     42       {else}
    43     43           <li class="home{if $current == 'home'} current{/if}"><a href="{$admin_url}">Accueil</a></li>
           44  +        {if !empty($plugins_menu)}
           45  +            <li class="plugins">
           46  +                <ul>
           47  +                {foreach from=$plugins_menu key="id" item="name"}
           48  +                    <li class="plugins {$id|escape}{if $current == 'plugin_`$id`'} current{/if}"><a href="{plugin_url id=$id}">{$name|escape}</a></li>
           49  +                {/foreach}
           50  +                </ul>
           51  +            </li>
           52  +        {/if}
    44     53           {if $user.droits.membres >= Garradin\Membres::DROIT_ACCES}
    45     54               <li class="member list{if $current == 'membres'} current{/if}"><a href="{$admin_url}membres/">Membres <small>({$nb_membres|escape})</small></a>
    46     55               {if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}
    47     56               <ul>
    48     57                   <li class="member new{if $current == 'membres/ajouter'} current{/if}"><a href="{$admin_url}membres/ajouter.php">Ajouter</a></li>
    49     58                   <li class="member cotisations{if $current == 'membres/cotisations'} current{/if}"><a href="{$admin_url}membres/cotisations/">Cotisations</a></li>
    50     59                   {if $user.droits.membres >= Garradin\Membres::DROIT_ADMIN}
................................................................................
    81     90                   {*<li class="wiki follow{if $current == 'wiki/contribution'} current{/if}"><a href="{$admin_url}wiki/contributions.php">Mes contributions</a>*}
    82     91               </ul>
    83     92               </li>
    84     93           {/if}
    85     94           {if $user.droits.config >= Garradin\Membres::DROIT_ADMIN}
    86     95               <li class="main config{if $current == 'config'} current{/if}"><a href="{$admin_url}config/">Configuration</a>
    87     96           {/if}
    88         -        {if !empty($plugins_menu)}
    89         -            <li class="plugins">
    90         -                <a>Extensions</a>
    91         -                <ul>
    92         -                {foreach from=$plugins_menu key="id" item="name"}
    93         -                    <li class="plugins {$id|escape}{if $current == 'plugin_`$id`'} current{/if}"><a href="{plugin_url id=$id}">{$name|escape}</a></li>
    94         -                {/foreach}
    95         -                </ul>
    96         -            </li>
    97         -        {/if}
    98     97           <li class="my config{if $current == 'mes_infos'} current{/if}"><a href="{$admin_url}mes_infos.php">Mes infos personnelles</a>
    99     98               <ul>
   100     99                   <li class="my cotisations{if $current == 'mes_cotisations'} current{/if}"><a href="{$admin_url}mes_cotisations.php">Mes cotisations</a></li>
   101    100               </ul>
   102    101           </li>
   103    102           {if !defined('Garradin\LOCAL_LOGIN')}
   104    103           <li class="logout"><a href="{$admin_url}logout.php">Déconnexion</a></li>

Modified src/www/admin/static/datepickr.js from [3ca93c8113] to [34b4a67e07].

   186    186   	function bindDayLinks() {
   187    187   		var days = body.getElementsByTagName('a');
   188    188   
   189    189   		for(i = 0, x = days.length; i < x; i++) {
   190    190   			days[i].onclick = function() {
   191    191   				currentDate = new Date(currentYearView, currentMonthView, this.innerHTML);
   192    192   				element.value = formatDate(currentDate.getTime());
          193  +				element.onchange(element);
   193    194   				close();
   194    195   				return false;
   195    196   			}
   196    197   		}
   197    198   	}
   198    199   
   199    200   	function buildWeekdays() {
................................................................................
   265    266   					parentNode = parentNode.parentNode;
   266    267   					if(parentNode == null) {
   267    268   						close();
   268    269   						break;
   269    270   					}
   270    271   				}
   271    272   			}
          273  +
          274  +			if (target == element)
          275  +			{
          276  +				close();
          277  +			}
   272    278   
   273    279   			e.preventDefault();
   274    280   		}
          281  +
          282  +		document.onkeyup = function(e) {
          283  +			var k = e.keyCode || e.which;
          284  +
          285  +			if (k == 27)
          286  +			{
          287  +				close();
          288  +				e.preventDefault();
          289  +				return false;
          290  +			}
          291  +		};
   275    292   
   276    293   		document.onkeypress = function(e) {
   277    294   			var k = e.keyCode || e.which;
   278    295   
   279    296   			if (k == 33) // PgUp
   280    297   			{
   281    298   				e.preventDefault();
................................................................................
   319    336   
   320    337   				currentPosition = pos;
   321    338   				currentDate = new Date(currentYearView, currentMonthView, row.firstChild.innerHTML);
   322    339   			}
   323    340   			else if (k == 13 || k == 32)
   324    341   			{
   325    342   				element.value = formatDate(currentDate.getTime());
          343  +				element.onchange(element);
   326    344   				close();
   327    345   				e.preventDefault();
   328    346   				return false;
   329    347   			}
   330    348   		}
   331    349   
   332    350   		handleMonthClick();
................................................................................
   346    364   					config[key] = userConfig[key];
   347    365   				}
   348    366   			}
   349    367   		}
   350    368   
   351    369   		if (element.value)
   352    370   		{
   353         -			var d = element.value.split('-');
          371  +			var d = element.value.split('/').reverse();
   354    372   			currentDate = new Date(parseInt(d[0], 10), parseInt(d[1], 10) - 1, parseInt(d[2], 10), 0, 0, 0, 0);
   355    373   			currentYearView = get.current.year();
   356    374   			currentMonthView = get.current.month.integer();
   357    375   		}
   358    376   		container = build('div', { className: 'calendar' });
   359    377   		container.style.cssText = 'display: none; position: absolute; z-index: 9999;';
   360    378   
................................................................................
   391    409   }
   392    410   
   393    411   // Add-on for HTML5 input type="date" fallback
   394    412   
   395    413   (function() {
   396    414   	var config_fr = {
   397    415   		fullCurrentMonth: true,
   398         -		dateFormat: 'Y-m-d',
          416  +		dateFormat: 'd/m/Y',
   399    417   		firstDayOfWeek: 0,
   400    418   		weekdays: ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim'],
   401    419   		months: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
   402    420   		suffix: { 1: 'er' },
   403    421   		defaultSuffix: ''
   404    422   	};
   405    423   
................................................................................
   409    427   		var length = inputs.length;
   410    428   		var enabled = false;
   411    429   
   412    430   		for (i = 0; i < inputs.length; i++)
   413    431   		{
   414    432   			if (inputs[i].getAttribute('type') == 'date')
   415    433   			{
   416         -				inputs[i].setAttribute('type', 'text');
   417         -				inputs[i].className += ' date';
   418         -				inputs[i].size = 10;
   419         -				inputs[i].maxlength = 10;
   420         -				inputs[i].setAttribute('pattern', '[0-9]{4}-[0-9]{2}-[0-9]{2}');
   421         -				new datepickr(inputs[i], config_fr);
          434  +				var new_input = inputs[i].cloneNode(true);
          435  +				inputs[i].type = 'hidden';
          436  +				inputs[i].removeAttribute('pattern');
          437  +				inputs[i].removeAttribute('id');
          438  +				inputs[i].removeAttribute('required');
          439  +				
          440  +				new_input.removeAttribute('name');
          441  +				new_input.setAttribute('type', 'text');
          442  +				new_input.className += ' date';
          443  +				new_input.size = 10;
          444  +				new_input.maxlength = 10;
          445  +				new_input.value = inputs[i].value.split('-').reverse().join('/');
          446  +				new_input.setAttribute('pattern', '([012][0-9]|3[01])/(0[0-9]|1[0-2])/[12][0-9]{3}');
          447  +				
          448  +				new_input.onchange = function ()
          449  +				{
          450  +					if (this.value.match(/\d{2}\/\d{2}\/\d{4}/))
          451  +						this.nextSibling.value = this.value.split('/').reverse().join('-');
          452  +					else
          453  +						this.nextSibling.value = this.value;
          454  +				};
          455  +
          456  +				inputs[i].parentNode.insertBefore(new_input, inputs[i]);
          457  +				new datepickr(new_input, config_fr);
   422    458   			}
   423    459   		}
   424    460   	}
   425    461   
   426    462   	dateInputFallback();
   427    463   } () );