jverkoey/nimbus — pull request #342 by djMax (2013-02-20 12:42:58+00:00)
Title: Relative positioning, localized string support, and Chameleon updates for strings

Four main components here:

1) Relative positioning for CSS. Using the -mobile-relative property with an element id or .first/.last/.next/.prev and margin-top/bottom/left/right, one can position elements by absolute pixel units or percentage of the specified element. "auto" will align centers on that dimension.

2) Localized string support. Using the -mobile-text-key property, a CSS file can specify the name of a localized string entry and the engine will apply that to the title/text property as appropriate. The engine for resolving keys to strings is pluggable with a default that just calls NSLocalizedString.

3) Chameleon support for strings files. When the strings file changes, the app will pick it up and the default string resolver will use that file first before falling back on NSLocalizedString. Also, with a special prefix on that file, the engine will show all the string key names in the interface instead of the value. This makes it easy for a copywriter or tester to see exactly what string is used where, and can be toggled at runtime multiple times. In production since Chameleon isn't used, there is essentially zero overhead since we just check for non-nil overrides (which will never be non-nil). There may be some work left here to rationalize projects which have multiple strings files. At the moment, if you change any language file, the interface is likely to change to that language file. I think this is a feature, but could be convinced it's a bug because it doesn't fully switch the app into that locale.

4) A small but powerful styled view builder that you will love or hate. It allows complex view construction with a javascript like syntax where each element of the array is interpreted according to its type - a view starts a new "directive", a string with a # means the element id, string with a . means the CSS class, any other string is the accessibility label. A localized string (NIUserInterfaceString) will be set as the title/text and then update via Chameleon, an NSInvocation will be the touchupinside target, and an NSArray will construct a set of subviews. You can see in the sample app it's taken about 50 lines of boilerplate code down to 10. I think I might add NSDictionary suppor for folks who have a religious aversion to javascript like syntax with more intentional key/value mapping - but it can support both at the same time.

Also, supports maxHeight, maxWidth, button image adjustment. Added addCssClass/removeCssClass for runtime modification of characteristics. For example you can remove/add a class inside an animation block and it will animate the change. To do all this I had to deprecate the applyRuleSet method in favor of applyRuleSet:inDOM:, but it should be backwards compatible.

Updated the sample app to use all this stuff.