From 2257cc0c1f7b8d07003698516ef5f48a32f6252d Mon Sep 17 00:00:00 2001 From: Wikinaut-devel Date: Wed, 23 Nov 2011 08:46:44 +0100 Subject: [PATCH 1/2] auto-focus auto-open auto-close chat function --- static/js/chat.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/static/js/chat.js b/static/js/chat.js index c3eddacb2..cd1b16d98 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -14,11 +14,14 @@ * limitations under the License. */ +var chatAnimationIsStarted = false; + var chat = (function() { var self = { show: function () - { + { if (chatAnimationIsStarted) return; + chatAnimationIsStarted = true; $("#chaticon").hide("slide", { direction: "down" }, 500, function () @@ -46,19 +49,27 @@ var chat = (function() }, hide: function () { + if (chatAnimationIsStarted) return; + chatAnimationIsStarted = true; + $("#chatcounter").text("0"); $("#chatbox").hide("slide", { direction: "down" }, 750, function() { - $("#chaticon").show("slide", { direction: "down" }, 500); + $("#chaticon").show("slide", { direction: "down" }, 500, function() + { + chatAnimationIsStarted = false; + }); }); }, scrollDown: function() { //console.log($('#chatbox').css("display")); - - if($('#chatbox').css("display") != "none") + + if($('#chatbox').css("display") != "none") { $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); - }, + } + chatAnimationIsStarted = false; + }, send: function() { var text = $("#chatinput").val(); @@ -98,7 +109,7 @@ var chat = (function() var count = Number($("#chatcounter").text()); count++; $("#chatcounter").text(count); - // chat throb stuff -- Just make it throb in for ~2 secs then fadeotu + // chat throb stuff -- Just make it throb in for ~2 secs then fadeout $('#chatthrob').html(""+authorName+"" + ": " + text); $('#chatthrob').effect("pulsate", {times:1,mode:"hide"},2000); } @@ -108,6 +119,15 @@ var chat = (function() }, init: function() { + $("#chaticon").mouseenter(function(){ + if (!chatAnimationIsStarted) self.show(); + }); + $("#titlecross").mouseenter(function(){ + if (!chatAnimationIsStarted) self.hide(); + }); + $("#chatbox").mouseenter(function(){ + if (!chatAnimationIsStarted) $("#chatinput").focus(); + }); $("#chatinput").keypress(function(evt) { //if the user typed enter, fire the send From 9bb9f59a291c3a44c6c8ad68411080470c548959 Mon Sep 17 00:00:00 2001 From: Wikinaut Date: Sun, 27 Nov 2011 06:39:12 +0100 Subject: [PATCH 2/2] removed redundant statements --- static/js/chat.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/static/js/chat.js b/static/js/chat.js index cd1b16d98..3e7aa65e1 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -21,7 +21,6 @@ var chat = (function() var self = { show: function () { if (chatAnimationIsStarted) return; - chatAnimationIsStarted = true; $("#chaticon").hide("slide", { direction: "down" }, 500, function () @@ -50,8 +49,6 @@ var chat = (function() hide: function () { if (chatAnimationIsStarted) return; - chatAnimationIsStarted = true; - $("#chatcounter").text("0"); $("#chatbox").hide("slide", { direction: "down" }, 750, function() {