{I" class:ETI"ProcessedAsset;FI"logical_path;TI"transponder/presenter.js;FI" pathname;TI"‚/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/transponder-1.0.0/lib/assets/javascripts/transponder/presenter.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+¢z¿TI" length;TiI" digest;TI"%1d2f261b80b37ad4eb135ccd753e05b9;FI" source;TI"(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); ;TI"dependency_digest;TI"%2029095ec8847d16665044bd208e75fc;FI"required_paths;T[I"‚/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/transponder-1.0.0/lib/assets/javascripts/transponder/presenter.coffee;FI"dependency_paths;T[{I" path;TI"‚/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/transponder-1.0.0/lib/assets/javascripts/transponder/presenter.coffee;F@I"2015-01-21T17:08:34+07:00;T@I"%ed4ea20de8c79cfdc41f01b9df436f3d;FI" _version;TI"%b6ac50cb4d1b14f34051c36782faf205;F