mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Optimizing our JavaScript
This commit is contained in:
parent
e7e8457ca5
commit
d20fd79ece
@ -47,24 +47,30 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {};
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
success: $.proxy(function (data, textStatus, jqXHR) {
|
success: $.proxy(function (data, textStatus, jqXHR) {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
$('#loading-' + target.attr('id')).remove();
|
|
||||||
target.css({
|
target.css({
|
||||||
'float' : 'none',
|
'float' : 'none',
|
||||||
'padding' : '5px 25px 7px 35px',
|
'padding' : '5px 25px 7px 35px',
|
||||||
'width' : '',
|
'width' : '',
|
||||||
'overflow' : 'visible'
|
'overflow' : 'visible'
|
||||||
});
|
})
|
||||||
|
.siblings('.ajaxLoad')
|
||||||
|
.remove();
|
||||||
|
|
||||||
|
// mark as active;
|
||||||
|
$('.activeMenuItem .chatRoom').parent().removeClass('activeMenuItem');
|
||||||
|
target.parent().addClass('activeMenuItem');
|
||||||
|
|
||||||
// set new topic
|
// set new topic
|
||||||
if (data.topic == '') {
|
if (data.topic == '') {
|
||||||
if(data.topic == '' && $('#topic').text().trim() == '') return;
|
if (data.topic == '' && $('#topic').text().trim() == '') return;
|
||||||
|
|
||||||
$('#topic').wcfBlindOut('vertical', function() {
|
$('#topic').wcfBlindOut('vertical', function() {
|
||||||
$(this).text('');
|
$(this).text('');
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
if($('#topic').text().trim() != '') {
|
else {
|
||||||
$('#topic').text(data.topic);
|
if ($('#topic').text().trim() != '') $('#topic').text(data.topic);
|
||||||
} else {
|
else {
|
||||||
$('#topic').text(data.topic);
|
$('#topic').text(data.topic);
|
||||||
$('#topic').wcfBlindIn();
|
$('#topic').wcfBlindIn();
|
||||||
}
|
}
|
||||||
@ -74,32 +80,30 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {};
|
|||||||
$('title').text(this.titleTemplate.fetch(data));
|
$('title').text(this.titleTemplate.fetch(data));
|
||||||
}, this),
|
}, this),
|
||||||
beforeSend: $.proxy(function () {
|
beforeSend: $.proxy(function () {
|
||||||
if(this.loading == true || target.parent().attr('class') == "activeMenuItem") return false;
|
if (this.loading || target.parent().hasClass('activeMenuItem')) return false;
|
||||||
|
|
||||||
// mark as active;
|
|
||||||
$('.activeMenuItem .chatRoom').parent().removeClass('activeMenuItem');
|
|
||||||
target.parent().addClass('activeMenuItem');
|
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
//target.append('<img id="loading-' + target.attr('id') + '" src="' + WCF.Icon.get('wcf.global.spinner') + '" />');
|
|
||||||
target.css({
|
target.css({
|
||||||
'width' : target.width() - 19,
|
'width' : target.width() - 19,
|
||||||
'float' : 'left',
|
'float' : 'left',
|
||||||
'padding' : '5px 0 7px 35px',
|
'padding' : '5px 0 7px 35px',
|
||||||
'overflow': 'hidden'
|
'overflow': 'hidden'
|
||||||
});
|
})
|
||||||
target.parent().append('<img id="loading-' + target.attr('id') + '" class="ajaxLoad" src="' + RELATIVE_WCF_DIR + 'icon/spinner1.svg" alt="" />');
|
.parent()
|
||||||
$('#loading-' + target.attr('id')).css({'marginTop' : function(index) {return (target.parent().height() / 2) - ($(this).height() / 2)}});
|
.append('<img class="ajaxLoad" src="' + RELATIVE_WCF_DIR + 'icon/spinner1.svg" alt="" />')
|
||||||
|
.css({'marginTop' : function(index) {return (target.parent().height() / 2) - ($(this).height() / 2)}});
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
toggleUserMenu: function(target) {
|
toggleUserMenu: function(target) {
|
||||||
liUserID = '#' + target.parent().attr('id');
|
liUserID = '#' + target.parent().attr('id');
|
||||||
if($(liUserID).hasClass('activeMenuItem')) {
|
if ($(liUserID).hasClass('activeMenuItem')) {
|
||||||
$(liUserID + ' .chatUserMenu').wcfBlindOut('vertical', function() {
|
$(liUserID + ' .chatUserMenu').wcfBlindOut('vertical', function() {
|
||||||
$(liUserID).removeClass('activeMenuItem');
|
$(liUserID).removeClass('activeMenuItem');
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$(liUserID).addClass('activeMenuItem');
|
$(liUserID).addClass('activeMenuItem');
|
||||||
$(liUserID + ' .chatUserMenu').wcfBlindIn();
|
$(liUserID + ' .chatUserMenu').wcfBlindIn();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user