From 50d74972867412e76d403d3e67943c8675f3792b Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Fri, 31 May 2013 08:59:18 +0200 Subject: [PATCH 01/14] Fixed: Corrected import paths As Objective-J now enforces correct import paths I added imports for needed AppKit/FoundationKit imports and also fixed in-framework imports. E.g: @import became @import "LPViewAnimation.j" --- LPAnchorButton.j | 54 +++++++++-------- LPCalendarHeaderView.j | 53 +++++++++-------- LPCalendarView.j | 22 +++---- LPCrashReporter.j | 66 ++++++++++----------- LPKit.j | 36 +++++------ LPSlideView.j | 52 ++++++++-------- LPSwitch.j | 78 ++++++++++++------------ LPViewAnimation.j | 131 +++++++++++++++++++++-------------------- 8 files changed, 248 insertions(+), 244 deletions(-) diff --git a/LPAnchorButton.j b/LPAnchorButton.j index 28459f3..7eff3fd 100644 --- a/LPAnchorButton.j +++ b/LPAnchorButton.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on November 9, 2009. - * + * * The MIT License - * + * * Copyright (c) 2009 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,9 +25,11 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ +@import + LPAnchorButtonNoUnderline = 0; LPAnchorButtonNormalUnderline = 1; LPAnchorButtonHoverUnderline = 2; @@ -36,7 +38,7 @@ LPAnchorButtonHoverUnderline = 2; @implementation LPAnchorButton : CPControl { unsigned _underlineMask @accessors(property=underlineMask); - + CPString _title @accessors(property=title); CPURL _URL; id _DOMAnchorElement; @@ -67,9 +69,9 @@ LPAnchorButtonHoverUnderline = 2; } - (void)openURLOnClick:(CPURL)aURL -{ +{ _URL = aURL; - + [self setNeedsLayout]; } @@ -112,7 +114,7 @@ LPAnchorButtonHoverUnderline = 2; { return [self bounds]; } - + - (CPView)createEphemeralSubviewNamed:(CPString)aName { return [[_CPImageAndTextView alloc] initWithFrame:CGRectMakeZero()]; @@ -132,32 +134,32 @@ LPAnchorButtonHoverUnderline = 2; self._DOMElement.appendChild(_DOMAnchorElement) } - + _DOMAnchorElement.href = typeof _URL == 'string' ? _URL : [_URL absoluteString]; - + var bounds = [self bounds]; - + _DOMAnchorElement.style.width = CGRectGetWidth(bounds) + @"px"; _DOMAnchorElement.style.height = CGRectGetHeight(bounds) + @"px"; } - + var cssTextDecoration = @"none"; - + // Check if we should underline if (((_themeState === CPThemeStateNormal || _themeState === CPThemeStateSelected) && (_underlineMask & LPAnchorButtonNormalUnderline)) || ((_themeState & CPThemeStateHighlighted) && (_underlineMask & LPAnchorButtonHoverUnderline))) { cssTextDecoration = @"underline"; } - + var contentView = [self layoutEphemeralSubviewNamed:@"content-view" positioned:CPWindowAbove relativeToEphemeralSubviewNamed:nil]; - + if (contentView) { [contentView setText:_title]; - + [contentView setTextColor:[self currentValueForThemeAttribute:@"text-color"]]; [contentView setFont:[self currentValueForThemeAttribute:@"font"]]; [contentView setAlignment:[self currentValueForThemeAttribute:@"alignment"]]; @@ -165,10 +167,10 @@ LPAnchorButtonHoverUnderline = 2; [contentView setLineBreakMode:[self currentValueForThemeAttribute:@"line-break-mode"]]; [contentView setTextShadowColor:[self currentValueForThemeAttribute:@"text-shadow-color"]]; [contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]]; - + if (contentView._DOMTextElement) contentView._DOMTextElement.style.setProperty(@"text-decoration", cssTextDecoration, null); - + if (contentView._DOMTextShadowElement) contentView._DOMTextShadowElement.style.setProperty(@"text-decoration", cssTextDecoration, null); } @@ -180,23 +182,23 @@ LPAnchorButtonHoverUnderline = 2; var LPAnchorButtonUnderlineMaskKey = @"LPAnchorButtonUnderlineMaskKey"; @implementation LPAnchorButton (CPCoding) - + - (id)initWithCoder:(CPCoder)aCoder { if (self = [super initWithCoder:aCoder]) { _underlineMask = [aCoder decodeIntForKey:LPAnchorButtonUnderlineMaskKey] || LPAnchorButtonNoUnderline; } - + return self; } - + - (void)encodeWithCoder:(CPCoder)aCoder { [super encodeWithCoder:aCoder]; - + if (_underlineMask !== LPAnchorButtonNoUnderline) [aCoder encodeInt:_underlineMask forKey:LPAnchorButtonUnderlineMaskKey]; } - -@end \ No newline at end of file + +@end diff --git a/LPCalendarHeaderView.j b/LPCalendarHeaderView.j index 465d4a2..989eea3 100644 --- a/LPCalendarHeaderView.j +++ b/LPCalendarHeaderView.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on September 21, 2009. - * + * * The MIT License - * + * * Copyright (c) 2009 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,10 +25,11 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ @import @import +@import var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June", @"July", @"August", @"September", @"October", @"November", @"December"], LPDayNamesShort = [@"mon", @"tue", @"wed", @"thu", @"fri", @"sat", @"sun"], @@ -38,12 +39,12 @@ var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June" @implementation LPCalendarHeaderView : CPControl { CPDate representedDate; - + CPTextField monthLabel; id prevButton @accessors(readonly); id nextButton @accessors(readonly); CPArray dayLabels; - + BOOL weekStartsOnMonday @accessors; } @@ -59,25 +60,25 @@ var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June" monthLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; [monthLabel setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin]; [self addSubview:monthLabel]; - + prevButton = [[LPCalendarHeaderArrowButton alloc] initWithFrame:CGRectMake(6, 9, 0, 0)]; [prevButton sizeToFit]; [self addSubview:prevButton]; - + nextButton = [[LPCalendarHeaderArrowButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX([self bounds]) - 21, 9, 0, 0)]; [nextButton sizeToFit]; [nextButton setAutoresizingMask:CPViewMinXMargin]; [self addSubview:nextButton]; - + dayLabels = [CPArray array]; - + for (var i = 0; i < [LPDayNamesShort count]; i++) { var label = [LPCalendarLabel labelWithTitle:[LPDayNamesShort objectAtIndex:i]]; [dayLabels addObject:label]; [self addSubview:label]; } - + [self setBackgroundColor:[CPColor lightGrayColor]]; } return self; @@ -87,9 +88,9 @@ var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June" { if ([representedDate isEqualToDate:aDate]) return; - + representedDate = [aDate copy]; - + [monthLabel setStringValue:[CPString stringWithFormat:@"%s %i", LPMonthNames[representedDate.getUTCMonth()], representedDate.getUTCFullYear()]]; [monthLabel sizeToFit]; [monthLabel setCenter:CGPointMake(CGRectGetMidX([self bounds]), 16)]; @@ -98,9 +99,9 @@ var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June" - (void)setWeekStartsOnMonday:(BOOL)shouldWeekStartOnMonday { weekStartsOnMonday = shouldWeekStartOnMonday; - + var dayNames = (shouldWeekStartOnMonday) ? LPDayNamesShort : LPDayNamesShortUS; - + for (var i = 0; i < [dayLabels count]; i++) [[dayLabels objectAtIndex:i] setTitle:[dayNames objectAtIndex:i]]; @@ -113,21 +114,21 @@ var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June" width = CGRectGetWidth(bounds), superview = [self superview], themeState = [self themeState]; - + // Title [self setBackgroundColor:[superview valueForThemeAttribute:@"header-background-color" inState:themeState]]; [monthLabel setFont:[superview valueForThemeAttribute:@"header-font" inState:themeState]]; [monthLabel setTextColor:[superview valueForThemeAttribute:@"header-text-color" inState:themeState]]; [monthLabel setTextShadowColor:[superview valueForThemeAttribute:@"header-text-shadow-color" inState:themeState]]; [monthLabel setTextShadowOffset:[superview valueForThemeAttribute:@"header-text-shadow-offset" inState:themeState]]; - + // Arrows var buttonOrigin = [superview valueForThemeAttribute:@"header-button-offset" inState:themeState]; [prevButton setFrameOrigin:CGPointMake(buttonOrigin.width, buttonOrigin.height)]; [prevButton setValue:[superview valueForThemeAttribute:@"header-prev-button-image" inState:themeState] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered]; [nextButton setFrameOrigin:CGPointMake(width - 16 - buttonOrigin.width, buttonOrigin.height)]; [nextButton setValue:[superview valueForThemeAttribute:@"header-next-button-image" inState:themeState] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered]; - + // Weekday labels var numberOfLabels = [dayLabels count], labelWidth = width / numberOfLabels, @@ -176,19 +177,19 @@ var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June" { var calendarView = [[self superview] superview], themeState = [self themeState]; - + [self setFont:[calendarView valueForThemeAttribute:@"header-weekday-label-font" inState:themeState]]; [self setTextColor:[calendarView valueForThemeAttribute:@"header-weekday-label-color" inState:themeState]]; [self setTextShadowColor:[calendarView valueForThemeAttribute:@"header-weekday-label-shadow-color" inState:themeState]]; [self setTextShadowOffset:[calendarView valueForThemeAttribute:@"header-weekday-label-shadow-offset" inState:themeState]]; - + [super layoutSubviews]; } @end -@implementation LPCalendarHeaderArrowButton : CPButton +@implementation LPCalendarHeaderArrowButton : CPButton { } @@ -216,13 +217,13 @@ var LPMonthNames = [@"January", @"February", @"March", @"April", @"May", @"June" - (void)trackMouse:(CPEvent)anEvent { var type = [anEvent type]; - + if (type === CPLeftMouseDown) [self incrementOriginBy:1] else if (type === CPLeftMouseUp) [self incrementOriginBy:-1] - + [super trackMouse:anEvent]; } -@end \ No newline at end of file +@end diff --git a/LPCalendarView.j b/LPCalendarView.j index f322a6b..9e6e0cc 100644 --- a/LPCalendarView.j +++ b/LPCalendarView.j @@ -28,16 +28,16 @@ * */ @import -@import -@import -@import +@import "LPCalendarHeaderView.j" +@import "LPCalendarMonthView.j" +@import "LPSlideView.j" @implementation LPCalendarView : CPView { LPCalendarHeaderView headerView @accessors(readonly); LPSlideView slideView; - + LPCalendarMonthView currentMonthView; LPCalendarMonthView firstMonthView; LPCalendarMonthView secondMonthView; @@ -150,7 +150,7 @@ // new current view currentMonthView = slideToView; - + // Display it way off, // because cappuccino wont draw // CGGraphics stuff unless it's visible @@ -196,10 +196,10 @@ { var width = CGRectGetWidth([self bounds]), headerHeight = [self currentValueForThemeAttribute:@"header-height"]; - + [headerView setFrameSize:CGSizeMake(width, headerHeight)]; [slideView setFrame:CGRectMake(0, headerHeight, width, CGRectGetHeight([self bounds]) - headerHeight)]; - + [slideView setBackgroundColor:[self currentValueForThemeAttribute:@"background-color"]]; } @@ -208,7 +208,7 @@ // We can only slide one month in at a time. if ([slideView isSliding]) return; - + [self changeToMonth:[currentMonthView previousMonth]]; } @@ -217,7 +217,7 @@ // We can only slide one month in at a time. if ([slideView isSliding]) return; - + [self changeToMonth:[currentMonthView nextMonth]]; } @@ -231,11 +231,11 @@ // Make sure we have an end to the selection if ([aSelection count] <= 1) [aSelection addObject:nil]; - + // The selection didn't change if ([fullSelection isEqualToArray:aSelection]) return; - + // Copy the selection fullSelection = [CPArray arrayWithArray:aSelection]; diff --git a/LPCrashReporter.j b/LPCrashReporter.j index 9883a9d..52b42d4 100644 --- a/LPCrashReporter.j +++ b/LPCrashReporter.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on February 19, 2010. - * + * * The MIT License - * + * * Copyright (c) 2010 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,13 +25,13 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ - + @import @import -@import -@import +@import "LPURLPostRequest.j" +@import "LPMultiLineTextField.j" var sharedErrorLoggerInstance = nil; @@ -45,7 +45,7 @@ var sharedErrorLoggerInstance = nil; { if (!sharedErrorLoggerInstance) sharedErrorLoggerInstance = [[LPCrashReporter alloc] init]; - + return sharedErrorLoggerInstance; } @@ -55,13 +55,13 @@ var sharedErrorLoggerInstance = nil; { if (_exception) return; - + _exception = anException; - + var overlayWindow = [[LPCrashReporterOverlayWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask]; [overlayWindow setLevel:CPNormalWindowLevel]; [overlayWindow makeKeyAndOrderFront:nil]; - + var alert = [[CPAlert alloc] init]; [alert setDelegate:self]; [alert setAlertStyle:CPCriticalAlertStyle]; @@ -88,13 +88,13 @@ var sharedErrorLoggerInstance = nil; */ - (void)alertDidEnd:(CPAlert)anAlert returnCode:(id)returnCode -{ +{ switch(returnCode) { case 0: // Reload application location.reload(); break; - + case 1: // Send report var reportWindow = [[LPCrashReporterReportWindow alloc] initWithContentRect:CGRectMake(0,0,460,309) styleMask:CPTitledWindowMask | CPResizableWindowMask]; [CPApp runModalForWindow:reportWindow]; @@ -107,7 +107,7 @@ var sharedErrorLoggerInstance = nil; @implementation LPCrashReporterOverlayWindow : CPWindow { - + } - (void)initWithContentRect:(CGRect)aContentRect styleMask:(id)aStyleMask @@ -126,13 +126,13 @@ var sharedErrorLoggerInstance = nil; { CPTextField informationLabel; LPMultiLineTextField informationTextField; - + CPTextField descriptionLabel; LPMultiLineTextField descriptionTextField; - + CPButton sendButton; CPButton cancelButton; - + CPTextField sendingLabel; } @@ -142,14 +142,14 @@ var sharedErrorLoggerInstance = nil; { var contentView = [self contentView], applicationName = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPBundleName"]; - + [self setMinSize:aContentRect.size]; [self setTitle:[CPString stringWithFormat:@"Problem Report for %@", applicationName]]; - + informationLabel = [CPTextField labelWithTitle:@"Problem and system information:"]; [informationLabel setFrameOrigin:CGPointMake(12,12)]; [contentView addSubview:informationLabel]; - + var informationTextValue = [CPString stringWithFormat:@"User-Agent: %@\n\nException: %@", navigator.userAgent, [[LPCrashReporter sharedErrorLogger] exception]]; informationTextField = [LPMultiLineTextField textFieldWithStringValue:informationTextValue placeholder:@"" width:0]; @@ -157,16 +157,16 @@ var sharedErrorLoggerInstance = nil; [informationTextField setFrame:CGRectMake(12, 31, CGRectGetWidth(aContentRect) - 24, 100)]; [informationTextField setAutoresizingMask:CPViewWidthSizable]; [contentView addSubview:informationTextField]; - + descriptionLabel = [CPTextField labelWithTitle:@"Please describe what you were doing when the problem happened:"]; [descriptionLabel setFrameOrigin:CGPointMake(12,141)]; [contentView addSubview:descriptionLabel]; - + descriptionTextField = [LPMultiLineTextField textFieldWithStringValue:@"" placeholder:@"" width:0]; [descriptionTextField setFrame:CGRectMake(CGRectGetMinX([informationTextField frame]), CGRectGetMaxY([descriptionLabel frame]) + 1, CGRectGetWidth([informationTextField frame]), 100)]; [descriptionTextField setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; [contentView addSubview:descriptionTextField]; - + sendButton = [CPButton buttonWithTitle:[CPString stringWithFormat:@"Send to %@", applicationName]]; [sendButton setFrameOrigin:CGPointMake(CGRectGetWidth(aContentRect) - CGRectGetWidth([sendButton frame]) - 15, 270)]; [sendButton setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; @@ -174,21 +174,21 @@ var sharedErrorLoggerInstance = nil; [sendButton setAction:@selector(didClickSendButton:)]; [contentView addSubview:sendButton]; [self setDefaultButton:sendButton]; - + cancelButton = [CPButton buttonWithTitle:@"Cancel"]; [cancelButton setFrameOrigin:CGPointMake(CGRectGetMinX([sendButton frame]) - CGRectGetWidth([cancelButton frame]) - 12, CGRectGetMinY([sendButton frame]))]; [cancelButton setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; [cancelButton setTarget:self]; [cancelButton setAction:@selector(didClickCancelButton:)]; [contentView addSubview:cancelButton]; - + sendingLabel = [CPTextField labelWithTitle:@"Sending Report..."]; [sendingLabel setFont:[CPFont boldSystemFontOfSize:11]]; [sendingLabel sizeToFit]; [sendingLabel setFrameOrigin:CGPointMake(12, CGRectGetMaxY(aContentRect) - 35)]; [sendingLabel setHidden:YES]; [contentView addSubview:sendingLabel]; - + } return self; } @@ -207,9 +207,9 @@ var sharedErrorLoggerInstance = nil; [cancelButton setEnabled:NO]; [informationLabel setAlphaValue:0.5]; [descriptionLabel setAlphaValue:0.5]; - + [sendingLabel setHidden:NO]; - + var loggingURL = [CPURL URLWithString:[[CPBundle mainBundle] objectForInfoDictionaryKey:@"LPCrashReporterLoggingURL"] || @"/"], request = [LPURLPostRequest requestWithURL:loggingURL], exception = [[LPCrashReporter sharedErrorLogger] exception], @@ -235,7 +235,7 @@ var sharedErrorLoggerInstance = nil; { [CPApp stopModal]; [self orderOut:nil]; - + var alert = [[CPAlert alloc] init]; [alert setDelegate:[LPCrashReporter sharedErrorLogger]]; [alert setAlertStyle:CPInformationalAlertStyle]; @@ -257,7 +257,7 @@ objj_msgSend = function() { if (!shouldCatchExceptions) return original_objj_msgSend.apply(this, arguments); - + try { return original_objj_msgSend.apply(this, arguments); @@ -267,4 +267,4 @@ objj_msgSend = function() [[LPCrashReporter sharedErrorLogger] didCatchException:anException]; return nil; } -} \ No newline at end of file +} diff --git a/LPKit.j b/LPKit.j index 30afd27..873bfca 100644 --- a/LPKit.j +++ b/LPKit.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on November 7, 2009. - * + * * The MIT License - * + * * Copyright (c) 2009 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,18 +25,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ -@import -@import -@import -@import -@import -@import -@import -@import -@import -@import -@import -@import \ No newline at end of file +@import "LPAnchorButton.j" +@import "LPCalendarView.j" +@import "LPChartView.j" +@import "LPCookieController.j" +@import "LPEmail.j" +@import "LPLocationController.j" +@import "LPPieChartView.j" +@import "LPSlideView.j" +@import "LPSparkLine.j" +@import "LPSwitch.j" +@import "LPURLPostRequest.j" +@import "LPViewAnimation.j" diff --git a/LPSlideView.j b/LPSlideView.j index 9fb8d47..6a2be6a 100644 --- a/LPSlideView.j +++ b/LPSlideView.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on August 23, 2009. - * + * * The MIT License - * + * * Copyright (c) 2009 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,11 +25,11 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ @import -@import +@import "LPViewAnimation.j" LPSlideViewHorizontalDirection = 0; LPSlideViewVerticalDirection = 1; @@ -42,11 +42,11 @@ LPSlideViewNegativeDirection = 4; int slideDirection @accessors; id currentView @accessors; id previousView @accessors; - + float animationDuration @accessors; id animationCurve @accessors; BOOL isSliding @accessors(readonly); - + id _delegate @accessors(property=delegate); } @@ -68,7 +68,7 @@ LPSlideViewNegativeDirection = 4; currentView = aView; else [aView setHidden:YES]; - + [aView setFrame:[self bounds]]; [aView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; [super addSubview:aView]; @@ -88,42 +88,42 @@ LPSlideViewNegativeDirection = 4; { if (aView == currentView || isSliding) return; - + isSliding = YES; - + if(_delegate && [_delegate respondsToSelector:@selector(slideView:willMoveToView:)]) [_delegate slideView:self willMoveToView:aView]; - + var viewIndex = [[self subviews] indexOfObject:aView], currentViewIndex = [[self subviews] indexOfObject:currentView], size = [self frame].size; - + // Unhide the view [aView setHidden:NO]; - + var showViewStart = CGPointMake(0,0), hideViewEnd = CGPointMake(0,0); - + // Horizontal sliding if (slideDirection == LPSlideViewHorizontalDirection) { var showSlideFromX, hideSlideToX; - + // Showing a view to the left if ((aDirection && aDirection == LPSlideViewNegativeDirection) || (!aDirection && viewIndex < currentViewIndex)) { showSlideFromX = -size.width; hideSlideToX = size.width; } - + // Showing a view to the right if ((aDirection && aDirection == LPSlideViewPositiveDirection) || (!aDirection && viewIndex > currentViewIndex)) { showSlideFromX = size.width; hideSlideToX = -size.width; } - + showViewStart.x = showSlideFromX; hideViewEnd.x = hideSlideToX; } @@ -133,24 +133,24 @@ LPSlideViewNegativeDirection = 4; { var showSlideFromY, hideSlideToY; - + // Showing a view from the top if ((aDirection && aDirection == LPSlideViewNegativeDirection) || (!aDirection && viewIndex > currentViewIndex)) { showSlideFromY = size.height; hideSlideToY = -size.height; } - + // Showing a view from the bottom if ((aDirection && aDirection == LPSlideViewPositiveDirection) || (!aDirection && viewIndex < currentViewIndex)) { showSlideFromY = -size.height; hideSlideToY = size.height; } - + showViewStart.y = showSlideFromY; hideViewEnd.y = hideSlideToY; - + // We've got a forced start progress if (aProgress) { @@ -158,7 +158,7 @@ LPSlideViewNegativeDirection = 4; hideViewEnd.y -= (aProgress * hideViewEnd.y) } } - + var animation = [[LPViewAnimation alloc] initWithViewAnimations:[ { @"target": aView, @@ -177,7 +177,7 @@ LPSlideViewNegativeDirection = 4; [animation setDuration:animationDuration]; [animation setDelegate:self]; [animation startAnimation]; - + previousView = currentView; currentView = aView; } @@ -201,4 +201,4 @@ LPSlideViewNegativeDirection = 4; [self animationDidEnd]; } -@end \ No newline at end of file +@end diff --git a/LPSwitch.j b/LPSwitch.j index 8313223..8a99b92 100644 --- a/LPSwitch.j +++ b/LPSwitch.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on November 7, 2009. - * + * * The MIT License - * + * * Copyright (c) 2009 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,33 +25,33 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ @import -@import +@import "LPViewAnimation.j" @implementation LPSwitch : CPControl { BOOL on @accessors(readonly, getter=isOn); - + CGPoint dragStartPoint; - + LPSwitchKnob knob; CGPoint knobDragStartPoint; - + BOOL isDragging; - + float animationDuration; id animationCurve; - + CPView offBackgroundView; CPView onBackgroundView; - + CPTextField offLabel; CPTextField onLabel; - + LPViewAnimation animation; } @@ -71,32 +71,32 @@ - (id)initWithFrame:(CGRect)aFrame { if (self = [super initWithFrame:aFrame]) - { + { offBackgroundView = [[CPView alloc] initWithFrame:[self bounds]]; [offBackgroundView setHitTests:NO]; [self addSubview:offBackgroundView]; - + onBackgroundView = [[CPView alloc] initWithFrame:CGRectMake(0,0,0,CGRectGetHeight([self bounds]))]; [onBackgroundView setHitTests:NO]; [self addSubview:onBackgroundView]; - + knob = [[LPSwitchKnob alloc] initWithFrame:CGRectMakeZero()]; [self addSubview:knob]; - + offLabel = [CPTextField labelWithTitle:@"Off"]; [self addSubview:offLabel]; - + onLabel = [CPTextField labelWithTitle:@"On"]; [self addSubview:onLabel]; - + animationDuration = 0.2; animationCurve = CPAnimationEaseOut; - + // Need to call layoutSubviews directly to make sure // all theme attributes are set. // TODO: FIX THIS. [self layoutSubviews]; - + [self setNeedsLayout]; } return self; @@ -117,7 +117,7 @@ } else on = shouldSetOn; - + var knobMinY = CGRectGetMinY([knob frame]), knobEndFrame = CGRectMake((on) ? [knob maxX] : [knob minX], knobMinY, CGRectGetWidth([knob frame]), CGRectGetHeight([knob frame])), onBackgroundEndFrame = CGRectMake(0,0, CGRectGetMinX(knobEndFrame) + CGRectGetMidX([knob bounds]), CGRectGetHeight([onBackgroundView bounds])), @@ -126,12 +126,12 @@ CGRectGetWidth([offLabel bounds]), CGRectGetHeight([offLabel bounds])), onLabelEndFrame = CGRectMake(CGRectGetMinX(knobEndFrame) - labelOffset.width - CGRectGetWidth([onLabel bounds]), labelOffset.height, CGRectGetWidth([onLabel bounds]), CGRectGetHeight([onLabel bounds])); - + // added to counter a problem whereby changing the state more than once (i.e., ON -> OFF -> ON) before giving control to the run loop, // caused the control to not update properly if([animation isAnimating]) [animation stopAnimation]; - + if (shouldAnimate) { animation = [[LPViewAnimation alloc] initWithViewAnimations:[ @@ -180,16 +180,16 @@ dragStartPoint = [self convertPoint:[anEvent locationInWindow] fromView:nil]; knobDragStartPoint = [knob frame].origin; - + isDragging = NO; - + // If the drag started on top of the knob, we highlight it var startPointX = [knob convertPoint:dragStartPoint fromView:self].x; if (startPointX > 0 && startPointX < CGRectGetWidth([knob bounds])) { [knob setHighlighted:YES]; [self setNeedsLayout]; - } + } } - (void)mouseDragged:(CPEvent)anEvent @@ -199,25 +199,25 @@ // We are dragging isDragging = YES; - + var point = [self convertPoint:[anEvent locationInWindow] fromView:nil], knobX = knobDragStartPoint.x + (point.x - dragStartPoint.x), knobMinX = [knob minX], knobMaxX = [knob maxX], height = CGRectGetHeight([self bounds]); - + // Limit X if (knobX < knobMinX) knobX = knobMinX; else if(knobX > knobMaxX) knobX = knobMaxX; - + // Resize background views [onBackgroundView setFrameSize:CGSizeMake(knobX + CGRectGetMidX([knob bounds]), height)]; - + // Re-position knob [knob setFrameOrigin:CGPointMake(knobX, CGRectGetMinY([knob frame]))]; - + [self setNeedsLayout]; } @@ -227,7 +227,7 @@ return; [self setOn:isDragging ? CGRectGetMidX([self bounds]) < CGRectGetMidX([knob frame]) : !on animated:YES]; - + [knob setHighlighted:NO]; [self setNeedsLayout]; } @@ -245,22 +245,22 @@ [onBackgroundView setBackgroundColor:[self currentValueForThemeAttribute:@"on-background-color"]]; [knob setBackgroundColor:[self valueForThemeAttribute:@"knob-background-color" inState:[knob themeState]]]; [knob setFrameSize:[self currentValueForThemeAttribute:@"knob-size"]]; - + var labelOffset = [self labelOffset]; - + [offLabel setFont:[self currentValueForThemeAttribute:@"off-label-font"]]; [offLabel setTextColor:[self currentValueForThemeAttribute:@"off-label-text-color"]]; [offLabel setTextShadowColor:[self currentValueForThemeAttribute:@"off-label-text-shadow-color"]]; [offLabel setTextShadowOffset:[self currentValueForThemeAttribute:@"off-label-text-shadow-offset"]]; [offLabel setFrameOrigin:CGPointMake(CGRectGetMaxX([knob frame]) + labelOffset.width, labelOffset.height)]; [offLabel sizeToFit]; - + [onLabel setFont:[self currentValueForThemeAttribute:@"on-label-font"]]; [onLabel setTextColor:[self currentValueForThemeAttribute:@"on-label-text-color"]]; [onLabel setTextShadowColor:[self currentValueForThemeAttribute:@"on-label-text-shadow-color"]]; [onLabel setTextShadowOffset:[self currentValueForThemeAttribute:@"on-label-text-shadow-offset"]]; [onLabel sizeToFit]; - + [onLabel setFrameOrigin:CGPointMake(CGRectGetMinX([knob frame]) - labelOffset.width - CGRectGetWidth([onLabel bounds]), CGRectGetMinY([offLabel frame]))]; } @@ -301,4 +301,4 @@ return CGRectGetWidth([[self superview] bounds]) - CGRectGetWidth([self bounds]); } -@end \ No newline at end of file +@end diff --git a/LPViewAnimation.j b/LPViewAnimation.j index aaad75f..738b017 100644 --- a/LPViewAnimation.j +++ b/LPViewAnimation.j @@ -2,21 +2,21 @@ * LPViewAnimation.j * * Created by Ludwig Pettersson on April 3, 2010. - * + * * The MIT License - * + * * Copyright (c) 2010 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -24,10 +24,11 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ @import +@import LPCSSAnimationsAreAvailable = NO; @@ -43,21 +44,21 @@ LPTestCSSFeature = function(/*CPString*/aFeature) { if (typeof document === "undefined") return NO; - + if (!_tmpDOMElement) _tmpDOMElement = document.createElement("div"); - + var properties = [aFeature]; - + for (var i = 0; i < _browserPrefixes.length; i++) properties.push(_browserPrefixes[i] + aFeature); - + for (var i = 0; i < properties.length; i++) { if (typeof _tmpDOMElement.style[properties[i]] !== "undefined") return YES; } - + return NO; } @@ -76,12 +77,12 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, @implementation LPViewAnimation : CPAnimation { BOOL _isAnimating; - + CPArray _viewAnimations @accessors(property=viewAnimations); id _animationDidEndTimeout; - + BOOL _shouldUseCSSAnimations @accessors(property=shouldUseCSSAnimations); - + // Curve CPArray _c1; CPArray _c2; @@ -92,7 +93,7 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, if (self = [self initWithDuration:1.0 animationCurve:CPAnimationLinear]) { _isAnimating = NO; - + _viewAnimations = viewAnimations; _shouldUseCSSAnimations = NO; } @@ -102,10 +103,10 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, - (void)setAnimationCurve:(id)anAnimationCurve { [super setAnimationCurve:anAnimationCurve]; - + _c1 = []; _c2 = []; - + [_timingFunction getControlPointAtIndex:1 values:_c1]; [_timingFunction getControlPointAtIndex:2 values:_c2]; } @@ -116,19 +117,19 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, { if (_isAnimating) return; - + _isAnimating = YES; - + var i = _viewAnimations.length; while (i--) { var viewAnimation = _viewAnimations[i], target = viewAnimation[@"target"]; - + // Prepare target with general animation stuff. [self target:target setCSSAnimationDuration:_duration]; [self target:target setCSSAnimationCurve:_animationCurve]; - + var x = viewAnimation[@"animations"].length; while (x--) { @@ -136,51 +137,51 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, kind = animation[0], start = animation[1], end = animation[2]; - + if (kind === LPFadeAnimationKey) { [target setAlphaValue:start]; - + // Prepare target for this specific animation. [self target:target addCSSAnimationPropertyForKey:kind append:x !== 0]; - + // Needs to be wrapped. setTimeout(function(_target, _end){ _target._DOMElement.style["-webkit-transform"] = "translate3d(0px, 0px, 0px)"; [_target setAlphaValue:_end]; }, 0, target, end); - + } else if(kind === LPOriginAnimationKey) { if (!CGPointEqualToPoint(start, end)) { [target setFrameOrigin:start]; - + // Prepare target for this specific animation. [self target:target addCSSAnimationPropertyForKey:kind append:x !== 0]; - + // Need to call it later for the animation to work. setTimeout(function(_target, _start, _end){ - + var x = _end.x - _start.x, y = _end.y - _start.y; - + _target._DOMElement.style["-webkit-transform"] = "translate3d(" + x +"px, " + y + "px, 0px)"; - - // Need to match the new position with the actual frame + + // Need to match the new position with the actual frame setTimeout(function(){ - + // Make sure we got rid of the animation specific css [self _clearCSS]; - + // Reset the translate _target._DOMElement.style["-webkit-transform"] = "translate3d(0px, 0px, 0px)"; - + // Set the real frame [_target setFrameOrigin:_end]; }, (1000 * _duration) + 100); - + }, 0, target, start, end); } } @@ -190,23 +191,23 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, } } } - + if (_animationDidEndTimeout) clearTimeout(_animationDidEndTimeout); - + _animationDidEndTimeout = setTimeout(function(animation){ _isAnimating = NO; - + // Clear CSS [animation _clearCSS]; - + if ([_delegate respondsToSelector:@selector(animationDidEnd:)]) [_delegate animationDidEnd:animation]; - + // We delay it by 100 extra mseconds to make sure that all css animations have finished, // it's not always *exactly* 1000 * duration. }, (1000 * _duration) + 100, self); - + } else { @@ -216,7 +217,7 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, { var viewAnimation = _viewAnimations[i], target = viewAnimation[@"target"]; - + var x = viewAnimation[@"animations"].length; while (x--) { @@ -224,21 +225,21 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, kind = animation[0], start = animation[1], end = animation[2]; - + switch (kind) { case LPFadeAnimationKey: [target setAlphaValue:start]; break; - + case LPOriginAnimationKey: [target setFrameOrigin:start]; break; - + case LPFrameAnimationKey: [target setFrame:start]; break; } } } - + [super startAnimation]; } } @@ -250,32 +251,32 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, - (void)setCurrentProgress:(float)aProgress { _progress = aProgress; - + var value = CubicBezierAtTime(_progress, _c1[0], _c1[1], _c2[0], _c2[1], _duration), i = _viewAnimations.length; - + while (i--) { var viewAnimation = _viewAnimations[i], target = viewAnimation["target"], x = viewAnimation["animations"].length; - + while (x--) { var animation = viewAnimation["animations"][x], kind = animation[0], start = animation[1], end = animation[2]; - + switch (kind) { case LPFadeAnimationKey: [target setAlphaValue:(value * (end - start)) + start]; break; - + case LPOriginAnimationKey: [target setFrameOrigin:CGPointMake(start.x + (value * (end.x - start.x)), start.y + (value * (end.y - start.y)))]; break; - + case LPFrameAnimationKey: [target setFrame:CGRectMake(start.origin.x + (value * (end.origin.x - start.origin.x)), start.origin.y + (value * (end.origin.y - start.origin.y)), start.size.width + (value * (end.size.width - start.size.width)), @@ -298,12 +299,12 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, if (LPCSSAnimationsAreAvailable && _shouldUseCSSAnimations) { //_isAnimating = NO; - + //if (_animationDidEndTimeout) // window.clearTimeout(_animationDidEndTimeout); - + //[self _stopCSSAnimation]; - + //if ([_delegate respondsToSelector:@selector(animationDidStop:)]) // [_delegate animationDidStop:self]; } @@ -326,7 +327,7 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, - (void)target:(id)aTarget setCSSAnimationCurve:(id)anAnimationCurve { var curve = nil; - + switch (anAnimationCurve) { case CPAnimationLinear: curve = @"linear"; @@ -341,37 +342,37 @@ var appendCSSValueToKey = function(/*DOMElement*/ anElement, /*CPString*/aValue, case CPAnimationEaseInOut: curve = @"ease-in-out"; break; } - + aTarget._DOMElement.style["-webkit-transition-timing-function"] = curve; } - (void)target:(id)aTarget addCSSAnimationPropertyForKey:(CPString)aKey append:(BOOL)shouldAppend { var CSSValue = nil; - + switch(aKey) { case LPFadeAnimationKey: CSSValue = @"-webkit-transform, opacity"; break; - + case LPOriginAnimationKey: CSSValue = @"-webkit-transform"; break; case LPFrameAnimationKey: CSSValue = @"top, left, width, height"; break; - + default: CSSValue = @"none"; } - + appendCSSValueToKey(aTarget._DOMElement, CSSValue, @"-webkit-transition-property", shouldAppend); } @end /* - + Inlined this, because I managed to crank out a few more fps by doing that. I think. - + */ // currently used function to determine time @@ -389,7 +390,7 @@ var CubicBezierAtTime = function CubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration) function solve(x,epsilon) {return sampleCurveY(solveCurveX(x,epsilon));}; // Given an x value, find a parametric value it came from. function solveCurveX(x,epsilon) {var t0,t1,t2,x2,d2,i; - function fabs(n) {if(n>=0) {return n;}else {return 0-n;}}; + function fabs(n) {if(n>=0) {return n;}else {return 0-n;}}; // First try a few iterations of Newton's method -- normally very fast. for(t2=x, i=0; i<8; i++) {x2=sampleCurveX(t2)-x; if(fabs(x2) Date: Fri, 31 May 2013 11:30:28 +0200 Subject: [PATCH 02/14] Fixed: Added LPMultiLineTextField.j to Framework imports Added LPMultiLineTextField.j import to LPKit.j. Importing the framework with @import would also import LPMultiLineTextField as well. --- LPKit.j | 1 + 1 file changed, 1 insertion(+) diff --git a/LPKit.j b/LPKit.j index 873bfca..bd8c8cd 100644 --- a/LPKit.j +++ b/LPKit.j @@ -40,3 +40,4 @@ @import "LPSwitch.j" @import "LPURLPostRequest.j" @import "LPViewAnimation.j" +@import "LPMultiLineTextField.j" From 0de7f693a52c152552e943a76744f76526cc547f Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Fri, 31 May 2013 11:40:08 +0200 Subject: [PATCH 03/14] Fixed: Updated Jakefile Updated Jakefile to use new template. Kept original license an and author settings. --- Jakefile | 226 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 188 insertions(+), 38 deletions(-) diff --git a/Jakefile b/Jakefile index c39562d..a367538 100644 --- a/Jakefile +++ b/Jakefile @@ -3,6 +3,7 @@ * LPKit * * Created by Ludwig Pettersson on November 9, 2009. + * Updated by Udo Schneider on May 31, 2013 * * The MIT License * @@ -28,38 +29,98 @@ * */ -var OS = require("os"), - ENV = require("system").env, +//=========================================================== +// DO NOT REMOVE +//=========================================================== + +var SYS = require("system"), + ENV = SYS.env, FILE = require("file"), + OS = require("os"); + + +//=========================================================== +// USER CONFIGURABLE VARIABLES +//=========================================================== + +/* + The directory in which the project will be built. By default + it is built in $CAPP_BUILD if that is defined, otherwise + in a "Build" directory within the project directory. +*/ +var buildDir = ENV["BUILD_PATH"] || ENV["CAPP_BUILD"] || "Build"; + +/* + The list of directories containing Objective-J source + that should be compiled by jake. The main framework + directory is always checked for Objective-J source, + you only need to edit this if you have source in + subdirectories. Do NOT include a leading ortrailing slash + in the directory name. + + Example: + + var sourceDirs = [ + "Core", + "Modules", + "Modules/Foo", + "Modules/Bar" + ]; +*/ +var sourceDirs = [ + ]; + + + //=========================================================== + // AUTOMATICALLY GENERATED + // + // Do not edit! (unless you know what you are doing) + //=========================================================== + +var stream = require("narwhal/term").stream, JAKE = require("jake"), task = JAKE.task, CLEAN = require("jake/clean").CLEAN, + CLOBBER = require("jake/clean").CLOBBER, FileList = JAKE.FileList, + filedir = JAKE.filedir, framework = require("cappuccino/jake").framework, browserEnvironment = require("objective-j/jake/environment").Browser, - configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug"; - -framework ("LPKit", function(task) -{ - task.setBuildIntermediatesPath(FILE.join(ENV["CAPP_BUILD"], "LPKit.build", configuration)); - task.setBuildPath(FILE.join(ENV["CAPP_BUILD"], configuration)); - - task.setProductName("LPKit"); - task.setIdentifier("com.luddep.LPKit"); - task.setVersion("0.1"); - task.setAuthor("Ludwig Pettersson"); - task.setEmail("luddep@gmail.com"); - task.setSummary("A collection of re-usable views, controls & utilities for Cappuccino."); - task.setSources(new FileList("*.j")); - task.setResources(new FileList("Resources/**/*")); - //task.setEnvironments([browserEnvironment]); - //task.setFlattensSources(true); - task.setInfoPlistPath("Info.plist"); + configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug", + productName = "LPKit", + buildPath = FILE.canonical(FILE.join(buildDir, productName + ".build")), + packageFrameworksPath = FILE.join(SYS.prefix, "packages", "cappuccino", "Frameworks"), + debugPackagePath = FILE.join(packageFrameworksPath, "Debug", productName); + releasePackagePath = FILE.join(packageFrameworksPath, productName); + +var frameworkTask = framework (productName, function(frameworkTask) +{ + frameworkTask.setBuildIntermediatesPath(FILE.join(buildPath, configuration)); + frameworkTask.setBuildPath(FILE.join(buildDir, configuration)); + + frameworkTask.setProductName(productName); + frameworkTask.setIdentifier("com.luddep.LPKit"); + frameworkTask.setVersion("0.1"); + frameworkTask.setAuthor("Ludwig Pettersson"); + frameworkTask.setEmail("luddep@gmail.com"); + frameworkTask.setSummary("A collection of re-usable views, controls & utilities for Cappuccino."); + + var includes = sourceDirs.map(function(dir) { return dir + "/*.j"; }), + fileList = new FileList(); + + includes.unshift("*.j"); + fileList.include(includes); + frameworkTask.setSources(fileList); + frameworkTask.setResources(new FileList("Resources/**/*")); + frameworkTask.setFlattensSources(true); + frameworkTask.setInfoPlistPath("Info.plist"); + frameworkTask.setLicense(BundleTask.License.LGPL_v2_1); + //frameworkTask.setEnvironments([browserEnvironment]); if (configuration === "Debug") - task.setCompilerFlags("-DDEBUG -g"); + frameworkTask.setCompilerFlags("-DDEBUG -g"); else - task.setCompilerFlags("-O"); + frameworkTask.setCompilerFlags("-O"); }); task ("debug", function() @@ -76,26 +137,115 @@ task ("release", function() task ("default", ["release"]); -task ("build", ["LPKit"]); +var frameworkCJS = FILE.join(buildDir, configuration, "CommonJS", "cappuccino", "Frameworks", productName); + +filedir (frameworkCJS, [productName], function() +{ + if (FILE.exists(frameworkCJS)) + FILE.rmtree(frameworkCJS); + + FILE.copyTree(frameworkTask.buildProductPath(), frameworkCJS); +}); + +task ("build", [productName, frameworkCJS]); -task ("install", ["debug", "release"]) +task ("all", ["debug", "release"]); -task ("symlink-narwhal", ["release", "debug"], function() +task ("install", ["debug", "release"], function() { - // TODO: this should not be hardcoded to /usr/local - not sure how - // to actually find the path to narwhal right now though. - var frameworksPath = FILE.join("", "usr", "local", "narwhal", "packages", "cappuccino", "Frameworks"); - + install("copy"); +}); + +task ("install-symlinks", ["debug", "release"], function() +{ + install("symlink"); +}); + +task ("help", function() +{ + var app = JAKE.application().name(); + + colorPrint("--------------------------------------------------------------------------", "bold+green"); + colorPrint("LPKit - Framework", "bold+green"); + colorPrint("--------------------------------------------------------------------------", "bold+green"); + + describeTask(app, "debug", "Builds a debug version at " + FILE.join(buildDir, "Debug", productName)); + describeTask(app, "release", "Builds a release version at " + FILE.join(buildDir, "Release", productName)); + describeTask(app, "all", "Builds a debug and release version"); + describeTask(app, "install", "Builds a debug and release version, then installs in " + packageFrameworksPath); + describeTask(app, "install-symlinks", "Builds a debug and release version, then symlinks the built versions into " + packageFrameworksPath); + describeTask(app, "clean", "Removes the intermediate build files"); + describeTask(app, "clobber", "Removes the intermediate build files and the installed frameworks"); + + colorPrint("--------------------------------------------------------------------------", "bold+green"); +}); + +CLEAN.include(buildPath); +CLOBBER.include(FILE.join(buildDir, "Debug", productName)) + .include(FILE.join(buildDir, "Release", productName)) + .include(debugPackagePath) + .include(releasePackagePath); + +var install = function(action) +{ + var packageFrameworksPath = FILE.join(SYS.prefix, "packages", "cappuccino", "Frameworks"); + ["Release", "Debug"].forEach(function(aConfig) { - print("Symlinking " + aConfig + " ..."); - + colorPrint((action === "symlink" ? "Symlinking " : "Copying ") + aConfig + "...", "cyan"); + if (aConfig === "Debug") - frameworksPath = FILE.join(frameworksPath, aConfig); - - var buildPath = FILE.absolute(FILE.join(ENV["CAPP_BUILD"], aConfig, "LPKit")), - symlinkPath = FILE.join(frameworksPath, "LPKit"); - - OS.system(["sudo", "ln", "-s", buildPath, symlinkPath]); + packageFrameworksPath = FILE.join(packageFrameworksPath, aConfig); + + if (!FILE.isDirectory(packageFrameworksPath)) + sudo(["mkdir", "-p", packageFrameworksPath]); + + var buildPath = FILE.absolute(FILE.join(buildDir, aConfig, productName)), + targetPath = FILE.join(packageFrameworksPath, productName); + + if (action === "symlink") + directoryOp(["ln", "-sf", buildPath, targetPath]); + else + directoryOp(["cp", "-rf", buildPath, targetPath]); }); -}); +}; + +var directoryOp = function(cmd) +{ + var targetPath = cmd[cmd.length - 1]; + + if (FILE.isDirectory(targetPath)) + sudo(["rm", "-rf", targetPath]); + + sudo(cmd); +}; + +var sudo = function(cmd) +{ + if (OS.system(cmd)) + OS.system(["sudo"].concat(cmd)); +}; + +var describeTask = function(application, task, description) +{ + colorPrint("\n" + application + " " + task, "violet"); + description.split("\n").forEach(function(line) + { + stream.print(" " + line); + }); +}; + +var colorPrint = function(message, color) +{ + var matches = color.match(/(bold(?: |\+))?(.+)/); + + if (!matches) + return; + + message = "\0" + matches[2] + "(" + message + "\0)"; + + if (matches[1]) + message = "\0bold(" + message + "\0)"; + + stream.print(message); +}; From e273755c1ed0d5664df59323099a5a48ba7d30ec Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Fri, 31 May 2013 15:06:40 +0200 Subject: [PATCH 04/14] Fixed: Added missing import for --- LPAnchorButton.j | 1 + 1 file changed, 1 insertion(+) diff --git a/LPAnchorButton.j b/LPAnchorButton.j index 7eff3fd..c251286 100644 --- a/LPAnchorButton.j +++ b/LPAnchorButton.j @@ -29,6 +29,7 @@ */ @import +@import LPAnchorButtonNoUnderline = 0; LPAnchorButtonNormalUnderline = 1; From b2fae8cfb71981cf431d7d2cf99b11581fc2c485 Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 18:34:30 +0200 Subject: [PATCH 05/14] Fixed: Added missing imports for CPApp Added import for to provide global variable "CPApp". --- LPCalendarMonthView.j | 29 +++++++++++++++-------------- LPCrashReporter.j | 1 + 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/LPCalendarMonthView.j b/LPCalendarMonthView.j index 91e0bee..587baef 100644 --- a/LPCalendarMonthView.j +++ b/LPCalendarMonthView.j @@ -29,6 +29,7 @@ */ @import @import +@import @import @@ -74,7 +75,7 @@ var _startAndEndOfWeekCache = {}; BOOL highlightCurrentPeriod @accessors; BOOL weekStartsOnMonday @accessors; - + id _delegate @accessors(property=delegate); LPCalendarView calendarView @accessors; CPArray hiddenRows @accessors; @@ -118,10 +119,10 @@ var _startAndEndOfWeekCache = {}; // No need to reloadData if the new date is the same as before. // == // Future note: Do not use UTC comparison here, - // since we reset the date to the relative midnight later on. + // since we reset the date to the relative midnight later on. if (date && date.getFullYear() === aDate.getFullYear() && date.getMonth() === aDate.getMonth()) return; - + date = [aDate copy]; if (![aDate isEqualToDate:immutableDistantFuture]) @@ -137,7 +138,7 @@ var _startAndEndOfWeekCache = {}; previousMonth = new Date(_firstDay.getTime() - 86400000); nextMonth = new Date(_firstDay.getTime() + (([date daysInMonth] + 1) * 86400000)); } - + [self reloadData]; } @@ -145,16 +146,16 @@ var _startAndEndOfWeekCache = {}; { if (selectionLengthType === aSelectionType) return; - + selectionLengthType = aSelectionType; - + [self reloadData]; } - (void)tileSize { var tileSize = [calendarView currentValueForThemeAttribute:@"tile-size"]; - + if (tileSize) return tileSize else @@ -219,13 +220,13 @@ var _startAndEndOfWeekCache = {}; { if ([hiddenRows isEqualToArray:hiddenRowsArray]) return; - + hiddenRows = hiddenRowsArray; - + var tiles = [self subviews], tileIndex = 0, showAllRows = !hiddenRowsArray - + for (var weekIndex = 0; weekIndex < 6; weekIndex++) { var shouldHideRow = showAllRows || [hiddenRows indexOfObject:weekIndex] > -1; @@ -239,7 +240,7 @@ var _startAndEndOfWeekCache = {}; } - (void)reloadData -{ +{ if (!date) return; @@ -574,7 +575,7 @@ var _startAndEndOfWeekCache = {}; { if (date.getTime() === aDate.getTime()) return; - + // Update date date.setTime(aDate.getTime()); @@ -589,7 +590,7 @@ var _startAndEndOfWeekCache = {}; - (void)layoutSubviews { var themeState = [self themeState]; - + [self setBackgroundColor:[calendarView valueForThemeAttribute:@"tile-bezel-color" inState:themeState]] [textField setFont:[calendarView valueForThemeAttribute:@"tile-font" inState:themeState]]; @@ -598,4 +599,4 @@ var _startAndEndOfWeekCache = {}; [textField setTextShadowOffset:[calendarView valueForThemeAttribute:@"tile-text-shadow-offset" inState:themeState]]; } -@end \ No newline at end of file +@end diff --git a/LPCrashReporter.j b/LPCrashReporter.j index 52b42d4..d48b0c0 100644 --- a/LPCrashReporter.j +++ b/LPCrashReporter.j @@ -30,6 +30,7 @@ @import @import +@import @import "LPURLPostRequest.j" @import "LPMultiLineTextField.j" From 723465ec60d71a8d1e77e04e299c2a3bbde2ac4f Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 18:42:52 +0200 Subject: [PATCH 06/14] Fixed: Renamed locally overriden ivar - (void)mouseUp:(CPEvent)anEvent declared a local var "calenderView" which hid the ivar of the same name. Replaced the local var with "theCalenderView". Although it might also work to not define an additonal variable but simply refer to the ivar. --- LPCalendarMonthView.j | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/LPCalendarMonthView.j b/LPCalendarMonthView.j index 587baef..a20be62 100644 --- a/LPCalendarMonthView.j +++ b/LPCalendarMonthView.j @@ -373,22 +373,22 @@ var _startAndEndOfWeekCache = {}; // Clicked a date if (!currentSelectionIndex || startSelectionIndex == currentSelectionIndex) { - var calendarView = [[self superview] superview], + var theCalenderView = [[self superview] superview], tile = [[self subviews] objectAtIndex:startSelectionIndex], tileDate = [tile date], tileMonth = tileDate.getMonth(); // Double clicked a date in the current month. - if (tileMonth == date.getMonth() && [[CPApp currentEvent] clickCount] === 2 && [calendarView doubleAction]) - [CPApp sendAction:[calendarView doubleAction] to:[calendarView target] from:calendarView]; + if (tileMonth == date.getMonth() && [[CPApp currentEvent] clickCount] === 2 && [theCalenderView doubleAction]) + [CPApp sendAction:[theCalenderView doubleAction] to:[theCalenderView target] from:theCalenderView]; // Clicked the Previous month if (tileMonth == previousMonth.getMonth()) - [calendarView changeToMonth:previousMonth]; + [theCalenderView changeToMonth:previousMonth]; // Clicked the Next month if (tileMonth == nextMonth.getMonth()) - [calendarView changeToMonth:nextMonth]; + [theCalenderView changeToMonth:nextMonth]; } // Made a selection From db98b8a4b3678e586c1c2873d54644f70a0c4d61 Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 18:44:45 +0200 Subject: [PATCH 07/14] Fixed: Made _firstDay explicitly local The initial assignment of _firstDay with missing a var statement. --- LPCalendarMonthView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LPCalendarMonthView.j b/LPCalendarMonthView.j index a20be62..8fa945f 100644 --- a/LPCalendarMonthView.j +++ b/LPCalendarMonthView.j @@ -132,7 +132,7 @@ var _startAndEndOfWeekCache = {}; [date resetToMidnight]; // There must be a better way to do this. - _firstDay = [date copy]; + var _firstDay = [date copy]; _firstDay.setDate(1); previousMonth = new Date(_firstDay.getTime() - 86400000); From 1727078b1f26bcc924d215fe5669345490e9f72d Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 18:45:54 +0200 Subject: [PATCH 08/14] Fixed: Made _cached explicitly local The initial assignment of _cached with missing a var statement. --- LPCalendarMonthView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LPCalendarMonthView.j b/LPCalendarMonthView.j index 8fa945f..71472e0 100644 --- a/LPCalendarMonthView.j +++ b/LPCalendarMonthView.j @@ -182,7 +182,7 @@ var _startAndEndOfWeekCache = {}; - (CPArray)startAndEndOfWeekForDate:(CPDate)aDate { - _cached = _startAndEndOfWeekCache[aDate.toString()]; + var _cached = _startAndEndOfWeekCache[aDate.toString()]; if (_cached) return _cached; From ca68e96e7d9a049ad902d6272ce5ac25451fd6ab Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 18:58:08 +0200 Subject: [PATCH 09/14] Fixed: Referenced non-existent (local) var aFrame - (void)setDisplayLabels:(BOOL)shouldDisplayLabels referenced a non-existent (local) var aFrame. I assume aFrame references the size of the drawView. BREAKING CHANGE: Although this code would have thrown an error anyway this should be marked as breaking as I do not fully understand the original intention here. My "fix" might be incorrect from a intention point of view. --- LPChartView.j | 207 +++++++++++++++++++++++++------------------------- 1 file changed, 104 insertions(+), 103 deletions(-) diff --git a/LPChartView.j b/LPChartView.j index c20291c..bcf72f4 100644 --- a/LPChartView.j +++ b/LPChartView.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on December 6, 2009. - * + * * The MIT License - * + * * Copyright (c) 2009 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,7 +25,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ @import @@ -39,18 +39,18 @@ var labelViewHeight = 20, id dataSource @accessors; id delegate @accessors; id drawView @accessors; - + LPChartGridView gridView @accessors; - + LPChartLabelView labelView @accessors(readonly); BOOL displayLabels @accessors; - + CPArray _data; int _maxValue; - + CPArray _framesSet; CGSize _currentSize; - + float _maxValuePosition; float _minValuePosition; } @@ -68,16 +68,16 @@ var labelViewHeight = 20, { _maxValuePosition = 1.0; _minValuePosition = 0.0; - + gridView = [[LPChartGridView alloc] initWithFrame:CGRectMakeZero()]; [gridView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; [self addSubview:gridView]; - + var bounds = [self bounds]; - + labelView = [[LPChartLabelView alloc] initWithFrame:CGRectMake(drawViewPadding, CGRectGetHeight(bounds) - labelViewHeight, CGRectGetWidth(bounds) - (2 * drawViewPadding), labelViewHeight)]; [self addSubview:labelView]; - + _currentSize = CGSizeMake(0,0); } @@ -90,32 +90,32 @@ var labelViewHeight = 20, { if (aDrawView === drawView) return; - + if (drawView) [drawView removeFromSuperview]; - + [self addSubview:aDrawView positioned:CPWindowAbove relativeTo:gridView]; - + // Got a new drawView drawView = aDrawView; - + // Resize the drawview to the correct size var drawViewFrame = CGRectInset([self bounds], drawViewPadding, drawViewPadding); - + // Don't let it draw over the labelView if (labelView) drawViewFrame.size.height -= CGRectGetHeight([labelView bounds]); - + // Update drawView frame & autoresizingmask [drawView setFrame:drawViewFrame]; [drawView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; - + // Make drawView 1px higher, so the bottom line can be seen drawViewFrame.size.height += 1; - + // Update gridview as well [gridView setFrame:drawViewFrame]; - + // Re-draw if ([self window]) [self reloadData]; @@ -125,10 +125,10 @@ var labelViewHeight = 20, { if (gridView === aGridView) return; - + [aGridView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; [self replaceSubview:gridView with:aGridView]; - + gridView = aGridView; } @@ -141,17 +141,18 @@ var labelViewHeight = 20, var drawViewSize = [drawView frame]; drawViewSize.size.height += CGRectGetHeight([labelView bounds]); [drawView setFrame:drawViewSize]; - + // Remove labelview [labelView removeFromSuperview]; } // We should create labels else { - labelView = [[LPChartLabelView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(aFrame) - labelViewHeight, CGRectGetWidth(aFrame), labelViewHeight)]; + var drawViewSize = [drawView frame]; + labelView = [[LPChartLabelView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(drawViewSize) - labelViewHeight, CGRectGetWidth(drawViewSize), labelViewHeight)]; [self addSubview:labelView]; } - + displayLabels = shouldDisplayLabels; } @@ -164,7 +165,7 @@ var labelViewHeight = 20, { _maxValuePosition = aMaxValuePosition; _minValuePosition = aMinValuePosition; - + [[self drawView] setNeedsDisplay:YES]; } @@ -177,41 +178,41 @@ var labelViewHeight = 20, { if (!dataSource || !drawView) return; - + // Reset data & max value _data = [CPArray array]; _maxValue = 0; - + var numberOfSets = [dataSource numberOfSetsInChart:self]; - + for (var setIndex = 0; setIndex < numberOfSets; setIndex++) { var row = [], numberOfItems = [dataSource chart:self numberOfValuesInSet:setIndex]; - + for (var itemIndex = 0; itemIndex < numberOfItems; itemIndex++) { var value = [dataSource chart:self valueForIndex:itemIndex set:setIndex]; - + if (value > _maxValue) _maxValue = value; - + row.push(value); } - + _data.push(row); } - + // Clear the current size of the chart // this will force the re-calculation of item frames. _currentSize = nil; - + // Update grid view [gridView setNeedsDisplay:YES]; - + // Update Label view [labelView reloadData]; - + // Update Draw view [drawView setNeedsDisplay:YES]; } @@ -220,7 +221,7 @@ var labelViewHeight = 20, { var drawViewSize = [drawView bounds].size, maxValueHeightDelta = (1.0 - _maxValuePosition) * drawViewSize.height; - + // Restrict drawViewSize according to min value positions if (_minValuePosition !== 0.0) drawViewSize.height -= _minValuePosition * drawViewSize.height; @@ -231,21 +232,21 @@ var labelViewHeight = 20, // Make sure we don't do unnecessary word if (_currentSize && CGSizeEqualToSize(_currentSize, drawViewSize)) return _framesSet; - + _currentSize = drawViewSize; // Reset frames set _framesSet = [CPArray array]; - + if (!sets.length) return _framesSet; - + // If the chart has no data to display, // we set the max value to 1 so that it will // at least draw an empty line at the bottom of the chart. if (aMaxValue === 0) aMaxValue = 1; - + var width = drawViewSize.width, height = drawViewSize.height - (2 * drawViewPadding), numberOfItems = sets[0].length, @@ -257,39 +258,39 @@ var labelViewHeight = 20, var items = sets[setIndex], currentItemOriginX = 0, row = []; - + for (var itemIndex = 0; itemIndex < items.length; itemIndex++) { var value = items[itemIndex], itemFrame = CGRectMake(currentItemOriginX, 0, itemWidth, 0); - + // Pad the width of the item if we have any unused width if (unusedWidth > 0) { itemFrame.size.width++; unusedWidth--; } - + // Set the height itemFrame.size.height = ROUND((value / aMaxValue) * height); - + // Set Y Origin itemFrame.origin.y = height - CGRectGetHeight(itemFrame) + drawViewPadding; - + // Make up for _maxValuePosition if it's set if (_maxValuePosition !== 1.0) itemFrame.origin.y += maxValueHeightDelta; - + // Save it row.push(itemFrame); - + // Set the X origin for the next item currentItemOriginX += CGRectGetWidth(itemFrame); } - + _framesSet.push(row); } - + return _framesSet; } @@ -303,17 +304,17 @@ var labelViewHeight = 20, if (delegate && [delegate respondsToSelector:@selector(chart:didMouseOverItemAtIndex:)]) { var itemFrames = [self itemFrames]; - + if (!itemFrames.length) return; - + var firstSet = itemFrames[0], locationInDrawView = [drawView convertPoint:[anEvent locationInWindow] fromView:nil]; - + for (var i = 0; i < firstSet.length; i++) { var itemFrame = firstSet[i]; - + if (itemFrame.origin.x <= locationInDrawView.x && (itemFrame.origin.x + itemFrame.size.width) > locationInDrawView.x) { [delegate chart:self didMouseOverItemAtIndex:i]; @@ -356,22 +357,22 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", if (self = [super initWithCoder:aCoder]) { dataSource = [aCoder decodeObjectForKey:LPChartViewDataSourceKey]; - + gridView = [aCoder decodeObjectForKey:LPChartViewGridViewKey]; drawView = [aCoder decodeObjectForKey:LPChartViewDrawViewKey]; - + displayLabels = ![aCoder containsValueForKey:LPChartViewDisplayLabelsKey] || [aCoder decodeObjectForKey:LPChartViewDisplayLabelsKey]; labelView = [aCoder decodeObjectForKey:LPChartViewLabelViewKey]; - + _data = [aCoder decodeObjectForKey:LPChartViewDataKey]; _maxValue = [aCoder decodeIntForKey:LPChartViewMaxValueKey]; - + _framesSet = [aCoder decodeObjectForKey:LPChartViewFramesSetKey]; _currentSize = [aCoder decodeSizeForKey:LPChartViewCurrentSizeKey]; - + _maxValuePosition = [aCoder decodeIntForKey:LPChartViewMaxValuePositionKey]; _minValuePosition = [aCoder decodeFloatForKey:LPChartViewMinValuePositionKey]; - + [self _setup]; } return self; @@ -380,23 +381,23 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", - (void)encodeWithCoder:(CPCoder)aCoder { [super encodeWithCoder:aCoder]; - + [aCoder encodeObject:dataSource forKey:LPChartViewDataSourceKey]; [aCoder encodeObject:drawView forKey:LPChartViewDrawViewKey]; - + [aCoder encodeObject:gridView forKey:LPChartViewGridViewKey]; - + [aCoder encodeBool:displayLabels forKey:LPChartViewDisplayLabelsKey]; [aCoder encodeObject:labelView forKey:LPChartViewLabelViewKey]; - + [aCoder encodeObject:_data forKey:LPChartViewDataKey]; [aCoder encodeInt:_maxValue forKey:LPChartViewMaxValueKey]; - + [aCoder encodeObject:_framesSet forKey:LPChartViewFramesSetKey]; - + if (_currentSize) [aCoder encodeSize:_currentSize forKey:LPChartViewCurrentSizeKey]; - + [aCoder encodeFloat:_maxValuePosition forKey:LPChartViewMaxValuePositionKey]; [aCoder encodeFloat:_minValuePosition forKey:LPChartViewMinValuePositionKey]; } @@ -434,9 +435,9 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", width = CGRectGetWidth(bounds), height = CGRectGetHeight(bounds), lineWidth = 1; - + CGContextSetFillColor(context, gridColor); - + // Vertical lines if (itemFrames.length) { @@ -447,10 +448,10 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", } else CGContextFillRect(context, CGRectMake(0, 0, lineWidth, height)); - + // Right most line CGContextFillRect(context, CGRectMake(width - lineWidth, 0, lineWidth, height)); - + // Bottom & middle line CGContextFillRect(context, CGRectMake(0, height - lineWidth, width, lineWidth)); CGContextFillRect(context, CGRectMake(0, FLOOR(height / 2), width, lineWidth)); @@ -486,34 +487,34 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", { // Overwrite this method in your subclass // to get complete control of the drawing. - + CGContextSetStrokeColor(context, [CPColor colorWithHexString:@"4379ca"]); CGContextSetLineWidth(context, 2.0); - + for (var setIndex = 0; setIndex < aFramesSet.length; setIndex++) { var items = aFramesSet[setIndex]; - + // Start path CGContextBeginPath(context); - + for (var itemIndex = 0; itemIndex < items.length; itemIndex++) { var itemFrame = items[itemIndex], point = CGPointMake(CGRectGetMidX(itemFrame), CGRectGetMinY(itemFrame)); - + // Begin path if (itemIndex == 0) CGContextMoveToPoint(context, point.x, point.y); - + // Add point else CGContextAddLineToPoint(context, point.x, point.y); } - + // Stroke path CGContextStrokePath(context); - + // Close path CGContextClosePath(context); } @@ -525,12 +526,12 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", @implementation LPChartLabelView : CPView { LPChartView chart; - + id _labelPrototype; CPData _labelData; CPArray _cachedLabels; } - + - (id)initWithFrame:(CPRect)aFrame { if (self = [super initWithFrame:aFrame]) @@ -548,7 +549,7 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", _labelPrototype = aLabelPrototype; _labelData = nil; _cachedLabels = [CPArray array]; - + [self reloadData]; } @@ -561,12 +562,12 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", if (!_labelData) if (_labelPrototype) _labelData = [CPKeyedArchiver archivedDataWithRootObject:_labelPrototype]; - + var label = [CPKeyedUnarchiver unarchiveObjectWithData:_labelData]; } - + [label setItemIndex:anItemIndex]; - + return label; } @@ -575,22 +576,22 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", if (chart) { var subviews = [self subviews]; - + // Clear any previous labels if (numberOfSubviews = subviews.length) { while (numberOfSubviews--) { [subviews[numberOfSubviews] removeFromSuperview]; - + if (_labelData) _cachedLabels.push(subviews[numberOfSubviews]); } } - + // Insert new subviews var itemFrames = [chart itemFrames]; - + if (itemFrames && itemFrames.length) { itemFrames = itemFrames[0]; @@ -601,7 +602,7 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", [self addSubview:label]; } } - + // Layout subviews [self setNeedsLayout]; } @@ -615,10 +616,10 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", - (void)layoutSubviews { var itemFrames = [chart itemFrames]; - + if (!itemFrames) return; - + var subviews = [self subviews], numberOfSubviews = subviews.length, bounds = [self bounds], @@ -630,9 +631,9 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", { var subview = subviews[numberOfSubviews]; [subview setCenter:CGPointMake(CGRectGetMidX(itemFrames[numberOfSubviews]) + drawViewPadding, midY)]; - + var subviewFrame = [subview frame]; - + // Make sure the label stays within the rame if (subviewFrame.origin.x < 0) { @@ -648,7 +649,7 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", } } } - + @end @@ -682,14 +683,14 @@ var LPChartLabelViewChartKey = @"LPChartLabelViewChartKey", { int _itemIndex @accessors(property=itemIndex); } - + + (id)labelWithItemIndex:(int)anItemIndex { var label = [[self alloc] initWithFrame:CGRectMakeZero()]; [label setItemIndex:anItemIndex]; return label; } - + - (id)initWithFrame:(CGRect)aFrame { if (self = [super initWithFrame:aFrame]) @@ -730,4 +731,4 @@ var LPChartLabelItemIndexKey = @"LPChartLabelItemIndexKey"; [aCoder encodeInt:_itemIndex forKey:LPChartLabelItemIndexKey]; } -@end \ No newline at end of file +@end From 8b8780a15b60d9a9a61011af1c5fe55832ba9a89 Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 18:59:39 +0200 Subject: [PATCH 10/14] Fixed: Made itemFrames explicitly local The initial assignment of itemFrames with missing a var statement. --- LPChartView.j | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LPChartView.j b/LPChartView.j index bcf72f4..4a46002 100644 --- a/LPChartView.j +++ b/LPChartView.j @@ -428,6 +428,7 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", - (void)drawRect:(CGRect)aRect { + var itemFrames; if (itemFrames = [[self superview] itemFrames]) { var context = [[CPGraphicsContext currentContext] graphicsPort], @@ -476,6 +477,7 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", - (void)drawRect:(CGRect)aRect { + var itemFrames; if (itemFrames = [[self superview] itemFrames]) { var context = [[CPGraphicsContext currentContext] graphicsPort]; From a8b6b15182022b6fcfad10dc41e5eb6f55398af2 Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 19:07:33 +0200 Subject: [PATCH 11/14] Fixed: Made numberOfSubviews explicitly local The initial assignment of numberOfSubviews with missing a var statement. --- LPChartView.j | 1 + 1 file changed, 1 insertion(+) diff --git a/LPChartView.j b/LPChartView.j index 4a46002..5437529 100644 --- a/LPChartView.j +++ b/LPChartView.j @@ -580,6 +580,7 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", var subviews = [self subviews]; // Clear any previous labels + var numberOfSubviews; if (numberOfSubviews = subviews.length) { while (numberOfSubviews--) From 5a50081ada6f31dfbc0d1bee0e8d46bad68ec8da Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 19:09:22 +0200 Subject: [PATCH 12/14] Fixed: Made frameIsDirty explicitly local The initial assignment of frameIsDirty with missing a var statement. --- LPChartView.j | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LPChartView.j b/LPChartView.j index 5437529..99a1f9b 100644 --- a/LPChartView.j +++ b/LPChartView.j @@ -635,7 +635,8 @@ var LPChartViewDataSourceKey = @"LPChartViewDataSourceKey", var subview = subviews[numberOfSubviews]; [subview setCenter:CGPointMake(CGRectGetMidX(itemFrames[numberOfSubviews]) + drawViewPadding, midY)]; - var subviewFrame = [subview frame]; + var subviewFrame = [subview frame], + frameIsDirty; // Make sure the label stays within the rame if (subviewFrame.origin.x < 0) From 2f2f645c9b85f2dc770f88ffb295672de5ad1c6e Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 19:10:34 +0200 Subject: [PATCH 13/14] Fixed: Made key explicitly local The initial assignment of key with missing a var statement. --- LPURLPostRequest.j | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/LPURLPostRequest.j b/LPURLPostRequest.j index 666502e..518f938 100644 --- a/LPURLPostRequest.j +++ b/LPURLPostRequest.j @@ -3,21 +3,21 @@ * LPKit * * Created by Ludwig Pettersson on November 7, 2009. - * + * * The MIT License - * + * * Copyright (c) 2009 Ludwig Pettersson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,14 +25,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * */ @import @implementation LPURLPostRequest : CPURLRequest { -} +} + (id)requestWithURL:(CPURL)aURL { @@ -56,15 +56,16 @@ - (void)setContent:(id)anObject escape:(BOOL)shouldEscape { - var content = @""; - + var content = @"", + key; + for (key in anObject) content = [content stringByAppendingString:[CPString stringWithFormat:@"%s=%s&", key, shouldEscape ? encodeURIComponent(anObject[key]) : anObject[key]]]; - + // Remove trailing & content = [content substringToIndex:[content length] - 1]; [self setHTTPBody:content]; } -@end \ No newline at end of file +@end From 61d2030bdcb02f7aa9c793010c16188bb7b80d12 Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Sat, 1 Jun 2013 19:12:13 +0200 Subject: [PATCH 14/14] Fixed: Made isHighlighted explicitly local The initial assignment of isHighlighted with missing a var statement. --- LPSwitch.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LPSwitch.j b/LPSwitch.j index 8a99b92..74a4ac4 100644 --- a/LPSwitch.j +++ b/LPSwitch.j @@ -283,7 +283,7 @@ - (void)setHighlighted:(BOOL)shouldBeHighlighted { - isHighlighted = shouldBeHighlighted; + var isHighlighted = shouldBeHighlighted; if (shouldBeHighlighted) [self setThemeState:CPThemeStateHighlighted];