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;
that.addClass('OxEditing');
self.originalValue = self.options.value;
self.$value.hide();
if (!self.$input) {
self.$input = Ox.Input({
changeOnKeypress: true,
@ -141,6 +140,7 @@ Ox.Editable = function(options, self) {
? self.minHeight
: self.options.maxHeight || that.parent().height();
setSizes();
self.$value.hide();
self.$input.show();
if (!self.options.blurred) {
setTimeout(function() {
@ -194,14 +194,14 @@ Ox.Editable = function(options, self) {
function setSizes() {
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);
width = self.options.width || Ox.limit(self.$test.width(), self.minWidth, self.maxWidth);
self.$test.hide();
self.$test.css({display: 'none'});
self.$input.options({
width: width,
height: height
});
width: width,
height: height
});
self.$input.find(self.options.type).css({
height: height + 'px',
width: width + 'px'

View file

@ -397,9 +397,14 @@ Ox.AnnotationFolder = function(options, self) {
if (self.widget && self.options.items.length) {
self.$annotations.find('.OxEditableElement').each(function() {
var $element = $(this);
if (!Ox.getObjectById(
self.options.items, $element.data('id')
)[self.options.type]) {
// 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.type]
) {
$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) {
return html.replace(
/\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('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)')
'(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')
'<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>')
'<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>')
'&lt;a href="javascript:alert()"&gt;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>')
'<div style="direction: rtl">foo</div>'
> Ox.parseHTML('<script>alert()</script>')
@ -55,7 +55,7 @@ Ox.parseHTML = (function() {
],
parse = {
a: {
'<a [^<>]*?href="((https?:\/\/|\/).+?)".*?>': '<a href="{1}" title="{1}">',
'<a [^<>]*?href="((https?:\/\/|\/).+?)".*?>': '<a href="{1}">',
'<\/a>': '</a>'
},
img: {