front_idill/src/mosaic/js/notifications.js
changeset 47 4e1ee94d70b1
parent 46 9d7a2aa112fb
child 52 277c94533395
equal deleted inserted replaced
46:9d7a2aa112fb 47:4e1ee94d70b1
    12 	if(this.helpDisplayed)
    12 	if(this.helpDisplayed)
    13 	{
    13 	{
    14 		return;
    14 		return;
    15 	}
    15 	}
    16 	
    16 	
    17 	this.removeSelectionSearchMosaicFull();
    17 	console.log('HELP DISPLAYED');
    18 	this.removePointMosaicPrezoom();
    18 	
       
    19 	this.removeNotifications();
    19 	
    20 	
    20 	this.helpDisplayed = true;
    21 	this.helpDisplayed = true;
    21 	
    22 	
    22 	var search_2hands_tab = ['arret', 'contact', 'grandjete', 'group_spin', 'port_de_bras', 'rythme', 'slow', 'spin', 'up_down', 'wave'];
    23 	var search_2hands_tab;
    23 	var search_2hands_tab_opacities = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5];
    24 	var search_2hands_tab_opacities;
    24 	var search_body_tab = ['chute', 'knee_up', 'jump', 'bend'];
    25 	var search_body_tab;
    25 	var search_body_tab_opacities = [1, 1, 1, 1];
    26 	var search_body_tab_opacities;
    26 	var controls_1hand_tab;
    27 	var controls_1hand_tab;
    27 	var controls_1hand_tab_1;
    28 	var controls_1hand_tab;
    28 	var controls_1hand_tab_2;
       
    29 	var controls_1hand_tab_opacities;
    29 	var controls_1hand_tab_opacities;
    30 	var controls_1hand_tab_opacities_1;
    30 	var controls_1hand_tab_opacities;
    31 	var controls_1hand_tab_opacities_2;
    31 	
       
    32 	var img_directory = './pictos/help/';
       
    33 	
       
    34 	if(this.mouseInteractions)
       
    35 	{
       
    36 		search_2hands_tab = ['arret', 'contact', 'grandjete', 'group_spin', 'port_de_bras', 'spin', 'up_down', 'wave', 'chute', 'knee_up', 'jump', 'bend'];
       
    37 		search_2hands_tab_opacities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
       
    38 	}
       
    39 	else
       
    40 	{
       
    41 		search_2hands_tab = ['arret', 'contact', 'grandjete', 'group_spin', 'port_de_bras', 'spin', 'up_down', 'wave'];
       
    42 		search_body_tab = ['chute', 'knee_up', 'jump', 'bend'];
       
    43 		search_2hands_tab_opacities = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5];
       
    44 		search_body_tab_opacities = [1, 1, 1, 1];
       
    45 	}
    32 	
    46 	
    33 	if(inMosaic)
    47 	if(inMosaic)
    34 	{
    48 	{
    35 		controls_1hand_tab = ['selection'];
    49 		controls_1hand_tab = ['selection'];
    36 		controls_1hand_tab_opacities = [1];
    50 		controls_1hand_tab_opacities = [1];
    37 	}
    51 	}
    38 	else
    52 	else
    39 	{
    53 	{
    40 		controls_1hand_tab_1 = ['deplacer', 'precedent', 'suivant', 'mosaique_horizontal', 'mosaique_vertical'];
    54 		controls_1hand_tab = ['deplacer', 'precedent', 'suivant', 'mosaique_horizontal', 'mosaique_vertical', 'move_down', 'move_up', 'move_right', 'move_left'];
    41 		controls_1hand_tab_2 = ['move_down', 'move_up', 'move_right', 'move_left'];
    55 		controls_1hand_tab_opacities = [1, 1, 1, 1, 1, 1, 1, 1, 1];
    42 		controls_1hand_tab_opacities_1 = [1, 1, 1, 1, 1];
       
    43 		controls_1hand_tab_opacities_2 = [1, 1, 1, 1];
       
    44 	}
    56 	}
    45 	
    57 	
    46 	//On spécifie les notifications en div.
    58 	//On spécifie les notifications en div.
    47 	var search_title = "<div id='search_title'></div>";
    59 	var search_title = "<div id='search_title'></div>";
    48 	var search_img = "<div id='search_img' class='notify_imgs'></div>";
    60 	var search_img = "<div id='search_img' class='notify_imgs'></div>";
    53 	{
    65 	{
    54 		search_2hands_imgs += "<div id='2hands_" + search_2hands_tab[i] + "' class='notify_imgs_small' style='opacity: " + search_2hands_tab_opacities[i] + ";'></div>";
    66 		search_2hands_imgs += "<div id='2hands_" + search_2hands_tab[i] + "' class='notify_imgs_small' style='opacity: " + search_2hands_tab_opacities[i] + ";'></div>";
    55 	}
    67 	}
    56 	search_2hands_imgs += "</div>";
    68 	search_2hands_imgs += "</div>";
    57 	
    69 	
    58 	var search_body_text = "<div id='search_body_text'></div>";
    70 	var search_body_text;
    59 	var search_body_imgs = "<div id='search_body_imgs' class='notify_imgs'>"
    71 	var search_body_imgs;
    60 	
    72 	
    61 	for(var i = 0 ; i < search_body_tab.length ; i++)
    73 	if(!this.mouseInteractions)
    62 	{
    74 	{
    63 		search_body_imgs += "<div id='body_" + search_body_tab[i] + "' class='notify_imgs_small' style='opacity: " + search_body_tab_opacities[i] + ";'></div>";
    75 		search_body_text = "<div id='search_body_text'></div>";
    64 	}
    76 		search_body_imgs = "<div id='search_body_imgs' class='notify_imgs'>"
    65 	search_body_imgs += "</div>";
    77 		
       
    78 		for(var i = 0 ; i < search_body_tab.length ; i++)
       
    79 		{
       
    80 			search_body_imgs += "<div id='body_" + search_body_tab[i] + "' class='notify_imgs_small' style='opacity: " + search_body_tab_opacities[i] + ";'></div>";
       
    81 		}
       
    82 		search_body_imgs += "</div>";
       
    83 	}
    66 	
    84 	
    67 	var controls_title = "<div id='controls_title'></div>";
    85 	var controls_title = "<div id='controls_title'></div>";
    68 	var controls_img = "<div id='controls_img' class='notify_imgs'></div>";
    86 	var controls_img = "<div id='controls_img' class='notify_imgs'></div>";
    69 	var controls_1hand_text = "<div id='controls_1hand_text'></div>";
    87 	var controls_1hand_text = "<div id='controls_1hand_text'></div>";
    70 	var controls_1hand_imgs;
    88 	var controls_1hand_imgs;
    71 	var controls_1hand_imgs_1;
    89 	var controls_1hand_imgs;
    72 	var controls_1hand_imgs_2;
    90 	
    73 	
    91 	controls_1hand_imgs = "<div id='controls_1hand_imgs' class='notify_imgs'>";
    74 	if(inMosaic)
    92 	for(var i = 0 ; i < controls_1hand_tab.length ; i++)
    75 	{
    93 	{
    76 		controls_1hand_imgs = "<div id='controls_1hand_imgs' class='notify_imgs'>";
    94 		controls_1hand_imgs += "<div id='1hand_" + controls_1hand_tab[i] + "' class='notify_imgs_small' style='opacity: " + controls_1hand_tab_opacities[i] + ";'></div>";
    77 		for(var i = 0 ; i < controls_1hand_tab.length ; i++)
    95 	}
    78 		{
    96 	controls_1hand_imgs += "</div>";
    79 			controls_1hand_imgs += "<div id='1hand_" + controls_1hand_tab[i] + "' class='notify_imgs_small' style='opacity: " + controls_1hand_tab_opacities[i] + ";'></div>";
    97 	
    80 		}
    98 	var help_search;
    81 		controls_1hand_imgs += "</div>";
    99 	
       
   100 	if(this.mouseInteractions)
       
   101 	{
       
   102 		help_search = "<div id='help_search'>" + search_title + search_img + search_2hands_text + search_2hands_imgs + "</div>";
    82 	}
   103 	}
    83 	else
   104 	else
    84 	{
   105 	{
    85 		controls_1hand_imgs_1 = "<div id='controls_1hand_imgs_1' class='notify_imgs'>";
   106 		help_search = "<div id='help_search'>" + search_title + search_img + search_2hands_text + search_2hands_imgs + search_body_text + search_body_imgs + "</div>";
    86 		controls_1hand_imgs_2 = "<div id='controls_1hand_imgs_2' class='notify_imgs'>";
   107 	}
    87 		for(var i = 0 ; i < controls_1hand_tab_1.length ; i++)
       
    88 		{
       
    89 			controls_1hand_imgs_1 += "<div id='1hand_" + controls_1hand_tab_1[i] + "' class='notify_imgs_small' style='opacity: " + controls_1hand_tab_opacities_1[i] + ";'></div>";
       
    90 		}
       
    91 		controls_1hand_imgs_1 += "</div>";
       
    92 		for(var i = 0 ; i < controls_1hand_tab_2.length ; i++)
       
    93 		{
       
    94 			controls_1hand_imgs_2 += "<div id='1hand_" + controls_1hand_tab_2[i] + "' class='notify_imgs_small' style='opacity: " + controls_1hand_tab_opacities_2[i] + ";'></div>";
       
    95 		}
       
    96 		controls_1hand_imgs_2 += "</div>";
       
    97 	}
       
    98 	
       
    99 	var help_search = "<div id='help_search'>" + search_title + search_img + search_2hands_text + search_2hands_imgs + search_body_text + search_body_imgs + "</div>";
       
   100 	var help_controls;
   108 	var help_controls;
   101 
   109 
   102 	if(inMosaic)
   110 	help_controls = "<div id='help_controls'>" + controls_title + controls_img + controls_1hand_text + controls_1hand_imgs + "</div>";
   103 	{
       
   104 		help_controls = "<div id='help_controls'>" + controls_title + controls_img + controls_1hand_text + controls_1hand_imgs + "</div>";
       
   105 	}
       
   106 	else
       
   107 	{
       
   108 		help_controls = "<div id='help_controls'>" + controls_title + controls_img + controls_1hand_text + controls_1hand_imgs_1 + controls_1hand_imgs_2 + "</div>";
       
   109 	}
       
   110 	
   111 	
   111 	var notification_help = "<div id='notify_help'>" + help_search + "<div id='help_sep'></div>" + help_controls + "</div>";
   112 	var notification_help = "<div id='notify_help'>" + help_search + "<div id='help_sep'></div>" + help_controls + "</div>";
   112 	
   113 	
   113 	//On les ajoute à la mosaïque.
   114 	//On les ajoute à la mosaïque.
   114 	$('body').append(notification_help);
   115 	$('body').append(notification_help);
   128 		'z-index': 2000
   129 		'z-index': 2000
   129 	});
   130 	});
   130 	
   131 	
   131 	// console.log(($('#help_search').width() - ($('.notify_imgs_small').width() * 5 + parseInt($('.notify_imgs_small').css('margin')))) / 2);
   132 	// console.log(($('#help_search').width() - ($('.notify_imgs_small').width() * 5 + parseInt($('.notify_imgs_small').css('margin')))) / 2);
   132 	
   133 	
       
   134 	var margins = parseInt($('.notify_imgs_small').css('margin'));
       
   135 	var widths = $('.notify_imgs_small').width();
       
   136 	var heights = $('.notify_imgs_small').height();
       
   137 	
       
   138 	var sep_left = $('#help_sep').position().left;
       
   139 	var help_margin = parseInt($('#notify_help').css('margin'));
       
   140 	
       
   141 	//On calcule la taille d'une zone de recherche (une des deux parties).
       
   142 	var help_column_width = sep_left - help_margin;
       
   143 	//Longueur d'une image.
       
   144 	var img_width = (margins * 2 + widths);
       
   145 	//Longueur totale des images de recherche à deux mains mises bout à bout.
       
   146 	// var search_2hands_total_width = search_2hands_tab.length * img_width;
       
   147 	
       
   148 	//On récupère le nombre d'images affichables horizontalement pour les gestures de recherche à deux mains dans une des parties de l'aide.
       
   149 	var search_2hands_n_imgs = Math.floor(help_column_width / img_width);
       
   150 	//Calcul du padding-left de cette section.
       
   151 	var search_2hands_padding_left = (help_column_width - search_2hands_n_imgs * img_width) / 2;
       
   152 	
   133 	$('#search_2hands_imgs').css(
   153 	$('#search_2hands_imgs').css(
   134 	{
   154 	{
   135 		'padding-left': ($('#help_search').width() - ($('.notify_imgs_small').width() * 5 + parseInt($('.notify_imgs_small').css('margin')))) / 2,
   155 		// 'padding-left': ($('#help_search').width() - ($('.notify_imgs_small').width() * 5 + parseInt($('.notify_imgs_small').css('margin')))) / 2,
       
   156 		'padding-left': search_2hands_padding_left,
   136 		'height': ($('.notify_imgs_small').height() * 2 + parseInt($('.notify_imgs_small').css('margin')))
   157 		'height': ($('.notify_imgs_small').height() * 2 + parseInt($('.notify_imgs_small').css('margin')))
   137 	});
   158 	});
   138 	
   159 	
       
   160 	//On récupère le nombre d'images affichables horizontalement pour les gestures de recherche corporelles dans une des parties de l'aide.
       
   161 	var search_body_n_imgs = Math.floor(help_column_width / img_width);
       
   162 	//Calcul du padding-left de cette section.
       
   163 	var search_body_padding_left = (help_column_width - search_body_n_imgs * img_width) / 2;
       
   164 	
   139 	$('#search_body_imgs').css(
   165 	$('#search_body_imgs').css(
   140 	{
   166 	{
   141 		'padding-left': ($('#help_search').width() - ($('.notify_imgs_small').width() * 4 + parseInt($('.notify_imgs_small').css('margin')))) / 2,
   167 		// 'padding-left': ($('#help_search').width() - ($('.notify_imgs_small').width() * 4 + parseInt($('.notify_imgs_small').css('margin')))) / 2,
       
   168 		'padding-left': search_body_padding_left,
   142 		'height': ($('.notify_imgs_small').height() * 2 + parseInt($('.notify_imgs_small').css('margin')))
   169 		'height': ($('.notify_imgs_small').height() * 2 + parseInt($('.notify_imgs_small').css('margin')))
   143 	});
   170 	});
   144 	
   171 	
   145 	if(inMosaic)
   172 	//On récupère le nombre d'images affichables horizontalement pour les gestures de controle dans une des parties de l'aide.
   146 	{
   173 	var controls_1hand_n_imgs = Math.floor(help_column_width / img_width);
   147 		$('#controls_1hand_imgs').css(
   174 	//Calcul du padding-left de cette section.
       
   175 	var controls_1hand_padding_left = (help_column_width - controls_1hand_n_imgs * img_width) / 2;
       
   176 	
       
   177 	$('#controls_1hand_imgs').css(
       
   178 	{
       
   179 		// 'padding-left': ($('#help_controls').width() - ($('.notify_imgs_small').width())) / 2,
       
   180 		'padding-left': controls_1hand_padding_left,
       
   181 		'height': ($('.notify_imgs_small').height())
       
   182 	});
       
   183 	
       
   184 	var search_width = $('#help_search').width();
       
   185 	
       
   186 	$('#search_title').html('Recherche');
       
   187 	
       
   188 	if(this.mouseInteractions)
       
   189 	{
       
   190 		$('#search_2hands_text').html('Courbes à effectuer avec la souris');
       
   191 	}
       
   192 	else
       
   193 	{
       
   194 		$('#search_2hands_text').html('Gestes à effectuer avec les deux mains');
       
   195 	}
       
   196 	
       
   197 	for(var i = 0 ; i < search_2hands_tab.length ; i++)
       
   198 	{
       
   199 		$("#2hands_" + search_2hands_tab[i]).css("background-image", "url('" + img_directory + 'MI/' + search_2hands_tab[i] + ".png')");
       
   200 		//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')");
       
   201 	}
       
   202 	
       
   203 	if(!this.mouseInteractions)
       
   204 	{
       
   205 		$('#search_body_text').html('Gestes à effectuer avec le corps entier');
       
   206 		
       
   207 		for(var i = 0 ; i < search_body_tab.length ; i++)
   148 		{
   208 		{
   149 			'padding-left': ($('#help_controls').width() - ($('.notify_imgs_small').width())) / 2,
   209 			$("#body_" + search_body_tab[i]).css("background-image", "url('" + img_directory + search_body_tab[i] + ".png')");
   150 			'height': ($('.notify_imgs_small').height())
   210 			//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')");
   151 		});
   211 		}
   152 	}
       
   153 	else
       
   154 	{
       
   155 		$('#controls_1hand_imgs_1').css(
       
   156 		{
       
   157 			'padding-left': ($('#help_controls').width() - ($('.notify_imgs_small').width() * 5 + parseInt($('.notify_imgs_small').css('margin')))) / 2,
       
   158 			'height': ($('.notify_imgs_small').height())
       
   159 		});
       
   160 		$('#controls_1hand_imgs_2').css(
       
   161 		{
       
   162 			'padding-left': ($('#help_controls').width() - ($('.notify_imgs_small').width() * 4 + parseInt($('.notify_imgs_small').css('margin')))) / 2,
       
   163 			'height': ($('.notify_imgs_small').height())
       
   164 		});
       
   165 	}
       
   166 	
       
   167 	var search_width = $('#help_search').width();
       
   168 	
       
   169 	$('#search_title').html('Recherche');
       
   170 	$('#search_2hands_text').html('Gestes à effectuer avec les deux mains');
       
   171 	$('#search_body_text').html('Gestes à effectuer avec le corps entier');
       
   172 	
       
   173 	for(var i = 0 ; i < search_2hands_tab.length ; i++)
       
   174 	{
       
   175 		$("#2hands_" + search_2hands_tab[i]).css("background-image", "url('./pictos/help/" + search_2hands_tab[i] + ".png')");
       
   176 		//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')");
       
   177 	}
       
   178 	
       
   179 	for(var i = 0 ; i < search_body_tab.length ; i++)
       
   180 	{
       
   181 		$("#body_" + search_body_tab[i]).css("background-image", "url('./pictos/help/" + search_body_tab[i] + ".png')");
       
   182 		//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')");
       
   183 	}
   212 	}
   184 	
   213 	
   185 	$('#controls_title').html('Contrôles');
   214 	$('#controls_title').html('Contrôles');
   186 	$('#controls_1hand_text').html('Gestes à effectuer avec une seule main');
   215 	$('#controls_1hand_text').html('Gestes à effectuer avec une seule main');
   187 	
   216 	
   188 	if(inMosaic)
   217 	for(var i = 0 ; i < controls_1hand_tab.length ; i++)
   189 	{
   218 	{
   190 		for(var i = 0 ; i < controls_1hand_tab.length ; i++)
   219 		$("#1hand_" + controls_1hand_tab[i]).css("background-image", "url('" + img_directory + controls_1hand_tab[i] + ".png')");
   191 		{
       
   192 			$("#1hand_" + controls_1hand_tab[i]).css("background-image", "url('./pictos/help/" + controls_1hand_tab[i] + ".png')");
       
   193 		}
       
   194 	}
       
   195 	else
       
   196 	{
       
   197 		for(var i = 0 ; i < controls_1hand_tab_1.length ; i++)
       
   198 		{
       
   199 			$("#1hand_" + controls_1hand_tab_1[i]).css("background-image", "url('./pictos/help/" + controls_1hand_tab_1[i] + ".png')");
       
   200 		}
       
   201 		for(var i = 0 ; i < controls_1hand_tab_2.length ; i++)
       
   202 		{
       
   203 			$("#1hand_" + controls_1hand_tab_2[i]).css("background-image", "url('./pictos/help/" + controls_1hand_tab_2[i] + ".png')");
       
   204 		}
       
   205 	}
   220 	}
   206 	
   221 	
   207 	//On les fait apparaître.
   222 	//On les fait apparaître.
   208 	$('#notify_help').css(
   223 	$('#notify_help').css(
   209 	{
   224 	{
   251 	}
   266 	}
   252 	
   267 	
   253 	//Si on a effectué une demande de recherche auparavant, on supprime la notification de demande de recherche.
   268 	//Si on a effectué une demande de recherche auparavant, on supprime la notification de demande de recherche.
   254 	if($('#notify_search').length > 0)
   269 	if($('#notify_search').length > 0)
   255 	{
   270 	{
   256 		$('.notifications').remove();
   271 		this.removeNotifications();
   257 	}
   272 	}
   258 	
   273 	
   259 	var _this = this;
   274 	var _this = this;
   260 	
   275 	
   261 	//On spécifie les notifications en div.
   276 	//On spécifie les notifications en div.
  1059 /*
  1074 /*
  1060  * Affichage de la notification de résultat dans une vidéo de recherche.
  1075  * Affichage de la notification de résultat dans une vidéo de recherche.
  1061 */
  1076 */
  1062 mosaic.prototype.searchGesture = function(gestureName, mode)
  1077 mosaic.prototype.searchGesture = function(gestureName, mode)
  1063 {
  1078 {
  1064 	if(this.currentMode != 'SEARCH' || !this.isCurrentlyInASearchByGesture)
  1079 	console.log('NOTIFY GESTURE ' + this.currentMode + ' ' + this.centerId + ' ' + this.currentSearchGesture[this.centerId]);
  1065 	{
  1080 	if(this.currentMode != 'SEARCH' || this.currentSearchGesture[this.centerId] == '')
  1066 		return;
  1081 	{
  1067 	}
  1082 		return;
  1068 	
  1083 	}
       
  1084 	console.log('NOTIFY GESTURE');
  1069 	var _this = this;
  1085 	var _this = this;
  1070 	
  1086 	
  1071 	//On spécifie les notifications en div.
  1087 	//On spécifie les notifications en div.
  1072 	var notification_search_1gesture = "<div id='notify_search_1gesture' class='notifications'></div>";
  1088 	var notification_search_1gesture = "<div id='notify_search_1gesture' class='notifications'></div>";
  1073 	
  1089 	
  1079 	//On calcule leurs coordonnées et dimensions.
  1095 	//On calcule leurs coordonnées et dimensions.
  1080 	var notify_width = $('.notifications').width(), notify_height = $('.notifications').height();
  1096 	var notify_width = $('.notifications').width(), notify_height = $('.notifications').height();
  1081 	var notify_margin = parseInt($('.notifications').css('margin'));
  1097 	var notify_margin = parseInt($('.notifications').css('margin'));
  1082 	var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin;
  1098 	var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin;
  1083 	
  1099 	
       
  1100 	// console.log('SHOW GESTURE NOTIFICATION 1');
  1084 	if(_.include(this.gestures, gestureName))
  1101 	if(_.include(this.gestures, gestureName))
  1085 	{
  1102 	{
       
  1103 		// console.log('SHOW GESTURE NOTIFICATION 2');
  1086 		$('#notify_search_1gesture').css('background-image', 'url("./pictos/big/' + (this.mouseInteractions ? 'MI/' : '') + mode + '/' + gestureName + '.png")');
  1104 		$('#notify_search_1gesture').css('background-image', 'url("./pictos/big/' + (this.mouseInteractions ? 'MI/' : '') + mode + '/' + gestureName + '.png")');
  1087 	}
  1105 	}
  1088 	else if(mode == 'none')
  1106 	else if(mode == 'none')
  1089 	{
  1107 	{
  1090 		$('#notify_search_1gesture').css('background-image', 'url("./pictos/big/normal/inconnu.png")');
  1108 		$('#notify_search_1gesture').css('background-image', 'url("./pictos/big/normal/inconnu.png")');
  1424 	$('.notifications').css(
  1442 	$('.notifications').css(
  1425 	{
  1443 	{
  1426 		opacity: "0.9"
  1444 		opacity: "0.9"
  1427 	});
  1445 	});
  1428 }
  1446 }
       
  1447 
       
  1448 /*
       
  1449  * Efface les notifications.
       
  1450 */
       
  1451 mosaic.prototype.removeNotifications = function()
       
  1452 {
       
  1453 	// console.trace();
       
  1454 	$('.notifications').remove();
       
  1455 }