Ox.EditableContent: self.editing -> self.options.editiing
This commit is contained in:
parent
0aa4c42ecf
commit
5b5a133533
1 changed files with 22 additions and 13 deletions
|
@ -8,7 +8,13 @@ Ox.EditableContent = function(options, self) {
|
|||
.defaults({
|
||||
clickLink: null,
|
||||
editable: true,
|
||||
editing: false,
|
||||
format: null,
|
||||
highlight: null,
|
||||
placeholder: '',
|
||||
replaceTags: {},
|
||||
submitOnBlur: true,
|
||||
tags: null,
|
||||
tooltip: '',
|
||||
type: 'span',
|
||||
value: ''
|
||||
|
@ -16,10 +22,10 @@ Ox.EditableContent = function(options, self) {
|
|||
.options(options || {})
|
||||
.update({
|
||||
highlight: function() {
|
||||
!self.editing && self.$value.html(formatValue());
|
||||
!self.options.editing && self.$value.html(formatValue());
|
||||
},
|
||||
value: function() {
|
||||
!self.editing && self.$value.html(formatValue());
|
||||
!self.options.editing && self.$value.html(formatValue());
|
||||
}
|
||||
})
|
||||
.addClass('OxEditableContent')
|
||||
|
@ -44,14 +50,12 @@ Ox.EditableContent = function(options, self) {
|
|||
|
||||
self.options.value = self.options.value.toString();
|
||||
|
||||
self.editing = false;
|
||||
|
||||
self.$value = Ox.Element(self.options.type == 'span' ? '<span>' : '<div>')
|
||||
.html(formatValue(self.options.value))
|
||||
.html(formatValue())
|
||||
.on({
|
||||
blur: submit,
|
||||
keydown: function(e) {
|
||||
if (self.editing) {
|
||||
if (self.options.editing) {
|
||||
if (self.options.type == 'span' && e.keyCode == 13) {
|
||||
submit();
|
||||
return false;
|
||||
|
@ -63,11 +67,15 @@ Ox.EditableContent = function(options, self) {
|
|||
}
|
||||
})
|
||||
.appendTo(that);
|
||||
|
||||
|
||||
function blur() {
|
||||
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
if (self.editing) {
|
||||
if (self.options.editing) {
|
||||
that.loseFocus();
|
||||
self.editing = false;
|
||||
self.options.editing = false;
|
||||
self.$value
|
||||
.attr({contenteditable: false})
|
||||
.removeClass('OxEditableContentInput')
|
||||
|
@ -77,7 +85,7 @@ Ox.EditableContent = function(options, self) {
|
|||
}
|
||||
|
||||
function edit() {
|
||||
if (self.options.editable && !self.editing) {
|
||||
if (self.options.editable && !self.options.editing) {
|
||||
var value = formatInputValue();
|
||||
self.$value
|
||||
.addClass('OxEditableContentInput')
|
||||
|
@ -87,7 +95,7 @@ Ox.EditableContent = function(options, self) {
|
|||
} else {
|
||||
self.$value.html(' ');
|
||||
}
|
||||
self.editing = true;
|
||||
self.options.editing = true;
|
||||
that.gainFocus();
|
||||
setTimeout(updateSelection, 50);
|
||||
}
|
||||
|
@ -132,9 +140,9 @@ Ox.EditableContent = function(options, self) {
|
|||
}
|
||||
|
||||
function submit() {
|
||||
if (self.editing) {
|
||||
if (self.options.editing) {
|
||||
that.loseFocus();
|
||||
self.editing = false;
|
||||
self.options.editing = false;
|
||||
self.options.value = self.$value.text();
|
||||
if (self.options.value.charCodeAt(0) == 160) {
|
||||
self.options.value = '';
|
||||
|
@ -146,6 +154,7 @@ Ox.EditableContent = function(options, self) {
|
|||
that.triggerEvent('submit', {value: self.options.value});
|
||||
}
|
||||
}
|
||||
|
||||
function updateSelection() {
|
||||
var range, selection;
|
||||
self.$value[0].focus();
|
||||
|
|
Loading…
Reference in a new issue