add 'unformat' option to editables

This commit is contained in:
rolux 2014-12-16 20:38:41 +00:00
parent ad4e7dfa9a
commit e43881c594
3 changed files with 8 additions and 3 deletions

View file

@ -41,6 +41,7 @@ Ox.ArrayEditable = function(options, self) {
submitOnBlur: true,
tooltipText: '',
type: 'input',
unformat: null,
width: 256
})
.options(options || {})
@ -185,6 +186,7 @@ Ox.ArrayEditable = function(options, self) {
: ''
),
type: self.options.type,
unformat: self.options.unformat,
value: item.value,
width: self.options.type == 'input' ? 0 : self.options.width - 9
})

View file

@ -37,6 +37,7 @@ Ox.Editable = function(options, self) {
tags: null,
tooltip: '',
type: 'input',
unformat: null,
value: '',
width: 0
})
@ -199,12 +200,14 @@ Ox.Editable = function(options, self) {
function formatInputValue() {
return self.options.type == 'input'
? self.options.value
? (self.options.unformat || Ox.identity)(self.options.value)
: self.options.value.replace(/<br\/?><br\/?>/g, '\n\n');
}
function formatTestValue() {
var value = Ox.encodeHTMLEntities(self.$input.options('value'));
var value = Ox.encodeHTMLEntities(
(self.options.unformat || Ox.identity)(self.$input.options('value'))
);
return !value ? '&nbsp;'
: self.options.type == 'input'
? value.replace(/ /g, '&nbsp;')

View file

@ -295,7 +295,7 @@ Ox.AnnotationFolder = function(options, self) {
autocompleteSelect: true,
autocompleteSelectHighlight: true,
autocompleteSelectMaxWidth: 256,
format: function(value) {
unformat: function(value) {
return Ox.stripTags(value);
}
} : {}))