Last active
August 29, 2015 13:58
-
-
Save designeng/10068503 to your computer and use it in GitHub Desktop.
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
define [ | |
"underscore" | |
"when" | |
], (_, When) -> | |
return (options) -> | |
extend = (componentDefinition, wire) -> | |
When.promise (resolve) -> | |
if !componentDefinition.options.with | |
throw "no 'with' option specified" | |
if componentDefinition.options.module | |
wire.loadModule(componentDefinition.options.module).then (Module) -> | |
_keys = _.keys componentDefinition.options.with | |
_values = _.values componentDefinition.options.with | |
class Extended extends Module | |
# no new fields yet | |
i = 0 | |
for key in _keys | |
Extended::[key] = _values[i] | |
i++ | |
resolve Extended | |
, (error) -> | |
reject error | |
else | |
throw "no 'module' option specified" | |
extendWithFactory = (resolver, componentDefinition, wire) -> | |
extend(componentDefinition, wire).then (extended) -> | |
resolver.resolve(extended) | |
, (error) -> | |
console.error error.stack | |
context: | |
ready: (resolver, wire) -> | |
resolver.resolve() | |
factories: | |
extend: extendWithFactory |
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
switchItemView: | |
extend: | |
module: "controls/switch/item/switchItemView" | |
with: | |
itemSelectedClass: "switchItem__selected" | |
itemFocusedClass: "switchItem__focused" | |
switcher: | |
create: | |
module: "controls/switch/switchControl" | |
args: | |
name: "switcher" | |
properties: | |
itemView: {$ref: 'switchItemView'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment