Sometimes you'll have objects that manage state along with event handling. This happens frequently in MVC apps. Let's start with a messy example:
var Launcher = function(rocket) {
this.rocket = rocket
}
Launcher.prototype.isReady = function() {
| // Add modules globally | |
| (function () { | |
| var cfg = window.YUI_config || {}; | |
| cfg.modules = cfg.modules || {}; | |
| // Add external dependencies | |
| cfg.modules.externalDependency = { | |
| fullpath: '/path/to/script.js', | |
| requires: ['node', 'event'] |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| /* Coded by @passcod, MIT Licensed: passcod.mit-license.org | |
| Adapted from @shojberg's cssarrowplease.com | |
| */ | |
| @mixin arrow-box( $selector: ".arrow-box", | |
| $position: "top", | |
| $arrow_size: 10px, | |
| $border_width: 2px, | |
| $box_color: #333, | |
| $border_color: #ccc) { | |
| var parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.hostname; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" | |
| parser.host; // => "example.com:3000" |
| YUI({ | |
| modules: { | |
| 'router': { | |
| fullpath: 'router-fixes.js', | |
| requires: ['array-extras', 'base-build', 'history'], | |
| optional: ['querystring-parse'] | |
| } | |
| } | |
| }).use('app-base', 'app-transitions', function (Y) { |
| YUI.add('router', function(Y) { | |
| /** | |
| Provides URL-based routing using HTML5 `pushState()` or the location hash. | |
| @module app | |
| @submodule router | |
| @since 3.4.0 | |
| **/ |
| for i in $HOME/local/*; do | |
| [ -d $i/bin ] && PATH="${i}/bin:${PATH}" | |
| [ -d $i/sbin ] && PATH="${i}/sbin:${PATH}" | |
| [ -d $i/include ] && CPATH="${i}/include:${CPATH}" | |
| [ -d $i/lib ] && LD_LIBRARY_PATH="${i}/lib:${LD_LIBRARY_PATH}" | |
| [ -d $i/lib ] && LD_RUN_PATH="${i}/lib:${LD_RUN_PATH}" | |
| # uncomment the following if you use macintosh | |
| # [ -d $i/lib ] && DYLD_LIBRARY_PATH="${i}/lib:${DYLD_LIBRARY_PATH}" | |
| [ -d $i/lib/pkgconfig ] && PKG_CONFIG_PATH="${i}/lib/pkgconfig:${PKG_CONFIG_PATH}" | |
| [ -d $i/share/man ] && MANPATH="${i}/share/man:${MANPATH}" |
| /* | |
| This is the Node.js file, it will export files directly to | |
| `tdp-bundle-min.js` which obviously won't work well for you! | |
| This relies on having a YUI_config that can be parsed and | |
| passed into Y.Loader. Everything you need should be in this | |
| gist, though. You may need to change the path to your | |
| YUI_config file (mine is named `bundle.js`). | |
| However, it's an easy change, just scroll down and edit it. |
| YUI.add('paged-model-list', function(Y) { | |
| var NS = Y.namespace('BackOffice.Model'), | |
| Lang = Y.Lang, | |
| isString = Lang.isString, | |
| isArray = Lang.isArray, | |
| isObject = Lang.isObject; | |
| function PagedList() { } | |
| PagedList.prototype = { |