1 | <%@ page import="com.ether.WebHelper" %> |
---|
2 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> |
---|
3 | |
---|
4 | <script type="text/javascript"> |
---|
5 | |
---|
6 | var InterfaceStatistics = Class.create( { |
---|
7 | initialize: function() |
---|
8 | { |
---|
9 | /** *********** CONTAINERS *********** **/ |
---|
10 | this.parent = $( "#containerMiddle" ); |
---|
11 | this.containerMenu = $( "#menuCircle" ); |
---|
12 | |
---|
13 | /** *********** VARIABLES *********** **/ |
---|
14 | this.language = '<spring:message code="language"/>'; |
---|
15 | this.webmaster = "<%=WebHelper.getProperty(request, "mail.webmaster")%>"; |
---|
16 | this.projectsPath = "resources/images/"; |
---|
17 | this.projectsArray = [ |
---|
18 | {id:"logo_Ether_50", img:"logo_Ether_50.jpg", top:"-16px", left:"125px"}, |
---|
19 | {id:"logo_Ndacc_50", img:"logo_Ndacc_50.jpg", top:"1.66667px", left:"46.3334px"}, |
---|
20 | {id:"logo_ECCAD_50", img:"logo_ECCAD_50.gif", top:"39.3333px", left:"109.333px"}, |
---|
21 | {id:"logo_iasi_50", img:"logo_iasi_50.jpg", top:"-78.6667px", left:"77.6666px"}, |
---|
22 | {id:"logo_gosat_50", img:"logo_gosat_50.jpg", top:"-0.333328px", left:"200.667px"}, |
---|
23 | {id:"logo_Iagos_50", img:"logo_Iagos_50.jpg", top:"36px", left:"138px"}, |
---|
24 | {id:"logo_tropico_50", img:"logo_tropico_50.jpg", top:"-74px", left:"45px"}, |
---|
25 | {id:"logo_Megapoli_50", img:"logo_Megapoli_50.png", top:"-74.3333px", left:"15.3333px"}, |
---|
26 | {id:"logo_mimosa_50", img:"logo_mimosa_50.png", top:"-45.6667px", left:"76.3334px"}, |
---|
27 | {id:"logo_reprobus_50", img:"logo_reprobus_50.png", top:"-48px", left:"161.667px"}, |
---|
28 | {id:"logo_geisa_50", img:"logo_geisa_50.jpg", top:"22px", left:"167.667px"}, |
---|
29 | {id:"logo_tapas_50", img:"logo_tapas_50.png", top:"58.3333px", left:"125px"}, |
---|
30 | {id:"logo_acomida_50", img:"logo_acomida_50.jpg", top:"-77.3333px", left:"225px"}, |
---|
31 | {id:"logo_omer7A_50", img:"logo_omer7A_50.jpg", top:"22.6667px", left:"76.3334px"}, |
---|
32 | {id:"logo_girafe_50", img:"logo_girafe_50.JPG", top:"-79.6667px", left:"192.333px"}, |
---|
33 | {id:"logo_arletty_50", img:"logo_arletty_50.jpg", top:"-79px", left:"161.667px"} |
---|
34 | ] |
---|
35 | |
---|
36 | this.bindButtons(); |
---|
37 | this.createDivs(); |
---|
38 | this.animateMenuCircle(); |
---|
39 | $( ".containerToDrag" ).draggable(); |
---|
40 | }, |
---|
41 | |
---|
42 | |
---|
43 | // CREATES AND BINDS ******************************************************** |
---|
44 | bindButtons: function() |
---|
45 | { |
---|
46 | $( "#home_button" ).bind( "dblclick", this.onClickHome ); |
---|
47 | $( "#language_button" ).bind( "dblclick", jQuery.proxy( this.onClickLanguage, this ) ); |
---|
48 | $( "#mail_button" ).bind( "dblclick", this.onClickMail ); |
---|
49 | $( "#login_button" ).bind( "dblclick", jQuery.proxy( this.onClickLogin, this ) ); |
---|
50 | }, |
---|
51 | |
---|
52 | createDivs: function() |
---|
53 | { |
---|
54 | var div1 = this.createDiv( "div1", "150", "200", "140", "53", "Main statistics", "div1" ); |
---|
55 | this.parent.append( div1 ); |
---|
56 | var div2 = this.createDiv( "div2", "430", "430", "140", "230", "MEGAPOLI Statistics", "div2" ); |
---|
57 | this.parent.append( div2 ); |
---|
58 | var div3 = this.createDiv( "div3", "200", "300", "180", "700", "TAPAS Statistics", "div3" ); |
---|
59 | this.parent.append( div3 ); |
---|
60 | var div4 = this.createDiv( "div4", "150", "200", "370", "53", "Hop hop hop", "div4" ); |
---|
61 | this.parent.append( div4 ); |
---|
62 | }, |
---|
63 | |
---|
64 | createDiv: function( id, width, height, top, left, title, content ) |
---|
65 | { |
---|
66 | var divContainer = $( document.createElement( "div" ) ); |
---|
67 | divContainer.addClass( "containerStatistics containerToDrag" ); |
---|
68 | divContainer.attr( {id:id, style:"width:" + width + "px; height:" + height + "px; top:" + top + "px; left:" + left + "px"} ); |
---|
69 | var divTitle = $( document.createElement( "div" ) ); |
---|
70 | divTitle.addClass( "containerStatisticsTitle" ); |
---|
71 | divTitle.html( title ); |
---|
72 | divTitle.attr( {style:"width:" + (width - 7) + "px"} ); |
---|
73 | divContainer.append( divTitle ); |
---|
74 | var divContent = $( document.createElement( "div" ) ); |
---|
75 | divContent.addClass( "containerStatisticsContent" ); |
---|
76 | divContent.html( content ); |
---|
77 | divContainer.append( divContent ); |
---|
78 | return divContainer; |
---|
79 | }, |
---|
80 | |
---|
81 | createCircleMenuOld: function() |
---|
82 | { |
---|
83 | var menuSize = this.containerMenu.width(); |
---|
84 | var nbLogosForSize = (this.projectsArray.length / 2) + 1; |
---|
85 | var divLogoSize = menuSize / nbLogosForSize; |
---|
86 | var logoSize = divLogoSize - 5; |
---|
87 | var stepLeft = 0; |
---|
88 | var stepTop = this.createTopLevels( nbLogosForSize - 1 ); |
---|
89 | for( var i = 0; i < this.projectsArray.length; i++ ) |
---|
90 | { |
---|
91 | var left = stepLeft * divLogoSize; |
---|
92 | var top = menuSize / 2 - stepTop[stepLeft] * divLogoSize; |
---|
93 | var divLogo = $( document.createElement( "div" ) ); |
---|
94 | divLogo.html( '<img id="img_' + this.projectsArray[i] + '"src="' + this.projectsPath + '' + this.projectsArray[i] + '" width="' + logoSize + 'px" height="' + logoSize + 'px"/>' ); |
---|
95 | divLogo.addClass( "divLogo containerToDrag" ); |
---|
96 | divLogo.attr( {id:this.projectsArray[i], style:"position:absolute; top:" + top + "px; left:" + left + "px"} ); |
---|
97 | this.containerMenu.append( divLogo ); |
---|
98 | |
---|
99 | if( 0 != i && (this.projectsArray.length - 1) != i ) |
---|
100 | { |
---|
101 | top = menuSize / 2 + stepTop[stepLeft] * divLogoSize; |
---|
102 | i++; |
---|
103 | var divLogo2 = $( document.createElement( "div" ) ); |
---|
104 | divLogo2.html( '<img id="img_' + this.projectsArray[i] + '"src="' + this.projectsPath + '' + this.projectsArray[i] + '" width="' + logoSize + 'px" height="' + logoSize + 'px"/>' ); |
---|
105 | divLogo2.addClass( "divLogo containerToDrag" ); |
---|
106 | divLogo2.attr( {id:this.projectsArray[i], style:"position:absolute; top:" + top + "px; left:" + left + "px"} ); |
---|
107 | this.containerMenu.append( divLogo2 ); |
---|
108 | } |
---|
109 | stepLeft++; |
---|
110 | } |
---|
111 | |
---|
112 | // $( ".divLogo" ).hover( function() |
---|
113 | // { |
---|
114 | // $( this )[0].firstChild.width = "50px"; |
---|
115 | // $( "#img_logo_mimosa_50.png" ).animate( { |
---|
116 | // opacity: 1, |
---|
117 | // width:'50px' |
---|
118 | // }, 5000, function() |
---|
119 | // { |
---|
120 | // } ); |
---|
121 | |
---|
122 | // $("#img_logo_mimosa_50.png").stop(false, false).animate({width:'50px'}, 600); |
---|
123 | // $( "#img_" + $( this )[0].id ).width( "50px" ); |
---|
124 | // } ); |
---|
125 | }, |
---|
126 | |
---|
127 | createTopLevels: function( nb ) |
---|
128 | { |
---|
129 | var topLevels = []; |
---|
130 | var level = 0; |
---|
131 | for( var i = 0; i <= (nb / 2); i++ ) |
---|
132 | { |
---|
133 | topLevels[i] = level; |
---|
134 | topLevels[nb - i] = level; |
---|
135 | level++; |
---|
136 | } |
---|
137 | return topLevels; |
---|
138 | }, |
---|
139 | |
---|
140 | // REQUESTS ******************************************************** |
---|
141 | requestChangeLocale: function() |
---|
142 | { |
---|
143 | $.ajax( { |
---|
144 | url: "project?methodName=setLocale&language=<spring:message code="label.language.value.to.switch"/>", |
---|
145 | success:function() |
---|
146 | { |
---|
147 | location.reload(); |
---|
148 | } |
---|
149 | } ); |
---|
150 | }, |
---|
151 | |
---|
152 | // HANDLES ******************************************************** = retours ajax |
---|
153 | handleCreateXML: function( result ) |
---|
154 | { |
---|
155 | this.loadingRequest.hide(); |
---|
156 | //this.loadingRequest.display(); |
---|
157 | |
---|
158 | var res = jQuery.parseJSON( result ).result; |
---|
159 | alert( res ); |
---|
160 | }, |
---|
161 | |
---|
162 | |
---|
163 | // EVENTS ******************************************************** |
---|
164 | onClickHome: function() |
---|
165 | { |
---|
166 | location.reload(); |
---|
167 | }, |
---|
168 | |
---|
169 | onClickLanguage: function() |
---|
170 | { |
---|
171 | this.requestChangeLocale(); |
---|
172 | }, |
---|
173 | |
---|
174 | onClickMail: function() |
---|
175 | { |
---|
176 | document.location.href = "mailto:" + this.webmaster + "?subject=[STATISTICS]"; |
---|
177 | }, |
---|
178 | |
---|
179 | onClickLogin: function() |
---|
180 | { |
---|
181 | if( 88 == $( "#login_bg" ).width() ) |
---|
182 | this.enlargeLogin(); |
---|
183 | else |
---|
184 | this.reduceLogin(); |
---|
185 | }, |
---|
186 | |
---|
187 | onClickButtonLogin: function() |
---|
188 | { |
---|
189 | // TODO reduce cloud |
---|
190 | |
---|
191 | }, |
---|
192 | |
---|
193 | // OTHERS ******************************************************** |
---|
194 | reduceLogin: function() |
---|
195 | { |
---|
196 | $( "#login_text" ).css( "visibility", "hidden" ); |
---|
197 | $( "#login_bg" ).animate( { |
---|
198 | opacity: 1, |
---|
199 | height:'60px', |
---|
200 | width:'78px' |
---|
201 | }, 5000, function() |
---|
202 | { |
---|
203 | } ); |
---|
204 | |
---|
205 | $( "#login_button" ).animate( { |
---|
206 | top:'16px', |
---|
207 | left: '20px' |
---|
208 | }, 5000, function() |
---|
209 | { |
---|
210 | } ); |
---|
211 | }, |
---|
212 | |
---|
213 | enlargeLogin: function() |
---|
214 | { |
---|
215 | $( "#login_bg" ).animate( { |
---|
216 | opacity: 0.45, |
---|
217 | height:'500px', |
---|
218 | width:'500px' |
---|
219 | }, 2000, function() |
---|
220 | { |
---|
221 | $( "#login_text" ).css( "visibility", "visible" ); |
---|
222 | } ); |
---|
223 | |
---|
224 | $( "#login_button" ).animate( { |
---|
225 | top:'82px', |
---|
226 | left: '155px' |
---|
227 | }, 2000, function() |
---|
228 | { |
---|
229 | } ); |
---|
230 | }, |
---|
231 | |
---|
232 | animateMenuCircle: function() |
---|
233 | { |
---|
234 | var menuSize = this.containerMenu.width(); |
---|
235 | var nbLogosForSize = (this.projectsArray.length / 2) + 1; |
---|
236 | var divLogoSize = menuSize / nbLogosForSize; |
---|
237 | var logoSize = divLogoSize - 5; |
---|
238 | |
---|
239 | var initTop = this.projectsArray[0].top; |
---|
240 | var initLeft = this.projectsArray[0].left; |
---|
241 | |
---|
242 | jQuery.each( this.projectsArray, jQuery.proxy( function( i, logo ) |
---|
243 | { |
---|
244 | var divLogo = $( document.createElement( "div" ) ); |
---|
245 | divLogo.addClass( "divLogo containerToDrag" ); |
---|
246 | divLogo.attr( {id:logo.id, style:"position:absolute; top:" + initTop + "; left:" + initLeft} ); |
---|
247 | divLogo.html( '<img id="img_' + logo.id + '"src="' + this.projectsPath + '' + logo.img + '" width="' + logoSize + 'px" height="' + logoSize + 'px"/>' ); |
---|
248 | $( "#menuCircle" ).append( divLogo ); |
---|
249 | }, this ) ); |
---|
250 | |
---|
251 | jQuery.each( this.projectsArray, jQuery.proxy( function( i, logo ) |
---|
252 | { |
---|
253 | $( "#" + logo.id ).animate( { |
---|
254 | top:logo.top, |
---|
255 | left:logo.left |
---|
256 | }, 5000, function() |
---|
257 | { |
---|
258 | } ); |
---|
259 | }, this ) ); |
---|
260 | } |
---|
261 | } ); |
---|
262 | |
---|
263 | </script> |
---|