From 818d98916873945d7e0e7bf2855e982496c7fe35 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 24 Sep 2011 17:41:58 +0100 Subject: [feature/ajax] Moved script.js into a few different files. Seperated it into: assets/javascript/core.js, styles/prosilver/template/ajax.js and adm/style/ajax.js. PHPBB3-10270 --- phpBB/adm/style/ajax.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 phpBB/adm/style/ajax.js (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js new file mode 100644 index 0000000000..407ef92110 --- /dev/null +++ b/phpBB/adm/style/ajax.js @@ -0,0 +1,61 @@ +(function($) { // Avoid conflicts with other libraries + + + +phpbb.add_ajax_callback('forum_down', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':first-child')) + { + $(el).parents('span').siblings('.up').html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); + } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) + { + $(el).html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); + } +}).add_ajax_callback('forum_up', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':last-child')) + { + $(el).parents('span').siblings('.down').html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); + } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) + { + $(el).html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); + } +}).add_ajax_callback('act_deact', function(el, res) { + $(el).text(res.text); + var new_href = $(el).attr('href'); + if (new_href.indexOf('deactivate') !== -1) + { + new_href = new_href.replace('deactivate', 'activate') + } + else + { + new_href = new_href.replace('activate', 'deactivate') + } + $(el).attr('href', new_href); +}).add_ajax_callback('row_delete', function(el) { + var tr = $(el).parents('tr'); + tr.remove(); +}); + + + +$('[data-ajax]').each(function() { + var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; + phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); +}); + + + +})(jQuery); // Avoid conflicts with other libraries -- cgit v1.2.1 From 1c5b1ede1c35d57e9abfb62bdee145828011b1b0 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 22 Oct 2011 16:16:15 +0100 Subject: [ticket/10271] Added comments to AJAX callbacks. PHPBB3-10271 --- phpBB/adm/style/ajax.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 407ef92110..1c315eeeff 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -1,7 +1,12 @@ (function($) { // Avoid conflicts with other libraries - +/** + * The following callbacks are for reording forums in acp_forums. forum_down + * is triggered when a forum is moved down, and forum_up is triggered when + * a forum is moved up. It moves the row up or down, and deactivates / + * activates any up / down icons that require it (the ones at the top or bottom). + */ phpbb.add_ajax_callback('forum_down', function(el) { var tr = $(el).parents('tr'); if (tr.is(':first-child')) @@ -32,7 +37,14 @@ phpbb.add_ajax_callback('forum_down', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } -}).add_ajax_callback('act_deact', function(el, res) { +}); + +/** + * This callback replaces activate links with deactivate links and vice versa. + * It does this by replacing the text, and replacing all instances of "activate" + * in the href with "deactivate", and vice versa. + */ +phpbb.add_ajax_callback('act_deact', function(el, res) { $(el).text(res.text); var new_href = $(el).attr('href'); if (new_href.indexOf('deactivate') !== -1) @@ -44,7 +56,13 @@ phpbb.add_ajax_callback('forum_down', function(el) { new_href = new_href.replace('activate', 'deactivate') } $(el).attr('href', new_href); -}).add_ajax_callback('row_delete', function(el) { +}); + +/** + * The removes the parent row of the link or form that triggered the callback, + * and is good for stuff like the removal of forums. + */ +phpbb.add_ajax_callback('row_delete', function(el) { var tr = $(el).parents('tr'); tr.remove(); }); -- cgit v1.2.1 From 95659ba92c01a3cf4c654568e9a59ba554558a7e Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 22 Oct 2011 16:31:52 +0100 Subject: [ticket/10271] Reduced calls to $ in the AJAX JavaScript. PHPBB3-10271 --- phpBB/adm/style/ajax.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 1c315eeeff..2fdabd2a80 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -8,32 +8,34 @@ * activates any up / down icons that require it (the ones at the top or bottom). */ phpbb.add_ajax_callback('forum_down', function(el) { - var tr = $(el).parents('tr'); + el = $(el); + var tr = el.parents('tr'); if (tr.is(':first-child')) { - $(el).parents('span').siblings('.up').html('Move up'); + el.parents('span').siblings('.up').html('Move up'); tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); + phpbb.ajaxify({selector: el.parents('span').siblings('.up').children('a')}, false, 'forum_up'); } tr.insertAfter(tr.next()); if (tr.is(':last-child')) { - $(el).html('Move down'); + el.html('Move down'); tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); } }).add_ajax_callback('forum_up', function(el) { - var tr = $(el).parents('tr'); + el = $(el); + var tr = el.parents('tr'); if (tr.is(':last-child')) { - $(el).parents('span').siblings('.down').html('Move down'); + el.parents('span').siblings('.down').html('Move down'); tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); + phpbb.ajaxify({selector: el.parents('span').siblings('.down').children('a')}, false, 'forum_down'); } tr.insertBefore(tr.prev()); if (tr.is(':first-child')) { - $(el).html('Move up'); + el.html('Move up'); tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } @@ -45,8 +47,9 @@ phpbb.add_ajax_callback('forum_down', function(el) { * in the href with "deactivate", and vice versa. */ phpbb.add_ajax_callback('act_deact', function(el, res) { - $(el).text(res.text); - var new_href = $(el).attr('href'); + el = $(el); + el.text(res.text); + var new_href = el.attr('href'); if (new_href.indexOf('deactivate') !== -1) { new_href = new_href.replace('deactivate', 'activate') @@ -55,7 +58,7 @@ phpbb.add_ajax_callback('act_deact', function(el, res) { { new_href = new_href.replace('activate', 'deactivate') } - $(el).attr('href', new_href); + el.attr('href', new_href); }); /** @@ -70,8 +73,9 @@ phpbb.add_ajax_callback('row_delete', function(el) { $('[data-ajax]').each(function() { - var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; - phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); + var $this = $(this); + var fn = ($this.data('ajax') !== 'true') ? $this.data('ajax') : null; + phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); }); -- cgit v1.2.1 From 81200236052333f88bbf6ecf0c2198080481c07a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 22 Oct 2011 16:37:35 +0100 Subject: [ticket/10271] data-ajax="false" is now ignored. PHPBB3-10271 --- phpBB/adm/style/ajax.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 2fdabd2a80..cb3289b936 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -74,8 +74,11 @@ phpbb.add_ajax_callback('row_delete', function(el) { $('[data-ajax]').each(function() { var $this = $(this); - var fn = ($this.data('ajax') !== 'true') ? $this.data('ajax') : null; - phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); + if ($this.data('ajax') !== 'false') + { + var fn = ($this.data('ajax') !== 'true') ? $this.data('ajax') : null; + phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); + } }); -- cgit v1.2.1 From 03d4ae20d1fc98b43edfdf26ae2a2379e52b3182 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 22 Oct 2011 17:18:09 +0100 Subject: [ticket/10271] Started using .call for javascript callbacks. Previously, they were just being called by appending parentheses and functions. Now, they're being called and the element is being set as the context instead of a parameter. It's a lot cleaner. PHPBB3-10271 --- phpBB/adm/style/ajax.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index cb3289b936..869126ab76 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -7,8 +7,8 @@ * a forum is moved up. It moves the row up or down, and deactivates / * activates any up / down icons that require it (the ones at the top or bottom). */ -phpbb.add_ajax_callback('forum_down', function(el) { - el = $(el); +phpbb.add_ajax_callback('forum_down', function() { + el = $(this); var tr = el.parents('tr'); if (tr.is(':first-child')) { @@ -23,8 +23,8 @@ phpbb.add_ajax_callback('forum_down', function(el) { tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); } -}).add_ajax_callback('forum_up', function(el) { - el = $(el); +}).add_ajax_callback('forum_up', function() { + el = $(this); var tr = el.parents('tr'); if (tr.is(':last-child')) { @@ -46,8 +46,8 @@ phpbb.add_ajax_callback('forum_down', function(el) { * It does this by replacing the text, and replacing all instances of "activate" * in the href with "deactivate", and vice versa. */ -phpbb.add_ajax_callback('act_deact', function(el, res) { - el = $(el); +phpbb.add_ajax_callback('act_deact', function(res) { + el = $(this); el.text(res.text); var new_href = el.attr('href'); if (new_href.indexOf('deactivate') !== -1) @@ -65,9 +65,8 @@ phpbb.add_ajax_callback('act_deact', function(el, res) { * The removes the parent row of the link or form that triggered the callback, * and is good for stuff like the removal of forums. */ -phpbb.add_ajax_callback('row_delete', function(el) { - var tr = $(el).parents('tr'); - tr.remove(); +phpbb.add_ajax_callback('row_delete', function() { + $(this).parents('tr').remove(); }); -- cgit v1.2.1 From 05a88966d4d7156417c151d657989dca4ae01b87 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 17 Nov 2011 17:37:51 +0000 Subject: [ticket/10272] Renamed AJAX callback act_deact to activate_deactivate. PHPBB3-10272 --- phpBB/adm/style/ajax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 869126ab76..88c28fe071 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -46,7 +46,7 @@ phpbb.add_ajax_callback('forum_down', function() { * It does this by replacing the text, and replacing all instances of "activate" * in the href with "deactivate", and vice versa. */ -phpbb.add_ajax_callback('act_deact', function(res) { +phpbb.add_ajax_callback('activate_deactivate', function(res) { el = $(this); el.text(res.text); var new_href = el.attr('href'); -- cgit v1.2.1 From 81e357beef9e1e82607e59d59deba1cf54af4257 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 18 Nov 2011 17:33:22 +0000 Subject: [ticket/10272] Removed some duplication calls to $.fn.data. PHPBB3-10272 --- phpBB/adm/style/ajax.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 88c28fe071..902e072dda 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -72,10 +72,10 @@ phpbb.add_ajax_callback('row_delete', function() { $('[data-ajax]').each(function() { - var $this = $(this); - if ($this.data('ajax') !== 'false') + var $this = $(this), ajax = $this.data('ajax'); + if (ajax !== 'false') { - var fn = ($this.data('ajax') !== 'true') ? $this.data('ajax') : null; + var fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); } }); -- cgit v1.2.1 From 30888ff2a009fe5a001046484d5df4b6e2c67ac8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 18:42:21 +0100 Subject: [feature/ajax] Use attr('data-foo') instead of data('foo') data() is slower and does additional unwanted things like caching and type conversion. Just reading the value is safer. PHPBB3-10270 --- phpBB/adm/style/ajax.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 902e072dda..50477eef90 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -12,7 +12,7 @@ phpbb.add_ajax_callback('forum_down', function() { var tr = el.parents('tr'); if (tr.is(':first-child')) { - el.parents('span').siblings('.up').html('Move up'); + el.parents('span').siblings('.up').html('Move up'); tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: el.parents('span').siblings('.up').children('a')}, false, 'forum_up'); } @@ -20,7 +20,7 @@ phpbb.add_ajax_callback('forum_down', function() { if (tr.is(':last-child')) { el.html('Move down'); - tr.prev().find('.down').html('Move down'); + tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); } }).add_ajax_callback('forum_up', function() { @@ -28,7 +28,7 @@ phpbb.add_ajax_callback('forum_down', function() { var tr = el.parents('tr'); if (tr.is(':last-child')) { - el.parents('span').siblings('.down').html('Move down'); + el.parents('span').siblings('.down').html('Move down'); tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: el.parents('span').siblings('.down').children('a')}, false, 'forum_down'); } @@ -36,7 +36,7 @@ phpbb.add_ajax_callback('forum_down', function() { if (tr.is(':first-child')) { el.html('Move up'); - tr.next().find('.up').html('Move up'); + tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } }); @@ -72,11 +72,11 @@ phpbb.add_ajax_callback('row_delete', function() { $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.data('ajax'); + var $this = $(this), ajax = $this.attr('data-ajax'); if (ajax !== 'false') { var fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn); + phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } }); -- cgit v1.2.1 From 628074bf7057ad5f9aff929d7c8cd85171ce60b8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:02:16 +0100 Subject: [feature/ajax] Stylistic JavaScript adjustments PHPBB3-10270 --- phpBB/adm/style/ajax.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 50477eef90..2725d9fa0a 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -8,8 +8,9 @@ * activates any up / down icons that require it (the ones at the top or bottom). */ phpbb.add_ajax_callback('forum_down', function() { - el = $(this); - var tr = el.parents('tr'); + var el = $(this), + tr = el.parents('tr'); + if (tr.is(':first-child')) { el.parents('span').siblings('.up').html('Move up'); @@ -23,9 +24,12 @@ phpbb.add_ajax_callback('forum_down', function() { tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); } -}).add_ajax_callback('forum_up', function() { - el = $(this); - var tr = el.parents('tr'); +}); + +phpbb.add_ajax_callback('forum_up', function() { + var el = $(this), + tr = el.parents('tr'); + if (tr.is(':last-child')) { el.parents('span').siblings('.down').html('Move down'); @@ -47,9 +51,9 @@ phpbb.add_ajax_callback('forum_down', function() { * in the href with "deactivate", and vice versa. */ phpbb.add_ajax_callback('activate_deactivate', function(res) { - el = $(this); + var el = $(this), + new_href = el.attr('href'); el.text(res.text); - var new_href = el.attr('href'); if (new_href.indexOf('deactivate') !== -1) { new_href = new_href.replace('deactivate', 'activate') @@ -72,10 +76,13 @@ phpbb.add_ajax_callback('row_delete', function() { $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.attr('data-ajax'); + var $this = $(this), + ajax = $this.attr('data-ajax'), + fn; + if (ajax !== 'false') { - var fn = (ajax !== 'true') ? ajax : null; + fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } }); -- cgit v1.2.1 From d53c36684db5ee592b871f518364ae9de03d3e8b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:03:30 +0100 Subject: [feature/ajax] JavaScript strict mode PHPBB3-10270 --- phpBB/adm/style/ajax.js | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 2725d9fa0a..9b73b618d6 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -1,5 +1,6 @@ (function($) { // Avoid conflicts with other libraries +"use strict"; /** * The following callbacks are for reording forums in acp_forums. forum_down -- cgit v1.2.1 From 7ed2cbef75e2e3e561dec00cad26870684968a3a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 19:56:25 +0100 Subject: [feature/ajax] Make phpbb.ajaxify signature use single object (more explicit) PHPBB3-10270 --- phpBB/adm/style/ajax.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 9b73b618d6..b4385b2740 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -16,14 +16,20 @@ phpbb.add_ajax_callback('forum_down', function() { { el.parents('span').siblings('.up').html('Move up'); tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: el.parents('span').siblings('.up').children('a')}, false, 'forum_up'); + phpbb.ajaxify({ + selector: el.parents('span').siblings('.up').children('a'), + callback: 'forum_up' + }); } tr.insertAfter(tr.next()); if (tr.is(':last-child')) { el.html('Move down'); tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); + phpbb.ajaxify({ + selector: tr.prev().find('.down').children('a'), + callback: 'forum_down' + }); } }); @@ -35,14 +41,20 @@ phpbb.add_ajax_callback('forum_up', function() { { el.parents('span').siblings('.down').html('Move down'); tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: el.parents('span').siblings('.down').children('a')}, false, 'forum_down'); + phpbb.ajaxify({ + selector: el.parents('span').siblings('.down').children('a'), + callback: 'forum_down' + }); } tr.insertBefore(tr.prev()); if (tr.is(':first-child')) { el.html('Move up'); tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); + phpbb.ajaxify({ + selector: tr.next().find('.up').children('a'), + callback: 'forum_up' + }); } }); @@ -84,7 +96,11 @@ $('[data-ajax]').each(function() { if (ajax !== 'false') { fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); + phpbb.ajaxify({ + selector: this, + refresh: $this.attr('data-refresh') !== undefined, + callback: fn + }); } }); -- cgit v1.2.1 From 8a0d8c0a84e119121bc9bd69c757aa4776d42acb Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 8 Feb 2012 20:38:23 +0100 Subject: [feature/ajax] Do not hard-code sorting images of acp_forums ordering PHPBB3-10270 --- phpBB/adm/style/ajax.js | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index b4385b2740..0c00efee1b 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -2,6 +2,13 @@ "use strict"; +var img_templates = { + up: $('.template-up-img'), + up_disabled: $('.template-up-img-disabled'), + down: $('.template-down-img'), + down_disabled: $('.template-down-img-disabled') +}; + /** * The following callbacks are for reording forums in acp_forums. forum_down * is triggered when a forum is moved down, and forum_up is triggered when @@ -14,18 +21,26 @@ phpbb.add_ajax_callback('forum_down', function() { if (tr.is(':first-child')) { - el.parents('span').siblings('.up').html('Move up'); - tr.next().find('.up').html('Move up'); + var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); + el.parents('span').siblings('.up').html(up_img); + + tr.next().find('.up').html(img_templates.up_disabled); + phpbb.ajaxify({ selector: el.parents('span').siblings('.up').children('a'), callback: 'forum_up' }); } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) { - el.html('Move down'); - tr.prev().find('.down').html('Move down'); + el.replaceWith(img_templates.down_disabled); + + var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); + tr.prev().find('.down').html(down_img); + phpbb.ajaxify({ selector: tr.prev().find('.down').children('a'), callback: 'forum_down' @@ -39,18 +54,26 @@ phpbb.add_ajax_callback('forum_up', function() { if (tr.is(':last-child')) { - el.parents('span').siblings('.down').html('Move down'); - tr.prev().find('.down').html('Move down'); + var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); + el.parents('span').siblings('.down').html(down_img); + + tr.prev().find('.down').html(img_templates.down_disabled); + phpbb.ajaxify({ selector: el.parents('span').siblings('.down').children('a'), callback: 'forum_down' }); } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) { - el.html('Move up'); - tr.next().find('.up').html('Move up'); + el.replaceWith(img_templates.up_disabled); + + var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); + tr.next().find('.up').html(up_img); + phpbb.ajaxify({ selector: tr.next().find('.up').children('a'), callback: 'forum_up' -- cgit v1.2.1 From d3e7744dd6968b941fb3216ee2a989ed6a0c2ba1 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 00:59:49 +0200 Subject: [feature/ajax] Remove not working module enable/disable ajax code PHPBB3-10270 --- phpBB/adm/style/ajax.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/adm/style/ajax.js') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 0c00efee1b..fd2f7a2122 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -89,7 +89,9 @@ phpbb.add_ajax_callback('forum_up', function() { phpbb.add_ajax_callback('activate_deactivate', function(res) { var el = $(this), new_href = el.attr('href'); + el.text(res.text); + if (new_href.indexOf('deactivate') !== -1) { new_href = new_href.replace('deactivate', 'activate') @@ -98,6 +100,7 @@ phpbb.add_ajax_callback('activate_deactivate', function(res) { { new_href = new_href.replace('activate', 'deactivate') } + el.attr('href', new_href); }); -- cgit v1.2.1