1;(function($) { 2 3jQuery.fn.choose = function(f) { 4 $(this).bind('choose', f); 5}; 6 7 8jQuery.fn.file = function(options) { 9 var config = $.extend({ 10 name: 'file-upload' 11 }, options); 12 return this.each(function() { 13 var btn = $(this); 14 var pos = btn.offset(); 15 16 function update() { 17 pos = btn.offset(); 18 file.css({ 19 'top': pos.top, 20 'left': pos.left, 21 'width': btn.width(), 22 'height': btn.height() 23 }); 24 } 25 26 btn.mouseover(update); 27 28 var hidden = $('<div></div>').css({ 29 'display': 'none' 30 }).appendTo('body'); 31 32 var file = $('<div id="area-form-file-'+config.name+'"><form></form></div>').appendTo('body').css({ 33 'position': 'absolute', 34 'overflow': 'hidden', 35 '-moz-opacity': '0', 36 'filter': 'alpha(opacity: 0)', 37 'opacity': '0', 38 'cursor': 'pointer', 39 'z-index': '2' 40 }); 41 42 var form = file.find('form'); 43 var input = form.find('input'); 44 45 function reset() { 46 var input = $('<input type="file" multiple>').attr('name',config.name).css({'cursor':'pointer'}).appendTo(form); 47 input.change(function(e) { 48 input.unbind(); 49 input.detach(); 50 btn.trigger('choose', [input]); 51 reset(); 52 }); 53 }; 54 55 reset(); 56 57 function placer(e) { 58 form.css('margin-left', e.pageX - pos.left - offset.width); 59 form.css('margin-top', e.pageY - pos.top - offset.height + 3); 60 } 61 62 function redirect(name) { 63 file[name](function(e) { 64 btn.trigger(name); 65 }); 66 } 67 68 file.mousemove(placer); 69 btn.mousemove(placer); 70 71 redirect('mouseover'); 72 redirect('mouseout'); 73 redirect('mousedown'); 74 redirect('mouseup'); 75 76 var offset = { 77 width: file.width() - 25, 78 height: file.height() / 2 79 }; 80 81 update(); 82 }); 83}; 84 85})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.