diff --git a/README.md b/README.md index 06767cb3..b890df53 100644 --- a/README.md +++ b/README.md @@ -34,22 +34,39 @@ API ### Device +Exposes properties of the phone, such as its device ID, model, and OS version number. + ### Location + +Gain access to the Latitude / Longitude of the device, and depending on the type of device, the course, speed, and altitude. ### Accelerometer + +Monitor the accelerometer on the device to detect orientation, shaking and other similar actions. ### Contacts +Query the phone addressbook to read the users contacts. + ### Orientation +Read the device layout orientation, e.g. landscape vs portrait. + ### Camera +Brings up the camera or photo browser on the phone to allow the user to upload a photo. + ### Vibrate +Triggers the vibration alert on the phone, if it is supported. + ### Sound +Play sound files (WAV, MP3, etc). + ### Telephony +Trigger and activate phone calls. XUI ------------------------------------------------------------- @@ -91,4 +108,4 @@ THE SOFTWARE. ------------------------------------------------------------- -*phonegap is a [nitobi](http://nitobi.com) sponsored project* \ No newline at end of file +*phonegap is a [nitobi](http://nitobi.com) sponsored project* diff --git a/Rakefile b/Rakefile index b167fa59..de9c67b2 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ def doc end FileUtils.mkdir_p "#{ LIBPATH }tmp" open(final,'w'){|f| f.puts( js )} - sh "java -jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }jsrun.jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }app#{ File::SEPARATOR }run.js -a -t=util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }templates#{ File::SEPARATOR }jsdoc tmp#{ File::SEPARATOR }phonegap.js" + sh "java -jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }jsrun.jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }app#{ File::SEPARATOR }run.js -a -d=javascripts/docs -t=util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }templates#{ File::SEPARATOR }jsdoc tmp#{ File::SEPARATOR }phonegap.js" end def build diff --git a/iphone/Classes/Notification.m b/iphone/Classes/Notification.m index d0de296a..34903443 100644 --- a/iphone/Classes/Notification.m +++ b/iphone/Classes/Notification.m @@ -31,11 +31,18 @@ - (void)alert:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options - (void)activityStart:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options { //[(UIActivityIndicatorView*)[self.webView.window viewWithTag:2] startAnimating]; + NSLog(@"Starting"); + UIApplication* app = [UIApplication sharedApplication]; + app.networkActivityIndicatorVisible = YES; } - (void)activityStop:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options { //[(UIActivityIndicatorView*)[self.webView.window viewWithTag:2] stopAnimating]; + + NSLog(@"Stopping "); + UIApplication* app = [UIApplication sharedApplication]; + app.networkActivityIndicatorVisible = NO; } - (void)vibrate:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options diff --git a/iphone/Classes/PhoneGapCommand.h b/iphone/Classes/PhoneGapCommand.h index cf4d9245..7b90c66b 100644 --- a/iphone/Classes/PhoneGapCommand.h +++ b/iphone/Classes/PhoneGapCommand.h @@ -10,11 +10,15 @@ #import @interface PhoneGapCommand : NSObject { - UIWebView* webView; + UIWebView* webView; + NSDictionary* settings; } @property (nonatomic, retain) UIWebView *webView; +@property (nonatomic, retain) NSDictionary *settings; +-(PhoneGapCommand*) initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings; -(PhoneGapCommand*) initWithWebView:(UIWebView*)theWebView; -(void) setWebView:(UIWebView*) theWebView; +-(void) setSettings:(NSDictionary*) classSettings; @end diff --git a/iphone/Classes/PhoneGapCommand.m b/iphone/Classes/PhoneGapCommand.m index c3bdcf09..99e801b9 100644 --- a/iphone/Classes/PhoneGapCommand.m +++ b/iphone/Classes/PhoneGapCommand.m @@ -10,14 +10,21 @@ @implementation PhoneGapCommand @synthesize webView; +@synthesize settings; + +-(PhoneGapCommand*) initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings +{ + self = [self initWithWebView:theWebView]; + if (self) + [self setSettings:classSettings]; + return self; +} -(PhoneGapCommand*) initWithWebView:(UIWebView*)theWebView { - NSLog(@"phonegap command initializing"); self = [super init]; - if (self) { + if (self) [self setWebView:theWebView]; - } return self; } @@ -26,4 +33,16 @@ -(void) setWebView:(UIWebView*) theWebView webView = theWebView; } +-(void) setSettings:(NSDictionary*) classSettings +{ + settings = classSettings; +} + +- (void)dealloc +{ + if (self.settings) + [self.settings release]; + [super dealloc]; +} + @end diff --git a/iphone/Classes/PhoneGapDelegate.h b/iphone/Classes/PhoneGapDelegate.h index a922a7a4..591012dd 100755 --- a/iphone/Classes/PhoneGapDelegate.h +++ b/iphone/Classes/PhoneGapDelegate.h @@ -1,7 +1,7 @@ - #import #import #import +#import #import "Location.h" #import "Device.h" @@ -43,6 +43,7 @@ //UIImagePickerController *imagePickerController; UIInterfaceOrientation orientationType; + NSDictionary *settings; NSURLConnection *callBackConnection; Sound *sound; @@ -58,6 +59,7 @@ //@property (nonatomic, retain) UIImagePickerController *imagePickerController; @property (nonatomic, retain) UIActivityIndicatorView *activityView; @property (nonatomic, retain) NSMutableDictionary *commandObjects; +@property (nonatomic, retain) NSDictionary *settings; //- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image2 editingInfo:(NSDictionary *)editingInfo; //- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker; diff --git a/iphone/Classes/PhoneGapDelegate.m b/iphone/Classes/PhoneGapDelegate.m index d6ec7a89..4f4ee713 100755 --- a/iphone/Classes/PhoneGapDelegate.m +++ b/iphone/Classes/PhoneGapDelegate.m @@ -8,6 +8,7 @@ @implementation PhoneGapDelegate @synthesize viewController; @synthesize activityView; @synthesize commandObjects; +@synthesize settings; //@synthesize imagePickerController; @@ -24,8 +25,14 @@ -(id) getCommandInstance:(NSString*)className { id obj = [commandObjects objectForKey:className]; if (!obj) { - obj = [[NSClassFromString(className) alloc] initWithWebView:webView]; - NSLog(@"******* Object %@ created from scratch for %@", obj, className); + // attempt to load the settings for this command class + NSDictionary* classSettings; + classSettings = [settings objectForKey:className]; + + if (classSettings) + obj = [[NSClassFromString(className) alloc] initWithWebView:webView settings:classSettings]; + else + obj = [[NSClassFromString(className) alloc] initWithWebView:webView]; [commandObjects setObject:obj forKey:className]; } @@ -39,30 +46,31 @@ -(id) getCommandInstance:(NSString*)className - (void)applicationDidFinishLaunching:(UIApplication *)application { /* - * Settings.plist + * PhoneGap.plist * - * This block of code navigates to the Settings.plist in the Config Group and reads the XML into an Hash (Dictionary) + * This block of code navigates to the PhoneGap.plist in the Config Group and reads the XML into an Hash (Dictionary) * */ NSString *errorDesc = nil; NSPropertyListFormat format; - NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]; + NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"PhoneGap" ofType:@"plist"]; NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath]; NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization - propertyListFromData:plistXML - mutabilityOption:NSPropertyListMutableContainersAndLeaves - format:&format errorDescription:&errorDesc]; + propertyListFromData:plistXML + mutabilityOption:NSPropertyListMutableContainersAndLeaves + format:&format errorDescription:&errorDesc]; + settings = [[NSDictionary alloc] initWithDictionary:temp]; - NSNumber *offline = [temp objectForKey:@"Offline"]; - NSString *url = [temp objectForKey:@"Callback"]; - NSNumber *detectNumber = [temp objectForKey:@"DetectPhoneNumber"]; - NSNumber *useLocation = [temp objectForKey:@"UseLocation"]; - NSNumber *useAccelerometer = [temp objectForKey:@"UseAccelerometer"]; - NSNumber *autoRotate = [temp objectForKey:@"AutoRotate"]; - NSString *startOrientation = [temp objectForKey:@"StartOrientation"]; - NSString *rotateOrientation = [temp objectForKey:@"RotateOrientation"]; - NSString *topStatusBar = [temp objectForKey:@"TopStatusBar"]; - NSString *topActivityIndicator = [temp objectForKey:@"TopActivityIndicator"]; + NSNumber *offline = [settings objectForKey:@"Offline"]; + NSString *url = [settings objectForKey:@"Callback"]; + NSNumber *detectNumber = [settings objectForKey:@"DetectPhoneNumber"]; + NSNumber *useLocation = [settings objectForKey:@"UseLocation"]; + NSNumber *useAccelerometer = [settings objectForKey:@"UseAccelerometer"]; + NSNumber *autoRotate = [settings objectForKey:@"AutoRotate"]; + NSString *startOrientation = [settings objectForKey:@"StartOrientation"]; + NSString *rotateOrientation = [settings objectForKey:@"RotateOrientation"]; + NSString *topStatusBar = [settings objectForKey:@"TopStatusBar"]; + NSString *topActivityIndicator = [settings objectForKey:@"TopActivityIndicator"]; /* * Fire up the GPS Service right away as it takes a moment for data to come back. @@ -115,7 +123,7 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application ]]; /* - * detectNumber - If we want to Automagically convery phone numbers to links - Set in Settings.plist + * detectNumber - If we want to Automagically convery phone numbers to links - Set in PhoneGap.plist * Value should be BOOL (YES|NO) */ webView.detectsPhoneNumbers = [detectNumber boolValue]; @@ -153,7 +161,7 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application /* * rotateOrientation - This option is only enabled when AutoRotate is enabled. If the phone is still rotated * when AutoRotate is disabled, this will control what orientations will be rotated to. If you wish your app to - * only use landscape or portrait orientations, change the value in Settings.plist to indicate that. + * only use landscape or portrait orientations, change the value in PhoneGap.plist to indicate that. * Value should be one of: any, portrait, landscape */ [viewController setRotateOrientation:rotateOrientation]; @@ -175,7 +183,14 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application topStatusBarStyle = UIStatusBarStyleDefault; } if ([topStatusBar isEqualToString:@"none"]) { + int toolbarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height; [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; + CGRect webViewBounds = webView.bounds; + [webView setFrame:CGRectMake(webViewBounds.origin.x, + webViewBounds.origin.y - toolbarHeight, + webViewBounds.size.width, + webViewBounds.size.height + toolbarHeight + )]; } else { [[UIApplication sharedApplication] setStatusBarStyle:topStatusBarStyle animated:NO]; } @@ -212,7 +227,29 @@ - (void)webViewDidStartLoad:(UIWebView *)theWebView { /* * This is the Device.platform information */ - [theWebView stringByEvaluatingJavaScriptFromString:[[Device alloc] init]]; + NSString *deviceStr = [[Device alloc] init]; + + /* Settings.plist + * Read the optional Settings.plist file and push these user-defined settings down into the web application. + * This can be useful for supplying build-time configuration variables down to the app to change its behaviour, + * such as specifying Full / Lite version, or localization (English vs German, for instance). + */ + NSString *errorDesc = nil; + NSPropertyListFormat format; + NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]; + NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath]; + NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization + propertyListFromData:plistXML + mutabilityOption:NSPropertyListMutableContainersAndLeaves + format:&format errorDescription:&errorDesc]; + if ([temp respondsToSelector:@selector(JSONFragment)]) { + NSString *initString = [[NSString alloc] initWithFormat:@"%@\nwindow.Settings = %@;", deviceStr, [temp JSONFragment]]; + NSLog(@"%@", initString); + [theWebView stringByEvaluatingJavaScriptFromString:initString]; + [initString release]; + } else { + [theWebView stringByEvaluatingJavaScriptFromString:deviceStr]; + } } - (void)webViewDidFinishLoad:(UIWebView *)theWebView { @@ -301,9 +338,11 @@ - (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest NSString* className = [components objectAtIndex:0]; NSString* methodName = [components objectAtIndex:1]; + // Fetch an instance of this class + PhoneGapCommand* obj = [self getCommandInstance:className]; + // construct the fill method name to ammend the second argument. NSString* fullMethodName = [[NSString alloc] initWithFormat:@"%@:withDict:", methodName]; - PhoneGapCommand* obj = [self getCommandInstance:className]; if ([obj respondsToSelector:NSSelectorFromString(fullMethodName)]) { [obj performSelector:NSSelectorFromString(fullMethodName) withObject:arguments withObject:options]; diff --git a/iphone/Classes/UIControls.h b/iphone/Classes/UIControls.h index 7c01576b..c31119e8 100644 --- a/iphone/Classes/UIControls.h +++ b/iphone/Classes/UIControls.h @@ -8,13 +8,42 @@ #import #import -/* #import -#import -*/ +#import + #import "PhoneGapCommand.h" -@interface UIControls : PhoneGapCommand { +@interface UIControls : PhoneGapCommand { + UITabBar* tabBar; + NSMutableDictionary* tabBarItems; + + UIToolbar* toolBar; + UIBarButtonItem* toolBarTitle; + NSMutableDictionary* toolBarItems; } +/* Tab Bar methods + */ +- (void)createTabBar:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)showTabBar:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)hideTabBar:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)showTabBarItems:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)createTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)updateTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)selectTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options; + +/* Tool Bar methods + */ +- (void)createToolBar:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)setToolBarTitle:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)toolBarTitleClicked; + +/* +- (void)createToolBarButton:(NSArray*)arguments withDict:(NSDictionary*)options; +- (void)createToolBarTitle:(NSArray*)arguments withDict:(NSDictionary*)options; +*/ + +//- (void)setToolBarTitle:(NSArray*)arguments withDict:(NSDictionary*)options; +//- (void)setToolBarButtons:(NSArray*)arguments withDict:(NSDictionary*)options; + @end diff --git a/iphone/Classes/UIControls.m b/iphone/Classes/UIControls.m index 3641bf6f..41f8db56 100644 --- a/iphone/Classes/UIControls.m +++ b/iphone/Classes/UIControls.m @@ -9,12 +9,427 @@ #import "UIControls.h" @implementation UIControls +@synthesize webView; + +-(PhoneGapCommand*) initWithWebView:(UIWebView*)theWebView +{ + self = [super initWithWebView:theWebView]; + if (self) { + tabBarItems = [[NSMutableDictionary alloc] initWithCapacity:5]; + + } + return self; +} + +/** + * Create a native tab bar at either the top or the bottom of the display. + * @brief creates a tab bar + * @param arguments unused + * @param options unused + */ +- (void)createTabBar:(NSArray*)arguments withDict:(NSDictionary*)options +{ + tabBar = [UITabBar new]; + [tabBar sizeToFit]; + tabBar.delegate = self; + tabBar.multipleTouchEnabled = NO; + tabBar.autoresizesSubviews = YES; + tabBar.hidden = YES; + tabBar.userInteractionEnabled = YES; + + [self.webView.superview addSubview:tabBar]; +} + +/** + * Show the tab bar after its been created. + * @brief show the tab bar + * @param arguments unused + * @param options used to indicate options for where and how the tab bar should be placed + * - \c height integer indicating the height of the tab bar (default: \c 49) + * - \c position specifies whether the tab bar will be placed at the \c top or \c bottom of the screen (default: \c bottom) + */ +- (void)showTabBar:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!tabBar) + [self createTabBar:nil options:nil]; + + CGFloat height = 49.0f; + BOOL atBottom = YES; + + NSDictionary* tabSettings = [settings objectForKey:@"TabBarSettings"]; + if (tabSettings) { + height = [[tabSettings objectForKey:@"height"] floatValue]; + atBottom = [[tabSettings objectForKey:@"position"] isEqualTo:@"bottom"]; + } + tabBar.hidden = NO; + + CGRect webViewBounds = webView.bounds; + CGRect tabBarBounds; + if (atBottom) { + tabBarBounds = CGRectMake( + webViewBounds.origin.x, + webViewBounds.origin.y + webViewBounds.size.height - height, + webViewBounds.size.width, + height + ); + webViewBounds = CGRectMake( + webViewBounds.origin.x, + webViewBounds.origin.y, + webViewBounds.size.width, + webViewBounds.size.height - height + ); + } else { + tabBarBounds = CGRectMake( + webViewBounds.origin.x, + webViewBounds.origin.y, + webViewBounds.size.width, + height + ); + webViewBounds = CGRectMake( + webViewBounds.origin.x, + webViewBounds.origin.y + height, + webViewBounds.size.width, + webViewBounds.size.height - height + ); + } + + [tabBar setFrame:tabBarBounds]; + [webView setFrame:webViewBounds]; +} + +/** + * Hide the tab bar + * @brief hide the tab bar + * @param arguments unused + * @param options unused + */ +- (void)hideTabBar:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!tabBar) + [self createTabBar:nil options:nil]; + tabBar.hidden = YES; +} + +/** + * Create a new tab bar item for use on a previously created tab bar. Use ::showTabBarItems to show the new item on the tab bar. + * + * If the supplied image name is one of the labels listed below, then this method will construct a tab button + * using the standard system buttons. Note that if you use one of the system images, that the \c title you supply will be ignored. + * - Tab Buttons + * - tabButton:More + * - tabButton:Favorites + * - tabButton:Featured + * - tabButton:TopRated + * - tabButton:Recents + * - tabButton:Contacts + * - tabButton:History + * - tabButton:Bookmarks + * - tabButton:Search + * - tabButton:Downloads + * - tabButton:MostRecent + * - tabButton:MostViewed + * @brief create a tab bar item + * @param arguments Parameters used to create the tab bar + * -# \c name internal name to refer to this tab by + * -# \c title title text to show on the tab, or null if no text should be shown + * -# \c image image filename or internal identifier to show, or null if now image should be shown + * -# \c tag unique number to be used as an internal reference to this button + * @param options Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if nil or unspecified, the badge will be hidden + */ +- (void)createTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!tabBar) + [self createTabBar:nil options:nil]; + + NSString *name = [arguments objectAtIndex:0]; + NSString *title = [arguments objectAtIndex:1]; + NSString *imageName = [arguments objectAtIndex:2]; + int tag = [[arguments objectAtIndex:3] intValue]; + + UITabBarItem *item; + if ([[imageName substringWithRange:NSMakeRange(0, 10)] isEqualTo:@"tabButton:"]) { + UIBarButtonSystemItem systemItem; + if ([imageName isEqualTo:@"tabButton:More"]) systemItem = UITabBarSystemItemMore; + if ([imageName isEqualTo:@"tabButton:Favorites"]) systemItem = UITabBarSystemItemFavorites; + if ([imageName isEqualTo:@"tabButton:Featured"]) systemItem = UITabBarSystemItemFeatured; + if ([imageName isEqualTo:@"tabButton:TopRated"]) systemItem = UITabBarSystemItemTopRated; + if ([imageName isEqualTo:@"tabButton:Recents"]) systemItem = UITabBarSystemItemRecents; + if ([imageName isEqualTo:@"tabButton:Contacts"]) systemItem = UITabBarSystemItemContacts; + if ([imageName isEqualTo:@"tabButton:History"]) systemItem = UITabBarSystemItemHistory; + if ([imageName isEqualTo:@"tabButton:Bookmarks"]) systemItem = UITabBarSystemItemBookmarks; + if ([imageName isEqualTo:@"tabButton:Search"]) systemItem = UITabBarSystemItemSearch; + if ([imageName isEqualTo:@"tabButton:Downloads"]) systemItem = UITabBarSystemItemDownloads; + if ([imageName isEqualTo:@"tabButton:MostRecent"]) systemItem = UITabBarSystemItemMostRecent; + if ([imageName isEqualTo:@"tabButton:MostViewed"]) systemItem = UITabBarSystemItemMostViewed; + item = [[UITabBarItem alloc] initWithTabBarSystemItem:systemItem tag:tag]; + } + + if (!item) { + NSLog(@"Creating with custom image and title"); + UIImage *image = [[UIImage alloc] initWithContentsOfFile:imageName]; + item = [[UITabBarItem alloc] initWithTitle:title image:image tag:tag]; + } + + if ([options objectForKey:@"badge"]) + item.badgeValue = [options objectForKey:@"badge"]; + + [tabBarItems setObject:item forKey:name]; +} + +/** + * Update an existing tab bar item to change its badge value. + * @brief update the badge value on an existing tab bar item + * @param arguments Parameters used to identify the tab bar item to update + * -# \c name internal name used to represent this item when it was created + * @param options Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if nil or unspecified, the badge will be hidden + */ +- (void)updateTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!tabBar) + [self createTabBar:nil options:nil]; + + NSString *name = [arguments objectAtIndex:0]; + UITabBarItem *item = [tabBarItems objectForKey:name]; + if (item) + item.badgeValue = [options objectForKey:@"badge"]; +} + +/** + * Show previously created items on the tab bar + * @brief show a list of tab bar items + * @param arguments the item names to be shown + * @param options dictionary of options, notable options including: + * - \c animate indicates that the items should animate onto the tab bar + * @see createTabBarItem + * @see createTabBar + */ +- (void)showTabBarItems:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!tabBar) + [self createTabBar:nil options:nil]; + + int i, count = [arguments count]; + NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:count]; + for (i = 0; i < count; i++) { + NSString *itemName = [arguments objectAtIndex:i]; + UITabBarItem *item = [tabBarItems objectForKey:itemName]; + if (item) + [items addObject:item]; + } + + BOOL animateItems = YES; + if ([options objectForKey:@"animate"]) + animateItems = [(NSString*)[options objectForKey:@"animate"] boolValue]; + [tabBar setItems:items animated:animateItems]; +} + +/** + * Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item. + * @brief manually select a tab bar item + * @param arguments the name of the tab bar item to select + * @see createTabBarItem + * @see showTabBarItems + */ +- (void)selectTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!tabBar) + [self createTabBar:nil options:nil]; + + NSString *itemName = [arguments objectAtIndex:0]; + UITabBarItem *item = [tabBarItems objectForKey:itemName]; + if (item) + tabBar.selectedItem = item; + else + tabBar.selectedItem = nil; +} + +/* + * - Tool Buttons + * - toolButton:Done + * - toolButton:Cancel + * - toolButton:Edit + * - toolButton:Save + * - toolButton:Add + * - toolButton:FlexibleSpace + * - toolButton:FixedSpace + * - toolButton:Compose + * - toolButton:Reply + * - toolButton:Action + * - toolButton:Organize + * - toolButton:Bookmarks + * - toolButton:Search + * - toolButton:Refresh + * - toolButton:Stop + * - toolButton:Camera + * - toolButton:Trash + * - toolButton:Play + * - toolButton:Pause + * - toolButton:Rewind + * - toolButton:FastForward + */ +/* +-(UIBarButtonSystemItem) getSystemItemFromString:(NSString*)imageName +{ + if ([[imageName substringWithRange:NSMakeRange(0, 10)] isEqualTo:@"tabButton:"]) { + NSLog(@"Tab button!!"); + if ([imageName isEqualTo:@"tabButton:More"]) return UITabBarSystemItemMore; + if ([imageName isEqualTo:@"tabButton:Favorites"]) return UITabBarSystemItemFavorites; + if ([imageName isEqualTo:@"tabButton:Featured"]) return UITabBarSystemItemFeatured; + if ([imageName isEqualTo:@"tabButton:TopRated"]) return UITabBarSystemItemTopRated; + if ([imageName isEqualTo:@"tabButton:Recents"]) return UITabBarSystemItemRecents; + if ([imageName isEqualTo:@"tabButton:Contacts"]) return UITabBarSystemItemContacts; + if ([imageName isEqualTo:@"tabButton:History"]) return UITabBarSystemItemHistory; + if ([imageName isEqualTo:@"tabButton:Bookmarks"]) return UITabBarSystemItemBookmarks; + if ([imageName isEqualTo:@"tabButton:Search"]) return UITabBarSystemItemSearch; + if ([imageName isEqualTo:@"tabButton:Downloads"]) return UITabBarSystemItemDownloads; + if ([imageName isEqualTo:@"tabButton:MostRecent"]) return UITabBarSystemItemMostRecent; + if ([imageName isEqualTo:@"tabButton:MostViewed"]) return UITabBarSystemItemMostViewed; + NSLog(@"Couldn't figure out what it was"); + return -1; + } + else if ([[imageName substringWithRange:NSMakeRange(0, 11)] isEqualTo:@"toolButton:"]) { + NSLog(@"Tool button!!"); + if ([imageName isEqualTo:@"toolButton:Done"]) return UIBarButtonSystemItemDone; + if ([imageName isEqualTo:@"toolButton:Cancel"]) return UIBarButtonSystemItemCancel; + if ([imageName isEqualTo:@"toolButton:Edit"]) return UIBarButtonSystemItemEdit; + if ([imageName isEqualTo:@"toolButton:Save"]) return UIBarButtonSystemItemSave; + if ([imageName isEqualTo:@"toolButton:Add"]) return UIBarButtonSystemItemAdd; + if ([imageName isEqualTo:@"toolButton:FlexibleSpace"]) return UIBarButtonSystemItemFlexibleSpace; + if ([imageName isEqualTo:@"toolButton:FixedSpace"]) return UIBarButtonSystemItemFixedSpace; + if ([imageName isEqualTo:@"toolButton:Compose"]) return UIBarButtonSystemItemCompose; + if ([imageName isEqualTo:@"toolButton:Reply"]) return UIBarButtonSystemItemReply; + if ([imageName isEqualTo:@"toolButton:Action"]) return UIBarButtonSystemItemAction; + if ([imageName isEqualTo:@"toolButton:Organize"]) return UIBarButtonSystemItemOrganize; + if ([imageName isEqualTo:@"toolButton:Bookmarks"]) return UIBarButtonSystemItemBookmarks; + if ([imageName isEqualTo:@"toolButton:Search"]) return UIBarButtonSystemItemSearch; + if ([imageName isEqualTo:@"toolButton:Refresh"]) return UIBarButtonSystemItemRefresh; + if ([imageName isEqualTo:@"toolButton:Stop"]) return UIBarButtonSystemItemStop; + if ([imageName isEqualTo:@"toolButton:Camera"]) return UIBarButtonSystemItemCamera; + if ([imageName isEqualTo:@"toolButton:Trash"]) return UIBarButtonSystemItemTrash; + if ([imageName isEqualTo:@"toolButton:Play"]) return UIBarButtonSystemItemPlay; + if ([imageName isEqualTo:@"toolButton:Pause"]) return UIBarButtonSystemItemPause; + if ([imageName isEqualTo:@"toolButton:Rewind"]) return UIBarButtonSystemItemRewind; + if ([imageName isEqualTo:@"toolButton:FastForward"]) return UIBarButtonSystemItemFastForward; + return -1; + } else { + return -1; + } +} +*/ + +- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item +{ + NSString * jsCallBack = [NSString stringWithFormat:@"uicontrols.tabBarItemSelected(%d);", item.tag]; + [webView stringByEvaluatingJavaScriptFromString:jsCallBack]; +} + +/*********************************************************************************/ +- (void)createToolBar:(NSArray*)arguments withDict:(NSDictionary*)options +{ + CGFloat height = 39.0f; + BOOL atTop = YES; + UIBarStyle style = UIBarStyleDefault; + + NSDictionary* toolBarSettings = [settings objectForKey:@"ToolBarSettings"]; + if (toolBarSettings) { + if ([toolBarSettings objectForKey:@"height"]) + height = [[toolBarSettings objectForKey:@"height"] floatValue]; + if ([toolBarSettings objectForKey:@"position"]) + atTop = [[toolBarSettings objectForKey:@"position"] isEqualTo:@"top"]; + + NSString *styleStr = [toolBarSettings objectForKey:@"style"]; + if ([styleStr isEqualTo:@"Default"]) + style = UIBarStyleDefault; + else if ([styleStr isEqualTo:@"BlackOpaque"]) + style = UIBarStyleBlackOpaque; + else if ([styleStr isEqualTo:@"BlackTranslucent"]) + style = UIBarStyleBlackTranslucent; + } + + CGRect webViewBounds = webView.bounds; + CGRect toolBarBounds = CGRectMake( + webViewBounds.origin.x, + webViewBounds.origin.y, + webViewBounds.size.width, + height + ); + webViewBounds = CGRectMake( + webViewBounds.origin.x, + webViewBounds.origin.y + height, + webViewBounds.size.width, + webViewBounds.size.height - height + ); + toolBar = [[UIToolbar alloc] initWithFrame:toolBarBounds]; + [toolBar sizeToFit]; + toolBar.hidden = NO; + toolBar.multipleTouchEnabled = NO; + toolBar.autoresizesSubviews = YES; + toolBar.userInteractionEnabled = YES; + toolBar.barStyle = style; + + [toolBar setFrame:toolBarBounds]; + [webView setFrame:webViewBounds]; + + [self.webView.superview addSubview:toolBar]; +} /* -+ (void)createTabBar:(NSArray*)arguments withDict:(NSDictionary*)options +- (void)createToolBarButton:(NSArray*)arguments withDict:(NSDictionary*)options { - id* controller = [[UITabBar alloc] initWithFrame:( } */ +/* +- (void)createToolBarItem:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!toolBar) + [self createToolBar:nil options:nil]; + + NSString *name = [arguments objectAtIndex:0]; + NSString *title = [arguments objectAtIndex:1]; + NSString *style = [arguments objectAtIndex:2]; + UIBarButtonItemStyle styleRef = UIBarButtonItemStylePlain; + if ([style isEqualTo:@"plain"]) + styleRef = UIBarButtonItemStylePlain; + else if ([style isEqualTo:@"border"]) + styleRef = UIBarButtonItemStyleBordered; + else if ([style isEqualTo: + + + UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:title style:styleRef target:self action:@selector(clickedToolBarTitle)]; + [toolBarItems setObject:item forKey:name]; +} +*/ + +- (void)setToolBarTitle:(NSArray*)arguments withDict:(NSDictionary*)options +{ + if (!toolBar) + [self createToolBar:nil withDict:nil]; + + NSString *title = [arguments objectAtIndex:0]; + if (!toolBarTitle) { + toolBarTitle = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(toolBarTitleClicked)]; + } else { + toolBarTitle.title = title; + } + + UIBarButtonItem *space1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; + UIBarButtonItem *space2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; + NSArray *items = [[NSArray alloc] initWithObjects:space1, toolBarTitle, space2, nil]; + [toolBar setItems:items]; +} + +- (void)toolBarTitleClicked +{ + NSLog(@"Toolbar clicked"); +} + +- (void)dealloc +{ + if (tabBar) + [tabBar release]; + [super dealloc]; +} @end diff --git a/iphone/Frameworks/JSON/iphoneos.sdk/SDKSettings.plist b/iphone/Frameworks/JSON/iphoneos.sdk/SDKSettings.plist new file mode 100644 index 00000000..4307f277 --- /dev/null +++ b/iphone/Frameworks/JSON/iphoneos.sdk/SDKSettings.plist @@ -0,0 +1,49 @@ + + + + + AlternateSDK + jsoniphonesimulator2.0 + CanonicalName + jsoniphoneos2.0 + CustomProperties + + DefaultProperties + + AD_HOC_CODE_SIGNING_ALLOWED + NO + CODE_SIGN_ENTITLEMENTS + + CODE_SIGN_RESOURCE_RULES_PATH + $(SDKROOT)/ResourceRules.plist + DEAD_CODE_STRIPPING + YES + ENTITLEMENTS_REQUIRED + YES + GCC_THUMB_SUPPORT + YES + IPHONEOS_DEPLOYMENT_TARGET + 2.0 + MACOSX_DEPLOYMENT_TARGET + 10.5 + PLATFORM_NAME + iphoneos + + DisplayName + Device - iPhone OS 2.0 + FamilyIdentifier + iphoneos + FamilyName + iPhone OS + IsBaseSDK + NO + MaximumOSDeploymentTarget + 10.5 + MinimalDisplayName + Device + MinimumSupportedToolsVersion + 3.1 + Version + 2.0 + + diff --git a/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/JSON.h b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/JSON.h new file mode 100644 index 00000000..54b26f82 --- /dev/null +++ b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/JSON.h @@ -0,0 +1,44 @@ +/* +Copyright (c) 2007, Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +@mainpage A strict JSON parser and generator for Objective-C + +JSON (JavaScript Object Notation) is a lightweight data-interchange +format. This framework provides two apis for parsing and generating +JSON. One standard object-based and a higher level api consisting of +categories added to existing Objective-C classes. + +Learn more on the http://code.google.com/p/json-framework project site. +*/ + +#import +#import +#import + diff --git a/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/NSObject+SBJSON.h b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/NSObject+SBJSON.h new file mode 100644 index 00000000..038ea8e3 --- /dev/null +++ b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/NSObject+SBJSON.h @@ -0,0 +1,60 @@ +/* +Copyright (C) 2007 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + + +/// Adds JSON generation to NSObject subclasses +@interface NSObject (NSObject_SBJSON) + +/** + @brief Returns a string containing the receiver encoded as a JSON fragment. + + This method is added as a category on NSObject but is only actually + supported for the following objects: + @li NSDictionary + @li NSArray + @li NSString + @li NSNumber (also used for booleans) + @li NSNull + */ +- (NSString *)JSONFragment; + +/** + @brief Returns a string containing the receiver encoded in JSON. + + This method is added as a category on NSObject but is only actually + supported for the following objects: + @li NSDictionary + @li NSArray + */ +- (NSString *)JSONRepresentation; + +@end + diff --git a/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/NSString+SBJSON.h b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/NSString+SBJSON.h new file mode 100644 index 00000000..69cfa4fd --- /dev/null +++ b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/NSString+SBJSON.h @@ -0,0 +1,41 @@ +/* +Copyright (C) 2007 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + +/// Adds JSON parsing to NSString +@interface NSString (NSString_SBJSON) + +/// Returns the object represented in the receiver, or nil on error. +- (id)JSONFragmentValue; + +/// Returns the dictionary or array represented in the receiver, or nil on error. +- (id)JSONValue; + +@end diff --git a/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/SBJSON.h b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/SBJSON.h new file mode 100644 index 00000000..c931d464 --- /dev/null +++ b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/include/JSON/SBJSON.h @@ -0,0 +1,137 @@ +/* +Copyright (C) 2008 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + +extern NSString * SBJSONErrorDomain; + +enum { + EUNSUPPORTED = 1, + EPARSENUM, + EPARSE, + EFRAGMENT, + ECTRL, + EUNICODE, + EDEPTH, + EESCAPE, + ETRAILCOMMA, + ETRAILGARBAGE, + EEOF, + EINPUT +}; + +/** +@brief A strict JSON parser and generator + +This is the parser and generator underlying the categories added to +NSString and various other objects. + +Objective-C types are mapped to JSON types and back in the following way: + +@li NSNull -> Null -> NSNull +@li NSString -> String -> NSMutableString +@li NSArray -> Array -> NSMutableArray +@li NSDictionary -> Object -> NSMutableDictionary +@li NSNumber (-initWithBool:) -> Boolean -> NSNumber -initWithBool: +@li NSNumber -> Number -> NSDecimalNumber + +In JSON the keys of an object must be strings. NSDictionary keys need +not be, but attempting to convert an NSDictionary with non-string keys +into JSON will throw an exception. + +NSNumber instances created with the +numberWithBool: method are +converted into the JSON boolean "true" and "false" values, and vice +versa. Any other NSNumber instances are converted to a JSON number the +way you would expect. JSON numbers turn into NSDecimalNumber instances, +as we can thus avoid any loss of precision. + +Strictly speaking correctly formed JSON text must have exactly +one top-level container. (Either an Array or an Object.) Scalars, +i.e. nulls, numbers, booleans and strings, are not valid JSON on their own. +It can be quite convenient to pretend that such fragments are valid +JSON however, and this class lets you do so. + +This class does its best to be as strict as possible, both in what it +accepts and what it generates. (Other than the above mentioned support +for JSON fragments.) For example, it does not support trailing commas +in arrays or objects. Nor does it support embedded comments, or +anything else not in the JSON specification. + +*/ +@interface SBJSON : NSObject { + BOOL humanReadable; + BOOL sortKeys; + NSUInteger maxDepth; + +@private + // Used temporarily during scanning/generation + NSUInteger depth; + const char *c; +} + +/// Whether we are generating human-readable (multiline) JSON +/** + Set whether or not to generate human-readable JSON. The default is NO, which produces + JSON without any whitespace. (Except inside strings.) If set to YES, generates human-readable + JSON with linebreaks after each array value and dictionary key/value pair, indented two + spaces per nesting level. + */ +@property BOOL humanReadable; + +/// Whether or not to sort the dictionary keys in the output +/** The default is to not sort the keys. */ +@property BOOL sortKeys; + +/// The maximum depth the parser will go to +/** Defaults to 512. */ +@property NSUInteger maxDepth; + +/// Return JSON representation of an array or dictionary +- (NSString*)stringWithObject:(id)value error:(NSError**)error; + +/// Return JSON representation of any legal JSON value +- (NSString*)stringWithFragment:(id)value error:(NSError**)error; + +/// Return the object represented by the given string +- (id)objectWithString:(NSString*)jsonrep error:(NSError**)error; + +/// Return the fragment represented by the given string +- (id)fragmentWithString:(NSString*)jsonrep error:(NSError**)error; + +/// Return JSON representation (or fragment) for the given object +- (NSString*)stringWithObject:(id)value + allowScalar:(BOOL)x + error:(NSError**)error; + +/// Parse the string and return the represented object (or scalar) +- (id)objectWithString:(id)value + allowScalar:(BOOL)x + error:(NSError**)error; + +@end diff --git a/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/lib/libjson.a b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/lib/libjson.a new file mode 100644 index 00000000..9f8c01fa Binary files /dev/null and b/iphone/Frameworks/JSON/iphoneos.sdk/usr/local/lib/libjson.a differ diff --git a/iphone/Frameworks/JSON/iphonesimulator.sdk/SDKSettings.plist b/iphone/Frameworks/JSON/iphonesimulator.sdk/SDKSettings.plist new file mode 100644 index 00000000..73581f56 --- /dev/null +++ b/iphone/Frameworks/JSON/iphonesimulator.sdk/SDKSettings.plist @@ -0,0 +1,35 @@ + + + + + CanonicalName + jsoniphonesimulator2.0 + CustomProperties + + DefaultProperties + + GCC_PRODUCT_TYPE_PREPROCESSOR_DEFINITIONS + __IPHONE_OS_VERSION_MIN_REQUIRED=20000 + MACOSX_DEPLOYMENT_TARGET + 10.5 + PLATFORM_NAME + iphonesimulator + + DisplayName + Simulator - iPhone OS 2.0 + FamilyIdentifier + iphoneos + FamilyName + iPhone OS + MaximumDeploymentTarget + 10.5 + MinimalDisplayName + Simulator + MinimumSupportedToolsVersion + 3.1 + Version + 2.0 + isBaseSDK + NO + + diff --git a/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/JSON.h b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/JSON.h new file mode 100644 index 00000000..54b26f82 --- /dev/null +++ b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/JSON.h @@ -0,0 +1,44 @@ +/* +Copyright (c) 2007, Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +@mainpage A strict JSON parser and generator for Objective-C + +JSON (JavaScript Object Notation) is a lightweight data-interchange +format. This framework provides two apis for parsing and generating +JSON. One standard object-based and a higher level api consisting of +categories added to existing Objective-C classes. + +Learn more on the http://code.google.com/p/json-framework project site. +*/ + +#import +#import +#import + diff --git a/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/NSObject+SBJSON.h b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/NSObject+SBJSON.h new file mode 100644 index 00000000..038ea8e3 --- /dev/null +++ b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/NSObject+SBJSON.h @@ -0,0 +1,60 @@ +/* +Copyright (C) 2007 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + + +/// Adds JSON generation to NSObject subclasses +@interface NSObject (NSObject_SBJSON) + +/** + @brief Returns a string containing the receiver encoded as a JSON fragment. + + This method is added as a category on NSObject but is only actually + supported for the following objects: + @li NSDictionary + @li NSArray + @li NSString + @li NSNumber (also used for booleans) + @li NSNull + */ +- (NSString *)JSONFragment; + +/** + @brief Returns a string containing the receiver encoded in JSON. + + This method is added as a category on NSObject but is only actually + supported for the following objects: + @li NSDictionary + @li NSArray + */ +- (NSString *)JSONRepresentation; + +@end + diff --git a/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/NSString+SBJSON.h b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/NSString+SBJSON.h new file mode 100644 index 00000000..69cfa4fd --- /dev/null +++ b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/NSString+SBJSON.h @@ -0,0 +1,41 @@ +/* +Copyright (C) 2007 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + +/// Adds JSON parsing to NSString +@interface NSString (NSString_SBJSON) + +/// Returns the object represented in the receiver, or nil on error. +- (id)JSONFragmentValue; + +/// Returns the dictionary or array represented in the receiver, or nil on error. +- (id)JSONValue; + +@end diff --git a/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/SBJSON.h b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/SBJSON.h new file mode 100644 index 00000000..c931d464 --- /dev/null +++ b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/include/JSON/SBJSON.h @@ -0,0 +1,137 @@ +/* +Copyright (C) 2008 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + +extern NSString * SBJSONErrorDomain; + +enum { + EUNSUPPORTED = 1, + EPARSENUM, + EPARSE, + EFRAGMENT, + ECTRL, + EUNICODE, + EDEPTH, + EESCAPE, + ETRAILCOMMA, + ETRAILGARBAGE, + EEOF, + EINPUT +}; + +/** +@brief A strict JSON parser and generator + +This is the parser and generator underlying the categories added to +NSString and various other objects. + +Objective-C types are mapped to JSON types and back in the following way: + +@li NSNull -> Null -> NSNull +@li NSString -> String -> NSMutableString +@li NSArray -> Array -> NSMutableArray +@li NSDictionary -> Object -> NSMutableDictionary +@li NSNumber (-initWithBool:) -> Boolean -> NSNumber -initWithBool: +@li NSNumber -> Number -> NSDecimalNumber + +In JSON the keys of an object must be strings. NSDictionary keys need +not be, but attempting to convert an NSDictionary with non-string keys +into JSON will throw an exception. + +NSNumber instances created with the +numberWithBool: method are +converted into the JSON boolean "true" and "false" values, and vice +versa. Any other NSNumber instances are converted to a JSON number the +way you would expect. JSON numbers turn into NSDecimalNumber instances, +as we can thus avoid any loss of precision. + +Strictly speaking correctly formed JSON text must have exactly +one top-level container. (Either an Array or an Object.) Scalars, +i.e. nulls, numbers, booleans and strings, are not valid JSON on their own. +It can be quite convenient to pretend that such fragments are valid +JSON however, and this class lets you do so. + +This class does its best to be as strict as possible, both in what it +accepts and what it generates. (Other than the above mentioned support +for JSON fragments.) For example, it does not support trailing commas +in arrays or objects. Nor does it support embedded comments, or +anything else not in the JSON specification. + +*/ +@interface SBJSON : NSObject { + BOOL humanReadable; + BOOL sortKeys; + NSUInteger maxDepth; + +@private + // Used temporarily during scanning/generation + NSUInteger depth; + const char *c; +} + +/// Whether we are generating human-readable (multiline) JSON +/** + Set whether or not to generate human-readable JSON. The default is NO, which produces + JSON without any whitespace. (Except inside strings.) If set to YES, generates human-readable + JSON with linebreaks after each array value and dictionary key/value pair, indented two + spaces per nesting level. + */ +@property BOOL humanReadable; + +/// Whether or not to sort the dictionary keys in the output +/** The default is to not sort the keys. */ +@property BOOL sortKeys; + +/// The maximum depth the parser will go to +/** Defaults to 512. */ +@property NSUInteger maxDepth; + +/// Return JSON representation of an array or dictionary +- (NSString*)stringWithObject:(id)value error:(NSError**)error; + +/// Return JSON representation of any legal JSON value +- (NSString*)stringWithFragment:(id)value error:(NSError**)error; + +/// Return the object represented by the given string +- (id)objectWithString:(NSString*)jsonrep error:(NSError**)error; + +/// Return the fragment represented by the given string +- (id)fragmentWithString:(NSString*)jsonrep error:(NSError**)error; + +/// Return JSON representation (or fragment) for the given object +- (NSString*)stringWithObject:(id)value + allowScalar:(BOOL)x + error:(NSError**)error; + +/// Parse the string and return the represented object (or scalar) +- (id)objectWithString:(id)value + allowScalar:(BOOL)x + error:(NSError**)error; + +@end diff --git a/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/lib/libjson.a b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/lib/libjson.a new file mode 100644 index 00000000..d127448f Binary files /dev/null and b/iphone/Frameworks/JSON/iphonesimulator.sdk/usr/local/lib/libjson.a differ diff --git a/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/JSON.h b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/JSON.h new file mode 100644 index 00000000..54b26f82 --- /dev/null +++ b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/JSON.h @@ -0,0 +1,44 @@ +/* +Copyright (c) 2007, Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +@mainpage A strict JSON parser and generator for Objective-C + +JSON (JavaScript Object Notation) is a lightweight data-interchange +format. This framework provides two apis for parsing and generating +JSON. One standard object-based and a higher level api consisting of +categories added to existing Objective-C classes. + +Learn more on the http://code.google.com/p/json-framework project site. +*/ + +#import +#import +#import + diff --git a/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/NSObject+SBJSON.h b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/NSObject+SBJSON.h new file mode 100644 index 00000000..038ea8e3 --- /dev/null +++ b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/NSObject+SBJSON.h @@ -0,0 +1,60 @@ +/* +Copyright (C) 2007 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + + +/// Adds JSON generation to NSObject subclasses +@interface NSObject (NSObject_SBJSON) + +/** + @brief Returns a string containing the receiver encoded as a JSON fragment. + + This method is added as a category on NSObject but is only actually + supported for the following objects: + @li NSDictionary + @li NSArray + @li NSString + @li NSNumber (also used for booleans) + @li NSNull + */ +- (NSString *)JSONFragment; + +/** + @brief Returns a string containing the receiver encoded in JSON. + + This method is added as a category on NSObject but is only actually + supported for the following objects: + @li NSDictionary + @li NSArray + */ +- (NSString *)JSONRepresentation; + +@end + diff --git a/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/NSString+SBJSON.h b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/NSString+SBJSON.h new file mode 100644 index 00000000..69cfa4fd --- /dev/null +++ b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/NSString+SBJSON.h @@ -0,0 +1,41 @@ +/* +Copyright (C) 2007 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + +/// Adds JSON parsing to NSString +@interface NSString (NSString_SBJSON) + +/// Returns the object represented in the receiver, or nil on error. +- (id)JSONFragmentValue; + +/// Returns the dictionary or array represented in the receiver, or nil on error. +- (id)JSONValue; + +@end diff --git a/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/SBJSON.h b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/SBJSON.h new file mode 100644 index 00000000..c931d464 --- /dev/null +++ b/iphone/Frameworks/JSON/macosx.sdk/usr/local/include/JSON/SBJSON.h @@ -0,0 +1,137 @@ +/* +Copyright (C) 2008 Stig Brautaset. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + Neither the name of the author nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import + +extern NSString * SBJSONErrorDomain; + +enum { + EUNSUPPORTED = 1, + EPARSENUM, + EPARSE, + EFRAGMENT, + ECTRL, + EUNICODE, + EDEPTH, + EESCAPE, + ETRAILCOMMA, + ETRAILGARBAGE, + EEOF, + EINPUT +}; + +/** +@brief A strict JSON parser and generator + +This is the parser and generator underlying the categories added to +NSString and various other objects. + +Objective-C types are mapped to JSON types and back in the following way: + +@li NSNull -> Null -> NSNull +@li NSString -> String -> NSMutableString +@li NSArray -> Array -> NSMutableArray +@li NSDictionary -> Object -> NSMutableDictionary +@li NSNumber (-initWithBool:) -> Boolean -> NSNumber -initWithBool: +@li NSNumber -> Number -> NSDecimalNumber + +In JSON the keys of an object must be strings. NSDictionary keys need +not be, but attempting to convert an NSDictionary with non-string keys +into JSON will throw an exception. + +NSNumber instances created with the +numberWithBool: method are +converted into the JSON boolean "true" and "false" values, and vice +versa. Any other NSNumber instances are converted to a JSON number the +way you would expect. JSON numbers turn into NSDecimalNumber instances, +as we can thus avoid any loss of precision. + +Strictly speaking correctly formed JSON text must have exactly +one top-level container. (Either an Array or an Object.) Scalars, +i.e. nulls, numbers, booleans and strings, are not valid JSON on their own. +It can be quite convenient to pretend that such fragments are valid +JSON however, and this class lets you do so. + +This class does its best to be as strict as possible, both in what it +accepts and what it generates. (Other than the above mentioned support +for JSON fragments.) For example, it does not support trailing commas +in arrays or objects. Nor does it support embedded comments, or +anything else not in the JSON specification. + +*/ +@interface SBJSON : NSObject { + BOOL humanReadable; + BOOL sortKeys; + NSUInteger maxDepth; + +@private + // Used temporarily during scanning/generation + NSUInteger depth; + const char *c; +} + +/// Whether we are generating human-readable (multiline) JSON +/** + Set whether or not to generate human-readable JSON. The default is NO, which produces + JSON without any whitespace. (Except inside strings.) If set to YES, generates human-readable + JSON with linebreaks after each array value and dictionary key/value pair, indented two + spaces per nesting level. + */ +@property BOOL humanReadable; + +/// Whether or not to sort the dictionary keys in the output +/** The default is to not sort the keys. */ +@property BOOL sortKeys; + +/// The maximum depth the parser will go to +/** Defaults to 512. */ +@property NSUInteger maxDepth; + +/// Return JSON representation of an array or dictionary +- (NSString*)stringWithObject:(id)value error:(NSError**)error; + +/// Return JSON representation of any legal JSON value +- (NSString*)stringWithFragment:(id)value error:(NSError**)error; + +/// Return the object represented by the given string +- (id)objectWithString:(NSString*)jsonrep error:(NSError**)error; + +/// Return the fragment represented by the given string +- (id)fragmentWithString:(NSString*)jsonrep error:(NSError**)error; + +/// Return JSON representation (or fragment) for the given object +- (NSString*)stringWithObject:(id)value + allowScalar:(BOOL)x + error:(NSError**)error; + +/// Parse the string and return the represented object (or scalar) +- (id)objectWithString:(id)value + allowScalar:(BOOL)x + error:(NSError**)error; + +@end diff --git a/iphone/Frameworks/JSON/macosx.sdk/usr/local/lib/libjson.a b/iphone/Frameworks/JSON/macosx.sdk/usr/local/lib/libjson.a new file mode 100644 index 00000000..3072d81a Binary files /dev/null and b/iphone/Frameworks/JSON/macosx.sdk/usr/local/lib/libjson.a differ diff --git a/iphone/PhoneGap.plist b/iphone/PhoneGap.plist new file mode 100755 index 00000000..e6725021 --- /dev/null +++ b/iphone/PhoneGap.plist @@ -0,0 +1,41 @@ + + + + + Callback + http://localhost/iphone/ + Offline + + DetectPhoneNumber + + TopStatusBar + default + TopActivityIndicator + gray + EnableLocation + + EnableAcceleration + + AutoRotate + + StartOrientation + portrait + RotateOrientation + portrait + UIControls + + TabBarSettings + + height + 49 + position + bottom + + ToolBarSettings + + style + Default + + + + diff --git a/iphone/PhoneGap.xcodeproj/project.pbxproj b/iphone/PhoneGap.xcodeproj/project.pbxproj index 6b98b5d2..857cdb75 100755 --- a/iphone/PhoneGap.xcodeproj/project.pbxproj +++ b/iphone/PhoneGap.xcodeproj/project.pbxproj @@ -12,13 +12,14 @@ 1B1B4FBE0F94571B00ECD4E6 /* PhoneGapCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B1B4FBD0F94571B00ECD4E6 /* PhoneGapCommand.m */; }; 1B1B53830F98070D00ECD4E6 /* Notification.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B1B53820F98070D00ECD4E6 /* Notification.m */; }; 1B64D89A0F6C73C700D12F7F /* DebugConsole.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B64D8990F6C73C700D12F7F /* DebugConsole.m */; }; + 1BB1F7D20F9E1BE2002A28DA /* Settings.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1BB1F7D10F9E1BE2002A28DA /* Settings.plist */; }; 1D3623260D0F684500981E51 /* PhoneGapDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* PhoneGapDelegate.m */; }; 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 47DC5AEE0F4BDEDB00FB54CE /* beep.wav in Resources */ = {isa = PBXBuildFile; fileRef = 47DC5AED0F4BDEDB00FB54CE /* beep.wav */; }; - 47DC7FB30EFADF9E00D0B526 /* Settings.plist in Resources */ = {isa = PBXBuildFile; fileRef = 47DC7FB20EFADF9E00D0B526 /* Settings.plist */; }; + 47DC7FB30EFADF9E00D0B526 /* PhoneGap.plist in Resources */ = {isa = PBXBuildFile; fileRef = 47DC7FB20EFADF9E00D0B526 /* PhoneGap.plist */; }; 47F565210F3AC95D001DFBDB /* Image.m in Sources */ = {isa = PBXBuildFile; fileRef = 47F565200F3AC95D001DFBDB /* Image.m */; }; 47FAB6A90EF751E2005F55AB /* PhoneGapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 47FAB6A80EF751E2005F55AB /* PhoneGapViewController.m */; }; 47FAB72A0EF7A663005F55AB /* Sound.m in Sources */ = {isa = PBXBuildFile; fileRef = 47FAB7290EF7A663005F55AB /* Sound.m */; }; @@ -46,6 +47,7 @@ 1B1B53820F98070D00ECD4E6 /* Notification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Notification.m; sourceTree = ""; }; 1B64D8980F6C73C700D12F7F /* DebugConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugConsole.h; sourceTree = ""; }; 1B64D8990F6C73C700D12F7F /* DebugConsole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DebugConsole.m; sourceTree = ""; }; + 1BB1F7D10F9E1BE2002A28DA /* Settings.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Settings.plist; sourceTree = ""; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 1D3623240D0F684500981E51 /* PhoneGapDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneGapDelegate.h; sourceTree = ""; }; 1D3623250D0F684500981E51 /* PhoneGapDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhoneGapDelegate.m; sourceTree = ""; }; @@ -55,7 +57,7 @@ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ../main.m; sourceTree = ""; }; 474A7F820EFAD6580020DD7F /* PhoneGap_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneGap_Prefix.pch; sourceTree = ""; }; 47DC5AED0F4BDEDB00FB54CE /* beep.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = beep.wav; sourceTree = ""; }; - 47DC7FB20EFADF9E00D0B526 /* Settings.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Settings.plist; sourceTree = ""; }; + 47DC7FB20EFADF9E00D0B526 /* PhoneGap.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = PhoneGap.plist; sourceTree = ""; }; 47F5651F0F3AC95D001DFBDB /* Image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Image.h; sourceTree = ""; }; 47F565200F3AC95D001DFBDB /* Image.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Image.m; sourceTree = ""; }; 47FAB6A70EF751E2005F55AB /* PhoneGapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneGapViewController.h; sourceTree = ""; }; @@ -199,7 +201,8 @@ AA13D3080F20286200B18061 /* Config */ = { isa = PBXGroup; children = ( - 47DC7FB20EFADF9E00D0B526 /* Settings.plist */, + 1BB1F7D10F9E1BE2002A28DA /* Settings.plist */, + 47DC7FB20EFADF9E00D0B526 /* PhoneGap.plist */, 8D1107310486CEB800E47090 /* Info.plist */, ); name = Config; @@ -251,9 +254,10 @@ 825DFB5E0E464E6C000D0A5D /* README.md in Resources */, 8204F3D30E5CB4DC00F2DAA1 /* icon.png in Resources */, 824041C10E942F0E002F3376 /* Default.png in Resources */, - 47DC7FB30EFADF9E00D0B526 /* Settings.plist in Resources */, + 47DC7FB30EFADF9E00D0B526 /* PhoneGap.plist in Resources */, AA13D3420F202D0400B18061 /* www in Resources */, 47DC5AEE0F4BDEDB00FB54CE /* beep.wav in Resources */, + 1BB1F7D20F9E1BE2002A28DA /* Settings.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -287,6 +291,7 @@ 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ADDITIONAL_SDKS = "$(SRCROOT)/Frameworks/JSON/$(PLATFORM_NAME).sdk"; ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -298,6 +303,10 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = PhoneGap_Prefix.pch; INFOPLIST_FILE = Info.plist; + OTHER_LDFLAGS = ( + "-ObjC", + "-ljson", + ); PRODUCT_NAME = PhoneGap; }; name = Debug; @@ -305,6 +314,7 @@ 1D6058950D05DD3E006BFB54 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ADDITIONAL_SDKS = "$(SRCROOT)/Frameworks/JSON/$(PLATFORM_NAME).sdk"; ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -340,6 +350,7 @@ B74E58190EC6C9AC00215614 /* Distribution */ = { isa = XCBuildConfiguration; buildSettings = { + ADDITIONAL_SDKS = "$(SRCROOT)/Frameworks/JSON/$(PLATFORM_NAME).sdk"; ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -351,6 +362,10 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Glass_Prefix.pch; INFOPLIST_FILE = Info.plist; + OTHER_LDFLAGS = ( + "-ObjC", + "-ljson", + ); PRODUCT_NAME = Glass; PROVISIONING_PROFILE = "B02DE0E6-FD92-4854-9B69-3C191831ABA5"; }; @@ -376,12 +391,17 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ADDITIONAL_SDKS = "$(SRCROOT)/Frameworks/JSON/$(PLATFORM_NAME).sdk"; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CODE_SIGN_IDENTITY = "iPhone Developer: Brant Vasilieff"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Brant Vasilieff"; GCC_C_LANGUAGE_STANDARD = c99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + OTHER_LDFLAGS = ( + "-ObjC", + "-ljson", + ); PREBINDING = NO; PROVISIONING_PROFILE = "880150E2-809D-4BBE-B91E-244F2A6F59A0"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "880150E2-809D-4BBE-B91E-244F2A6F59A0"; diff --git a/iphone/Settings.plist b/iphone/Settings.plist old mode 100755 new mode 100644 index 9e9e93c3..d3fceafc --- a/iphone/Settings.plist +++ b/iphone/Settings.plist @@ -2,25 +2,7 @@ - Callback - http://localhost/iphone/ - Offline - - DetectPhoneNumber - - TopStatusBar - default - TopActivityIndicator - gray - EnableLocation - - EnableAcceleration - - AutoRotate - - StartOrientation - portrait - RotateOrientation - portrait + version + 1 diff --git a/iphone/www/index.html b/iphone/www/index.html index 0898e52c..8c857863 100755 --- a/iphone/www/index.html +++ b/iphone/www/index.html @@ -70,36 +70,91 @@ return result; } + function setupToolbars() { + uicontrols.createTabBar(); + + var toprated = 0; + uicontrols.createTabBarItem("toprated", "Top Rated", "tabButton:TopRated", { + onSelect: function() { + navigator.notification.alert("Top Rated selected"); + uicontrols.updateTabBarItem("toprated", { badge: ++toprated }); + } + }); + + var recents = 0; + uicontrols.createTabBarItem("recents", "Recents", "tabButton:Recents", { + onSelect: function() { + navigator.notification.alert("Recents selected"); + uicontrols.updateTabBarItem("recents", { badge: ++recents }); + } + }); + + var history = 0; + uicontrols.createTabBarItem("history", "History", "tabButton:History", { + onSelect: function() { + navigator.notification.alert("History selected"); + uicontrols.updateTabBarItem("history", { badge: ++history }); + } + }); + + var more = false; + uicontrols.createTabBarItem("more", "More", "tabButton:More", { + onSelect: function() { + if (more) { + uicontrols.showTabBarItems("search", "downloads", "more"); + } else { + uicontrols.showTabBarItems("toprated", "recents", "history", "more"); + } + uicontrols.selectTabBarItem(null); + more = !more; + } + }); + + try { + uicontrols.createTabBarItem("search", "Search", "tabButton:Search"); + uicontrols.createTabBarItem("downloads", "Downloads", "tabButton:Downloads"); + } catch(e) { debug.log(e) } + + uicontrols.showTabBar(); + uicontrols.showTabBarItems("toprated", "recents", "history", "more"); + + uicontrols.setToolBarTitle("PhoneGap Demo"); + } + function preventBehavior(e) { e.preventDefault(); }; PhoneGap.addConstructor(function(){ document.addEventListener("touchmove", preventBehavior, false); + setupToolbars(); deviceInfo(); }); -

Welcome to PhoneGap!

-

this file is located at iphone/www/index.html

-
-

Platform:  

-

Version:  

-

UUID:  

-
-
-
X:
 
-
Y:
 
-
Z:
 
-
- Watch Accelerometer - Get Location - Call 411 - Custom Alert - Beep - Vibrate - Get Fourth Contact +
+

this file is located at iphone/www/index.html

+
+

Platform:  

+

Version:  

+

UUID:  

+
+
+
X:
 
+
Y:
 
+
Z:
 
+
+ Watch Accelerometer + Get Location + Call 411 + Custom Alert + Beep + Vibrate +
+ diff --git a/iphone/www/master.css b/iphone/www/master.css index 1d1bea20..c7ae5784 100755 --- a/iphone/www/master.css +++ b/iphone/www/master.css @@ -29,7 +29,7 @@ } /* Definition List */ - #stage.theme > dl{ + #Page1 > dl{ padding-top:10px; clear:both; margin:0; @@ -38,13 +38,13 @@ overflow:auto; } - #stage.theme > dl > dt{ + #Page1 > dl > dt{ font-weight:bold; float:left; margin-left:5px; } - #stage.theme > dl > dd{ + #Page1 > dl > dd{ width:45px; float:left; color:#a87; @@ -52,11 +52,11 @@ } /* Content Styling */ - #stage.theme > h1, #stage.theme > h2, #stage.theme > p{ + h1, h2, p{ margin:1em 0 .5em 13px; } - #stage.theme > h1{ + h1{ color:#eee; font-size:1.6em; text-align:center; @@ -65,7 +65,7 @@ padding:0; } - #stage.theme > h2{ + h2{ clear:both; margin:0; padding:3px; diff --git a/iphone/www/phonegap.js b/iphone/www/phonegap.js index 23870833..71f49976 100644 --- a/iphone/www/phonegap.js +++ b/iphone/www/phonegap.js @@ -1 +1 @@ -if(typeof(DeviceInfo)!="object"){DeviceInfo={}}PhoneGap={queue:{ready:true,commands:[],timer:null},_constructors:[]};PhoneGap.available=DeviceInfo.uuid!=undefined;PhoneGap.addConstructor=function(a){var b=document.readyState;if(b!="loaded"&&b!="complete"){PhoneGap._constructors.push(a)}else{a()}};(function(){var a=setInterval(function(){var c=document.readyState;if(c!="loaded"&&c!="complete"){return}clearInterval(a);while(PhoneGap._constructors.length>0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){if(!PhoneGap.available){return}PhoneGap.queue.ready=false;var d=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var f=[];var g=null;for(var e=1;eg){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;b0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){};function Device(){this.available=PhoneGap.available;this.model=null;this.version=null;this.gap=null;this.uuid=null;try{if(window.DroidGap!=undefined&&window.DroidGap.exists()){this.available=true;this.isAndroid=true;this.uuid=window.DroidGap.getUuid();this.gapVersion=window.DroidGap.getVersion()}else{this.model=DeviceInfo.platform;this.version=DeviceInfo.version;this.gap=DeviceInfo.gap;this.uuid=DeviceInfo.uuid}}catch(a){this.available=false}}PhoneGap.addConstructor(function(){navigator.device=window.device=new Device()});PhoneGap.run_command=function(){if(!PhoneGap.available){return}PhoneGap.queue.ready=false;var d=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var f=[];var g=null;for(var e=1;eg){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;btmp/phonegap.js
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:51 GMT-0700 (PDT)
\ No newline at end of file diff --git a/util/jsdoc-toolkit/out/jsdoc/index.html b/javascripts/docs/index.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/index.html rename to javascripts/docs/index.html index 8e508015..09904107 100644 --- a/util/jsdoc-toolkit/out/jsdoc/index.html +++ b/javascripts/docs/index.html @@ -348,7 +348,7 @@

