Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/mvUploader.js |
— | — | @@ -328,16 +328,18 @@ |
329 | 329 | if( tmpAryData[i]['name'] ) |
330 | 330 | _this.formData[ tmpAryData[i]['name'] ] = tmpAryData[i]['value']; |
331 | 331 | } |
332 | | - |
333 | | - //get a clean loader: |
334 | | - _this.dispProgressOverlay(); |
335 | | - |
336 | | - //for some unknown reason we have to drop down the #p-search z-index: |
337 | | - $j('#p-search').css('z-index', 1); |
338 | | - |
339 | | - //select upload mode: |
340 | | - _this.detectUploadMode(); |
341 | | - |
| 332 | + //put into a try catch so we are sure to return false: |
| 333 | + try{ |
| 334 | + //get a clean loader: |
| 335 | + _this.dispProgressOverlay(); |
| 336 | + |
| 337 | + //for some unknown reason we have to drop down the #p-search z-index: |
| 338 | + $j('#p-search').css('z-index', 1); |
| 339 | + |
| 340 | + //select upload mode: |
| 341 | + _this.detectUploadMode(); |
| 342 | + }catch(e){} |
| 343 | + |
342 | 344 | //don't submit the form we will do the post in ajax |
343 | 345 | return false; |
344 | 346 | }; |
— | — | @@ -422,11 +424,10 @@ |
423 | 425 | 'action' : 'upload', |
424 | 426 | 'url' : $j('#wpUploadFileURL').val(), |
425 | 427 | 'filename' : $j('#wpDestFile').val(), |
426 | | - 'comment' : $j('#wpUploadDescription').val(), |
427 | | - 'asyncdownload': 'true' |
| 428 | + 'comment' : $j('#wpUploadDescription').val() |
428 | 429 | }, |
429 | 430 | 'url' : _this.api_url |
430 | | - }, function( data ){ |
| 431 | + }, function( data ){ |
431 | 432 | _this.processApiResult( data ); |
432 | 433 | }); |
433 | 434 | }, |
— | — | @@ -518,6 +519,7 @@ |
519 | 520 | }, |
520 | 521 | processApiResult: function( apiRes ){ |
521 | 522 | var _this = this; |
| 523 | + |
522 | 524 | //check for upload api error: |
523 | 525 | // {"upload":{"result":"Failure","error":"unknown-error","code":{"status":5,"filtered":"NGC2207%2BIC2163.jpg"}}} |
524 | 526 | if( apiRes.error || ( apiRes.upload && apiRes.upload.result == "Failure" ) ){ |
— | — | @@ -545,28 +547,33 @@ |
546 | 548 | //error space is too large so we don't front load it |
547 | 549 | //do a remote call to get the error msg: |
548 | 550 | if(!error_code || error_code == 'unknown-error'){ |
549 | | - js_log('Error: apiRes: ' + JSON.stringify( apiRes) ); |
| 551 | + if(typeof JSON != 'undefined'){ |
| 552 | + js_log('Error: apiRes: ' + JSON.stringify( apiRes) ); |
| 553 | + } |
550 | 554 | _this.updateUploadError( gM('unknown-error') + '<br>' + error_msg); |
551 | 555 | }else{ |
552 | 556 | gMsgLoadRemote(error_code, function(){ |
553 | 557 | js_log('send msg: ' + gM( error_code )); |
554 | 558 | _this.updateUploadError( gM( error_code )); |
555 | 559 | }); |
556 | | - } |
| 560 | + } |
| 561 | + js_log("api.erorr"); |
557 | 562 | return ; |
558 | 563 | } |
559 | 564 | //check for upload_session key for async upload: |
560 | 565 | if( apiRes.upload && apiRes.upload.upload_session_key ){ |
561 | 566 | //set the session key |
562 | 567 | _this.upload_session_key = apiRes.upload.upload_session_key; |
563 | | - js_log("set session key: " + _this.upload_session_key); |
| 568 | + |
564 | 569 | //do ajax upload status: |
565 | | - _this.doAjaxUploadStatus(); |
| 570 | + _this.doAjaxUploadStatus(); |
| 571 | + js_log("set upload_session_key: " + _this.upload_session_key); |
566 | 572 | return ; |
567 | 573 | } |
568 | 574 | |
569 | 575 | if( apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ){ |
570 | 576 | _this.updateUploadDone( apiRes.upload.imageinfo.descriptionurl ); |
| 577 | + js_log('apiRes.upload.imageinfo:: updateUploadDone'); |
571 | 578 | return ; |
572 | 579 | } |
573 | 580 | |
— | — | @@ -576,7 +583,8 @@ |
577 | 584 | return ; |
578 | 585 | } |
579 | 586 | //check for known warnings: |
580 | | - if( apiRes.upload.warnings ){ |
| 587 | + if( apiRes.upload.warnings ){ |
| 588 | + //debugger; |
581 | 589 | var wmsg = '<ul>'; |
582 | 590 | for(var wtype in apiRes.upload.warnings){ |
583 | 591 | var winfo = apiRes.upload.warnings[wtype] |
— | — | @@ -584,8 +592,13 @@ |
585 | 593 | switch(wtype){ |
586 | 594 | case 'duplicate': |
587 | 595 | case 'exists': |
588 | | - wmsg += gM('file-exists-duplicate') +' '+ |
589 | | - '<b>' + winfo[1].title.mTextform + '</b>'; |
| 596 | + if(winfo[1] && winfo[1].title && winfo[1].title.mTextform){ |
| 597 | + wmsg += gM('file-exists-duplicate') +' '+ |
| 598 | + '<b>' + winfo[1].title.mTextform + '</b>'; |
| 599 | + }else{ |
| 600 | + //misc error (weird that winfo[1] not present |
| 601 | + wmsg += gM('upload-misc-error') + ' ' + wtype; |
| 602 | + } |
590 | 603 | break; |
591 | 604 | case 'file-thumbnail-no': |
592 | 605 | wmsg += gM('file-thumbnail-no', winfo); |
— | — | @@ -664,5 +677,7 @@ |
665 | 678 | '<div id="dlbox-overlay" class="dlbox-overlay" style="background:#000;cursor:wait;height:100%;'+ |
666 | 679 | 'left:0;top:0;position:fixed;width:100%;z-index:99;filter:alpha(opacity=60);'+ |
667 | 680 | '-moz-opacity: 0.6; opacity: 0.6;" ></div>'); |
| 681 | + //fade them in: |
| 682 | + $j('#dlbox-centered,#dlbox-overlay').show(); |
668 | 683 | } |
669 | 684 | } |