merging changes

This commit is contained in:
rolux 2011-08-15 18:41:54 +02:00
parent 72b892f982
commit 1ece68be42
4 changed files with 58 additions and 30 deletions

View file

@ -35,7 +35,7 @@ Ox.load('UI', {debug: true}, function() {
country: ['France'], country: ['France'],
director: ['Jean-Luc Godard'], director: ['Jean-Luc Godard'],
language: ['French', 'English'], language: ['French', 'English'],
runtime: 5400, runtime: '90 min',
title: 'Deux ou trois choses que je sais d\'elle', title: 'Deux ou trois choses que je sais d\'elle',
year: '1967' year: '1967'
}; };
@ -72,17 +72,17 @@ Ox.load('UI', {debug: true}, function() {
.css({float: 'left', margin: '1px 0 0 1px'}) .css({float: 'left', margin: '1px 0 0 1px'})
.append( .append(
$('<div>') $('<div>')
.css({float: 'left'}) .css({float: 'left', fontWeight: 'bold'})
.html((i ? '; ' : '') + Ox.toTitleCase(key) + ':&nbsp;') .html((i ? '; ' : '') + Ox.toTitleCase(key) + ':&nbsp;')
) )
.appendTo($div); .appendTo($div);
Ox.Editable({ Ox.Editable({
format: function(value) { format: function(value) {
return value ? ( return (value ? (
Ox.isArray(data[key]) ? value.split(', ').map(function(value) { Ox.isArray(data[key]) ? value.split(', ').map(function(value) {
return '<a href="/?find=' + value + '">' + value + '</a>' return '<a href="/?find=' + value + '">' + value + '</a>'
}).join(', ') : value }).join(', ') : value
) : 'unknown'; ) : 'unknown');// + (i == 3 ? '' : ';');
}, },
value: Ox.isArray(data[key]) ? data[key].join(', ') : data[key] value: Ox.isArray(data[key]) ? data[key].join(', ') : data[key]
}) })
@ -92,16 +92,20 @@ Ox.load('UI', {debug: true}, function() {
.appendTo($div_); .appendTo($div_);
}); });
$div = $('<div>')
.css({clear: 'both'})
.appendTo($box.$element);
$div = $('<div>').css({clear: 'both', marginTop: '16px', textAlign: 'justify'}).appendTo($box.$element);
Ox.Editable({ Ox.Editable({
format: function(value) { format: function(value) {
return value ? Ox.parseHTML(value) : 'No description' return '<span style="font-weight: bold">Keywords:</span> '
+ value.split(', ').map(function(value) {
return '<a href="/?find=' + value + '">' + value + '</a>'
}).join(', ')
}, },
type: 'textarea', type: 'textarea',
value: 'foo bar\nfoo bar' value: 'Sex, Crime, Car, Spoiler in Keywords, Genre in Keywords, Director Cameo, One Or More Meta Keywords',
width: 512
})
.css({
}) })
.appendTo($div); .appendTo($div);

View file

