|
50 | 50 | var main = function(el, options) {
|
51 | 51 | return el.each(function(i, input) {
|
52 | 52 | input = $(input);
|
53 |
| - var id = input.attr('id'); |
54 |
| - if (!id) { |
55 |
| - id = 'flashFileInput' + inputsCount; |
56 |
| - input.attr('id', id); |
| 53 | + var inputId = input.attr('id'), |
| 54 | + label, |
| 55 | + clickableElement; |
| 56 | + |
| 57 | + if (!inputId) { |
| 58 | + inputId = 'flashFileInput' + inputsCount; |
57 | 59 | inputsCount++;
|
58 | 60 | }
|
| 61 | + label = input.parent('label'); |
| 62 | + clickableElement = label.length > 0 ? label : input; |
| 63 | + clickableElement.attr('id', clickableElement.attr('id') || inputId); |
| 64 | + |
| 65 | + |
59 | 66 | options.multiple = !!(options.multiple === null ? input.attr('multiple') : options.multiple);
|
60 | 67 | options.accept = options.accept === null ? input.attr('accept') : options.accept;
|
61 | 68 |
|
62 |
| - FileAPIProxy.inputs[id] = input; |
63 |
| - FileAPIProxy.swfObject.add(id, options.multiple, options.accept, options.label, options.extensions); |
| 69 | + FileAPIProxy.inputs[inputId] = input; |
| 70 | + FileAPIProxy.swfObject.add(clickableElement.attr('id'), options.multiple, options.accept, options.label, options.extensions); |
64 | 71 |
|
65 |
| - input.css('z-index', 0) |
| 72 | + |
| 73 | + clickableElement.css('z-index', 0) |
66 | 74 | .mouseover(function (e) {
|
67 |
| - if (id !== currentTarget) { |
| 75 | + if (inputId !== currentTarget) { |
68 | 76 | e = e || window.event;
|
69 |
| - currentTarget = id; |
70 |
| - FileAPIProxy.swfObject.mouseover(id); |
| 77 | + currentTarget = inputId; |
| 78 | + FileAPIProxy.swfObject.mouseover(clickableElement.attr('id')); |
71 | 79 | FileAPIProxy.container
|
72 |
| - .height(input.outerHeight()) |
73 |
| - .width(input.outerWidth()) |
74 |
| - .css(input.offset()); |
| 80 | + .height(clickableElement.outerHeight()) |
| 81 | + .width(clickableElement.outerWidth()) |
| 82 | + .css(clickableElement.offset()); |
75 | 83 | }
|
76 | 84 | })
|
77 | 85 | .click(function(e) {
|
|
0 commit comments