diff options
author | Callum Macrae <callum@lynxphp.com> | 2011-07-16 18:20:04 +0100 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2012-03-31 02:00:22 +0200 |
commit | 456e56144256f3d14d78b02b397d5f3838f0cfea (patch) | |
tree | 66bab00b4d9cc7bd3d84ed15f57b829e1d38e34a /phpBB/styles/script.js | |
parent | 8a28456f759747fc34aaf9a6589102fcace3acb6 (diff) | |
download | forums-456e56144256f3d14d78b02b397d5f3838f0cfea.tar forums-456e56144256f3d14d78b02b397d5f3838f0cfea.tar.gz forums-456e56144256f3d14d78b02b397d5f3838f0cfea.tar.bz2 forums-456e56144256f3d14d78b02b397d5f3838f0cfea.tar.xz forums-456e56144256f3d14d78b02b397d5f3838f0cfea.zip |
[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
Diffstat (limited to 'phpBB/styles/script.js')
-rw-r--r-- | phpBB/styles/script.js | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index b5dec2ca0a..17934ed6ae 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -16,14 +16,14 @@ phpbb.alert = function(title, msg) { { return true; } - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); return false; }); $('body').append(div); - div.show(300); + div.css('opacity', 0).show().animate({opacity: 1}, 300); return div; } @@ -43,13 +43,13 @@ phpbb.confirm = function(msg, callback) { $('body').append(div); $('.jalertbut').bind('click', function(event) { - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); callback(this.value === 'Yes'); return false; }); - div.show(300); + div.css('opacity', 0).show().animate({opacity: 1}, 300); return div; } @@ -78,7 +78,7 @@ function handle_refresh(data, refresh, div) else { setTimeout(function() { - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); }, 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. @@ -110,19 +98,20 @@ function parse_hidden(inputs) phpbb.confirm_box = function(condition, refresh, callback) { $(condition).click(function() { - var __self = this; + var that = this; $.get(this.href, function(res) { res = JSON.parse(res); phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { - var p = res.S_CONFIRM_ACTION.split('?'); - $.post(p[0], p[1] + '&confirm=Yes', function(res) { + var path = res.S_CONFIRM_ACTION; + var data = $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize(); + $.post(path, data + '&confirm=Yes', function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { - callback(__self); + callback(that); } handle_refresh(res.REFRESH_DATA, refresh, alert); }); @@ -143,13 +132,13 @@ phpbb.confirm_box = function(condition, refresh, callback) */ phpbb.ajaxify = function(selector, refresh, callback) { $(selector).click(function() { - var __self = this; + var that = this; $.get(this.href, function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { - callback(__self, res); + callback(that, res); } 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. */ $('input[name^="action"]').click(function(e) { - var __self = this; + var that = this; var path = $(this).parents('form')[0].action.replace('&', '&'); var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove'; var data = { @@ -207,13 +196,12 @@ $('input[name^="action"]').click(function(e) { if (del) { 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) { - console.log(res); res = JSON.parse(res); 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() { alert.hide(300, function() { |