@ -693,6 +693,10 @@ OxEditable
padding: 0 1px 0 0; padding: 0 1px 0 0;
border: 0; border: 0;
} }
.OxEditable textarea.OxInput {
padding: 0 0 0 1px;
border: 0;
}
/* /*
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View file

@ -18,6 +18,7 @@ Ox.Editable = function(options, self) {
editing: false, editing: false,
format: null, format: null,
value: '', value: '',
width: 256,
type: 'input' type: 'input'
}) })
.options(options || {}) .options(options || {})
@ -26,6 +27,8 @@ Ox.Editable = function(options, self) {
doubleclick: edit doubleclick: edit
}); });
self.options.value = self.options.value.toString();
self.$value = Ox.Element(self.options.type == 'input' ? '<span>' : '<div>') self.$value = Ox.Element(self.options.type == 'input' ? '<span>' : '<div>')
.addClass('OxValue') .addClass('OxValue')
.css(self.options.type == 'input' ? { .css(self.options.type == 'input' ? {
@ -33,7 +36,8 @@ Ox.Editable = function(options, self) {
//padding: '1px 4px 1px 4px', //padding: '1px 4px 1px 4px',
//border: '1px solid transparent' //border: '1px solid transparent'
} : { } : {
padding: '0 4px 0 4px' //padding: '0 4px 0 4px'
width: self.options.width + 'px'
}) })
.html( .html(
self.options.format self.options.format
@ -43,12 +47,25 @@ Ox.Editable = function(options, self) {
//[self.options.editing ? 'hide' : 'show']() //[self.options.editing ? 'hide' : 'show']()
.appendTo(that); .appendTo(that);
self.$input = Ox.Input({ self.$test = self.$value.$element.clone()
.html(self.options.value.replace(/ /g, '&nbsp;'))
.css({
display: 'table-cell',
//position: 'absolute',
//left: 200,
//top: 200
})
.hide()
.appendTo(that.$element);
self.$input = Ox.Input(Ox.extend({
changeOnKeypress: true, changeOnKeypress: true,
style: 'square', style: 'square',
type: self.options.type, type: self.options.type,
value: self.options.value value: self.options.value
}) }, self.options.type == 'textarea' ? {
width: self.options.width
} : {}))
.bindEvent({ .bindEvent({
blur: submit, blur: submit,
cancel: cancel, cancel: cancel,
@ -72,25 +89,22 @@ Ox.Editable = function(options, self) {
function change(event) { function change(event) {
var height, width; var height, width;
self.options.value = event.value; self.options.value = formatValue(event.value);
if (self.options.type == 'input') {
self.options.value = self.options.value.replace(/ /g, '&nbsp;');
} else if (Ox.endsWith(self.options.value, '\n')) {
self.options.value += '&nbsp;';
}
self.$value.html( self.$value.html(
self.options.format self.options.format
? self.options.format(self.options.value) ? self.options.format(self.options.value)
: self.options.value : self.options.value
); );
height = self.$value.height(); self.$test.html(self.options.value.replace(/ /g, '&nbsp;'));
width = self.$value.width(); height = self.$test.height();
height = Math.max(self.$test.height(), 14);
width = Math.max(self.$test.width() + 2, 8);
Ox.print('wxh', width, height)
if (self.options.type == 'input') { if (self.options.type == 'input') {
self.$input.options({ self.$input.options({
height: height, width: width
width: width + 2
}); });
self.$input.find('input').css({width: width + 2 + 'px'}); self.$input.find('input').css({width: width + 'px'});
} else { } else {
self.$input.options({ self.$input.options({
height: height, height: height,
@ -102,7 +116,7 @@ Ox.Editable = function(options, self) {
}); });
} }
self.$input.find('input').css({width: width + 2}) //self.$input.find('input').css({width: width + 2})
/* /*
that.triggerEvent('change', { that.triggerEvent('change', {
@ -137,6 +151,16 @@ Ox.Editable = function(options, self) {
} }
} }
function formatValue(value) {
if (self.options.type == 'input') {
value = value.replace(/ /g, '&nbsp;');
} else {
value = value.replace(/\n/g, '<br/>')
.replace(/<br\/>$/, '<br/>&nbsp;');
}
return value;
}
function submit() { function submit() {
self.options.value = self.$input.value(); self.options.value = self.$input.value();
self.$value.html( self.$value.html(

View file

@ -46,6 +46,8 @@ Ox.Dialog = function(options, self) {
self.hasButtons = !!self.options.buttons.length; self.hasButtons = !!self.options.buttons.length;
self.barsHeight = 24 + 24 * self.hasButtons; self.barsHeight = 24 + 24 * self.hasButtons;
self.initialMaxHeight = self.options.maxHeight;
self.initialMaxWidth = self.options.maxWidth;
self.titleMargin = 8 + (self.options.closeButton ? 20 : 0) self.titleMargin = 8 + (self.options.closeButton ? 20 : 0)
+ (self.options.maximizeButton ? 20 : 0); + (self.options.maximizeButton ? 20 : 0);
@ -629,15 +631,9 @@ Ox.Dialog = function(options, self) {
return that; return that;
}; };
that.fullscreen = function() {
};
that.open = function() { that.open = function() {
self.initialHeight = self.options.height; self.initialHeight = self.options.height;
self.initialWidth = self.options.width; self.initialWidth = self.options.width;
self.initialMaxHeight = self.options.maxHeight;
self.initialMaxWidth = self.options.maxWidth;
setMinAndMax(); setMinAndMax();
center(); center();
reset(); reset();