Re: Admin Javascript Roadmap/Brainstorming

Showing 1-2 of 2 messages
Re: Admin Javascript Roadmap/Brainstorming Florian Apolloner 11/30/12 5:42 AM
Hi Tyler,

On Wednesday, November 28, 2012 6:24:57 PM UTC+1, Tyler Ball wrote:
- jQuery: Inlines are written as a jQuery plugin, DateTime and i18n are written without jQuery. The version of jQuery included is 1.4.2, which is ~3 years old. Do we want to have jQuery in this project? I think Django should include it, as it helps solve a lot of browser inconsistencies and is familiar to all JS devs. But if so, we should try to keep it up to date.

Django namespaces it's jquery under django.jquery, there should be no issue including an up2date version for your projects. Django probably will never keep up with jquery's release cycle.
 
- Not extensible: Behaviour for the jQuery plugins are defined in template blocks which are somewhat easy to customize, while DateTimeShortcuts uses href="javascript:void" links generated dynamically, which are nearly impossible to override.

Independent of extensibility I think we have to get rid of javascript: urls and onclick handlers (see http://www.html5rocks.com/en/tutorials/security/content-security-policy/ as reference).

Best regards,
Florian
Re: Admin Javascript Roadmap/Brainstorming Travis Swicegood 11/30/12 6:30 AM
On Nov 30, 2012, at 7:42 AM, Florian Apolloner <f.apo...@gmail.com> wrote:

Hi Tyler,

On Wednesday, November 28, 2012 6:24:57 PM UTC+1, Tyler Ball wrote:
- jQuery: Inlines are written as a jQuery plugin, DateTime and i18n are written without jQuery. The version of jQuery included is 1.4.2, which is ~3 years old. Do we want to have jQuery in this project? I think Django should include it, as it helps solve a lot of browser inconsistencies and is familiar to all JS devs. But if so, we should try to keep it up to date.

Django namespaces it's jquery under django.jquery, there should be no issue including an up2date version for your projects. Django probably will never keep up with jquery's release cycle.

I can vouch for this.  It would be nice to keep it more up-to-date, but it is namespaced in a way that keeps it from bother other parts of the code that require a more modern version of jQuery.  I'm currently using 1.7.x in my admin alongside Django's jQuery 1.4 version.


 - Not extensible: Behaviour for the jQuery plugins are defined in template blocks which are somewhat easy to customize, while DateTimeShortcuts uses href="javascript:void" links generated dynamically, which are nearly impossible to override. I'd like to rewrite the Admin JS to use a Backbone like structure, where all the necessary JS is initialized as an instance from one place by calling `new` and a .extend() function can be used where the developer wants to customize behaviour. This change would be pretty radical but I feel it would be for the better.

Agreed that this code is not a good as it could be.  Having created a custom admin on top of admin_tools[1], I've come across a lot of pain points and have slowly (more slowly than I'd like) been refactoring bits of the admin JS into something that's more extensible.[2]

As for your actual idea, I'd have to see it to fully understand what you're proposing here.  Could you mock up some pseudo code that shows what you're trying to accomplish?  It doesn't need to be complex, just something that shows the order of execution using comments and what would be called.