|
77 | 77 | #define LPMT_ARG_LAYOUT_WIDTH @"Layout.Width" |
78 | 78 | #define LPMT_ARG_LAYOUT_HEIGHT @"Layout.Height" |
79 | 79 | #define LPMT_ARG_HTML_HEIGHT @"HTML Height" |
| 80 | +#define LPMT_ARG_HTML_WIDTH @"HTML Width" |
80 | 81 | #define LPMT_ARG_HTML_ALIGN @"HTML Align" |
81 | 82 | #define LPMT_ARG_HTML_ALIGN_TOP @"Top" |
82 | 83 | #define LPMT_ARG_HTML_ALIGN_BOTTOM @"Bottom" |
@@ -454,6 +455,7 @@ - (void)defineActions |
454 | 455 | withString:LPMT_DEFAULT_TRACK_ACTION_URL], |
455 | 456 | [LPActionArg argNamed:LPMT_ARG_HTML_ALIGN withString:LPMT_ARG_HTML_ALIGN_TOP], |
456 | 457 | [LPActionArg argNamed:LPMT_ARG_HTML_HEIGHT withNumber:@0], |
| 458 | + [LPActionArg argNamed:LPMT_ARG_HTML_WIDTH withString:@"100%"], |
457 | 459 | [LPActionArg argNamed:LPMT_HAS_DISMISS_BUTTON withBool:NO], |
458 | 460 | [LPActionArg argNamed:LPMT_ARG_HTML_TEMPLATE withFile:nil]] |
459 | 461 | withResponder:messageResponder]; |
@@ -981,8 +983,24 @@ - (void)updatePopupLayout |
981 | 983 | htmlY += app.statusBarFrame.size.height; |
982 | 984 | } |
983 | 985 | #endif |
| 986 | + |
| 987 | + // Calculate HTML width by percentage or px (it parses any suffix for extra protection). |
| 988 | + NSString *contextArgWidth = [context stringNamed:LPMT_ARG_HTML_WIDTH] ?: @"100%"; |
| 989 | + CGFloat htmlWidth = screenWidth; |
| 990 | + if (contextArgWidth && [contextArgWidth length] > 0) { |
| 991 | + if ([contextArgWidth hasSuffix:@"%"]) { |
| 992 | + NSString *percentageValue = [contextArgWidth stringByReplacingOccurrencesOfString:@"%" |
| 993 | + withString:@""]; |
| 994 | + htmlWidth = screenWidth * [percentageValue floatValue] / 100.; |
| 995 | + } else { |
| 996 | + NSCharacterSet *letterSet = [NSCharacterSet letterCharacterSet]; |
| 997 | + NSArray *components = [contextArgWidth componentsSeparatedByCharactersInSet:letterSet]; |
| 998 | + htmlWidth = [[components componentsJoinedByString:@""] floatValue]; |
| 999 | + } |
| 1000 | + } |
984 | 1001 |
|
985 | | - _popupGroup.frame = CGRectMake(0, htmlY, screenWidth, htmlHeight); |
| 1002 | + CGFloat htmlX = (screenWidth - htmlWidth) / 2.; |
| 1003 | + _popupGroup.frame = CGRectMake(htmlX, htmlY, htmlWidth, htmlHeight); |
986 | 1004 | _popupView.frame = _popupGroup.bounds; |
987 | 1005 | } |
988 | 1006 |
|
|
0 commit comments