From 4a49109ceb0c4672bb693a29f26c54a6f0b3cecf Mon Sep 17 00:00:00 2001 From: Manuel Herrmann <it@icetruck.de> Date: Sun, 21 Sep 2014 03:38:32 +0200 Subject: [PATCH] fixed jquery effect on index load --- registration-system/view/js/story.js | 47 +++++++++++++++++----------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/registration-system/view/js/story.js b/registration-system/view/js/story.js index ab231e9..db2dac2 100644 --- a/registration-system/view/js/story.js +++ b/registration-system/view/js/story.js @@ -28,42 +28,53 @@ function Story(_storybox) { this.storybox = _storybox; this.umleitung = $('#story_umleitung'); - this.state = 0; + this.state = -2; this.basicData = null; this.travelStart = null; } -Story.prototype.next = function(bPrev) +Story.prototype.next = function(bGoBack) { - if (bPrev) - { - this.state -= 1; - if (this.state < 1) - this.state = 1; - } + var previousState = this.state; + if (!bGoBack) + this.state += 1; switch(this.state) { + case -1: + this.initBeginButton(); + break; case 0: + if (previousState == -1) + this.storybox.children().remove(); this.initBasicData(); break; case 1: this.initTravelStart(); - this.travelStart.animate({left:bPrev?'900px':'0px'}, 1000); - this.basicData.animate({left:bPrev?'0px':'-900px'}, 1000); - break; - case 2: - break; - case 3: + this.travelStart.animate({left:bGoBack?'900px':'0px'}, 1000); + this.basicData.animate({left:bGoBack?'0px':'-900px'}, 1000); break; + default: + if (bGoBack) + this.state += 1; + else + this.state -= 1; } - if (!bPrev) - this.state += 1; - if (bPrev && this.state == 1) + if (bGoBack) + { + this.state -= 1; + if (this.state < 0) + this.state = 0; + } + if (bGoBack && this.state == 0) this.umleitung.animate({bottom:'-70px'}, 500); - else if (!bPrev && this.state == 2) + else if (!bGoBack && this.state == 1) this.umleitung.animate({bottom:'0px'}, 500); } +Story.prototype.initBeginButton = function() +{ + this.storybox.append('<div style="cursor:pointer; text-decoration: underline" onclick="story.next()">Anmeldung starten (Story mode)</a>'); +} Story.prototype.initTravelStart = function() { if (this.travelStart) return; -- GitLab