Skip to content

Commit

Permalink
add additional css style property
Browse files Browse the repository at this point in the history
  • Loading branch information
mureev committed Aug 29, 2012
1 parent 2fe89d6 commit 5d0c565
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMHTMLView/CMHTMLView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef void (^UrlClickBlock)(NSString* url);
@property (assign) CGFloat lineHeight;
@property (retain) NSString* defaultImagePath;
@property (assign) BOOL disableAHrefForImages;
@property (retain) NSString* additionalStyle;

// Callbacks
@property (copy) ImagePathBlock imageLoading;
Expand Down
13 changes: 9 additions & 4 deletions CMHTMLView/CMHTMLView.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ + (NSString *)md5OfString:(NSString *)str;

@implementation CMHTMLView

@synthesize loaded, webView, competitionBlock, jsCode, imgURLforHash, imgURLs, maxWidthPortrait, maxWidthLandscape, blockTags, removeTags, fontFamily, fontSize, lineHeight, defaultImagePath, disableAHrefForImages, imageLoading, imageClick, urlClick;
@synthesize loaded, webView, competitionBlock, jsCode, imgURLforHash, imgURLs, maxWidthPortrait, maxWidthLandscape, blockTags, removeTags, fontFamily, fontSize, lineHeight, defaultImagePath, disableAHrefForImages, additionalStyle, imageLoading, imageClick, urlClick;
@dynamic scrollView, images;


Expand Down Expand Up @@ -88,6 +88,7 @@ - (void)dealloc {
self.removeTags = nil;
self.fontFamily = nil;
self.defaultImagePath = nil;
self.additionalStyle = nil;
self.imageLoading = nil;
self.imageClick = nil;
self.urlClick = nil;
Expand Down Expand Up @@ -126,10 +127,14 @@ - (void)loadHtmlBody:(NSString*)html competition:(CompetitionBlock)competition {
loadHTML = [self disableIFrameForNonSupportedSrcInHtml:loadHTML];

// Add blocking some HTML tags
NSString* additionalStyle = @"";
NSString *localacAdditionalStyle = self.additionalStyle;
if (!localacAdditionalStyle) {
localacAdditionalStyle = @"";
}

if (self.blockTags) {
for (NSString* tag in self.blockTags) {
additionalStyle = [additionalStyle stringByAppendingFormat:@"%@ {display:none;}", tag];
localacAdditionalStyle = [localacAdditionalStyle stringByAppendingFormat:@"%@ {display:none;}", tag];
}
}

Expand All @@ -150,7 +155,7 @@ - (void)loadHtmlBody:(NSString*)html competition:(CompetitionBlock)competition {
NSString* rotateStyle = [NSString stringWithFormat:kDefaultDocumentRotateStyle, self.maxWidthPortrait-18, self.maxWidthLandscape-18];

// Create full page code
NSString* body = [NSString stringWithFormat:@"<html><head><script type=\"text/javascript\">%@</script> %@ <style type=\"text/css\">%@ %@ %@ %@</style></head><body>%@</body></html>", kFastClickJs, kDefaultDocumentMeta, kDefaultDocumentHtmlStyle, bodyStyle, rotateStyle, additionalStyle, loadHTML];
NSString* body = [NSString stringWithFormat:@"<html><head><script type=\"text/javascript\">%@</script> %@ <style type=\"text/css\">%@ %@ %@ %@</style></head><body>%@</body></html>", kFastClickJs, kDefaultDocumentMeta, kDefaultDocumentHtmlStyle, bodyStyle, rotateStyle, localacAdditionalStyle, loadHTML];

// Start loading
NSString *path = [[NSBundle mainBundle] bundlePath];
Expand Down

0 comments on commit 5d0c565

Please sign in to comment.