forked from 0x2620/oxjs
form elements rewrite, part 2
This commit is contained in:
parent
fe303bf2b0
commit
074902d079
33 changed files with 163 additions and 153 deletions
|
|
@ -115,26 +115,29 @@ Ox.DateInput = function(options, self) {
|
|||
}), self);
|
||||
|
||||
function changeDay() {
|
||||
self.options.weekday && self.$input.weekday.options({
|
||||
value: Ox.formatDate(new Date([
|
||||
self.$input.month.options('value'),
|
||||
self.$input.day.options('value'),
|
||||
self.$input.year.options('value')
|
||||
self.options.weekday && self.$input.weekday.value(
|
||||
Ox.formatDate(new Date([
|
||||
self.$input.month.value(),
|
||||
self.$input.day.value(),
|
||||
self.$input.year.value()
|
||||
].join(' ')), self.formats.weekday)
|
||||
});
|
||||
);
|
||||
self.options.value = join();
|
||||
}
|
||||
|
||||
function changeMonthOrYear() {
|
||||
var day = self.$input.day.options('value'),
|
||||
month = self.$input.month.options('value'),
|
||||
year = self.$input.year.options('value'),
|
||||
var day = self.$input.day.value(),
|
||||
month = self.$input.month.value(),
|
||||
year = self.$input.year.value(),
|
||||
days = Ox.getDaysInMonth(year, self.options.format == 'short' ? parseInt(month, 10) : month);
|
||||
day = day <= days ? day : days;
|
||||
//Ox.Log('Form', year, month, 'day days', day, days)
|
||||
self.options.weekday && self.$input.weekday.options({
|
||||
value: Ox.formatDate(new Date([month, day, year].join(' ')), self.formats.weekday)
|
||||
});
|
||||
self.options.weekday && self.$input.weekday.value(
|
||||
Ox.formatDate(
|
||||
new Date([month, day, year].join(' ')),
|
||||
self.formats.weekday
|
||||
)
|
||||
);
|
||||
self.$input.day.options({
|
||||
autocomplete: Ox.range(1, days + 1).map(function(i) {
|
||||
return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
|
||||
|
|
@ -146,21 +149,20 @@ Ox.DateInput = function(options, self) {
|
|||
|
||||
function changeWeekday() {
|
||||
var date = getDateInWeek(
|
||||
self.$input.weekday.options('value'),
|
||||
self.$input.month.options('value'),
|
||||
self.$input.day.options('value'),
|
||||
self.$input.year.options('value')
|
||||
self.$input.weekday.value(),
|
||||
self.$input.month.value(),
|
||||
self.$input.day.value(),
|
||||
self.$input.year.value()
|
||||
);
|
||||
self.$input.month.options({value: date.month});
|
||||
self.$input.month.value(date.month);
|
||||
self.$input.day.options({
|
||||
autocomplete: Ox.range(1, Ox.getDaysInMonth(date.year, date.month) + 1).map(function(i) {
|
||||
return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
|
||||
}),
|
||||
value: date.day
|
||||
});
|
||||
self.$input.year.options({value: date.year});
|
||||
self.$input.year.value(date.year);
|
||||
self.options.value = join();
|
||||
Ox.print('self.options.value =', self.options.value)
|
||||
}
|
||||
|
||||
function getDate(value) {
|
||||
|
|
@ -190,13 +192,13 @@ Ox.DateInput = function(options, self) {
|
|||
|
||||
function join() {
|
||||
return Ox.formatDate(new Date(self.options.format == 'short' ? [
|
||||
self.$input.year.options('value'),
|
||||
self.$input.month.options('value'),
|
||||
self.$input.day.options('value')
|
||||
self.$input.year.value(),
|
||||
self.$input.month.value(),
|
||||
self.$input.day.value()
|
||||
].join('/') : [
|
||||
self.$input.month.options('value'),
|
||||
self.$input.day.options('value'),
|
||||
self.$input.year.options('value')
|
||||
self.$input.month.value(),
|
||||
self.$input.day.value(),
|
||||
self.$input.year.value()
|
||||
].join(' ')), '%F');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue