handlers.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */
  2. var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
  3. // progress and success handlers for media multi uploads
  4. function fileQueued( fileObj ) {
  5. // Get rid of unused form
  6. jQuery( '.media-blank' ).remove();
  7. var items = jQuery( '#media-items' ).children(), postid = post_id || 0;
  8. // Collapse a single item
  9. if ( items.length == 1 ) {
  10. items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 );
  11. }
  12. // Create a progress bar containing the filename
  13. jQuery( '<div class="media-item">' )
  14. .attr( 'id', 'media-item-' + fileObj.id )
  15. .addClass( 'child-of-' + postid )
  16. .append( '<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>',
  17. jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ) )
  18. .appendTo( jQuery( '#media-items' ) );
  19. // Disable submit
  20. jQuery( '#insert-gallery' ).prop( 'disabled', true );
  21. }
  22. function uploadStart() {
  23. try {
  24. if ( typeof topWin.tb_remove != 'undefined' )
  25. topWin.jQuery( '#TB_overlay' ).unbind( 'click', topWin.tb_remove );
  26. } catch( e ){}
  27. return true;
  28. }
  29. function uploadProgress( up, file ) {
  30. var item = jQuery( '#media-item-' + file.id );
  31. jQuery( '.bar', item ).width( ( 200 * file.loaded ) / file.size );
  32. jQuery( '.percent', item ).html( file.percent + '%' );
  33. }
  34. // check to see if a large file failed to upload
  35. function fileUploading( up, file ) {
  36. var hundredmb = 100 * 1024 * 1024,
  37. max = parseInt( up.settings.max_file_size, 10 );
  38. if ( max > hundredmb && file.size > hundredmb ) {
  39. setTimeout( function() {
  40. if ( file.status < 3 && file.loaded === 0 ) { // not uploading
  41. wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
  42. up.stop(); // stops the whole queue
  43. up.removeFile( file );
  44. up.start(); // restart the queue
  45. }
  46. }, 10000 ); // wait for 10 sec. for the file to start uploading
  47. }
  48. }
  49. function updateMediaForm() {
  50. var items = jQuery( '#media-items' ).children();
  51. // Just one file, no need for collapsible part
  52. if ( items.length == 1 ) {
  53. items.addClass( 'open' ).find( '.slidetoggle' ).show();
  54. jQuery( '.insert-gallery' ).hide();
  55. } else if ( items.length > 1 ) {
  56. items.removeClass( 'open' );
  57. // Only show Gallery/Playlist buttons when there are at least two files.
  58. jQuery( '.insert-gallery' ).show();
  59. }
  60. // Only show Save buttons when there is at least one file.
  61. if ( items.not( '.media-blank' ).length > 0 )
  62. jQuery( '.savebutton' ).show();
  63. else
  64. jQuery( '.savebutton' ).hide();
  65. }
  66. function uploadSuccess( fileObj, serverData ) {
  67. var item = jQuery( '#media-item-' + fileObj.id );
  68. // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag
  69. if ( typeof serverData === 'string' ) {
  70. serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' );
  71. // if async-upload returned an error message, place it in the media item div and return
  72. if ( /media-upload-error|error-div/.test( serverData ) ) {
  73. item.html( serverData );
  74. return;
  75. }
  76. }
  77. item.find( '.percent' ).html( pluploadL10n.crunching );
  78. prepareMediaItem( fileObj, serverData );
  79. updateMediaForm();
  80. // Increment the counter.
  81. if ( post_id && item.hasClass( 'child-of-' + post_id ) ) {
  82. jQuery( '#attachments-count' ).text( 1 * jQuery( '#attachments-count' ).text() + 1 );
  83. }
  84. }
  85. function setResize( arg ) {
  86. if ( arg ) {
  87. if ( window.resize_width && window.resize_height ) {
  88. uploader.settings.resize = {
  89. enabled: true,
  90. width: window.resize_width,
  91. height: window.resize_height,
  92. quality: 100
  93. };
  94. } else {
  95. uploader.settings.multipart_params.image_resize = true;
  96. }
  97. } else {
  98. delete( uploader.settings.multipart_params.image_resize );
  99. }
  100. }
  101. function prepareMediaItem( fileObj, serverData ) {
  102. var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery( '#media-item-' + fileObj.id );
  103. if ( f == 2 && shortform > 2 )
  104. f = shortform;
  105. try {
  106. if ( typeof topWin.tb_remove != 'undefined' )
  107. topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove );
  108. } catch( e ){}
  109. if ( isNaN( serverData ) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs
  110. item.append( serverData );
  111. prepareMediaItemInit( fileObj );
  112. } else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
  113. item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();});
  114. }
  115. }
  116. function prepareMediaItemInit( fileObj ) {
  117. var item = jQuery( '#media-item-' + fileObj.id );
  118. // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
  119. jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item );
  120. // Replace the original filename with the new (unique) one assigned during upload
  121. jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) );
  122. // Bind AJAX to the new Delete button
  123. jQuery( 'a.delete', item ).click( function(){
  124. // Tell the server to delete it. TODO: handle exceptions
  125. jQuery.ajax({
  126. url: ajaxurl,
  127. type: 'post',
  128. success: deleteSuccess,
  129. error: deleteError,
  130. id: fileObj.id,
  131. data: {
  132. id : this.id.replace(/[^0-9]/g, '' ),
  133. action : 'trash-post',
  134. _ajax_nonce : this.href.replace(/^.*wpnonce=/,'' )
  135. }
  136. });
  137. return false;
  138. });
  139. // Bind AJAX to the new Undo button
  140. jQuery( 'a.undo', item ).click( function(){
  141. // Tell the server to untrash it. TODO: handle exceptions
  142. jQuery.ajax({
  143. url: ajaxurl,
  144. type: 'post',
  145. id: fileObj.id,
  146. data: {
  147. id : this.id.replace(/[^0-9]/g,'' ),
  148. action: 'untrash-post',
  149. _ajax_nonce: this.href.replace(/^.*wpnonce=/,'' )
  150. },
  151. success: function( ){
  152. var type,
  153. item = jQuery( '#media-item-' + fileObj.id );
  154. if ( type = jQuery( '#type-of-' + fileObj.id ).val() )
  155. jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text()-0+1 );
  156. if ( post_id && item.hasClass( 'child-of-'+post_id ) )
  157. jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text()-0+1 );
  158. jQuery( '.filename .trashnotice', item ).remove();
  159. jQuery( '.filename .title', item ).css( 'font-weight','normal' );
  160. jQuery( 'a.undo', item ).addClass( 'hidden' );
  161. jQuery( '.menu_order_input', item ).show();
  162. item.css( {backgroundColor:'#ceb'} ).animate( {backgroundColor: '#fff'}, { queue: false, duration: 500, complete: function(){ jQuery( this ).css({backgroundColor:''}); } }).removeClass( 'undo' );
  163. }
  164. });
  165. return false;
  166. });
  167. // Open this item if it says to start open (e.g. to display an error)
  168. jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn();
  169. }
  170. // generic error message
  171. function wpQueueError( message ) {
  172. jQuery( '#media-upload-error' ).show().html( '<div class="error"><p>' + message + '</p></div>' );
  173. }
  174. // file-specific error messages
  175. function wpFileError( fileObj, message ) {
  176. itemAjaxError( fileObj.id, message );
  177. }
  178. function itemAjaxError( id, message ) {
  179. var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' );
  180. if ( last_err == id ) // prevent firing an error for the same file twice
  181. return;
  182. item.html( '<div class="error-div">' +
  183. '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' +
  184. '<strong>' + pluploadL10n.error_uploading.replace( '%s', jQuery.trim( filename )) + '</strong> ' +
  185. message +
  186. '</div>' ).data( 'last-err', id );
  187. }
  188. function deleteSuccess( data ) {
  189. var type, id, item;
  190. if ( data == '-1' )
  191. return itemAjaxError( this.id, 'You do not have permission. Has your session expired?' );
  192. if ( data == '0' )
  193. return itemAjaxError( this.id, 'Could not be deleted. Has it been deleted already?' );
  194. id = this.id;
  195. item = jQuery( '#media-item-' + id );
  196. // Decrement the counters.
  197. if ( type = jQuery( '#type-of-' + id ).val() )
  198. jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text() - 1 );
  199. if ( post_id && item.hasClass( 'child-of-'+post_id ) )
  200. jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text() - 1 );
  201. if ( jQuery( 'form.type-form #media-items' ).children().length == 1 && jQuery( '.hidden', '#media-items' ).length > 0 ) {
  202. jQuery( '.toggle' ).toggle();
  203. jQuery( '.slidetoggle' ).slideUp( 200 ).siblings().removeClass( 'hidden' );
  204. }
  205. // Vanish it.
  206. jQuery( '.toggle', item ).toggle();
  207. jQuery( '.slidetoggle', item ).slideUp( 200 ).siblings().removeClass( 'hidden' );
  208. item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass( 'undo' );
  209. jQuery( '.filename:empty', item ).remove();
  210. jQuery( '.filename .title', item ).css( 'font-weight','bold' );
  211. jQuery( '.filename', item ).append( '<span class="trashnotice"> ' + pluploadL10n.deleted + ' </span>' ).siblings( 'a.toggle' ).hide();
  212. jQuery( '.filename', item ).append( jQuery( 'a.undo', item ).removeClass( 'hidden' ) );
  213. jQuery( '.menu_order_input', item ).hide();
  214. return;
  215. }
  216. function deleteError() {
  217. }
  218. function uploadComplete() {
  219. jQuery( '#insert-gallery' ).prop( 'disabled', false );
  220. }
  221. function switchUploader( s ) {
  222. if ( s ) {
  223. deleteUserSetting( 'uploader' );
  224. jQuery( '.media-upload-form' ).removeClass( 'html-uploader' );
  225. if ( typeof( uploader ) == 'object' )
  226. uploader.refresh();
  227. } else {
  228. setUserSetting( 'uploader', '1' ); // 1 == html uploader
  229. jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
  230. }
  231. }
  232. function uploadError( fileObj, errorCode, message, up ) {
  233. var hundredmb = 100 * 1024 * 1024, max;
  234. switch ( errorCode ) {
  235. case plupload.FAILED:
  236. wpFileError( fileObj, pluploadL10n.upload_failed );
  237. break;
  238. case plupload.FILE_EXTENSION_ERROR:
  239. wpFileExtensionError( up, fileObj, pluploadL10n.invalid_filetype );
  240. break;
  241. case plupload.FILE_SIZE_ERROR:
  242. uploadSizeError( up, fileObj );
  243. break;
  244. case plupload.IMAGE_FORMAT_ERROR:
  245. wpFileError( fileObj, pluploadL10n.not_an_image );
  246. break;
  247. case plupload.IMAGE_MEMORY_ERROR:
  248. wpFileError( fileObj, pluploadL10n.image_memory_exceeded );
  249. break;
  250. case plupload.IMAGE_DIMENSIONS_ERROR:
  251. wpFileError( fileObj, pluploadL10n.image_dimensions_exceeded );
  252. break;
  253. case plupload.GENERIC_ERROR:
  254. wpQueueError( pluploadL10n.upload_failed );
  255. break;
  256. case plupload.IO_ERROR:
  257. max = parseInt( up.settings.filters.max_file_size, 10 );
  258. if ( max > hundredmb && fileObj.size > hundredmb ) {
  259. wpFileError( fileObj, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
  260. } else {
  261. wpQueueError( pluploadL10n.io_error );
  262. }
  263. break;
  264. case plupload.HTTP_ERROR:
  265. wpQueueError( pluploadL10n.http_error );
  266. break;
  267. case plupload.INIT_ERROR:
  268. jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
  269. break;
  270. case plupload.SECURITY_ERROR:
  271. wpQueueError( pluploadL10n.security_error );
  272. break;
  273. /* case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
  274. case plupload.UPLOAD_ERROR.FILE_CANCELLED:
  275. jQuery( '#media-item-' + fileObj.id ).remove();
  276. break;*/
  277. default:
  278. wpFileError( fileObj, pluploadL10n.default_error );
  279. }
  280. }
  281. function uploadSizeError( up, file ) {
  282. var message, errorDiv;
  283. message = pluploadL10n.file_exceeds_size_limit.replace( '%s', file.name );
  284. // Construct the error div.
  285. errorDiv = jQuery( '<div />' )
  286. .attr( {
  287. 'id': 'media-item-' + file.id,
  288. 'class': 'media-item error'
  289. } )
  290. .append(
  291. jQuery( '<p />' )
  292. .text( message )
  293. );
  294. // Append the error.
  295. jQuery( '#media-items' ).append( errorDiv );
  296. up.removeFile( file );
  297. }
  298. function wpFileExtensionError( up, file, message ) {
  299. jQuery( '#media-items' ).append( '<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>' );
  300. up.removeFile( file );
  301. }
  302. jQuery( document ).ready( function( $ ) {
  303. var tryAgainCount = {};
  304. var tryAgain;
  305. $( '.media-upload-form' ).bind( 'click.uploader', function( e ) {
  306. var target = $( e.target ), tr, c;
  307. if ( target.is( 'input[type="radio"]' ) ) { // remember the last used image size and alignment
  308. tr = target.closest( 'tr' );
  309. if ( tr.hasClass( 'align' ) )
  310. setUserSetting( 'align', target.val() );
  311. else if ( tr.hasClass( 'image-size' ) )
  312. setUserSetting( 'imgsize', target.val() );
  313. } else if ( target.is( 'button.button' ) ) { // remember the last used image link url
  314. c = e.target.className || '';
  315. c = c.match( /url([^ '"]+)/ );
  316. if ( c && c[1] ) {
  317. setUserSetting( 'urlbutton', c[1] );
  318. target.siblings( '.urlfield' ).val( target.data( 'link-url' ) );
  319. }
  320. } else if ( target.is( 'a.dismiss' ) ) {
  321. target.parents( '.media-item' ).fadeOut( 200, function() {
  322. $( this ).remove();
  323. } );
  324. } else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // switch uploader to html4
  325. $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' );
  326. switchUploader( 0 );
  327. e.preventDefault();
  328. } else if ( target.is( '.upload-html-bypass a' ) ) { // switch uploader to multi-file
  329. $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' );
  330. switchUploader( 1 );
  331. e.preventDefault();
  332. } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show
  333. target.parent().addClass( 'open' );
  334. target.siblings( '.slidetoggle' ).fadeIn( 250, function() {
  335. var S = $( window ).scrollTop(),
  336. H = $( window ).height(),
  337. top = $( this ).offset().top,
  338. h = $( this ).height(),
  339. b,
  340. B;
  341. if ( H && top && h ) {
  342. b = top + h;
  343. B = S + H;
  344. if ( b > B ) {
  345. if ( b - B < top - S )
  346. window.scrollBy( 0, ( b - B ) + 10 );
  347. else
  348. window.scrollBy( 0, top - S - 40 );
  349. }
  350. }
  351. } );
  352. e.preventDefault();
  353. } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide
  354. target.siblings( '.slidetoggle' ).fadeOut( 250, function() {
  355. target.parent().removeClass( 'open' );
  356. } );
  357. e.preventDefault();
  358. }
  359. });
  360. // Attempt to create image sub-sizes when an image was uploaded successfully
  361. // but the server responded with an HTTP 5xx error.
  362. tryAgain = function( up, error ) {
  363. var file = error.file;
  364. var times;
  365. var id;
  366. if ( ! error || ! error.responseHeaders ) {
  367. wpQueueError( pluploadL10n.http_error_image );
  368. return;
  369. }
  370. id = error.responseHeaders.match( /x-wp-upload-attachment-id:\s*(\d+)/i );
  371. if ( id && id[1] ) {
  372. id = id[1];
  373. } else {
  374. wpQueueError( pluploadL10n.http_error_image );
  375. return;
  376. }
  377. times = tryAgainCount[ file.id ];
  378. if ( times && times > 4 ) {
  379. // The file may have been uploaded and attachment post created,
  380. // but post-processing and resizing failed...
  381. // Do a cleanup then tell the user to scale down the image and upload it again.
  382. $.ajax({
  383. type: 'post',
  384. url: ajaxurl,
  385. dataType: 'json',
  386. data: {
  387. action: 'media-create-image-subsizes',
  388. _wpnonce: wpUploaderInit.multipart_params._wpnonce,
  389. attachment_id: id,
  390. _wp_upload_failed_cleanup: true,
  391. }
  392. });
  393. if ( error.message && ( error.status < 500 || error.status >= 600 ) ) {
  394. wpQueueError( error.message );
  395. } else {
  396. wpQueueError( pluploadL10n.http_error_image );
  397. }
  398. return;
  399. }
  400. if ( ! times ) {
  401. tryAgainCount[ file.id ] = 1;
  402. } else {
  403. tryAgainCount[ file.id ] = ++times;
  404. }
  405. // Try to create the missing image sizes.
  406. $.ajax({
  407. type: 'post',
  408. url: ajaxurl,
  409. dataType: 'json',
  410. data: {
  411. action: 'media-create-image-subsizes',
  412. _wpnonce: wpUploaderInit.multipart_params._wpnonce,
  413. attachment_id: id,
  414. _legacy_support: 'true',
  415. }
  416. }).done( function( response ) {
  417. var message;
  418. if ( response.success ) {
  419. uploadSuccess( file, response.data.id );
  420. } else {
  421. if ( response.data && response.data.message ) {
  422. message = response.data.message;
  423. }
  424. wpQueueError( message || pluploadL10n.http_error_image );
  425. }
  426. }).fail( function( jqXHR ) {
  427. // If another HTTP 5xx error, try try again...
  428. if ( jqXHR.status >= 500 && jqXHR.status < 600 ) {
  429. tryAgain( up, error );
  430. return;
  431. }
  432. wpQueueError( pluploadL10n.http_error_image );
  433. });
  434. }
  435. // init and set the uploader
  436. uploader_init = function() {
  437. uploader = new plupload.Uploader( wpUploaderInit );
  438. $( '#image_resize' ).bind( 'change', function() {
  439. var arg = $( this ).prop( 'checked' );
  440. setResize( arg );
  441. if ( arg )
  442. setUserSetting( 'upload_resize', '1' );
  443. else
  444. deleteUserSetting( 'upload_resize' );
  445. });
  446. uploader.bind( 'Init', function( up ) {
  447. var uploaddiv = $( '#plupload-upload-ui' );
  448. setResize( getUserSetting( 'upload_resize', false ) );
  449. if ( up.features.dragdrop && ! $( document.body ).hasClass( 'mobile' ) ) {
  450. uploaddiv.addClass( 'drag-drop' );
  451. $( '#drag-drop-area' ).on( 'dragover.wp-uploader', function() { // dragenter doesn't fire right :(
  452. uploaddiv.addClass( 'drag-over' );
  453. }).on( 'dragleave.wp-uploader, drop.wp-uploader', function() {
  454. uploaddiv.removeClass( 'drag-over' );
  455. });
  456. } else {
  457. uploaddiv.removeClass( 'drag-drop' );
  458. $( '#drag-drop-area' ).off( '.wp-uploader' );
  459. }
  460. if ( up.runtime === 'html4' ) {
  461. $( '.upload-flash-bypass' ).hide();
  462. }
  463. });
  464. uploader.bind( 'postinit', function( up ) {
  465. up.refresh();
  466. });
  467. uploader.init();
  468. uploader.bind( 'FilesAdded', function( up, files ) {
  469. $( '#media-upload-error' ).empty();
  470. uploadStart();
  471. plupload.each( files, function( file ) {
  472. fileQueued( file );
  473. });
  474. up.refresh();
  475. up.start();
  476. });
  477. uploader.bind( 'UploadFile', function( up, file ) {
  478. fileUploading( up, file );
  479. });
  480. uploader.bind( 'UploadProgress', function( up, file ) {
  481. uploadProgress( up, file );
  482. });
  483. uploader.bind( 'Error', function( up, error ) {
  484. var isImage = error.file && error.file.type && error.file.type.indexOf( 'image/' ) === 0;
  485. var status = error && error.status;
  486. // If the file is an image and the error is HTTP 5xx try to create sub-sizes again.
  487. if ( isImage && status >= 500 && status < 600 ) {
  488. tryAgain( up, error );
  489. return;
  490. }
  491. uploadError( error.file, error.code, error.message, up );
  492. up.refresh();
  493. });
  494. uploader.bind( 'FileUploaded', function( up, file, response ) {
  495. uploadSuccess( file, response.response );
  496. });
  497. uploader.bind( 'UploadComplete', function() {
  498. uploadComplete();
  499. });
  500. };
  501. if ( typeof( wpUploaderInit ) == 'object' ) {
  502. uploader_init();
  503. }
  504. });