mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/12982] Refactoring: made JS in adm nice
PHPBB3-12982
This commit is contained in:
parent
340f48fdeb
commit
d79fec1c3f
1 changed files with 16 additions and 17 deletions
|
@ -1,6 +1,8 @@
|
||||||
|
/* global phpbb */
|
||||||
|
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
|
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The following callbacks are for reording items. row_down
|
* The following callbacks are for reording items. row_down
|
||||||
|
@ -13,11 +15,10 @@ phpbb.addAjaxCallback('row_down', function(res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var el = $(this),
|
var $firstTr = $(this).parents('tr'),
|
||||||
tr = el.parents('tr'),
|
$secondTr = $firstTr.next();
|
||||||
trSwap = tr.next();
|
|
||||||
|
|
||||||
tr.insertAfter(trSwap);
|
$firstTr.insertAfter($secondTr);
|
||||||
});
|
});
|
||||||
|
|
||||||
phpbb.addAjaxCallback('row_up', function(res) {
|
phpbb.addAjaxCallback('row_up', function(res) {
|
||||||
|
@ -25,11 +26,10 @@ phpbb.addAjaxCallback('row_up', function(res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var el = $(this),
|
var $secondTr = $(this).parents('tr'),
|
||||||
tr = el.parents('tr'),
|
$firstTr = $secondTr.prev();
|
||||||
trSwap = tr.prev();
|
|
||||||
|
|
||||||
tr.insertBefore(trSwap);
|
$secondTr.insertBefore($firstTr);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,10 +38,10 @@ phpbb.addAjaxCallback('row_up', function(res) {
|
||||||
* in the href with "deactivate", and vice versa.
|
* in the href with "deactivate", and vice versa.
|
||||||
*/
|
*/
|
||||||
phpbb.addAjaxCallback('activate_deactivate', function(res) {
|
phpbb.addAjaxCallback('activate_deactivate', function(res) {
|
||||||
var el = $(this),
|
var $this = $(this),
|
||||||
newHref = el.attr('href');
|
newHref = $this.attr('href');
|
||||||
|
|
||||||
el.text(res.text);
|
$this.text(res.text);
|
||||||
|
|
||||||
if (newHref.indexOf('deactivate') !== -1) {
|
if (newHref.indexOf('deactivate') !== -1) {
|
||||||
newHref = newHref.replace('deactivate', 'activate');
|
newHref = newHref.replace('deactivate', 'activate');
|
||||||
|
@ -49,7 +49,7 @@ phpbb.addAjaxCallback('activate_deactivate', function(res) {
|
||||||
newHref = newHref.replace('activate', 'deactivate');
|
newHref = newHref.replace('activate', 'deactivate');
|
||||||
}
|
}
|
||||||
|
|
||||||
el.attr('href', newHref);
|
$this.attr('href', newHref);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,11 +66,10 @@ phpbb.addAjaxCallback('row_delete', function(res) {
|
||||||
|
|
||||||
$('[data-ajax]').each(function() {
|
$('[data-ajax]').each(function() {
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
ajax = $this.attr('data-ajax'),
|
ajax = $this.attr('data-ajax');
|
||||||
fn;
|
|
||||||
|
|
||||||
if (ajax !== 'false') {
|
if (ajax !== 'false') {
|
||||||
fn = (ajax !== 'true') ? ajax : null;
|
var fn = (ajax !== 'true') ? ajax : null;
|
||||||
phpbb.ajaxify({
|
phpbb.ajaxify({
|
||||||
selector: this,
|
selector: this,
|
||||||
refresh: $this.attr('data-refresh') !== undefined,
|
refresh: $this.attr('data-refresh') !== undefined,
|
||||||
|
@ -82,7 +81,7 @@ $('[data-ajax]').each(function() {
|
||||||
/**
|
/**
|
||||||
* Automatically resize textarea
|
* Automatically resize textarea
|
||||||
*/
|
*/
|
||||||
$(document).ready(function() {
|
$(function() {
|
||||||
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});
|
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue