{I" class:ETI"BundledAsset;FI"logical_path;TI""simple_form_fileinput/init.js;FI" pathname;TI"}/Users/smit1625/.rvm/gems/ruby-2.1.0/gems/simple_form_fileinput-0.0.6/vendor/assets/javascripts/simple_form_fileinput/init.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+Ó UI" length;Tiù I" digest;TI"%4a892ee5f3c70dbc4679619aea979529;FI" source;TI"ù /* Bootstrap - File Input ====================== This is meant to convert all file input tags into a set of elements that displays consistently in all browsers. Converts all into Bootstrap buttons Browse */ (function($) { $.fn.bootstrapFileInput = function() { this.each(function(i,elem){ var $elem = $(elem); // Maybe some fields don't need to be standardized. if (typeof $elem.attr('data-bfi-disabled') != 'undefined') { return; } // Set the word to be displayed on the button var buttonWord = 'Browse'; if (typeof $elem.attr('title') != 'undefined') { buttonWord = $elem.attr('title'); } var className = ''; if (!!$elem.attr('class')) { className = ' ' + $elem.attr('class'); } // Now we're going to wrap that input field with a Bootstrap button. // The input will actually still be there, it will just be float above and transparent (done with the CSS). $elem.wrap('').parent().prepend($('').html(buttonWord)); }) // After we have found all of the file inputs let's apply a listener for tracking the mouse movement. // This is important because the in order to give the illusion that this is a button in FF we actually need to move the button from the file input under the cursor. Ugh. .promise().done( function(){ // As the cursor moves over our new Bootstrap button we need to adjust the position of the invisible file input Browse button to be under the cursor. // This gives us the pointer cursor that FF denies us $('.file-input-wrapper').mousemove(function(cursor) { var input, wrapper, wrapperX, wrapperY, inputWidth, inputHeight, cursorX, cursorY; // This wrapper element (the button surround this file input) wrapper = $(this); // The invisible file input element input = wrapper.find("input"); // The left-most position of the wrapper wrapperX = wrapper.offset().left; // The top-most position of the wrapper wrapperY = wrapper.offset().top; // The with of the browsers input field inputWidth= input.width(); // The height of the browsers input field inputHeight= input.height(); //The position of the cursor in the wrapper cursorX = cursor.pageX; cursorY = cursor.pageY; //The positions we are to move the invisible file input // The 20 at the end is an arbitrary number of pixels that we can shift the input such that cursor is not pointing at the end of the Browse button but somewhere nearer the middle moveInputX = cursorX - wrapperX - inputWidth + 20; // Slides the invisible input Browse button to be positioned middle under the cursor moveInputY = cursorY- wrapperY - (inputHeight/2); // Apply the positioning styles to actually move the invisible file input input.css({ left:moveInputX, top:moveInputY }); }); $('body').on('change', '.file-input-wrapper input[type=file]', function(){ var fileName; fileName = $(this).val(); // Remove any previous file names $(this).parent().next('.file-input-name').remove(); if (!!$(this).prop('files') && $(this).prop('files').length > 1) { fileName = $(this)[0].files.length+' files'; } else { fileName = fileName.substring(fileName.lastIndexOf('\\') + 1, fileName.length); } // Don't try to show the name if there is none if (!fileName) { return; } var selectedFileNamePlacement = $(this).data('filename-placement'); if (selectedFileNamePlacement === 'inside') { // Print the fileName inside $(this).siblings('span').html(fileName); $(this).attr('title', fileName); } else { // Print the fileName aside (right after the the button) $(this).parent().after(''+fileName+''); } }); }); }; // Add the styles before the first stylesheet // This ensures they can be easily overridden with developer styles var cssHtml = ''; $('link[rel=stylesheet]').eq(0).before(cssHtml); })(jQuery); (function() { $(function() { $.fn.draghover = function(options) { var defaults, settings; if (options == null) { options = {}; } defaults = { fireDragLeaveOnChild: true }; settings = $.extend(true, defaults, options); return this.each(function() { var collection, self; collection = $(); self = $(this); self.on('dragenter', function(e) { if (collection.length === 0) { self.trigger('draghoverstart'); } return collection = collection.add(e.target); }); self.on('dragleave', function(e) { console.log(e); console.log("" + e.originalEvent.pageX + ", " + e.originalEvent.pageY); if (!settings.fireDragLeaveOnChild && e.originalEvent.pageX !== 0) { e.preventDefault(); return false; } collection = collection.not(e.target); if (collection.length === 0) { return self.trigger("draghoverend"); } }); return self.on('drop', function(e) { collection = collection.not(e.target); if (collection.length === 0) { return self.trigger("draghoverend"); } }); }); }; return $(document).ready(function() { $(window).draghover({ fireDragLeaveOnChild: false }).on({ draghoverstart: function() { return $('.file-input-wrapper').addClass('file-in-window'); }, draghoverend: function() { return $('.file-input-wrapper').removeClass('file-in-window'); } }); return $('.file-input-wrapper input[type=file]').draghover().on({ draghoverstart: function() { return $(this).parent().addClass('file-hovering'); }, draghoverend: function() { return $(this).parent().removeClass('file-hovering'); } }); }); }); }).call(this); // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // about supported directives. // (function($){ $(document).ready(function(){ $('input[type=file]').bootstrapFileInput(); }); })(jQuery); ;TI"required_assets_digest;TI"%af0ceff87a40b15036ab78ff062a02fc;FI" _version;TI"%aed3113fdeca372cf743bc063ad6b94a;F