forked from 0x2620/oxjs
update video editor
This commit is contained in:
parent
56cf323110
commit
688ae65cf1
8 changed files with 413 additions and 176 deletions
|
|
@ -19,6 +19,7 @@ Ox.Editable = function(options, self) {
|
|||
tooltip: options.tooltip
|
||||
}, self)
|
||||
.defaults({
|
||||
blurred: false,
|
||||
clickLink: null,
|
||||
editable: true,
|
||||
editing: false,
|
||||
|
|
@ -62,13 +63,22 @@ Ox.Editable = function(options, self) {
|
|||
.appendTo(that);
|
||||
|
||||
if (self.options.editing) {
|
||||
// edit will toggle self.options.editing
|
||||
self.options.editing = false;
|
||||
edit();
|
||||
// need timeout so that when determining height
|
||||
// the element is actually in the DOM
|
||||
setTimeout(function() {
|
||||
// edit will toggle self.options.editing
|
||||
self.options.editing = false;
|
||||
edit();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function blur() {
|
||||
that.triggerEvent('blur');
|
||||
function blur(data) {
|
||||
self.options.value = parseValue();
|
||||
if (self.options.value !== self.originalValue) {
|
||||
self.originalValue = self.options.value;
|
||||
that.triggerEvent('change', {value: self.options.value});
|
||||
}
|
||||
that.triggerEvent('blur', data);
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
|
|
@ -104,14 +114,10 @@ Ox.Editable = function(options, self) {
|
|||
width: width + 'px'
|
||||
});
|
||||
}
|
||||
/*
|
||||
that.triggerEvent('change', {
|
||||
value: event.value
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
function edit() {
|
||||
Ox.print('E EDIT! editable editing', self.options.editable, self.options.editing)
|
||||
var height, width;
|
||||
if (self.options.editable && !self.options.editing) {
|
||||
self.options.editing = true;
|
||||
|
|
@ -166,12 +172,15 @@ Ox.Editable = function(options, self) {
|
|||
});
|
||||
}
|
||||
// fixme: why can't this be chained?
|
||||
setTimeout(function() {
|
||||
self.$input.focusInput(self.options.type == 'input');
|
||||
}, 0);
|
||||
that.$tooltip && that.$tooltip.options({title: ''});
|
||||
that.triggerEvent('edit');
|
||||
if (!self.options.blurred) {
|
||||
setTimeout(function() {
|
||||
self.$input.focusInput(self.options.type == 'input');
|
||||
}, 0);
|
||||
that.$tooltip && that.$tooltip.options({title: ''});
|
||||
that.triggerEvent('edit');
|
||||
}
|
||||
}
|
||||
self.options.blurred = false;
|
||||
}
|
||||
|
||||
function formatInputValue() {
|
||||
|
|
@ -204,9 +213,15 @@ Ox.Editable = function(options, self) {
|
|||
return value;
|
||||
}
|
||||
|
||||
function parseValue() {
|
||||
return self.options.type == 'input'
|
||||
? Ox.encodeHTML(self.$input.value())
|
||||
: Ox.parseHTML(self.$input.value());
|
||||
}
|
||||
|
||||
function submit() {
|
||||
self.options.editing = false;
|
||||
self.options.value = Ox.parseHTML(self.$input.value());
|
||||
self.options.value = parseValue();
|
||||
self.$input.value(formatInputValue()).hide();
|
||||
self.$test.html(formatTestValue());
|
||||
self.$value.html(formatValue()).show();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue