Fixed: Code formatting

This commit is contained in:
Martin Carlberg committed 2015-10-27 09:03:26 +01:00
1 parent ed12bae6aa
commit 68f45beb20
3 files changed
+28 -16

No files matched your search

+16
View File
@@ -326,6 +326,7 @@ function ThemeState(stateNames)
{
if (!stateNames.hasOwnProperty(key))
continue;
if (key !== 'normal')
{
this._stateNames[key] = true;
@@ -343,8 +344,10 @@ function ThemeState(stateNames)
this._stateNameString = stateNameKeys[0];
var stateNameLength = stateNameKeys.length;
for (var stateIndex = 1; stateIndex < stateNameLength; stateIndex++)
this._stateNameString = this._stateNameString + "+" + stateNameKeys[stateIndex];
this._stateNameCount = stateNameLength;
}
@@ -397,6 +400,7 @@ ThemeState.prototype.without = function(aState)
if (firstTransform)
{
result = firstTransform[aState._stateNameString];
if (result)
return result;
}
@@ -430,6 +434,7 @@ ThemeState.prototype.and = function(aState)
if (firstTransform)
{
result = firstTransform[aState._stateNameString];
if (result)
return result;
}
@@ -452,11 +457,13 @@ ThemeState._cacheThemeState = function(aState)
{
// We do this caching so themeState equality works. Basically, doing CPThemeState('foo+bar') === CPThemeState('bar', 'foo') will return true.
var themeState = CPThemeStates[String(aState)];
if (themeState === undefined)
{
themeState = aState;
CPThemeStates[String(themeState)] = themeState;
}
return themeState;
}
@@ -474,14 +481,17 @@ function CPThemeState()
throw "CPThemeState() must be called with at least one string argument";
var themeState;
if (arguments.length === 1 && typeof arguments[0] === 'string')
{
themeState = CPThemeStates[arguments[0]];
if (themeState !== undefined)
return themeState;
}
var stateNames = {};
for (var argIndex = 0; argIndex < arguments.length; argIndex++)
{
if (arguments[argIndex] === [CPNull null] || !arguments[argIndex])
@@ -493,12 +503,14 @@ function CPThemeState()
{
if (!arguments[argIndex]._stateNames.hasOwnProperty(stateName))
continue;
stateNames[stateName] = true;
}
}
else
{
var allNames = arguments[argIndex].split('+');
for (var nameIndex = 0; nameIndex < allNames.length; nameIndex++)
stateNames[allNames[nameIndex]] = true;
}
@@ -580,6 +592,7 @@ CPThemeStateNormalString = String(CPThemeStateNormal);
_cache = { };
_name = aName;
_defaultValue = aDefaultValue;
if (aDefaultAttribute)
_themeDefaultAttribute = aDefaultAttribute;
}
@@ -621,10 +634,12 @@ CPThemeStateNormalString = String(CPThemeStateNormal);
if (values != null)
{
values = [values copy];
if (shouldRemoveValue)
[values removeObjectForKey:String(aState)];
else
[values setObject:aValue forKey:String(aState)];
attribute._values = values;
}
else if (!shouldRemoveValue)
@@ -714,6 +729,7 @@ CPThemeStateNormalString = String(CPThemeStateNormal);
var mergedAttribute = [[_CPThemeAttribute alloc] initWithName:_name defaultValue:_defaultValue defaultAttribute:_themeDefaultAttribute];
mergedAttribute._values = [_values copy];
if (anAttribute._values)
mergedAttribute._values ? [mergedAttribute._values addEntriesFromDictionary:anAttribute._values] : [anAttribute._values copy];
+8 -6
View File
@@ -231,14 +231,15 @@ var ItemSizes = { },
value = attributeValueState[1],
state = attributeValueState[2];
if (state) {
if (state)
{
if (state.isa && [state isKindOfClass:CPArray])
[aView setValue:value forThemeAttribute:attribute inStates:state];
else
[aView setValue:value forThemeAttribute:attribute inState:state];
} else {
[aView setValue:value forThemeAttribute:attribute];
}
else
[aView setValue:value forThemeAttribute:attribute];
}
}
@@ -307,14 +308,15 @@ var ItemSizes = { },
}
}
if (state) {
if (state)
{
if (state.isa && [state isKindOfClass:CPArray])
[aView setValue:value forThemeAttribute:attribute inStates:state];
else
[aView setValue:value forThemeAttribute:attribute inState:state];
} else {
[aView setValue:value forThemeAttribute:attribute];
}
else
[aView setValue:value forThemeAttribute:attribute];
}
}
}
+4 -10
View File
@@ -89,9 +89,8 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey",
aState = [states objectAtIndex:--i];
while (i > 0)
{
aState = aState.and([states objectAtIndex:--i]);
}
return _themeState.hasThemeState(aState);
}
@@ -118,6 +117,7 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey",
#endif
var oldThemeState = _themeState;
_themeState = _themeState.without(aState);
if (oldThemeState === _themeState)
@@ -132,9 +132,8 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey",
aState = [states objectAtIndex:--i];
while (i > 0)
{
aState = aState.and([states objectAtIndex:--i]);
}
return [self setThemeState:aState];
}
@@ -144,9 +143,8 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey",
aState = [states objectAtIndex:--i];
while (i > 0)
{
aState = aState.and([states objectAtIndex:--i]);
}
return [self unsetThemeState:aState];
}
@@ -316,9 +314,7 @@ var NULL_THEME = {};
aState = [states objectAtIndex:--i];
while (i > 0)
{
aState = aState.and([states objectAtIndex:--i]);
}
var themeAttr = _themeAttributes && _themeAttributes[aName];
@@ -359,9 +355,7 @@ var NULL_THEME = {};
aState = [states objectAtIndex:--i];
while (i > 0)
{
aState = aState.and([states objectAtIndex:--i]);
}
var themeAttr = _themeAttributes && _themeAttributes[aName];