summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/logo.js
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-07-24 23:45:11 +0300
committerFatih Acet <acetfatih@gmail.com>2016-07-24 23:45:11 +0300
commitaaa9509d120524573085e94af9de5cdde83e3271 (patch)
tree3824cffd4cdd132ee9cf75a00a7624f5ccc0dabd /app/assets/javascripts/logo.js
parent56b79181adc0bd6e9abef97ea075c14be971a01a (diff)
downloadgitlab-ce-aaa9509d120524573085e94af9de5cdde83e3271.tar.gz
ES6ify all the things!
Diffstat (limited to 'app/assets/javascripts/logo.js')
-rw-r--r--app/assets/javascripts/logo.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/assets/javascripts/logo.js b/app/assets/javascripts/logo.js
new file mode 100644
index 00000000000..218f24fe908
--- /dev/null
+++ b/app/assets/javascripts/logo.js
@@ -0,0 +1,54 @@
+(function() {
+ var clearHighlights, currentTimer, defaultClass, delay, firstPiece, pieceIndex, pieces, start, stop, work;
+
+ Turbolinks.enableProgressBar();
+
+ defaultClass = 'tanuki-shape';
+
+ pieces = ['path#tanuki-right-cheek', 'path#tanuki-right-eye, path#tanuki-right-ear', 'path#tanuki-nose', 'path#tanuki-left-eye, path#tanuki-left-ear', 'path#tanuki-left-cheek'];
+
+ pieceIndex = 0;
+
+ firstPiece = pieces[0];
+
+ currentTimer = null;
+
+ delay = 150;
+
+ clearHighlights = function() {
+ return $("." + defaultClass + ".highlight").attr('class', defaultClass);
+ };
+
+ start = function() {
+ clearHighlights();
+ pieceIndex = 0;
+ if (pieces[0] !== firstPiece) {
+ pieces.reverse();
+ }
+ if (currentTimer) {
+ clearInterval(currentTimer);
+ }
+ return currentTimer = setInterval(work, delay);
+ };
+
+ stop = function() {
+ clearInterval(currentTimer);
+ return clearHighlights();
+ };
+
+ work = function() {
+ clearHighlights();
+ $(pieces[pieceIndex]).attr('class', defaultClass + " highlight");
+ if (pieceIndex === pieces.length - 1) {
+ pieceIndex = 0;
+ return pieces.reverse();
+ } else {
+ return pieceIndex++;
+ }
+ };
+
+ $(document).on('page:fetch', start);
+
+ $(document).on('page:change', stop);
+
+}).call(this);