UIControls

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:51 GMT-0700 (PDT)
\ No newline at end of file diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Acceleration.html b/javascripts/docs/symbols/Acceleration.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Acceleration.html rename to javascripts/docs/symbols/Acceleration.html index cf04a953..0673db81 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Acceleration.html +++ b/javascripts/docs/symbols/Acceleration.html @@ -502,7 +502,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/AccelerationOptions.html b/javascripts/docs/symbols/AccelerationOptions.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/AccelerationOptions.html rename to javascripts/docs/symbols/AccelerationOptions.html index 1affeb7c..16bb1e95 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/AccelerationOptions.html +++ b/javascripts/docs/symbols/AccelerationOptions.html @@ -385,7 +385,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Accelerometer.html b/javascripts/docs/symbols/Accelerometer.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Accelerometer.html rename to javascripts/docs/symbols/Accelerometer.html index fd515f6d..f8c2cbc4 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Accelerometer.html +++ b/javascripts/docs/symbols/Accelerometer.html @@ -571,7 +571,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Camera.html b/javascripts/docs/symbols/Camera.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Camera.html rename to javascripts/docs/symbols/Camera.html index 87358c74..748714ee 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Camera.html +++ b/javascripts/docs/symbols/Camera.html @@ -408,7 +408,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Contact.html b/javascripts/docs/symbols/Contact.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Contact.html rename to javascripts/docs/symbols/Contact.html index 81c608de..1130f313 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Contact.html +++ b/javascripts/docs/symbols/Contact.html @@ -408,7 +408,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/DebugConsole.html b/javascripts/docs/symbols/DebugConsole.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/DebugConsole.html rename to javascripts/docs/symbols/DebugConsole.html index c0647338..8ac63fa4 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/DebugConsole.html +++ b/javascripts/docs/symbols/DebugConsole.html @@ -486,7 +486,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Device.html b/javascripts/docs/symbols/Device.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Device.html rename to javascripts/docs/symbols/Device.html index 20fc8532..4890ad50 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Device.html +++ b/javascripts/docs/symbols/Device.html @@ -330,7 +330,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Geolocation.html b/javascripts/docs/symbols/Geolocation.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Geolocation.html rename to javascripts/docs/symbols/Geolocation.html index 9e9b8e76..752d6dc1 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Geolocation.html +++ b/javascripts/docs/symbols/Geolocation.html @@ -661,7 +661,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Media.html b/javascripts/docs/symbols/Media.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Media.html rename to javascripts/docs/symbols/Media.html index 254b883c..f77a3dac 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Media.html +++ b/javascripts/docs/symbols/Media.html @@ -464,7 +464,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/MediaError.html b/javascripts/docs/symbols/MediaError.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/MediaError.html rename to javascripts/docs/symbols/MediaError.html index a2939bc8..ff6e7664 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/MediaError.html +++ b/javascripts/docs/symbols/MediaError.html @@ -328,7 +328,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Orientation.html b/javascripts/docs/symbols/Orientation.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Orientation.html rename to javascripts/docs/symbols/Orientation.html index d4778b3b..f8be7b42 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Orientation.html +++ b/javascripts/docs/symbols/Orientation.html @@ -557,7 +557,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/PhoneGap.html b/javascripts/docs/symbols/PhoneGap.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/PhoneGap.html rename to javascripts/docs/symbols/PhoneGap.html index 8b2f1ded..21a5631d 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/PhoneGap.html +++ b/javascripts/docs/symbols/PhoneGap.html @@ -510,7 +510,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Position.html b/javascripts/docs/symbols/Position.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Position.html rename to javascripts/docs/symbols/Position.html index 4919c7c8..8b842041 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Position.html +++ b/javascripts/docs/symbols/Position.html @@ -654,7 +654,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/PositionError.html b/javascripts/docs/symbols/PositionError.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/PositionError.html rename to javascripts/docs/symbols/PositionError.html index 9c1aceb6..eecac42e 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/PositionError.html +++ b/javascripts/docs/symbols/PositionError.html @@ -328,7 +328,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/PositionOptions.html b/javascripts/docs/symbols/PositionOptions.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/PositionOptions.html rename to javascripts/docs/symbols/PositionOptions.html index 1c028e98..e8139128 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/PositionOptions.html +++ b/javascripts/docs/symbols/PositionOptions.html @@ -417,7 +417,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Sms.html b/javascripts/docs/symbols/Sms.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Sms.html rename to javascripts/docs/symbols/Sms.html index a6ea2678..ab199e1b 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Sms.html +++ b/javascripts/docs/symbols/Sms.html @@ -420,7 +420,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/Telephony.html b/javascripts/docs/symbols/Telephony.html similarity index 98% rename from util/jsdoc-toolkit/out/jsdoc/symbols/Telephony.html rename to javascripts/docs/symbols/Telephony.html index 7db2cadb..fd6ecc43 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/Telephony.html +++ b/javascripts/docs/symbols/Telephony.html @@ -396,7 +396,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/javascripts/docs/symbols/UIControls.html b/javascripts/docs/symbols/UIControls.html new file mode 100644 index 00000000..fdf1d06a --- /dev/null +++ b/javascripts/docs/symbols/UIControls.html @@ -0,0 +1,857 @@ + + + + + + + JsDoc Reference - UIControls + + + + + + + + + + + + + +
+ +

