enmi12/glossaire/js/main.js
changeset 0 d970ebf37754
child 1 f6eb5a861d2f
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 function preg_replace (array_pattern, array_pattern_replace, my_string) { var new_string = String (my_string); for (i=0; i<array_pattern.length; i++) { var reg_exp= RegExp(array_pattern[i], "gi"); var val_to_replace = array_pattern_replace[i]; new_string = new_string.replace (reg_exp, val_to_replace); } return new_string; }
       
     2 
       
     3 function removeAccents (my_string) { var new_string = ""; var pattern_accent = new Array("é", "è", "ê", "ë", "ç", "à", "â", "ä", "î", "ï", "ù", "ô", "ó", "ö"); var pattern_replace_accent = new Array("e", "e", "e", "e", "c", "a", "a", "a", "i", "i", "u", "o", "o", "o"); if (my_string && my_string!= "") { new_string = preg_replace (pattern_accent, pattern_replace_accent, my_string); } new_string = new_string.replace(/\s+/g, ''); return new_string; }
       
     4 
       
     5 $('#container').isotope({
       
     6   itemSelector : '.definition',
       
     7   layoutMode : 'fitRows'
       
     8 });
       
     9 
       
    10 $(function()
       
    11 {
       
    12 	if($('#champsRecherche').val().length > 0)
       
    13 	{
       
    14 		var recherche = $('#champsRecherche').val().toLowerCase();
       
    15 		recherche = removeAccents(recherche);
       
    16 		var resultat = $("[data-mot*='" + recherche + "']").add('.row-end');
       
    17 		var selector = resultat;
       
    18 		
       
    19 		$('#container').isotope({ 
       
    20 		filter: selector 
       
    21 		});
       
    22 	}
       
    23 	
       
    24 	$(".copyButton").zclip({
       
    25 		path: "ZeroClipboard.swf",
       
    26 		copy: function(){return $(this).prev().val();},
       
    27 		afterCopy: function(){$(this).text('Copié !');},
       
    28 		
       
    29 	});
       
    30 });
       
    31 
       
    32 $('.defineTile').click(function(event){
       
    33 	event.stopPropagation();
       
    34 	$(this).addClass('active');
       
    35 	$(this).siblings('li').removeClass('active');
       
    36 	$(this).parent().nextAll('.commentSection').hide();
       
    37 });
       
    38 
       
    39 $('.commentTile').click(function(event){
       
    40 	event.stopPropagation()
       
    41 	$(this).addClass('active');
       
    42 	$(this).siblings('li').removeClass('active');
       
    43 	$(this).parent().nextAll('.commentSection').show();
       
    44 	
       
    45 	//xmlRequest(event);
       
    46 });
       
    47 
       
    48 $('#menuExtraContent a').click(function(event){
       
    49 	event.stopPropagation();
       
    50 	$(this).addClass('active');
       
    51 	$(this).siblings('a').removeClass('active');
       
    52 });
       
    53 
       
    54 $('#filters input').click(function(){
       
    55 	$(this).siblings().attr('checked', false);
       
    56 	$(this).attr('checked', true);
       
    57 	
       
    58 	if($('#champsRecherche').val().length == 0)
       
    59 	{
       
    60 		var selector = $('div input[checked]').attr('data-filter');
       
    61 	}
       
    62 	else
       
    63 	{
       
    64 		var recherche = $('#champsRecherche').val().toLowerCase();
       
    65 		recherche = removeAccents(recherche);
       
    66 		var resultat = $("[data-mot*='" + recherche + "']");
       
    67 		var selector = $($('div input[checked]').attr('data-filter')).filter(resultat).add('.row-end');
       
    68 	}
       
    69 	
       
    70 	$('#container').isotope({ 
       
    71 	filter: selector 
       
    72 	});
       
    73 });
       
    74 
       
    75 $('#champsRecherche').keyup(function(event){
       
    76 	var recherche = $('#champsRecherche').val().toLowerCase();
       
    77 	recherche = removeAccents(recherche);
       
    78 	var resultat = $("[data-mot*='" + recherche + "']");
       
    79 	var selector = $($('div input[checked]').attr('data-filter')).filter(resultat).add('.row-end');
       
    80 
       
    81 	
       
    82 	if($('#champsRecherche').val().length == 0)
       
    83 	{
       
    84 		selector = $('div input[checked]').attr('data-filter');
       
    85 	}
       
    86 	$('#container').isotope({ 
       
    87 	filter: selector 
       
    88 	});
       
    89 
       
    90 });
       
    91 
       
    92 $('.element').click(function(){
       
    93 	if(!$(this).hasClass("folder")){
       
    94 		$(this).toggleClass("large");
       
    95 		if(!$(this).prevAll('.folder').first().hasClass('height2')){
       
    96 			$(this).prevAll('.folder').first().toggleClass('height2');
       
    97 		}
       
    98 		else if($(this).prevAll('.folder').first().hasClass('height2') && $(this).siblings('.large').length == 0 && !$(this).hasClass('large')){
       
    99 			$(this).prevAll('.folder').first().toggleClass('height2');
       
   100 		}
       
   101 		$('#container').isotope(
       
   102 			'reLayout');
       
   103 	}
       
   104 });