From bc604dc658564d567293c5c1c9ae8e42cb39f6ad Mon Sep 17 00:00:00 2001 From: max-m Date: Sun, 4 Dec 2011 00:44:16 +0100 Subject: [PATCH] Added ajax loading indicators next to channel name. --- file/js/TimWolla.WCF.Chat.js | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.js b/file/js/TimWolla.WCF.Chat.js index 5a81c71..4667deb 100644 --- a/file/js/TimWolla.WCF.Chat.js +++ b/file/js/TimWolla.WCF.Chat.js @@ -21,9 +21,9 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {}; alert($(event.target).attr('alt')); }); - $(window).bind('beforeunload', function() { - return false; - }); + // $(window).bind('beforeunload', function() { + // return false; + // }); $('.chatRoom').click($.proxy(function (event) { if (typeof window.history.replaceState != 'undefined') { @@ -45,14 +45,25 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {}; data: { ajax: 1 }, type: 'POST', success: $.proxy(function (data, textStatus, jqXHR) { + this.loading = false; + $('#loading-' + target.attr('id')).remove(); + target.css({ + 'float' : 'none', + 'padding' : '5px 25px 7px 35px', + 'width' : '', + 'overflow' : 'visible' + }); + // set new topic if (data.topic == '') { + if(data.topic == '' && $('#topic').text().trim() == '') return; $('#topic').wcfBlindOut('vertical', function() { - $('#topic').text(''); + $('#topic').text(''); }); } else { - if($('#topic').text() != "") $('#topic').text(data.topic); - else { + if($('#topic').text().trim() != '') { + $('#topic').text(data.topic); + } else { $('#topic').text(data.topic); $('#topic').wcfBlindIn(); } @@ -60,6 +71,19 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {}; // set page-title $('title').text(this.titleTemplate.fetch(data)); + }, this), + beforeSend: $.proxy(function () { + if(this.loading == true) return; + this.loading = true; + //target.append(''); + target.css({ + 'width' : target.width() - 19, + 'float' : 'left', + 'padding' : '5px 0 7px 35px', + 'overflow': 'hidden' + }); + target.parent().append(''); + $('#loading-' + target.attr('id')).css({'marginTop' : function(index) {return (target.parent().height() / 2) - ($(this).height() / 2) - 2}, 'borderRadius' : 3}); }, this) }); }