Modify

Opened 12 years ago

Closed 12 years ago

#10655 closed enhancement (fixed)

[Patch] Use jQuery UI provided by Trac in 1.0 and later

Reported by: Ryan J Ollos Owned by: Stepan Riha
Priority: normal Component: AdminEnumListPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

Trac 1.0 provides jQuery UI. The attached patch uses jQuery UI from Trac when the Trac version is >= 1.0.

Attachments (2)

t10655-r7112-1.patch (1.3 KB) - added by Ryan J Ollos 12 years ago.
t10655-r7112-2.diff (1.4 KB) - added by Jun Omae 12 years ago.
Use hasattr(Chrome, 'add_jquery_ui')

Download all attachments as: .zip

Change History (7)

Changed 12 years ago by Ryan J Ollos

Attachment: t10655-r7112-1.patch added

comment:1 Changed 12 years ago by Ryan J Ollos

I have repository-wide commit access, so I'd be happy to push this change if you approve.

Changed 12 years ago by Jun Omae

Attachment: t10655-r7112-2.diff added

Use hasattr(Chrome, 'add_jquery_ui')

comment:2 Changed 12 years ago by Jun Omae

IMO, it would be better to check Chrome.add_jquery_ui attribute instead of Trac version, t10655-r7112-2.diff.

comment:3 Changed 12 years ago by Ryan J Ollos

Yeah, I agree that Jun's patch is the better approach. I'm glad you brought this up, because after I made the first patch, I started thinking one day of a similar approach:

try:
    Chrome(self.env).add_jquery_ui(req)
except AttributeError:
    add_script(req, 'adminenumlistplugin/jquery-ui-custom.js')

I'm not sure of any advantages of try/except vs hasattr; I've seen both patterns used in code quite a bit and I'm fairly new to Python. From reading the docs though, it looks like hasattr effectively does the same behind the scenes by calling getattr in a try/except, so the approach taken in the patch is probably cleaner and more readable.

comment:4 Changed 12 years ago by Ryan J Ollos

Btw, I'll just go ahead and push this change in 2 weeks (per guidelines in AdoptingHacks), if we don't hear from nonplus by then.

comment:5 Changed 12 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

(In [12413]) Fixes #10655: (1.1dev) Use jQuery UI bundled with Trac core when available (1.0 and later). Thanks to Jun Omae for improving the patch. Removed some uncessary imports.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Stepan Riha.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.