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

View file

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

View file

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