-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjohn-cena.js
108 lines (92 loc) · 2.63 KB
/
john-cena.js
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
/*
* John CenaPlugin 1.0
* Copyright 2015, ZDVELOPER (Zedd)
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* Shamelessly Based on the Raptorize Kit
*/
(function ($) {
$.fn.cena = function (options) {
//Yo' defaults
var defaults = {
enterOn: 'click', //timer, konami-code, click
delayTime: 5000 //time before Cena attacks on timer mode
};
//Extend those options
var options = $.extend(defaults, options);
return this.each(function () {
var _this = $(this);
var audioSupported = false;
//Stupid Browser Checking which should be in jQuery Support
if ($.browser.mozilla && $.browser.version.substr(0, 5) >= "1.9.2" || $.browser.webkit) {
audioSupported = true;
}
//Cena Vars
var cenaImageMarkup = '<img id="elCena" style="display: none" src="cena.png" />'
var cenaAudioMarkup = '<audio id="elCenaShriek" preload="auto"><source src="his-name-is-john-cena.mp3" /><source src="his-name-is-john-cena.ogg" /></audio>';
var locked = false;
//Append Cena and Style
$('body').append(cenaImageMarkup);
if (audioSupported) {
$('body').append(cenaAudioMarkup);
}
var Cena = $('#elCena').css({
"position": "fixed",
"bottom": "-700px",
"right": "0",
"display": "block"
})
// Animating Code
function init() {
locked = true;
//Sound Hilarity
if (audioSupported) {
function playSound() {
document.getElementById('elCenaShriek').play();
}
playSound();
}
// Movement Hilarity
Cena.animate({
"bottom": "0"
}, function () {
$(this).animate({
"bottom": "-130px"
}, 100, function () {
var offset = (($(this).position().left) + 400);
$(this).delay(300).animate({
"right": offset
}, 2200, function () {
Cena = $('#elCena').css({
"bottom": "-700px",
"right": "0"
})
locked = false;
})
});
});
}
//Determine Entrance
if (options.enterOn == 'timer') {
setTimeout(init, options.delayTime);
} else if (options.enterOn == 'click') {
_this.bind('click', function (e) {
e.preventDefault();
if (!locked) {
init();
}
})
} else if (options.enterOn == 'konami-code') {
var kkeys = [],
konami = "38,38,40,40,37,39,37,39,66,65";
$(window).bind("keydown.Cenaz", function (e) {
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(konami) >= 0) {
init();
$(window).unbind('keydown.Cenaz');
}
}, true);
}
}); //each call
} //orbit plugin call
})(jQuery);