I"ê(function() { window.setupUploadInputs = function(scope) { if (scope == null) { scope = document; } return $(scope).find(".form-group.upload").map(function() { var form, group, input, label, progress, submit; group = $(this); form = group.parents("form"); input = group.find("[type=file]"); submit = group.find("[type=submit]"); label = group.find("label"); progress = group.find(".progress"); if (!xhr2_available()) { progress.hide(); } label.map(function() { return this.dataset.defaultValue = $(this).html(); }); input.change(function() { var label_value; if (this.value === "") { submit.prop({ disabled: true }); label_value = label.data("defaultValue"); } else { submit.prop({ disabled: false }); label_value = this.value.split("/").pop().split("\\").pop(); } return label.html(label_value); }); return input.change(); }); }; $(document).on("ready turbolinks:load page:load", function() { $("button.reset").click(function() { var form; form = $(this).parents("form"); form.find("select option:first-child").map(function() { return this.selected = true; }); form.find("input").map(function() { if (this.type.match(/submit|hidden|button/)) { return; } return this.value = $(this).data("default-value") || ""; }); form.find("textarea").map(function() { return this.value = $(this).data("default-value") || ""; }); return form.find("select").map(function() { if (this.selectize) { this.selectize.clear(); } return $(this).val("").trigger("change"); }); }); return $("form").submit(function() { var input; if (this.method.toUpperCase() === "GET") { return; } if ($(this).find("[name=form_url]").length > 0) { return; } input = document.createElement("input"); input.type = "hidden"; input.name = "form_url"; input.value = location.href; return $(this).append(input); }); }); }).call(this); :ET