{I" class:EFI"ProcessedAsset;FI"logical_path;FI"outpost/date_time_input.js;TI" pathname;FI"b/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/date_time_input.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;Fl+d}RI" length;FiI" digest;F"%0530d96848bac3486a2d5ada2640f9b4I" source;FI"(function() { $(function() { outpost.DateTimeInput.buildDateTimeInputs($("form")); return outpost.DateTimeInput.buildDateInputs($("form")); }); outpost.DateTimeInput = (function() { DateTimeInput.buildDateTimeInputs = function(els) { var wrapper, _i, _len, _ref, _results; _ref = $("div.datetime", els); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { wrapper = _ref[_i]; _results.push(new outpost.DateTimeInput({ wrapper: wrapper })); } return _results; }; DateTimeInput.buildDateInputs = function(els) { var wrapper, _i, _len, _ref, _results; _ref = $("div.date", els); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { wrapper = _ref[_i]; _results.push(new outpost.DateTimeInput({ wrapper: wrapper, time: false, field: "input.date" })); } return _results; }; DateTimeInput.prototype.DefaultOptions = { time: true, dateTemplate: JST["outpost/templates/date_field"], timeTemplate: JST["outpost/templates/time_field"], timestampEls: ".timestamp-el", populateIcons: "span.populate", controls: "div.controls", field: "input.datetime", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm", dbFormat: "YYYY-MM-DD HH:mm:ss" }; function DateTimeInput(options) { var _this = this; if (options == null) { options = {}; } this.options = _.defaults(options, this.DefaultOptions); this.time = this.options.time; this.wrapper = $(this.options.wrapper); this.controls = $(this.options.controls, this.wrapper); this.field = $(this.options.field, this.wrapper); this.id = this.field.attr("id"); this.dateId = "" + this.id + "_date"; this.timeId = "" + this.id + "_time"; this.field.hide(); if (this.time) { this.controls.prepend(this.options.timeTemplate({ time_id: this.timeId, time_format: this.options.timeFormat })); } this.controls.prepend(this.options.dateTemplate({ date_id: this.dateId, date_format: this.options.dateFormat })); this.timestampEls = $(this.options.timestampEls, this.wrapper); this.dateEl = $("#" + this.dateId); this.timeEl = $("#" + this.timeId); this.populateIcons = $(this.options.populateIcons, this.wrapper); if (this.field.val()) { this.dateEl.val(this.getDate(this.options.dateFormat)); if (this.time) { this.timeEl.val(this.getDate(this.options.timeFormat)); } } this.dateEl.datepicker({ autoclose: true, format: this.options.dateFormat.toLowerCase() }); this.timestampEls.on({ change: function(event) { return _this.field.trigger("update"); } }); this.field.on({ update: function() { return _this.setDate(_this.dateEl.val(), _this.time ? _this.timeEl.val() : void 0); } }); this.populateIcons.on({ click: function(event) { _this.populateDate(_this.dateEl, _this.options.dateFormat); if (_this.time) { _this.populateDate(_this.timeEl, _this.options.timeFormat); } return _this.field.trigger("update"); } }); } DateTimeInput.prototype.populateDate = function(el, format) { var date; date = moment().format(format); return el.val(date); }; DateTimeInput.prototype.getDate = function(format) { var date; date = Date.parse(this.field.val()); if (date) { return moment(date).format(format); } }; DateTimeInput.prototype.setDate = function(date, time) { var formatted; if (time == null) { time = ""; } date = moment(Date.parse("" + date + " " + time)); console.log("date set to", date); if (date) { formatted = date.format(this.options.dbFormat); return this.field.val(formatted); } else { return this.field.val(""); } }; return DateTimeInput; })(); }).call(this); ;TI"dependency_digest;F"%c3cc87df789014f0ab05bd58c1e1f521I"required_paths;F[I"b/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/date_time_input.js.coffee;TI"dependency_paths;F[{I" path;FI"b/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/date_time_input.js.coffee;TI" mtime;FI"2013-11-08T18:26:44-08:00;FI" digest;F"%2b5de925f009e6467aed79e3236ef3d0I" _version;F"%ac1cd7cf9811f9938e2b8937c60a24e6