form elements rewrite, part 2

This commit is contained in:
rolux 2011-12-21 21:03:52 +05:30
parent fe303bf2b0
commit 074902d079
33 changed files with 163 additions and 153 deletions

View file

@ -25,9 +25,7 @@ Ox.load('UI', function() {
.css({marginLeft: '16px'}) .css({marginLeft: '16px'})
.bindEvent({ .bindEvent({
click: function() { click: function() {
$arrayInput.options({ $arrayInput.value(['foo', 'bar']);
value: ['foo', 'bar']
});
} }
}) })
.appendTo(Ox.$body) .appendTo(Ox.$body)

View file

@ -27,6 +27,7 @@
var colors = getColors(i); var colors = getColors(i);
$ranges[i] = new Ox.Range({ $ranges[i] = new Ox.Range({
arrows: true, arrows: true,
changeOnDrag: true,
id: rgb[i], id: rgb[i],
max: 255, max: 255,
size: 256, size: 256,

View file

@ -307,7 +307,7 @@ Ox.Calendar = function(options, self) {
.css({float: 'left', margin: '4px'}) .css({float: 'left', margin: '4px'})
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
self.options.showTypes = data.selected.map(function(type) { self.options.showTypes = data.value.map(function(type) {
return type.id; return type.id;
}); });
getLines(); getLines();
@ -491,6 +491,7 @@ Ox.Calendar = function(options, self) {
self.$zoomInput = Ox.Range({ self.$zoomInput = Ox.Range({
arrows: true, arrows: true,
changeOnDrag: true,
max: self.maxZoom, max: self.maxZoom,
min: 0, min: 0,
size: self.options.width, size: self.options.width,
@ -1008,9 +1009,9 @@ Ox.Calendar = function(options, self) {
renderTimelines(); renderTimelines();
renderOverlay(); renderOverlay();
renderEvents(); renderEvents();
self.$dateInput.options({ self.$dateInput.value(
value: Ox.formatDate(self.options.date, '%Y-%m-%d %H:%M:%S', true) Ox.formatDate(self.options.date, '%Y-%m-%d %H:%M:%S', true)
}); );
} }
function renderEvents() { function renderEvents() {
@ -1160,7 +1161,7 @@ Ox.Calendar = function(options, self) {
function zoomTo(zoom) { function zoomTo(zoom) {
self.options.zoom = Ox.limit(zoom, 0, self.maxZoom); self.options.zoom = Ox.limit(zoom, 0, self.maxZoom);
self.$zoomInput.options({value: self.options.zoom}); self.$zoomInput.value(self.options.zoom);
renderCalendar(); renderCalendar();
} }

View file

@ -156,7 +156,7 @@ Ox.ListCalendar = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
var key = data.selected[0].id, var key = data.value,
value = self.$findInput.value(); value = self.$findInput.value();
value && updateList(key, value); value && updateList(key, value);
} }
@ -364,7 +364,7 @@ Ox.ListCalendar = function(options, self) {
self.$alternativeNamesInput.setErrors([exists]); self.$alternativeNamesInput.setErrors([exists]);
} }
} else if (data.id == 'type') { } else if (data.id == 'type') {
editEvent('type', data.data.selected[0].id); editEvent('type', data.data.value);
} else if (data.id == 'start') { } else if (data.id == 'start') {
editEvent('start', data.data.value); editEvent('start', data.data.value);
} else if (data.id == 'end') { } else if (data.id == 'end') {
@ -508,14 +508,14 @@ Ox.ListCalendar = function(options, self) {
if (key == 'name') { if (key == 'name') {
self.$eventName.options({title: value}); self.$eventName.options({title: value});
} else if (['start', 'end'].indexOf(key) > -1) { } else if (['start', 'end'].indexOf(key) > -1) {
self.$durationInput.options({ self.$durationInput.value(
value: Ox.formatDateRangeDuration( Ox.formatDateRangeDuration(
self.$startInput.options('value'), self.$startInput.value(),
self.$endInput.options('value') self.$endInput.value()
|| Ox.formatDate(new Date(), '%Y-%m-%d %H%:%M:%S'), || Ox.formatDate(new Date(), '%Y-%m-%d %H%:%M:%S'),
true true
) )
}); );
} }
} else { } else {
alert(result.status.text); alert(result.status.text);

View file

@ -487,6 +487,15 @@ Ox.Element = function(options, self) {
return that; return that;
}; };
/*@
value <f> Shortcut to get or set self.options.value
@*/
that.value = function() {
return that.options(
arguments.length == 0 ? 'value' : {value: arguments[0]}
);
};
return that; return that;
}; };

View file

@ -76,7 +76,7 @@ Ox.ArrayInput = function(options, self) {
click: function() { click: function() {
var index = $(this).parent().data('index'); var index = $(this).parent().data('index');
if (self.$input[index].value() !== '') { if (self.$input[index].value() !== '') {
self.$input[index].options({value: ''}); self.$input[index].value('');
self.options.value = getValue(); self.options.value = getValue();
that.triggerEvent('change', { that.triggerEvent('change', {
value: self.options.value value: self.options.value

View file

@ -75,20 +75,20 @@ Ox.ButtonGroup = function(options, self) {
function toggleButton(pos) { function toggleButton(pos) {
var toggled = self.optionGroup.toggle(pos); var toggled = self.optionGroup.toggle(pos);
Ox.print('TOGGLED::', toggled)
if (!toggled.length) { if (!toggled.length) {
self.$buttons[pos].options({ // FIXME: fix and use that.toggleOption()
value: !self.$buttons[pos].options('value') self.$buttons[pos].value(!self.$buttons[pos].value());
});
} else { } else {
toggled.forEach(function(i) { toggled.forEach(function(i) {
i != pos && self.$buttons[i].options({ i != pos && self.$buttons[i].value(!self.$buttons[i].value());
// FIXME: fix and use that.toggleOption()
value: !self.$buttons[i].options('value')
});
}); });
self.options.value = self.optionGroup.value(); self.options.value = self.optionGroup.value();
that.triggerEvent('change', { that.triggerEvent('change', {
title: Ox.isString(self.options.value)
? Ox.getObjectById(self.options.buttons, self.options.value).title
: self.options.value.map(function(value) {
return Ox.getObjectById(self.options.buttons, value).title;
}),
value: self.options.value value: self.options.value
}); });
} }

View file

@ -49,6 +49,7 @@ Ox.CheckboxGroup = function(options, self) {
'checked' 'checked'
); );
self.options.checkboxes = self.optionGroup.init(); self.options.checkboxes = self.optionGroup.init();
self.options.value = self.optionGroup.value();
self.$checkboxes = []; self.$checkboxes = [];
if (self.options.type == 'group') { if (self.options.type == 'group') {
@ -78,18 +79,19 @@ Ox.CheckboxGroup = function(options, self) {
var toggled = self.optionGroup.toggle(pos); var toggled = self.optionGroup.toggle(pos);
Ox.Log('Form', 'change', pos, 'toggled', toggled) Ox.Log('Form', 'change', pos, 'toggled', toggled)
if (!toggled.length) { if (!toggled.length) {
self.$checkboxes[pos].options({ // FIXME: fix and use that.toggleOption()
value: !self.$checkboxes[pos].options('value') self.$checkboxes[pos].value(!self.$checkboxes[pos].value());
});
} else { } else {
toggled.forEach(function(i) { toggled.forEach(function(i) {
i != pos && self.$checkboxes[i].options({ i != pos && self.$checkboxes[i].value(!self.$checkboxes[i].value());
// FIXME: fix and use that.toggleOption()
value: !self.$checkboxes[i].options('value')
});
}); });
self.options.value = self.optionGroup.value(); self.options.value = self.optionGroup.value();
that.triggerEvent('change', { that.triggerEvent('change', {
title: Ox.isString(self.options.value)
? Ox.getObjectById(self.options.checkboxes, self.options.value).title
: self.options.value.map(function(value) {
return Ox.getObjectById(self.options.checkboxes, value).title;
}),
value: self.options.value value: self.options.value
}); });
} }

View file

@ -48,9 +48,7 @@ Ox.ColorInput = function(options, self) {
//Ox.Log('Form', 'change function called'); //Ox.Log('Form', 'change function called');
self.options.value = data.value; self.options.value = data.value;
Ox.loop(3, function(i) { Ox.loop(3, function(i) {
self.$inputs[i].options({ self.$inputs[i].value(self.options.value[i]);
value: self.options.value[i]
});
}); });
self.$inputs[3].css({ self.$inputs[3].css({
background: 'rgb(' + getRGB().join(', ') + ')' background: 'rgb(' + getRGB().join(', ') + ')'
@ -76,7 +74,7 @@ Ox.ColorInput = function(options, self) {
function change() { function change() {
self.options.value = self.$inputs.map(function(input, i) { self.options.value = self.$inputs.map(function(input, i) {
return i < 3 ? input.options('value') : null; return i < 3 ? input.value() : null;
}); });
self.$inputs[3].css({ self.$inputs[3].css({
background: 'rgb(' + getRGB().join(', ') + ')' background: 'rgb(' + getRGB().join(', ') + ')'

View file

@ -115,26 +115,29 @@ Ox.DateInput = function(options, self) {
}), self); }), self);
function changeDay() { function changeDay() {
self.options.weekday && self.$input.weekday.options({ self.options.weekday && self.$input.weekday.value(
value: Ox.formatDate(new Date([ Ox.formatDate(new Date([
self.$input.month.options('value'), self.$input.month.value(),
self.$input.day.options('value'), self.$input.day.value(),
self.$input.year.options('value') self.$input.year.value()
].join(' ')), self.formats.weekday) ].join(' ')), self.formats.weekday)
}); );
self.options.value = join(); self.options.value = join();
} }
function changeMonthOrYear() { function changeMonthOrYear() {
var day = self.$input.day.options('value'), var day = self.$input.day.value(),
month = self.$input.month.options('value'), month = self.$input.month.value(),
year = self.$input.year.options('value'), year = self.$input.year.value(),
days = Ox.getDaysInMonth(year, self.options.format == 'short' ? parseInt(month, 10) : month); days = Ox.getDaysInMonth(year, self.options.format == 'short' ? parseInt(month, 10) : month);
day = day <= days ? day : days; day = day <= days ? day : days;
//Ox.Log('Form', year, month, 'day days', day, days) //Ox.Log('Form', year, month, 'day days', day, days)
self.options.weekday && self.$input.weekday.options({ self.options.weekday && self.$input.weekday.value(
value: Ox.formatDate(new Date([month, day, year].join(' ')), self.formats.weekday) Ox.formatDate(
}); new Date([month, day, year].join(' ')),
self.formats.weekday
)
);
self.$input.day.options({ self.$input.day.options({
autocomplete: Ox.range(1, days + 1).map(function(i) { autocomplete: Ox.range(1, days + 1).map(function(i) {
return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString(); return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
@ -146,21 +149,20 @@ Ox.DateInput = function(options, self) {
function changeWeekday() { function changeWeekday() {
var date = getDateInWeek( var date = getDateInWeek(
self.$input.weekday.options('value'), self.$input.weekday.value(),
self.$input.month.options('value'), self.$input.month.value(),
self.$input.day.options('value'), self.$input.day.value(),
self.$input.year.options('value') self.$input.year.value()
); );
self.$input.month.options({value: date.month}); self.$input.month.value(date.month);
self.$input.day.options({ self.$input.day.options({
autocomplete: Ox.range(1, Ox.getDaysInMonth(date.year, date.month) + 1).map(function(i) { 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(); return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
}), }),
value: date.day value: date.day
}); });
self.$input.year.options({value: date.year}); self.$input.year.value(date.year);
self.options.value = join(); self.options.value = join();
Ox.print('self.options.value =', self.options.value)
} }
function getDate(value) { function getDate(value) {
@ -190,13 +192,13 @@ Ox.DateInput = function(options, self) {
function join() { function join() {
return Ox.formatDate(new Date(self.options.format == 'short' ? [ return Ox.formatDate(new Date(self.options.format == 'short' ? [
self.$input.year.options('value'), self.$input.year.value(),
self.$input.month.options('value'), self.$input.month.value(),
self.$input.day.options('value') self.$input.day.value()
].join('/') : [ ].join('/') : [
self.$input.month.options('value'), self.$input.month.value(),
self.$input.day.options('value'), self.$input.day.value(),
self.$input.year.options('value') self.$input.year.value()
].join(' ')), '%F'); ].join(' ')), '%F');
} }

View file

@ -60,7 +60,7 @@ Ox.DateTimeInput = function(options, self) {
function join() { function join() {
return that.options('inputs').map(function($input) { return that.options('inputs').map(function($input) {
return $input.options('value'); return $input.value();
}).join(' '); }).join(' ');
} }

View file

@ -67,7 +67,7 @@ Ox.Editable = function(options, self) {
function cancel() { function cancel() {
self.options.value = self.originalValue; self.options.value = self.originalValue;
self.$input.options({value: formatInputValue()}).hide(); self.$input.value(formatInputValue()).hide();
self.$test.html(formatTestValue()); self.$test.html(formatTestValue());
self.$value.html(formatValue()).show(); self.$value.html(formatValue()).show();
} }
@ -191,7 +191,7 @@ Ox.Editable = function(options, self) {
function submit() { function submit() {
self.options.editing = false; self.options.editing = false;
self.options.value = Ox.parseHTML(self.$input.value()); self.options.value = Ox.parseHTML(self.$input.value());
self.$input.options({value: formatInputValue()}).hide(); self.$input.value(formatInputValue()).hide();
self.$test.html(formatTestValue()); self.$test.html(formatTestValue());
self.$value.html(formatValue()).show(); self.$value.html(formatValue()).show();
that.$tooltip.options({title: self.options.tooltip}); that.$tooltip.options({title: self.options.tooltip});
@ -204,7 +204,6 @@ Ox.Editable = function(options, self) {
if (key == 'height' || key == 'width') { if (key == 'height' || key == 'width') {
var css = {}; var css = {};
css[key] = value + 'px'; css[key] = value + 'px';
Ox.print(key, 'VALUE', value)
self.$test && self.$test.css(css); self.$test && self.$test.css(css);
self.$input && self.$input.css(css); self.$input && self.$input.css(css);
self.$input && self.$input.find(self.options.type).css(css); self.$input && self.$input.find(self.options.type).css(css);

View file

@ -392,7 +392,7 @@ Ox.Filter = function(options, self) {
function changeOperator(data) { function changeOperator(data) {
var changeGroupOperator = false; var changeGroupOperator = false;
self.options.query.operator = data.selected[0].id; self.options.query.operator = data.value;
self.options.query.conditions.forEach(function(condition, pos) { self.options.query.conditions.forEach(function(condition, pos) {
if (condition.conditions) { if (condition.conditions) {
condition.operator = condition.operator == '&' ? '|' : '&'; condition.operator = condition.operator == '&' ? '|' : '&';
@ -549,7 +549,7 @@ Ox.Filter = function(options, self) {
changeConditionKey( changeConditionKey(
$element.data('position'), $element.data('position'),
$element.data('subposition'), $element.data('subposition'),
data.selected[0].id data.value
); );
} }
}); });
@ -581,7 +581,7 @@ Ox.Filter = function(options, self) {
changeConditionOperator( changeConditionOperator(
$element.data('position'), $element.data('position'),
$element.data('subposition'), $element.data('subposition'),
data.selected[0].id data.value
); );
} }
}); });
@ -717,7 +717,6 @@ Ox.Filter = function(options, self) {
if (formatType == 'color') { if (formatType == 'color') {
isHue = formatArgs[0] == 'hue'; isHue = formatArgs[0] == 'hue';
$input = Ox.Range({ $input = Ox.Range({
changeOnDrag: false,
max: isHue ? 360 : 1, max: isHue ? 360 : 1,
min: 0, min: 0,
size: !isArray ? 288 : 128, // fixme: should be width! size: !isArray ? 288 : 128, // fixme: should be width!
@ -793,11 +792,13 @@ Ox.Filter = function(options, self) {
}) })
], ],
float: 'right', float: 'right',
joinValues: function(values) { join: function(value) {
Ox.print(values, '?????')
return formatType == 'value' return formatType == 'value'
? values[0] * values[1] ? value[0] * value[1]
: values[0]; : value[0];
},
split: function(value) {
}, },
width: !isArray ? 288 : 128 width: !isArray ? 288 : 128
}) })

View file

@ -149,7 +149,7 @@ Ox.Form = function(options, self) {
self.$items.forEach(function($item, i) { self.$items.forEach(function($item, i) {
values[self.itemIds[i]] = self.$items[i].value(); values[self.itemIds[i]] = self.$items[i].value();
//fixme: make the following work //fixme: make the following work
//values[self.itemIds[i]] = self.$items[i].options('value'); //values[self.itemIds[i]] = self.$items[i].value();
}); });
//Ox.Log('Form', 'VALUES', values) //Ox.Log('Form', 'VALUES', values)
return values; return values;
@ -158,7 +158,7 @@ Ox.Form = function(options, self) {
Ox.forEach(arguments[0], function(value, key) { Ox.forEach(arguments[0], function(value, key) {
var index = getItemIndexById(key); var index = getItemIndexById(key);
//index > -1 && Ox.Log('Form', ':::::::', key, value) //index > -1 && Ox.Log('Form', ':::::::', key, value)
index > -1 && self.options.items[index].options({value: value}); index > -1 && self.options.items[index].value(value);
}); });
return that; return that;
} }

View file

@ -79,7 +79,7 @@ Ox.FormElementGroup = function(options, self) {
function getValue() { function getValue() {
var value = self.options.elements.map(function($element) { var value = self.options.elements.map(function($element) {
return $element.options('value'); return $element.value();
}); });
return self.options.join ? self.options.join(value) : value; return self.options.join ? self.options.join(value) : value;
} }
@ -93,7 +93,7 @@ Ox.FormElementGroup = function(options, self) {
? self.options.split(self.options.value) ? self.options.split(self.options.value)
: self.options.value; : self.options.value;
values.forEach(function(value, i) { values.forEach(function(value, i) {
self.options.elements[i].options({value: value}); self.options.elements[i].value(value);
}); });
} }

View file

@ -117,7 +117,6 @@ Ox.FormPanel = function(options, self) {
//that.triggerEvent('change', data); //that.triggerEvent('change', data);
}, },
validate: function(data) { validate: function(data) {
Ox.print('---------------VALIDATE', data);
self.$list.value(section.title, 'valid', data.valid); self.$list.value(section.title, 'valid', data.valid);
that.triggerEvent('validate', { that.triggerEvent('validate', {
title: section.title, title: section.title,

View file

@ -1875,20 +1875,18 @@ Ox.Range_ = function(options, self) {
width: thumbWidth + 'px' width: thumbWidth + 'px'
}, self.options.animate ? animate : 0, function() { }, self.options.animate ? animate : 0, function() {
if (self.options.thumbValue) { if (self.options.thumbValue) {
$thumb.options({ $thumb.value(
value: self.options.valueNames ? value: self.options.valueNames
self.options.valueNames[self.options.value] : ? self.options.valueNames[self.options.value]
self.options.value : self.options.value
}); );
} }
}); });
} }
function setValue(val, animate) { function setValue(val, animate) {
val = Ox.limit(val, self.options.min, self.options.max); val = Ox.limit(val, self.options.min, self.options.max);
if (val != self.options.value) { if (val != self.options.value) {
that.options({ that.value(val);
value: val
});
setThumb(animate); setThumb(animate);
that.triggerEvent('change', {value: val}); that.triggerEvent('change', {value: val});
} }

View file

@ -100,7 +100,7 @@ Ox.InputGroup = function(options, self) {
function getValue() { function getValue() {
var value = self.options.inputs.map(function($input) { var value = self.options.inputs.map(function($input) {
return $input.options('value'); return $input.value();
}); });
return self.options.join ? self.options.join(value) : value; return self.options.join ? self.options.join(value) : value;
} }
@ -118,7 +118,7 @@ Ox.InputGroup = function(options, self) {
? self.options.split(self.options.value) ? self.options.split(self.options.value)
: self.options.value; : self.options.value;
values.forEach(function(value, i) { values.forEach(function(value, i) {
self.options.inputs[i].options({value: value}); self.options.inputs[i].value(value);
}); });
} }

View file

@ -33,7 +33,6 @@ Ox.ObjectArrayInput = function(options, self) {
}); });
function addInput(index, value) { function addInput(index, value) {
Ox.print('addInput', index)
self.$element.splice(index, 0, Ox.Element() self.$element.splice(index, 0, Ox.Element()
.css({ .css({
width: self.options.width + 'px', width: self.options.width + 'px',
@ -53,6 +52,11 @@ Ox.ObjectArrayInput = function(options, self) {
labelWidth: self.options.labelWidth, labelWidth: self.options.labelWidth,
width: self.options.width width: self.options.width
}) })
.bindEvent({
change: function(data) {
// ...
}
})
.appendTo(self.$element[index]) .appendTo(self.$element[index])
); );
self.$removeButton.splice(index, 0, Ox.Button({ self.$removeButton.splice(index, 0, Ox.Button({
@ -115,6 +119,13 @@ Ox.ObjectArrayInput = function(options, self) {
}); });
} }
self.setOption = function(key, value) {
if (key == 'value') {
// ...
}
};
// FIXME: remove
that.value = function() { that.value = function() {
return self.$input.map(function($input) { return self.$input.map(function($input) {
return $input.value(); return $input.value();

View file

@ -16,8 +16,6 @@ Ox.ObjectInput = function(options, self) {
height: self.options.elements.length * 24 - 8 + 'px' height: self.options.elements.length * 24 - 8 + 'px'
}); });
Ox.print('ObjI', self.options)
self.options.elements.forEach(function($element) { self.options.elements.forEach(function($element) {
$element.options({ $element.options({
labelWidth: self.options.labelWidth, labelWidth: self.options.labelWidth,
@ -25,18 +23,22 @@ Ox.ObjectInput = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
// ... self.options.value = {};
self.options.elements.forEach(function(element) {
self.options.value[element.options('id')] = element.value();
});
that.triggerEvent('change', {
value: self.options.value
});
} }
}) })
.appendTo(that); .appendTo(that);
}); });
that.value = function() { self.setOption = function(key, value) {
var value = {}; if (key == 'value') {
self.options.elements.forEach(function(element) { // ...
value[element.options('id')] = element.value(); }
});
return value;
}; };
return that; return that;

View file

@ -60,6 +60,7 @@ Ox.PlacePicker = function(options, self) {
.append( .append(
self.$range = Ox.Range({ self.$range = Ox.Range({
arrows: true, arrows: true,
changeOnDrag: true,
id: self.options.id + 'Range', id: self.options.id + 'Range',
max: 22, max: 22,
size: 256, size: 256,
@ -107,12 +108,11 @@ Ox.PlacePicker = function(options, self) {
function clickLabel() { function clickLabel() {
var name = that.$label.html(); var name = that.$label.html();
if (name) { if (name) {
self.$input.options({ self.$input
value: name .value(name)
}) .triggerEvent('submit', {
.triggerEvent('submit', { value: name
value: name });
});
} }
} }
@ -128,9 +128,7 @@ Ox.PlacePicker = function(options, self) {
} }
function onZoom(data) { function onZoom(data) {
self.$range.options({ self.$range.value(data.value);
value: data.value
});
} }
function showPicker() { function showPicker() {

View file

@ -67,7 +67,6 @@ Ox.Range = function(options, self) {
self.options.thumbValue = true; self.options.thumbValue = true;
self.options.value = Ox.isNumber(self.options.value) self.options.value = Ox.isNumber(self.options.value)
? self.options.values[self.options.value] : self.options.value; ? self.options.values[self.options.value] : self.options.value;
Ox.print('!!!$!!!', self.options.value)
} }
self.options.arrowStep = options.arrowStep || self.options.step; self.options.arrowStep = options.arrowStep || self.options.step;
self.options.trackImages = Ox.toArray(self.options.trackImages); self.options.trackImages = Ox.toArray(self.options.trackImages);

View file

@ -156,6 +156,11 @@ Ox.Select = function(options, self) {
self.options.title ? self.options.title : getItem(self.options.value).title self.options.title ? self.options.title : getItem(self.options.value).title
); );
that.triggerEvent('change', { that.triggerEvent('change', {
title: Ox.isString(self.options.value)
? getItem(self.options.value).title
: self.options.value.map(function(value) {
return getItem(value).title;
}),
value: self.options.value value: self.options.value
}); });
} }

View file

@ -47,7 +47,7 @@ Ox.SelectInput = function(options, self) {
self.$select.options({width: self.otherWidth}) self.$select.options({width: self.otherWidth})
.addClass('OxOverlapRight'); .addClass('OxOverlapRight');
self.$input.show().focusInput(true); self.$input.show().focusInput(true);
self.options.value = self.$input.options('value'); self.options.value = self.$input.value();
} }
} }
}); });
@ -58,7 +58,6 @@ Ox.SelectInput = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
Ox.print('DATA:', data)
self.options.value = data.value; self.options.value = data.value;
} }
}) })

View file

@ -32,11 +32,9 @@ Ox.Spreadsheet = function(options, self) {
function addColumn(index) { function addColumn(index) {
self.options.columns.splice(index, 0, ''); self.options.columns.splice(index, 0, '');
Ox.print('sv', JSON.stringify(self.values))
self.values.forEach(function(columns) { self.values.forEach(function(columns) {
columns.splice(index, 0, 0); columns.splice(index, 0, 0);
}); });
Ox.print('sv', JSON.stringify(self.values))
renderSpreadsheet(); renderSpreadsheet();
} }
@ -52,7 +50,6 @@ Ox.Spreadsheet = function(options, self) {
row: Ox.repeat([0], self.rows), row: Ox.repeat([0], self.rows),
sheet: 0 sheet: 0
}; };
Ox.print('sv', self.values);
self.values.forEach(function(columns, r) { self.values.forEach(function(columns, r) {
columns.forEach(function(value, c) { columns.forEach(function(value, c) {
sums.column[c] += value; sums.column[c] += value;
@ -93,12 +90,10 @@ Ox.Spreadsheet = function(options, self) {
Ox.merge([self.options.title], Ox.clone(self.options.rows), ['Total']).forEach(function(row, r) { Ox.merge([self.options.title], Ox.clone(self.options.rows), ['Total']).forEach(function(row, r) {
r--; r--;
Ox.print('ROW', row);
Ox.merge([''], Ox.clone(self.options.columns), ['Total']).forEach(function(column, c) { Ox.merge([''], Ox.clone(self.options.columns), ['Total']).forEach(function(column, c) {
c--; c--;
if (r == -1) { if (r == -1) {
if (c == -1 || c == self.columns) { if (c == -1 || c == self.columns) {
Ox.print('c', c, 'row', row)
Ox.Label({ Ox.Label({
style: 'square', style: 'square',
textAlign: c == -1 ? 'left' : 'right', textAlign: c == -1 ? 'left' : 'right',
@ -210,9 +205,9 @@ Ox.Spreadsheet = function(options, self) {
change: function(data) { change: function(data) {
self.values[r][c] = parseInt(data.value); self.values[r][c] = parseInt(data.value);
self.sums = getSums(); self.sums = getSums();
self.$input[c + ',' + self.rows].options({value: self.sums.column[c]}); self.$input[c + ',' + self.rows].value(self.sums.column[c]);
self.$input[self.columns + ',' + r].options({value: self.sums.row[r]}); self.$input[self.columns + ',' + r].value(self.sums.row[r]);
self.$input[self.columns + ',' + self.rows].options({value: self.sums.sheet}); self.$input[self.columns + ',' + self.rows].value(self.sums.sheet);
triggerChangeEvent(); triggerChangeEvent();
} }
}); });

View file

@ -143,17 +143,17 @@ Ox.TimeInput = function(options, self) {
return Ox.formatDate( return Ox.formatDate(
new Date( new Date(
'1970/01/01 ' + [ '1970/01/01 ' + [
self.$input.hours.options('value'), self.$input.hours.value(),
self.$input.minutes.options('value'), self.$input.minutes.value(),
self.options.seconds ? self.$input.seconds.options('value') : '00' self.options.seconds ? self.$input.seconds.value() : '00'
].join(':') + ( ].join(':') + (
self.options.ampm ? ' ' + self.$input.ampm.options('value') : '' self.options.ampm ? ' ' + self.$input.ampm.value() : ''
) )
), ),
( (
self.options.seconds ? '%T' : '%H:%M' self.options.seconds ? '%T' : '%H:%M'
) + ( ) + (
self.options.milliseconds ? '.' + self.$input.milliseconds.options('value') : '' self.options.milliseconds ? '.' + self.$input.milliseconds.value() : ''
) )
); );
} }

View file

@ -265,7 +265,7 @@ Ox.TextList = function(options, self) {
function changeColumns(data) { function changeColumns(data) {
var add, var add,
ids = []; ids = [];
Ox.forEach(data.selected, function(column) { Ox.forEach(data.value, function(column) {
var index = getColumnIndexById(column.id); var index = getColumnIndexById(column.id);
if (!self.options.columns[index].visible) { if (!self.options.columns[index].visible) {
addColumn(column.id); addColumn(column.id);

View file

@ -234,7 +234,7 @@ Ox.ListMap = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
var key = data.selected[0].id, var key = data.value,
value = self.$findInput.value(); value = self.$findInput.value();
value && updateList(key, value); value && updateList(key, value);
} }
@ -324,7 +324,7 @@ Ox.ListMap = function(options, self) {
*/ */
changeplace: function(data) { changeplace: function(data) {
self.$placeForm.values(data).show(); self.$placeForm.values(data).show();
self.$areaKmInput.options({value: Ox.formatArea(data.area)}); self.$areaKmInput.value(Ox.formatArea(data.area));
}, },
changeplaceend: function(data) { changeplaceend: function(data) {
//Ox.Log('Map', 'ssP', self.selectedPlace); //Ox.Log('Map', 'ssP', self.selectedPlace);
@ -470,7 +470,7 @@ Ox.ListMap = function(options, self) {
{id: 'borough', title: 'Borough'}, {id: 'borough', title: 'Borough'},
{id: 'street', title: 'Street'}, // streets, squares, bridges, tunnels, ... {id: 'street', title: 'Street'}, // streets, squares, bridges, tunnels, ...
{id: 'building', title: 'Building'}, // airports, stations, stadiums, military installations, ... {id: 'building', title: 'Building'}, // airports, stations, stadiums, military installations, ...
{id: 'feature', title: 'Feature'} // continents, islands, rivers, lakes, seas, oceans, ... {id: 'feature', title: 'Feature'} // continents, islands, rivers, lakes, seas, oceans, mountains...
], ],
label: 'Type', label: 'Type',
labelWidth: 64, labelWidth: 64,
@ -483,7 +483,7 @@ Ox.ListMap = function(options, self) {
} else { } else {
!isResult && editPlace(['type']) !isResult && editPlace(['type'])
} }
self.$map.value(self.selectedPlace, 'type', data.selected[0].id); self.$map.value(self.selectedPlace, 'type', data.value);
} }
}) })
], ['Latitude', 'Longitude', 'South', 'West', 'North', 'East'].map(function(v) { ], ['Latitude', 'Longitude', 'South', 'West', 'North', 'East'].map(function(v) {
@ -805,7 +805,7 @@ Ox.ListMap = function(options, self) {
}); });
self.$placeName.options({title: place.geoname || ''}); self.$placeName.options({title: place.geoname || ''});
self.$placeTitle.show(); self.$placeTitle.show();
self.$areaKmInput.options({value: Ox.formatArea(place.area)}); self.$areaKmInput.value(Ox.formatArea(place.area));
self.$placeForm.values(place).show(); self.$placeForm.values(place).show();
self.$placeButton.options({title: isResult ? 'Add Place' : 'Remove Place'}).show(); self.$placeButton.options({title: isResult ? 'Add Place' : 'Remove Place'}).show();
updateMatches(); updateMatches();
@ -850,12 +850,12 @@ Ox.ListMap = function(options, self) {
return name !== ''; return name !== '';
}); });
if (names.length) { if (names.length) {
self.$matchesInput.options({value: ''}); self.$matchesInput.value('');
self.options.getMatches(names, function(matches) { self.options.getMatches(names, function(matches) {
self.$matchesInput.options({value: Ox.formatNumber(matches)}); self.$matchesInput.value(Ox.formatNumber(matches));
}); });
} else { } else {
self.$matchesInput.options({value: 0}); self.$matchesInput.value(0);
} }
} }
} }

View file

@ -575,6 +575,7 @@ Ox.Map = function(options, self) {
self.$zoomInput && self.$zoomInput.remove(); self.$zoomInput && self.$zoomInput.remove();
self.$zoomInput = Ox.Range({ self.$zoomInput = Ox.Range({
arrows: true, arrows: true,
changeOnDrag: true,
max: self.maxZoom, max: self.maxZoom,
min: self.minZoom, min: self.minZoom,
size: that.width(), size: that.width(),
@ -817,7 +818,7 @@ Ox.Map = function(options, self) {
that.overlayView.draw(); that.overlayView.draw();
if (self.options.find) { if (self.options.find) {
self.$findInput.options({value: self.options.find}) self.$findInput.value(self.options.find)
.triggerEvent('submit', {value: self.options.find}); .triggerEvent('submit', {value: self.options.find});
} else if (self.options.selected) { } else if (self.options.selected) {
selectPlace(self.options.selected, true); selectPlace(self.options.selected, true);
@ -906,7 +907,6 @@ Ox.Map = function(options, self) {
} }
}); });
} else { } else {
Ox.print ('sG cD', spansGlobe(), crossesDateline())
self.options.places({ self.options.places({
keys: self.placeKeys, keys: self.placeKeys,
query: { query: {
@ -1363,7 +1363,7 @@ Ox.Map = function(options, self) {
self.map.setZoom(self.maxZoom); self.map.setZoom(self.maxZoom);
} else { } else {
self.zoomChanged = true; self.zoomChanged = true;
self.$zoomInput && self.$zoomInput.options({value: zoom}); self.$zoomInput && self.$zoomInput.value(zoom);
that.triggerEvent('zoom', { that.triggerEvent('zoom', {
value: zoom value: zoom
}); });

View file

@ -21,7 +21,7 @@ Ox.TabPanel = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
self.selected = data.selected[0]; self.selected = data.value;
that.$element.replaceElement(1, getContent()); that.$element.replaceElement(1, getContent());
that.triggerEvent('change', {selected: self.selected}); that.triggerEvent('change', {selected: self.selected});
} }

View file

@ -435,7 +435,7 @@ Ox.VideoEditor = function(options, self) {
width: 256 width: 256
}).open(); }).open();
} else if (id == 'resolution') { } else if (id == 'resolution') {
self.options.resolution = parseInt(data.checked[0].id); self.options.resolution = parseInt(value);
self.$player[0].options({resolution: self.options.resolution}); self.$player[0].options({resolution: self.options.resolution});
} }
} }

View file

@ -261,9 +261,7 @@ Ox.VideoEditorPlayer = function(options, self) {
self.options.position = data.position; self.options.position = data.position;
setMarkers(); setMarkers();
setSubtitle(); setSubtitle();
self.$positionInput.options({ self.$positionInput.value(Ox.formatDuration(self.options.position, 3));
value: Ox.formatDuration(self.options.position, 3)
});
that.triggerEvent('playing', { that.triggerEvent('playing', {
position: self.options.position position: self.options.position
}); });
@ -322,9 +320,7 @@ Ox.VideoEditorPlayer = function(options, self) {
} }
setMarkers(); setMarkers();
setSubtitle(); setSubtitle();
self.$positionInput.options({ self.$positionInput.value(Ox.formatDuration(self.options.position, 3));
value: Ox.formatDuration(self.options.position, 3)
});
} }
function setSubtitle() { function setSubtitle() {

View file

@ -658,9 +658,7 @@ Ox.VideoPlayer = function(options, self) {
} }
self.$position.hide(); self.$position.hide();
self.$positionInput self.$positionInput
.options({ .value(formatPosition())
value: formatPosition()
})
.show() .show()
.focusInput(false); .focusInput(false);
} }
@ -1019,6 +1017,7 @@ Ox.VideoPlayer = function(options, self) {
.appendTo(self.$volume); .appendTo(self.$volume);
self.$volumeInput = Ox.Range({ self.$volumeInput = Ox.Range({
changeOnDrag: true,
max: 1, max: 1,
min: 0, min: 0,
step: 0.001, step: 0.001,
@ -1916,9 +1915,7 @@ Ox.VideoPlayer = function(options, self) {
showVolume(); showVolume();
self.options.volume = Ox.limit(self.options.volume + num, 0, 1); self.options.volume = Ox.limit(self.options.volume + num, 0, 1);
setVolume(self.options.volume); setVolume(self.options.volume);
self.$volumeInput && self.$volumeInput.options({ self.$volumeInput && self.$volumeInput.value(self.options.volume);
value: self.options.volume
});
} }
function setVolume(volume) { function setVolume(volume) {
@ -2030,8 +2027,8 @@ Ox.VideoPlayer = function(options, self) {
function submitPositionInput() { function submitPositionInput() {
self.$positionInput.hide(); self.$positionInput.hide();
self.$position.html('').show(); self.$position.html('').show();
//Ox.Log('Video', '###', parsePositionInput(self.$positionInput.options('value'))) //Ox.Log('Video', '###', parsePositionInput(self.$positionInput.value()))
setPosition(parsePositionInput(self.$positionInput.options('value'))); setPosition(parsePositionInput(self.$positionInput.value()));
if (self.playOnSubmit) { if (self.playOnSubmit) {
togglePaused(); togglePaused();
self.$video.play(); self.$video.play();
@ -2143,9 +2140,9 @@ Ox.VideoPlayer = function(options, self) {
self.$volumeButton && self.$volumeButton.attr({ self.$volumeButton && self.$volumeButton.attr({
src: getVolumeImageURL() src: getVolumeImageURL()
}); });
self.$volumeInput && self.$volumeInput.options({ self.$volumeInput && self.$volumeInput.value(
value: self.options.muted ? 0 : self.options.volume self.options.muted ? 0 : self.options.volume
}); );
self.$volumeValue && self.$volumeValue.html( self.$volumeValue && self.$volumeValue.html(
self.options.muted ? 0 : Math.round(self.options.volume * 100) self.options.muted ? 0 : Math.round(self.options.volume * 100)
); );