phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

[RFC|Merged] AJAX

These requests for comments 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.

Re: [RFC] AJAX

Postby wGEric » Wed Nov 09, 2011 5:29 am

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
wGEric
Registered User
 
Posts: 506
Joined: Wed Jun 11, 2003 2:07 am

Re: [RFC] AJAX

Postby callumacrae » Wed Nov 09, 2011 5:54 pm

wGEric wrote:https://gist.github.com/1350388

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.
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 882
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] AJAX

Postby wGEric » Wed Nov 09, 2011 10:37 pm

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
wGEric
Registered User
 
Posts: 506
Joined: Wed Jun 11, 2003 2:07 am

Re: [RFC] AJAX

Postby Oleg » Sun Nov 20, 2011 4:12 am

Oleg
3.1 Release Manager
3.1 Release Manager
 
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am

Re: [RFC] AJAX

Postby nickvergessen » Sat Nov 26, 2011 12:16 pm

Was this merged? I received commit emails from 21 october today
cheers nickvergessen :geek:
Member of phpBB Development-Team
No Support via PM — My MODs for phpBB 3.0.x
User avatar
nickvergessen
Development Team
Development Team
 
Posts: 350
Joined: Sun Oct 07, 2007 11:54 am
Location: Esslingen, Germany

Re: [RFC] AJAX

Postby igorw » Sat Nov 26, 2011 12:51 pm

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
igorw
Registered User
 
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] AJAX

Postby callumacrae » Wed Nov 30, 2011 6:33 pm

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>' : '';
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 882
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] AJAX

Postby naderman » Wed Nov 30, 2011 6:54 pm

Yup absolutely, we should move all markup into templates. Just as you said, let's do this in a separate PR :)
www.naderman.de
Move your forum to Forumatic - we'll take care of maintenance & spam
User avatar
naderman
Development Team Leader
Development Team Leader
 
Posts: 1649
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany

Re: [RFC] AJAX

Postby callumacrae » Fri Dec 02, 2011 8:15 am

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?
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 882
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] AJAX

Postby naderman » Fri Dec 02, 2011 7:44 pm

Create one
www.naderman.de
Move your forum to Forumatic - we'll take care of maintenance & spam
User avatar
naderman
Development Team Leader
Development Team Leader
 
Posts: 1649
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany

Previous Next

Return to [3.1/Ascraeus] Merged RFCs

Who is online

Users browsing this forum: No registered users and 10 guests