mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-16 03:30:42 +00:00
Merge branch 'master' into tableview
This commit is contained in:
commit
b8755c113f
3 files changed
+77
-1
No files matched your search
@@ -1018,3 +1018,43 @@ var CPDOMEventStop = function(aDOMEvent)
|
||||
CPSharedDOMWindowBridge._DOMFocusElement.blur();
|
||||
}
|
||||
}
|
||||
|
||||
function CPWindowObjectList()
|
||||
{
|
||||
var bridge = [CPDOMWindowBridge sharedDOMWindowBridge],
|
||||
levels = bridge._windowLevels,
|
||||
layers = bridge._windowLayers,
|
||||
levelCount = levels.length,
|
||||
windowObjects = [];
|
||||
|
||||
while (levelCount--)
|
||||
{
|
||||
var windows = [layers objectForKey:levels[levelCount]]._windows,
|
||||
windowCount = windows.length;
|
||||
|
||||
while (windowCount--)
|
||||
windowObjects.push(windows[windowCount]);
|
||||
}
|
||||
|
||||
return windowObjects;
|
||||
}
|
||||
|
||||
function CPWindowList()
|
||||
{
|
||||
var bridge = [CPDOMWindowBridge sharedDOMWindowBridge],
|
||||
levels = bridge._windowLevels,
|
||||
layers = bridge._windowLayers,
|
||||
levelCount = levels.length,
|
||||
windowNumbers = [];
|
||||
|
||||
while (levelCount--)
|
||||
{
|
||||
var windows = [layers objectForKey:levels[levelCount]]._windows,
|
||||
windowCount = windows.length;
|
||||
|
||||
while (windowCount--)
|
||||
windowNumbers.push([windows[windowCount] windowNumber]);
|
||||
}
|
||||
|
||||
return windowNumbers;
|
||||
}
|
||||
@@ -488,7 +488,7 @@
|
||||
*/
|
||||
- (unsigned)indexOfObject:(id)anObject sortedByDescriptors:(CPArray)descriptors
|
||||
{
|
||||
[self indexOfObject:anObject sortedByFunction:function(lhs, rhs)
|
||||
return [self indexOfObject:anObject sortedByFunction:function(lhs, rhs)
|
||||
{
|
||||
var i = 0,
|
||||
count = [descriptors count],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@import <Foundation/CPArray.j>
|
||||
@import <Foundation/CPString.j>
|
||||
@import <Foundation/CPNumber.j>
|
||||
@import <Foundation/CPSortDescriptor.j>
|
||||
|
||||
@implementation CPArrayTest : OJTestCase
|
||||
|
||||
@@ -92,4 +93,39 @@
|
||||
|
||||
[self assert:array equals:[@"one", @"two", @"four"]];
|
||||
}
|
||||
|
||||
- (void)testIndexOfObjectSortedByFunction
|
||||
{
|
||||
var array = [0, 1, 2, 3, 4, 7];
|
||||
|
||||
[self assert:[array indexOfObject:3 sortedByFunction:function(a, b){ return a - b; }] equals:3];
|
||||
[self assert:[[array arrayByReversingArray] indexOfObject:3 sortedByFunction:function(a, b){ return b - a; }] equals:2];
|
||||
}
|
||||
|
||||
- (void)testIndexOfObjectSortedByDescriptors
|
||||
{
|
||||
var array = [0, 1, 2, 3, 4, 7];
|
||||
|
||||
[self assert:[array indexOfObject:3
|
||||
sortedByDescriptors:[[[CPSortDescriptor alloc] initWithKey:@"intValue" ascending:YES]]]
|
||||
equals:3];
|
||||
|
||||
[self assert:[[array arrayByReversingArray] indexOfObject:3
|
||||
sortedByDescriptors:[[[CPSortDescriptor alloc] initWithKey:@"intValue" ascending:NO]]]
|
||||
equals:2];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPArray (reverse)
|
||||
|
||||
- (CPArray)arrayByReversingArray
|
||||
{
|
||||
var a = [];
|
||||
for (i = length - 1; i>0; --i)
|
||||
a.push(self[i]);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user