r114968 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114967‎ | r114968 | r114969 >
Date:18:21, 19 April 2012
Author:catrope
Status:deferred
Tags:
Comment:
1.19wmf1: Update ArticleFeedbackv5 from git (wmf/1.20wmf1)
Modified paths:
  • /branches/wmf/1.19wmf1/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -578,9 +578,10 @@
579579 /**
580580 * Builds the empty form
581581 *
 582+ * @param from string from whence came the request ("bottom" or "overlay")
582583 * @return Element the form
583584 */
584 - buildForm: function () {
 585+ buildForm: function ( from ) {
585586
586587 // Start up the block to return
587588 var $block = $( $.articleFeedbackv5.editable ? $.articleFeedbackv5.currentBucket().templates.editable : $.articleFeedbackv5.currentBucket().templates.noneditable );
@@ -590,11 +591,10 @@
591592 .attr( 'href', mw.msg( 'articlefeedbackv5-cta1-learn-how-url' ) );
592593
593594 // 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;
596596 if ( $.articleFeedbackv5.editable ) {
597597 $block.find( '.articleFeedbackv5-cta-button' )
598 - .attr( 'href', $.articleFeedbackv5.editUrl( track_id ) );
 598+ .attr( 'href', $.articleFeedbackv5.editUrl( track_id, from ) );
599599 } else {
600600 var learn_url = mw.msg( 'articlefeedbackv5-cta1-learn-how-url' );
601601 $block.find( '.articleFeedbackv5-cta-button' )
@@ -628,6 +628,22 @@
629629 $.articleFeedbackv5.find( '.articleFeedbackv5-ui' )
630630 .addClass( 'articleFeedbackv5-option-4-noedit' );
631631 }
 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+ }
632648 }
633649
634650 // }}}
@@ -1882,8 +1898,10 @@
18831899 * Builds the edit URL, with tracking if appropriate
18841900 *
18851901 * @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
18861904 */
1887 - $.articleFeedbackv5.editUrl = function ( trackingId ) {
 1905+ $.articleFeedbackv5.editUrl = function ( trackingId, from ) {
18881906 var params = {
18891907 'title': mw.config.get( 'wgPageName' ),
18901908 'action': 'edit',
@@ -1896,7 +1914,11 @@
18971915 params.articleFeedbackv5_link_id = $.articleFeedbackv5.submittedLinkId;
18981916 params.articleFeedbackv5_f_link_id = $.articleFeedbackv5.floatingLinkId;
18991917 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+ }
19011923 }
19021924 var url = mw.config.get( 'wgScript' ) + '?' + $.param( params );
19031925 if ( trackingId ) {
@@ -2034,7 +2056,7 @@
20352057
20362058 // Build the form
20372059 var bucket = $.articleFeedbackv5.currentBucket();
2038 - var $block = bucket.buildForm();
 2060+ var $block = bucket.buildForm( from );
20392061 if ( 'bindEvents' in bucket ) {
20402062 bucket.bindEvents( $block );
20412063 }
@@ -2690,6 +2712,9 @@
26912713 if ( 'cta' == $.articleFeedbackv5.nowShowing ) {
26922714 $.articleFeedbackv5.clear();
26932715 }
 2716+ if ( 'onModalToggle' in $.articleFeedbackv5.currentBucket() ) {
 2717+ $.articleFeedbackv5.currentBucket().onModalToggle( 'bottom' );
 2718+ }
26942719 }
26952720 };
26962721
@@ -2708,6 +2733,9 @@
27092734 } else {
27102735 $.articleFeedbackv5.openAsModal( $link );
27112736 }
 2737+ if ( 'onModalToggle' in $.articleFeedbackv5.currentBucket() ) {
 2738+ $.articleFeedbackv5.currentBucket().onModalToggle( $.articleFeedbackv5.inDialog ? 'overlay' : 'bottom' );
 2739+ }
27122740 };
27132741
27142742 // }}}

Status & tagging log