Changeset 411
- Timestamp:
- 08/21/08 13:04:49 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/dashboardreportsplugin/dashboardreports/patch/trac-query.7477.diff
r408 r411 1 Index: oforge/vendor/trac/trac/ticket/api.py1 Index: trac/ticket/api.py 2 2 =================================================================== 3 --- oforge/vendor/trac/trac/ticket/api.py (revision 7477)4 +++ oforge/vendor/trac/trac/ticket/api.py (working copy)3 --- trac/ticket/api.py (revision 7477) 4 +++ trac/ticket/api.py (working copy) 5 5 @@ -183,6 +183,17 @@ 6 6 valid_states.update(controller.get_all_status()) … … 21 21 """Returns the list of fields available for tickets.""" 22 22 from trac.ticket import model 23 Index: oforge/vendor/trac/trac/ticket/query.py23 Index: trac/ticket/query.py 24 24 =================================================================== 25 --- oforge/vendor/trac/trac/ticket/query.py (revision 7477)26 +++ oforge/vendor/trac/trac/ticket/query.py (working copy)27 @@ -31,7 +31, 7@@25 --- trac/ticket/query.py (revision 7477) 26 +++ trac/ticket/query.py (working copy) 27 @@ -31,7 +31,8 @@ 28 28 from trac.ticket.api import TicketSystem 29 29 from trac.util import Ranges 30 30 from trac.util.compat import groupby 31 31 -from trac.util.datefmt import to_timestamp, utc 32 +from trac.util.datefmt import to_timestamp, utc, parse_date 32 +from trac.util.datefmt import to_timestamp, utc, \ 33 + parse_date, get_date_format_hint, format_date 33 34 from trac.util.presentation import Paginator 34 35 from trac.util.text import shorten_line 35 36 from trac.util.translation import _ 36 @@ -43,6 +4 3,9 @@37 @@ -43,6 +44,9 @@ 37 38 from trac.wiki.api import IWikiSyntaxProvider, parse_args 38 39 from trac.wiki.macros import WikiMacroBase # TODO: should be moved in .api … … 44 45 """Exception raised when a ticket query cannot be parsed from a string.""" 45 46 46 @@ -99,7 +10 2,7 @@47 @@ -99,7 +103,7 @@ 47 48 rows = [] 48 49 if verbose and 'description' not in rows: # 0.10 compatibility … … 53 54 self.cols = [c for c in cols or [] if c in field_names or 54 55 c in ('id', 'time', 'changetime')] 55 @@ -119,6 +12 2,7 @@56 @@ -119,6 +123,7 @@ 56 57 self.group = None 57 58 … … 61 62 kw_strs = ['order', 'group', 'page', 'max'] 62 63 kw_arys = ['rows'] 63 @@ -139,8 +14 3,8 @@64 @@ -139,8 +144,8 @@ 64 65 and not field in cls.substitutions: 65 66 mode = field[-1] … … 72 73 processed_values = [] 73 74 for val in values.split('|'): 74 @@ -177,6 +18 1,7 @@75 @@ -177,6 +182,7 @@ 75 76 return [f['name'] for f in self.fields if f['type'] == 'textarea'] 76 77 … … 80 81 cols = ['id'] 81 82 cols += [f['name'] for f in self.fields if f['type'] != 'textarea'] 82 @@ -184,16 +1 89,13 @@83 @@ -184,16 +190,13 @@ 83 84 if col in cols: 84 85 cols.remove(col) … … 98 99 cols.remove(col) 99 100 if col == 'status' and not 'closed' in constraint \ 100 @@ -378,6 +38 0,7 @@101 @@ -378,6 +381,7 @@ 101 102 102 103 def get_sql(self, req=None, cached_ids=None): … … 106 107 107 108 enum_columns = ('resolution', 'priority', 'severity') 108 @@ -423,15 +42 6,31 @@109 @@ -423,15 +427,31 @@ 109 110 % (col, col, col)) 110 111 … … 141 142 return None 142 143 db = self.env.get_db_cnx() 143 @@ -442,7 +46 1,7 @@144 @@ -442,7 +462,7 @@ 144 145 value = value + '%' 145 146 elif mode == '$': … … 150 151 value) 151 152 152 @@ -451,18 +47 0,20 @@153 @@ -451,18 +471,20 @@ 153 154 for k, v in self.constraints.items(): 154 155 if req: … … 178 179 ids = [] 179 180 id_clauses = [] 180 @@ -476,7 +49 7,7 @@181 @@ -476,7 +498,7 @@ 181 182 if ids: 182 183 id_clauses.append('id IN (%s)' % (','.join(ids))) … … 187 188 # Special case for exact matches on multiple values 188 189 elif not mode and len(v) > 1: 189 @@ -485,16 +50 6,16 @@190 @@ -485,16 +507,16 @@ 190 191 else: 191 192 col = k + '.value' … … 207 208 [item[0] for item in constraint_sql]) + ")") 208 209 else: 209 @@ -572,28 +59 3,28 @@210 @@ -572,28 +594,28 @@ 210 211 211 212 def template_data(self, context, tickets, orig_list=None, orig_time=None, … … 245 246 'name': col, 'label': labels.get(col, _('Ticket')), 246 247 'href': self.get_href(context.href, order=col, 247 @@ -610,13 +63 1,19 @@248 @@ -610,13 +632,19 @@ 248 249 fields[field['name']] = field_data 249 250 … … 266 267 modes['select'] = [ 267 268 {'name': _("is"), 'value': ""}, 268 @@ -820,9 +84 7,10 @@269 @@ -820,9 +848,10 @@ 269 270 # Internal methods 270 271 … … 278 279 279 280 # For clients without JavaScript, we remove constraints here if 280 @@ -839,6 +86 7,16 @@281 @@ -839,6 +868,16 @@ 281 282 282 283 for field in [k for k in req.args.keys() if k in ticket_fields]: … … 295 296 vals = [vals] 296 297 if vals: 297 @@ -927,7 +965,9 @@ 298 @@ -925,9 +964,15 @@ 299 # Don't allow the user to remove the id column 300 data['all_columns'].remove('id') 298 301 data['all_textareas'] = query.get_all_textareas() 302 + data['date_format_hint'] = get_date_format_hint().lower(); 303 + data['start_date'] = format_date(datetime(1999, 10, 29, tzinfo=req.tz), 304 + tzinfo=req.tz) 299 305 300 306 add_stylesheet(req, 'common/css/report.css') 301 307 + add_stylesheet(req, 'common/css/datePicker.css') 302 308 add_script(req, 'common/js/query.js') 309 + add_script(req, 'common/js/date.js') 303 310 + add_script(req, 'common/js/jquery.datePicker.js') 304 311 305 312 return 'query.html', data, None 306 313 307 Index: oforge/vendor/trac/trac/ticket/templates/query.html314 Index: trac/ticket/templates/query.html 308 315 =================================================================== 309 --- oforge/vendor/trac/trac/ticket/templates/query.html (revision 7477) 310 +++ oforge/vendor/trac/trac/ticket/templates/query.html (working copy) 311 @@ -100,6 +100,13 @@ 316 --- trac/ticket/templates/query.html (revision 7477) 317 +++ trac/ticket/templates/query.html (working copy) 318 @@ -19,7 +19,13 @@ 319 $("#filters").toggleClass("collapsed"); 320 /* Hide the columns by default. */ 321 $("#columns").toggleClass("collapsed"); 322 + 323 + Date.format = '${date_format_hint}'; 324 + START_DATE = '${start_date}'; 325 + 326 + $('.date-pick').datePicker({startDate:START_DATE}); 327 }); 328 + 329 </script> 330 </head> 331 332 @@ -100,6 +106,10 @@ 312 333 <input type="text" name="${field_name}" value="$constraint_value" size="42" /> 313 334 </py:when> 314 335 315 336 + <py:when test="'date'"> 316 + <input type="text" id="${field_name}" name="${field_name}" value="$constraint_value" /> 317 + <script type="text/javascript"> 318 + jQuery.datePicker.setDateFormat('mdy','/'); 319 + $('#${field_name}').datePicker({startDate:"01/01/1996"}); 320 + </script> 337 + <input type="text" id="${field_name}" 338 + name="${field_name}" value="$constraint_value" class="date-pick"/> 321 339 + </py:when> 322 340 </td> 323 341 <td class="actions" 324 342 py:with="rm_idx = multiline and constraint_idx or len(constraint['values']) - 1"><input 325 Index: oforge/vendor/trac/trac/htdocs/js/query.js 343 @@ -119,7 +129,7 @@ 344 <option></option> 345 <option py:for="field_name, field in fields.items()" 346 value="$field_name" 347 - disabled="${(field.type == 'radio' and 348 + disabled="${(field.type in ['radio', 'date'] and 349 field_name in constraints and 350 len(constraints[field_name])) or None}"> 351 ${field.label} 352 Index: trac/htdocs/js/query.js 326 353 =================================================================== 327 --- oforge/vendor/trac/trac/htdocs/js/query.js (revision 7477) 328 +++ oforge/vendor/trac/trac/htdocs/js/query.js (working copy) 329 @@ -3,6 +3,7 @@ 354 --- trac/htdocs/js/query.js (revision 7477) 355 +++ trac/htdocs/js/query.js (working copy) 356 @@ -2,7 +2,7 @@ 357 (function($){ 330 358 331 359 window.initializeFilters = function() { 332 333 + jQuery.datePicker.setDateFormat('mdy','/');360 - 361 + 334 362 // Bail early for Konqueror and IE5.2/Mac, which don't fully support dynamic 335 363 // creation of form controls 336 364 try { 337 @@ -120,6 +12 1,15@@365 @@ -120,6 +120,16 @@ 338 366 if (htmlFor) label.htmlFor = htmlFor; 339 367 return label; … … 346 374 + if (value) input.value = value; 347 375 + if (id) input.id = id; 376 + input.className = "date-pick"; 348 377 + return input; 349 378 + } … … 351 380 // Convenience function for creating an <input type="checkbox"> 352 381 function createCheckbox(name, value, id) { 353 @@ -230,8 +240,14 @@ 382 @@ -127,7 +137,7 @@ 383 input.type = "checkbox"; 384 if (name) input.name = name; 385 if (value) input.value = value; 386 - if (id) input.id = id; 387 + if (id) input.id = 'id_'+ id; 388 return input; 389 } 390 391 @@ -230,8 +240,15 @@ 354 392 element.type = "text"; 355 393 element.name = propertyName; … … 360 398 } 361 399 td.appendChild(element); 362 + if (property.type == 'date') { 363 + $(element).datePicker({startDate:"01/01/1996"}); 364 + } 400 + //if (property.type == 'date') { 401 + // $(element).datePicker({startDate:START_DATE}); 402 + //$('.date-pick').datePicker(); 403 + //} 365 404 element.focus(); 366 405 tr.appendChild(td); 367 406 } 368 @@ -265, 6 +281,7@@407 @@ -265,14 +282,18 @@ 369 408 var tbody = document.createElement("tbody"); 370 409 tbody.appendChild(tr); … … 374 413 375 414 // Disable the add filter in the drop-down list 376 Index: oforge/vendor/trac/trac/htdocs/js/jquery.datePicker.js 415 - if (property.type == "radio" || property.type == "checkbox") { 416 + if (property.type == "radio" || property.type == "checkbox" || 417 + property.type == "date") { 418 select.options[select.selectedIndex].disabled = true; 419 } 420 select.selectedIndex = 0; 421 + $('.date-pick').datePicker({startDate:START_DATE}); 422 } 423 + 424 } 425 426 })(jQuery); 427 \ No newline at end of file 428 Index: trac/htdocs/js/date.js 377 429 =================================================================== 378 --- oforge/vendor/trac/trac/htdocs/js/jquery.datePicker.js (revision 0)379 +++ oforge/vendor/trac/trac/htdocs/js/jquery.datePicker.js (revision 0)380 @@ -0,0 +1, 13@@430 --- trac/htdocs/js/date.js (revision 0) 431 +++ trac/htdocs/js/date.js (revision 0) 432 @@ -0,0 +1,467 @@ 381 433 +/* 382 + * Date picker plugin for jQuery 383 + * http://kelvinluck.com/assets/jquery/datePicker 384 + * 385 + * Copyright (c) 2006 Kelvin Luck (kelvinluck.com) 386 + * Licensed under the MIT License: 434 + * Date prototype extensions. Doesn't depend on any 435 + * other code. Doens't overwrite existing methods. 436 + * 437 + * Adds dayNames, abbrDayNames, monthNames and abbrMonthNames static properties and isLeapYear, 438 + * isWeekend, isWeekDay, getDaysInMonth, getDayName, getMonthName, getDayOfYear, getWeekOfYear, 439 + * setDayOfYear, addYears, addMonths, addDays, addHours, addMinutes, addSeconds methods 440 + * 441 + * Copyright (c) 2006 Jörn Zaefferer and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) 442 + * 443 + * Additional methods and properties added by Kelvin Luck: firstDayOfWeek, dateFormat, zeroTime, asString, fromString - 444 + * I've added my name to these methods so you know who to blame if they are broken! 445 + * 446 + * Dual licensed under the MIT and GPL licenses: 387 447 + * http://www.opensource.org/licenses/mit-license.php 388 + * 389 + * $LastChangedDate: 2007-02-14 12:01:15 +0000 (Wed, 14 Feb 2007) $ 390 + * $Rev: 1342 $ 448 + * http://www.gnu.org/licenses/gpl.html 449 + * 391 450 + */ 392 451 + 393 +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('8.B=f(){9(1v.2B==M){1v.2B={43:f(){}}}4 1b=[\'2Q\',\'3x\',\'3v\',\'3y\',\'2T\',\'44\',\'2V\',\'2W\',\'2X\',\'3h\',\'3k\',\'2Z\'];4 1J=[\'30\',\'3b\',\'3c\',\'3d\',\'34\',\'32\',\'3e\'];4 U={p:\'37\',n:\'38\',c:\'42\',b:\'39 1e\'};4 1i=\'1R\';4 v="/";4 1h=C;4 P;4 E;4 H;4 R;4 A;4 1L=f(2M){4 s=\'0\'+2M;h s.3a(s.1A-2)};4 14=f(O){1X(1i){N\'2A\':r=O.1k(v);h u t(r[0],Q(r[1])-1,r[2]);N\'1R\':r=O.1k(v);h u t(r[2],Q(r[1])-1,Q(r[0]));N\'1Y\':r=O.1k(v);1z(4 m=0;m<12;m++){9(r[1].1m()==1b[m].1x(0,3).1m()){h u t(Q(r[2]),m,Q(r[0]))}}h M;N\'1Z\':20:4 1N=1N?1N:[2,1,0];r=O.1k(v);h u t(r[2],Q(r[0])-1,Q(r[1]))}};4 1w=f(d){4 1c=d.g();4 1f=1L(d.k()+1);4 1d=1L(d.13());1X(1i){N\'2A\':h 1c+v+1f+v+1d;N\'1R\':h 1d+v+1f+v+1c;N\'1Y\':h 1d+v+1b[d.k()].1x(0,3)+v+1c;N\'1Z\':20:h 1f+v+1d+v+1c}};4 15=f(O){4 V=u t();9(O==M){d=u t(V.g(),V.k(),1)}G{d=O;d.2n(1)}9((d.k()<E.k()&&d.g()==E.g())||d.g()<E.g()){d=u t(E.g(),E.k(),1)}G 9((d.k()>H.k()&&d.g()==H.g())||d.g()>H.g()){d=u t(H.g(),H.k(),1)}4 T=8("<j></j>").q(\'x\',\'D-I\');4 1D=10;4 2k=E.13();4 1K=\'\';9(!(d.k()==E.k()&&d.g()==E.g())){1D=C;4 23=d.k()==0?u t(d.g()-1,11,1):u t(d.g(),d.k()-1,1);4 2v=8("<a></a>").q(\'1a\',\'Z:;\').L(U.p).19(f(){8.B.1y(23,l);h C});1K=8("<j></j>").q(\'x\',\'1s-3C\').L(\'&3l;\').o(2v)}4 1q=10;4 2l=H.13();1H=\'\';9(!(d.k()==H.k()&&d.g()==H.g())){1q=C;4 26=u t(d.g(),d.k()+1,1);4 29=8("<a></a>").q(\'1a\',\'Z:;\').L(U.n).19(f(){8.B.1y(26,l);h C});1H=8("<j></j>").q(\'x\',\'1s-3n\').L(\'&3o;\').3p(29)}4 2a=8("<a></a>").q(\'1a\',\'Z:;\').L(U.c).19(f(){8.B.2u()});T.o(8("<j></j>").q(\'x\',\'1s-3q\').o(2a),8("<2b></2b>").L(1b[d.k()]+\' \'+d.g()));4 1F=8("<1n></1n>");1z(4 i=P;i<P+7;i++){4 K=i%7;4 1g=1J[K];1F.o(8("<2c></2c>").q({\'3r\':\'3s\',\'3t\':1g,\'1B\':1g,\'x\':(K==0||K==6?\'2g\':\'K\')}).L(1g.1x(0,1)))}4 1G=8("<2f></2f>");4 2i=(u t(d.g(),d.k()+1,0)).13();4 y=P-d.3u();9(y>0)y-=7;4 2s=(u t()).13();4 2r=d.k()==V.k()&&d.g()==V.g();4 w=0;24(w++<6){4 1p=8("<1n></1n>");1z(4 i=0;i<7;i++){4 K=(P+i)%7;4 18={\'x\':(K==0||K==6?\'2g \':\'K \')};9(y<0||y>=2i){S=\' \'}G 9(1D&&y<2k-1){S=y+1;18[\'x\']+=\'1W\'}G 9(1q&&y>2l-1){S=y+1;18[\'x\']+=\'1W\'}G{d.2n(y+1);4 1o=1w(d);S=8("<a></a>").q({\'1a\':\'Z:;\',\'2p\':1o}).L(y+1).19(f(e){8.B.2j(8.q(l,\'2p\'),l);h C})[0];9(R&&R==1o){8(S).q(\'x\',\'3B\')}}9(2r&&y+1==2s){18[\'x\']+=\'V\'}1p.o(8("<2t></2t>").q(18).o(S));y++}1G.o(1p)}T.o(8("<2x></2x>").q(\'3G\',2).o("<1P></1P>").3J("1P").o(1F).2e().o(1G.3K())).o(1K).o(1H);9(8.1V.25){4 1Q=[\'<1Q x="3L" 3M="-1" \',\'3O="1r:2O; 3P:3Q;\',\'3R: 0;\',\'3S:0;\',\'z-3T:-1; 3U:3V(3X=\\\'0\\\');\',\'3Y:2L;\',\'3Z:2L"/>\'].40(\'\');T.o(1u.41(1Q))}T.28({\'1r\':\'2O\'});h T[0]};4 16=f(c){8(\'j.D-I a\',A[0]).1M();8(\'j.D-I\',A[0]).2q();8(\'j.D-I\',A[0]).2R();A.o(c)};4 W=f(){8(\'j.D-I a\',A).1M();8(\'j.D-I\',A).2q();8(\'j.D-I\',A).28({\'1r\':\'2Y\'});8(1u).1M(\'2d\',1t);33 A;A=35};4 36=f(e){4 2P=e.1S?e.1S:(e.2K?e.2K:0);9(2P==27){W()}h C};4 1t=f(e){9(!1h){4 1E=8.1V.25?1v.3f.3g:e.1E;4 21=8(1E).17(\'j.D-I\');9(21.3i(0).3j!=\'1e-1j-2D\'){W()}}};h{2G:f(){h U.b},1U:f(){9(A){W()}l.3m();4 F=8(\'F\',8(l).17(\'F\')[0])[0];E=F.1O;H=F.X;P=F.P;A=8(l).17(\'j.D-I\');4 d=8(F).2m();9(d!=\'\'){9(1w(14(d))==d){R=d;16(15(14(d)))}G{R=C;16(15())}}G{R=C;16(15())}8(1u).2z(\'2d\',1t)},1y:f(d,e){1h=10;16(15(d));1h=C},2j:f(d,J){3z=d;4 $1C=8(\'F\',8(J).17(\'F\')[0]);$1C.2m(d);$1C.3D(\'3E\');W(J)},2u:f(){W(l)},2I:f(i){i.2w=10},2F:f(i){h i.2w!=M},3H:f(2y,1I){1i=2y.1m();v=1I?1I:"/"},3N:f(2E,2H,2J){1J=2E;1b=2H;U=2J},2C:f(i,w){9(w==M)w={};9(w.2N==M){i.1O=u t()}G{i.1O=14(w.2N)}9(w.1T==M){i.X=u t();i.X.2S(i.X.g()+5)}G{i.X=14(w.1T)};i.P=w.22==M?0:w.22}}}();8.2o.17=f(s){4 J=l;24(10){9(8(s,J[0]).1A>0){h(J)}J=J.2e();9(J[0].1A==0){h C}}};8.2o.B=f(a){l.3F(f(){9(l.3I.1m()!=\'F\')h;8.B.2C(l,a);9(!8.B.2F(l)){4 1l=8.B.2G();4 Y;9(a&&a.2U){Y=8(l).q(\'1B\',1l).31(\'1e-1j\')}G{Y=8("<a></a>").q({\'1a\':\'Z:;\',\'x\':\'1e-1j\',\'1B\':1l}).o("<2h>"+1l+"</2h>")}8(l).3A(\'<j x="1e-1j-2D"></j>\').3W(8("<j></j>").q({\'x\':\'D-I\'})).3w(Y);Y.2z(\'19\',8.B.1U);8.B.2I(l)}});h l};',62,253,'||||var||||jQuery|if||||||function|getFullYear|return||div|getMonth|this|||append||attr|dParts||Date|new|dateSeparator||class|curDay||_openCal|datePicker|false|popup|_firstDate|input|else|_lastDate|calendar|ele|weekday|html|undefined|case|dIn|_firstDayOfWeek|Number|_selectedDate|dayStr|jCalDiv|navLinks|today|_closeDatePicker|_endDate|calBut|javascript|true|||getDate|_strToDate|_getCalendarDiv|_draw|findClosestParent|atts|click|href|months|dY|dD|date|dM|day|_drawingMonth|dateFormat|picker|split|chooseDate|toLowerCase|tr|dStr|thisRow|finalMonth|display|link|_checkMouse|document|window|_dateToStr|substr|changeMonth|for|length|title|theInput|firstMonth|target|headRow|tBody|nextLinkDiv|separator|days|prevLinkDiv|_zeroPad|unbind|parts|_startDate|thead|iframe|dmy|keyCode|endDate|show|browser|inactive|switch|dmmy|mdy|default|cp|firstDayOfWeek|lastMonth|while|msie|nextMonth||css|nextLink|closeLink|h3|th|mousedown|parent|tbody|weekend|span|lastDay|selectDate|firstDate|lastDate|val|setDate|fn|rel|empty|thisMonth|todayDate|td|closeCalendar|prevLink|_inited|table|format|bind|ymd|console|setDateWindow|holder|aDays|isInited|getChooseDateStr|aMonths|setInited|aNavLinks|which|3000px|num|startDate|block|key|January|remove|setFullYear|May|inputClick|July|August|September|none|December|Sunday|addClass|Friday|delete|Thursday|null|_handleKeys|Prev|Next|Choose|substring|Monday|Tuesday|Wednesday|Saturday|event|srcElement|October|get|className|November|lt|blur|next|gt|prepend|close|scope|col|abbr|getDay|March|after|February|April|selectedDate|wrap|selected|prev|trigger|change|each|cellspacing|setDateFormat|nodeName|find|children|bgiframe|tabindex|setLanguageStrings|style|position|absolute|top|left|index|filter|Alpha|before|Opacity|width|height|join|createElement|Close|log|June'.split('|'),0,{})) 394 Index: oforge/vendor/trac/trac/htdocs/css/datePicker.css 452 +/** 453 + * An Array of day names starting with Sunday. 454 + * 455 + * @example dayNames[0] 456 + * @result 'Sunday' 457 + * 458 + * @name dayNames 459 + * @type Array 460 + * @cat Plugins/Methods/Date 461 + */ 462 +Date.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; 463 + 464 +/** 465 + * An Array of abbreviated day names starting with Sun. 466 + * 467 + * @example abbrDayNames[0] 468 + * @result 'Sun' 469 + * 470 + * @name abbrDayNames 471 + * @type Array 472 + * @cat Plugins/Methods/Date 473 + */ 474 +Date.abbrDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; 475 + 476 +/** 477 + * An Array of month names starting with Janurary. 478 + * 479 + * @example monthNames[0] 480 + * @result 'January' 481 + * 482 + * @name monthNames 483 + * @type Array 484 + * @cat Plugins/Methods/Date 485 + */ 486 +Date.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; 487 + 488 +/** 489 + * An Array of abbreviated month names starting with Jan. 490 + * 491 + * @example abbrMonthNames[0] 492 + * @result 'Jan' 493 + * 494 + * @name monthNames 495 + * @type Array 496 + * @cat Plugins/Methods/Date 497 + */ 498 +Date.abbrMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; 499 + 500 +/** 501 + * The first day of the week for this locale. 502 + * 503 + * @name firstDayOfWeek 504 + * @type Number 505 + * @cat Plugins/Methods/Date 506 + * @author Kelvin Luck 507 + */ 508 +Date.firstDayOfWeek = 1; 509 + 510 +/** 511 + * The format that string dates should be represented as (e.g. 'dd/mm/yyyy' for UK, 'mm/dd/yyyy' for US, 'yyyy-mm-dd' for Unicode etc). 512 + * 513 + * @name format 514 + * @type String 515 + * @cat Plugins/Methods/Date 516 + * @author Kelvin Luck 517 + */ 518 +Date.format = 'dd/mm/yyyy'; 519 +//Date.format = 'mm/dd/yyyy'; 520 +//Date.format = 'yyyy-mm-dd'; 521 +//Date.format = 'dd mmm yy'; 522 + 523 +/** 524 + * The first two numbers in the century to be used when decoding a two digit year. Since a two digit year is ambiguous (and date.setYear 525 + * only works with numbers < 99 and so doesn't allow you to set years after 2000) we need to use this to disambiguate the two digit year codes. 526 + * 527 + * @name format 528 + * @type String 529 + * @cat Plugins/Methods/Date 530 + * @author Kelvin Luck 531 + */ 532 +Date.fullYearStart = '20'; 533 + 534 +(function() { 535 + 536 + /** 537 + * Adds a given method under the given name 538 + * to the Date prototype if it doesn't 539 + * currently exist. 540 + * 541 + * @private 542 + */ 543 + function add(name, method) { 544 + if( !Date.prototype[name] ) { 545 + Date.prototype[name] = method; 546 + } 547 + }; 548 + 549 + /** 550 + * Checks if the year is a leap year. 551 + * 552 + * @example var dtm = new Date("01/12/2008"); 553 + * dtm.isLeapYear(); 554 + * @result true 555 + * 556 + * @name isLeapYear 557 + * @type Boolean 558 + * @cat Plugins/Methods/Date 559 + */ 560 + add("isLeapYear", function() { 561 + var y = this.getFullYear(); 562 + return (y%4==0 && y%100!=0) || y%400==0; 563 + }); 564 + 565 + /** 566 + * Checks if the day is a weekend day (Sat or Sun). 567 + * 568 + * @example var dtm = new Date("01/12/2008"); 569 + * dtm.isWeekend(); 570 + * @result false 571 + * 572 + * @name isWeekend 573 + * @type Boolean 574 + * @cat Plugins/Methods/Date 575 + */ 576 + add("isWeekend", function() { 577 + return this.getDay()==0 || this.getDay()==6; 578 + }); 579 + 580 + /** 581 + * Check if the day is a day of the week (Mon-Fri) 582 + * 583 + * @example var dtm = new Date("01/12/2008"); 584 + * dtm.isWeekDay(); 585 + * @result false 586 + * 587 + * @name isWeekDay 588 + * @type Boolean 589 + * @cat Plugins/Methods/Date 590 + */ 591 + add("isWeekDay", function() { 592 + return !this.isWeekend(); 593 + }); 594 + 595 + /** 596 + * Gets the number of days in the month. 597 + * 598 + * @example var dtm = new Date("01/12/2008"); 599 + * dtm.getDaysInMonth(); 600 + * @result 31 601 + * 602 + * @name getDaysInMonth 603 + * @type Number 604 + * @cat Plugins/Methods/Date 605 + */ 606 + add("getDaysInMonth", function() { 607 + return [31,(this.isLeapYear() ? 29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()]; 608 + }); 609 + 610 + /** 611 + * Gets the name of the day. 612 + * 613 + * @example var dtm = new Date("01/12/2008"); 614 + * dtm.getDayName(); 615 + * @result 'Saturday' 616 + * 617 + * @example var dtm = new Date("01/12/2008"); 618 + * dtm.getDayName(true); 619 + * @result 'Sat' 620 + * 621 + * @param abbreviated Boolean When set to true the name will be abbreviated. 622 + * @name getDayName 623 + * @type String 624 + * @cat Plugins/Methods/Date 625 + */ 626 + add("getDayName", function(abbreviated) { 627 + return abbreviated ? Date.abbrDayNames[this.getDay()] : Date.dayNames[this.getDay()]; 628 + }); 629 + 630 + /** 631 + * Gets the name of the month. 632 + * 633 + * @example var dtm = new Date("01/12/2008"); 634 + * dtm.getMonthName(); 635 + * @result 'Janurary' 636 + * 637 + * @example var dtm = new Date("01/12/2008"); 638 + * dtm.getMonthName(true); 639 + * @result 'Jan' 640 + * 641 + * @param abbreviated Boolean When set to true the name will be abbreviated. 642 + * @name getDayName 643 + * @type String 644 + * @cat Plugins/Methods/Date 645 + */ 646 + add("getMonthName", function(abbreviated) { 647 + return abbreviated ? Date.abbrMonthNames[this.getMonth()] : Date.monthNames[this.getMonth()]; 648 + }); 649 + 650 + /** 651 + * Get the number of the day of the year. 652 + * 653 + * @example var dtm = new Date("01/12/2008"); 654 + * dtm.getDayOfYear(); 655 + * @result 11 656 + * 657 + * @name getDayOfYear 658 + * @type Number 659 + * @cat Plugins/Methods/Date 660 + */ 661 + add("getDayOfYear", function() { 662 + var tmpdtm = new Date("1/1/" + this.getFullYear()); 663 + return Math.floor((this.getTime() - tmpdtm.getTime()) / 86400000); 664 + }); 665 + 666 + /** 667 + * Get the number of the week of the year. 668 + * 669 + * @example var dtm = new Date("01/12/2008"); 670 + * dtm.getWeekOfYear(); 671 + * @result 2 672 + * 673 + * @name getWeekOfYear 674 + * @type Number 675 + * @cat Plugins/Methods/Date 676 + */ 677 + add("getWeekOfYear", function() { 678 + return Math.ceil(this.getDayOfYear() / 7); 679 + }); 680 + 681 + /** 682 + * Set the day of the year. 683 + * 684 + * @example var dtm = new Date("01/12/2008"); 685 + * dtm.setDayOfYear(1); 686 + * dtm.toString(); 687 + * @result 'Tue Jan 01 2008 00:00:00' 688 + * 689 + * @name setDayOfYear 690 + * @type Date 691 + * @cat Plugins/Methods/Date 692 + */ 693 + add("setDayOfYear", function(day) { 694 + this.setMonth(0); 695 + this.setDate(day); 696 + return this; 697 + }); 698 + 699 + /** 700 + * Add a number of years to the date object. 701 + * 702 + * @example var dtm = new Date("01/12/2008"); 703 + * dtm.addYears(1); 704 + * dtm.toString(); 705 + * @result 'Mon Jan 12 2009 00:00:00' 706 + * 707 + * @name addYears 708 + * @type Date 709 + * @cat Plugins/Methods/Date 710 + */ 711 + add("addYears", function(num) { 712 + this.setFullYear(this.getFullYear() + num); 713 + return this; 714 + }); 715 + 716 + /** 717 + * Add a number of months to the date object. 718 + * 719 + * @example var dtm = new Date("01/12/2008"); 720 + * dtm.addMonths(1); 721 + * dtm.toString(); 722 + * @result 'Tue Feb 12 2008 00:00:00' 723 + * 724 + * @name addMonths 725 + * @type Date 726 + * @cat Plugins/Methods/Date 727 + */ 728 + add("addMonths", function(num) { 729 + var tmpdtm = this.getDate(); 730 + 731 + this.setMonth(this.getMonth() + num); 732 + 733 + if (tmpdtm > this.getDate()) 734 + this.addDays(-this.getDate()); 735 + 736 + return this; 737 + }); 738 + 739 + /** 740 + * Add a number of days to the date object. 741 + * 742 + * @example var dtm = new Date("01/12/2008"); 743 + * dtm.addDays(1); 744 + * dtm.toString(); 745 + * @result 'Sun Jan 13 2008 00:00:00' 746 + * 747 + * @name addDays 748 + * @type Date 749 + * @cat Plugins/Methods/Date 750 + */ 751 + add("addDays", function(num) { 752 + this.setDate(this.getDate() + num); 753 + return this; 754 + }); 755 + 756 + /** 757 + * Add a number of hours to the date object. 758 + * 759 + * @example var dtm = new Date("01/12/2008"); 760 + * dtm.addHours(24); 761 + * dtm.toString(); 762 + * @result 'Sun Jan 13 2008 00:00:00' 763 + * 764 + * @name addHours 765 + * @type Date 766 + * @cat Plugins/Methods/Date 767 + */ 768 + add("addHours", function(num) { 769 + this.setHours(this.getHours() + num); 770 + return this; 771 + }); 772 + 773 + /** 774 + * Add a number of minutes to the date object. 775 + * 776 + * @example var dtm = new Date("01/12/2008"); 777 + * dtm.addMinutes(60); 778 + * dtm.toString(); 779 + * @result 'Sat Jan 12 2008 01:00:00' 780 + * 781 + * @name addMinutes 782 + * @type Date 783 + * @cat Plugins/Methods/Date 784 + */ 785 + add("addMinutes", function(num) { 786 + this.setMinutes(this.getMinutes() + num); 787 + return this; 788 + }); 789 + 790 + /** 791 + * Add a number of seconds to the date object. 792 + * 793 + * @example var dtm = new Date("01/12/2008"); 794 + * dtm.addSeconds(60); 795 + * dtm.toString(); 796 + * @result 'Sat Jan 12 2008 00:01:00' 797 + * 798 + * @name addSeconds 799 + * @type Date 800 + * @cat Plugins/Methods/Date 801 + */ 802 + add("addSeconds", function(num) { 803 + this.setSeconds(this.getSeconds() + num); 804 + return this; 805 + }); 806 + 807 + /** 808 + * Sets the time component of this Date to zero for cleaner, easier comparison of dates where time is not relevant. 809 + * 810 + * @example var dtm = new Date(); 811 + * dtm.zeroTime(); 812 + * dtm.toString(); 813 + * @result 'Sat Jan 12 2008 00:01:00' 814 + * 815 + * @name zeroTime 816 + * @type Date 817 + * @cat Plugins/Methods/Date 818 + * @author Kelvin Luck 819 + */ 820 + add("zeroTime", function() { 821 + this.setMilliseconds(0); 822 + this.setSeconds(0); 823 + this.setMinutes(0); 824 + this.setHours(0); 825 + return this; 826 + }); 827 + 828 + /** 829 + * Returns a string representation of the date object according to Date.format. 830 + * (Date.toString may be used in other places so I purposefully didn't overwrite it) 831 + * 832 + * @example var dtm = new Date("01/12/2008"); 833 + * dtm.asString(); 834 + * @result '12/01/2008' // (where Date.format == 'dd/mm/yyyy' 835 + * 836 + * @name asString 837 + * @type Date 838 + * @cat Plugins/Methods/Date 839 + * @author Kelvin Luck 840 + */ 841 + add("asString", function() { 842 + var r = Date.format; 843 + return r 844 + .split('yyyy').join(this.getFullYear()) 845 + .split('yy').join((this.getFullYear() + '').substring(2)) 846 + .split('mmm').join(this.getMonthName(true)) 847 + .split('mm').join(_zeroPad(this.getMonth()+1)) 848 + .split('dd').join(_zeroPad(this.getDate())); 849 + }); 850 + 851 + /** 852 + * Returns a new date object created from the passed String according to Date.format or false if the attempt to do this results in an invalid date object 853 + * (We can't simple use Date.parse as it's not aware of locale and I chose not to overwrite it incase it's functionality is being relied on elsewhere) 854 + * 855 + * @example var dtm = Date.fromString("12/01/2008"); 856 + * dtm.toString(); 857 + * @result 'Sat Jan 12 2008 00:00:00' // (where Date.format == 'dd/mm/yyyy' 858 + * 859 + * @name fromString 860 + * @type Date 861 + * @cat Plugins/Methods/Date 862 + * @author Kelvin Luck 863 + */ 864 + Date.fromString = function(s) 865 + { 866 + var f = Date.format; 867 + var d = new Date('01/01/1977'); 868 + var iY = f.indexOf('yyyy'); 869 + if (iY > -1) { 870 + d.setFullYear(Number(s.substr(iY, 4))); 871 + } else { 872 + // TODO - this doesn't work very well - are there any rules for what is meant by a two digit year? 873 + d.setFullYear(Number(Date.fullYearStart + s.substr(f.indexOf('yy'), 2))); 874 + } 875 + var iM = f.indexOf('mmm'); 876 + if (iM > -1) { 877 + var mStr = s.substr(iM, 3); 878 + for (var i=0; i<Date.abbrMonthNames.length; i++) { 879 + if (Date.abbrMonthNames[i] == mStr) break; 880 + } 881 + d.setMonth(i); 882 + } else { 883 + d.setMonth(Number(s.substr(f.indexOf('mm'), 2)) - 1); 884 + } 885 + d.setDate(Number(s.substr(f.indexOf('dd'), 2))); 886 + if (isNaN(d.getTime())) { 887 + return false; 888 + } 889 + return d; 890 + }; 891 + 892 + // utility method 893 + var _zeroPad = function(num) { 894 + var s = '0'+num; 895 + return s.substring(s.length-2) 896 + //return ('0'+num).substring(-2); // doesn't work on IE :( 897 + }; 898 + 899 +})(); 900 \ No newline at end of file 901 Index: trac/htdocs/js/jquery.datePicker.js 395 902 =================================================================== 396 --- oforge/vendor/trac/trac/htdocs/css/datePicker.css (revision 0) 397 +++ oforge/vendor/trac/trac/htdocs/css/datePicker.css (revision 0) 398 @@ -0,0 +1,110 @@ 399 +/* Styles for the example page */ 400 + 401 +div.demo-holder { 402 + float: left; 403 + margin: 1em; 404 + font-size: 80%; 405 +} 406 +div.demo-holder input { 407 + width: 90px; 408 + margin: 1px 5px 5px 0; 409 +} 410 + 411 +/* Date picker specific styles follow */ 412 + 413 +a.date-picker { 903 --- trac/htdocs/js/jquery.datePicker.js (revision 0) 904 +++ trac/htdocs/js/jquery.datePicker.js (revision 0) 905 @@ -0,0 +1,1056 @@ 906 +/** 907 + * Copyright (c) 2007 Kelvin Luck (http://www.kelvinluck.com/) 908 + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 909 + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. 910 + * 911 + * $Id: jquery.datePicker.js 3739 2007-10-25 13:55:30Z kelvin.luck $ 912 + **/ 913 + 914 +(function($){ 915 + 916 + $.fn.extend({ 917 +/** 918 + * Render a calendar table into any matched elements. 919 + * 920 + * @param Object s (optional) Customize your calendars. 921 + * @option Number month The month to render (NOTE that months are zero based). Default is today's month. 922 + * @option Number year The year to render. Default is today's year. 923 + * @option Function renderCallback A reference to a function that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Default is no callback. 924 + * @option Number showHeader Whether or not to show the header row, possible values are: $.dpConst.SHOW_HEADER_NONE (no header), $.dpConst.SHOW_HEADER_SHORT (first letter of each day) and $.dpConst.SHOW_HEADER_LONG (full name of each day). Default is $.dpConst.SHOW_HEADER_SHORT. 925 + * @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class. 926 + * @type jQuery 927 + * @name renderCalendar 928 + * @cat plugins/datePicker 929 + * @author Kelvin Luck (http://www.kelvinluck.com/) 930 + * 931 + * @example $('#calendar-me').renderCalendar({month:0, year:2007}); 932 + * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me. 933 + * 934 + * @example 935 + * var testCallback = function($td, thisDate, month, year) 936 + * { 937 + * if ($td.is('.current-month') && thisDate.getDay() == 4) { 938 + * var d = thisDate.getDate(); 939 + * $td.bind( 940 + * 'click', 941 + * function() 942 + * { 943 + * alert('You clicked on ' + d + '/' + (Number(month)+1) + '/' + year); 944 + * } 945 + * ).addClass('thursday'); 946 + * } else if (thisDate.getDay() == 5) { 947 + * $td.html('Friday the ' + $td.html() + 'th'); 948 + * } 949 + * } 950 + * $('#calendar-me').renderCalendar({month:0, year:2007, renderCallback:testCallback}); 951 + * 952 + * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me. Every Thursday in the current month has a class of "thursday" applied to it, is clickable and shows an alert when clicked. Every Friday on the calendar has the number inside replaced with text. 953 + **/ 954 + renderCalendar : function(s) 955 + { 956 + var dc = function(a) 957 + { 958 + return document.createElement(a); 959 + }; 960 + 961 + s = $.extend( 962 + { 963 + month : null, 964 + year : null, 965 + renderCallback : null, 966 + showHeader : $.dpConst.SHOW_HEADER_SHORT, 967 + dpController : null, 968 + hoverClass : 'dp-hover' 969 + } 970 + , s 971 + ); 972 + 973 + if (s.showHeader != $.dpConst.SHOW_HEADER_NONE) { 974 + var headRow = $(dc('tr')); 975 + for (var i=Date.firstDayOfWeek; i<Date.firstDayOfWeek+7; i++) { 976 + var weekday = i%7; 977 + var day = Date.dayNames[weekday]; 978 + headRow.append( 979 + jQuery(dc('th')).attr({'scope':'col', 'abbr':day, 'title':day, 'class':(weekday == 0 || weekday == 6 ? 'weekend' : 'weekday')}).html(s.showHeader == $.dpConst.SHOW_HEADER_SHORT ? day.substr(0, 1) : day) 980 + ); 981 + } 982 + }; 983 + 984 + var calendarTable = $(dc('table')) 985 + .attr( 986 + { 987 + 'cellspacing':2, 988 + 'className':'jCalendar' 989 + } 990 + ) 991 + .append( 992 + (s.showHeader != $.dpConst.SHOW_HEADER_NONE ? 993 + $(dc('thead')) 994 + .append(headRow) 995 + : 996 + dc('thead') 997 + ) 998 + ); 999 + var tbody = $(dc('tbody')); 1000 + 1001 + var today = (new Date()).zeroTime(); 1002 + 1003 + var month = s.month == undefined ? today.getMonth() : s.month; 1004 + var year = s.year || today.getFullYear(); 1005 + 1006 + var currentDate = new Date(year, month, 1); 1007 + 1008 + 1009 + var firstDayOffset = Date.firstDayOfWeek - currentDate.getDay() + 1; 1010 + if (firstDayOffset > 1) firstDayOffset -= 7; 1011 + var weeksToDraw = Math.ceil(( (-1*firstDayOffset+1) + currentDate.getDaysInMonth() ) /7); 1012 + currentDate.addDays(firstDayOffset-1); 1013 + 1014 + var doHover = function() 1015 + { 1016 + if (s.hoverClass) { 1017 + $(this).addClass(s.hoverClass); 1018 + } 1019 + }; 1020 + var unHover = function() 1021 + { 1022 + if (s.hoverClass) { 1023 + $(this).removeClass(s.hoverClass); 1024 + } 1025 + }; 1026 + 1027 + var w = 0; 1028 + while (w++<weeksToDraw) { 1029 + var r = jQuery(dc('tr')); 1030 + for (var i=0; i<7; i++) { 1031 + var thisMonth = currentDate.getMonth() == month; 1032 + var d = $(dc('td')) 1033 + .text(currentDate.getDate() + '') 1034 + .attr('className', (thisMonth ? 'current-month ' : 'other-month ') + 1035 + (currentDate.isWeekend() ? 'weekend ' : 'weekday ') + 1036 + (thisMonth && currentDate.getTime() == today.getTime() ? 'today ' : '') 1037 + ) 1038 + .hover(doHover, unHover) 1039 + ; 1040 + if (s.renderCallback) { 1041 + s.renderCallback(d, currentDate, month, year); 1042 + } 1043 + r.append(d); 1044 + currentDate.addDays(1); 1045 + } 1046 + tbody.append(r); 1047 + } 1048 + calendarTable.append(tbody); 1049 + 1050 + return this.each( 1051 + function() 1052 + { 1053 + $(this).empty().append(calendarTable); 1054 + } 1055 + ); 1056 + }, 1057 +/** 1058 + * Create a datePicker associated with each of the matched elements. 1059 + * 1060 + * The matched element will receive a few custom events with the following signatures: 1061 + * 1062 + * dateSelected(event, date, $td, status) 1063 + * Triggered when a date is selected. event is a reference to the event, date is the Date selected, $td is a jquery object wrapped around the TD that was clicked on and status is whether the date was selected (true) or deselected (false) 1064 + * 1065 + * dpClosed(event, selected) 1066 + * Triggered when the date picker is closed. event is a reference to the event and selected is an Array containing Date objects. 1067 + * 1068 + * dpMonthChanged(event, displayedMonth, displayedYear) 1069 + * Triggered when the month of the popped up calendar is changed. event is a reference to the event, displayedMonth is the number of the month now displayed (zero based) and displayedYear is the year of the month. 1070 + * 1071 + * dpDisplayed(event, $datePickerDiv) 1072 + * Triggered when the date picker is created. $datePickerDiv is the div containing the date picker. Use this event to add custom content/ listeners to the popped up date picker. 1073 + * 1074 + * @param Object s (optional) Customize your date pickers. 1075 + * @option Number month The month to render when the date picker is opened (NOTE that months are zero based). Default is today's month. 1076 + * @option Number year The year to render when the date picker is opened. Default is today's year. 1077 + * @option String startDate The first date date can be selected. 1078 + * @option String endDate The last date that can be selected. 1079 + * @option Boolean inline Whether to create the datePicker as inline (e.g. always on the page) or as a model popup. Default is false (== modal popup) 1080 + * @option Boolean createButton Whether to create a .dp-choose-date anchor directly after the matched element which when clicked will trigger the showing of the date picker. Default is true. 1081 + * @option Boolean showYearNavigation Whether to display buttons which allow the user to navigate through the months a year at a time. Default is true. 1082 + * @option Boolean closeOnSelect Whether to close the date picker when a date is selected. Default is true. 1083 + * @option Boolean displayClose Whether to create a "Close" button within the date picker popup. Default is false. 1084 + * @option Boolean selectMultiple Whether a user should be able to select multiple dates with this date picker. Default is false. 1085 + * @option Boolean clickInput If the matched element is an input type="text" and this option is true then clicking on the input will cause the date picker to appear. 1086 + * @option Number verticalPosition The vertical alignment of the popped up date picker to the matched element. One of $.dpConst.POS_TOP and $.dpConst.POS_BOTTOM. Default is $.dpConst.POS_TOP. 1087 + * @option Number horizontalPosition The horizontal alignment of the popped up date picker to the matched element. One of $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT. 1088 + * @option Number verticalOffset The number of pixels offset from the defined verticalPosition of this date picker that it should pop up in. Default in 0. 1089 + * @option Number horizontalOffset The number of pixels offset from the defined horizontalPosition of this date picker that it should pop up in. Default in 0. 1090 + * @option (Function|Array) renderCallback A reference to a function (or an array of seperate functions) that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Each callback function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year. Default is no callback. 1091 + * @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class. 1092 + * @type jQuery 1093 + * @name datePicker 1094 + * @cat plugins/datePicker 1095 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1096 + * 1097 + * @example $('input.date-picker').datePicker(); 1098 + * @desc Creates a date picker button next to all matched input elements. When the button is clicked on the value of the selected date will be placed in the corresponding input (formatted according to Date.format). 1099 + * 1100 + * @example demo/index.html 1101 + * @desc See the projects homepage for many more complex examples... 1102 + **/ 1103 + datePicker : function(s) 1104 + { 1105 + if (!$.event._dpCache) $.event._dpCache = []; 1106 + 1107 + // initialise the date picker controller with the relevant settings... 1108 + s = $.extend( 1109 + { 1110 + month : undefined, 1111 + year : undefined, 1112 + startDate : undefined, 1113 + endDate : undefined, 1114 + inline : false, 1115 + renderCallback : [], 1116 + createButton : true, 1117 + showYearNavigation : true, 1118 + closeOnSelect : true, 1119 + displayClose : false, 1120 + selectMultiple : false, 1121 + clickInput : false, 1122 + verticalPosition : $.dpConst.POS_TOP, 1123 + horizontalPosition : $.dpConst.POS_LEFT, 1124 + verticalOffset : 0, 1125 + horizontalOffset : 0, 1126 + hoverClass : 'dp-hover' 1127 + } 1128 + , s 1129 + ); 1130 + 1131 + return this.each( 1132 + function() 1133 + { 1134 + var $this = $(this); 1135 + var alreadyExists = true; 1136 + 1137 + if (!this._dpId) { 1138 + this._dpId = $.event.guid++; 1139 + $.event._dpCache[this._dpId] = new DatePicker(this); 1140 + alreadyExists = false; 1141 + } 1142 + 1143 + if (s.inline) { 1144 + s.createButton = false; 1145 + s.displayClose = false; 1146 + s.closeOnSelect = false; 1147 + $this.empty(); 1148 + } 1149 + 1150 + var controller = $.event._dpCache[this._dpId]; 1151 + 1152 + controller.init(s); 1153 + 1154 + if (!alreadyExists && s.createButton) { 1155 + // create it! 1156 + controller.button = $('<a href="#" class="dp-choose-date" title="' + $.dpText.TEXT_CHOOSE_DATE + '">' + $.dpText.TEXT_CHOOSE_DATE + '</a>') 1157 + .bind( 1158 + 'click', 1159 + function() 1160 + { 1161 + $this.dpDisplay(this); 1162 + this.blur(); 1163 + return false; 1164 + } 1165 + ); 1166 + $this.after(controller.button); 1167 + } 1168 + 1169 + if (!alreadyExists && $this.is(':text')) { 1170 + $this 1171 + .bind( 1172 + 'dateSelected', 1173 + function(e, selectedDate, $td) 1174 + { 1175 + this.value = selectedDate.asString(); 1176 + } 1177 + ).bind( 1178 + 'change', 1179 + function() 1180 + { 1181 + var d = Date.fromString(this.value); 1182 + if (d) { 1183 + controller.setSelected(d, true, true); 1184 + } 1185 + } 1186 + ); 1187 + if (s.clickInput) { 1188 + $this.bind( 1189 + 'click', 1190 + function() 1191 + { 1192 + $this.dpDisplay(); 1193 + } 1194 + ); 1195 + } 1196 + var d = Date.fromString(this.value); 1197 + if (this.value != '' && d) { 1198 + controller.setSelected(d, true, true); 1199 + } 1200 + } 1201 + 1202 + $this.addClass('dp-applied'); 1203 + 1204 + } 1205 + ) 1206 + }, 1207 +/** 1208 + * Disables or enables this date picker 1209 + * 1210 + * @param Boolean s Whether to disable (true) or enable (false) this datePicker 1211 + * @type jQuery 1212 + * @name dpSetDisabled 1213 + * @cat plugins/datePicker 1214 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1215 + * 1216 + * @example $('.date-picker').datePicker(); 1217 + * $('.date-picker').dpSetDisabled(true); 1218 + * @desc Prevents this date picker from displaying and adds a class of dp-disabled to it (and it's associated button if it has one) for styling purposes. If the matched element is an input field then it will also set the disabled attribute to stop people directly editing the field. 1219 + **/ 1220 + dpSetDisabled : function(s) 1221 + { 1222 + return _w.call(this, 'setDisabled', s); 1223 + }, 1224 +/** 1225 + * Updates the first selectable date for any date pickers on any matched elements. 1226 + * 1227 + * @param String d A string representing the first selectable date (formatted according to Date.format). 1228 + * @type jQuery 1229 + * @name dpSetStartDate 1230 + * @cat plugins/datePicker 1231 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1232 + * 1233 + * @example $('.date-picker').datePicker(); 1234 + * $('.date-picker').dpSetStartDate('01/01/2000'); 1235 + * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the first selectable date for each of these to the first day of the millenium. 1236 + **/ 1237 + dpSetStartDate : function(d) 1238 + { 1239 + return _w.call(this, 'setStartDate', d); 1240 + }, 1241 +/** 1242 + * Updates the last selectable date for any date pickers on any matched elements. 1243 + * 1244 + * @param String d A string representing the last selectable date (formatted according to Date.format). 1245 + * @type jQuery 1246 + * @name dpSetEndDate 1247 + * @cat plugins/datePicker 1248 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1249 + * 1250 + * @example $('.date-picker').datePicker(); 1251 + * $('.date-picker').dpSetEndDate('01/01/2010'); 1252 + * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the last selectable date for each of these to the first Janurary 2010. 1253 + **/ 1254 + dpSetEndDate : function(d) 1255 + { 1256 + return _w.call(this, 'setEndDate', d); 1257 + }, 1258 +/** 1259 + * Gets a list of Dates currently selected by this datePicker. This will be an empty array if no dates are currently selected or NULL if there is no datePicker associated with the matched element. 1260 + * 1261 + * @type Array 1262 + * @name dpGetSelected 1263 + * @cat plugins/datePicker 1264 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1265 + * 1266 + * @example $('.date-picker').datePicker(); 1267 + * alert($('.date-picker').dpGetSelected()); 1268 + * @desc Will alert an empty array (as nothing is selected yet) 1269 + **/ 1270 + dpGetSelected : function() 1271 + { 1272 + var c = _getController(this[0]); 1273 + if (c) { 1274 + return c.getSelected(); 1275 + } 1276 + return null; 1277 + }, 1278 +/** 1279 + * Selects or deselects a date on any matched element's date pickers. Deselcting is only useful on date pickers where selectMultiple==true. Selecting will only work if the passed date is within the startDate and endDate boundries for a given date picker. 1280 + * 1281 + * @param String d A string representing the date you want to select (formatted according to Date.format). 1282 + * @param Boolean v Whether you want to select (true) or deselect (false) this date. Optional - default = true. 1283 + * @param Boolean m Whether you want the date picker to open up on the month of this date when it is next opened. Optional - default = true. 1284 + * @type jQuery 1285 + * @name dpSetSelected 1286 + * @cat plugins/datePicker 1287 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1288 + * 1289 + * @example $('.date-picker').datePicker(); 1290 + * $('.date-picker').dpSetSelected('01/01/2010'); 1291 + * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the selected date on these date pickers to the first Janurary 2010. When the date picker is next opened it will display Janurary 2010. 1292 + **/ 1293 + dpSetSelected : function(d, v, m) 1294 + { 1295 + if (v == undefined) v=true; 1296 + if (m == undefined) m=true; 1297 + return _w.call(this, 'setSelected', Date.fromString(d), v, m); 1298 + }, 1299 +/** 1300 + * Sets the month that will be displayed when the date picker is next opened. If the passed month is before startDate then the month containing startDate will be displayed instead. If the passed month is after endDate then the month containing the endDate will be displayed instead. 1301 + * 1302 + * @param Number m The month you want the date picker to display. Optional - defaults to the currently displayed month. 1303 + * @param Number y The year you want the date picker to display. Optional - defaults to the currently displayed year. 1304 + * @type jQuery 1305 + * @name dpSetDisplayedMonth 1306 + * @cat plugins/datePicker 1307 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1308 + * 1309 + * @example $('.date-picker').datePicker(); 1310 + * $('.date-picker').dpSetDisplayedMonth(10, 2008); 1311 + * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the selected date on these date pickers to the first Janurary 2010. When the date picker is next opened it will display Janurary 2010. 1312 + **/ 1313 + dpSetDisplayedMonth : function(m, y) 1314 + { 1315 + return _w.call(this, 'setDisplayedMonth', Number(m), Number(y)); 1316 + }, 1317 +/** 1318 + * Displays the date picker associated with the matched elements. Since only one date picker can be displayed at once then the date picker associated with the last matched element will be the one that is displayed. 1319 + * 1320 + * @param HTMLElement e An element that you want the date picker to pop up relative in position to. Optional - default behaviour is to pop up next to the element associated with this date picker. 1321 + * @type jQuery 1322 + * @name dpDisplay 1323 + * @cat plugins/datePicker 1324 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1325 + * 1326 + * @example $('#date-picker').datePicker(); 1327 + * $('#date-picker').dpDisplay(); 1328 + * @desc Creates a date picker associated with the element with an id of date-picker and then causes it to pop up. 1329 + **/ 1330 + dpDisplay : function(e) 1331 + { 1332 + return _w.call(this, 'display', e); 1333 + }, 1334 +/** 1335 + * Sets a function or array of functions that is called when each TD of the date picker popup is rendered to the page 1336 + * 1337 + * @param (Function|Array) a A function or an array of functions that are called when each td is rendered. Each function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year. 1338 + * @type jQuery 1339 + * @name dpSetRenderCallback 1340 + * @cat plugins/datePicker 1341 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1342 + * 1343 + * @example $('#date-picker').datePicker(); 1344 + * $('#date-picker').dpSetRenderCallback(function($td, thisDate, month, year) 1345 + * { 1346 + * // do stuff as each td is rendered dependant on the date in the td and the displayed month and year 1347 + * }); 1348 + * @desc Creates a date picker associated with the element with an id of date-picker and then creates a function which is called as each td is rendered when this date picker is displayed. 1349 + **/ 1350 + dpSetRenderCallback : function(a) 1351 + { 1352 + return _w.call(this, 'setRenderCallback', a); 1353 + }, 1354 +/** 1355 + * Sets the position that the datePicker will pop up (relative to it's associated element) 1356 + * 1357 + * @param Number v The vertical alignment of the created date picker to it's associated element. Possible values are $.dpConst.POS_TOP and $.dpConst.POS_BOTTOM 1358 + * @param Number h The horizontal alignment of the created date picker to it's associated element. Possible values are $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT 1359 + * @type jQuery 1360 + * @name dpSetPosition 1361 + * @cat plugins/datePicker 1362 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1363 + * 1364 + * @example $('#date-picker').datePicker(); 1365 + * $('#date-picker').dpSetPosition($.dpConst.POS_BOTTOM, $.dpConst.POS_RIGHT); 1366 + * @desc Creates a date picker associated with the element with an id of date-picker and makes it so that when this date picker pops up it will be bottom and right aligned to the #date-picker element. 1367 + **/ 1368 + dpSetPosition : function(v, h) 1369 + { 1370 + return _w.call(this, 'setPosition', v, h); 1371 + }, 1372 +/** 1373 + * Sets the offset that the popped up date picker will have from it's default position relative to it's associated element (as set by dpSetPosition) 1374 + * 1375 + * @param Number v The vertical offset of the created date picker. 1376 + * @param Number h The horizontal offset of the created date picker. 1377 + * @type jQuery 1378 + * @name dpSetOffset 1379 + * @cat plugins/datePicker 1380 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1381 + * 1382 + * @example $('#date-picker').datePicker(); 1383 + * $('#date-picker').dpSetOffset(-20, 200); 1384 + * @desc Creates a date picker associated with the element with an id of date-picker and makes it so that when this date picker pops up it will be 20 pixels above and 200 pixels to the right of it's default position. 1385 + **/ 1386 + dpSetOffset : function(v, h) 1387 + { 1388 + return _w.call(this, 'setOffset', v, h); 1389 + }, 1390 +/** 1391 + * Closes the open date picker associated with this element. 1392 + * 1393 + * @type jQuery 1394 + * @name dpClose 1395 + * @cat plugins/datePicker 1396 + * @author Kelvin Luck (http://www.kelvinluck.com/) 1397 + * 1398 + * @example $('.date-pick') 1399 + * .datePicker() 1400 + * .bind( 1401 + * 'focus', 1402 + * function() 1403 + * { 1404 + * $(this).dpDisplay(); 1405 + * } 1406 + * ).bind( 1407 + * 'blur', 1408 + * function() 1409 + * { 1410 + * $(this).dpClose(); 1411 + * } 1412 + * ); 1413 + * @desc Creates a date picker and makes it appear when the relevant element is focused and disappear when it is blurred. 1414 + **/ 1415 + dpClose : function() 1416 + { 1417 + return _w.call(this, '_closeCalendar', false, this[0]); 1418 + }, 1419 + // private function called on unload to clean up any expandos etc and prevent memory links... 1420 + _dpDestroy : function() 1421 + { 1422 + // TODO - implement this? 1423 + } 1424 + }); 1425 + 1426 + // private internal function to cut down on the amount of code needed where we forward 1427 + // dp* methods on the jQuery object on to the relevant DatePicker controllers... 1428 + var _w = function(f, a1, a2, a3) 1429 + { 1430 + return this.each( 1431 + function() 1432 + { 1433 + var c = _getController(this); 1434 + if (c) { 1435 + c[f](a1, a2, a3); 1436 + } 1437 + } 1438 + ); 1439 + }; 1440 + 1441 + function DatePicker(ele) 1442 + { 1443 + this.ele = ele; 1444 + 1445 + // initial values... 1446 + this.displayedMonth = null; 1447 + this.displayedYear = null; 1448 + this.startDate = null; 1449 + this.endDate = null; 1450 + this.showYearNavigation = null; 1451 + this.closeOnSelect = null; 1452 + this.displayClose = null; 1453 + this.selectMultiple = null; 1454 + this.verticalPosition = null; 1455 + this.horizontalPosition = null; 1456 + this.verticalOffset = null; 1457 + this.horizontalOffset = null; 1458 + this.button = null; 1459 + this.renderCallback = []; 1460 + this.selectedDates = {}; 1461 + this.inline = null; 1462 + this.context = '#dp-popup'; 1463 + }; 1464 + $.extend( 1465 + DatePicker.prototype, 1466 + { 1467 + init : function(s) 1468 + { 1469 + this.setStartDate(s.startDate); 1470 + this.setEndDate(s.endDate); 1471 + this.setDisplayedMonth(Number(s.month), Number(s.year)); 1472 + this.setRenderCallback(s.renderCallback); 1473 + this.showYearNavigation = s.showYearNavigation; 1474 + this.closeOnSelect = s.closeOnSelect; 1475 + this.displayClose = s.displayClose; 1476 + this.selectMultiple = s.selectMultiple; 1477 + this.verticalPosition = s.verticalPosition; 1478 + this.horizontalPosition = s.horizontalPosition; 1479 + this.hoverClass = s.hoverClass; 1480 + this.setOffset(s.verticalOffset, s.horizontalOffset); 1481 + this.inline = s.inline; 1482 + if (this.inline) { 1483 + this.context = this.ele; 1484 + this.display(); 1485 + } 1486 + }, 1487 + setStartDate : function(d) 1488 + { 1489 + if (d) { 1490 + this.startDate = Date.fromString(d); 1491 + } 1492 + if (!this.startDate) { 1493 + this.startDate = (new Date()).zeroTime(); 1494 + } 1495 + this.setDisplayedMonth(this.displayedMonth, this.displayedYear); 1496 + }, 1497 + setEndDate : function(d) 1498 + { 1499 + if (d) { 1500 + this.endDate = Date.fromString(d); 1501 + } 1502 + if (!this.endDate) { 1503 + this.endDate = (new Date('12/31/2999')); // using the JS Date.parse function which expects mm/dd/yyyy 1504 + } 1505 + if (this.endDate.getTime() < this.startDate.getTime()) { 1506 + this.endDate = this.startDate; 1507 + } 1508 + this.setDisplayedMonth(this.displayedMonth, this.displayedYear); 1509 + }, 1510 + setPosition : function(v, h) 1511 + { 1512 + this.verticalPosition = v; 1513 + this.horizontalPosition = h; 1514 + }, 1515 + setOffset : function(v, h) 1516 + { 1517 + this.verticalOffset = parseInt(v) || 0; 1518 + this.horizontalOffset = parseInt(h) || 0; 1519 + }, 1520 + setDisabled : function(s) 1521 + { 1522 + $e = $(this.ele); 1523 + $e[s ? 'addClass' : 'removeClass']('dp-disabled'); 1524 + if (this.button) { 1525 + $but = $(this.button); 1526 + $but[s ? 'addClass' : 'removeClass']('dp-disabled'); 1527 + $but.attr('title', s ? '' : $.dpText.TEXT_CHOOSE_DATE); 1528 + } 1529 + if ($e.is(':text')) { 1530 + $e.attr('disabled', s ? 'disabled' : ''); 1531 + } 1532 + }, 1533 + setDisplayedMonth : function(m, y) 1534 + { 1535 + if (this.startDate == undefined || this.endDate == undefined) { 1536 + return; 1537 + } 1538 + var s = new Date(this.startDate.getTime()); 1539 + s.setDate(1); 1540 + var e = new Date(this.endDate.getTime()); 1541 + e.setDate(1); 1542 + 1543 + var t; 1544 + if ((!m && !y) || (isNaN(m) && isNaN(y))) { 1545 + // no month or year passed - default to current month 1546 + t = new Date().zeroTime(); 1547 + t.setDate(1); 1548 + } else if (isNaN(m)) { 1549 + // just year passed in - presume we want the displayedMonth 1550 + t = new Date(y, this.displayedMonth, 1); 1551 + } else if (isNaN(y)) { 1552 + // just month passed in - presume we want the displayedYear 1553 + t = new Date(this.displayedYear, m, 1); 1554 + } else { 1555 + // year and month passed in - that's the date we want! 1556 + t = new Date(y, m, 1) 1557 + } 1558 + 1559 + // check if the desired date is within the range of our defined startDate and endDate 1560 + if (t.getTime() < s.getTime()) { 1561 + t = s; 1562 + } else if (t.getTime() > e.getTime()) { 1563 + t = e; 1564 + } 1565 + this.displayedMonth = t.getMonth(); 1566 + this.displayedYear = t.getFullYear(); 1567 + }, 1568 + setSelected : function(d, v, moveToMonth) 1569 + { 1570 + if (this.selectMultiple == false) { 1571 + this.selectedDates = {}; 1572 + $('td.selected', this.context).removeClass('selected'); 1573 + } 1574 + if (moveToMonth) { 1575 + this.setDisplayedMonth(d.getMonth(), d.getFullYear()); 1576 + } 1577 + this.selectedDates[d.toString()] = v; 1578 + }, 1579 + isSelected : function(d) 1580 + { 1581 + return this.selectedDates[d.toString()]; 1582 + }, 1583 + getSelected : function() 1584 + { 1585 + var r = []; 1586 + for(s in this.selectedDates) { 1587 + if (this.selectedDates[s] == true) { 1588 + r.push(Date.parse(s)); 1589 + } 1590 + } 1591 + return r; 1592 + }, 1593 + display : function(eleAlignTo) 1594 + { 1595 + if ($(this.ele).is('.dp-disabled')) return; 1596 + 1597 + eleAlignTo = eleAlignTo || this.ele; 1598 + var c = this; 1599 + var $ele = $(eleAlignTo); 1600 + var eleOffset = $ele.offset(); 1601 + 1602 + var $createIn; 1603 + var attrs; 1604 + var attrsCalendarHolder; 1605 + var cssRules; 1606 + 1607 + if (c.inline) { 1608 + $createIn = $(this.ele); 1609 + attrs = { 1610 + 'id' : 'calendar-' + this.ele._dpId, 1611 + 'className' : 'dp-popup dp-popup-inline' 1612 + }; 1613 + cssRules = { 1614 + }; 1615 + } else { 1616 + $createIn = $('body'); 1617 + attrs = { 1618 + 'id' : 'dp-popup', 1619 + 'className' : 'dp-popup' 1620 + }; 1621 + cssRules = { 1622 + 'top' : eleOffset.top + c.verticalOffset, 1623 + 'left' : eleOffset.left + c.horizontalOffset 1624 + }; 1625 + 1626 + var _checkMouse = function(e) 1627 + { 1628 + var el = e.target; 1629 + var cal = $('#dp-popup')[0]; 1630 + 1631 + while (true){ 1632 + if (el == cal) { 1633 + return true; 1634 + } else if (el == document) { 1635 + c._closeCalendar(); 1636 + return false; 1637 + } else { 1638 + el = $(el).parent()[0]; 1639 + } 1640 + } 1641 + }; 1642 + this._checkMouse = _checkMouse; 1643 + 1644 + this._closeCalendar(true); 1645 + } 1646 + 1647 + 1648 + $createIn 1649 + .append( 1650 + $('<div></div>') 1651 + .attr(attrs) 1652 + .css(cssRules) 1653 + .append( 1654 + $('<h2></h2>'), 1655 + $('<div class="dp-nav-prev"></div>') 1656 + .append( 1657 + $('<a class="dp-nav-prev-year" href="#" title="' + $.dpText.TEXT_PREV_YEAR + '"><<</a>') 1658 + .bind( 1659 + 'click', 1660 + function() 1661 + { 1662 + return c._displayNewMonth.call(c, this, 0, -1); 1663 + } 1664 + ), 1665 + $('<a class="dp-nav-prev-month" href="#" title="' + $.dpText.TEXT_PREV_MONTH + '"><</a>') 1666 + .bind( 1667 + 'click', 1668 + function() 1669 + { 1670 + return c._displayNewMonth.call(c, this, -1, 0); 1671 + } 1672 + ) 1673 + ), 1674 + $('<div class="dp-nav-next"></div>') 1675 + .append( 1676 + $('<a class="dp-nav-next-year" href="#" title="' + $.dpText.TEXT_NEXT_YEAR + '">>></a>') 1677 + .bind( 1678 + 'click', 1679 + function() 1680 + { 1681 + return c._displayNewMonth.call(c, this, 0, 1); 1682 + } 1683 + ), 1684 + $('<a class="dp-nav-next-month" href="#" title="' + $.dpText.TEXT_NEXT_MONTH + '">></a>') 1685 + .bind( 1686 + 'click', 1687 + function() 1688 + { 1689 + return c._displayNewMonth.call(c, this, 1, 0); 1690 + } 1691 + ) 1692 + ), 1693 + $('<div></div>') 1694 + .attr('className', 'dp-calendar') 1695 + ) 1696 + .bgIframe() 1697 + ); 1698 + 1699 + var $pop = this.inline ? $('.dp-popup', this.context) : $('#dp-popup'); 1700 + 1701 + if (this.showYearNavigation == false) { 1702 + $('.dp-nav-prev-year, .dp-nav-next-year', c.context).css('display', 'none'); 1703 + } 1704 + if (this.displayClose) { 1705 + $pop.append( 1706 + $('<a href="#" id="dp-close">' + $.dpText.TEXT_CLOSE + '</a>') 1707 + .bind( 1708 + 'click', 1709 + function() 1710 + { 1711 + c._closeCalendar(); 1712 + return false; 1713 + } 1714 + ) 1715 + ); 1716 + } 1717 + c._renderCalendar(); 1718 + 1719 + $(this.ele).trigger('dpDisplayed', $pop); 1720 + 1721 + if (!c.inline) { 1722 + if (this.verticalPosition == $.dpConst.POS_BOTTOM) { 1723 + $pop.css('top', eleOffset.top + $ele.height() - $pop.height() + c.verticalOffset); 1724 + } 1725 + if (this.horizontalPosition == $.dpConst.POS_RIGHT) { 1726 + $pop.css('left', eleOffset.left + $ele.width() - $pop.width() + c.horizontalOffset); 1727 + } 1728 + $(document).bind('mousedown', this._checkMouse); 1729 + } 1730 + }, 1731 + setRenderCallback : function(a) 1732 + { 1733 + if (a && typeof(a) == 'function') { 1734 + a = [a]; 1735 + } 1736 + this.renderCallback = this.renderCallback.concat(a); 1737 + }, 1738 + cellRender : function ($td, thisDate, month, year) { 1739 + var c = this.dpController; 1740 + var d = new Date(thisDate.getTime()); 1741 + 1742 + // add our click handlers to deal with it when the days are clicked... 1743 + 1744 + $td.bind( 1745 + 'click', 1746 + function() 1747 + { 1748 + var $this = $(this); 1749 + if (!$this.is('.disabled')) { 1750 + c.setSelected(d, !$this.is('.selected') || !c.selectMultiple); 1751 + var s = c.isSelected(d); 1752 + $(c.ele).trigger('dateSelected', [d, $td, s]); 1753 + $(c.ele).trigger('change'); 1754 + if (c.closeOnSelect) { 1755 + c._closeCalendar(); 1756 + } else { 1757 + $this[s ? 'addClass' : 'removeClass']('selected'); 1758 + } 1759 + } 1760 + } 1761 + ); 1762 + 1763 + if (c.isSelected(d)) { 1764 + $td.addClass('selected'); 1765 + } 1766 + 1767 + // call any extra renderCallbacks that were passed in 1768 + for (var i=0; i<c.renderCallback.length; i++) { 1769 + c.renderCallback[i].apply(this, arguments); 1770 + } 1771 + 1772 + 1773 + }, 1774 + // ele is the clicked button - only proceed if it doesn't have the class disabled... 1775 + // m and y are -1, 0 or 1 depending which direction we want to go in... 1776 + _displayNewMonth : function(ele, m, y) 1777 + { 1778 + if (!$(ele).is('.disabled')) { 1779 + this.setDisplayedMonth(this.displayedMonth + m, this.displayedYear + y); 1780 + this._clearCalendar(); 1781 + this._renderCalendar(); 1782 + $(this.ele).trigger('dpMonthChanged', [this.displayedMonth, this.displayedYear]); 1783 + } 1784 + ele.blur(); 1785 + return false; 1786 + }, 1787 + _renderCalendar : function() 1788 + { 1789 + // set the title... 1790 + $('h2', this.context).html(Date.monthNames[this.displayedMonth] + ' ' + this.displayedYear); 1791 + 1792 + // render the calendar... 1793 + $('.dp-calendar', this.context).renderCalendar( 1794 + { 1795 + month : this.displayedMonth, 1796 + year : this.displayedYear, 1797 + renderCallback : this.cellRender, 1798 + dpController : this, 1799 + hoverClass : this.hoverClass 1800 + } 1801 + ); 1802 + 1803 + // update the status of the control buttons and disable dates before startDate or after endDate... 1804 + // TODO: When should the year buttons be disabled? When you can't go forward a whole year from where you are or is that annoying? 1805 + if (this.displayedYear == this.startDate.getFullYear() && this.displayedMonth == this.startDate.getMonth()) { 1806 + $('.dp-nav-prev-year', this.context).addClass('disabled'); 1807 + $('.dp-nav-prev-month', this.context).addClass('disabled'); 1808 + $('.dp-calendar td.other-month', this.context).each( 1809 + function() 1810 + { 1811 + var $this = $(this); 1812 + if (Number($this.text()) > 20) { 1813 + $this.addClass('disabled'); 1814 + } 1815 + } 1816 + ); 1817 + var d = this.startDate.getDate(); 1818 + $('.dp-calendar td.current-month', this.context).each( 1819 + function() 1820 + { 1821 + var $this = $(this); 1822 + if (Number($this.text()) < d) { 1823 + $this.addClass('disabled'); 1824 + } 1825 + } 1826 + ); 1827 + } else { 1828 + $('.dp-nav-prev-year', this.context).removeClass('disabled'); 1829 + $('.dp-nav-prev-month', this.context).removeClass('disabled'); 1830 + var d = this.startDate.getDate(); 1831 + if (d > 20) { 1832 + // check if the startDate is last month as we might need to add some disabled classes... 1833 + var sd = new Date(this.startDate.getTime()); 1834 + sd.addMonths(1); 1835 + if (this.displayedYear == sd.getFullYear() && this.displayedMonth == sd.getMonth()) { 1836 + $('dp-calendar td.other-month', this.context).each( 1837 + function() 1838 + { 1839 + var $this = $(this); 1840 + if (Number($this.text()) < d) { 1841 + $this.addClass('disabled'); 1842 + } 1843 + } 1844 + ); 1845 + } 1846 + } 1847 + } 1848 + if (this.displayedYear == this.endDate.getFullYear() && this.displayedMonth == this.endDate.getMonth()) { 1849 + $('.dp-nav-next-year', this.context).addClass('disabled'); 1850 + $('.dp-nav-next-month', this.context).addClass('disabled'); 1851 + $('.dp-calendar td.other-month', this.context).each( 1852 + function() 1853 + { 1854 + var $this = $(this); 1855 + if (Number($this.text()) < 14) { 1856 + $this.addClass('disabled'); 1857 + } 1858 + } 1859 + ); 1860 + var d = this.endDate.getDate(); 1861 + $('.dp-calendar td.current-month', this.context).each( 1862 + function() 1863 + { 1864 + var $this = $(this); 1865 + if (Number($this.text()) > d) { 1866 + $this.addClass('disabled'); 1867 + } 1868 + } 1869 + ); 1870 + } else { 1871 + $('.dp-nav-next-year', this.context).removeClass('disabled'); 1872 + $('.dp-nav-next-month', this.context).removeClass('disabled'); 1873 + var d = this.endDate.getDate(); 1874 + if (d < 13) { 1875 + // check if the endDate is next month as we might need to add some disabled classes... 1876 + var ed = new Date(this.endDate.getTime()); 1877 + ed.addMonths(-1); 1878 + if (this.displayedYear == ed.getFullYear() && this.displayedMonth == ed.getMonth()) { 1879 + $('.dp-calendar td.other-month', this.context).each( 1880 + function() 1881 + { 1882 + var $this = $(this); 1883 + if (Number($this.text()) > d) { 1884 + $this.addClass('disabled'); 1885 + } 1886 + } 1887 + ); 1888 + } 1889 + } 1890 + } 1891 + }, 1892 + _closeCalendar : function(programatic, ele) 1893 + { 1894 + if (!ele || ele == this.ele) 1895 + { 1896 + $(document).unbind('mousedown', this._checkMouse); 1897 + this._clearCalendar(); 1898 + $('#dp-popup a').unbind(); 1899 + $('#dp-popup').empty().remove(); 1900 + if (!programatic) { 1901 + $(this.ele).trigger('dpClosed', [this.getSelected()]); 1902 + } 1903 + } 1904 + }, 1905 + // empties the current dp-calendar div and makes sure that all events are unbound 1906 + // and expandos removed to avoid memory leaks... 1907 + _clearCalendar : function() 1908 + { 1909 + // TODO. 1910 + $('.dp-calendar td', this.context).unbind(); 1911 + $('.dp-calendar', this.context).empty(); 1912 + } 1913 + } 1914 + ); 1915 + 1916 + // static constants 1917 + $.dpConst = { 1918 + SHOW_HEADER_NONE : 0, 1919 + SHOW_HEADER_SHORT : 1, 1920 + SHOW_HEADER_LONG : 2, 1921 + POS_TOP : 0, 1922 + POS_BOTTOM : 1, 1923 + POS_LEFT : 0, 1924 + POS_RIGHT : 1 1925 + }; 1926 + // localisable text 1927 + $.dpText = { 1928 + TEXT_PREV_YEAR : 'Previous year', 1929 + TEXT_PREV_MONTH : 'Previous month', 1930 + TEXT_NEXT_YEAR : 'Next year', 1931 + TEXT_NEXT_MONTH : 'Next month', 1932 + TEXT_CLOSE : 'Close', 1933 + TEXT_CHOOSE_DATE : 'Choose date' 1934 + }; 1935 + // version 1936 + $.dpVersion = '$Id: jquery.datePicker.js 3739 2007-10-25 13:55:30Z kelvin.luck $'; 1937 + 1938 + function _getController(ele) 1939 + { 1940 + if (ele._dpId) return $.event._dpCache[ele._dpId]; 1941 + return false; 1942 + }; 1943 + 1944 + // make it so that no error is thrown if bgIframe plugin isn't included (allows you to use conditional 1945 + // comments to only include bgIframe where it is needed in IE without breaking this plugin). 1946 + if ($.fn.bgIframe == undefined) { 1947 + $.fn.bgIframe = function() {return this; }; 1948 + }; 1949 + 1950 + 1951 + // clean-up 1952 + $(window) 1953 + .bind('unload', function() { 1954 + var els = $.event._dpCache || []; 1955 + for (var i in els) { 1956 + $(els[i].ele)._dpDestroy(); 1957 + } 1958 + }); 1959 + 1960 + 1961 +})(jQuery); 1962 Index: trac/htdocs/css/datePicker.css 1963 =================================================================== 1964 --- trac/htdocs/css/datePicker.css (revision 0) 1965 +++ trac/htdocs/css/datePicker.css (revision 0) 1966 @@ -0,0 +1,140 @@ 1967 + 1968 + 1969 +table.jCalendar { 1970 + border: 1px solid #000; 1971 + background: #aaa; 1972 + border-collapse: separate; 1973 + border-spacing: 2px; 1974 +} 1975 +table.jCalendar th { 1976 + background: #333; 1977 + color: #fff; 1978 + font-weight: bold; 1979 + padding: 3px 5px; 1980 +} 1981 +table.jCalendar td { 1982 + background: #ccc; 1983 + color: #000; 1984 + padding: 3px 5px; 1985 + text-align: center; 1986 +} 1987 +table.jCalendar td.other-month { 1988 + background: #ddd; 1989 + color: #aaa; 1990 +} 1991 +table.jCalendar td.today { 1992 + background: #666; 1993 + color: #fff; 1994 +} 1995 +table.jCalendar td.selected { 1996 + background: #f66; 1997 + color: #fff; 1998 +} 1999 +table.jCalendar td.selected:hover { 2000 + background: #f33; 2001 + color: #fff; 2002 +} 2003 +table.jCalendar td:hover, table.jCalendar td.dp-hover { 2004 + background: #fff; 2005 + color: #000; 2006 +} 2007 +table.jCalendar td.disabled, table.jCalendar td.disabled:hover { 2008 + background: #bbb; 2009 + color: #888; 2010 +} 2011 + 2012 +/* For the popup */ 2013 + 2014 +/* NOTE - you will probably want to style a.dp-choose-date - see how I did it in demo.css */ 2015 + 2016 +div.dp-popup { 2017 + position: relative; 2018 + background: #ccc; 2019 + font-size: 10px; 2020 + font-family: arial, sans-serif; 2021 + padding: 2px; 2022 + width: 171px; 2023 + line-height: 1.2em; 2024 +} 2025 +div#dp-popup { 2026 + position: absolute; 2027 + z-index: 199; 2028 +} 2029 +div.dp-popup h2 { 2030 + font-size: 12px; 2031 + text-align: center; 2032 + margin: 2px 0; 2033 + padding: 0; 2034 +} 2035 +a#dp-close { 2036 + font-size: 11px; 2037 + padding: 4px 0; 2038 + text-align: center; 2039 + display: block; 2040 +} 2041 +a#dp-close:hover { 2042 + text-decoration: underline; 2043 +} 2044 +div.dp-popup a { 2045 + color: #000; 2046 + text-decoration: none; 2047 + padding: 3px 2px 0; 2048 +} 2049 +div.dp-popup div.dp-nav-prev { 2050 + position: absolute; 2051 + top: 2px; 2052 + left: 4px; 2053 + width: 100px; 2054 +} 2055 +div.dp-popup div.dp-nav-prev a { 2056 + float: left; 2057 +} 2058 +/* Opera needs the rules to be this specific otherwise it doesn't change the cursor back to pointer after you have disabled and re-enabled a link */ 2059 +div.dp-popup div.dp-nav-prev a, div.dp-popup div.dp-nav-next a { 2060 + cursor: pointer; 2061 +} 2062 +div.dp-popup div.dp-nav-prev a.disabled, div.dp-popup div.dp-nav-next a.disabled { 2063 + cursor: default; 2064 +} 2065 +div.dp-popup div.dp-nav-next { 2066 + position: absolute; 2067 + top: 2px; 2068 + right: 4px; 2069 + width: 100px; 2070 +} 2071 +div.dp-popup div.dp-nav-next a { 2072 + float: right; 2073 +} 2074 +div.dp-popup a.disabled { 2075 + cursor: default; 2076 + color: #aaa; 2077 +} 2078 +div.dp-popup td { 2079 + cursor: pointer; 2080 +} 2081 +div.dp-popup td.disabled { 2082 + cursor: default; 2083 +} 2084 + 2085 +a.dp-choose-date { 2086 + float: left; 414 2087 + width: 16px; 415 2088 + height: 16px; 416 + border: none;417 + color: #fff;418 2089 + padding: 0; 419 + margin: 0; 2090 + margin: 5px 3px 0; 2091 + display: block; 2092 + text-indent: -2000px; 2093 + overflow: hidden; 2094 + background: url(../calendar.png) no-repeat; 2095 +} 2096 +a.dp-choose-date.dp-disabled { 2097 + background-position: 0 -20px; 2098 + cursor: default; 2099 +} 2100 +/* makes the input field shorter once the date picker code 2101 + * has run (to allow space for the calendar icon 2102 + */ 2103 +input.dp-applied { 2104 + width: 140px; 420 2105 + float: left; 421 + overflow: hidden; 422 + cursor: pointer; 423 + background: url(../calendar.png) no-repeat; 424 +} 425 +a.date-picker span { 426 + margin: 0 0 0 -2000px; 427 +} 428 +div.date-picker-holder, div.date-picker-holder * { 429 + margin: 0; 430 + padding: 0; 431 +} 432 +div.date-picker-holder { 433 + position: relative; 434 +} 435 +div.date-picker-holder input { 436 + float: left; 437 +} 438 +div.popup-calendar { 439 + display: none; 440 + position: absolute; 441 + z-index: 2; 442 + top: 0; 443 + left: -16px; /* value for IE */ 444 + padding: 4px; 445 + border: 2px solid #000; 446 + background: #fff; 447 + color: #000; 448 + overflow:hidden; 449 + width: 163px; 450 +} 451 +html>body div.popup-calendar { 452 + left: 99px; /* value for decent browsers */ 453 +} 454 +div.popup-calendar div.link-close { 455 + float: right; 456 +} 457 +div.popup-calendar div.link-prev { 458 + float: left; 459 +} 460 +div.popup-calendar h3 { 461 + font-size: 1.3em; 462 + margin: 2px 0 5px 3px; 463 +} 464 +div.popup-calendar div.link-next { 465 + float: right; 466 +} 467 +div.popup-calendar div a { 468 + padding: 1px 2px; 469 + color: #000; 470 +} 471 +div.popup-calendar div a:hover { 472 + background-color: #000; 473 + color: #fff; 474 +} 475 +div.popup-calendar table { 476 + margin: 0; 477 +} 478 +* html div.popup-calendar table { 479 + display: inline; 480 +} 481 +div.popup-calendar table th, div.popup-calendar table td { 482 + background: #eee; 483 + width: 21px; 484 + height: 17px; 485 + text-align: center; 486 +} 487 +div.popup-calendar table td.inactive { 488 + color: #aaa; 489 + padding: 1px 0 0; 490 +} 491 +div.popup-calendar table th.weekend, div.popup-calendar table td.weekend { 492 + background: #f6f6f6; 493 +} 494 +div.popup-calendar table td a { 495 + display: block; 496 + border: 1px solid #eee; 497 + width: 19px; 498 + height: 15px; 499 + text-decoration: none; 500 + color: #333; 501 +} 502 +div.popup-calendar table td.today a { 503 + border-color: #aaa; 504 +} 505 +div.popup-calendar table td a.selected, div.popup-calendar table td a:hover { 506 + background: #333; 507 + color: #fff; 508 +} 509 Index: oforge/vendor/trac/trac/htdocs/calendar.png 2106 +} 2107 Index: trac/htdocs/calendar.png 510 2108 =================================================================== 511 2109 Cannot display: file marked as a binary type. 512 2110 svn:mime-type = application/octet-stream 513 2111 514 Property changes on: oforge/vendor/trac/trac/htdocs/calendar.png2112 Property changes on: trac/htdocs/calendar.png 515 2113 ___________________________________________________________________ 516 2114 Added: svn:mime-type
Note: See TracChangeset
for help on using the changeset viewer.
