mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10270] Cleaned up code and made popups fade.
This commit cleans up some code - mostly, replacing all instances of __self with "that", and also replacing the parse_hidden function with jQuerys built in .serialize. It also adds animations to the popups. PHPBB3-10270
This commit is contained in:
parent
8a28456f75
commit
456e561442
1 changed files with 15 additions and 27 deletions
|
@ -16,14 +16,14 @@ phpbb.alert = function(title, msg) {
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
div.hide(300, function() {
|
div.animate({opacity: 0}, 300, function() {
|
||||||
div.remove();
|
div.remove();
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').append(div);
|
$('body').append(div);
|
||||||
div.show(300);
|
div.css('opacity', 0).show().animate({opacity: 1}, 300);
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ phpbb.confirm = function(msg, callback) {
|
||||||
$('body').append(div);
|
$('body').append(div);
|
||||||
|
|
||||||
$('.jalertbut').bind('click', function(event) {
|
$('.jalertbut').bind('click', function(event) {
|
||||||
div.hide(300, function() {
|
div.animate({opacity: 0}, 300, function() {
|
||||||
div.remove();
|
div.remove();
|
||||||
});
|
});
|
||||||
callback(this.value === 'Yes');
|
callback(this.value === 'Yes');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
div.show(300);
|
div.css('opacity', 0).show().animate({opacity: 1}, 300);
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ function handle_refresh(data, refresh, div)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
div.hide(300, function() {
|
div.animate({opacity: 0}, 300, function() {
|
||||||
div.remove();
|
div.remove();
|
||||||
});
|
});
|
||||||
}, data.time * 1000);
|
}, data.time * 1000);
|
||||||
|
@ -86,18 +86,6 @@ function handle_refresh(data, refresh, div)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_hidden(inputs)
|
|
||||||
{
|
|
||||||
var end = [];
|
|
||||||
$(inputs).each(function() {
|
|
||||||
if (this.type === 'hidden')
|
|
||||||
{
|
|
||||||
end.push(this.name + '=' + this.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return end.join('&');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function interacts via AJAX with phpBBs confirm_box function.
|
* This function interacts via AJAX with phpBBs confirm_box function.
|
||||||
|
@ -110,19 +98,20 @@ function parse_hidden(inputs)
|
||||||
phpbb.confirm_box = function(condition, refresh, callback)
|
phpbb.confirm_box = function(condition, refresh, callback)
|
||||||
{
|
{
|
||||||
$(condition).click(function() {
|
$(condition).click(function() {
|
||||||
var __self = this;
|
var that = this;
|
||||||
$.get(this.href, function(res) {
|
$.get(this.href, function(res) {
|
||||||
res = JSON.parse(res);
|
res = JSON.parse(res);
|
||||||
phpbb.confirm(res.MESSAGE_TEXT, function(del) {
|
phpbb.confirm(res.MESSAGE_TEXT, function(del) {
|
||||||
if (del)
|
if (del)
|
||||||
{
|
{
|
||||||
var p = res.S_CONFIRM_ACTION.split('?');
|
var path = res.S_CONFIRM_ACTION;
|
||||||
$.post(p[0], p[1] + '&confirm=Yes', function(res) {
|
var data = $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize();
|
||||||
|
$.post(path, data + '&confirm=Yes', function(res) {
|
||||||
res = JSON.parse(res);
|
res = JSON.parse(res);
|
||||||
var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
||||||
if (typeof callback !== 'undefined')
|
if (typeof callback !== 'undefined')
|
||||||
{
|
{
|
||||||
callback(__self);
|
callback(that);
|
||||||
}
|
}
|
||||||
handle_refresh(res.REFRESH_DATA, refresh, alert);
|
handle_refresh(res.REFRESH_DATA, refresh, alert);
|
||||||
});
|
});
|
||||||
|
@ -143,13 +132,13 @@ phpbb.confirm_box = function(condition, refresh, callback)
|
||||||
*/
|
*/
|
||||||
phpbb.ajaxify = function(selector, refresh, callback) {
|
phpbb.ajaxify = function(selector, refresh, callback) {
|
||||||
$(selector).click(function() {
|
$(selector).click(function() {
|
||||||
var __self = this;
|
var that = this;
|
||||||
$.get(this.href, function(res) {
|
$.get(this.href, function(res) {
|
||||||
res = JSON.parse(res);
|
res = JSON.parse(res);
|
||||||
var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
||||||
if (typeof callback !== 'undefined')
|
if (typeof callback !== 'undefined')
|
||||||
{
|
{
|
||||||
callback(__self, res);
|
callback(that, res);
|
||||||
}
|
}
|
||||||
handle_refresh(res.REFRESH_DATA, refresh, alert);
|
handle_refresh(res.REFRESH_DATA, refresh, alert);
|
||||||
});
|
});
|
||||||
|
@ -194,7 +183,7 @@ phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums
|
||||||
* Forms have to be captured manually, as they're all different.
|
* Forms have to be captured manually, as they're all different.
|
||||||
*/
|
*/
|
||||||
$('input[name^="action"]').click(function(e) {
|
$('input[name^="action"]').click(function(e) {
|
||||||
var __self = this;
|
var that = this;
|
||||||
var path = $(this).parents('form')[0].action.replace('&', '&');
|
var path = $(this).parents('form')[0].action.replace('&', '&');
|
||||||
var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove';
|
var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove';
|
||||||
var data = {
|
var data = {
|
||||||
|
@ -207,13 +196,12 @@ $('input[name^="action"]').click(function(e) {
|
||||||
if (del)
|
if (del)
|
||||||
{
|
{
|
||||||
path = res.S_CONFIRM_ACTION;
|
path = res.S_CONFIRM_ACTION;
|
||||||
data = parse_hidden(res.S_HIDDEN_FIELDS);
|
data = $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize();
|
||||||
$.post(path, data + '&confirm=Yes', function(res) {
|
$.post(path, data + '&confirm=Yes', function(res) {
|
||||||
console.log(res);
|
|
||||||
res = JSON.parse(res);
|
res = JSON.parse(res);
|
||||||
var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
||||||
|
|
||||||
$(__self).parents((action === 'approve') ? '.rules' : '.post').remove();
|
$(that).parents((action === 'approve') ? '.rules' : '.post').remove();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
alert.hide(300, function() {
|
alert.hide(300, function() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue