mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[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
This commit is contained in:
parent
265907b115
commit
30888ff2a0
3 changed files with 14 additions and 14 deletions
|
@ -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('<a href="' + tr.data('up') + '"><img src="./images/icon_up.gif" alt="Move up" title="Move up" /></a>');
|
||||
el.parents('span').siblings('.up').html('<a href="' + tr.attr('data-up') + '"><img src="./images/icon_up.gif" alt="Move up" title="Move up" /></a>');
|
||||
tr.next().find('.up').html('<img src="./images/icon_up_disabled.gif" alt="Move up" title="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('<img src="./images/icon_down_disabled.gif" alt="Move down" title="Move down" />');
|
||||
tr.prev().find('.down').html('<a href="' + tr.data('down') + '"><img src="./images/icon_down.gif" alt="Move down" title="Move down" /></a>');
|
||||
tr.prev().find('.down').html('<a href="' + tr.attr('data-down') + '"><img src="./images/icon_down.gif" alt="Move down" title="Move down" /></a>');
|
||||
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('<a href="' + tr.data('down') + '"><img src="./images/icon_down.gif" alt="Move down" title="Move down" /></a>');
|
||||
el.parents('span').siblings('.down').html('<a href="' + tr.attr('data-down') + '"><img src="./images/icon_down.gif" alt="Move down" title="Move down" /></a>');
|
||||
tr.prev().find('.down').html('<img src="./images/icon_down_disabled.gif" alt="Move down" title="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('<img src="./images/icon_up_disabled.gif" alt="Move up" title="Move up" />');
|
||||
tr.next().find('.up').html('<a href="' + tr.data('up') + '"><img src="./images/icon_up.gif" alt="Move up" title="Move up" /></a>');
|
||||
tr.next().find('.up').html('<a href="' + tr.attr('data-up') + '"><img src="./images/icon_up.gif" alt="Move up" title="Move up" /></a>');
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ phpbb.loading_alert = function() {
|
|||
setTimeout(function() {
|
||||
if (loading_alert.is(':visible'))
|
||||
{
|
||||
phpbb.alert($('#phpbb_alert').data('l-err'), $('#phpbb_alert').data('l-timeout-processing-req'));
|
||||
phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req'));
|
||||
}
|
||||
}, 5000);
|
||||
});
|
||||
|
@ -125,7 +125,7 @@ phpbb.confirm = function(msg, callback, fadedark) {
|
|||
e.stopPropagation();
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
var click_handler = function() {
|
||||
var res = this.className === 'button1';
|
||||
var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark;
|
||||
|
@ -236,7 +236,7 @@ phpbb.ajaxify = function(options, refresh, callback) {
|
|||
elements.click(function() {
|
||||
var action, data, path, that = this, $this = $(this);
|
||||
|
||||
if ($this.data('ajax') == false)
|
||||
if ($this.attr('data-ajax') == false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -385,8 +385,8 @@ phpbb.add_ajax_callback = function(id, callback)
|
|||
*/
|
||||
phpbb.add_ajax_callback('alt_text', function(el) {
|
||||
el = $(el);
|
||||
var alt_text = el.data('alt-text');
|
||||
el.data('alt-text', el.text());
|
||||
var alt_text = el.attr('data-alt-text');
|
||||
el.attr('data-alt-text', el.text());
|
||||
el.text(el[0].title = alt_text);
|
||||
});
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// This callback finds the post from the delete link, and removes it.
|
||||
phpbb.add_ajax_callback('post_delete', function() {
|
||||
var el = $(this);
|
||||
if (el.data('refresh') === undefined)
|
||||
if (el.attr('data-refresh') === undefined)
|
||||
{
|
||||
var post_id = el[0].href.split('&p=')[1];
|
||||
el.parents('#p' + post_id).fadeOut(function() {
|
||||
|
@ -44,11 +44,11 @@ phpbb.add_ajax_callback('zebra', function(res) {
|
|||
|
||||
|
||||
$('[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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue