Overview
Comment:Change date inputs to something more accessible
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 59cbce0ec394c4406b09ae43c92e4f9ea50b50d2
User & Date: bohwaz on 2020-09-25 11:58:11
Other Links: branch diff | manifest | tags
Context
2020-09-29
16:52
Add member selector in transactions check-in: 16ef53f5a3 user: bohwaz tags: dev
2020-09-25
11:58
Change date inputs to something more accessible check-in: 59cbce0ec3 user: bohwaz tags: dev
11:46
Use grids for
columns
check-in: ee59447841 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Template.php from [d5ece6e6b5] to [26eb4fe83a].

225
226
227
228
229
230
231
232
233
234
235








236
237
238
239
240
241
242
		if ($type == 'radio' || $type == 'checkbox') {
			$attributes['id'] .= '_' . $value;

			if (isset($_POST[$name]) && $_POST[$name] == $value) {
				$attributes['checked'] = 'checked';
			}
		}

		if ($type == 'file') {
			$help = sprintf('Taille maximale : %s', Utils::format_bytes(Utils::getMaxUploadSize()));
		}









		// Create attributes string
		if (array_key_exists('required', $attributes)) {
			$attributes['required'] = 'required';
		}

		$attributes_string = $attributes;







<
|


>
>
>
>
>
>
>
>







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
		if ($type == 'radio' || $type == 'checkbox') {
			$attributes['id'] .= '_' . $value;

			if (isset($_POST[$name]) && $_POST[$name] == $value) {
				$attributes['checked'] = 'checked';
			}
		}

		elseif ($type == 'file') {
			$help = sprintf('Taille maximale : %s', Utils::format_bytes(Utils::getMaxUploadSize()));
		}
		elseif ($type == 'date') {
			$type = 'text';
			$attributes['placeholder'] = 'JJ/MM/AAAA';
			$attributes['data-input'] = 'date';
			$attributes['size'] = 12;
			$attributes['maxlength'] = 10;
			$attributes['pattern'] = '\d+/\d+/\d{2,4}';
		}

		// Create attributes string
		if (array_key_exists('required', $attributes)) {
			$attributes['required'] = 'required';
		}

		$attributes_string = $attributes;

Modified src/www/admin/static/scripts/global.js from [24c23639ba] to [e3967bb322].

20
21
22
23
24
25
26





27
28
29
30
31
32
33
...
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
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
			return document.getElementById(selector.substr(1));
		}
		else
		{
			return document.getElementsByTagName(selector);
		}
	};






	g.onload = function(callback, dom)
	{
		if (typeof dom == 'undefined')
			dom = true;

		var eventName = dom ? 'DOMContentLoaded' : 'load';
................................................................................
			field.focus();
			field.selectionStart = field.selectionEnd = pos;
		};

		field.parentNode.insertBefore(show_password, field.nextSibling);
	};

	var dateInputFallback = function ()
	{
		/*
		// Firefox dit implémenter date, mais ne l'implémente pas, aucun moyen de détecter ce cas
		// donc on force l'utilisation du custom datepicker de Garradin…
		var input = document.createElement('input');
		input.setAttribute('type', 'date');
		input.value = ':-)';
		input.style.position = 'absolute';
		input.style.visibility = 'hidden';
		document.body.appendChild(input);

		// If input type changed or value hasn't been sanitized then
		// the input type date element is not supported
		if (input.type !== 'text' && input.value !== ':-)')
		{
			document.body.removeChild(input);
		*/
			if (document.querySelector && !document.querySelector('input[type=date]'))
				return false;

			g.script('scripts/datepickr.js');
			g.style('scripts/datepickr.css');
		/*
		}
		else
		{
			document.body.removeChild(input);
		}*/



	};

	g.current_list_input = null;

		// Sélecteurs de listes
	g.onload(() => {
		var inputs = $('form .input-list button');
................................................................................
				g.current_list_input = i.parentNode;
				g.openFrameDialog(i.value);
				return false;
			};
		});
	});

	g.onload(dateInputFallback);

	if (!document.querySelectorAll)
	{
		return;
	}

	g.onload(function () {
		var tableActions = document.querySelectorAll('form table tfoot .actions select');

		for (var i = 0; i < tableActions.length; i++)
		{
			tableActions[i].onchange = function () {







>
>
>
>
>







 







|
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
>
>







 







|
|
|
|
|
<







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
...
185
186
187
188
189
190
191
192




193























194
195
196
197
198
199
200
201
202
203
...
207
208
209
210
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
			return document.getElementById(selector.substr(1));
		}
		else
		{
			return document.getElementsByTagName(selector);
		}
	};

	if (!document.querySelectorAll)
	{
		return;
	}

	g.onload = function(callback, dom)
	{
		if (typeof dom == 'undefined')
			dom = true;

		var eventName = dom ? 'DOMContentLoaded' : 'load';
................................................................................
			field.focus();
			field.selectionStart = field.selectionEnd = pos;
		};

		field.parentNode.insertBefore(show_password, field.nextSibling);
	};

	g.enhanceDateField = (input) => {




		var btn = document.createElement('button');























		btn.className = 'icn-btn';
		btn.innerHTML = 'Cal'; // FIXME: calendar icon
		input.parentNode.insertBefore(btn, input.nextSibling);
	};

	g.current_list_input = null;

		// Sélecteurs de listes
	g.onload(() => {
		var inputs = $('form .input-list button');
................................................................................
				g.current_list_input = i.parentNode;
				g.openFrameDialog(i.value);
				return false;
			};
		});
	});

	g.onload(() => {
		document.querySelectorAll('input[data-input="date"]').forEach((e) => {
			g.enhanceDateField(e);
		});
	});


	g.onload(function () {
		var tableActions = document.querySelectorAll('form table tfoot .actions select');

		for (var i = 0; i < tableActions.length; i++)
		{
			tableActions[i].onchange = function () {