{:uriI"file:///Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/fileinputer.js?type=application/javascript&pipeline=self&id=80345a7d984746b6ffd97e593b5bfdab3b23ea711fe866f0902451089cc3b767:ET:load_pathI"G/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts;F: filenameI"Z/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/fileinputer.js;T: nameI"fae/fileinputer;T:logical_pathI"fae/fileinputer.self.js;T:content_typeI"application/javascript;T: sourceI" // plugin have a checkbox in the thead of a table that controls that table column's checkboxes. var FileInputer = { options: { wrapper_class: "file_input-wrapper", button_class: "file_input-button", delete_class: "file_input-delete", text: "Choose File", file_text: "No File Chosen", active_class: "js-active" }, init: function(options, elm){ //reference for callback var that = this; // unite the default options with the passed-in ones this.options = $.extend({}, this.options, options); // saving element reference this.elm = elm; this.$input = $(elm).find("input[type=file]"); // create the visuals this.make_visuals(); // make the events this.clicker(); this.onchanger(); this.deleter(); }, make_visuals: function() { // positoin the input off screen this.$input.css({ "position": "absolute", "top": 0, "left": "-9999px", "visibility": "hidden" }); //save the reference for each element to object this.$inputer = $(document.createElement("div")).addClass(this.options.wrapper_class); this.$button = $(document.createElement("button")).addClass(this.options.button_class).attr("type", "button").text(this.options.text); this.$text = $(document.createElement("span")).text(this.options.file_text); this.$deleter = $(document.createElement("div")).addClass(this.options.delete_class); this.$inputer.append(this.$button).append(this.$text).append(this.$deleter); $(this.elm).append(this.$inputer); }, clicker: function() { var that = this; // redirect the click on the created visuals to the file input area this.$button.on("click", function(){ that.$input.click(); }); }, deleter: function() { var that = this; this.$deleter.on("click", function() { that.$input.val(""); that.$text.text(that.options.file_text); that.$inputer.removeClass(that.options.active_class); }); }, onchanger: function() { var that = this; // this is to get the filename and present it next to the button this.$input.on("change", function(e){ if(that.check_size()) { that.$text.text($(this).val().replace("C:\\fakepath\\", "")); if ($(this).val() !== "") { that.$inputer.addClass(that.options.active_class); } } else { e.preventDefault(); } }); }, check_size: function() { var limit = parseInt( this.$input.attr('data-limit') ); var size = this.$input.get(0).files[0].size / 1024 / 1024; var error_obj = $('', { class: 'error' }) error_obj.text( this.$input.attr('data-exceeded').replace('###', limit) ) if(size > limit) { this.$input.after( error_obj ); $(this.elm).addClass('field_with_errors'); return false; } else { return true; } } }; // make it a plugin $.plugin("fileinputer", FileInputer); ;T: metadata{ :dependencieso:Set: @hash{ I"environment-version;TTI"environment-paths;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"hfile-digest:///Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/fileinputer.js;TT: requiredo;;{: stubbedo;;{: linkso;;{: charsetI" utf-8;F: digest"%Vc+,`V ]xЇ)x: lengthi :integrityI"Xni:///sha-256;3x1WY8ortiyD9aGG_2BWDYhdeOv5odCHKap4nZ8b-5k?ct=application/javascript;T:dependencies_digest"%f8q*hgKBэV@Y:idI"E80345a7d984746b6ffd97e593b5bfdab3b23ea711fe866f0902451089cc3b767;F: mtimel+!ZU