Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | * 5. Rate This Page |
28 | 28 | * The existing article feedback tool, except that it can use any of the |
29 | 29 | * CTA types. |
30 | | - * 6. No Feedback |
| 30 | + * 0. No Feedback |
31 | 31 | * Shows nothing at all. |
32 | 32 | * The available CTAs are: |
33 | 33 | * 1. Edit this page |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | * |
70 | 70 | * @see http://www.mediawiki.org/wiki/Article_feedback/Version_5/Feature_Requirements#Feedback_form_interface |
71 | 71 | */ |
72 | | - $.articleFeedbackv5.bucketId = 6; |
| 72 | + $.articleFeedbackv5.bucketId = 0; |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * The CTA is the view presented to a user who has successfully submitted |
— | — | @@ -112,6 +112,14 @@ |
113 | 113 | */ |
114 | 114 | $.articleFeedbackv5.buckets = { |
115 | 115 | |
| 116 | + // {{{ Bucket 0 |
| 117 | + |
| 118 | + /** |
| 119 | + * Bucket 0: No form |
| 120 | + */ |
| 121 | + '0': { } |
| 122 | + |
| 123 | + // }}} |
116 | 124 | // {{{ Bucket 1 |
117 | 125 | |
118 | 126 | /** |
— | — | @@ -390,6 +398,639 @@ |
391 | 399 | }, |
392 | 400 | |
393 | 401 | // }}} |
| 402 | + // {{{ Bucket 2 |
| 403 | + |
| 404 | + /** |
| 405 | + * Bucket 2: Help Improve This Article |
| 406 | + */ |
| 407 | + '2': { |
| 408 | + |
| 409 | + // {{{ buildForm |
| 410 | + |
| 411 | + /** |
| 412 | + * Builds the empty form |
| 413 | + * |
| 414 | + * @return Element the form |
| 415 | + */ |
| 416 | + buildForm: function () { |
| 417 | + |
| 418 | + // The overall template |
| 419 | + var block_tpl = '\ |
| 420 | + <form>\ |
| 421 | + <div class="title-wrap">\ |
| 422 | + <h2 class="articleFeedbackv5-title"><html:msg key="bucket2-title" /></h2>\ |
| 423 | + <a class="articleFeedbackv5-tooltip-trigger"></a>\ |
| 424 | + <div class="articleFeedbackv5-tooltip">\ |
| 425 | + <div class="tooltip-top"></div>\ |
| 426 | + <div class="tooltip-repeat">\ |
| 427 | + <h3><html:msg key="bucket2-tooltip-title" /></h3>\ |
| 428 | + <p><html:msg key="bucket2-tooltip-info" /></p>\ |
| 429 | + <p><a target="_blank" href="http://www.mediawiki.org/wiki/Article_feedback/Version_5"><html:msg key="bucket2-tooltip-linktext" /></a></p>\ |
| 430 | + </div>\ |
| 431 | + <div class="tooltip-bottom"></div>\ |
| 432 | + </div>\ |
| 433 | + <div class="clear"></div>\ |
| 434 | + </div>\ |
| 435 | + <div class="form-row articleFeedbackv5-bucket2-toggle">\ |
| 436 | + <p class="instructions-left"><html:msg key="bucket2-question-toggle" /></p>\ |
| 437 | + <div class="buttons">\ |
| 438 | + <div class="form-item" rel="yes" id="articleFeedbackv5-bucket2-toggle-wrapper-yes">\ |
| 439 | + <label for="articleFeedbackv5-bucket2-toggle-yes"><html:msg key="bucket2-toggle-found-yes-full" /></label>\ |
| 440 | + <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket2-toggle-found-yes" value="yes" /></span>\ |
| 441 | + <input type="radio" name="toggle" id="articleFeedbackv5-bucket2-toggle-yes" class="query-button" value="yes" />\ |
| 442 | + </div>\ |
| 443 | + <div class="form-item" rel="no" id="articleFeedbackv5-bucket2-toggle-wrapper-no">\ |
| 444 | + <label for="articleFeedbackv5-bucket2-toggle-no"><html:msg key="bucket2-toggle-found-no-full" /></label>\ |
| 445 | + <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket2-toggle-found-no" /></span>\ |
| 446 | + <input type="radio" name="toggle" id="articleFeedbackv5-bucket2-toggle-no" class="query-button last" value="no" />\ |
| 447 | + </div>\ |
| 448 | + <div class="clear"></div>\ |
| 449 | + </div>\ |
| 450 | + <div class="clear"></div>\ |
| 451 | + </div>\ |
| 452 | + <div class="articleFeedbackv5-comment">\ |
| 453 | + <textarea id="find-feedback" class="feedback-text" name="comment"></textarea>\ |
| 454 | + </div>\ |
| 455 | + <div class="articleFeedbackv5-disclosure">\ |
| 456 | + <p class="articlefeedbackv5-shared-on-feedback"></p>\ |
| 457 | + <p class="articlefeedbackv5-transparency-terms"></p>\ |
| 458 | + </div>\ |
| 459 | + <button class="articleFeedbackv5-submit" type="submit" disabled="disabled"><html:msg key="bucket2-form-submit" /></button>\ |
| 460 | + <div class="clear"></div>\ |
| 461 | + </form>\ |
| 462 | + '; |
| 463 | + // Start up the block to return |
| 464 | + var $block = $( block_tpl ); |
| 465 | + |
| 466 | + // Start out the tooltip hidden |
| 467 | + $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
| 468 | + |
| 469 | + // Fill in the disclosure text |
| 470 | + $block.find( '.articlefeedbackv5-shared-on-feedback' ) |
| 471 | + .html( $.articleFeedbackv5.buildLink( |
| 472 | + 'articlefeedbackv5-shared-on-feedback', |
| 473 | + { |
| 474 | + href: mw.config.get( 'wgScript' ) + '?' + $.param( { |
| 475 | + title: mw.config.get( 'wgPageName' ), |
| 476 | + action: 'feedback' |
| 477 | + } ), |
| 478 | + text: 'articlefeedbackv5-shared-on-feedback-linktext', |
| 479 | + target: '_blank' |
| 480 | + } ) ); |
| 481 | + $block.find( '.articlefeedbackv5-transparency-terms' ) |
| 482 | + .html( $.articleFeedbackv5.buildLink( |
| 483 | + 'articlefeedbackv5-transparency-terms', |
| 484 | + { |
| 485 | + href: mw.util.wikiGetlink( mw.config.get( 'wgArticleFeedbackv5TermsPage' ) ), |
| 486 | + text: 'articlefeedbackv5-transparency-terms-linktext', |
| 487 | + target: '_blank' |
| 488 | + } ) ); |
| 489 | + |
| 490 | + // Localize the block |
| 491 | + $block.localize( { 'prefix': 'articlefeedbackv5-' } ); |
| 492 | + |
| 493 | + // Turn the submit into a slick button |
| 494 | + $block.find( '.articleFeedbackv5-submit' ) |
| 495 | + .button() |
| 496 | + .addClass( 'ui-button-blue' ) |
| 497 | + |
| 498 | + return $block; |
| 499 | + }, |
| 500 | + |
| 501 | + // }}} |
| 502 | + // {{{ bindEvents |
| 503 | + |
| 504 | + /** |
| 505 | + * Binds any events |
| 506 | + * |
| 507 | + * @param $block element the form block |
| 508 | + */ |
| 509 | + bindEvents: function ( $block ) { |
| 510 | + |
| 511 | + // Attach the submit |
| 512 | + $block.find( '.articleFeedbackv5-submit' ) |
| 513 | + .click( function ( e ) { |
| 514 | + e.preventDefault(); |
| 515 | + $.articleFeedbackv5.submitForm(); |
| 516 | + } ); |
| 517 | + |
| 518 | + }, |
| 519 | + |
| 520 | + // }}} |
| 521 | + // {{{ enableSubmission |
| 522 | + |
| 523 | + /** |
| 524 | + * Enables or disables submission of the form |
| 525 | + * |
| 526 | + * @param state bool true to enable; false to disable |
| 527 | + */ |
| 528 | + enableSubmission: function ( state ) { |
| 529 | + var $h = $.articleFeedbackv5.$holder; |
| 530 | + if ( state ) { |
| 531 | + if ($.articleFeedbackv5.successTimeout) { |
| 532 | + clearTimeout( $.articleFeedbackv5.successTimeout ); |
| 533 | + } |
| 534 | + $h.find( '.articleFeedbackv5-submit' ).button( { 'disabled': false } ); |
| 535 | + $h.find( '.articleFeedbackv5-success span' ).hide(); |
| 536 | + $h.find( '.articleFeedbackv5-pending span' ).fadeIn( 'fast' ); |
| 537 | + } else { |
| 538 | + $h.find( '.articleFeedbackv5-submit' ).button( { 'disabled': true } ); |
| 539 | + $h.find( '.articleFeedbackv5-pending span' ).hide(); |
| 540 | + } |
| 541 | + }, |
| 542 | + |
| 543 | + // }}} |
| 544 | + // {{{ getFormData |
| 545 | + |
| 546 | + /** |
| 547 | + * Pulls down form data |
| 548 | + * |
| 549 | + * @return object the form data |
| 550 | + */ |
| 551 | + getFormData: function () { |
| 552 | + var data = {}; |
| 553 | + return data; |
| 554 | + }, |
| 555 | + |
| 556 | + // }}} |
| 557 | + // {{{ localValidation |
| 558 | + |
| 559 | + /** |
| 560 | + * Performs any local validation |
| 561 | + * |
| 562 | + * @param object formdata the form data |
| 563 | + * @return mixed if ok, false; otherwise, an object as { 'field name' : 'message' } |
| 564 | + */ |
| 565 | + localValidation: function ( formdata ) { |
| 566 | + var error = {}; |
| 567 | + var ok = true; |
| 568 | + if ( $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-bucket2-toggle input[checked]' ).length < 1 ) { |
| 569 | + error.toggle = 'Please select an option'; |
| 570 | + ok = false; |
| 571 | + } |
| 572 | + return ok ? false : error; |
| 573 | + }, |
| 574 | + |
| 575 | + // }}} |
| 576 | + // {{{ markFormError |
| 577 | + |
| 578 | + /** |
| 579 | + * Marks any errors on the form |
| 580 | + * |
| 581 | + * @param object error errors, indexed by field name |
| 582 | + */ |
| 583 | + markFormError: function ( error ) { |
| 584 | + if ( '_api' in error ) { |
| 585 | + $.articleFeedbackv5.markShowstopperError( error._api.info ); |
| 586 | + } else { |
| 587 | + alert( 'Validation error' ); |
| 588 | + mw.log( 'Validation error' ); |
| 589 | + } |
| 590 | + console.log( error ); |
| 591 | + }, |
| 592 | + |
| 593 | + // }}} |
| 594 | + // {{{ setSuccessState |
| 595 | + |
| 596 | + /** |
| 597 | + * Sets the success state |
| 598 | + */ |
| 599 | + setSuccessState: function () { |
| 600 | + var $h = $.articleFeedbackv5.$holder; |
| 601 | + $h.find( '.articleFeedbackv5-success span' ).fadeIn( 'fast' ); |
| 602 | + $.articleFeedbackv5.successTimeout = setTimeout( function () { |
| 603 | + $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-success span' ) |
| 604 | + .fadeOut( 'slow' ); |
| 605 | + }, 5000 ); |
| 606 | + }, |
| 607 | + |
| 608 | + // }}} |
| 609 | + |
| 610 | + }, |
| 611 | + |
| 612 | + // }}} |
| 613 | + // {{{ Bucket 3 |
| 614 | + |
| 615 | + /** |
| 616 | + * Bucket 3: Help Improve This Article |
| 617 | + */ |
| 618 | + '3': { |
| 619 | + |
| 620 | + // {{{ buildForm |
| 621 | + |
| 622 | + /** |
| 623 | + * Builds the empty form |
| 624 | + * |
| 625 | + * @return Element the form |
| 626 | + */ |
| 627 | + buildForm: function () { |
| 628 | + |
| 629 | + // The overall template |
| 630 | + var block_tpl = '\ |
| 631 | + <form>\ |
| 632 | + <div class="title-wrap">\ |
| 633 | + <h2 class="articleFeedbackv5-title"><html:msg key="bucket3-title" /></h2>\ |
| 634 | + <a class="articleFeedbackv5-tooltip-trigger"></a>\ |
| 635 | + <div class="articleFeedbackv5-tooltip">\ |
| 636 | + <div class="tooltip-top"></div>\ |
| 637 | + <div class="tooltip-repeat">\ |
| 638 | + <h3><html:msg key="bucket3-tooltip-title" /></h3>\ |
| 639 | + <p><html:msg key="bucket3-tooltip-info" /></p>\ |
| 640 | + <p><a target="_blank" href="http://www.mediawiki.org/wiki/Article_feedback/Version_5"><html:msg key="bucket3-tooltip-linktext" /></a></p>\ |
| 641 | + </div>\ |
| 642 | + <div class="tooltip-bottom"></div>\ |
| 643 | + </div>\ |
| 644 | + <div class="clear"></div>\ |
| 645 | + </div>\ |
| 646 | + <div class="form-row articleFeedbackv5-bucket3-toggle">\ |
| 647 | + <p class="instructions-left"><html:msg key="bucket3-question-toggle" /></p>\ |
| 648 | + <div class="buttons">\ |
| 649 | + <div class="form-item" rel="yes" id="articleFeedbackv5-bucket3-toggle-wrapper-yes">\ |
| 650 | + <label for="articleFeedbackv5-bucket3-toggle-yes"><html:msg key="bucket3-toggle-found-yes-full" /></label>\ |
| 651 | + <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket3-toggle-found-yes" value="yes" /></span>\ |
| 652 | + <input type="radio" name="toggle" id="articleFeedbackv5-bucket3-toggle-yes" class="query-button" value="yes" />\ |
| 653 | + </div>\ |
| 654 | + <div class="form-item" rel="no" id="articleFeedbackv5-bucket3-toggle-wrapper-no">\ |
| 655 | + <label for="articleFeedbackv5-bucket3-toggle-no"><html:msg key="bucket3-toggle-found-no-full" /></label>\ |
| 656 | + <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket3-toggle-found-no" /></span>\ |
| 657 | + <input type="radio" name="toggle" id="articleFeedbackv5-bucket3-toggle-no" class="query-button last" value="no" />\ |
| 658 | + </div>\ |
| 659 | + <div class="clear"></div>\ |
| 660 | + </div>\ |
| 661 | + <div class="clear"></div>\ |
| 662 | + </div>\ |
| 663 | + <div class="articleFeedbackv5-comment">\ |
| 664 | + <textarea id="find-feedback" class="feedback-text" name="comment"></textarea>\ |
| 665 | + </div>\ |
| 666 | + <div class="articleFeedbackv5-disclosure">\ |
| 667 | + <p class="articlefeedbackv5-shared-on-feedback"></p>\ |
| 668 | + <p class="articlefeedbackv5-transparency-terms"></p>\ |
| 669 | + </div>\ |
| 670 | + <button class="articleFeedbackv5-submit" type="submit" disabled="disabled"><html:msg key="bucket3-form-submit" /></button>\ |
| 671 | + <div class="clear"></div>\ |
| 672 | + </form>\ |
| 673 | + '; |
| 674 | + // Start up the block to return |
| 675 | + var $block = $( block_tpl ); |
| 676 | + |
| 677 | + // Start out the tooltip hidden |
| 678 | + $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
| 679 | + |
| 680 | + // Fill in the disclosure text |
| 681 | + $block.find( '.articlefeedbackv5-shared-on-feedback' ) |
| 682 | + .html( $.articleFeedbackv5.buildLink( |
| 683 | + 'articlefeedbackv5-shared-on-feedback', |
| 684 | + { |
| 685 | + href: mw.config.get( 'wgScript' ) + '?' + $.param( { |
| 686 | + title: mw.config.get( 'wgPageName' ), |
| 687 | + action: 'feedback' |
| 688 | + } ), |
| 689 | + text: 'articlefeedbackv5-shared-on-feedback-linktext', |
| 690 | + target: '_blank' |
| 691 | + } ) ); |
| 692 | + $block.find( '.articlefeedbackv5-transparency-terms' ) |
| 693 | + .html( $.articleFeedbackv5.buildLink( |
| 694 | + 'articlefeedbackv5-transparency-terms', |
| 695 | + { |
| 696 | + href: mw.util.wikiGetlink( mw.config.get( 'wgArticleFeedbackv5TermsPage' ) ), |
| 697 | + text: 'articlefeedbackv5-transparency-terms-linktext', |
| 698 | + target: '_blank' |
| 699 | + } ) ); |
| 700 | + |
| 701 | + // Localize the block |
| 702 | + $block.localize( { 'prefix': 'articlefeedbackv5-' } ); |
| 703 | + |
| 704 | + // Turn the submit into a slick button |
| 705 | + $block.find( '.articleFeedbackv5-submit' ) |
| 706 | + .button() |
| 707 | + .addClass( 'ui-button-blue' ) |
| 708 | + |
| 709 | + return $block; |
| 710 | + }, |
| 711 | + |
| 712 | + // }}} |
| 713 | + // {{{ bindEvents |
| 714 | + |
| 715 | + /** |
| 716 | + * Binds any events |
| 717 | + * |
| 718 | + * @param $block element the form block |
| 719 | + */ |
| 720 | + bindEvents: function ( $block ) { |
| 721 | + |
| 722 | + // Attach the submit |
| 723 | + $block.find( '.articleFeedbackv5-submit' ) |
| 724 | + .click( function ( e ) { |
| 725 | + e.preventDefault(); |
| 726 | + $.articleFeedbackv5.submitForm(); |
| 727 | + } ); |
| 728 | + |
| 729 | + }, |
| 730 | + |
| 731 | + // }}} |
| 732 | + // {{{ enableSubmission |
| 733 | + |
| 734 | + /** |
| 735 | + * Enables or disables submission of the form |
| 736 | + * |
| 737 | + * @param state bool true to enable; false to disable |
| 738 | + */ |
| 739 | + enableSubmission: function ( state ) { |
| 740 | + var $h = $.articleFeedbackv5.$holder; |
| 741 | + if ( state ) { |
| 742 | + if ($.articleFeedbackv5.successTimeout) { |
| 743 | + clearTimeout( $.articleFeedbackv5.successTimeout ); |
| 744 | + } |
| 745 | + $h.find( '.articleFeedbackv5-submit' ).button( { 'disabled': false } ); |
| 746 | + $h.find( '.articleFeedbackv5-success span' ).hide(); |
| 747 | + $h.find( '.articleFeedbackv5-pending span' ).fadeIn( 'fast' ); |
| 748 | + } else { |
| 749 | + $h.find( '.articleFeedbackv5-submit' ).button( { 'disabled': true } ); |
| 750 | + $h.find( '.articleFeedbackv5-pending span' ).hide(); |
| 751 | + } |
| 752 | + }, |
| 753 | + |
| 754 | + // }}} |
| 755 | + // {{{ getFormData |
| 756 | + |
| 757 | + /** |
| 758 | + * Pulls down form data |
| 759 | + * |
| 760 | + * @return object the form data |
| 761 | + */ |
| 762 | + getFormData: function () { |
| 763 | + var data = {}; |
| 764 | + return data; |
| 765 | + }, |
| 766 | + |
| 767 | + // }}} |
| 768 | + // {{{ localValidation |
| 769 | + |
| 770 | + /** |
| 771 | + * Performs any local validation |
| 772 | + * |
| 773 | + * @param object formdata the form data |
| 774 | + * @return mixed if ok, false; otherwise, an object as { 'field name' : 'message' } |
| 775 | + */ |
| 776 | + localValidation: function ( formdata ) { |
| 777 | + var error = {}; |
| 778 | + var ok = true; |
| 779 | + if ( $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-bucket3-toggle input[checked]' ).length < 1 ) { |
| 780 | + error.toggle = 'Please select an option'; |
| 781 | + ok = false; |
| 782 | + } |
| 783 | + return ok ? false : error; |
| 784 | + }, |
| 785 | + |
| 786 | + // }}} |
| 787 | + // {{{ markFormError |
| 788 | + |
| 789 | + /** |
| 790 | + * Marks any errors on the form |
| 791 | + * |
| 792 | + * @param object error errors, indexed by field name |
| 793 | + */ |
| 794 | + markFormError: function ( error ) { |
| 795 | + if ( '_api' in error ) { |
| 796 | + $.articleFeedbackv5.markShowstopperError( error._api.info ); |
| 797 | + } else { |
| 798 | + alert( 'Validation error' ); |
| 799 | + mw.log( 'Validation error' ); |
| 800 | + } |
| 801 | + console.log( error ); |
| 802 | + }, |
| 803 | + |
| 804 | + // }}} |
| 805 | + // {{{ setSuccessState |
| 806 | + |
| 807 | + /** |
| 808 | + * Sets the success state |
| 809 | + */ |
| 810 | + setSuccessState: function () { |
| 811 | + var $h = $.articleFeedbackv5.$holder; |
| 812 | + $h.find( '.articleFeedbackv5-success span' ).fadeIn( 'fast' ); |
| 813 | + $.articleFeedbackv5.successTimeout = setTimeout( function () { |
| 814 | + $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-success span' ) |
| 815 | + .fadeOut( 'slow' ); |
| 816 | + }, 5000 ); |
| 817 | + }, |
| 818 | + |
| 819 | + // }}} |
| 820 | + |
| 821 | + }, |
| 822 | + |
| 823 | + // }}} |
| 824 | + // {{{ Bucket 4 |
| 825 | + |
| 826 | + /** |
| 827 | + * Bucket 4: Help Improve This Article |
| 828 | + */ |
| 829 | + '4': { |
| 830 | + |
| 831 | + // {{{ buildForm |
| 832 | + |
| 833 | + /** |
| 834 | + * Builds the empty form |
| 835 | + * |
| 836 | + * @return Element the form |
| 837 | + */ |
| 838 | + buildForm: function () { |
| 839 | + |
| 840 | + // The overall template |
| 841 | + var block_tpl = '\ |
| 842 | + <form>\ |
| 843 | + <div class="title-wrap">\ |
| 844 | + <h2 class="articleFeedbackv5-title"><html:msg key="bucket4-title" /></h2>\ |
| 845 | + <a class="articleFeedbackv5-tooltip-trigger"></a>\ |
| 846 | + <div class="articleFeedbackv5-tooltip">\ |
| 847 | + <div class="tooltip-top"></div>\ |
| 848 | + <div class="tooltip-repeat">\ |
| 849 | + <h4><html:msg key="bucket4-tooltip-title" /></h4>\ |
| 850 | + <p><html:msg key="bucket4-tooltip-info" /></p>\ |
| 851 | + <p><a target="_blank" href="http://www.mediawiki.org/wiki/Article_feedback/Version_5"><html:msg key="bucket4-tooltip-linktext" /></a></p>\ |
| 852 | + </div>\ |
| 853 | + <div class="tooltip-bottom"></div>\ |
| 854 | + </div>\ |
| 855 | + <div class="clear"></div>\ |
| 856 | + </div>\ |
| 857 | + <div class="form-row articleFeedbackv5-bucket4-toggle">\ |
| 858 | + <p class="instructions-left"><html:msg key="bucket4-question-toggle" /></p>\ |
| 859 | + <div class="buttons">\ |
| 860 | + <div class="form-item" rel="yes" id="articleFeedbackv5-bucket4-toggle-wrapper-yes">\ |
| 861 | + <label for="articleFeedbackv5-bucket4-toggle-yes"><html:msg key="bucket4-toggle-found-yes-full" /></label>\ |
| 862 | + <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket4-toggle-found-yes" value="yes" /></span>\ |
| 863 | + <input type="radio" name="toggle" id="articleFeedbackv5-bucket4-toggle-yes" class="query-button" value="yes" />\ |
| 864 | + </div>\ |
| 865 | + <div class="form-item" rel="no" id="articleFeedbackv5-bucket4-toggle-wrapper-no">\ |
| 866 | + <label for="articleFeedbackv5-bucket4-toggle-no"><html:msg key="bucket4-toggle-found-no-full" /></label>\ |
| 867 | + <span class="articleFeedbackv5-button-placeholder"><html:msg key="bucket4-toggle-found-no" /></span>\ |
| 868 | + <input type="radio" name="toggle" id="articleFeedbackv5-bucket4-toggle-no" class="query-button last" value="no" />\ |
| 869 | + </div>\ |
| 870 | + <div class="clear"></div>\ |
| 871 | + </div>\ |
| 872 | + <div class="clear"></div>\ |
| 873 | + </div>\ |
| 874 | + <div class="articleFeedbackv5-comment">\ |
| 875 | + <textarea id="find-feedback" class="feedback-text" name="comment"></textarea>\ |
| 876 | + </div>\ |
| 877 | + <div class="articleFeedbackv5-disclosure">\ |
| 878 | + <p class="articlefeedbackv5-shared-on-feedback"></p>\ |
| 879 | + <p class="articlefeedbackv5-transparency-terms"></p>\ |
| 880 | + </div>\ |
| 881 | + <button class="articleFeedbackv5-submit" type="submit" disabled="disabled"><html:msg key="bucket4-form-submit" /></button>\ |
| 882 | + <div class="clear"></div>\ |
| 883 | + </form>\ |
| 884 | + '; |
| 885 | + // Start up the block to return |
| 886 | + var $block = $( block_tpl ); |
| 887 | + |
| 888 | + // Start out the tooltip hidden |
| 889 | + $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
| 890 | + |
| 891 | + // Fill in the disclosure text |
| 892 | + $block.find( '.articlefeedbackv5-shared-on-feedback' ) |
| 893 | + .html( $.articleFeedbackv5.buildLink( |
| 894 | + 'articlefeedbackv5-shared-on-feedback', |
| 895 | + { |
| 896 | + href: mw.config.get( 'wgScript' ) + '?' + $.param( { |
| 897 | + title: mw.config.get( 'wgPageName' ), |
| 898 | + action: 'feedback' |
| 899 | + } ), |
| 900 | + text: 'articlefeedbackv5-shared-on-feedback-linktext', |
| 901 | + target: '_blank' |
| 902 | + } ) ); |
| 903 | + $block.find( '.articlefeedbackv5-transparency-terms' ) |
| 904 | + .html( $.articleFeedbackv5.buildLink( |
| 905 | + 'articlefeedbackv5-transparency-terms', |
| 906 | + { |
| 907 | + href: mw.util.wikiGetlink( mw.config.get( 'wgArticleFeedbackv5TermsPage' ) ), |
| 908 | + text: 'articlefeedbackv5-transparency-terms-linktext', |
| 909 | + target: '_blank' |
| 910 | + } ) ); |
| 911 | + |
| 912 | + // Localize the block |
| 913 | + $block.localize( { 'prefix': 'articlefeedbackv5-' } ); |
| 914 | + |
| 915 | + // Turn the submit into a slick button |
| 916 | + $block.find( '.articleFeedbackv5-submit' ) |
| 917 | + .button() |
| 918 | + .addClass( 'ui-button-blue' ) |
| 919 | + |
| 920 | + return $block; |
| 921 | + }, |
| 922 | + |
| 923 | + // }}} |
| 924 | + // {{{ bindEvents |
| 925 | + |
| 926 | + /** |
| 927 | + * Binds any events |
| 928 | + * |
| 929 | + * @param $block element the form block |
| 930 | + */ |
| 931 | + bindEvents: function ( $block ) { |
| 932 | + |
| 933 | + // Attach the submit |
| 934 | + $block.find( '.articleFeedbackv5-submit' ) |
| 935 | + .click( function ( e ) { |
| 936 | + e.preventDefault(); |
| 937 | + $.articleFeedbackv5.submitForm(); |
| 938 | + } ); |
| 939 | + |
| 940 | + }, |
| 941 | + |
| 942 | + // }}} |
| 943 | + // {{{ enableSubmission |
| 944 | + |
| 945 | + /** |
| 946 | + * Enables or disables submission of the form |
| 947 | + * |
| 948 | + * @param state bool true to enable; false to disable |
| 949 | + */ |
| 950 | + enableSubmission: function ( state ) { |
| 951 | + var $h = $.articleFeedbackv5.$holder; |
| 952 | + if ( state ) { |
| 953 | + if ($.articleFeedbackv5.successTimeout) { |
| 954 | + clearTimeout( $.articleFeedbackv5.successTimeout ); |
| 955 | + } |
| 956 | + $h.find( '.articleFeedbackv5-submit' ).button( { 'disabled': false } ); |
| 957 | + $h.find( '.articleFeedbackv5-success span' ).hide(); |
| 958 | + $h.find( '.articleFeedbackv5-pending span' ).fadeIn( 'fast' ); |
| 959 | + } else { |
| 960 | + $h.find( '.articleFeedbackv5-submit' ).button( { 'disabled': true } ); |
| 961 | + $h.find( '.articleFeedbackv5-pending span' ).hide(); |
| 962 | + } |
| 963 | + }, |
| 964 | + |
| 965 | + // }}} |
| 966 | + // {{{ getFormData |
| 967 | + |
| 968 | + /** |
| 969 | + * Pulls down form data |
| 970 | + * |
| 971 | + * @return object the form data |
| 972 | + */ |
| 973 | + getFormData: function () { |
| 974 | + var data = {}; |
| 975 | + return data; |
| 976 | + }, |
| 977 | + |
| 978 | + // }}} |
| 979 | + // {{{ localValidation |
| 980 | + |
| 981 | + /** |
| 982 | + * Performs any local validation |
| 983 | + * |
| 984 | + * @param object formdata the form data |
| 985 | + * @return mixed if ok, false; otherwise, an object as { 'field name' : 'message' } |
| 986 | + */ |
| 987 | + localValidation: function ( formdata ) { |
| 988 | + var error = {}; |
| 989 | + var ok = true; |
| 990 | + if ( $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-bucket4-toggle input[checked]' ).length < 1 ) { |
| 991 | + error.toggle = 'Please select an option'; |
| 992 | + ok = false; |
| 993 | + } |
| 994 | + return ok ? false : error; |
| 995 | + }, |
| 996 | + |
| 997 | + // }}} |
| 998 | + // {{{ markFormError |
| 999 | + |
| 1000 | + /** |
| 1001 | + * Marks any errors on the form |
| 1002 | + * |
| 1003 | + * @param object error errors, indexed by field name |
| 1004 | + */ |
| 1005 | + markFormError: function ( error ) { |
| 1006 | + if ( '_api' in error ) { |
| 1007 | + $.articleFeedbackv5.markShowstopperError( error._api.info ); |
| 1008 | + } else { |
| 1009 | + alert( 'Validation error' ); |
| 1010 | + mw.log( 'Validation error' ); |
| 1011 | + } |
| 1012 | + console.log( error ); |
| 1013 | + }, |
| 1014 | + |
| 1015 | + // }}} |
| 1016 | + // {{{ setSuccessState |
| 1017 | + |
| 1018 | + /** |
| 1019 | + * Sets the success state |
| 1020 | + */ |
| 1021 | + setSuccessState: function () { |
| 1022 | + var $h = $.articleFeedbackv5.$holder; |
| 1023 | + $h.find( '.articleFeedbackv5-success span' ).fadeIn( 'fast' ); |
| 1024 | + $.articleFeedbackv5.successTimeout = setTimeout( function () { |
| 1025 | + $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-success span' ) |
| 1026 | + .fadeOut( 'slow' ); |
| 1027 | + }, 5000 ); |
| 1028 | + }, |
| 1029 | + |
| 1030 | + // }}} |
| 1031 | + |
| 1032 | + }, |
| 1033 | + |
| 1034 | + // }}} |
394 | 1035 | // {{{ Bucket 5 |
395 | 1036 | |
396 | 1037 | /** |
— | — | @@ -1074,15 +1715,7 @@ |
1075 | 1716 | }, |
1076 | 1717 | |
1077 | 1718 | // }}} |
1078 | | - // {{{ Bucket 6 |
1079 | 1719 | |
1080 | | - /** |
1081 | | - * Bucket 6: No form |
1082 | | - */ |
1083 | | - '6': { } |
1084 | | - |
1085 | | - // }}} |
1086 | | - |
1087 | 1720 | }; |
1088 | 1721 | |
1089 | 1722 | // }}} |
— | — | @@ -1252,7 +1885,7 @@ |
1253 | 1886 | // 1. Requested in query string (debug only) |
1254 | 1887 | // 2. From cookie (see below) |
1255 | 1888 | // 3. Core bucketing |
1256 | | - var knownBuckets = { 1: true, 5: true, 6: true }; |
| 1889 | + var knownBuckets = { 0: true, 1: true, 2: true, 3: true, 5: true }; |
1257 | 1890 | var requested = mw.util.getParamValue( 'bucket' ); |
1258 | 1891 | var cookieval = $.cookie( $.articleFeedbackv5.prefix( 'display-bucket' ) ); |
1259 | 1892 | if ( $.articleFeedbackv5.debug && requested in knownBuckets ) { |