fix Ox.Edidable textarea height, dont add title to links in parseHTML

This commit is contained in:
j 2012-01-19 22:07:39 +05:30
parent f7755eb303
commit 7475ef0124
3 changed files with 21 additions and 16 deletions

View file

@ -110,7 +110,6 @@ Ox.Editable = function(options, self) {
self.options.editing = true; self.options.editing = true;
that.addClass('OxEditing'); that.addClass('OxEditing');
self.originalValue = self.options.value; self.originalValue = self.options.value;
self.$value.hide();
if (!self.$input) { if (!self.$input) {
self.$input = Ox.Input({ self.$input = Ox.Input({
changeOnKeypress: true, changeOnKeypress: true,
@ -141,6 +140,7 @@ Ox.Editable = function(options, self) {
? self.minHeight ? self.minHeight
: self.options.maxHeight || that.parent().height(); : self.options.maxHeight || that.parent().height();
setSizes(); setSizes();
self.$value.hide();
self.$input.show(); self.$input.show();
if (!self.options.blurred) { if (!self.options.blurred) {
setTimeout(function() { setTimeout(function() {
@ -194,10 +194,10 @@ Ox.Editable = function(options, self) {
function setSizes() { function setSizes() {
var height, width; var height, width;
self.$test.show(); self.$test.css({display: 'inline-block'});
height = self.options.height || Ox.limit(self.$test.height(), self.minHeight, self.maxHeight); height = self.options.height || Ox.limit(self.$test.height(), self.minHeight, self.maxHeight);
width = self.options.width || Ox.limit(self.$test.width(), self.minWidth, self.maxWidth); width = self.options.width || Ox.limit(self.$test.width(), self.minWidth, self.maxWidth);
self.$test.hide(); self.$test.css({display: 'none'});
self.$input.options({ self.$input.options({
width: width, width: width,
height: height height: height

View file

@ -397,9 +397,14 @@ Ox.AnnotationFolder = function(options, self) {
if (self.widget && self.options.items.length) { if (self.widget && self.options.items.length) {
self.$annotations.find('.OxEditableElement').each(function() { self.$annotations.find('.OxEditableElement').each(function() {
var $element = $(this); var $element = $(this);
if (!Ox.getObjectById( // We don't want to catch an eventual placeholder,
// which is an EditableElement without .data('id')
if (
$element.data('id')
&& !Ox.getObjectById(
self.options.items, $element.data('id') self.options.items, $element.data('id')
)[self.options.type]) { )[self.options.type]
) {
$element.addClass('OxWarning'); $element.addClass('OxWarning');
} }
}); });

View file

@ -8,24 +8,24 @@ Ox.parseEmailAddresses <f> Takes HTML and turns e-mail addresses into links
Ox.parseEmailAddresses = function(html) { Ox.parseEmailAddresses = function(html) {
return html.replace( return html.replace(
/\b([0-9A-Z\.\+\-_]+@(?:[0-9A-Z\-]+\.)+[A-Z]{2,6})\b/gi, /\b([0-9A-Z\.\+\-_]+@(?:[0-9A-Z\-]+\.)+[A-Z]{2,6})\b/gi,
'<a href="mailto:$1" title="mailto:$1">$1</a>' '<a href="mailto:$1">$1</a>'
); );
}; };
/*@ /*@
Ox.parseHTML <f> Takes HTML from an untrusted source and returns something sane Ox.parseHTML <f> Takes HTML from an untrusted source and returns something sane
> Ox.parseHTML('http://foo.com, bar') > Ox.parseHTML('http://foo.com, bar')
'<a href="http://foo.com" title="http://foo.com">foo.com</a>, bar' '<a href="http://foo.com">foo.com</a>, bar'
> Ox.parseHTML('(see: www.foo.com)') > Ox.parseHTML('(see: www.foo.com)')
'(see: <a href="http://www.foo.com" title="http://www.foo.com">www.foo.com</a>)' '(see: <a href="http://www.foo.com">www.foo.com</a>)'
> Ox.parseHTML('foo@bar.com') > Ox.parseHTML('foo@bar.com')
'<a href="mailto:foo@bar.com" title="mailto:foo@bar.com">foo@bar.com</a>' '<a href="mailto:foo@bar.com">foo@bar.com</a>'
> Ox.parseHTML('<a href="http://foo.com" onmouseover="alert()">foo</a>') > Ox.parseHTML('<a href="http://foo.com" onmouseover="alert()">foo</a>')
'<a href="http://foo.com" title="http://foo.com">foo</a>' '<a href="http://foo.com">foo</a>'
> Ox.parseHTML('<a href="javascript:alert()">foo</a>') > Ox.parseHTML('<a href="javascript:alert()">foo</a>')
'&lt;a href="javascript:alert()"&gt;foo' '&lt;a href="javascript:alert()"&gt;foo'
> Ox.parseHTML('[http://foo.com foo]') > Ox.parseHTML('[http://foo.com foo]')
'<a href="http://foo.com" title="http://foo.com">foo</a>' '<a href="http://foo.com">foo</a>'
> Ox.parseHTML('<rtl>foo</rtl>') > Ox.parseHTML('<rtl>foo</rtl>')
'<div style="direction: rtl">foo</div>' '<div style="direction: rtl">foo</div>'
> Ox.parseHTML('<script>alert()</script>') > Ox.parseHTML('<script>alert()</script>')
@ -55,7 +55,7 @@ Ox.parseHTML = (function() {
], ],
parse = { parse = {
a: { a: {
'<a [^<>]*?href="((https?:\/\/|\/).+?)".*?>': '<a href="{1}" title="{1}">', '<a [^<>]*?href="((https?:\/\/|\/).+?)".*?>': '<a href="{1}">',
'<\/a>': '</a>' '<\/a>': '</a>'
}, },
img: { img: {