Index: datefield/filter.py
===================================================================
--- datefield/filter.py	(revision 7165)
+++ datefield/filter.py	(working copy)
@@ -2,7 +2,7 @@
 from trac.web.api import IRequestFilter, IRequestHandler, ITemplateStreamFilter
 from trac.web.chrome import ITemplateProvider, add_script, add_stylesheet
 from trac.ticket.api import ITicketManipulator
-from trac.config import Option, IntOption
+from trac.config import Option, IntOption, ListOption, BoolOption
 
 from genshi.builder import tag
 from genshi.filters.transform import Transformer
@@ -20,9 +20,14 @@
             doc='First day of the week. 0 == Sunday.')
     date_sep = Option('datefield', 'separator', default='/',
             doc='The separator character to use for dates.')
+    match_req = ListOption('datefield', 'match_request', default='',
+            doc='Additional request paths to match (use input class="datepick")')
+    use_milestone = BoolOption('datefield', 'milestone', default='false',
+            doc='Use datepicker for milestone due/completed fields? (default=Off)')
+
+    implements(IRequestFilter, IRequestHandler, ITemplateProvider, ITicketManipulator, \
+               ITemplateStreamFilter)
     
-    implements(IRequestFilter, IRequestHandler, ITemplateProvider, ITicketManipulator)
-    
     # IRequestHandler methods
     def match_request(self, req):
         return req.path_info.startswith('/datefield')
@@ -37,19 +42,39 @@
 
         data = {}
         data['calendar'] = req.href.chrome('common', 'ics.png')
-        data['ids'] = list(self._date_fields())
         data['format'] = format
         data['first_day'] = self.first_day
         return 'datefield.html', {'data': data},'text/javascript' 
     
+    # ITemplateStreamFilter methods
+    def filter_stream(self, req, method, filename, stream, data):
+        if filename == 'ticket.html':
+            for field in list(self._date_fields()):
+                stream = stream | Transformer('//input[@name="field_' + field + '"]').\
+                         attr('class', 'datepick')
+        elif self.use_milestone and filename in ('milestone_edit.html', 'admin_milestones.html'):
+            for field in ('duedate', 'completeddate'):
+                stream = stream | Transformer('//input[@name="' + field + '"]').\
+                         attr('class', 'datepick')
+        return stream
+    
     # IRequestFilter methods
     def pre_process_request(self, req, handler):
         return handler
             
     def post_process_request(self, req, template, data, content_type):
-        if req.path_info.startswith('/newticket') or \
-                req.path_info.startswith('/ticket') or \
-                req.path_info.startswith('/simpleticket'):
+        mine = ['/newticket', '/ticket', '/simpleticket']
+        if self.use_milestone:
+            mine.append('/milestone')
+            mine.append('/admin/ticket/milestones')
+
+        match = False
+        for target in mine + self.match_req:
+            if req.path_info.startswith(target):
+                match = True
+                break
+
+        if match:
             add_script(req, 'datefield/js/jquery-ui.js')
             # virtual script
             add_script(req, '/datefield/datefield.js')
Index: datefield/templates/datefield.html
===================================================================
--- datefield/templates/datefield.html	(revision 7165)
+++ datefield/templates/datefield.html	(working copy)
@@ -2,14 +2,12 @@
       xmlns:xi="http://www.w3.org/2001/XInclude"
       xmlns:py="http://genshi.edgewall.org/" py:strip="">
 jQuery(function($) {
-    <py:for each="id in data.ids" >
-        jQuery('#field-${ id }').datepicker({
-            firstDay: "${data.first_day}",
-            dateFormat: "${data.format}",
-            showOn: "both",
-            buttonImage: "${data.calendar}",
-            buttonImageOnly: true
-        });
-    </py:for>
+    jQuery('.datepick').datepicker({
+        firstDay: "${data.first_day}",
+        dateFormat: "${data.format}",
+        showOn: "both",
+        buttonImage: "${data.calendar}",
+        buttonImageOnly: true
+    });
 });
 </script>
