Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 208 | Rev 212 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
143 delphine 1
<h1>Fiche</h1>
201 gduche 2
<style>
3
	#zone_contenu_fiche {
203 gduche 4
		border:solid 1px #DDD;
5
		border-width:0px 1px 1px 1px;
201 gduche 6
		width:100%;
7
		min-height:400px;
203 gduche 8
		clear:left;
9
 
201 gduche 10
	}
11
 
12
	.module {margin: 0 1em 1em 0;}
13
	.module .titre{ margin: 0.3em; padding-bottom: 4px; padding-left: 0.2em; cursor:pointer;}
14
	.module .titre .ui-icon { float: right; }
15
	.module .contenu { padding: 0.4em; }
16
 
17
	.colonne {float:left; padding-bottom:100px; width:30%}
18
 
19
	.ui-sortable-placeholder { border: 1px dotted black; visibility: visible !important; height: 50px !important; }
20
	.ui-sortable-placeholder * { visibility: hidden; }
21
 
22
	#zone_onglets ul li {list-style:none}
23
	.lienToggle {cursor:pointer}
24
 
25
 
26
	#dialog label, #dialog input { display:block; }
27
	#dialog label { margin-top: 0.5em; }
28
	#dialog input, #dialog textarea { width: 95%; }
211 aurelien 29
	#zone_onglets { margin-top: 1em; padding-right: 5px; border-width: 1px 1px 0 1px; border-radius:0; width:99%; font-size:12px}
203 gduche 30
	#zone_onglets li {float:left}
201 gduche 31
	#zone_onglets li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
211 aurelien 32
	#zone_onglets #ongletEtPlus { cursor: pointer; float:right;}
33
 
34
	.elementMenuModules {
35
		display:block;
36
		border: 1px solid black;
37
		width: 150px;
38
		padding: 10px 10px 10px 25px;
39
		margin:0px;
40
		cursor: pointer;
41
	}
42
 
43
	.elementMenuModules:hover {
44
		background-color: grey;
45
	}
46
	.menuModules {left: 73%; position: absolute; border: 1px solid grey; margin: 0px; padding: 0px}
201 gduche 47
</style>
48
 
203 gduche 49
<div id="zone_onglets" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
50
	<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
51
		<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#fiche">Accueil</a></li>
52
		<li class="ui-state-default ui-corner-top"><a href="#fiche">Illustrations</a></li>
53
		<li class="ui-state-default ui-corner-top"><a href="#fiche">Répartition</a></li>
54
		<li class="ui-state-default ui-corner-top"><a href="#fiche">Wiki</a></li>
211 aurelien 55
		<li id="ongletEtPlus" class="ui-state-default ui-corner-top"><a href="#fiche">+</a></li>
203 gduche 56
	</ul>
211 aurelien 57
	<span id="conteneurMenuOnglets"></span>
203 gduche 58
</div>
59
 
201 gduche 60
<div id="zone_contenu_fiche">
203 gduche 61
	<div class="colonne">
62
		<div id="illustrations" class="module ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
63
			<h3 class="titre ui-widget-header ui-corner-all" id="titre-0">Illustrations</h3>
64
			<span id="contenu-0" class="contenu">contenu-0</span>
65
		</div>
66
 
67
		<div id="repartition" class="module ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
68
			<h3 class="titre ui-widget-header ui-corner-all" id="titre-0">Répartition</h3>
69
			<span id="contenu-0" class="contenu">contenu-0</span>
70
		</div>
71
 
72
		<div id="wiki" class="module ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
73
			<h3 class="titre ui-widget-header ui-corner-all" id="titre-0">Wiki<span class="lienToggle"></span></h3>
74
			<span id="contenu-0" class="contenu">contenu-0</span>
75
		</div>
76
 
77
 
78
	</div>
201 gduche 79
	<div class="colonne"></div>
80
	<div class="colonne"></div>
81
 
82
	<br style="clear:left" />
83
</div>
84
 
85
<script type="text/Javascript">
86
	var modules = Array();
211 aurelien 87
	var ongletsOuverts = Array();
201 gduche 88
 
89
	/** Classe Module
90
	* Définit un module de type portlet
91
	**/
