forked from 0x2620/oxjs
some fixes for filters and form elements
This commit is contained in:
parent
842d536dc8
commit
3f3edac8c7
9 changed files with 113 additions and 79 deletions
|
|
@ -7,17 +7,21 @@ Ox.DateInput <f:Ox.Element> DateInput Element
|
|||
(options, self) -> <f> DateInput Element
|
||||
options <o> Options object
|
||||
format <s|short> format can be short, medium, long
|
||||
value <d> date value, defaults to now
|
||||
value <d> date value, defaults to current date
|
||||
weekday <b|false> weekday
|
||||
width: <o> width object with day, month, weekday, year width
|
||||
width <o> width of individual input elements, in px
|
||||
day <n> width of day input element
|
||||
month <n> width of month input element
|
||||
weekday <n> width of weekday input element
|
||||
year <n> width of year input element
|
||||
self <o> Shared private variable
|
||||
change <!> triggered on change of value
|
||||
@*/
|
||||
Ox.DateInput = function(options, self) {
|
||||
|
||||
var that;
|
||||
self = $.extend(self || {}, {
|
||||
options: $.extend({
|
||||
self = Ox.extend(self || {}, {
|
||||
options: Ox.extend({
|
||||
format: 'short',
|
||||
value: Ox.formatDate(new Date(), '%F'),
|
||||
weekday: false,
|
||||
|
|
@ -30,7 +34,7 @@ Ox.DateInput = function(options, self) {
|
|||
}, options)
|
||||
});
|
||||
|
||||
$.extend(self, {
|
||||
Ox.extend(self, {
|
||||
date: new Date(self.options.value.replace(/-/g, '/')),
|
||||
formats: {
|
||||
day: '%d',
|
||||
|
|
@ -59,11 +63,11 @@ Ox.DateInput = function(options, self) {
|
|||
.bindEvent('autocomplete', changeWeekday),
|
||||
} : {}, {
|
||||
day: Ox.Input({
|
||||
autocomplete: $.map(Ox.range(1, Ox.getDaysInMonth(
|
||||
autocomplete: Ox.range(1, Ox.getDaysInMonth(
|
||||
parseInt(Ox.formatDate(self.date, '%Y'), 10),
|
||||
parseInt(Ox.formatDate(self.date, '%m'), 10)
|
||||
) + 1), function(v, i) {
|
||||
return self.options.format == 'short' ? Ox.pad(v, 2) : v.toString();
|
||||
) + 1).map(function(i) {
|
||||
return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
|
||||
}),
|
||||
autocompleteReplace: true,
|
||||
autocompleteReplaceCorrect: true,
|
||||
|
|
@ -99,16 +103,16 @@ Ox.DateInput = function(options, self) {
|
|||
.bindEvent('autocomplete', changeMonthOrYear)
|
||||
});
|
||||
|
||||
that = Ox.InputGroup($.extend(self.options, {
|
||||
that = Ox.InputGroup(Ox.extend(self.options, {
|
||||
id: self.options.id,
|
||||
inputs: $.merge(self.options.weekday ? [
|
||||
inputs: Ox.merge(self.options.weekday ? [
|
||||
self.$input.weekday
|
||||
] : [], self.options.format == 'short' ? [
|
||||
self.$input.year, self.$input.month, self.$input.day
|
||||
] : [
|
||||
self.$input.month, self.$input.day, self.$input.year
|
||||
]),
|
||||
separators: $.merge(self.options.weekday ? [
|
||||
separators: Ox.merge(self.options.weekday ? [
|
||||
{title: self.options.format == 'short' ? '' : ',', width: 8},
|
||||
] : [], self.options.format == 'short' ? [
|
||||
{title: '-', width: 8}, {title: '-', width: 8}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue