UNPKG

janus

Version:

the two-faced application library-framework

131 lines (123 loc) 3.73 kB
// Generated by CoffeeScript 1.12.2 (function() { var from, isFunction, mutators, render, safe, slice = [].slice; from = require('../core/from'); render = require('./render'); isFunction = require('../util/util').isFunction; safe = function(x) { if (isFunction(x != null ? x.toString : void 0)) { return x.toString(); } else { return ''; } }; mutators = { attr: function(prop, data) { return function(dom, point, immediate) { if (immediate == null) { immediate = true; } return data.all.point(point).react(immediate, function(x) { return dom.attr(prop, safe(x)); }); }; }, classGroup: function(prefix, data) { return function(dom, point, immediate) { if (immediate == null) { immediate = true; } return data.all.point(point).react(immediate, function(x) { var desired, existing, i, len, ref, ref1, str; existing = (ref = (ref1 = dom.attr('class')) != null ? ref1.split(/ +/) : void 0) != null ? ref : []; desired = ''; for (i = 0, len = existing.length; i < len; i++) { str = existing[i]; if (!str.startsWith(prefix)) { desired += str + " "; } } desired += "" + prefix + (safe(x)); return dom.attr('class', desired); }); }; }, classed: function(name, data) { return function(dom, point, immediate) { if (immediate == null) { immediate = true; } return data.all.point(point).react(immediate, function(x) { return dom.toggleClass(name, x === true); }); }; }, css: function(prop, data) { return function(dom, point, immediate) { if (immediate == null) { immediate = true; } return data.all.point(point).react(immediate, function(x) { return dom.css(prop, safe(x)); }); }; }, text: function(data) { return function(dom, point, immediate) { if (immediate == null) { immediate = true; } return data.all.point(point).react(immediate, function(x) { return dom.text(safe(x)); }); }; }, html: function(data) { return function(dom, point, immediate) { if (immediate == null) { immediate = true; } return data.all.point(point).react(immediate, function(x) { return dom.html(safe(x)); }); }; }, prop: function(prop, data) { return function(dom, point, immediate) { if (immediate == null) { immediate = true; } return data.all.point(point).react(immediate, function(x) { return dom.prop(prop, x); }); }; }, render: render, on: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return function(dom, point) { return from.self().all.point(point).react(function(view) { var f_, g_, thisArgs; f_ = args[args.length - 1]; g_ = function(event) { return f_(event, view.subject, view, view.artifact()); }; thisArgs = args.slice(0, -1); thisArgs.push(g_); this.start = ((function(_this) { return function() { dom.on.apply(dom, thisArgs); return _this.stop = (function() { dom.off(thisArgs[0], g_); this.constructor.prototype.stop.call(this); }); }; })(this)); }); }; } }; module.exports = mutators; }).call(this);