203 gduche 92
	function Module(id, module, onglet, statique) {
201 gduche 93
 
94
		// Variables de classe : identifiant, titre, et le HTML du résumé à afficher dans le contenu
95
		this.id = id;
203 gduche 96
		this.titre;
97
		this.htmlResume;
201 gduche 98
		this.statique = statique;
99
 
100
		// Les objets Portlet et Onglet que l'ont garde en mémoire pour pouvoir y accéder facilement
203 gduche 101
		this.portlet = module;
201 gduche 102
		this.onglet;
103
 
104
		// creerPortlet
105
		// Créer l'objet Portlet HTML à afficher et le stocker dans les variables de classe
106
		this.creerPortlet = function() {
107
			var objet = this;
108
 
203 gduche 109
			var titre = $(module).children('.titre');
201 gduche 110
			titre.className = 'titre ui-widget-header ui-corner-all';
111
			titre.id = 'titre-' + this.id;
112
 
203 gduche 113
			var contenu = $(module).children('.contenu');
201 gduche 114
			contenu.id = 'contenu-' + this.id;
115
			contenu.className ='contenu';
116
 
117
			var lienToggle = document.createElement('span');
118
			lienToggle.className = 'lienToggle ui-icon ui-icon-minusthick';
203 gduche 119
			$(titre).append(lienToggle);
201 gduche 120
			$(lienToggle).click(function() {
121
				$(contenu).toggle();
208 aurelien 122
				$(this).toggleClass("ui-icon-plusthick");
123
				$(this).toggleClass("ui-icon-minusthick");
124
				$(objet.onglet).toggle();
201 gduche 125
			});
126
 
127
			this.portlet = module;
128
			return module;
129
		}
130
 
131
		// creerOnglet
132
		// Créer l'objet Onglet HTML
133
		this.creerOnglet = function() {
134
			var objet = this;
135
 
203 gduche 136
			var a = $(onglet).find("a");
201 gduche 137
 
138
			// Gestion du clic sur le lien
139
			// Comme les liens sont mis en place par jqueryui tabs, il faut ajouter une surcouche pour
140
			// déplacer vers la page du module
141
			$(a).click(function() {
211 aurelien 142
				// TODO : Changer l'url par celle du module et enregistrer la configuration actuelle des onglets.
201 gduche 143
				//$(location).attr('href',"http://www.google.fr");
144
			});
145
 
146
			if (!statique) {
147
				var span = document.createElement('span');
148
				span.className = "ui-icon ui-icon-close";
149
 
150
				// Gestion de la fermeture de l'onglet
151
				$(span).live( "click", function() {
152
					$(span).parent().toggle();
208 aurelien 153
					$(objet.portlet).find(".lienToggle").toggleClass("ui-icon-plusthick");
154
					$(objet.portlet).find(".lienToggle").toggleClass("ui-icon-minusthick");
201 gduche 155
					$(objet.portlet).find(".contenu").toggle(false);
156
				});
157
 
203 gduche 158
				$(onglet).append(span);
201 gduche 159
			}
160
 
203 gduche 161
			this.onglet = onglet;
201 gduche 162
		}
163
 
164
		// Initialisation de l'objet
165
		this.creerPortlet();
166
		this.creerOnglet();
167
 
168
		// Accesseurs de la classe
169
		this.getOnglet = function() {
170
			return this.onglet;
171
		}
172
 
173
		this.getPortlet = function() {
174
 
175
			return this.portlet;
176
		}
211 aurelien 177
 
178
		// fonctions d'affichage et cachage (je sais pas si on dit ça comme ça) des onglets
179
		this.afficherCacherModule = function() {
180
			$(this.portlet).find(".lienToggle").toggleClass("ui-icon-plusthick");
181
			$(this.portlet).find(".lienToggle").toggleClass("ui-icon-minusthick");
182
			$(this.portlet).find(".contenu").toggle();
183
		}
184
 
201 gduche 185
	}
186
 
211 aurelien 187
	function afficherMenuOnglets() {
188
		if($("#conteneurMenuOnglets").html() != '') {
189
			$("#conteneurMenuOnglets").html('');
190
		} else {
191
			console.log(ongletsOuverts);
192
			var htmlMenu = '<ul class="menuModules">';
193
			for (idOnglet in ongletsOuverts) {
194
				htmlMenu += '<li class="elementMenuModules" rel="'+idOnglet+'" id="menu_module_'+idOnglet+'">'+ongletsOuverts[idOnglet].titre+'</li>';
195
			}
196
			htmlMenu += '</ul>';
197
			$("#conteneurMenuOnglets").html(htmlMenu);
198
			$("#conteneurMenuOnglets").toggle();
199
		}
200
	}
201
 
203 gduche 202
	//Initialisation
201 gduche 203
	$(document).ready(function() {
203 gduche 204
		i = 1;
201 gduche 205
 
203 gduche 206
		//Parcourir la totalité des modules générés et les lier grâce à la classe Module
207
		$(".module").each(function () {
201 gduche 208
			i++;
203 gduche 209
			identifiantOnglet = "#zone_onglets>ul>li:nth-child(" + i +")";
210
			var module = new Module(i, this, $(identifiantOnglet));
211 aurelien 211
			module.titre = $(this).children('h3').text();
212
			ongletsOuverts[identifiantOnglet] = module;
203 gduche 213
		});
201 gduche 214
 
215
		$( ".colonne" ).sortable({
216
			connectWith: ".colonne"
217
		});
218
 
219
		$( ".colonne" ).disableSelection();
220
		$('#zone_onglets').tabs();
211 aurelien 221
		$("#ongletEtPlus").click(function() {
222
			afficherMenuOnglets();
223
		});
224
 
225
		$('.elementMenuModules').live('click', function() {
226
			var idOnglet = $(this).attr('rel');
227
			var objet = ongletsOuverts[idOnglet];
228
			$(idOnglet).toggle();
229
			$(objet.portlet).find(".lienToggle").toggleClass("ui-icon-plusthick");
230
			$(objet.portlet).find(".lienToggle").toggleClass("ui-icon-minusthick");
231
			$(objet.portlet).find(".contenu").toggle();
232
		})
201 gduche 233
	});
234
</script>