Opened 18 years ago
Closed 17 years ago
#3824 closed task (blessed) (fixed)
Transition the Admin Area over to using jQuery
Reported by: | jeresig | Owned by: | |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.1.1 |
Component: | Administration | Keywords: | jquery javascript admin hit-list |
Focuses: | Cc: |
Description
As discussed with Matt, he would like to see the Admin area, in 2.2, using jQuery as the Javascript library running the frontend.
This is the ticket where we can discuss this issue and post possible patches. (An influx of jQuery developers are going to be coming here to help out with the transition.)
Attachments (12)
Change History (61)
#2
@
18 years ago
how to install jquery/interface in wordpress 2.1 (admin)
wp-admin/index.php:
17a18 > wp_enqueue_script('interface');
wp-admin/page-new.php:
7a8 > wp_enqueue_script('interface');
wp-admin/page.php:
56a57 > wp_enqueue_script('interface');
wp-admin/post-new.php:
7a8 > wp_enqueue_script('interface');
wp-admin/post.php:
59a60 > wp_enqueue_script('interface');
wp-includes/script-loader.php:
32a33,34 > $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.1'); > $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.1.1');
#3
@
18 years ago
aercolino, can you just attach any patches. Lots of code in line a ticket makes it harder to follow any discussion
#5
@
18 years ago
I forgot to mention that jQuery needs the noConflict mode enabled.
jQuery.noConflict();
I added it to the end of jquery.js, but a different location is possible I guess.
#8
@
18 years ago
Because we currently only use those things for autosave which is only loaded for drafts. We don't autosave published posts because the saves would show up publicly. If we expand use of jquery beyond autosave for page.php, we can move it outside the draft block.
#9
@
18 years ago
Here is a diff that replaces jQuery to Prototype in the Dashboard and Users / Authors & Users pages. I'm working on the 2.1 version. Please tell me wether this is unacceptable, I'll install 2.1.1...
This file replaces entirely what I posted earlier.
I've decided not to use the interface plugin, for now, so I've removed it.
Files to add (excluded from this diff):
wp-includes/js/jquery/jquery.js wp-includes/js/jquery/jquery.form.js
The diff includes some short new file.
Replaced files are still in place.
#10
@
18 years ago
aercolino,
As this will be going into trunk for 2.2, and not the 2.1.x branch, we'll need the patches to apply against /trunk/
jQuery has already been added to /trunk/
so your patch wouldn't need to add it... you'd just need to implement it.
#11
@
18 years ago
OK, I understand... I just installed a fresh trunk :-)
Could you please add the jquery.form.js file to trunk? It's the jQuery plugin I used in the last patch. (http://www.malsup.com/jquery/form/)
#13
@
18 years ago
The jQuery library in trunk is old (1.1.1).
Could you please install version 1.1.2? (http://jquery.com/)
jQuery is distributed in compressed and uncompressed format. It would be great if you could install both (maybe with same filenames?), so that if I find issues, I can debug them. The uncompressd one could be erased at deployment time, I guess.
Thanks.
@
18 years ago
replaces jQuery to Prototype in pages: Dashboard; Users / Authors & Users - (based on trunk)
#14
@
18 years ago
The patch works fine in IE7 and FF2, and is now based on trunk.
Please try different browsers.
For testers: remember that in the Users / Authors & Users page ajax (jQuery) is called only for adding users to non-empty roles. This is how it works in WordPress. So the first user with a given role will be processed without ajax, and any other with ajax.
#17
@
18 years ago
aercolino, this looks tremendously pleasant :) In fact, awesome.
My only suggestion is to abstract the ajax request sending stuff out of users-js and put it into a rewritten, jQuery based wp-ajax-js.php
Also, if you want to take a look at the list manipulation stuff, I'd be happy to collaborate or help out. I'd like to see if it's possible to
- get rid of all of WP's inline JS. There's a lot of stuff like onclick="deleteSomething(...)"
- have the listMan stuff all be markup based like
<ul id='the-list' class='list-man-list'> <li id='item-1' class='list-man-list-item'> blah blah <a href="http://delete url" class='list-man-delete'>delete</a> </li> </ul>
I don't think we need to worry about backward compatibility with listMan, so no holds barred as far as I'm concerned.
#18
@
18 years ago
mdawaffe, thanks :-)
You're right, the code in users-js.php is mostly shareable. In fact I began to transform the Write page, and I'll try to use as much as possible of it. (abstraction by comparison)
List manipulation is (almost) straightforward in jQuery, so knowing that it's possible to simplify the markup is a big relief.
I posted an article on my blog about an alternative display of custom fields (based on jQuery). I was using a DL instead of a TABLE (or a UL). I think it's a flexible design for lists in general and particularly useful for custom fields.
I'd like you to have a look at it and see if you deem it too radical a change or not.
#21
@
18 years ago
I've attached a patch (uploads.diff) that converts the image uploading stuff to jQuery from Prototype.
#25
@
17 years ago
I've added a patch, jquery_admin_widgets.diff, which converts the admin widgets area to jQuery.
There were a couple of places in the old code where Javascript was doing the work of CSS (basically just clearing some floats), so I took that out and used CSS instead.
Also in the old code was some dead code in which someone had apparently thought about making the dropzone lists all expand equally, but then didn't implement it (a line in resetDroppableHeights() gets the greatest number of widgets that any dropzone has, but never uses that info). I went ahead and made the dropzones expand equally vertically, because 1) someone seemingly meant to do this before and didn't 2) it looks better 3) under the old system if you had a really tall dropzone and a short dropzone, you had to go through shenanigans to drag a widget from the palette to the short dropzone.
I've tested it successfully with the following browsers:
Firefox 2.0.0.6 in Windows and Linux
IE 6 & IE 7
Safari 3.0.3 for Windows
Opera 9.23 for Windows
Konqueror 3.5.6
#27
@
17 years ago
Nice work on the widgets, filosofo! It is much more responsive than the Scriptaculous version.
#28
@
17 years ago
Yes, smoother and faster. One difference I note is that you can't reorder the Available Widgets list. You can only drop to the front of the list. I kinda like it this way, but it is different behavior.
#31
@
17 years ago
I'm not exactly sure why, but it appears that it's not working. Can someone help me out here please? I've spent hours trying to find out why. I think it's because of the nonces, but there was no code previously to add it to the request parameters.
#32
@
17 years ago
Hmm, it appears that the only difference between the 2 is that Prototype/SACK is that the original (using SACK) sends $_POSTrndval?. Is this used anywhere?
#35
@
17 years ago
Hmm, seems it is saving, but drafts are disappearing/aren't displayed on the write page. My bad.
#37
@
17 years ago
The call to jQuery.post() wasn't quite right, so the new nonce wasn't being generated. There's still a problem with post_ID, _wpnonce, and hiddenaction not being updated. I don't see them in the AYS POST data.
#38
@
17 years ago
Adding an ID to _wpnonce fixes the nonce. The problem with the post ID is that the field has an ID of post_ID but a name of temp_ID. We're updating the element with an ID of post_ID, which is actually the temp_ID field. I think the old code inserted a new field with the name post_ID.
#39
follow-up:
↓ 40
@
17 years ago
Setting the name instead of id for #post_ID fixed that last issue I was having. Working well now. Next we need to get rid of PeriodicalExecuter so that we can really lose the prototype dependency.
#42
@
17 years ago
Tags and cats aren't being saved. The reference to tags_input should be tags-input. Not sure what's up with categories, but catslist ends up empty.
#43
@
17 years ago
Categories were being saved for me before; I know, because I spent a fair bit of time getting them working.
#44
in reply to:
↑ 41
@
17 years ago
Replying to ryan:
Would we need to add a currentlyExecuting flag to that?
It looks like we can just set it to false in the callback.
Can someone outline the advantages of jQuery over Prototype/Scriptaculous, or point to a discussion or article Matt has referenced?