{I" class:ETI"ProcessedAsset;FI"logical_path;TI"outpost/index_manager.js;FI" pathname;TI"`/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/index_manager.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+d}RI" length;Ti I" digest;TI"%989422a85c94109521529b3c60683e31;FI" source;TI" (function() { outpost.IndexManager = (function() { IndexManager.prototype.DefaultOptions = { cellFinder: "*[data-updatable='true']" }; function IndexManager(baseUrl, options) { var cell, _i, _len, _ref; this.baseUrl = baseUrl; if (options == null) { options = {}; } this.options = _.defaults(options, this.DefaultOptions); _ref = $(this.options.cellFinder); for (_i = 0, _len = _ref.length; _i < _len; _i++) { cell = _ref[_i]; new outpost.QuickEditCell($(cell), this.baseUrl); } } return IndexManager; })(); outpost.QuickEditCell = (function() { QuickEditCell.prototype.defaults = { formTemplate: JST["outpost/templates/data_field"], attribute: "data-attribute", id: "data-id", highlightColor: "#dff0d8", highlightTime: 2000 }; function QuickEditCell(el, baseUrl, options) { this.el = el; if (options == null) { options = {}; } this.options = _.defaults(options, this.defaults); this.value = null; this.keyup = false; this.attribute = this.el.attr(this.options.attribute); this.id = this.el.attr(this.options.id); this.url = "" + baseUrl + "/" + this.id; this.ajaxOptions = { dataType: 'json', url: this.url }; this.el.on({ click: (function(_this) { return function(event) { return _this.buildForm(); }; })(this) }); this.el.on({ keyup: (function(_this) { return function(event) { if (event.keyCode === 13) { _this.keyup = true; return _this.updateData(event); } }; })(this), blur: (function(_this) { return function(event) { if (!_this.keyup) { return _this.updateData(event); } }; })(this) }, 'input'); } QuickEditCell.prototype.buildForm = function(event) { return $.ajax(_.extend(this.ajaxOptions, { type: "GET", success: (function(_this) { return function(data, status, xhr) { _this.value = data[_this.attribute]; _this.el.html(_this.options.formTemplate({ attribute: _this.attribute, id: _this.id, inputValue: _this.value })); return _this.el.find("input").focus(); }; })(this) })); }; QuickEditCell.prototype.updateData = function(event) { var input, value; input = $(event.target); value = input.val(); if (value === this.value) { this.el.html(value); this.keyup = false; return; } return $.ajax(_.extend(this.ajaxOptions, { type: "PUT", data: { data_point: { data_value: value } }, success: (function(_this) { return function(data, status, xhr) { _this.el.html(value); _this.el.effect("highlight", { color: _this.options.highlightColor }, _this.options.highlightTime); return _this.keyup = false; }; })(this) })); }; return QuickEditCell; })(); }).call(this); ;TI"dependency_digest;TI"%e21d8ae179cc66addb66b38b86f921d5;FI"required_paths;T[I"`/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/index_manager.js.coffee;FI"dependency_paths;T[{I" path;TI"`/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/index_manager.js.coffee;FI" mtime;TI"2013-11-08T18:26:44-08:00;TI" digest;TI"%c892132ceb647820168a5727aaec8319;FI" _version;TI"%64b22cf9f770209c1e0beb31754a8cbc;F