Index: branches/wmf/1.19wmf1/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js |
— | — | @@ -578,9 +578,10 @@ |
579 | 579 | /** |
580 | 580 | * Builds the empty form |
581 | 581 | * |
| 582 | + * @param from string from whence came the request ("bottom" or "overlay") |
582 | 583 | * @return Element the form |
583 | 584 | */ |
584 | | - buildForm: function () { |
| 585 | + buildForm: function ( from ) { |
585 | 586 | |
586 | 587 | // Start up the block to return |
587 | 588 | var $block = $( $.articleFeedbackv5.editable ? $.articleFeedbackv5.currentBucket().templates.editable : $.articleFeedbackv5.currentBucket().templates.noneditable ); |
— | — | @@ -590,11 +591,10 @@ |
591 | 592 | .attr( 'href', mw.msg( 'articlefeedbackv5-cta1-learn-how-url' ) ); |
592 | 593 | |
593 | 594 | // Fill in the button link |
594 | | - var track_id = $.articleFeedbackv5.experiment() + '-button_click-' + |
595 | | - ( $.articleFeedbackv5.inDialog ? 'overlay' : 'bottom' ); |
| 595 | + var track_id = $.articleFeedbackv5.experiment() + '-button_click-' + from; |
596 | 596 | if ( $.articleFeedbackv5.editable ) { |
597 | 597 | $block.find( '.articleFeedbackv5-cta-button' ) |
598 | | - .attr( 'href', $.articleFeedbackv5.editUrl( track_id ) ); |
| 598 | + .attr( 'href', $.articleFeedbackv5.editUrl( track_id, from ) ); |
599 | 599 | } else { |
600 | 600 | var learn_url = mw.msg( 'articlefeedbackv5-cta1-learn-how-url' ); |
601 | 601 | $block.find( '.articleFeedbackv5-cta-button' ) |
— | — | @@ -628,6 +628,22 @@ |
629 | 629 | $.articleFeedbackv5.find( '.articleFeedbackv5-ui' ) |
630 | 630 | .addClass( 'articleFeedbackv5-option-4-noedit' ); |
631 | 631 | } |
| 632 | + }, |
| 633 | + |
| 634 | + // }}} |
| 635 | + // {{{ onModalToggle |
| 636 | + |
| 637 | + /** |
| 638 | + * Handles any setup that has to be done when the modal window gets |
| 639 | + * toggled on or off |
| 640 | + */ |
| 641 | + onModalToggle: function ( from ) { |
| 642 | + // Fill in the button link |
| 643 | + if ( $.articleFeedbackv5.editable ) { |
| 644 | + var track_id = $.articleFeedbackv5.experiment() + '-button_click-' + from; |
| 645 | + $.articleFeedbackv5.find( '.articleFeedbackv5-cta-button' ) |
| 646 | + .attr( 'href', $.articleFeedbackv5.editUrl( track_id, from ) ); |
| 647 | + } |
632 | 648 | } |
633 | 649 | |
634 | 650 | // }}} |
— | — | @@ -1882,8 +1898,10 @@ |
1883 | 1899 | * Builds the edit URL, with tracking if appropriate |
1884 | 1900 | * |
1885 | 1901 | * @param trackingId string the tracking ID |
| 1902 | + * @param from string from whence came the request ("bottom" or "overlay"), |
| 1903 | + * since the build process happens before inDialog gets set |
1886 | 1904 | */ |
1887 | | - $.articleFeedbackv5.editUrl = function ( trackingId ) { |
| 1905 | + $.articleFeedbackv5.editUrl = function ( trackingId, from ) { |
1888 | 1906 | var params = { |
1889 | 1907 | 'title': mw.config.get( 'wgPageName' ), |
1890 | 1908 | 'action': 'edit', |
— | — | @@ -1896,7 +1914,11 @@ |
1897 | 1915 | params.articleFeedbackv5_link_id = $.articleFeedbackv5.submittedLinkId; |
1898 | 1916 | params.articleFeedbackv5_f_link_id = $.articleFeedbackv5.floatingLinkId; |
1899 | 1917 | params.articleFeedbackv5_experiment = $.articleFeedbackv5.experiment(); |
1900 | | - params.articleFeedbackv5_location = $.articleFeedbackv5.inDialog ? 'overlay' : 'bottom'; |
| 1918 | + if ( from ) { |
| 1919 | + params.articleFeedbackv5_location = from; |
| 1920 | + } else { |
| 1921 | + params.articleFeedbackv5_location = $.articleFeedbackv5.inDialog ? 'overlay' : 'bottom'; |
| 1922 | + } |
1901 | 1923 | } |
1902 | 1924 | var url = mw.config.get( 'wgScript' ) + '?' + $.param( params ); |
1903 | 1925 | if ( trackingId ) { |
— | — | @@ -2034,7 +2056,7 @@ |
2035 | 2057 | |
2036 | 2058 | // Build the form |
2037 | 2059 | var bucket = $.articleFeedbackv5.currentBucket(); |
2038 | | - var $block = bucket.buildForm(); |
| 2060 | + var $block = bucket.buildForm( from ); |
2039 | 2061 | if ( 'bindEvents' in bucket ) { |
2040 | 2062 | bucket.bindEvents( $block ); |
2041 | 2063 | } |
— | — | @@ -2690,6 +2712,9 @@ |
2691 | 2713 | if ( 'cta' == $.articleFeedbackv5.nowShowing ) { |
2692 | 2714 | $.articleFeedbackv5.clear(); |
2693 | 2715 | } |
| 2716 | + if ( 'onModalToggle' in $.articleFeedbackv5.currentBucket() ) { |
| 2717 | + $.articleFeedbackv5.currentBucket().onModalToggle( 'bottom' ); |
| 2718 | + } |
2694 | 2719 | } |
2695 | 2720 | }; |
2696 | 2721 | |
— | — | @@ -2708,6 +2733,9 @@ |
2709 | 2734 | } else { |
2710 | 2735 | $.articleFeedbackv5.openAsModal( $link ); |
2711 | 2736 | } |
| 2737 | + if ( 'onModalToggle' in $.articleFeedbackv5.currentBucket() ) { |
| 2738 | + $.articleFeedbackv5.currentBucket().onModalToggle( $.articleFeedbackv5.inDialog ? 'overlay' : 'bottom' ); |
| 2739 | + } |
2712 | 2740 | }; |
2713 | 2741 | |
2714 | 2742 | // }}} |