| 1 |
;/*jslint regexp: true, confusion: true, undef: true, sloppy: true, eqeq: true, vars: true, white: true, plusplus: true, maxerr: 50, indent: 4 */ |
| 2 |
/*global bbpcAttachmentsInit*/(function($, window, document, undefined) { |
| 3 |
window.wp = window.wp || {}; |
| 4 |
window.wp.gdatt = window.wp.gdatt || {}; |
| 5 |
|
| 6 |
window.wp.gdatt.attachments = { |
| 7 |
init: function() { |
| 8 |
$( "form#new-post" ).attr( "enctype", "multipart/form-data" ); |
| 9 |
|
| 10 |
$( document ).on( |
| 11 |
"click", |
| 12 |
".d4p-bba-actions a", |
| 13 |
function(e){ |
| 14 |
return confirm( bbpcAttachmentsInit.are_you_sure ); |
| 15 |
} |
| 16 |
); |
| 17 |
|
| 18 |
$( document ).on( |
| 19 |
"click", |
| 20 |
".bbpc-attachment-addfile", |
| 21 |
function(e){ |
| 22 |
e.preventDefault(); |
| 23 |
|
| 24 |
var now = $( ".bbpc_attachments input[type=file]" ).length, |
| 25 |
max = parseInt( bbpcAttachmentsInit.max_files ); |
| 26 |
|
| 27 |
if (now < max) { |
| 28 |
$( this ).before( '<input type="file" size="40" name="bbpc_attachment[]">' ); |
| 29 |
} |
| 30 |
|
| 31 |
if (now + 1 >= max) { |
| 32 |
$( this ).remove(); |
| 33 |
} |
| 34 |
} |
| 35 |
); |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
$( document ).ready( |
| 40 |
function() { |
| 41 |
wp.gdatt.attachments.init(); |
| 42 |
} |
| 43 |
); |
| 44 |
})( jQuery, window, document ); |
| 45 |
|