+ + Class UIControls +

+ + +

+ + + + + +
Defined in: phonegap.js. + +

+ + + + + + + + + + + + + + + + + +
Class Summary
Constructor AttributesConstructor Name and Description
  +
+ UIControls() +
+
This class exposes mobile phone interface controls to JavaScript, such as +native tab and tool bars, etc.
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method Summary
Method AttributesMethod Name and Description
  + +
Create a native tab bar that can have tab buttons added to it which can respond to events.
+
  +
createTabBarItem(name, title, image, options) +
+
Create a new tab bar item for use on a previously created tab bar.
+
  + +
Create a toolbar.
+
  +
hideTabBar(animate) +
+
Hide a tab bar.
+
  +
selectTabBarItem(tabName) +
+
Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item.
+
  +
setToolBarTitle(title) +
+
Function called when a tab bar item has been selected.
+
  +
showTabBar(options) +
+
Show a tab bar.
+
  +
showTabBarItems(options) +
+
Show previously created items on the tab bar
+
  + +
Function called when a tab bar item has been selected.
+
  +
updateTabBarItem(name, options) +
+
Update an existing tab bar item to change its badge value.
+
+ + + + + + + + + +
+
+ Class Detail +
+ +
+ UIControls() +
+ +
+ This class exposes mobile phone interface controls to JavaScript, such as +native tab and tool bars, etc. + +
+ + + + + + + + + + + + +
+ + + + + + + +
+ Method Detail +
+ + +
+ + + createTabBar() + +
+
+ Create a native tab bar that can have tab buttons added to it which can respond to events. + + +
+ + + + + + + + + + + +
+ + +
+ + + createTabBarItem(name, title, image, options) + +
+
+ Create a new tab bar item for use on a previously created tab bar. Use ::showTabBarItems to show the new item on the tab bar. + +If the supplied image name is one of the labels listed below, then this method will construct a tab button +using the standard system buttons. Note that if you use one of the system images, that the \c title you supply will be ignored. + +Tab Buttons + - tabButton:More + - tabButton:Favorites + - tabButton:Featured + - tabButton:TopRated + - tabButton:Recents + - tabButton:Contacts + - tabButton:History + - tabButton:Bookmarks + - tabButton:Search + - tabButton:Downloads + - tabButton:MostRecent + - tabButton:MostViewed + + +
+ + + + +
+
Parameters:
+ +
+ {String} name + +
+
internal name to refer to this tab by
+ +
+ {String} title + Optional +
+
title text to show on the tab, or null if no text should be shown
+ +
+ {String} image + Optional +
+
image filename or internal identifier to show, or null if now image should be shown
+ +
+ {Object} options + Optional +
+
Options for customizing the individual tab item + - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden
+ +
+ + + + + + + + +
+ + +
+ + + createToolBar() + +
+
+ Create a toolbar. + + +
+ + + + + + + + + + + +
+ + +
+ + + hideTabBar(animate) + +
+
+ Hide a tab bar. The tab bar has to be created first. + + +
+ + + + +
+
Parameters:
+ +
+ animate + +
+
+ +
+ + + + + + + + +
+ + +
+ + + selectTabBarItem(tabName) + +
+
+ Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item. + + +
+ + + + +
+
Parameters:
+ +
+ {String} tabName + +
+
the name of the tab to select, or null if all tabs should be deselected
+ +
+ + + + + + + +
+
See:
+ +
createTabBarItem
+ +
showTabBarItems
+ +
+ + +
+ + +
+ + + setToolBarTitle(title) + +
+
+ Function called when a tab bar item has been selected. + + +
+ + + + +
+
Parameters:
+ +
+ {String} title + +
+
the title to set within the toolbar
+ +
+ + + + + + + + +
+ + +
+ + + showTabBar(options) + +
+
+ Show a tab bar. The tab bar has to be created first. + + +
+ + + + +
+
Parameters:
+ +
+ {Object} options + Optional +
+
Options indicating how the tab bar should be shown: +- \c height integer indicating the height of the tab bar (default: \c 49) +- \c position specifies whether the tab bar will be placed at the \c top or \c bottom of the screen (default: \c bottom)
+ +
+ + + + + + + + +
+ + +
+ + + showTabBarItems(options) + +
+
+ Show previously created items on the tab bar + + +
+ + + + +
+
Parameters:
+ +
+ {String} arguments... + +
+
the item names to be shown
+ +
+ {Object} options + Optional +
+
dictionary of options, notable options including: + - \c animate indicates that the items should animate onto the tab bar
+ +
+ + + + + + + +
+
See:
+ +
createTabBarItem
+ +
createTabBar
+ +
+ + +
+ + +
+ + + tabBarItemSelected(tag) + +
+
+ Function called when a tab bar item has been selected. + + +
+ + + + +
+
Parameters:
+ +
+ {Number} tag + +
+
the tag number for the item that has been selected
+ +
+ + + + + + + + +
+ + +
+ + + updateTabBarItem(name, options) + +
+
+ Update an existing tab bar item to change its badge value. + + +
+ + + + +
+
Parameters:
+ +
+ {String} name + +
+
internal name used to represent this item when it was created
+ +
+ {Object} options + +
+
Options for customizing the individual tab item + - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden
+ +
+ + + + + + + + + + + + + + + +
+
+ + + +
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:51 GMT-0700 (PDT) +
+ + diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/_global_.html b/javascripts/docs/symbols/_global_.html similarity index 99% rename from util/jsdoc-toolkit/out/jsdoc/symbols/_global_.html rename to javascripts/docs/symbols/_global_.html index 4a32db6f..c267a6e1 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/_global_.html +++ b/javascripts/docs/symbols/_global_.html @@ -616,7 +616,7 @@

- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:09 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Apr 24 2009 08:12:50 GMT-0700 (PDT)
diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/src/tmp_phonegap.js.html b/javascripts/docs/symbols/src/tmp_phonegap.js.html similarity index 64% rename from util/jsdoc-toolkit/out/jsdoc/symbols/src/tmp_phonegap.js.html rename to javascripts/docs/symbols/src/tmp_phonegap.js.html index 429ca7ac..0f2ed855 100644 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/src/tmp_phonegap.js.html +++ b/javascripts/docs/symbols/src/tmp_phonegap.js.html @@ -74,791 +74,850 @@ 67 PhoneGap.queue.timer = setInterval(PhoneGap.run_command, 10); 68 }; 69 /** - 70 * Internal function used to dispatch the request to PhoneGap. It processes the - 71 * command queue and executes the next command on the list. If one of the - 72 * arguments is a JavaScript object, it will be passed on the QueryString of the - 73 * url, which will be turned into a dictionary on the other end. - 74 * @private - 75 */ - 76 PhoneGap.run_command = function() { - 77 if (!PhoneGap.available) - 78 return; - 79 - 80 PhoneGap.queue.ready = false; - 81 - 82 var args = PhoneGap.queue.commands.shift(); - 83 if (PhoneGap.queue.commands.length == 0) { - 84 clearInterval(PhoneGap.queue.timer); - 85 PhoneGap.queue.timer = null; - 86 } - 87 - 88 var uri = []; - 89 var dict = null; - 90 for (var i = 1; i < args.length; i++) { - 91 if (typeof(args[i]) == 'object') - 92 dict = args[i]; - 93 else - 94 uri.push(encodeURIComponent(args[i])); - 95 } - 96 var url = "gap://" + args[0] + "/" + uri.join("/"); - 97 if (dict != null) { - 98 var query_args = []; - 99 for (var name in dict) { -100 if (typeof(name) != 'string') -101 continue; -102 query_args.push(encodeURIComponent(name) + "=" + encodeURIComponent(dict[name])); -103 } -104 if (query_args.length > 0) -105 url += "?" + query_args.join("&"); -106 } -107 document.location = url; + 70 * Internal function used to dispatch the request to PhoneGap. This needs to be implemented per-platform to + 71 * ensure that methods are called on the phone in a way appropriate for that device. + 72 * @private + 73 */ + 74 PhoneGap.run_command = function() { + 75 }; + 76 + 77 /** + 78 * this represents the mobile device, and provides properties for inspecting the model, version, UUID of the + 79 * phone, etc. + 80 * @constructor + 81 */ + 82 function Device() { + 83 this.available = PhoneGap.available; + 84 this.model = null; + 85 this.version = null; + 86 this.gap = null; + 87 this.uuid = null; + 88 try { + 89 if (window['DroidGap'] != undefined && window.DroidGap.exists()) { + 90 this.available = true; + 91 this.isAndroid = true; + 92 this.uuid = window.DroidGap.getUuid(); + 93 this.gapVersion = window.DroidGap.getVersion(); + 94 } else { + 95 this.model = DeviceInfo.platform; + 96 this.version = DeviceInfo.version; + 97 this.gap = DeviceInfo.gap; + 98 this.uuid = DeviceInfo.uuid; + 99 } +100 } catch(e) { +101 this.available = false; +102 } +103 } +104 +105 PhoneGap.addConstructor(function() { +106 navigator.device = window.device = new Device(); +107 }); 108 -109 }; -110 +109 +110 111 /** -112 * this represents the mobile device, and provides properties for inspecting the model, version, UUID of the -113 * phone, etc. -114 * @constructor -115 */ -116 function Device() { -117 this.available = PhoneGap.available; -118 this.model = null; -119 this.version = null; -120 this.gap = null; -121 this.uuid = null; -122 try { -123 if (window['DroidGap'] != undefined && window.DroidGap.exists()) { -124 this.available = true; -125 this.isAndroid = true; -126 this.uuid = window.DroidGap.getUuid(); -127 this.gapVersion = window.DroidGap.getVersion(); -128 } else { -129 this.model = DeviceInfo.platform; -130 this.version = DeviceInfo.version; -131 this.gap = DeviceInfo.gap; -132 this.uuid = DeviceInfo.uuid; -133 } -134 } catch(e) { -135 this.available = false; -136 } -137 } -138 -139 PhoneGap.addConstructor(function() { -140 navigator.device = window.device = new Device(); -141 }); -142 -143 -144 -145 /** -146 * This class contains acceleration information -147 * @constructor -148 * @param {Number} x The force applied by the device in the x-axis. -149 * @param {Number} y The force applied by the device in the y-axis. -150 * @param {Number} z The force applied by the device in the z-axis. -151 */ -152 function Acceleration(x, y, z) { -153 /** -154 * The force applied by the device in the x-axis. -155 */ -156 this.x = x; -157 /** -158 * The force applied by the device in the y-axis. -159 */ -160 this.y = y; -161 /** -162 * The force applied by the device in the z-axis. -163 */ -164 this.z = z; -165 /** -166 * The time that the acceleration was obtained. -167 */ -168 this.timestamp = new Date().getTime(); -169 } -170 -171 /** -172 * This class specifies the options for requesting acceleration data. -173 * @constructor -174 */ -175 function AccelerationOptions() { -176 /** -177 * The timeout after which if acceleration data cannot be obtained the errorCallback -178 * is called. -179 */ -180 this.timeout = 10000; -181 } -182 -183 -184 /** -185 * This class provides access to device accelerometer data. -186 * @constructor -187 */ -188 function Accelerometer() { -189 /** -190 * The last known acceleration. -191 */ -192 this.lastAcceleration = null; -193 } -194 -195 /** -196 * Asynchronously aquires the current acceleration. -197 * @param {Function} successCallback The function to call when the acceleration -198 * data is available -199 * @param {Function} errorCallback The function to call when there is an error -200 * getting the acceleration data. -201 * @param {AccelerationOptions} options The options for getting the accelerometer data -202 * such as timeout. -203 */ -204 Accelerometer.prototype.getCurrentAcceleration = function(successCallback, errorCallback, options) { -205 // If the acceleration is available then call success -206 // If the acceleration is not available then call error -207 -208 // Created for iPhone, Iphone passes back _accel obj litteral -209 if (typeof successCallback == "function") { -210 var accel = new Acceleration(_accel.x,_accel.y,_accel.z); -211 Accelerometer.lastAcceleration = accel; -212 successCallback(accel); -213 } -214 } -215 +112 * This class contains acceleration information +113 * @constructor +114 * @param {Number} x The force applied by the device in the x-axis. +115 * @param {Number} y The force applied by the device in the y-axis. +116 * @param {Number} z The force applied by the device in the z-axis. +117 */ +118 function Acceleration(x, y, z) { +119 /** +120 * The force applied by the device in the x-axis. +121 */ +122 this.x = x; +123 /** +124 * The force applied by the device in the y-axis. +125 */ +126 this.y = y; +127 /** +128 * The force applied by the device in the z-axis. +129 */ +130 this.z = z; +131 /** +132 * The time that the acceleration was obtained. +133 */ +134 this.timestamp = new Date().getTime(); +135 } +136 +137 /** +138 * This class specifies the options for requesting acceleration data. +139 * @constructor +140 */ +141 function AccelerationOptions() { +142 /** +143 * The timeout after which if acceleration data cannot be obtained the errorCallback +144 * is called. +145 */ +146 this.timeout = 10000; +147 } +148 +149 +150 /** +151 * This class provides access to device accelerometer data. +152 * @constructor +153 */ +154 function Accelerometer() { +155 /** +156 * The last known acceleration. +157 */ +158 this.lastAcceleration = null; +159 } +160 +161 /** +162 * Asynchronously aquires the current acceleration. +163 * @param {Function} successCallback The function to call when the acceleration +164 * data is available +165 * @param {Function} errorCallback The function to call when there is an error +166 * getting the acceleration data. +167 * @param {AccelerationOptions} options The options for getting the accelerometer data +168 * such as timeout. +169 */ +170 Accelerometer.prototype.getCurrentAcceleration = function(successCallback, errorCallback, options) { +171 // If the acceleration is available then call success +172 // If the acceleration is not available then call error +173 +174 // Created for iPhone, Iphone passes back _accel obj litteral +175 if (typeof successCallback == "function") { +176 var accel = new Acceleration(_accel.x,_accel.y,_accel.z); +177 Accelerometer.lastAcceleration = accel; +178 successCallback(accel); +179 } +180 } +181 +182 /** +183 * Asynchronously aquires the acceleration repeatedly at a given interval. +184 * @param {Function} successCallback The function to call each time the acceleration +185 * data is available +186 * @param {Function} errorCallback The function to call when there is an error +187 * getting the acceleration data. +188 * @param {AccelerationOptions} options The options for getting the accelerometer data +189 * such as timeout. +190 */ +191 +192 Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options) { +193 this.getCurrentAcceleration(successCallback, errorCallback, options); +194 // TODO: add the interval id to a list so we can clear all watches +195 var frequency = (options != undefined)? options.frequency : 10000; +196 return setInterval(function() { +197 navigator.accelerometer.getCurrentAcceleration(successCallback, errorCallback, options); +198 }, frequency); +199 } +200 +201 /** +202 * Clears the specified accelerometer watch. +203 * @param {String} watchId The ID of the watch returned from #watchAcceleration. +204 */ +205 Accelerometer.prototype.clearWatch = function(watchId) { +206 clearInterval(watchId); +207 } +208 +209 PhoneGap.addConstructor(function() { +210 if (typeof navigator.accelerometer == "undefined") navigator.accelerometer = new Accelerometer(); +211 }); +212 +213 +214 +215 216 /** -217 * Asynchronously aquires the acceleration repeatedly at a given interval. -218 * @param {Function} successCallback The function to call each time the acceleration -219 * data is available -220 * @param {Function} errorCallback The function to call when there is an error -221 * getting the acceleration data. -222 * @param {AccelerationOptions} options The options for getting the accelerometer data -223 * such as timeout. -224 */ -225 -226 Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options) { -227 this.getCurrentAcceleration(successCallback, errorCallback, options); -228 // TODO: add the interval id to a list so we can clear all watches -229 var frequency = (options != undefined)? options.frequency : 10000; -230 return setInterval(function() { -231 navigator.accelerometer.getCurrentAcceleration(successCallback, errorCallback, options); -232 }, frequency); -233 } -234 -235 /** -236 * Clears the specified accelerometer watch. -237 * @param {String} watchId The ID of the watch returned from #watchAcceleration. -238 */ -239 Accelerometer.prototype.clearWatch = function(watchId) { -240 clearInterval(watchId); +217 * This class provides access to the device media, interfaces to both sound and video +218 * @constructor +219 */ +220 function Media(src) { +221 this.src = src; +222 } +223 +224 Media.prototype.play = function() { +225 } +226 +227 Media.prototype.pause = function() { +228 } +229 +230 Media.prototype.stop = function() { +231 } +232 +233 +234 /** +235 * This class contains information about any Media errors. +236 * @constructor +237 */ +238 function MediaError() { +239 this.code = null, +240 this.message = ""; 241 } 242 -243 PhoneGap.addConstructor(function() { -244 if (typeof navigator.accelerometer == "undefined") navigator.accelerometer = new Accelerometer(); -245 }); -246 -247 +243 MediaError.MEDIA_ERR_ABORTED = 1; +244 MediaError.MEDIA_ERR_NETWORK = 2; +245 MediaError.MEDIA_ERR_DECODE = 3; +246 MediaError.MEDIA_ERR_NONE_SUPPORTED = 4; +247 248 -249 -250 /** -251 * This class provides access to the device media, interfaces to both sound and video -252 * @constructor -253 */ -254 function Media(src) { -255 this.src = src; -256 } -257 -258 Media.prototype.play = function() { -259 } -260 -261 Media.prototype.pause = function() { -262 } -263 -264 Media.prototype.stop = function() { -265 } -266 -267 -268 /** -269 * This class contains information about any Media errors. -270 * @constructor -271 */ -272 function MediaError() { -273 this.code = null, -274 this.message = ""; -275 } -276 -277 MediaError.MEDIA_ERR_ABORTED = 1; -278 MediaError.MEDIA_ERR_NETWORK = 2; -279 MediaError.MEDIA_ERR_DECODE = 3; -280 MediaError.MEDIA_ERR_NONE_SUPPORTED = 4; -281 -282 -283 //if (typeof navigator.audio == "undefined") navigator.audio = new Media(src); -284 -285 +249 //if (typeof navigator.audio == "undefined") navigator.audio = new Media(src); +250 +251 +252 /** +253 * This class provides access to the device camera. +254 * @constructor +255 */ +256 function Camera() { +257 +258 } +259 +260 /** +261 * +262 * @param {Function} successCallback +263 * @param {Function} errorCallback +264 * @param {Object} options +265 */ +266 Camera.prototype.getPicture = function(successCallback, errorCallback, options) { +267 +268 } +269 +270 PhoneGap.addConstructor(function() { +271 if (typeof navigator.camera == "undefined") navigator.camera = new Camera(); +272 }); +273 +274 +275 +276 /** +277 * This class provides access to the device contacts. +278 * @constructor +279 */ +280 function Contact() { +281 this.name = ""; +282 this.phone = ""; +283 this.address = ""; +284 } +285 286 /** -287 * This class provides access to the device camera. -288 * @constructor -289 */ -290 function Camera() { -291 -292 } -293 -294 /** -295 * -296 * @param {Function} successCallback -297 * @param {Function} errorCallback -298 * @param {Object} options -299 */ -300 Camera.prototype.getPicture = function(successCallback, errorCallback, options) { -301 -302 } -303 -304 PhoneGap.addConstructor(function() { -305 if (typeof navigator.camera == "undefined") navigator.camera = new Camera(); -306 }); -307 -308 -309 -310 /** -311 * This class provides access to the device contacts. -312 * @constructor -313 */ -314 function Contact() { -315 this.name = ""; -316 this.phone = ""; -317 this.address = ""; -318 } -319 -320 /** -321 * -322 * @param {Object} successCallback -323 * @param {Object} errorCallback -324 * @param {Object} options +287 * +288 * @param {Object} successCallback +289 * @param {Object} errorCallback +290 * @param {Object} options +291 */ +292 Contact.prototype.get = function(successCallback, errorCallback, options) { +293 +294 } +295 +296 +297 function ContactManager() { +298 // Dummy object to hold array of contacts +299 this.contacts = []; +300 this.timestap = new Date().getTime(); +301 } +302 +303 ContactManager.prototype.get = function(successCallback, errorCallback, options) { +304 // Interface +305 } +306 +307 PhoneGap.addConstructor(function() { +308 if (typeof navigator.ContactManager == "undefined") navigator.ContactManager = new ContactManager(); +309 }); +310 +311 +312 +313 /** +314 * This class exposes mobile phone interface controls to JavaScript, such as +315 * native tab and tool bars, etc. +316 * @constructor +317 */ +318 function UIControls() { +319 this.tabBarTag = 0; +320 this.tabBarCallbacks = {}; +321 } +322 +323 /** +324 * Create a native tab bar that can have tab buttons added to it which can respond to events. 325 */ -326 Contact.prototype.get = function(successCallback, errorCallback, options) { -327 -328 } -329 -330 -331 function ContactManager() { -332 // Dummy object to hold array of contacts -333 this.contacts = []; -334 this.timestap = new Date().getTime(); -335 } -336 -337 ContactManager.prototype.get = function(successCallback, errorCallback, options) { -338 // Interface -339 } +326 UIControls.prototype.createTabBar = function() {}; +327 +328 /** +329 * Show a tab bar. The tab bar has to be created first. +330 * @param {Object} [options] Options indicating how the tab bar should be shown: +331 * - \c height integer indicating the height of the tab bar (default: \c 49) +332 * - \c position specifies whether the tab bar will be placed at the \c top or \c bottom of the screen (default: \c bottom) +333 */ +334 UIControls.prototype.showTabBar = function(options) {}; +335 +336 /** +337 * Hide a tab bar. The tab bar has to be created first. +338 */ +339 UIControls.prototype.hideTabBar = function(animate) {}; 340 -341 PhoneGap.addConstructor(function() { -342 if (typeof navigator.ContactManager == "undefined") navigator.ContactManager = new ContactManager(); -343 }); -344 -345 -346 -347 /** -348 * This class exposes mobile phone interface controls to JavaScript, such as -349 * native alerts, tab and tool bars, etc. -350 * @constructor -351 */ -352 function UIControls() { -353 } -354 -355 PhoneGap.addConstructor(function() { -356 window.uicontrols = new UIControls(); -357 }); -358 -359 -360 -361 /** -362 * This class provides access to the debugging console. -363 * @constructor -364 */ -365 function DebugConsole() { -366 } +341 /** +342 * Create a new tab bar item for use on a previously created tab bar. Use ::showTabBarItems to show the new item on the tab bar. +343 * +344 * If the supplied image name is one of the labels listed below, then this method will construct a tab button +345 * using the standard system buttons. Note that if you use one of the system images, that the \c title you supply will be ignored. +346 * +347 * <b>Tab Buttons</b> +348 * - tabButton:More +349 * - tabButton:Favorites +350 * - tabButton:Featured +351 * - tabButton:TopRated +352 * - tabButton:Recents +353 * - tabButton:Contacts +354 * - tabButton:History +355 * - tabButton:Bookmarks +356 * - tabButton:Search +357 * - tabButton:Downloads +358 * - tabButton:MostRecent +359 * - tabButton:MostViewed +360 * @param {String} name internal name to refer to this tab by +361 * @param {String} [title] title text to show on the tab, or null if no text should be shown +362 * @param {String} [image] image filename or internal identifier to show, or null if now image should be shown +363 * @param {Object} [options] Options for customizing the individual tab item +364 * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden +365 */ +366 UIControls.prototype.createTabBarItem = function(name, label, image, options) {}; 367 368 /** -369 * Utility function for rendering and indenting strings, or serializing -370 * objects to a string capable of being printed to the console. -371 * @param {Object|String} message The string or object to convert to an indented string -372 * @private +369 * Update an existing tab bar item to change its badge value. +370 * @param {String} name internal name used to represent this item when it was created +371 * @param {Object} options Options for customizing the individual tab item +372 * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden 373 */ -374 DebugConsole.prototype.processMessage = function(message) { -375 if (typeof(message) != 'object') { -376 return encodeURIComponent(message); -377 } else { -378 /** -379 * @function -380 * @ignore -381 */ -382 function indent(str) { -383 return str.replace(/^/mg, " "); -384 } -385 /** -386 * @function -387 * @ignore -388 */ -389 function makeStructured(obj) { -390 var str = ""; -391 for (var i in obj) { -392 try { -393 if (typeof(obj[i]) == 'object') { -394 str += i + ":\n" + indent(makeStructured(obj[i])) + "\n"; -395 } else { -396 str += i + " = " + indent(String(obj[i])).replace(/^ /, "") + "\n"; -397 } -398 } catch(e) { -399 str += i + " = EXCEPTION: " + e.message + "\n"; -400 } -401 } -402 return str; -403 } -404 return encodeURIComponent("Object:\n" + makeStructured(message)); -405 } -406 }; +374 UIControls.prototype.updateTabBarItem = function(name, options) {}; +375 +376 /** +377 * Show previously created items on the tab bar +378 * @param {String} arguments... the item names to be shown +379 * @param {Object} [options] dictionary of options, notable options including: +380 * - \c animate indicates that the items should animate onto the tab bar +381 * @see createTabBarItem +382 * @see createTabBar +383 */ +384 UIControls.prototype.showTabBarItems = function(tabs, options) {}; +385 +386 /** +387 * Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item. +388 * @param {String} tabName the name of the tab to select, or null if all tabs should be deselected +389 * @see createTabBarItem +390 * @see showTabBarItems +391 */ +392 UIControls.prototype.selectTabBarItem = function(tab) {}; +393 +394 /** +395 * Function called when a tab bar item has been selected. +396 * @param {Number} tag the tag number for the item that has been selected +397 */ +398 UIControls.prototype.tabBarItemSelected = function(tag) { +399 if (typeof(this.tabBarCallbacks[tag]) == 'function') +400 this.tabBarCallbacks[tag](); +401 }; +402 +403 /** +404 * Create a toolbar. +405 */ +406 UIControls.prototype.createToolBar = function() {}; 407 408 /** -409 * Print a normal log message to the console -410 * @param {Object|String} message Message or object to print to the console +409 * Function called when a tab bar item has been selected. +410 * @param {String} title the title to set within the toolbar 411 */ -412 DebugConsole.prototype.log = function(message) { -413 }; -414 -415 /** -416 * Print a warning message to the console -417 * @param {Object|String} message Message or object to print to the console -418 */ -419 DebugConsole.prototype.warn = function(message) { -420 }; -421 -422 /** -423 * Print an error message to the console -424 * @param {Object|String} message Message or object to print to the console -425 */ -426 DebugConsole.prototype.error = function(message) { -427 }; -428 -429 PhoneGap.addConstructor(function() { -430 window.debug = new DebugConsole(); -431 }); -432 -433 -434 -435 /** -436 * This class provides generic read and write access to the mobile device file system. -437 */ -438 function File() { -439 /** -440 * The data of a file. -441 */ -442 this.data = ""; -443 /** -444 * The name of the file. -445 */ -446 this.name = ""; -447 } -448 -449 /** -450 * Reads a file from the mobile device. This function is asyncronous. -451 * @param {String} fileName The name (including the path) to the file on the mobile device. -452 * The file name will likely be device dependant. -453 * @param {Function} successCallback The function to call when the file is successfully read. -454 * @param {Function} errorCallback The function to call when there is an error reading the file from the device. -455 */ -456 File.prototype.read = function(fileName, successCallback, errorCallback) { -457 -458 } -459 -460 /** -461 * Writes a file to the mobile device. -462 * @param {File} file The file to write to the device. -463 */ -464 File.prototype.write = function(file) { -465 -466 } -467 -468 PhoneGap.addConstructor(function() { -469 if (typeof navigator.file == "undefined") navigator.file = new File(); -470 }); -471 -472 -473 +412 UIControls.prototype.setToolBarTitle = function(title) {}; +413 +414 PhoneGap.addConstructor(function() { +415 window.uicontrols = new UIControls(); +416 }); +417 +418 +419 +420 /** +421 * This class provides access to the debugging console. +422 * @constructor +423 */ +424 function DebugConsole() { +425 } +426 +427 /** +428 * Utility function for rendering and indenting strings, or serializing +429 * objects to a string capable of being printed to the console. +430 * @param {Object|String} message The string or object to convert to an indented string +431 * @private +432 */ +433 DebugConsole.prototype.processMessage = function(message) { +434 if (typeof(message) != 'object') { +435 return encodeURIComponent(message); +436 } else { +437 /** +438 * @function +439 * @ignore +440 */ +441 function indent(str) { +442 return str.replace(/^/mg, " "); +443 } +444 /** +445 * @function +446 * @ignore +447 */ +448 function makeStructured(obj) { +449 var str = ""; +450 for (var i in obj) { +451 try { +452 if (typeof(obj[i]) == 'object') { +453 str += i + ":\n" + indent(makeStructured(obj[i])) + "\n"; +454 } else { +455 str += i + " = " + indent(String(obj[i])).replace(/^ /, "") + "\n"; +456 } +457 } catch(e) { +458 str += i + " = EXCEPTION: " + e.message + "\n"; +459 } +460 } +461 return str; +462 } +463 return encodeURIComponent("Object:\n" + makeStructured(message)); +464 } +465 }; +466 +467 /** +468 * Print a normal log message to the console +469 * @param {Object|String} message Message or object to print to the console +470 */ +471 DebugConsole.prototype.log = function(message) { +472 }; +473 474 /** -475 * This class provides access to device GPS data. -476 * @constructor +475 * Print a warning message to the console +476 * @param {Object|String} message Message or object to print to the console 477 */ -478 function Geolocation() { -479 /** -480 * The last known GPS position. -481 */ -482 this.lastPosition = null; -483 this.lastError = null; -484 this.callbacks = { -485 onLocationChanged: [], -486 onError: [] -487 }; -488 }; -489 -490 /** -491 * Asynchronously aquires the current position. -492 * @param {Function} successCallback The function to call when the position -493 * data is available -494 * @param {Function} errorCallback The function to call when there is an error -495 * getting the position data. -496 * @param {PositionOptions} options The options for getting the position data -497 * such as timeout. -498 */ -499 Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options) { -500 var referenceTime = 0; -501 if (this.lastPosition) -502 referenceTime = this.lastPosition.timeout; -503 else -504 this.start(options); -505 -506 var timeout = 20000; -507 var interval = 500; -508 if (typeof(options) == 'object' && options.interval) -509 interval = options.interval; -510 -511 if (typeof(successCallback) != 'function') -512 successCallback = function() {}; -513 if (typeof(errorCallback) != 'function') -514 errorCallback = function() {}; -515 -516 var dis = this; -517 var delay = 0; -518 var timer = setInterval(function() { -519 delay += interval; -520 -521 if (typeof(dis.lastPosition) == 'object' && dis.lastPosition.timestamp > referenceTime) { -522 successCallback(dis.lastPosition); -523 clearInterval(timer); -524 } else if (delay >= timeout) { -525 errorCallback(); -526 clearInterval(timer); -527 } -528 }, interval); -529 }; +478 DebugConsole.prototype.warn = function(message) { +479 }; +480 +481 /** +482 * Print an error message to the console +483 * @param {Object|String} message Message or object to print to the console +484 */ +485 DebugConsole.prototype.error = function(message) { +486 }; +487 +488 PhoneGap.addConstructor(function() { +489 window.debug = new DebugConsole(); +490 }); +491 +492 +493 +494 /** +495 * This class provides generic read and write access to the mobile device file system. +496 */ +497 function File() { +498 /** +499 * The data of a file. +500 */ +501 this.data = ""; +502 /** +503 * The name of the file. +504 */ +505 this.name = ""; +506 } +507 +508 /** +509 * Reads a file from the mobile device. This function is asyncronous. +510 * @param {String} fileName The name (including the path) to the file on the mobile device. +511 * The file name will likely be device dependant. +512 * @param {Function} successCallback The function to call when the file is successfully read. +513 * @param {Function} errorCallback The function to call when there is an error reading the file from the device. +514 */ +515 File.prototype.read = function(fileName, successCallback, errorCallback) { +516 +517 } +518 +519 /** +520 * Writes a file to the mobile device. +521 * @param {File} file The file to write to the device. +522 */ +523 File.prototype.write = function(file) { +524 +525 } +526 +527 PhoneGap.addConstructor(function() { +528 if (typeof navigator.file == "undefined") navigator.file = new File(); +529 }); 530 -531 /** -532 * Asynchronously aquires the position repeatedly at a given interval. -533 * @param {Function} successCallback The function to call each time the position -534 * data is available -535 * @param {Function} errorCallback The function to call when there is an error -536 * getting the position data. -537 * @param {PositionOptions} options The options for getting the position data -538 * such as timeout and the frequency of the watch. -539 */ -540 Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options) { -541 // Invoke the appropriate callback with a new Position object every time the implementation -542 // determines that the position of the hosting device has changed. -543 -544 this.getCurrentPosition(successCallback, errorCallback, options); -545 var frequency = 10000; -546 if (typeof(options) == 'object' && options.frequency) -547 frequency = options.frequency; -548 -549 var that = this; -550 return setInterval(function() { -551 that.getCurrentPosition(successCallback, errorCallback, options); -552 }, frequency); -553 }; -554 -555 -556 /** -557 * Clears the specified position watch. -558 * @param {String} watchId The ID of the watch returned from #watchPosition. -559 */ -560 Geolocation.prototype.clearWatch = function(watchId) { -561 clearInterval(watchId); -562 }; -563 -564 /** -565 * Called by the geolocation framework when the current location is found. -566 * @param {PositionOptions} position The current position. -567 */ -568 Geolocation.prototype.setLocation = function(position) { -569 this.lastPosition = position; -570 for (var i = 0; i < this.callbacks.onLocationChanged.length; i++) { -571 var f = this.callbacks.onLocationChanged.shift(); -572 f(position); -573 } -574 }; -575 -576 /** -577 * Called by the geolocation framework when an error occurs while looking up the current position. -578 * @param {String} message The text of the error message. -579 */ -580 Geolocation.prototype.setError = function(message) { -581 this.lastError = message; -582 for (var i = 0; i < this.callbacks.onError.length; i++) { -583 var f = this.callbacks.onError.shift(); -584 f(message); -585 } -586 }; -587 -588 PhoneGap.addConstructor(function() { -589 if (typeof navigator.geolocation == "undefined") navigator.geolocation = new Geolocation(); -590 }); -591 -592 -593 -594 /** -595 * This class provides access to native mapping applications on the device. -596 */ -597 function Map() { -598 -599 } -600 -601 /** -602 * Shows a native map on the device with pins at the given positions. -603 * @param {Array} positions -604 */ -605 Map.prototype.show = function(positions) { -606 -607 } -608 -609 PhoneGap.addConstructor(function() { -610 if (typeof navigator.map == "undefined") navigator.map = new Map(); -611 }); -612 -613 +531 +532 +533 /** +534 * This class provides access to device GPS data. +535 * @constructor +536 */ +537 function Geolocation() { +538 /** +539 * The last known GPS position. +540 */ +541 this.lastPosition = null; +542 this.lastError = null; +543 this.callbacks = { +544 onLocationChanged: [], +545 onError: [] +546 }; +547 }; +548 +549 /** +550 * Asynchronously aquires the current position. +551 * @param {Function} successCallback The function to call when the position +552 * data is available +553 * @param {Function} errorCallback The function to call when there is an error +554 * getting the position data. +555 * @param {PositionOptions} options The options for getting the position data +556 * such as timeout. +557 */ +558 Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options) { +559 var referenceTime = 0; +560 if (this.lastPosition) +561 referenceTime = this.lastPosition.timeout; +562 else +563 this.start(options); +564 +565 var timeout = 20000; +566 var interval = 500; +567 if (typeof(options) == 'object' && options.interval) +568 interval = options.interval; +569 +570 if (typeof(successCallback) != 'function') +571 successCallback = function() {}; +572 if (typeof(errorCallback) != 'function') +573 errorCallback = function() {}; +574 +575 var dis = this; +576 var delay = 0; +577 var timer = setInterval(function() { +578 delay += interval; +579 +580 if (typeof(dis.lastPosition) == 'object' && dis.lastPosition.timestamp > referenceTime) { +581 successCallback(dis.lastPosition); +582 clearInterval(timer); +583 } else if (delay >= timeout) { +584 errorCallback(); +585 clearInterval(timer); +586 } +587 }, interval); +588 }; +589 +590 /** +591 * Asynchronously aquires the position repeatedly at a given interval. +592 * @param {Function} successCallback The function to call each time the position +593 * data is available +594 * @param {Function} errorCallback The function to call when there is an error +595 * getting the position data. +596 * @param {PositionOptions} options The options for getting the position data +597 * such as timeout and the frequency of the watch. +598 */ +599 Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options) { +600 // Invoke the appropriate callback with a new Position object every time the implementation +601 // determines that the position of the hosting device has changed. +602 +603 this.getCurrentPosition(successCallback, errorCallback, options); +604 var frequency = 10000; +605 if (typeof(options) == 'object' && options.frequency) +606 frequency = options.frequency; +607 +608 var that = this; +609 return setInterval(function() { +610 that.getCurrentPosition(successCallback, errorCallback, options); +611 }, frequency); +612 }; +613 614 615 /** -616 * This class provides access to notifications on the device. -617 */ -618 function Notification() { -619 -620 } -621 -622 /** -623 * Open a native alert dialog, with a customizable title and button text. -624 * @param {String} message Message to print in the body of the alert -625 * @param {String} [title="Alert"] Title of the alert dialog (default: Alert) -626 * @param {String} [buttonLabel="OK"] Label of the close button (default: OK) -627 */ -628 Notification.prototype.alert = function(message, title, buttonLabel) { -629 // Default is to use a browser alert; this will use "index.html" as the title though -630 alert(message); -631 }; -632 -633 /** -634 * Start spinning the activity indicator on the statusbar -635 */ -636 Notification.prototype.activityStart = function() { -637 }; -638 -639 /** -640 * Stop spinning the activity indicator on the statusbar, if it's currently spinning -641 */ -642 Notification.prototype.activityStop = function() { -643 }; -644 -645 /** -646 * Causes the device to blink a status LED. -647 * @param {Integer} count The number of blinks. -648 * @param {String} colour The colour of the light. -649 */ -650 Notification.prototype.blink = function(count, colour) { -651 -652 }; -653 -654 /** -655 * Causes the device to vibrate. -656 * @param {Integer} mills The number of milliseconds to vibrate for. -657 */ -658 Notification.prototype.vibrate = function(mills) { -659 -660 }; -661 -662 /** -663 * Causes the device to beep. -664 * @param {Integer} count The number of beeps. -665 * @param {Integer} volume The volume of the beep. -666 */ -667 Notification.prototype.beep = function(count, volume) { -668 -669 }; -670 -671 // TODO: of course on Blackberry and Android there notifications in the UI as well -672 -673 PhoneGap.addConstructor(function() { -674 if (typeof navigator.notification == "undefined") navigator.notification = new Notification(); -675 }); -676 -677 -678 -679 /** -680 * This class provides access to the device orientation. -681 * @constructor -682 */ -683 function Orientation() { -684 /** -685 * The last known orientation. -686 */ -687 this.lastOrientation = null; -688 } -689 -690 /** -691 * Asynchronously aquires the current orientation. -692 * @param {Function} successCallback The function to call when the orientation -693 * is known. -694 * @param {Function} errorCallback The function to call when there is an error -695 * getting the orientation. -696 */ -697 Orientation.prototype.getCurrentOrientation = function(successCallback, errorCallback) { -698 // If the position is available then call success -699 // If the position is not available then call error -700 } -701 -702 /** -703 * Asynchronously aquires the orientation repeatedly at a given interval. -704 * @param {Function} successCallback The function to call each time the orientation -705 * data is available. -706 * @param {Function} errorCallback The function to call when there is an error -707 * getting the orientation data. +616 * Clears the specified position watch. +617 * @param {String} watchId The ID of the watch returned from #watchPosition. +618 */ +619 Geolocation.prototype.clearWatch = function(watchId) { +620 clearInterval(watchId); +621 }; +622 +623 /** +624 * Called by the geolocation framework when the current location is found. +625 * @param {PositionOptions} position The current position. +626 */ +627 Geolocation.prototype.setLocation = function(position) { +628 this.lastPosition = position; +629 for (var i = 0; i < this.callbacks.onLocationChanged.length; i++) { +630 var f = this.callbacks.onLocationChanged.shift(); +631 f(position); +632 } +633 }; +634 +635 /** +636 * Called by the geolocation framework when an error occurs while looking up the current position. +637 * @param {String} message The text of the error message. +638 */ +639 Geolocation.prototype.setError = function(message) { +640 this.lastError = message; +641 for (var i = 0; i < this.callbacks.onError.length; i++) { +642 var f = this.callbacks.onError.shift(); +643 f(message); +644 } +645 }; +646 +647 PhoneGap.addConstructor(function() { +648 if (typeof navigator.geolocation == "undefined") navigator.geolocation = new Geolocation(); +649 }); +650 +651 +652 +653 /** +654 * This class provides access to native mapping applications on the device. +655 */ +656 function Map() { +657 +658 } +659 +660 /** +661 * Shows a native map on the device with pins at the given positions. +662 * @param {Array} positions +663 */ +664 Map.prototype.show = function(positions) { +665 +666 } +667 +668 PhoneGap.addConstructor(function() { +669 if (typeof navigator.map == "undefined") navigator.map = new Map(); +670 }); +671 +672 +673 +674 /** +675 * This class provides access to notifications on the device. +676 */ +677 function Notification() { +678 +679 } +680 +681 /** +682 * Open a native alert dialog, with a customizable title and button text. +683 * @param {String} message Message to print in the body of the alert +684 * @param {String} [title="Alert"] Title of the alert dialog (default: Alert) +685 * @param {String} [buttonLabel="OK"] Label of the close button (default: OK) +686 */ +687 Notification.prototype.alert = function(message, title, buttonLabel) { +688 // Default is to use a browser alert; this will use "index.html" as the title though +689 alert(message); +690 }; +691 +692 /** +693 * Start spinning the activity indicator on the statusbar +694 */ +695 Notification.prototype.activityStart = function() { +696 }; +697 +698 /** +699 * Stop spinning the activity indicator on the statusbar, if it's currently spinning +700 */ +701 Notification.prototype.activityStop = function() { +702 }; +703 +704 /** +705 * Causes the device to blink a status LED. +706 * @param {Integer} count The number of blinks. +707 * @param {String} colour The colour of the light. 708 */ -709 Orientation.prototype.watchOrientation = function(successCallback, errorCallback) { -710 // Invoke the appropriate callback with a new Position object every time the implementation -711 // determines that the position of the hosting device has changed. -712 this.getCurrentPosition(successCallback, errorCallback); -713 return setInterval(function() { -714 navigator.orientation.getCurrentOrientation(successCallback, errorCallback); -715 }, 10000); -716 } -717 -718 /** -719 * Clears the specified orientation watch. -720 * @param {String} watchId The ID of the watch returned from #watchOrientation. -721 */ -722 Orientation.prototype.clearWatch = function(watchId) { -723 clearInterval(watchId); -724 } -725 -726 PhoneGap.addConstructor(function() { -727 if (typeof navigator.orientation == "undefined") navigator.orientation = new Orientation(); -728 }); +709 Notification.prototype.blink = function(count, colour) { +710 +711 }; +712 +713 /** +714 * Causes the device to vibrate. +715 * @param {Integer} mills The number of milliseconds to vibrate for. +716 */ +717 Notification.prototype.vibrate = function(mills) { +718 +719 }; +720 +721 /** +722 * Causes the device to beep. +723 * @param {Integer} count The number of beeps. +724 * @param {Integer} volume The volume of the beep. +725 */ +726 Notification.prototype.beep = function(count, volume) { +727 +728 }; 729 -730 -731 -732 /** -733 * This class contains position information. -734 * @param {Object} lat -735 * @param {Object} lng -736 * @param {Object} acc -737 * @param {Object} alt -738 * @param {Object} altacc -739 * @param {Object} head -740 * @param {Object} vel -741 * @constructor -742 */ -743 function Position(lat, lng, acc, alt, altacc, head, vel) { -744 /** -745 * The latitude of the position. -746 */ -747 this.latitude = lat; -748 /** -749 * The longitude of the position, -750 */ -751 this.longitude = lng; -752 /** -753 * The accuracy of the position. -754 */ -755 this.accuracy = acc; -756 /** -757 * The altitude of the position. -758 */ -759 this.altitude = alt; -760 /** -761 * The altitude accuracy of the position. -762 */ -763 this.altitudeAccuracy = altacc; -764 /** -765 * The direction the device is moving at the position. -766 */ -767 this.heading = head; -768 /** -769 * The velocity with which the device is moving at the position. -770 */ -771 this.velocity = vel; -772 /** -773 * The time that the position was obtained. -774 */ -775 this.timestamp = new Date().getTime(); -776 } -777 -778 /** -779 * This class specifies the options for requesting position data. -780 * @constructor -781 */ -782 function PositionOptions() { -783 /** -784 * Specifies the desired position accuracy. -785 */ -786 this.enableHighAccuracy = true; -787 /** -788 * The timeout after which if position data cannot be obtained the errorCallback -789 * is called. -790 */ -791 this.timeout = 10000; -792 } -793 -794 /** -795 * This class contains information about any GSP errors. -796 * @constructor -797 */ -798 function PositionError() { -799 this.code = null; -800 this.message = ""; -801 } -802 -803 PositionError.UNKNOWN_ERROR = 0; -804 PositionError.PERMISSION_DENIED = 1; -805 PositionError.POSITION_UNAVAILABLE = 2; -806 PositionError.TIMEOUT = 3; -807 -808 -809 -810 /** -811 * This class provides access to the device SMS functionality. -812 * @constructor -813 */ -814 function Sms() { -815 -816 } -817 -818 /** -819 * Sends an SMS message. -820 * @param {Integer} number The phone number to send the message to. -821 * @param {String} message The contents of the SMS message to send. -822 * @param {Function} successCallback The function to call when the SMS message is sent. -823 * @param {Function} errorCallback The function to call when there is an error sending the SMS message. -824 * @param {PositionOptions} options The options for accessing the GPS location such as timeout and accuracy. -825 */ -826 Sms.prototype.send = function(number, message, successCallback, errorCallback, options) { -827 -828 } -829 -830 PhoneGap.addConstructor(function() { -831 if (typeof navigator.sms == "undefined") navigator.sms = new Sms(); -832 }); -833 -834 -835 -836 /** -837 * This class provides access to the telephony features of the device. -838 * @constructor -839 */ -840 function Telephony() { -841 -842 } -843 -844 /** -845 * Calls the specifed number. -846 * @param {Integer} number The number to be called. -847 */ -848 Telephony.prototype.call = function(number) { -849 -850 } -851 -852 PhoneGap.addConstructor(function() { -853 if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony(); -854 }); -855 -856 -857 \ No newline at end of file +730 // TODO: of course on Blackberry and Android there notifications in the UI as well +731 +732 PhoneGap.addConstructor(function() { +733 if (typeof navigator.notification == "undefined") navigator.notification = new Notification(); +734 }); +735 +736 +737 +738 /** +739 * This class provides access to the device orientation. +740 * @constructor +741 */ +742 function Orientation() { +743 /** +744 * The last known orientation. +745 */ +746 this.lastOrientation = null; +747 } +748 +749 /** +750 * Asynchronously aquires the current orientation. +751 * @param {Function} successCallback The function to call when the orientation +752 * is known. +753 * @param {Function} errorCallback The function to call when there is an error +754 * getting the orientation. +755 */ +756 Orientation.prototype.getCurrentOrientation = function(successCallback, errorCallback) { +757 // If the position is available then call success +758 // If the position is not available then call error +759 } +760 +761 /** +762 * Asynchronously aquires the orientation repeatedly at a given interval. +763 * @param {Function} successCallback The function to call each time the orientation +764 * data is available. +765 * @param {Function} errorCallback The function to call when there is an error +766 * getting the orientation data. +767 */ +768 Orientation.prototype.watchOrientation = function(successCallback, errorCallback) { +769 // Invoke the appropriate callback with a new Position object every time the implementation +770 // determines that the position of the hosting device has changed. +771 this.getCurrentPosition(successCallback, errorCallback); +772 return setInterval(function() { +773 navigator.orientation.getCurrentOrientation(successCallback, errorCallback); +774 }, 10000); +775 } +776 +777 /** +778 * Clears the specified orientation watch. +779 * @param {String} watchId The ID of the watch returned from #watchOrientation. +780 */ +781 Orientation.prototype.clearWatch = function(watchId) { +782 clearInterval(watchId); +783 } +784 +785 PhoneGap.addConstructor(function() { +786 if (typeof navigator.orientation == "undefined") navigator.orientation = new Orientation(); +787 }); +788 +789 +790 +791 /** +792 * This class contains position information. +793 * @param {Object} lat +794 * @param {Object} lng +795 * @param {Object} acc +796 * @param {Object} alt +797 * @param {Object} altacc +798 * @param {Object} head +799 * @param {Object} vel +800 * @constructor +801 */ +802 function Position(lat, lng, acc, alt, altacc, head, vel) { +803 /** +804 * The latitude of the position. +805 */ +806 this.latitude = lat; +807 /** +808 * The longitude of the position, +809 */ +810 this.longitude = lng; +811 /** +812 * The accuracy of the position. +813 */ +814 this.accuracy = acc; +815 /** +816 * The altitude of the position. +817 */ +818 this.altitude = alt; +819 /** +820 * The altitude accuracy of the position. +821 */ +822 this.altitudeAccuracy = altacc; +823 /** +824 * The direction the device is moving at the position. +825 */ +826 this.heading = head; +827 /** +828 * The velocity with which the device is moving at the position. +829 */ +830 this.velocity = vel; +831 /** +832 * The time that the position was obtained. +833 */ +834 this.timestamp = new Date().getTime(); +835 } +836 +837 /** +838 * This class specifies the options for requesting position data. +839 * @constructor +840 */ +841 function PositionOptions() { +842 /** +843 * Specifies the desired position accuracy. +844 */ +845 this.enableHighAccuracy = true; +846 /** +847 * The timeout after which if position data cannot be obtained the errorCallback +848 * is called. +849 */ +850 this.timeout = 10000; +851 } +852 +853 /** +854 * This class contains information about any GSP errors. +855 * @constructor +856 */ +857 function PositionError() { +858 this.code = null; +859 this.message = ""; +860 } +861 +862 PositionError.UNKNOWN_ERROR = 0; +863 PositionError.PERMISSION_DENIED = 1; +864 PositionError.POSITION_UNAVAILABLE = 2; +865 PositionError.TIMEOUT = 3; +866 +867 +868 +869 /** +870 * This class provides access to the device SMS functionality. +871 * @constructor +872 */ +873 function Sms() { +874 +875 } +876 +877 /** +878 * Sends an SMS message. +879 * @param {Integer} number The phone number to send the message to. +880 * @param {String} message The contents of the SMS message to send. +881 * @param {Function} successCallback The function to call when the SMS message is sent. +882 * @param {Function} errorCallback The function to call when there is an error sending the SMS message. +883 * @param {PositionOptions} options The options for accessing the GPS location such as timeout and accuracy. +884 */ +885 Sms.prototype.send = function(number, message, successCallback, errorCallback, options) { +886 +887 } +888 +889 PhoneGap.addConstructor(function() { +890 if (typeof navigator.sms == "undefined") navigator.sms = new Sms(); +891 }); +892 +893 +894 +895 /** +896 * This class provides access to the telephony features of the device. +897 * @constructor +898 */ +899 function Telephony() { +900 +901 } +902 +903 /** +904 * Calls the specifed number. +905 * @param {Integer} number The number to be called. +906 */ +907 Telephony.prototype.call = function(number) { +908 +909 } +910 +911 PhoneGap.addConstructor(function() { +912 if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony(); +913 }); +914 +915 +916 \ No newline at end of file diff --git a/javascripts/iphone/device.js b/javascripts/iphone/device.js new file mode 100644 index 00000000..f9870df3 --- /dev/null +++ b/javascripts/iphone/device.js @@ -0,0 +1,41 @@ +/** + * Internal function used to dispatch the request to PhoneGap. It processes the + * command queue and executes the next command on the list. If one of the + * arguments is a JavaScript object, it will be passed on the QueryString of the + * url, which will be turned into a dictionary on the other end. + * @private + */ +PhoneGap.run_command = function() { + if (!PhoneGap.available) + return; + + PhoneGap.queue.ready = false; + + var args = PhoneGap.queue.commands.shift(); + if (PhoneGap.queue.commands.length == 0) { + clearInterval(PhoneGap.queue.timer); + PhoneGap.queue.timer = null; + } + + var uri = []; + var dict = null; + for (var i = 1; i < args.length; i++) { + if (typeof(args[i]) == 'object') + dict = args[i]; + else + uri.push(encodeURIComponent(args[i])); + } + var url = "gap://" + args[0] + "/" + uri.join("/"); + if (dict != null) { + var query_args = []; + for (var name in dict) { + if (typeof(name) != 'string') + continue; + query_args.push(encodeURIComponent(name) + "=" + encodeURIComponent(dict[name])); + } + if (query_args.length > 0) + url += "?" + query_args.join("&"); + } + document.location = url; + +}; diff --git a/javascripts/iphone/notification.js b/javascripts/iphone/notification.js index ceca7d54..513a252c 100644 --- a/javascripts/iphone/notification.js +++ b/javascripts/iphone/notification.js @@ -9,10 +9,10 @@ Notification.prototype.beep = function(count, volume) { }; Notification.prototype.alert = function(message, title, buttonLabel) { - var options = { - title: title, - buttonLabel: buttonLabel - }; + var options = {}; + if (title) options.title = title; + if (buttonLabel) options.buttonLabel = buttonLabel; + if (PhoneGap.available) PhoneGap.exec('Notification.alert', message, options); else diff --git a/javascripts/iphone/uicontrols.js b/javascripts/iphone/uicontrols.js index 8b137891..3fedbe5d 100644 --- a/javascripts/iphone/uicontrols.js +++ b/javascripts/iphone/uicontrols.js @@ -1 +1,42 @@ +UIControls.prototype.createTabBar = function() { + PhoneGap.exec("UIControls.createTabBar"); +}; +UIControls.prototype.showTabBar = function(options) { + PhoneGap.exec("UIControls.showTabBar", options); +}; + +UIControls.prototype.hideTabBar = function(animate) { + PhoneGap.exec("UIControls.hideTabBar", { animate: animate }); +}; + +UIControls.prototype.createTabBarItem = function(name, label, image, options) { + var tag = this.tabBarTag++; + if (options && 'onSelect' in options && typeof(options['onSelect']) == 'function') + this.tabBarCallbacks[tag] = options.onSelect; + PhoneGap.exec("UIControls.createTabBarItem", name, label, image, tag, options); +}; + +UIControls.prototype.updateTabBarItem = function(name, options) { + PhoneGap.exec("UIControls.updateTabBarItem", name, options); +}; + +UIControls.prototype.showTabBarItems = function() { + var parameters = [ "UIControls.showTabBarItems" ]; + for (var i = 0; i < arguments.length; i++) { + parameters.push(arguments[i]); + } + PhoneGap.exec.apply(this, parameters); +}; + +UIControls.prototype.selectTabBarItem = function(tab) { + PhoneGap.exec("UIControls.selectTabBarItem", tab); +}; + +UIControls.prototype.createToolBar = function() { + PhoneGap.exec("UIControls.createToolBar"); +}; + +UIControls.prototype.setToolBarTitle = function(title) { + PhoneGap.exec("UIControls.setToolBarTitle", title); +}; diff --git a/javascripts/uicontrols.js b/javascripts/uicontrols.js index 6ab7aacb..2533198b 100644 --- a/javascripts/uicontrols.js +++ b/javascripts/uicontrols.js @@ -1,11 +1,104 @@ /** * This class exposes mobile phone interface controls to JavaScript, such as - * native alerts, tab and tool bars, etc. + * native tab and tool bars, etc. * @constructor */ function UIControls() { + this.tabBarTag = 0; + this.tabBarCallbacks = {}; } +/** + * Create a native tab bar that can have tab buttons added to it which can respond to events. + */ +UIControls.prototype.createTabBar = function() {}; + +/** + * Show a tab bar. The tab bar has to be created first. + * @param {Object} [options] Options indicating how the tab bar should be shown: + * - \c height integer indicating the height of the tab bar (default: \c 49) + * - \c position specifies whether the tab bar will be placed at the \c top or \c bottom of the screen (default: \c bottom) + */ +UIControls.prototype.showTabBar = function(options) {}; + +/** + * Hide a tab bar. The tab bar has to be created first. + */ +UIControls.prototype.hideTabBar = function(animate) {}; + +/** + * Create a new tab bar item for use on a previously created tab bar. Use ::showTabBarItems to show the new item on the tab bar. + * + * If the supplied image name is one of the labels listed below, then this method will construct a tab button + * using the standard system buttons. Note that if you use one of the system images, that the \c title you supply will be ignored. + * + * Tab Buttons + * - tabButton:More + * - tabButton:Favorites + * - tabButton:Featured + * - tabButton:TopRated + * - tabButton:Recents + * - tabButton:Contacts + * - tabButton:History + * - tabButton:Bookmarks + * - tabButton:Search + * - tabButton:Downloads + * - tabButton:MostRecent + * - tabButton:MostViewed + * @param {String} name internal name to refer to this tab by + * @param {String} [title] title text to show on the tab, or null if no text should be shown + * @param {String} [image] image filename or internal identifier to show, or null if now image should be shown + * @param {Object} [options] Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ +UIControls.prototype.createTabBarItem = function(name, label, image, options) {}; + +/** + * Update an existing tab bar item to change its badge value. + * @param {String} name internal name used to represent this item when it was created + * @param {Object} options Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ +UIControls.prototype.updateTabBarItem = function(name, options) {}; + +/** + * Show previously created items on the tab bar + * @param {String} arguments... the item names to be shown + * @param {Object} [options] dictionary of options, notable options including: + * - \c animate indicates that the items should animate onto the tab bar + * @see createTabBarItem + * @see createTabBar + */ +UIControls.prototype.showTabBarItems = function(tabs, options) {}; + +/** + * Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item. + * @param {String} tabName the name of the tab to select, or null if all tabs should be deselected + * @see createTabBarItem + * @see showTabBarItems + */ +UIControls.prototype.selectTabBarItem = function(tab) {}; + +/** + * Function called when a tab bar item has been selected. + * @param {Number} tag the tag number for the item that has been selected + */ +UIControls.prototype.tabBarItemSelected = function(tag) { + if (typeof(this.tabBarCallbacks[tag]) == 'function') + this.tabBarCallbacks[tag](); +}; + +/** + * Create a toolbar. + */ +UIControls.prototype.createToolBar = function() {}; + +/** + * Function called when a tab bar item has been selected. + * @param {String} title the title to set within the toolbar + */ +UIControls.prototype.setToolBarTitle = function(title) {}; + PhoneGap.addConstructor(function() { window.uicontrols = new UIControls(); }); diff --git a/lib/android/phonegap-min.js b/lib/android/phonegap-min.js index db0273e1..98a94096 100644 --- a/lib/android/phonegap-min.js +++ b/lib/android/phonegap-min.js @@ -1 +1 @@ -if(typeof(DeviceInfo)!="object"){DeviceInfo={}}PhoneGap={queue:{ready:true,commands:[],timer:null},_constructors:[]};PhoneGap.available=DeviceInfo.uuid!=undefined;PhoneGap.addConstructor=function(a){var b=document.readyState;if(b!="loaded"&&b!="complete"){PhoneGap._constructors.push(a)}else{a()}};(function(){var a=setInterval(function(){var c=document.readyState;if(c!="loaded"&&c!="complete"){return}clearInterval(a);while(PhoneGap._constructors.length>0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){if(!PhoneGap.available){return}PhoneGap.queue.ready=false;var d=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var f=[];var g=null;for(var e=1;eg){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;b0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){};function Device(){this.available=PhoneGap.available;this.model=null;this.version=null;this.gap=null;this.uuid=null;try{if(window.DroidGap!=undefined&&window.DroidGap.exists()){this.available=true;this.isAndroid=true;this.uuid=window.DroidGap.getUuid();this.gapVersion=window.DroidGap.getVersion()}else{this.model=DeviceInfo.platform;this.version=DeviceInfo.version;this.gap=DeviceInfo.gap;this.uuid=DeviceInfo.uuid}}catch(a){this.available=false}}PhoneGap.addConstructor(function(){navigator.device=window.device=new Device()});function Acceleration(a,c,b){this.x=a;this.y=c;this.z=b;this.timestamp=new Date().getTime()}function AccelerationOptions(){this.timeout=10000}function Accelerometer(){this.lastAcceleration=null}Accelerometer.prototype.getCurrentAcceleration=function(a,b,c){if(typeof a=="function"){var d=new Acceleration(_accel.x,_accel.y,_accel.z);Accelerometer.lastAcceleration=d;a(d)}};Accelerometer.prototype.watchAcceleration=function(a,b,c){this.getCurrentAcceleration(a,b,c);var d=(c!=undefined)?c.frequency:10000;return setInterval(function(){navigator.accelerometer.getCurrentAcceleration(a,b,c)},d)};Accelerometer.prototype.clearWatch=function(a){clearInterval(a)};PhoneGap.addConstructor(function(){if(typeof navigator.accelerometer=="undefined"){navigator.accelerometer=new Accelerometer()}});function Media(a){this.src=a}Media.prototype.play=function(){};Media.prototype.pause=function(){};Media.prototype.stop=function(){};function MediaError(){this.code=null,this.message=""}MediaError.MEDIA_ERR_ABORTED=1;MediaError.MEDIA_ERR_NETWORK=2;MediaError.MEDIA_ERR_DECODE=3;MediaError.MEDIA_ERR_NONE_SUPPORTED=4;function Camera(){}Camera.prototype.getPicture=function(a,b,c){};PhoneGap.addConstructor(function(){if(typeof navigator.camera=="undefined"){navigator.camera=new Camera()}});function Contact(){this.name="";this.phone="";this.address=""}Contact.prototype.get=function(a,b,c){};function ContactManager(){this.contacts=[];this.timestap=new Date().getTime()}ContactManager.prototype.get=function(a,b,c){};PhoneGap.addConstructor(function(){if(typeof navigator.ContactManager=="undefined"){navigator.ContactManager=new ContactManager()}});function UIControls(){this.tabBarTag=0;this.tabBarCallbacks={}}UIControls.prototype.createTabBar=function(){};UIControls.prototype.showTabBar=function(a){};UIControls.prototype.hideTabBar=function(a){};UIControls.prototype.createTabBarItem=function(c,b,d,a){};UIControls.prototype.updateTabBarItem=function(b,a){};UIControls.prototype.showTabBarItems=function(b,a){};UIControls.prototype.selectTabBarItem=function(a){};UIControls.prototype.tabBarItemSelected=function(a){if(typeof(this.tabBarCallbacks[a])=="function"){this.tabBarCallbacks[a]()}};UIControls.prototype.createToolBar=function(){};UIControls.prototype.setToolBarTitle=function(a){};PhoneGap.addConstructor(function(){window.uicontrols=new UIControls()});function DebugConsole(){}DebugConsole.prototype.processMessage=function(b){if(typeof(b)!="object"){return encodeURIComponent(b)}else{function a(d){return d.replace(/^/mg," ")}function c(g){var h="";for(var d in g){try{if(typeof(g[d])=="object"){h+=d+":\n"+a(c(g[d]))+"\n"}else{h+=d+" = "+a(String(g[d])).replace(/^ /,"")+"\n"}}catch(f){h+=d+" = EXCEPTION: "+f.message+"\n"}}return h}return encodeURIComponent("Object:\n"+c(b))}};DebugConsole.prototype.log=function(a){};DebugConsole.prototype.warn=function(a){};DebugConsole.prototype.error=function(a){};PhoneGap.addConstructor(function(){window.debug=new DebugConsole()});function File(){this.data="";this.name=""}File.prototype.read=function(c,a,b){};File.prototype.write=function(a){};PhoneGap.addConstructor(function(){if(typeof navigator.file=="undefined"){navigator.file=new File()}});function Geolocation(){this.lastPosition=null;this.lastError=null;this.callbacks={onLocationChanged:[],onError:[]}}Geolocation.prototype.getCurrentPosition=function(c,f,i){var g=0;if(this.lastPosition){g=this.lastPosition.timeout}else{this.start(i)}var h=20000;var b=500;if(typeof(i)=="object"&&i.interval){b=i.interval}if(typeof(c)!="function"){c=function(){}}if(typeof(f)!="function"){f=function(){}}var d=this;var e=0;var a=setInterval(function(){e+=b;if(typeof(d.lastPosition)=="object"&&d.lastPosition.timestamp>g){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;bTab Buttons + * - tabButton:More + * - tabButton:Favorites + * - tabButton:Featured + * - tabButton:TopRated + * - tabButton:Recents + * - tabButton:Contacts + * - tabButton:History + * - tabButton:Bookmarks + * - tabButton:Search + * - tabButton:Downloads + * - tabButton:MostRecent + * - tabButton:MostViewed + * @param {String} name internal name to refer to this tab by + * @param {String} [title] title text to show on the tab, or null if no text should be shown + * @param {String} [image] image filename or internal identifier to show, or null if now image should be shown + * @param {Object} [options] Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ + UIControls.prototype.createTabBarItem = function(name, label, image, options) {}; + + /** + * Update an existing tab bar item to change its badge value. + * @param {String} name internal name used to represent this item when it was created + * @param {Object} options Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ + UIControls.prototype.updateTabBarItem = function(name, options) {}; + + /** + * Show previously created items on the tab bar + * @param {String} arguments... the item names to be shown + * @param {Object} [options] dictionary of options, notable options including: + * - \c animate indicates that the items should animate onto the tab bar + * @see createTabBarItem + * @see createTabBar + */ + UIControls.prototype.showTabBarItems = function(tabs, options) {}; + + /** + * Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item. + * @param {String} tabName the name of the tab to select, or null if all tabs should be deselected + * @see createTabBarItem + * @see showTabBarItems + */ + UIControls.prototype.selectTabBarItem = function(tab) {}; + + /** + * Function called when a tab bar item has been selected. + * @param {Number} tag the tag number for the item that has been selected + */ + UIControls.prototype.tabBarItemSelected = function(tag) { + if (typeof(this.tabBarCallbacks[tag]) == 'function') + this.tabBarCallbacks[tag](); + }; + + /** + * Create a toolbar. + */ + UIControls.prototype.createToolBar = function() {}; + + /** + * Function called when a tab bar item has been selected. + * @param {String} title the title to set within the toolbar + */ + UIControls.prototype.setToolBarTitle = function(title) {}; + PhoneGap.addConstructor(function() { window.uicontrols = new UIControls(); }); diff --git a/lib/blackberry/phonegap-min.js b/lib/blackberry/phonegap-min.js index 8923d337..526fba0d 100644 --- a/lib/blackberry/phonegap-min.js +++ b/lib/blackberry/phonegap-min.js @@ -1 +1 @@ -if(typeof(DeviceInfo)!="object"){DeviceInfo={}}PhoneGap={queue:{ready:true,commands:[],timer:null},_constructors:[]};PhoneGap.available=DeviceInfo.uuid!=undefined;PhoneGap.addConstructor=function(a){var b=document.readyState;if(b!="loaded"&&b!="complete"){PhoneGap._constructors.push(a)}else{a()}};(function(){var a=setInterval(function(){var c=document.readyState;if(c!="loaded"&&c!="complete"){return}clearInterval(a);while(PhoneGap._constructors.length>0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){if(!PhoneGap.available){return}PhoneGap.queue.ready=false;var d=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var f=[];var g=null;for(var e=1;e0){successCallback(file)}}}}};File.prototype.write=function(b,a){document.cookie='bb_command={command:9,args:{name:"'+b+'",data:"'+a+'"}}'};function Geolocation(){this.lastPosition=null;this.lastError=null;this.callbacks={onLocationChanged:[],onError:[]}}Geolocation.prototype.getCurrentPosition=function(c,f,i){var g=0;if(this.lastPosition){g=this.lastPosition.timeout}else{this.start(i)}var h=20000;var b=500;if(typeof(i)=="object"&&i.interval){b=i.interval}if(typeof(c)!="function"){c=function(){}}if(typeof(f)!="function"){f=function(){}}var d=this;var e=0;var a=setInterval(function(){e+=b;if(typeof(d.lastPosition)=="object"&&d.lastPosition.timestamp>g){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;b0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){};function Device(){this.available=PhoneGap.available;this.model=null;this.version=null;this.gap=null;this.uuid=null;try{if(window.DroidGap!=undefined&&window.DroidGap.exists()){this.available=true;this.isAndroid=true;this.uuid=window.DroidGap.getUuid();this.gapVersion=window.DroidGap.getVersion()}else{this.model=DeviceInfo.platform;this.version=DeviceInfo.version;this.gap=DeviceInfo.gap;this.uuid=DeviceInfo.uuid}}catch(a){this.available=false}}PhoneGap.addConstructor(function(){navigator.device=window.device=new Device()});function Acceleration(a,c,b){this.x=a;this.y=c;this.z=b;this.timestamp=new Date().getTime()}function AccelerationOptions(){this.timeout=10000}function Accelerometer(){this.lastAcceleration=null}Accelerometer.prototype.getCurrentAcceleration=function(a,b,c){if(typeof a=="function"){var d=new Acceleration(_accel.x,_accel.y,_accel.z);Accelerometer.lastAcceleration=d;a(d)}};Accelerometer.prototype.watchAcceleration=function(a,b,c){this.getCurrentAcceleration(a,b,c);var d=(c!=undefined)?c.frequency:10000;return setInterval(function(){navigator.accelerometer.getCurrentAcceleration(a,b,c)},d)};Accelerometer.prototype.clearWatch=function(a){clearInterval(a)};PhoneGap.addConstructor(function(){if(typeof navigator.accelerometer=="undefined"){navigator.accelerometer=new Accelerometer()}});function Media(a){this.src=a}Media.prototype.play=function(){};Media.prototype.pause=function(){};Media.prototype.stop=function(){};function MediaError(){this.code=null,this.message=""}MediaError.MEDIA_ERR_ABORTED=1;MediaError.MEDIA_ERR_NETWORK=2;MediaError.MEDIA_ERR_DECODE=3;MediaError.MEDIA_ERR_NONE_SUPPORTED=4;function Camera(){}Camera.prototype.getPicture=function(a,b,c){};PhoneGap.addConstructor(function(){if(typeof navigator.camera=="undefined"){navigator.camera=new Camera()}});function Contact(){this.name="";this.phone="";this.address=""}Contact.prototype.get=function(a,b,c){};function ContactManager(){this.contacts=[];this.timestap=new Date().getTime()}ContactManager.prototype.get=function(a,b,c){};PhoneGap.addConstructor(function(){if(typeof navigator.ContactManager=="undefined"){navigator.ContactManager=new ContactManager()}});function UIControls(){this.tabBarTag=0;this.tabBarCallbacks={}}UIControls.prototype.createTabBar=function(){};UIControls.prototype.showTabBar=function(a){};UIControls.prototype.hideTabBar=function(a){};UIControls.prototype.createTabBarItem=function(c,b,d,a){};UIControls.prototype.updateTabBarItem=function(b,a){};UIControls.prototype.showTabBarItems=function(b,a){};UIControls.prototype.selectTabBarItem=function(a){};UIControls.prototype.tabBarItemSelected=function(a){if(typeof(this.tabBarCallbacks[a])=="function"){this.tabBarCallbacks[a]()}};UIControls.prototype.createToolBar=function(){};UIControls.prototype.setToolBarTitle=function(a){};PhoneGap.addConstructor(function(){window.uicontrols=new UIControls()});function DebugConsole(){}DebugConsole.prototype.processMessage=function(b){if(typeof(b)!="object"){return encodeURIComponent(b)}else{function a(d){return d.replace(/^/mg," ")}function c(g){var h="";for(var d in g){try{if(typeof(g[d])=="object"){h+=d+":\n"+a(c(g[d]))+"\n"}else{h+=d+" = "+a(String(g[d])).replace(/^ /,"")+"\n"}}catch(f){h+=d+" = EXCEPTION: "+f.message+"\n"}}return h}return encodeURIComponent("Object:\n"+c(b))}};DebugConsole.prototype.log=function(a){};DebugConsole.prototype.warn=function(a){};DebugConsole.prototype.error=function(a){};PhoneGap.addConstructor(function(){window.debug=new DebugConsole()});function File(){this.data="";this.name=""}File.prototype.read=function(c,a,b){};File.prototype.write=function(a){};PhoneGap.addConstructor(function(){if(typeof navigator.file=="undefined"){navigator.file=new File()}});File.prototype.read=function(c,a,b){document.cookie='bb_command={command:8,args:{name:"'+c+'"}}';navigator.file.successCallback=a;navigator.file.errorCallback=b;navigator.file.readTimeout=window.setInterval("navigator.file._readReady()",1000)};File.prototype._readReady=function(){var cookies=document.cookie.split(";");for(var i=0;i0){successCallback(file)}}}}};File.prototype.write=function(b,a){document.cookie='bb_command={command:9,args:{name:"'+b+'",data:"'+a+'"}}'};function Geolocation(){this.lastPosition=null;this.lastError=null;this.callbacks={onLocationChanged:[],onError:[]}}Geolocation.prototype.getCurrentPosition=function(c,f,i){var g=0;if(this.lastPosition){g=this.lastPosition.timeout}else{this.start(i)}var h=20000;var b=500;if(typeof(i)=="object"&&i.interval){b=i.interval}if(typeof(c)!="function"){c=function(){}}if(typeof(f)!="function"){f=function(){}}var d=this;var e=0;var a=setInterval(function(){e+=b;if(typeof(d.lastPosition)=="object"&&d.lastPosition.timestamp>g){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;bTab Buttons + * - tabButton:More + * - tabButton:Favorites + * - tabButton:Featured + * - tabButton:TopRated + * - tabButton:Recents + * - tabButton:Contacts + * - tabButton:History + * - tabButton:Bookmarks + * - tabButton:Search + * - tabButton:Downloads + * - tabButton:MostRecent + * - tabButton:MostViewed + * @param {String} name internal name to refer to this tab by + * @param {String} [title] title text to show on the tab, or null if no text should be shown + * @param {String} [image] image filename or internal identifier to show, or null if now image should be shown + * @param {Object} [options] Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ + UIControls.prototype.createTabBarItem = function(name, label, image, options) {}; + + /** + * Update an existing tab bar item to change its badge value. + * @param {String} name internal name used to represent this item when it was created + * @param {Object} options Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ + UIControls.prototype.updateTabBarItem = function(name, options) {}; + + /** + * Show previously created items on the tab bar + * @param {String} arguments... the item names to be shown + * @param {Object} [options] dictionary of options, notable options including: + * - \c animate indicates that the items should animate onto the tab bar + * @see createTabBarItem + * @see createTabBar + */ + UIControls.prototype.showTabBarItems = function(tabs, options) {}; + + /** + * Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item. + * @param {String} tabName the name of the tab to select, or null if all tabs should be deselected + * @see createTabBarItem + * @see showTabBarItems + */ + UIControls.prototype.selectTabBarItem = function(tab) {}; + + /** + * Function called when a tab bar item has been selected. + * @param {Number} tag the tag number for the item that has been selected + */ + UIControls.prototype.tabBarItemSelected = function(tag) { + if (typeof(this.tabBarCallbacks[tag]) == 'function') + this.tabBarCallbacks[tag](); + }; + + /** + * Create a toolbar. + */ + UIControls.prototype.createToolBar = function() {}; + + /** + * Function called when a tab bar item has been selected. + * @param {String} title the title to set within the toolbar + */ + UIControls.prototype.setToolBarTitle = function(title) {}; + PhoneGap.addConstructor(function() { window.uicontrols = new UIControls(); }); diff --git a/lib/iphone/phonegap-min.js b/lib/iphone/phonegap-min.js index 23870833..71f49976 100644 --- a/lib/iphone/phonegap-min.js +++ b/lib/iphone/phonegap-min.js @@ -1 +1 @@ -if(typeof(DeviceInfo)!="object"){DeviceInfo={}}PhoneGap={queue:{ready:true,commands:[],timer:null},_constructors:[]};PhoneGap.available=DeviceInfo.uuid!=undefined;PhoneGap.addConstructor=function(a){var b=document.readyState;if(b!="loaded"&&b!="complete"){PhoneGap._constructors.push(a)}else{a()}};(function(){var a=setInterval(function(){var c=document.readyState;if(c!="loaded"&&c!="complete"){return}clearInterval(a);while(PhoneGap._constructors.length>0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){if(!PhoneGap.available){return}PhoneGap.queue.ready=false;var d=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var f=[];var g=null;for(var e=1;eg){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;b0){var b=PhoneGap._constructors.shift();try{b()}catch(d){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+d.message)}else{alert("Failed to run constructor: "+d.message)}}}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){};function Device(){this.available=PhoneGap.available;this.model=null;this.version=null;this.gap=null;this.uuid=null;try{if(window.DroidGap!=undefined&&window.DroidGap.exists()){this.available=true;this.isAndroid=true;this.uuid=window.DroidGap.getUuid();this.gapVersion=window.DroidGap.getVersion()}else{this.model=DeviceInfo.platform;this.version=DeviceInfo.version;this.gap=DeviceInfo.gap;this.uuid=DeviceInfo.uuid}}catch(a){this.available=false}}PhoneGap.addConstructor(function(){navigator.device=window.device=new Device()});PhoneGap.run_command=function(){if(!PhoneGap.available){return}PhoneGap.queue.ready=false;var d=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var f=[];var g=null;for(var e=1;eg){c(d.lastPosition);clearInterval(a)}else{if(e>=h){f();clearInterval(a)}}},b)};Geolocation.prototype.watchPosition=function(a,b,c){this.getCurrentPosition(a,b,c);var e=10000;if(typeof(c)=="object"&&c.frequency){e=c.frequency}var d=this;return setInterval(function(){d.getCurrentPosition(a,b,c)},e)};Geolocation.prototype.clearWatch=function(a){clearInterval(a)};Geolocation.prototype.setLocation=function(a){this.lastPosition=a;for(var b=0;bTab Buttons + * - tabButton:More + * - tabButton:Favorites + * - tabButton:Featured + * - tabButton:TopRated + * - tabButton:Recents + * - tabButton:Contacts + * - tabButton:History + * - tabButton:Bookmarks + * - tabButton:Search + * - tabButton:Downloads + * - tabButton:MostRecent + * - tabButton:MostViewed + * @param {String} name internal name to refer to this tab by + * @param {String} [title] title text to show on the tab, or null if no text should be shown + * @param {String} [image] image filename or internal identifier to show, or null if now image should be shown + * @param {Object} [options] Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ + UIControls.prototype.createTabBarItem = function(name, label, image, options) {}; + + /** + * Update an existing tab bar item to change its badge value. + * @param {String} name internal name used to represent this item when it was created + * @param {Object} options Options for customizing the individual tab item + * - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden + */ + UIControls.prototype.updateTabBarItem = function(name, options) {}; + + /** + * Show previously created items on the tab bar + * @param {String} arguments... the item names to be shown + * @param {Object} [options] dictionary of options, notable options including: + * - \c animate indicates that the items should animate onto the tab bar + * @see createTabBarItem + * @see createTabBar + */ + UIControls.prototype.showTabBarItems = function(tabs, options) {}; + + /** + * Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item. + * @param {String} tabName the name of the tab to select, or null if all tabs should be deselected + * @see createTabBarItem + * @see showTabBarItems + */ + UIControls.prototype.selectTabBarItem = function(tab) {}; + + /** + * Function called when a tab bar item has been selected. + * @param {Number} tag the tag number for the item that has been selected + */ + UIControls.prototype.tabBarItemSelected = function(tag) { + if (typeof(this.tabBarCallbacks[tag]) == 'function') + this.tabBarCallbacks[tag](); + }; + + /** + * Create a toolbar. + */ + UIControls.prototype.createToolBar = function() {}; + + /** + * Function called when a tab bar item has been selected. + * @param {String} title the title to set within the toolbar + */ + UIControls.prototype.setToolBarTitle = function(title) {}; + PhoneGap.addConstructor(function() { window.uicontrols = new UIControls(); }); + UIControls.prototype.createTabBar = function() { + PhoneGap.exec("UIControls.createTabBar"); + }; + UIControls.prototype.showTabBar = function(options) { + PhoneGap.exec("UIControls.showTabBar", options); + }; + + UIControls.prototype.hideTabBar = function(animate) { + PhoneGap.exec("UIControls.hideTabBar", { animate: animate }); + }; + + UIControls.prototype.createTabBarItem = function(name, label, image, options) { + var tag = this.tabBarTag++; + if (options && 'onSelect' in options && typeof(options['onSelect']) == 'function') + this.tabBarCallbacks[tag] = options.onSelect; + PhoneGap.exec("UIControls.createTabBarItem", name, label, image, tag, options); + }; + + UIControls.prototype.updateTabBarItem = function(name, options) { + PhoneGap.exec("UIControls.updateTabBarItem", name, options); + }; + + UIControls.prototype.showTabBarItems = function() { + var parameters = [ "UIControls.showTabBarItems" ]; + for (var i = 0; i < arguments.length; i++) { + parameters.push(arguments[i]); + } + PhoneGap.exec.apply(this, parameters); + }; + + UIControls.prototype.selectTabBarItem = function(tab) { + PhoneGap.exec("UIControls.selectTabBarItem", tab); + }; + + UIControls.prototype.createToolBar = function() { + PhoneGap.exec("UIControls.createToolBar"); + }; + + UIControls.prototype.setToolBarTitle = function(title) { + PhoneGap.exec("UIControls.setToolBarTitle", title); + }; @@ -771,10 +915,10 @@ }; Notification.prototype.alert = function(message, title, buttonLabel) { - var options = { - title: title, - buttonLabel: buttonLabel - }; + var options = {}; + if (title) options.title = title; + if (buttonLabel) options.buttonLabel = buttonLabel; + if (PhoneGap.available) PhoneGap.exec('Notification.alert', message, options); else diff --git a/util/jsdoc-toolkit/out/jsdoc/symbols/UIControls.html b/util/jsdoc-toolkit/out/jsdoc/symbols/UIControls.html deleted file mode 100644 index ef1ed758..00000000 --- a/util/jsdoc-toolkit/out/jsdoc/symbols/UIControls.html +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - - JsDoc Reference - UIControls - - - - - - - - - - - - - -
- -

- - Class UIControls -

- - -

- - - - - -
Defined in: phonegap.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  -
- UIControls() -
-
This class exposes mobile phone interface controls to JavaScript, such as -native alerts, tab and tool bars, etc.
-
- - - - - - - - - - - - -
-
- Class Detail -
- -
- UIControls() -
- -
- This class exposes mobile phone interface controls to JavaScript, such as -native alerts, tab and tool bars, etc. - -
- - - - - - - - - - - - -
- - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 16 2009 18:42:10 GMT-0700 (PDT) -
- -