0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Fix getFontInfo method.

Resolves #169
This commit is contained in:
Neil Jenkins 2016-02-03 15:35:13 +11:00
parent 7330324d92
commit 2fccc317ad
3 changed files with 21 additions and 19 deletions

View file

@ -2896,7 +2896,7 @@ proto.getFontInfo = function ( range ) {
size: undefined
};
var seenAttributes = 0;
var element, style;
var element, style, attr;
if ( !range && !( range = this.getSelection() ) ) {
return fontInfo;
@ -2908,20 +2908,21 @@ proto.getFontInfo = function ( range ) {
element = element.parentNode;
}
while ( seenAttributes < 4 && element && ( style = element.style ) ) {
if ( !fontInfo.color ) {
fontInfo.color = style.color;
if ( !fontInfo.color && ( attr = style.color ) ) {
fontInfo.color = attr;
seenAttributes += 1;
}
if ( !fontInfo.backgroundColor ) {
fontInfo.backgroundColor = style.backgroundColor;
if ( !fontInfo.backgroundColor &&
( attr = style.backgroundColor ) ) {
fontInfo.backgroundColor = attr;
seenAttributes += 1;
}
if ( !fontInfo.family ) {
fontInfo.family = style.fontFamily;
if ( !fontInfo.family && ( attr = style.fontFamily ) ) {
fontInfo.family = attr;
seenAttributes += 1;
}
if ( !fontInfo.size ) {
fontInfo.size = style.fontSize;
if ( !fontInfo.size && ( attr = style.fontSize ) ) {
fontInfo.size = attr;
seenAttributes += 1;
}
element = element.parentNode;

File diff suppressed because one or more lines are too long

View file

@ -768,7 +768,7 @@ proto.getFontInfo = function ( range ) {
size: undefined
};
var seenAttributes = 0;
var element, style;
var element, style, attr;
if ( !range && !( range = this.getSelection() ) ) {
return fontInfo;
@ -780,20 +780,21 @@ proto.getFontInfo = function ( range ) {
element = element.parentNode;
}
while ( seenAttributes < 4 && element && ( style = element.style ) ) {
if ( !fontInfo.color ) {
fontInfo.color = style.color;
if ( !fontInfo.color && ( attr = style.color ) ) {
fontInfo.color = attr;
seenAttributes += 1;
}
if ( !fontInfo.backgroundColor ) {
fontInfo.backgroundColor = style.backgroundColor;
if ( !fontInfo.backgroundColor &&
( attr = style.backgroundColor ) ) {
fontInfo.backgroundColor = attr;
seenAttributes += 1;
}
if ( !fontInfo.family ) {
fontInfo.family = style.fontFamily;
if ( !fontInfo.family && ( attr = style.fontFamily ) ) {
fontInfo.family = attr;
seenAttributes += 1;
}
if ( !fontInfo.size ) {
fontInfo.size = style.fontSize;
if ( !fontInfo.size && ( attr = style.fontSize ) ) {
fontInfo.size = attr;
seenAttributes += 1;
}
element = element.parentNode;