Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions app/Jasonette/Jason.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ - (id)init {
name:@"Jason.error"
object:nil];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(notifyCall:)
name:@"Jason.call"
object:nil];

}
return self;
}
Expand All @@ -69,6 +75,12 @@ - (void)notifyError:(NSNotification *)notification {
[[Jason client] error:args];
}

- (void)notifyCall:(NSNotification *)notification {
NSDictionary *args = notification.object;
NSLog(@"JasonCore: notifyCall: %@", args);
[[Jason client] call:args];
}


#pragma mark - Jason Core API (USE ONLY THESE METHODS TO ACCESS Jason Core!)

Expand Down Expand Up @@ -622,6 +634,8 @@ - (Jason *)attach:(UIViewController<RussianDollView>*)viewController{

VC.url = [VC.url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

VC.modules = [[NSMutableDictionary alloc] init];

// Set the stylesheet
if(VC.style){
JasonComponentFactory.stylesheet = [VC.style mutableCopy];
Expand Down Expand Up @@ -2335,7 +2349,12 @@ - (void)exec{
NSLog(@"Plugin: class: %@", PluginClass);

// Initialize Plugin
module = [[PluginClass alloc] init]; // could go away if we had some sort of plug in registration
if(VC.modules && VC.modules[type]){
module = modules[type];
} else {
module = [[PluginClass alloc] init]; // could go away if we had some sort of plug in registration
VC.modules[type] = module;
}

[[NSNotificationCenter defaultCenter]
postNotificationName:plugin_path
Expand Down Expand Up @@ -2386,7 +2405,13 @@ - (void)exec{
NSString *methodName = tokens[1];
SEL method = NSSelectorFromString(methodName);

module = [[ActionClass alloc] init];
if(VC.modules && VC.modules[type]){
module = modules[type];
} else {
module = [[ActionClass alloc] init]; // could go away if we had some sort of plug in registration
VC.modules[type] = module;
}

if([module respondsToSelector:@selector(VC)]) [module setValue:VC forKey:@"VC"];
if([module respondsToSelector:@selector(options)]) [module setValue:[self options] forKey:@"options"];
[module performSelector:method];
Expand Down
1 change: 1 addition & 0 deletions app/Jasonette/JasonViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

@property (strong, nonatomic) NSDictionary *parser;
@property (nonatomic, strong) NSDictionary *data;
@property (strong, nonatomic) NSMutableDictionary *modules;

@property (nonatomic, strong) NSMutableArray *sections;
@property (nonatomic, strong) NSArray *rows;
Expand Down
1 change: 1 addition & 0 deletions app/Jasonette/JasonViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ - (void)viewDidLoad {
self.callback = [[NSDictionary alloc] init];
self.sections = [[NSMutableArray alloc] init];
self.rows = [[NSArray alloc] init];
self.modules = [[NSMutableDictionary alloc] init];

self.form = [[NSMutableDictionary alloc] init];
self.tableView.delaysContentTouches = false;
Expand Down
1 change: 1 addition & 0 deletions app/Jasonette/RussianDollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@property (nonatomic, strong) NSString *url;
@property (nonatomic, strong) NSDictionary *data;
@property (nonatomic, strong) NSDictionary *options;
@property (nonatomic, strong) NSMutableDictionary *modules;
@property (nonatomic, strong) NSDictionary *parser;
@property (nonatomic, strong) NSDictionary *callback;
@property (nonatomic, strong) NSDictionary *nav;
Expand Down