Menu

[r2517]: / trunk / Src / Res / Scripts / easteregg.js  Maximize  Restore  History

Download this file

162 lines (149 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 2009-2012, Peter Johnson (www.delphidabbler.com).
*
* $Rev$
* $Date$
*
* JavaScript code used to perform animations in program's easter egg.
* Requires jQuery and lite version of jQuery Cycle plug-in.
*/
// Main function called when DOM has loaded. Runs prelinary animations up to
// when introductory page is shown on unfolded screen
$(document).ready(function(){
var spt = null; // showPrompt timeout
$("#screen-top").click(function(){
// screen top click => open screen
// prevent or stop any prompt animations
if ( spt != null )
clearTimeout(spt);
stopPrompt();
// disable click on screen top: this is a one time only event
$("#screen-top").off();
$("#screen-top").css("cursor", "default");
// unfolds out the screen: moves top and middle elements simultaneously,
// then displays intro page on unfolded screen
$("#screen-middle").animate({top: 48, height: 304}, 2000);
$("#screen-top").animate(
{top: 26},
2000,
'',
function() {
showIntro();
showCancelButton();
}
);
});
//
// show a prompt if user doesn't click anything in specified time
spt = setTimeout(showPrompt, 3500);
});
// Display introductory page on unfloded screen, along with slideshow start
// button.
function showIntro() {
var pulse = 150;
setRollover("#start", "play-btn.png", "play-btn-hover.png");
$("#start").click(function() {
// Start button clicked:
// disable further clicks: this is a one-time action
$("#start").off();
// switch of title text in pop-up window
$("#start").attr("title", "");
$("#start").css("cursor", "default");
// fade out intro text and start slide show
$("#intro").fadeOut(500, slideShow);
});
$("#intro").fadeIn(1200);
}
// Prepare and display cancel button in unfolded screen
function showCancelButton() {
setRollover("#cancel-btn", "cancel-btn.png", "cancel-btn-hover.png");
$("#cancel-btn").click(function() {
// clear events and switch of title (may be popped up)
$(this).off();
$(this).attr("title", "");
// return true to allow event to bubble up to dialogue box to permit it to
// close
return true;
});
$("#cancel-btn").fadeIn(1200);
}
// Runs slide show
function slideShow() {
$("#slideshow").fadeIn(1000).cycle({
fx: "fade",
timeout: 4000,
speed: 2500
});
}
// Runs prompt animation telling user where to click to display content
function showPrompt() {
var text = $("#click-prompt");
var arrow = $("#click-arrow");
var jigHi = 245;
var jigLo = 265;
var jigTime = 150;
// display arrow pointing at screen top and jiggle it, then display promt
// text
arrow.css("top", jigLo);
arrow
.fadeIn(200)
// first jiggle
.animate({top: jigHi}, jigTime)
.animate({top: jigLo}, jigTime)
.animate({top: jigHi}, jigTime)
.animate({top: jigLo}, jigTime)
.animate({top: jigHi}, jigTime)
.animate({top: jigLo}, jigTime)
.animate({top: jigHi}, jigTime)
.animate({top: jigLo}, jigTime)
.delay(1500)
// second jiggle
.animate({top: jigHi}, jigTime)
.animate({top: jigLo}, jigTime)
.animate({top: jigHi}, jigTime)
.animate({top: jigLo}, jigTime)
.animate({top: jigHi}, jigTime)
.animate({top: jigLo}, jigTime)
.animate({top: jigHi}, jigTime)
.animate(
{top: jigLo},
jigTime,
function(){
// show prompt text above arrow
text.css(
"top",
parseInt(arrow.css("top")) - parseInt(text.css("height")) - 6
);
text.delay(1000).fadeIn(1000);
}
);
}
// Stops any running prompt animation and hides related elements
function stopPrompt() {
$("#click-prompt").stop();
$("#click-arrow").stop();
$("#click-prompt").hide();
$("#click-arrow").hide();
// following is required to stop arrow from appearing when screen is
// expanding: don't understand why this happens
$("#click-arrow").css("width", "0");
}
// Sets rollover images for elements matching given CSS selector.
function setRollover(selector, normalImg, hoverImg) {
$(selector).on(
"mouseout",
function () {
$(this).attr("src", normalImg);
}
);
$(selector).on(
"mousemove",
function () {
$(this).attr("src", hoverImg);
}
);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.