Last active
December 15, 2015 03:58
-
-
Save rblalock/5197869 to your computer and use it in GitHub Desktop.
Dynamic styles for alloy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Override createWidget until widget styling is possible in Alloy | |
*/ | |
Alloy.createWidget = function(id, name, args) { | |
if ("undefined" != typeof name && null !== name && _.isObject(name) && !_.isString(name)) { | |
args = name; | |
name = DEFAULT_WIDGET; | |
} | |
var widget = new (require("alloy/widgets/" + id + "/controllers/" + (name || DEFAULT_WIDGET)))(args); | |
// Workaround for styling widgets until the feature is implemented in Alloy | |
if (args.styles) { | |
for(var property in args.styles) { | |
var value = args.styles[property]; | |
if (typeof value === 'object') { | |
widget[property].applyProperties(value); | |
} | |
} | |
} | |
return widget; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"#textfield": { | |
styles: { | |
textfield: { | |
width: 300, | |
hintText: "textfield widget" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Window id="window"> | |
<Widget id="textfield" src="uikit" name="textfield" /> | |
</Window> | |
</Alloy> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<TextField id="textfield" /> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment