Changeset 3978

Show
Ignore:
Timestamp:
07/06/08 22:15:42 (5 months ago)
Author:
doki_pen
Message:
  • changed template parameter map name to data for conventions sake
  • replaced ugly datefield.js addition to add_script invokation
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • datefieldplugin/0.11/datefield/filter.py

    r3977 r3978  
    33from trac.web.chrome import ITemplateProvider, add_script, add_stylesheet 
    44from trac.ticket.api import ITicketManipulator 
    5 from trac.config import Option 
     5from trac.config import Option, IntOption 
    66 
    77import time 
     
    1313    date_format = Option('datefield', 'format', default='dmy', 
    1414             doc='The format to use for dates. Valid values are dmy, mdy, and ymd.') 
    15     first_day = Option('datefield', 'first_day',  
     15    first_day = IntOption('datefield', 'first_day', default=0, 
    1616            doc='First day of the week. 0 == Sunday.') 
    1717    date_sep = Option('datefield', 'separator', default='/', 
     
    3131 
    3232        print format 
    33         datefield = {} 
    34         datefield['calendar'] = req.href.chrome('datefield', 'calendar.png') 
    35         datefield['ids'] = list(self._date_fields()) 
    36         datefield['format'] = format 
    37         datefield['first_day'] = self.first_day 
    38         return 'datefield.html', {'datefield': datefield},'text/javascript'  
     33        data = {} 
     34        data['calendar'] = req.href.chrome('datefield', 'calendar.png') 
     35        data['ids'] = list(self._date_fields()) 
     36        data['format'] = format 
     37        data['first_day'] = self.first_day 
     38        return 'datefield.html', {'data': data},'text/javascript'  
    3939     
    4040    # IRequestFilter methods 
     
    4545        if req.path_info.startswith('/newticket') or req.path_info.startswith('/ticket'): 
    4646            add_script(req, 'datefield/jquery-ui.js') 
     47            add_script(req, '/datefield/datefield.js') 
    4748            add_stylesheet(req, 'datefield/ui.datepicker.css') 
    48  
    49             req.chrome['scripts'].append({'href': req.href.datefield('datefield.js'), 'type': 'text/javascript'}) 
     49            #req.chrome['scripts'].append({'href': req.href.datefield('datefield.js'), 'type': 'text/javascript'}) 
    5050        return template, data, content_type 
    5151         
  • datefieldplugin/0.11/datefield/templates/datefield.html

    r3977 r3978  
    33      xmlns:py="http://genshi.edgewall.org/" py:strip=""> 
    44jQuery(function($) { 
    5     <py:for each="id in datefield.ids" > 
     5    <py:for each="id in data.ids" > 
    66        jQuery('#field-${ id }').datepicker({ 
    7             <py:if test="datefield.first_day"> 
    8                 firstDay: "${datefield.first_day}", 
     7            <!-- we do this instead of using the default because there is a bug in jquery-ui when using the firstDay parameter --> 
     8            <py:if test="data.first_day"> 
     9                firstDay: "${data.first_day}", 
    910            </py:if> 
    10             dateFormat: "${datefield.format}", 
     11            dateFormat: "${data.format}", 
    1112            showOn: "both", 
    12             buttonImage: "${datefield.calendar}", 
     13            buttonImage: "${data.calendar}", 
    1314            buttonImageOnly: true 
    1415        });