phorge/webroot/rsrc/externals/javelin/ext/view/ViewVisitor.js
epriestley 95f57756aa Move all external JS into webroot/rsrc/externals
Summary:
Currently, Celerity map rebuilds on Windows don't put Stripe or Raphael into the map. Move them into `webroot/rsrc/externals/` so they get picked up.

At some point we should maybe let the mapper load resources from mulitple locations, but this is more straightforward for now.

See https://github.com/facebook/phabricator/issues/294

Test Plan: Rebuilt map, verified Burnup Rate + Stripe work.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D5661
2013-04-11 10:06:05 -07:00

37 lines
1.1 KiB
JavaScript

/**
* @provides javelin-view-visitor
* @requires javelin-install
* javelin-util
*
* Add new behaviors to views without changing the view classes themselves.
*
* Allows you to register specific visitor functions for certain view classes.
* If no visitor is registered for a view class, the default_visitor is used.
* If no default_visitor is invoked, a no-op visitor is used.
*
* Registered visitors should be functions with signature
* function(view, results_of_visiting_children) {}
* Children are visited before their containing parents, and the return values
* of the visitor on the children are passed to the parent.
*
*/
JX.install('ViewVisitor', {
construct: function(default_visitor) {
this._visitors = {};
this._default = default_visitor || JX.bag;
},
members: {
_visitors: null,
_default: null,
register: function(cls, visitor) {
this._visitors[cls] = visitor;
},
visit: function(view, children) {
var visitor = this._visitors[cls] || this._default;
return visitor(view, children);
}
}
});