diff --git a/AppKit/CPCompatibility.j b/AppKit/CPCompatibility.j index de099192e..cc9328f0e 100644 --- a/AppKit/CPCompatibility.j +++ b/AppKit/CPCompatibility.j @@ -80,7 +80,7 @@ if (typeof window !== "undefined" && typeof window.navigator !== "undefined") if (typeof window !== "undefined" && window.opera) { PLATFORM_ENGINE = CPOperaBrowserEngine; - + PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature; } @@ -88,12 +88,12 @@ if (typeof window !== "undefined" && window.opera) else if (typeof window !== "undefined" && window.attachEvent) // Must follow Opera check. { PLATFORM_ENGINE = CPInternetExplorerBrowserEngine; - + // Features we can only be sure of with IE (no known independent tests) PLATFORM_FEATURES |= CPVMLFeature; PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport; PLATFORM_FEATURES |= CPJavaScriptShadowFeature; - + PLATFORM_FEATURES |= CPOpacityRequiresFilterFeature; PLATFORM_FEATURES &= ~CPInputTypeCanBeChangedFeature; @@ -103,7 +103,7 @@ else if (typeof window !== "undefined" && window.attachEvent) // Must follow Ope else if (USER_AGENT.indexOf("AppleWebKit/") != -1) { PLATFORM_ENGINE = CPWebKitBrowserEngine; - + // Features we can only be sure of with WebKit (no known independent tests) PLATFORM_FEATURES |= CPCSSRGBAFeature; PLATFORM_FEATURES |= CPHTMLContentEditableFeature; @@ -114,7 +114,7 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1) PLATFORM_FEATURES |= CPJavascriptClipboardEventsFeature; PLATFORM_FEATURES |= CPJavascriptClipboardAccessFeature; PLATFORM_FEATURES |= CPJavaScriptShadowFeature; - + var versionStart = USER_AGENT.indexOf("AppleWebKit/") + "AppleWebKit/".length, versionEnd = USER_AGENT.indexOf(" ", versionStart), versionString = USER_AGENT.substring(versionStart, versionEnd), @@ -122,7 +122,7 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1) majorVersion = parseInt(versionString.substring(0, versionDivision)), minorVersion = parseInt(versionString.substr(versionDivision + 1)); - if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion > 525 || (majorVersion === 525 && minorVersion > 14))) || USER_AGENT.indexOf("Chrome") !== CPNotFound) + if ((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion > 525 || (majorVersion === 525 && minorVersion > 14))) || USER_AGENT.indexOf("Chrome") !== CPNotFound) PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport; // FIXME this is a terrible hack to get around this bug: @@ -144,12 +144,12 @@ else if (USER_AGENT.indexOf("KHTML") != -1) // Must follow WebKit check. else if (USER_AGENT.indexOf("Gecko") !== -1) // Must follow KHTML check. { PLATFORM_ENGINE = CPGeckoBrowserEngine; - + PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature; - + var index = USER_AGENT.indexOf("Firefox"), version = (index === -1) ? 2.0 : parseFloat(USER_AGENT.substring(index + "Firefox".length + 1)); - + if (version >= 3.0) PLATFORM_FEATURES |= CPCSSRGBAFeature; @@ -165,16 +165,16 @@ if (typeof document != "undefined") if (canvasElement && canvasElement.getContext) { PLATFORM_FEATURES |= CPHTMLCanvasFeature; - + // Detect Canvas setTransform/transform support var context = document.createElement("canvas").getContext("2d"); - + if (context && context.setTransform && context.transform) PLATFORM_FEATURES |= CPJavaScriptCanvasTransformFeature; } - + var DOMElement = document.createElement("div"); - + // Detect whether we have innerText or textContent (or neither) if (DOMElement.innerText != undefined) PLATFORM_FEATURES |= CPJavascriptInnerTextFeature; diff --git a/AppKit/CPController.j b/AppKit/CPController.j index 476fc9243..9dd4fce90 100644 --- a/AppKit/CPController.j +++ b/AppKit/CPController.j @@ -8,7 +8,7 @@ // Adapted from GNUStep // Copyright (C) 2007 Free Software Foundation, Inc // Released under the LGPL. -// +// @import @@ -24,13 +24,13 @@ var CPControllerDeclaredKeysKey = @"CPControllerDeclaredKeysKey"; - (id)init { self = [super init]; - + if (self) { _editors = []; _declaredKeys = []; } - + return self; } @@ -43,7 +43,7 @@ var CPControllerDeclaredKeysKey = @"CPControllerDeclaredKeysKey"; - (id)initWithCoder:(CPCoder)aDecoder { self = [super init]; - + if (self) { _editors = []; diff --git a/AppKit/CPCookie.j b/AppKit/CPCookie.j index 5e0f9bd4c..c3f8da3b6 100644 --- a/AppKit/CPCookie.j +++ b/AppKit/CPCookie.j @@ -25,7 +25,7 @@ #include "Platform/Platform.h" -/*! +/*! @ingroup appkit @class CPCookie CPCookie is the Cappuccino interface to a web browser cookie. You can set the name @@ -34,7 +34,7 @@ { CPString _cookieName; CPString _cookieValue; - + CPString _expires; } @@ -45,7 +45,7 @@ - (id)initWithName:(CPString)aName { self = [super init]; - + _cookieName = aName; _cookieValue = [self _readCookieValue]; @@ -84,17 +84,17 @@ */ - (void)setValue:(CPString)value expires:(CPDate)date domain:(CPString)domain { - if(date) - var expires = "; expires="+date.toGMTString(); - else + if (date) + var expires = "; expires=" + date.toGMTString(); + else var expires = ""; - - if(domain) - domain = "; domain="+domain; - else + + if (domain) + domain = "; domain=" + domain; + else domain = ""; - -#if PLATFORM(DOM) + +#if PLATFORM(DOM) document.cookie = _cookieName+"="+value+expires+"; path=/"+domain; #else _cookieValue = value; @@ -106,12 +106,14 @@ - (CPString)_readCookieValue { #if PLATFORM(DOM) - var nameEQ = _cookieName + "="; - var ca = document.cookie.split(';'); - for(var i=0;i < ca.length;i++) { + var nameEQ = _cookieName + "=", + ca = document.cookie.split(';'); + + for (var i = 0; i < ca.length; i++) + { var c = ca[i]; - while (c.charAt(0)==' ') c = c.substring(1,c.length); - if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } #endif return ""; diff --git a/AppKit/CPCursor.j b/AppKit/CPCursor.j index 6a525e6e6..f693db5aa 100755 --- a/AppKit/CPCursor.j +++ b/AppKit/CPCursor.j @@ -63,9 +63,9 @@ var currentCursor = nil, if (CPBrowserIsEngine(CPGeckoBrowserEngine)) cursorURLFormat += ", default"; } - + var url = [CPString stringWithFormat:cursorURLFormat, imageName]; - + return [[CPCursor alloc] initWithCSSString:url]; } @@ -98,7 +98,7 @@ var currentCursor = nil, { if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine)) return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; - + return [CPCursor cursorWithCSSString:"s-resize"]; // WebKit | FF | opera } @@ -174,7 +174,7 @@ var currentCursor = nil, else if (CPBrowserIsEngine(CPOperaBrowserEngine)) return [CPCursor cursorWithCSSString:@"move"]; - return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit only. move in FFMac|Opera + return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit only. move in FFMac|Opera } + (CPCursor)closedHandCursor @@ -184,7 +184,7 @@ var currentCursor = nil, else if (CPBrowserIsEngine(CPGeckoBrowserEngine)) return [CPCursor cursorWithCSSString:@"-moz-grabbing"]; - return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit || FF + return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit || FF } + (CPCursor)disappearingItemCursor @@ -225,7 +225,7 @@ var currentCursor = nil, - (void)set { - currentCursor = self; + currentCursor = self; #if PLATFORM(DOM) [[self class] _setCursorCSS:_cssString]; diff --git a/AppKit/CPDocument.j b/AppKit/CPDocument.j index 2a52905d0..816d3602d 100644 --- a/AppKit/CPDocument.j +++ b/AppKit/CPDocument.j @@ -83,7 +83,7 @@ CPDocumentDidFailToSaveNotification = @"CPDocumentDidFailToSaveNotification"; var CPDocumentUntitledCount = 0; -/*! +/*! @ingroup appkit @class CPDocument @@ -121,7 +121,7 @@ var CPDocumentUntitledCount = 0; - (id)init { self = [super init]; - + if (self) { _windowControllers = []; @@ -132,7 +132,7 @@ var CPDocumentUntitledCount = 0; [self setNextResponder:CPApp]; } - + return self; } @@ -145,10 +145,10 @@ var CPDocumentUntitledCount = 0; - (id)initWithType:(CPString)aType error:({CPError})anError { self = [self init]; - + if (self) [self setFileType:aType]; - + return self; } @@ -166,7 +166,7 @@ var CPDocumentUntitledCount = 0; - (id)initWithContentsOfURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo { self = [self init]; - + if (self) { [self setFileURL:anAbsoluteURL]; @@ -174,7 +174,7 @@ var CPDocumentUntitledCount = 0; [self readFromURL:anAbsoluteURL ofType:aType delegate:aDelegate didReadSelector:aDidReadSelector contextInfo:aContextInfo]; } - + return self; } @@ -191,7 +191,7 @@ var CPDocumentUntitledCount = 0; - (id)initForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo { self = [self init]; - + if (self) { [self setFileURL:anAbsoluteURL]; @@ -199,7 +199,7 @@ var CPDocumentUntitledCount = 0; [self readFromURL:absoluteContentsURL ofType:aType delegate:aDelegate didReadSelector:aDidReadSelector contextInfo:aContextInfo]; } - + return self; } @@ -282,7 +282,7 @@ var CPDocumentUntitledCount = 0; { var view = [viewController view], viewFrame = [view frame]; - + viewFrame.origin = CGPointMake(50, 50); var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask]; @@ -382,14 +382,14 @@ var CPDocumentUntitledCount = 0; { if (_fileURL) return [_fileURL lastPathComponent]; - + if (!_untitledDocumentIndex) _untitledDocumentIndex = ++CPDocumentUntitledCount; - - if (_untitledDocumentIndex == 1) - return @"Untitled"; - return @"Untitled " + _untitledDocumentIndex; + if (_untitledDocumentIndex == 1) + return @"Untitled"; + + return @"Untitled " + _untitledDocumentIndex; } - (CPString)viewCibName @@ -458,7 +458,7 @@ var CPDocumentUntitledCount = 0; return; _fileURL = aFileURL; - + [_windowControllers makeObjectsPerformSelector:@selector(synchronizeWindowTitleWithDocumentName)]; } @@ -510,21 +510,21 @@ var CPDocumentUntitledCount = 0; // If we got this far and it wasn't an HTTP request, then everything is fine. if (![aResponse isKindOfClass:[CPHTTPURLResponse class]]) return; - + var statusCode = [aResponse statusCode]; - + // Nothing to do if everything is hunky dory. if (statusCode === 200) return; - + var session = aConnection.session; - + if (aConnection == _readConnection) { [aConnection cancel]; - + alert("There was an error retrieving the document."); - + objj_msgSend(session.delegate, session.didReadSelector, self, NO, session.contextInfo); } else @@ -533,23 +533,23 @@ var CPDocumentUntitledCount = 0; if (statusCode == 409) { [aConnection cancel]; - + if (confirm("There already exists a file with that name, would you like to overwrite it?")) { [_writeRequest setValue:@"true" forHTTPHeaderField:@"x-cappuccino-overwrite"]; - + [aConnection start]; } - else + else { if (session.saveOperation != CPSaveToOperation) { _changeCount += session.changeCount; [_windowControllers makeObjectsPerformSelector:@selector(setDocumentEdited:) withObject:[self isDocumentEdited]]; } - + _writeRequest = nil; - + objj_msgSend(session.delegate, session.didSaveSelector, self, NO, session.contextInfo); [self _sendDocumentSavedNotification:NO]; } @@ -564,7 +564,7 @@ var CPDocumentUntitledCount = 0; - (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)aData { var session = aConnection.session; - + // READ if (aConnection == _readConnection) { @@ -576,9 +576,9 @@ var CPDocumentUntitledCount = 0; { if (session.saveOperation != CPSaveToOperation) [self setFileURL:session.absoluteURL]; - + _writeRequest = nil; - + objj_msgSend(session.delegate, session.didSaveSelector, self, YES, session.contextInfo); [self _sendDocumentSavedNotification:YES]; } @@ -591,17 +591,17 @@ var CPDocumentUntitledCount = 0; - (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError { var session = aConnection.session; - + if (_readConnection == aConnection) objj_msgSend(session.delegate, session.didReadSelector, self, NO, session.contextInfo); - + else - { + { if (session.saveOperation != CPSaveToOperation) { _changeCount += session.changeCount; [_windowControllers makeObjectsPerformSelector:@selector(setDocumentEdited:) withObject:[self isDocumentEdited]]; - } + } _writeRequest = nil; @@ -644,9 +644,9 @@ var CPDocumentUntitledCount = 0; else if (aChangeType == CPChangeCleared) _changeCount = 0; /*else if (aChangeType == CPCHangeReadOtherContents) - - else if (aChangeType == CPChangeAutosaved)*/ - + + else if (aChangeType == CPChangeAutosaved)*/ + [_windowControllers makeObjectsPerformSelector:@selector(setDocumentEdited:) withObject:[self isDocumentEdited]]; } @@ -686,9 +686,9 @@ var CPDocumentUntitledCount = 0; { if (_hasUndoManager == aFlag) return; - + _hasUndoManager = aFlag; - + if (!_hasUndoManager) [self setUndoManager:nil]; } @@ -697,7 +697,7 @@ var CPDocumentUntitledCount = 0; - (void)_undoManagerWillCloseGroup:(CPNotification)aNotification { var undoManager = [aNotification object]; - + if ([undoManager isUndoing] || [undoManager isRedoing]) return; @@ -724,13 +724,13 @@ var CPDocumentUntitledCount = 0; - (void)setUndoManager:(CPUndoManager)anUndoManager { var defaultCenter = [CPNotificationCenter defaultCenter]; - + if (_undoManager) { [defaultCenter removeObserver:self name:CPUndoManagerDidUndoChangeNotification object:_undoManager]; - + [defaultCenter removeObserver:self name:CPUndoManagerDidRedoChangeNotification object:_undoManager]; @@ -739,17 +739,17 @@ var CPDocumentUntitledCount = 0; name:CPUndoManagerWillCloseUndoGroupNotification object:_undoManager]; } - + _undoManager = anUndoManager; - + if (_undoManager) { - + [defaultCenter addObserver:self selector:@selector(_undoManagerDidUndoChange:) name:CPUndoManagerDidUndoChangeNotification object:_undoManager]; - + [defaultCenter addObserver:self selector:@selector(_undoManagerDidRedoChange:) name:CPUndoManagerDidRedoChangeNotification @@ -775,7 +775,7 @@ var CPDocumentUntitledCount = 0; return _undoManager; } - + /* Implemented as a delegate of a CPWindow @ignore @@ -804,7 +804,7 @@ var CPDocumentUntitledCount = 0; [[CPNotificationCenter defaultCenter] postNotificationName:CPDocumentWillSaveNotification object:self]; - + [self saveToURL:_fileURL ofType:[self fileType] forSaveOperation:CPSaveOperation delegate:delegate didSaveSelector:didSaveSelector contextInfo:contextInfo]; } else @@ -862,7 +862,7 @@ var CPDocumentUntitledCount = 0; [[CPDocumentController sharedDocumentController] removeDocument:self]; } -- (void)shouldCloseWindowController:(CPWindowController)controller delegate:(id)delegate shouldCloseSelector:(SEL)selector contextInfo:(Object)info +- (void)shouldCloseWindowController:(CPWindowController)controller delegate:(id)delegate shouldCloseSelector:(SEL)selector contextInfo:(Object)info { if ([controller shouldCloseDocument] || ([_windowControllers count] < 2 && [_windowControllers indexOfObject:controller] !== CPNotFound)) [self canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(_document:shouldClose:context:) contextInfo:{delegate:delegate, selector:selector, context:info}]; @@ -879,7 +879,7 @@ var CPDocumentUntitledCount = 0; objj_msgSend(context.delegate, context.selector, aDocument, shouldClose, context.context); } -- (void)canCloseDocumentWithDelegate:(id)aDelegate shouldCloseSelector:(SEL)aSelector contextInfo:(Object)context +- (void)canCloseDocumentWithDelegate:(id)aDelegate shouldCloseSelector:(SEL)aSelector contextInfo:(Object)context { if (![self isDocumentEdited]) return [aDelegate respondsToSelector:aSelector] && objj_msgSend(aDelegate, aSelector, self, YES, context); diff --git a/AppKit/CPDocumentController.j b/AppKit/CPDocumentController.j index 401f5ec8e..481d5fe82 100644 --- a/AppKit/CPDocumentController.j +++ b/AppKit/CPDocumentController.j @@ -29,7 +29,7 @@ var CPSharedDocumentController = nil; -/*! +/*! @ingroup appkit @class CPDocumentController This class is responsible for managing an application's open documents. @@ -41,7 +41,7 @@ var CPSharedDocumentController = nil; } /*! - Returns the singleton instance of the application's document controller. If it has not + Returns the singleton instance of the application's document controller. If it has not been created yet, it will be created then returned. @return a CPDocumentController */ @@ -49,7 +49,7 @@ var CPSharedDocumentController = nil; { if (!CPSharedDocumentController) [[self alloc] init]; - + return CPSharedDocumentController; } @@ -59,11 +59,11 @@ var CPSharedDocumentController = nil; - (id)init { self = [super init]; - + if (self) { _documents = [[CPArray alloc] init]; - + if (!CPSharedDocumentController) CPSharedDocumentController = self; @@ -85,16 +85,16 @@ var CPSharedDocumentController = nil; { var index = 0, count = [_documents count]; - - for (; index < count; ++index) + + for (; index < count; ++index) { var theDocument = _documents[index]; - - if ([[theDocument fileURL] isEqual:aURL]) - return theDocument; + + if ([[theDocument fileURL] isEqual:aURL]) + return theDocument; } - - return nil; + + return nil; } /*! @@ -105,10 +105,10 @@ var CPSharedDocumentController = nil; - (void)openUntitledDocumentOfType:(CPString)aType display:(BOOL)shouldDisplay { var theDocument = [self makeUntitledDocumentOfType:aType error:nil]; - + if (theDocument) [self addDocument:theDocument]; - + if (shouldDisplay) { [theDocument makeWindowControllers]; @@ -210,7 +210,7 @@ var CPSharedDocumentController = nil; return; [aDocument makeWindowControllers]; - + if ([aContextInfo objectForKey:@"shouldDisplay"]) [aDocument showWindows]; } @@ -224,7 +224,7 @@ var CPSharedDocumentController = nil; [self openUntitledDocumentOfType:[[_documentTypes objectAtIndex:0] objectForKey:@"CPBundleTypeName"] display:YES]; } --(void)openDocument:(id)aSender +- (void)openDocument:(id)aSender { var openPanel = [CPOpenPanel openPanel]; @@ -276,17 +276,17 @@ var CPSharedDocumentController = nil; { var index = 0, count = _documentTypes.length, - + extension = [[anAbsoluteURL pathExtension] lowercaseString], starType = nil; - + for (; index < count; ++index) { var documentType = _documentTypes[index], extensions = [documentType objectForKey:@"CFBundleTypeExtensions"], extensionIndex = 0, extensionCount = extensions.length; - + for (; extensionIndex < extensionCount; ++extensionIndex) { var thisExtension = [extensions[extensionIndex] lowercaseString]; @@ -312,11 +312,11 @@ var CPSharedDocumentController = nil; for (;i < count; ++i) { var documentType = _documentTypes[i]; - + if ([documentType objectForKey:@"CPBundleTypeName"] == aType) return documentType; } - + return nil; } @@ -336,7 +336,7 @@ var CPSharedDocumentController = nil; @implementation CPDocumentController (Closing) -- (void)closeAllDocumentsWithDelegate:(id)aDelegate didCloseAllSelector:(SEL)didCloseSelector contextInfo:(Object)info +- (void)closeAllDocumentsWithDelegate:(id)aDelegate didCloseAllSelector:(SEL)didCloseSelector contextInfo:(Object)info { var context = { delegate: aDelegate,