This idea got triggered back in the day when trying to explain Custom Behavior as Tweets. The idea stuck with me in a literal form…
Mostly I use Hype these days for Widgets in CMS-Projects so I thought I share the concept of a unified communication pipeline across individual widget. So I recreated LocalConnection from the Flash-days with a little Twitter-twist and named it GlobalBehavior:
Hint: The code is an extension. It enables all Hype-Widget loaded on the same page to form a broadcast network. Inside the widget are just plain Custom Behavior calls following the rules mentioned in the example. The code from the JS-files below can also just be pasted into the Head-HTML.
- Link the runtime below into your head …
- Another way is to drag it into your resource folder (use the minified version).
- Or you can copy and paste the code into Head-HTML in your file (full or minified) but then don’t forget to wrap in in a script-tag …
You only need one of the methods not all!
1.0 Initial release #-syntax, @-syntax based on Hype Observer Pattern
1.1 Added callbacks in JS hypedocument.onGlobalBehavior
1.2 Added iFrame (onedirectional), onedirectional postMessage
1.3 Refactored code to Revealing Module Pattern, compiled against Closure-compiler, Bidirectional postMessage (Bubble Up, Bubble Down, Bubble Branching)
1.4 Refactored to new naming and interface, corrected to american english
1.5 Fixed a bug with iFrame propagation and added a “Singleton” check
1.6 Added Custom Behavior Ticker feature, code cleanup