[RFC|Merged] AJAX

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
Post Reply
wGEric
Registered User
Posts: 521
Joined: Wed Jun 11, 2003 2:07 am
Contact:

Re: [RFC] AJAX

Post by wGEric »

https://gist.github.com/1350388

It doesn't completely work and it is mostly your code in a jQuery extension so it isn't any better. You would use it like this:

Code: Select all

$.phpbb.alert(title, message);
$.phpbb.confirm(title, message, callback);
$.phpbb.loading_alert();
You may want to look at some of those functions anyways since I fixed it so that events won't be bound more than once and some $('element') calls are only stored in variables the first time they are called. The most benefit would be for ajaxify() which I talk about more below.
callumacrae wrote:In 99% of cases, they just have to use the data-ajax attribute on their element, and everything will be done for them. In the other 1% (where exceptions are required), the code you specified wouldn't work anyway.
That is incorrect. You have to add the data-ajax attribute and then add the callback. Most AJAX requests are to modify the page some how so you have to have the callback. Ideally you could do something like this:

Code: Select all

$('#move_forum_down').ajaxify(refresh, callback);
$('#move_forum_up').ajaxify(callback);
refresh would be optional and you could have an options array or something so that you can pass in more arguments. This would allow authors to make a link/form work using ajax and supply a callback all within one spot.
callumacrae wrote:
Oleg wrote:I must say I would have preferred having documentation and explanations of changes instead of having to figure that out the hard way. After multiple hours spent reading the diff I'm starting to see what it is doing. I do expect all points that I requested to be documented be documented.
The language entries are stored in data attributes. What specifically don't you understand?
This is a giant patch with many different commits so it is hard to follow anything that is going on with it unless you watch it very closely. It probably would have been better to break this up into multiple patches.
Eric

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] AJAX

Post by callumacrae »

I agree that el.ajaxify() would be nicer, but I don't think it is worth the effort when it will rarely be used.

This is a giant patch with many different commits so it is hard to follow anything that is going on with it unless you watch it very closely. It probably would have been better to break this up into multiple patches.
I didn't expect it to be quite so big. It isn't complete, and I'm waiting for it to be merged before I added AJAX to everything else.
Made by developers, for developers!
My blog

wGEric
Registered User
Posts: 521
Joined: Wed Jun 11, 2003 2:07 am
Contact:

Re: [RFC] AJAX

Post by wGEric »

callumacrae wrote:I agree that el.ajaxify() would be nicer, but I don't think it is worth the effort when it will rarely be used.
It will take more effort to add all the of the data attributes and callbacks in two spots then it does to create a jQuery plugin that is a wrapper to your existing ajaxify function.
Eric


User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: [RFC] AJAX

Post by nickvergessen »

Was this merged? I received commit emails from 21 october today
Member of the Development-TeamNo Support via PM

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] AJAX

Post by igorw »

It was not. The PR is still open: https://github.com/phpbb/phpbb3/pull/336

The thing you saw was most likely the jQuery CDN option being added.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] AJAX

Post by callumacrae »

As a separate pull request, could I move the quick mod tools HTML to the template? I want to add some stuff to the options for prosilver, but not subsilver2, and it's reaaaally impractical for it to be in the PHP:

Code: Select all

$topic_mod = '';
$topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '<option value="lock">' . $user->lang['LOCK_TOPIC'] . '</option>' : '<option value="unlock">' . $user->lang['UNLOCK_TOPIC'] . '</option>') : '';
$topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
Made by developers, for developers!
My blog

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] AJAX

Post by naderman »

Yup absolutely, we should move all markup into templates. Just as you said, let's do this in a separate PR :)

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] AJAX

Post by callumacrae »

naderman wrote:Yup absolutely, we should move all markup into templates. Just as you said, let's do this in a separate PR :)
Is there an existing ticket for this, or should I create one?
Made by developers, for developers!
My blog

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] AJAX

Post by naderman »

Create one

Post Reply