[ticket/102] Ajaxify moving modules up and down
The complete moving process for moving a module up or down now works with AJAX. Images are properly changing as one would expect. B3P-102
This commit is contained in:
81
adm/style/portal/ajax.js
Normal file
81
adm/style/portal/ajax.js
Normal file
@@ -0,0 +1,81 @@
|
||||
(function($) { // Avoid conflicts with other libraries
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* The following callbacks are for reording items. row_down
|
||||
* is triggered when an item is moved down, and row_up is triggered when
|
||||
* an item 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.addAjaxCallback('b3p_move_module_up', function(res) {
|
||||
if (typeof res.success === 'undefined' || !res.success) {
|
||||
return;
|
||||
}
|
||||
|
||||
var el = $(this).parents('tr:first'),
|
||||
trSwap = el.prev(),
|
||||
elClass = trSwap.attr('class'),
|
||||
trSwapClass = el.attr('class');
|
||||
|
||||
el.insertBefore(trSwap);
|
||||
el.attr('class', elClass);
|
||||
trSwap.attr('class', trSwapClass);
|
||||
|
||||
// Swap images if swap element is first row
|
||||
var swapIsFirstRow = trSwap.find('img[src*="icon_up_disabled"]').parents('span:first').is(':visible');
|
||||
|
||||
if (swapIsFirstRow) {
|
||||
trSwap.find('img[src*="icon_up_disabled"]').parents('span:first').toggle();
|
||||
trSwap.find('img[src*="icon_up."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_up."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_up_disabled"]').parents('span:first').toggle();
|
||||
}
|
||||
|
||||
// Swap images if move element is last row
|
||||
var elIsLastRow = el.find('img[src*="icon_down_disabled"]').parents('span:first').is(':visible');
|
||||
|
||||
if (elIsLastRow) {
|
||||
trSwap.find('img[src*="icon_down_disabled"]').parents('span:first').toggle();
|
||||
trSwap.find('img[src*="icon_down."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_down."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_down_disabled"]').parents('span:first').toggle();
|
||||
}
|
||||
});
|
||||
|
||||
phpbb.addAjaxCallback('b3p_move_module_down', function(res) {
|
||||
if (typeof res.success === 'undefined' || !res.success) {
|
||||
return;
|
||||
}
|
||||
|
||||
var el = $(this).parents('tr:first'),
|
||||
trSwap = el.next(),
|
||||
elClass = trSwap.attr('class'),
|
||||
trSwapClass = el.attr('class');
|
||||
|
||||
el.insertAfter(trSwap);
|
||||
el.attr('class', elClass);
|
||||
trSwap.attr('class', trSwapClass);
|
||||
|
||||
// Swap images if swap element is last row
|
||||
var swapIsLastRow = trSwap.find('img[src*="icon_down_disabled"]').parents('span:first').is(':visible');
|
||||
|
||||
if (swapIsLastRow) {
|
||||
trSwap.find('img[src*="icon_down_disabled"]').parents('span:first').toggle();
|
||||
trSwap.find('img[src*="icon_down."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_down."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_down_disabled"]').parents('span:first').toggle();
|
||||
}
|
||||
|
||||
// Swap images if move element is first row
|
||||
var elIsFirstRow = el.find('img[src*="icon_up_disabled"]').parents('span:first').is(':visible');
|
||||
|
||||
if (elIsFirstRow) {
|
||||
trSwap.find('img[src*="icon_up_disabled"]').parents('span:first').toggle();
|
||||
trSwap.find('img[src*="icon_up."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_up."]').parents('span:first').toggle();
|
||||
el.find('img[src*="icon_up_disabled"]').parents('span:first').toggle();
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
Reference in New Issue
Block a user