Changeset 667 for ether_statistics/web/project/statistics-script.jsp
- Timestamp:
- 11/15/12 11:01:02 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_statistics/web/project/statistics-script.jsp
r663 r667 9 9 /** *********** CONTAINERS *********** **/ 10 10 this.parent = $( "#containerMiddle" ); 11 this.containerMenu = $( "#menu Circle" );11 this.containerMenu = $( "#menuLogo" ); 12 12 this.containerErrors = $( "#errors" ); 13 13 … … 15 15 this.language = '<spring:message code="language"/>'; 16 16 this.webmaster = "<%=WebHelper.getProperty(request, "mail.webmaster")%>"; 17 this.projectsPath = "resources/images/"; 17 this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false; 18 this.logoSizeSmall = 30; 19 this.logoSizeBig = 50; 20 18 21 this.projectsArray = [ 19 22 {id:"ETHER", img:"logo_Ether_50.jpg", top:"-16px", left:"125px"}, … … 34 37 {id:"ARLETTY", img:"logo_arletty_50.jpg", top:"-79px", left:"161.667px"} 35 38 ]; 36 this.widthInitLogin = $( "#login_bg" ).width();37 39 this.widthInitMentionsOrCredits = $( "#mentions" ).width(); 38 40 … … 40 42 this.yArray = [0, 10, 30, 50, 100]; 41 43 42 43 44 this.bindButtons(); 44 this.createDraggableSlides(); 45 this.createMenuCircle(); 45 this.createMenuLogo(); 46 46 47 47 $( document ).ready( jQuery.proxy( function() … … 49 49 $( ".containerToDrag" ).draggable(); 50 50 // Menu 51 this.animateMenuCircle(); 52 this.bindMenuCircle(); 53 // Slides 54 // this.onClickHelp(); 55 this.selectedLogo = $( "#ETHER" )[0]; 56 this.isSelectedLogoEther = true; 57 this.onClickLogo(); 58 59 this.changeRightSlide(); 51 this.animateMenuLogos(); 52 this.bindMenuLogos(); 53 this.createRightSlide(); 54 55 if( !this.jSONUser ) 56 this.onClickHelp(); 57 else 58 this.handleLogin(); 60 59 }, this ) ); 61 60 }, … … 67 66 $( "#home_button" ).bind( "dblclick", this.onClickHome ); 68 67 $( "#language_button" ).bind( "dblclick", jQuery.proxy( this.onClickLanguage, this ) ); 69 $( "#mail_button" ).bind( "dblclick", this.onClickMail ); 70 $( "#login_button" ).bind( "dblclick", jQuery.proxy( this.onClickLogin, this ) ); 68 $( "#mail_button" ).bind( "dblclick", jQuery.proxy( this.onClickMail, this ) ); 71 69 $( "#help" ).bind( "click", jQuery.proxy( this.onClickHelp, this ) ); 72 70 $( "#credits" ).bind( "dblclick", jQuery.proxy( this.onClickCredits, this ) ); 73 71 $( "#mentions" ).bind( "dblclick", jQuery.proxy( this.onClickMentions, this ) ); 74 }, 75 76 createMenuCircle: function() 77 { 78 var menuSize = this.containerMenu.width(); 79 var nbLogosForSize = (this.projectsArray.length / 2) + 1; 80 var divLogoSize = menuSize / nbLogosForSize; 81 this.logoSize = divLogoSize - 5; 82 72 $( "#login_button" ).bind( "click", jQuery.proxy( this.onClickLogin, this ) ); 73 $( "#logout_button" ).bind( "dblclick", jQuery.proxy( this.onClickLogout, this ) ); 74 }, 75 76 createMenuLogo: function() 77 { 83 78 var initTop = this.projectsArray[0].top; 84 79 var initLeft = this.projectsArray[0].left; … … 89 84 divLogo.addClass( "divLogo containerToDrag" ); 90 85 divLogo.attr( {id:logo.id, style:"position:absolute; top:" + initTop + "; left:" + initLeft} ); 91 divLogo.html( '<img id="img_' + logo.id + '"src=" ' + this.projectsPath + '' + logo.img + '" width="' + this.logoSize + 'px" height="' + this.logoSize+ 'px"/>' );92 $( "#menuCircle" ).append( divLogo );86 divLogo.html( '<img id="img_' + logo.id + '"src="resources/images/' + logo.img + '" width="' + this.logoSizeSmall + 'px" height="' + this.logoSizeSmall + 'px"/>' ); 87 this.containerMenu.append( divLogo ); 93 88 }, this ) ); 94 89 }, 95 90 96 create DraggableSlides: function()91 createAllSlides: function() 97 92 { 98 93 this.leftTopSlide = new DragSlide( {id:"leftTop", parent:this.parent, width:"170", height:"200", top:"140px", left:"53px", … … 110 105 specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 111 106 112 this.rightSlide = new DragSlide( {id:"right", parent:this.parent, width:"200", height:"300", top:"180px", left:"698px", 107 this.rightSlide = new DragSlide( {id:"right", parent:this.parent, width:"200", height:"270", top:"210px", left:"698px", 108 specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 109 110 this.rightLoginSlide = new DragSlide( {id:"loginRight", parent:this.parent, width:"200", height:"25", top:"170px", left:"697px", 111 specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 112 }, 113 114 createRightSlide: function() 115 { 116 this.rightSlide = new DragSlide( {id:"right", parent:this.parent, width:"200", height:"270", top:"210px", left:"698px", 113 117 specificClass:"containerStatistics", specificTitleClass:"containerStatisticsTitle", specificContentClass:"containerStatisticsContent"} ); 114 118 }, … … 122 126 { 123 127 location.reload(); 124 } 128 }, 129 error: jQuery.proxy( this.showErrors, [this] ) 130 } ); 131 }, 132 133 requestLogin: function() 134 { 135 var login = $( "#loginValue" ).val(); 136 var pwd = $( "#pwdValue" ).val(); 137 $.ajax( { 138 url: "project?methodName=login&login=" + login + "&pwd=" + pwd, 139 dataType: 'json', // Info needed since jquery.1.7 !! 140 success:jQuery.proxy( this.handleLogin, this ), 141 error: jQuery.proxy( this.showErrors, [this, "489px", "566px"] ) 142 } ); 143 }, 144 145 requestLogout: function() 146 { 147 $.ajax( { 148 url: "project?methodName=logout", 149 dataType: 'json', // Info needed since jquery.1.7 !! 150 success:jQuery.proxy( this.handleLogout, this ), 151 error: jQuery.proxy( this.showErrors, [this] ) 125 152 } ); 126 153 }, … … 134 161 url: "statistic?methodName=searchMainStatisticsByProject&name=" + this.selectedLogo.id, 135 162 success:jQuery.proxy( this.handleDataByLogo, this ), 136 error: jQuery.proxy( this.show Errors, [this])137 } ); 138 }, 139 140 // HANDLES ******************************************************** = retours ajax163 error: jQuery.proxy( this.showLoginError, this ) 164 } ); 165 }, 166 167 // HANDLES ******************************************************** 141 168 handleDataByLogo: function( result ) 142 169 { … … 147 174 }, 148 175 176 handleLogin: function( result ) 177 { 178 this.containerErrors.empty(); 179 this.containerErrors.css( "visibility", "hidden" ); 180 181 if( result ) 182 this.jSONUser = result.jSONUser; 183 184 $( "#loginValue" ).empty(); 185 $( "#pwdValue" ).empty(); 186 $( "#login_text" ).css( "visibility", "hidden" ); 187 $( "#login" ).animate( { 188 top:'47px', 189 left:'126px' 190 }, 2000, function() 191 { 192 } ); 193 194 $( "#login_bg" ).animate( { 195 opacity: 1, 196 height:'60px', 197 width:'67px' 198 }, 2000, function() 199 { 200 } ); 201 202 $( "#login_img" ).animate( { 203 top:'25px', 204 left: '16px', 205 width: '0', 206 height: '0' 207 }, 2000, jQuery.proxy( function() 208 { 209 // Slides 210 this.parent.empty(); 211 this.createAllSlides(); 212 this.changeRightSlide(); 213 214 // User 215 if( this.jSONUser.name ) 216 this.rightLoginSlide.setTitle( this.jSONUser.name ); 217 else 218 this.rightLoginSlide.setTitle( '<spring:message code="label.unknown"/>' ); 219 $( "#logout_button" ).css( "visibility", "visible" ); 220 221 // Logo 222 this.selectedLogo = $( "#ETHER" )[0]; 223 this.isSelectedLogoEther = true; 224 this.onClickLogo(); 225 }, this ) ); 226 }, 227 228 handleLogout: function() 229 { 230 this.jSONUser = false; 231 this.parent.empty(); 232 this.createRightSlide(); 233 this.onClickHelp(); 234 235 $( "#logout_button" ).css( "visibility", "hidden" ); 236 $( "#login" ).css( { zIndex:1 } ).animate( { 237 top:'79px', 238 left:'88px' 239 }, 2000, function() 240 { 241 } ); 242 243 $( "#login_bg" ).animate( { 244 opacity: 0.85, 245 height:'500px', 246 width:'500px' 247 }, 2000, function() 248 { 249 $( "#login_text" ).css( "visibility", "visible" ); 250 } ); 251 252 $( "#login_img" ).animate( { 253 top:'103px', 254 left: '148px', 255 width: '30px', 256 height: '30px' 257 }, 2000, function() 258 { 259 } ); 260 }, 261 149 262 // EVENTS ******************************************************** 150 263 onClickHome: function() … … 161 274 { 162 275 document.location.href = "mailto:" + this.webmaster + "?subject=[STATISTICS]"; 163 },164 165 onClickLogin: function()166 {167 if( this.widthInitLogin == $( "#login_bg" ).width() )168 this.enlargeLogin();169 else170 this.reduceLogin();171 276 }, 172 277 … … 191 296 this.rightSlide.setTitle( '<spring:message code="label.help"/>' ); 192 297 this.rightSlide.setContent( "<spring:message code='label.help.content'/>" ); 193 var backHelpButton = new Button( {value:"<spring:message code="label.display.actions"/>", parent:this.rightSlide.getDivContent(), className: "small positive back_button", onClick:jQuery.proxy( this.changeRightSlide, this )} ); 194 }, 195 196 onClickButtonLogin: function() 197 { 198 // TODO reduce cloud 199 298 if( this.jSONUser ) 299 var backHelpButton = new Button( {value:"<spring:message code="label.display.actions"/>", parent:this.rightSlide.getDivContent(), className: "small positive back_button", onClick:jQuery.proxy( this.changeRightSlide, this )} ); 300 }, 301 302 onClickLogin: function() 303 { 304 this.containerErrors.empty(); 305 this.containerErrors.css( "visibility", "hidden" ); 306 this.requestLogin(); 307 }, 308 309 onClickLogout: function() 310 { 311 this.requestLogout(); 200 312 }, 201 313 … … 203 315 { 204 316 this.isSelectedLogoEther = (this.selectedLogo == $( "#ETHER" )[0]); 205 this.requestDataByLogo(); 317 318 if( this.jSONUser ) 319 this.requestDataByLogo(); 320 else 321 { 322 this.showErrors( "<spring:message code="error.connection.need"/>" ); 323 this.containerErrors.css( {top:"489px", left:"566px"} ); 324 this.containerErrors.css( "visibility", "visible" ); 325 } 206 326 }, 207 327 … … 221 341 { 222 342 var context = this[0] ? this[0] : this; 223 var text = this[1]; 343 var topValue = this[1] ? this[1] : false; 344 var leftValue = this[2] ? this[2] : false; 224 345 context.containerErrors.show(); 225 // if( text ) 226 // context.containerErrors.html( interfaceTexts[result.responseText] + " " + text ); 227 // else if( interfaceTexts[result.responseText] ) 228 // context.containerErrors.html( interfaceTexts[result.responseText] ); 229 if( result.responseText ) 346 if( result.responseText && interfaceTexts[result.responseText] ) 347 context.containerErrors.html( interfaceTexts[result.responseText] ); 348 else if( result.responseText ) 230 349 context.containerErrors.html( result.responseText ); 231 350 else 232 351 context.containerErrors.html( result ); 233 }, 234 235 reduceLogin: function() 236 { 237 $( "#login" ).css( { zIndex:0 } ); 238 $( "#login_text" ).css( "visibility", "hidden" ); 239 $( "#login_bg" ).animate( { 240 opacity: 1, 241 height:'60px', 242 width:'78px', 243 zIndex:'0' 244 }, 2000, function() 245 { 246 } ); 247 248 $( "#login_button" ).animate( { 249 top:'16px', 250 left: '20px' 251 }, 2000, function() 252 { 253 } ); 254 }, 255 256 enlargeLogin: function() 257 { 258 $( "#login" ).css( { zIndex:1 } ); 259 $( "#login_bg" ).animate( { 260 opacity: 0.45, 261 height:'500px', 262 width:'500px' 263 }, 2000, function() 264 { 265 $( "#login_text" ).css( "visibility", "visible" ); 266 } ); 267 268 $( "#login_button" ).animate( { 269 top:'82px', 270 left: '155px' 271 }, 2000, function() 272 { 273 } ); 352 if( topValue && leftValue ) 353 context.containerErrors.css( {top: topValue, left: leftValue} ); 354 context.containerErrors.css( "visibility", "visible" ); 355 }, 356 357 showLoginError: function( result ) 358 { 359 this.onClickLogout(); 360 this.onClickLogo(); 274 361 }, 275 362 … … 287 374 opacity: 1, 288 375 height:'42px', 289 width: '59px',376 width:this.widthInitMentionsOrCredits + 'px', 290 377 zIndex:'0' 291 378 }, 2000, function() … … 317 404 }, 318 405 319 animateMenu Circle: function()406 animateMenuLogos: function() 320 407 { 321 408 jQuery.each( this.projectsArray, jQuery.proxy( function( i, logo ) … … 330 417 }, 331 418 332 bindMenuCircle: function() 333 { 419 bindMenuLogos: function() 420 { 421 var gap = (this.logoSizeBig - this.logoSizeSmall) / 2; 422 var logoSizeBig = this.logoSizeBig + "px"; 423 var logoSizeSmall = this.logoSizeSmall + "px"; 334 424 var gridimage; 335 $( '.divLogo' ).mouseover( 336 function() 337 { 338 gridimage = $( this ).find( 'img' ); //Define target as a variable 339 gridimage.stop().animate( {width: 50, height:50}, 150 ); 340 } ).mouseout( 341 jQuery.proxy( function( element ) 342 { 343 this.selectedLogo = element.currentTarget; 344 gridimage.stop().animate( {width: this.logoSize, height:this.logoSize}, 150 ); 345 }, this ) ).dblclick( 346 jQuery.proxy( function() 347 { 348 this.onClickLogo(); 349 }, this ) ); 425 426 $( '.divLogo' ).mouseover( function( element ) 427 { 428 gridimage = $( this ).find( 'img' ); //Define target as a variable 429 gridimage.stop().animate( { 430 width: logoSizeBig, 431 height: logoSizeBig 432 }, 150 ); 433 $( this ).animate( { 434 top: "-=10px", 435 left: "-=10px" 436 }, 150 ); 437 } ); 438 439 $( '.divLogo' ).mouseout( function( element ) 440 { 441 $( this ).animate( { 442 top: "+=10px", 443 left: "+=10px" 444 }, 150 ); 445 gridimage.stop().animate( { 446 width: logoSizeSmall, 447 height:logoSizeSmall 448 }, 150 ); 449 } ); 450 451 $( '.divLogo' ).dblclick( jQuery.proxy( function( element ) 452 { 453 this.selectedLogo = element.currentTarget; 454 this.onClickLogo(); 455 }, this ) ); 350 456 }, 351 457 … … 379 485 new Button( {value:"<spring:message code="statistics.data.download"/>", parent:this.rightSlide.getDivContent(), className: "positive action_button", onClick:jQuery.proxy( this.displayDownloadEvolution, this )} ); 380 486 new Button( {value:"<spring:message code="statistics.map.distribution"/>", parent:this.rightSlide.getDivContent(), className: "positive action_button", onClick:jQuery.proxy( this.displayMapDistribution, this )} ); 381 new Button( {value:"<spring:message code="label. export"/>", parent:this.rightSlide.getDivContent(), className: "blue export_button print-preview", onClick:jQuery.proxy( this.onClickPrint, this )} );487 new Button( {value:"<spring:message code="label.print"/>", parent:this.rightSlide.getDivContent(), className: "blue export_button print-preview", onClick:jQuery.proxy( this.onClickPrint, this )} ); 382 488 }, 383 489 … … 547 653 this.changeMiddleSlideForMap(); 548 654 } 655 549 656 } ); 550 657
Note: See TracChangeset
for help on using the changeset viewer.