{I" class:ETI"BundledAsset;FI"logical_path;TI"transponder.js;FI" pathname;TI"€/Users/zacksiri/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/transponder-0.10.2/lib/assets/javascripts/transponder.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+ªà³RI" length;Ti I" digest;TI"%e54ba7672067e702e13cf4f64ff76000;FI" source;TI" (function() { window.Transponder = { buildEvent: function(array) { var eventType; eventType = array.filter(function(val) { return typeof val !== 'undefined' && val !== null; }); return eventType.join(':'); }, init: function() { Transponder.eh = new Transponder.Error(); Transponder.req = new Transponder.Request(); return Transponder.res = new Transponder.Response(); } }; }).call(this); (function() { Transponder.Error = (function() { Error.prototype.response = null; function Error() { var doc; doc = $(document); doc.ajaxError(this.handleError); } Error.prototype.handleError = function(event, xhr, settings, error) { var eventType; if (xhr.responseText !== "") { this.response = JSON.parse(xhr.responseText); eventType = Transponder.buildEvent(['ujs', this.response.module, this.response.controller, this.response.action]); return $(document).trigger(eventType, this.response); } }; return Error; })(); Transponder.InvalidService = (function() { function InvalidService(message) { this.message = message; this.name = "InvalidService"; } return InvalidService; })(); }).call(this); (function() { Transponder.Request = (function() { Request.prototype.url = ''; function Request() { $(document).on('ajax:beforeSend', (function(_this) { return function(event, xhr, settings) { _this.url = ''; return _this.url = settings.url; }; })(this)); } Request.prototype.objectifyParams = function() { if (this.url.split('?').length === 2) { return JSON.parse('{"' + this.url.split('?')[1].replace(/&/g, "\",\"").replace(/\=/g, "\":\"") + '"}'); } else { return {}; } }; return Request; })(); }).call(this); (function() { Transponder.Response = (function() { Response.prototype.payload = {}; function Response() { $(document).ajaxComplete((function(_this) { return function(event, xhr, status) { var content, element, event_name; if (xhr.getResponseHeader('Content-Type') === 'application/transmission') { _this.payload.raw = JSON.parse(_this.cleanContent(xhr.responseText)); element = _this.payload.raw[0]; event_name = _this.payload.raw[1]; content = _this.payload.raw[2]; return $(element).trigger(event_name, content); } }; })(this)); } Response.prototype.cleanContent = function(content) { return content.replace(/'/g, '"'); }; return Response; })(); }).call(this); (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; Transponder.Presenter = (function() { Presenter.prototype.actions = ['new', 'index', 'show', 'update', 'edit', 'create', 'destroy']; Presenter.prototype.params = {}; Presenter.prototype.presenterName = null; Presenter.prototype.module = null; Presenter.prototype.modelName = null; Presenter.prototype.element = null; Presenter.prototype.response = null; function Presenter(options) { var action, doc, events, _i, _len, _ref; if (options == null) { options = {}; } this.runAction = __bind(this.runAction, this); if (!options.presenterName) { options.presenterName = this.presenterName; } if (!options.module) { options.module = this.module; } if (!options.actions) { options.actions = this.actions; } doc = $(document); events = []; _ref = options.actions; for (_i = 0, _len = _ref.length; _i < _len; _i++) { action = _ref[_i]; events.push(Transponder.buildEvent(['ujs', options.module, options.presenterName, action])); } doc.on(events.join(' '), this.runAction); } Presenter.prototype.elify = function(event, response) { if (this.response.errors) { if (this.response.id) { return "#" + this.response.model_name + "_" + this.response.id; } else { return "#new_" + this.response.model_name; } } else { return "" + event.target.localName + "#" + event.target.id; } }; Presenter.prototype.beforeFilter = function(event, response) { this.response = response; this.element = this.elify(event, response); return this.params = Transponder.req.objectifyParams(); }; Presenter.prototype.runAction = function(event, response) { this.beforeFilter(event, response); if (this.response.errors) { this.errorOut(this.response.action); } else { this[event.type.split(':').pop()](); } return this.afterFilter(event, response); }; Presenter.prototype.afterFilter = function(event, response) {}; Presenter.prototype.triggerEmpty = function(eventName) { return console.log("" + eventName + " triggered! Override this action in your own presenter"); }; Presenter.prototype.errorOut = function(action) { return this.error[action](this.response.errors, this.element); }; Presenter.prototype.index = function() { return this.triggerEmpty('Index'); }; Presenter.prototype.show = function() { return this.triggerEmpty('Show'); }; Presenter.prototype["new"] = function() { return this.triggerEmpty('New'); }; Presenter.prototype.edit = function() { return this.triggerEmpty('Edit'); }; Presenter.prototype.update = function() { return this.triggerEmpty('Update'); }; Presenter.prototype.create = function() { return this.triggerEmpty('Create'); }; Presenter.prototype.destroy = function() { return this.triggerEmpty('Destroy'); }; Presenter.prototype.error = { triggerEmptyError: function(eventName) { return console.log("Error " + eventName + " triggered! Override this action in your own presenter"); }, index: function(errors, element) { return this.triggerEmptyError('Index'); }, show: function(errors, element) { return this.triggerEmptyError('Show'); }, "new": function(errors, element) { return this.triggerEmptyError('New'); }, edit: function(errors, element) { return this.triggerEmptyError('Edit'); }, update: function(errors, element) { return this.triggerEmptyError('Update'); }, create: function(errors, element) { return this.triggerEmptyError('Create'); }, destroy: function(errors, element) { return this.triggerEmptyError('Destroy'); } }; return Presenter; })(); }).call(this); (function() { Transponder.Service = (function() { Service.prototype.serviceName = null; Service.prototype.element = null; Service.prototype.module = null; function Service() { var serviceEvent, _this; if (this.serviceName == null) { throw new Transponder.InvalidService('no service name specified.'); } _this = this; serviceEvent = "" + _this.module + ":services:" + _this.serviceName; $(document).on(serviceEvent, function(e) { var service; service = _this.serviceName; return $("." + service + ":not(" + service + "_active)").each(function(i, e) { _this.element = $(this); _this.element.addClass("" + service + "_active"); return _this.serve(); }); }); } Service.prototype.serve = function() {}; return Service; })(); }).call(this); (function() { new Transponder.init(); }).call(this); (function() { }).call(this); ;TI"required_assets_digest;TI"%4c4ad1cb9184e4e12884564a7016e66a;FI" _version;TI"%a56df69ef97ba4d9f1a23bf9b0add58a;F