Skip to content

Commit 9b805a9

Browse files
committed
Custom fields with multiple fields seem to be working
@mrdale, care for a spin?
1 parent 87b6257 commit 9b805a9

File tree

5 files changed

+85
-61
lines changed

5 files changed

+85
-61
lines changed

glz_custom_fields.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,18 @@
2222
$plugin['order'] = '9';
2323

2424
// Plugin 'type' defines where the plugin is loaded
25-
// 0 = public : only on the public side of the website (default)
26-
// 1 = public+admin : on both the public and admin side
27-
// 2 = library : only when include_plugin() or require_plugin() is called
28-
// 3 = admin : only on the admin side
29-
$plugin['type'] = '1';
25+
// http://forum.textpattern.com/viewtopic.php?id=38434
26+
// -----------------------------------------------------------------------
27+
// | plugin type | public | admin (synchronous) | library | admin (ajax) |
28+
// -----------------------------------------------------------------------
29+
// | 0 | yes | | | |
30+
// | 1 | yes | yes | | |
31+
// | 2 | | | yes | |
32+
// | 3 | | yes | | |
33+
// | 4 | | yes | | yes |
34+
// | 5 | yes | yes | | yes |
35+
// -----------------------------------------------------------------------
36+
$plugin['type'] = '5';
3037

3138
// 0 = Plugin help is in Textile format, no raw HTML allowed (default).
3239
// 1 = Plugin help is in raw HTML. Not recommended.
137 Bytes
Binary file not shown.
-38 Bytes
Binary file not shown.

releases/glz_custom_fields/jquery.datePicker/datePicker.css

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
table.jCalendar {
24
border: 1px solid #000;
35
background: #aaa;
@@ -124,29 +126,4 @@ div.dp-popup td {
124126
}
125127
div.dp-popup td.disabled {
126128
cursor: default;
127-
}
128-
129-
130-
131-
a.dp-choose-date {
132-
float: left;
133-
width: 16px;
134-
height: 16px;
135-
padding: 0;
136-
margin: 5px 3px 0;
137-
display: block;
138-
text-indent: -2000px;
139-
overflow: hidden;
140-
background: url(calendar.png) no-repeat;
141-
}
142-
a.dp-choose-date.dp-disabled {
143-
background-position: 0 -20px;
144-
cursor: default;
145-
}
146-
/* makes the input field shorter once the date picker code
147-
* has run (to allow space for the calendar icon
148-
*/
149-
td#article-col-1 input.dp-applied {
150-
width: 139px;
151-
float: left;
152-
}
129+
}

