Allow class to be used with +themeForView, fix to image load notification

This commit is contained in:
Aparajita Fishman
2011-05-05 08:06:31 -04:00
parent a0a7b126ab
commit 9c181cc9c9
2 changed files with 14 additions and 7 deletions
+13 -6
View File
@@ -86,7 +86,8 @@ var CPThemesByName = { },
}
/*!
Returns the closest matching theme for a given view. The matching proceeds as follows:
Returns the closest matching theme for a given view or view class.
The matching proceeds as follows:
- The default theme class name for the class is retrieved.
- Starting with the last loaded theme and proceeding towards the default theme,
@@ -94,16 +95,22 @@ var CPThemesByName = { },
- If the theme defines the class name, that theme is returned.
- If no themes match, the default theme is returned.
@param aView The view to match with a theme
@return The first matching theme
@param aViewOrClass The view or view class to match with a theme
@return The first matching theme
*/
+ (CPTheme)themeForView:(CPView)aView
+ (CPTheme)themeForView:(id)aViewOrClass
{
var count = CPThemeNamesByInheritance.length,
themeClass = [aView themeClass];
var themeClass = nil;
if (class_isMetaClass(aViewOrClass.isa))
themeClass = [aViewOrClass defaultThemeClass];
else
themeClass = [aViewOrClass themeClass];
if (themeClass)
{
var count = CPThemeNamesByInheritance.length;
while (count--)
{
var theme = CPThemesByName[CPThemeNamesByInheritance[count]];
+1 -1
View File
@@ -294,7 +294,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
return;
if ([_image delegate] === self)
[[CPNotificationCenter defaultCenter] removeObserver:_image name:CPImageDidLoadNotification object:_image];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:_image];
_image = anImage;
_flags |= _CPImageAndTextViewImageChangedFlag;