| | @@ -372,20 +372,34 @@ |
| 372 | 372 | e.buttons.append(e.button.toggleHeader); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | }/*constructor*/ |
| 376 | 376 | |
| 377 | | - discard(){ |
| 377 | + close(){ |
| 378 | 378 | const e = this.#e.widget; |
| 379 | | - if( e.parentNode ){ |
| 379 | + if( e?.parentNode ){ |
| 380 | + if( this.#opt.onclose instanceof Function ){ |
| 381 | + try{this.#opt.onclose();} |
| 382 | + catch(e){ |
| 383 | + console.error("ForumPostEditor.onclose() threw:",e); |
| 384 | + } |
| 385 | + } |
| 380 | 386 | //console.debug("FPE discarding", this); |
| 381 | | - this.#clearDraft(); |
| 382 | | - e.remove(); |
| 383 | | - if( this.#opt.ondiscard instanceof Function ){ |
| 384 | | - this.#opt.ondiscard(); |
| 387 | + e.classList.add('animate-exit'); |
| 388 | + e.addEventListener('animationend', ()=>e.remove(), {once: true}); |
| 389 | + } |
| 390 | + } |
| 391 | + |
| 392 | + discard(){ |
| 393 | + if( this.#opt.ondiscard instanceof Function ){ |
| 394 | + try{this.#opt.ondiscard();} |
| 395 | + catch(e){ |
| 396 | + console.error("ForumPostEditor.ondiscard() threw:",e); |
| 385 | 397 | } |
| 386 | 398 | } |
| 399 | + this.#clearDraft(); |
| 400 | + this.close(); |
| 387 | 401 | } |
| 388 | 402 | |
| 389 | 403 | /** This widget's top-most DOM element. */ |
| 390 | 404 | get widget(){ |
| 391 | 405 | return this.#e.widget; |
| | @@ -410,13 +424,13 @@ |
| 410 | 424 | */ |
| 411 | 425 | reportError(...msg){ |
| 412 | 426 | const e = this.#e.error; |
| 413 | 427 | D.clearElement(e); |
| 414 | 428 | if( msg.length ){ |
| 429 | + console.error('ForumPostEditor:',...msg); |
| 415 | 430 | e.classList.remove('hidden'); |
| 416 | 431 | e.append(...msg); |
| 417 | | - console.error('ForumPostEditor:',...msg); |
| 418 | 432 | }else{ |
| 419 | 433 | e.classList.add('hidden'); |
| 420 | 434 | } |
| 421 | 435 | } |
| 422 | 436 | |
| | @@ -612,11 +626,11 @@ |
| 612 | 626 | }); |
| 613 | 627 | } |
| 614 | 628 | if( this.#att ){ |
| 615 | 629 | this.#att.populateFormData(fd); |
| 616 | 630 | } |
| 617 | | - console.warn("Ready to submit",fd); |
| 631 | + //console.warn("Ready to submit",fd); |
| 618 | 632 | if( 0 ){ |
| 619 | 633 | this.#isWaiting = false; |
| 620 | 634 | return; |
| 621 | 635 | } |
| 622 | 636 | const resp = window.fetch(F.repoUrl('forumajax_save'), { |
| | @@ -635,11 +649,14 @@ |
| 635 | 649 | return; |
| 636 | 650 | } |
| 637 | 651 | if( 1 ){ |
| 638 | 652 | this.#clearDraft(); |
| 639 | 653 | if( this.#opt.onsubmit instanceof Function ){ |
| 640 | | - this.#opt.onsubmit(this); |
| 654 | + try{this.#opt.onsubmit(this);} |
| 655 | + catch(e){ |
| 656 | + console.error("ForumPostEditor.onsubmit() threw: ", e); |
| 657 | + } |
| 641 | 658 | } |
| 642 | 659 | window.location = F.repoUrl('forumpost/'+j.uuid); |
| 643 | 660 | }else{ |
| 644 | 661 | this.reportError( |
| 645 | 662 | "Saving worked but we're ignoring it and staying here." |
| | @@ -883,11 +900,18 @@ |
| 883 | 900 | const w = fpe.widget; |
| 884 | 901 | w.style.borderTop = '1px dotted'; |
| 885 | 902 | //w.style.marginTop = '0.35em'; |
| 886 | 903 | /* Adding an "Editing..." <h3> here adds way too much space */ |
| 887 | 904 | ePost.append(w); |
| 888 | | - w.scrollIntoView(); |
| 905 | + w.classList.add('animate-entrance'); |
| 906 | + requestAnimationFrame(() => { |
| 907 | + w.scrollIntoView({ |
| 908 | + behavior: 'smooth', |
| 909 | + block: 'nearest', |
| 910 | + inline: 'nearest' |
| 911 | + }); |
| 912 | + }); |
| 889 | 913 | }; |
| 890 | 914 | |
| 891 | 915 | const eForumNew = ( |
| 892 | 916 | document.body.classList.contains('cpage-forumnew') |
| 893 | 917 | || document.body.classList.contains('cpage-forume1') |
| 894 | 918 | |