releases/glz_custom_fields/jquery.datePicker/datePicker.js

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
* Copyright (c) 2008 Kelvin Luck (http://www.kelvinluck.com/)
33
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
44
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
5-
*
6-
* $Id: jquery.datePicker.js 70 2009-04-05 19:25:15Z kelvin.luck $
5+
* .
6+
* $Id$
7+
* http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/
78
**/
89

910
(function($){
@@ -84,11 +85,12 @@
8485
var tbody = $(dc('tbody'));
8586

8687
var today = (new Date()).zeroTime();
88+
today.setHours(12);
8789

8890
var month = s.month == undefined ? today.getMonth() : s.month;
8991
var year = s.year || today.getFullYear();
9092

91-
var currentDate = new Date(year, month, 1);
93+
var currentDate = (new Date(year, month, 1, 12, 0, 0));
9294

9395

9496
var firstDayOffset = Date.firstDayOfWeek - currentDate.getDay() + 1;
@@ -140,7 +142,8 @@
140142
}
141143
// addDays(1) fails in some locales due to daylight savings. See issue 39.
142144
//currentDate.addDays(1);
143-
currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1);
145+
// set the time to midday to avoid any weird timezone issues??
146+
currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 12, 0, 0);
144147
}
145148
tbody.append(r);
146149
}
@@ -173,8 +176,8 @@
173176
* @param Object s (optional) Customize your date pickers.
174177
* @option Number month The month to render when the date picker is opened (NOTE that months are zero based). Default is today's month.
175178
* @option Number year The year to render when the date picker is opened. Default is today's year.
176-
* @option String startDate The first date date can be selected.
177-
* @option String endDate The last date that can be selected.
179+
* @option String|Date startDate The first date date can be selected.
180+
* @option String|Date endDate The last date that can be selected.
178181
* @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)
179182
* @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.
180183
* @option Boolean showYearNavigation Whether to display buttons which allow the user to navigate through the months a year at a time. Default is true.
@@ -189,8 +192,9 @@
189192
* @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.
190193
* @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.
191194
* @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.
192-
* @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.
195+
* @option (Function|Array) renderCallback A reference to a function (or an array of separate 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.
193196
* @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.
197+
* @option String autoFocusNextInput Whether focus should be passed onto the next input in the form (true) or remain on this input (false) when a date is selected and the calendar closes
194198
* @type jQuery
195199
* @name datePicker
196200
* @cat plugins/datePicker
@@ -216,7 +220,7 @@
216220
var alreadyExists = true;
217221

218222
if (!this._dpId) {
219-
this._dpId = $.event.guid++;
223+
this._dpId = $.guid++;
220224
$.event._dpCache[this._dpId] = new DatePicker(this);
221225
alreadyExists = false;
222226
}
@@ -311,7 +315,7 @@
311315
/**
312316
* Updates the first selectable date for any date pickers on any matched elements.
313317
*
314-
* @param String d A string representing the first selectable date (formatted according to Date.format).
318+
* @param String|Date d A Date object or string representing the first selectable date (formatted according to Date.format).
315319
* @type jQuery
316320
* @name dpSetStartDate
317321
* @cat plugins/datePicker
@@ -328,7 +332,7 @@
328332
/**
329333
* Updates the last selectable date for any date pickers on any matched elements.
330334
*
331-
* @param String d A string representing the last selectable date (formatted according to Date.format).
335+
* @param String|Date d A Date object or string representing the last selectable date (formatted according to Date.format).
332336
* @type jQuery
333337
* @name dpSetEndDate
334338
* @cat plugins/datePicker
@@ -365,7 +369,7 @@
365369
/**
366370
* 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.
367371
*
368-
* @param String d A string representing the date you want to select (formatted according to Date.format).
372+
* @param String|Date d A Date object or string representing the date you want to select (formatted according to Date.format).
369373
* @param Boolean v Whether you want to select (true) or deselect (false) this date. Optional - default = true.
370374
* @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.
371375
* @param Boolean e Whether you want the date picker to dispatch events related to this change of selection. Optional - default = true.
@@ -499,12 +503,24 @@
499503
* $(this).dpClose();
500504
* }
501505
* );
502-
* @desc Creates a date picker and makes it appear when the relevant element is focused and disappear when it is blurred.
503506
**/
504507
dpClose : function()
505508
{
506509
return _w.call(this, '_closeCalendar', false, this[0]);
507510
},
511+
/**
512+
* Rerenders the date picker's current month (for use with inline calendars and renderCallbacks).
513+
*
514+
* @type jQuery
515+
* @name dpRerenderCalendar
516+
* @cat plugins/datePicker
517+
* @author Kelvin Luck (http://www.kelvinluck.com/)
518+
*
519+
**/
520+
dpRerenderCalendar : function()
521+
{
522+
return _w.call(this, '_rerenderCalendar');
523+
},
508524
// private function called on unload to clean up any expandos etc and prevent memory links...
509525
_dpDestroy : function()
510526
{
@@ -584,7 +600,11 @@
584600
setStartDate : function(d)
585601
{
586602
if (d) {
587-
this.startDate = Date.fromString(d);
603+
if (d instanceof Date) {
604+
this.startDate = d;
605+
} else {
606+
this.startDate = Date.fromString(d);
607+
}
588608
}
589609
if (!this.startDate) {
590610
this.startDate = (new Date()).zeroTime();
@@ -594,7 +614,11 @@
594614
setEndDate : function(d)
595615
{
596616
if (d) {
597-
this.endDate = Date.fromString(d);
617+
if (d instanceof Date) {
618+
this.endDate = d;
619+
} else {
620+
this.endDate = Date.fromString(d);
621+
}
598622
}
599623
if (!this.endDate) {
600624
this.endDate = (new Date('12/31/2999')); // using the JS Date.parse function which expects mm/dd/yyyy
@@ -671,7 +695,7 @@
671695
},
672696
setSelected : function(d, v, moveToMonth, dispatchEvents)
673697
{
674-
if (d < this.startDate || d > this.endDate) {
698+
if (d < this.startDate || d.zeroTime() > this.endDate.zeroTime()) {
675699
// Don't allow people to select dates outside range...
676700
return;
677701
}
@@ -697,9 +721,9 @@
697721
if (moveToMonth && (this.displayedMonth != d.getMonth() || this.displayedYear != d.getFullYear())) {
698722
this.setDisplayedMonth(d.getMonth(), d.getFullYear(), true);
699723
}
700-
this.selectedDates[d.toString()] = v;
724+
this.selectedDates[d.asString()] = v;
701725
this.numSelected += v ? 1 : -1;
702-
var selectorString = 'td.' +( d.getMonth() == this.displayedMonth ? 'current-month' : 'other-month');
726+
var selectorString = 'td.' + (d.getMonth() == this.displayedMonth ? 'current-month' : 'other-month');
703727
var $td;
704728
$(selectorString, this.context).each(
705729
function()
@@ -727,14 +751,14 @@
727751
},
728752
isSelected : function(d)
729753
{
730-
return this.selectedDates[d.toString()];
754+
return this.selectedDates[d.asString()];
731755
},
732756
getSelected : function()
733757
{
734758
var r = [];
735-
for(s in this.selectedDates) {
759+
for(var s in this.selectedDates) {
736760
if (this.selectedDates[s] == true) {
737-
r.push(Date.parse(s));
761+
r.push(Date.fromString(s));
738762
}
739763
}
740764
return r;
@@ -926,18 +950,32 @@
926950
if (!$this.is('.disabled')) {
927951
c.setSelected(d, !$this.is('.selected') || !c.selectMultiple, false, true);
928952
if (c.closeOnSelect) {
953+
// Focus the next input in the form…
954+
if (c.settings.autoFocusNextInput) {
955+
var ele = c.ele;
956+
var found = false;
957+
$(':input', ele.form).each(
958+
function()
959+
{
960+
if (found) {
961+
$(this).focus();
962+
return false;
963+
}
964+
if (this == ele) {
965+
found = true;
966+
}
967+
}
968+
);
969+
} else {
970+
try {
971+
c.ele.focus();
972+
} catch (e) {}
973+
}
929974
c._closeCalendar();
930975
}
931-
// TODO: Instead of this which doesn't work in IE anyway we should find the next focusable element in the document
932-
// and pass the focus onto that. That would allow the user to continue on the form as expected...
933-
if (!$.browser.msie)
934-
{
935-
$(c.ele).trigger('focus', [$.dpConst.DP_INTERNAL_FOCUS]);
936-
}
937976
}
938977
}
939978
);
940-
941979
if (c.isSelected(d)) {
942980
$td.addClass('selected');
943981
if (c.settings.selectWeek)
@@ -1078,7 +1116,8 @@
10781116
function()
10791117
{
10801118
var $this = $(this);
1081-
if (Number($this.text()) > d) {
1119+
var cellDay = Number($this.text());
1120+
if (cellDay < 13 && cellDay > d) {
10821121
$this.addClass('disabled');
10831122
}
10841123
}
@@ -1135,7 +1174,7 @@
11351174
HEADER_FORMAT : 'mmmm yyyy'
11361175
};
11371176
// version
1138-
$.dpVersion = '$Id: jquery.datePicker.js 70 2009-04-05 19:25:15Z kelvin.luck $';
1177+
$.dpVersion = '$Id$';
11391178

11401179
$.fn.datePicker.defaults = {
11411180
month : undefined,
@@ -1158,7 +1197,8 @@
11581197
horizontalPosition : $.dpConst.POS_LEFT,
11591198
verticalOffset : 0,
11601199
horizontalOffset : 0,
1161-
hoverClass : 'dp-hover'
1200+
hoverClass : 'dp-hover',
1201+
autoFocusNextInput : false
11621202
};
11631203

11641204
function _getController(ele)

0 commit comments

Comments
 (0)