Skip to content

Instantly share code, notes, and snippets.

@orlaqp
Created November 4, 2011 05:23
Show Gist options
  • Save orlaqp/1338720 to your computer and use it in GitHub Desktop.
Save orlaqp/1338720 to your computer and use it in GitHub Desktop.
- (void)authenticationResult:(BOOL)aResult
{
console.log("result received: " + aResult);
[_loginController closeModal];
if (aResult == YES)
{
// Prepare the Application Toolbar
_appToolbar = [[CPToolbar alloc] initWithIdentifier:@"mainToolbar"];
[_appToolbar setDelegate:self];
[_appToolbar setVisible:YES];
[_theWindow setToolbar:_appToolbar];
}
}
// <-- Toolbar Delegates
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)toolbar
{
return [CPToolbarFlexibleSpaceItemIdentifier, AirplaneTicketsTII, VisasTII, PassportsTII, PackagesTII, MoneyTII, InvitationsTII, RentsTII, CPToolbarFlexibleSpaceItemIdentifier, GlobalSearchTII ];
}
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)toolbar
{
return [CPToolbarFlexibleSpaceItemIdentifier, AirplaneTicketsTII, VisasTII, PassportsTII, PackagesTII, MoneyTII, InvitationsTII, RentsTII, CPToolbarFlexibleSpaceItemIdentifier, GlobalSearchTII ];
}
- (CPToolbarItem)toolbar:(CPToolbar)toolbar itemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
var toolbarItem = [[CPToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
var mainBundle = [CPBundle mainBundle];
if (itemIdentifier == AirplaneTicketsTII)
{
var image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"airplane.png"] size:CPSizeMake(30, 25)];
var highlighted = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"airplane.png"] size:CPSizeMake(30, 25)];
[toolbarItem setAction:@selector(tickets:)];
[toolbarItem setLabel:"Pasajes"];
}
else if (itemIdentifier == VisasTII)
{
var image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"visa.png"] size:CPSizeMake(30, 25)];
var highlighted = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"visa.png"] size:CPSizeMake(30, 25)];
[toolbarItem setAction:@selector(visas:)];
[toolbarItem setLabel:"Visas"];
}
else if (itemIdentifier == PassportsTII)
{
var image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"passport.png"] size:CPSizeMake(30, 25)];
var highlighted = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"passport.png"] size:CPSizeMake(30, 25)];
[toolbarItem setAction:@selector(passports:)];
[toolbarItem setLabel:"Pasaportes"];
}
else if (itemIdentifier == PackagesTII)
{
var image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"package.png"] size:CPSizeMake(30, 25)];
var highlighted = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"package.png"] size:CPSizeMake(30, 25)];
[toolbarItem setAction:@selector(packages:)];
[toolbarItem setLabel:"Paquetes"];
}
else if (itemIdentifier == MoneyTII)
{
var image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"money.png"] size:CPSizeMake(30, 25)];
var highlighted = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"money.png"] size:CPSizeMake(30, 25)];
[toolbarItem setAction:@selector(money:)];
[toolbarItem setLabel:"Remesas"];
}
else if (itemIdentifier == InvitationsTII)
{
var image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"invitation.png"] size:CPSizeMake(30, 25)];
var highlighted = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"invitation.png"] size:CPSizeMake(30, 25)];
[toolbarItem setAction:@selector(invitations:)];
[toolbarItem setLabel:"Invitaciones"];
}
else if (itemIdentifier == RentsTII)
{
var image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"car_rental.png"] size:CPSizeMake(30, 25)];
var highlighted = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"car_rental.png"] size:CPSizeMake(30, 25)];
[toolbarItem setAction:@selector(rents:)];
[toolbarItem setLabel:"Rentas"];
}
else if (itemIdentifier == GlobalSearchTII)
{
var searchField = [[CPSearchField alloc] initWithFrame:CGRectMake(0,0,200,32)];
[toolbarItem setView:searchField];
[toolbarItem setAction:@selector(globalSearch:)];
[toolbarItem setLabel:"Busqueda Global"];
[toolbarItem setMinSize:CGSizeMake(200, 32)];
[toolbarItem setMaxSize:CGSizeMake(200, 32)];
}
[toolbarItem setImage:image];
[toolbarItem setAlternateImage:highlighted];
[toolbarItem setTarget:self];
if (itemIdentifier != GlobalSearchTII)
{
[toolbarItem setMinSize:CGSizeMake(32, 32)];
[toolbarItem setMaxSize:CGSizeMake(32, 32)];
}
return toolbarItem;
}
// --> Toolbar Delegates
// <-- Toolbar Button Messages
- (void)tickets:(id)sender
{
var p = [[CPPopover alloc] init],
viewC = [[CPViewController alloc] init];
view = [[CPView alloc] initWithFrame:CPRectMake(0.0, 0.0, 320, 300)];
// label = [CPTextField labelWithTitle:[buttonGravity title]];
//[label setFont:[CPFont boldSystemFontOfSize:30.0]];
//[label setFrameOrigin:CPPointMake(0, 70)];
//[label setValue:(a == CPPopoverAppearanceHUD) ? [CPColor colorWithHexString:@"333"] : [CPColor colorWithHexString:@"fff"] forThemeAttribute:@"text-shadow-color"];
//[label setValue:CGSizeMake(0.0, 1.0) forThemeAttribute:@"text-shadow-offset"];
//[label setTextColor:(a == CPPopoverAppearanceHUD) ? [CPColor whiteColor] : [CPColor colorWithHexString:@"444"]];
//[label setFrameSize:CPSizeMake([view frame].size.width, 50)];
//[label setAlignment:CPCenterTextAlignment];
//[view addSubview:label];
[viewC setView:view];
[p setContentViewController:viewC];
[p setAnimates:@"With animation"];
[p setBehaviour:CPPopoverBehaviorTransient];
[p setAppearance:CPPopoverAppearanceHUD];
[p setDelegate:self];
[p showRelativeToRect:nil ofView:[sender view] preferredEdge:nil];
}
// --> Toolbar Button Messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment