jQuery(function($) {
	editer_article();
	//onAjaxLoad(editer_article);

	function editer_article(){
		// chargement du datepicker
		$('.datepicker').datepicker({
			dateFormat: "dd/mm/yy",
		});

		// on charge dans le input #tags_save les mots au chargement du formulaire
		if (typeof(T_hastag_ini) !== 'undefined') {
			$('#tags_save').val(JSON.stringify(T_hastag_ini));
		}

		/* DOC :
		 * https://goodies.pixabay.com/jquery/tag-editor/demo.html
		 */
		$('#tags_ouverts').tagEditor({
			autocomplete: {
				delay: 0, // show suggestions immediately
				position: { collision: 'flip' }, // automatic menu position up/down
				source: T_hashtag
			},
			initialTags: T_hastag_ini,
			forceLowercase: false,
			placeholder: 'HashTags',
			onChange: function(field, editor, tags){
				$('#tags_save').val(JSON.stringify(tags));
			}
		});
		
	}
	
	// nb caractères champs SEO
	$('.compter').each( function() {
		var nb = $(this).val().length;
		var id_s = $(this).attr('data-nb');
		$('#' + id_s).html(nb);
	});
	$('.compter').on('keyup', function(e) {
		var nb = $(this).val().length;
		var id_s = $(this).attr('data-nb');
		$('#' + id_s).html(nb);
	});
});
