75 lines
1.1 KiB
Stylus
75 lines
1.1 KiB
Stylus
|
_selector_maps = {}
|
||
|
_catched = {}
|
||
|
|
||
|
throw(id, callback)
|
||
|
if id in _selector_maps
|
||
|
hook = _selector_maps[id]
|
||
|
else
|
||
|
hook = {}
|
||
|
|
||
|
hook[selector()] = callback
|
||
|
_selector_maps[id] = hook
|
||
|
|
||
|
catch(id, params)
|
||
|
if selector() in _catched
|
||
|
_catches = _catched[selector()]
|
||
|
else
|
||
|
_catches = {}
|
||
|
|
||
|
_catches[id] = params
|
||
|
_catched[selector()] = _catches
|
||
|
|
||
|
_generate_hooks()
|
||
|
for catched_selector, config in _catched
|
||
|
for id, parameter in config
|
||
|
if id in _selector_maps
|
||
|
hook = _selector_maps[id]
|
||
|
for thrown_selector, callback in hook
|
||
|
{thrown_selector}{catched_selector}
|
||
|
callback(parameter)
|
||
|
|
||
|
|
||
|
red()
|
||
|
color red
|
||
|
catch('button', green)
|
||
|
catch('field', red)
|
||
|
|
||
|
field()
|
||
|
display inline
|
||
|
padding 10px
|
||
|
border-bottom 2px solid blue
|
||
|
throw('field', @(){
|
||
|
border-bottom 2px solid red
|
||
|
color blue
|
||
|
})
|
||
|
|
||
|
button()
|
||
|
padding 5px
|
||
|
background-color orange
|
||
|
border 1px solid black
|
||
|
display inline
|
||
|
throw('button', @(c){color c})
|
||
|
|
||
|
.bluebutton
|
||
|
red()
|
||
|
button()
|
||
|
|
||
|
.button
|
||
|
button()
|
||
|
|
||
|
.wred
|
||
|
red()
|
||
|
|
||
|
.field
|
||
|
field()
|
||
|
|
||
|
.wurst
|
||
|
.field
|
||
|
field()
|
||
|
red()
|
||
|
|
||
|
.debug
|
||
|
--one _selector_maps
|
||
|
--two _catched
|
||
|
|
||
|
_generate_hooks()
|