janus
Version:
the two-faced application library-framework
97 lines (83 loc) • 3.62 kB
JavaScript
// Generated by CoffeeScript 1.12.2
(function() {
var Varying, from, fromApp, fromSelf, getView, getView_subject, getView_subjectContext, getView_subjectCriteria, getView_subjectOptions, pointify, render;
Varying = require('../core/varying').Varying;
from = require('../core/from');
pointify = function(x, point) {
var ref, ref1;
return (ref = x != null ? (ref1 = x.all) != null ? typeof ref1.point === "function" ? ref1.point(point) : void 0 : void 0 : void 0) != null ? ref : Varying.of(x);
};
getView = Varying.lift(function(app, subject, context, criteria, options, parent) {
return app.view(subject, Object.assign({
context: context
}, criteria), options, parent);
});
getView_subject = Varying.lift(function(app, subject, parent) {
return app.view(subject, void 0, void 0, parent);
});
getView_subjectContext = Varying.lift(function(app, subject, context, parent) {
return app.view(subject, {
context: context
}, void 0, parent);
});
getView_subjectCriteria = Varying.lift(function(app, subject, criteria, parent) {
return app.view(subject, criteria, void 0, parent);
});
getView_subjectOptions = Varying.lift(function(app, subject, options, parent) {
return app.view(subject, void 0, options, parent);
});
fromApp = from.app().all;
fromSelf = from.self().all;
render = function(data, args) {
var result;
if (args == null) {
args = {};
}
result = function(dom, point, immediate) {
var view;
if (immediate == null) {
immediate = true;
}
view = (args.context == null) && (args.criteria == null) && (args.options == null) ? getView_subject(fromApp.point(point), data.all.point(point), fromSelf.point(point)) : (args.criteria == null) && (args.options == null) ? getView_subjectContext(fromApp.point(point), data.all.point(point), pointify(args.context, point), fromSelf.point(point)) : (args.context == null) && (args.options == null) ? getView_subjectCriteria(fromApp.point(point), data.all.point(point), pointify(args.criteria, point), fromSelf.point(point)) : (args.context == null) && (args.criteria == null) ? getView_subjectOptions(fromApp.point(point), data.all.point(point), pointify(args.options, point), fromSelf.point(point)) : getView(fromApp.point(point), data.all.point(point), pointify(args.context, point), pointify(args.criteria, point), pointify(args.options, point), fromSelf.point(point));
return view.react(true, function(view_) {
var children, ref, runBefore;
runBefore = this.view != null;
if (this.view == null) {
this.view = new Varying();
}
if ((ref = this.view.get()) != null) {
ref.destroy();
}
children = dom.children();
if ((immediate === false) && (runBefore === false) && (children.length > 0)) {
if (view_ != null) {
view_.attach(children);
}
} else {
dom.empty();
if (view_ != null) {
dom.append(view_.artifact());
}
}
return this.view.set(view_);
});
};
result.context = function(context) {
return render(data, Object.assign({}, args, {
context: context
}));
};
result.criteria = function(criteria) {
return render(data, Object.assign({}, args, {
criteria: criteria
}));
};
result.options = function(options) {
return render(data, Object.assign({}, args, {
options: options
}));
};
return result;
};
module.exports = render;
}).call(this);