summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UICaboodle/BrowserView.h2
-rw-r--r--UICaboodle/BrowserView.mm43
2 files changed, 45 insertions, 0 deletions
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h
index f6d689a..692704a 100644
--- a/UICaboodle/BrowserView.h
+++ b/UICaboodle/BrowserView.h
@@ -126,4 +126,6 @@
- (void) close;
+- (void) dispatchEvent:(NSString *)event;
+
@end
diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm
index 956e359..bdb5753 100644
--- a/UICaboodle/BrowserView.mm
+++ b/UICaboodle/BrowserView.mm
@@ -1174,4 +1174,47 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
return 980;
}
+- (void) dispatchEvent:(NSString *)event {
+ WebThreadLocked lock;
+
+ NSString *script([NSString stringWithFormat:@
+ "(function() {"
+ "var event = this.document.createEvent('Events');"
+ "event.initEvent('%@', false, false);"
+ "this.document.dispatchEvent(event);"
+ "})();"
+ , event]);
+
+ NSMutableArray *frames([NSMutableArray arrayWithObjects:
+ [[[webview_ _documentView] webView] mainFrame]
+ , nil]);
+
+ while (WebFrame *frame = [frames lastObject]) {
+ WebScriptObject *object([frame windowObject]);
+ [object evaluateWebScript:script];
+ [frames removeLastObject];
+ [frames addObjectsFromArray:[frame childFrames]];
+ }
+}
+
+- (void) viewWillAppear:(BOOL)animated {
+ [self dispatchEvent:@"CydiaViewWillAppear"];
+ [super viewWillAppear:animated];
+}
+
+- (void) viewDidAppear:(BOOL)animated {
+ [self dispatchEvent:@"CydiaViewDidAppear"];
+ [super viewDidAppear:animated];
+}
+
+- (void) viewWillDisappear:(BOOL)animated {
+ [self dispatchEvent:@"CydiaViewWillDisappear"];
+ [super viewWillDisappear:animated];
+}
+
+- (void) viewDidDisappear:(BOOL)animated {
+ [self dispatchEvent:@"CydiaViewDidDisappear"];
+ [super viewDidDisappear:animated];
+}
+
@end