r105747 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105746‎ | r105747 | r105748 >
Date:02:51, 10 December 2011
Author:rsterbin
Status:ok
Tags:
Comment:
Updated the jquery module to allow for a zeroth CTA: display nothing but the
confirmation message:
- Put the title confirmation for CTAs in the top-level templates as
ctaTitleConfirm
- Added ctas[0] with two methods: build(), returning an empty div, and
afterBuild(), to remove the tooltip trigger
- Removed getTitle() and the old title confirmation template from ctas[1]
- Updated showCTA() to set up the default title and added a hook for
CTAs to call afterBuild()

Also fixed some out-of-date comments
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -13,22 +13,23 @@
1414 * This plugin supports a choice of forms and CTAs. Each form option is called
1515 * a "bucket" because users are sorted into buckets and each bucket gets a
1616 * different form option. Right now, these buckets are:
17 - * 1. Share Your Feedback - NOT implemented
 17+ * 0. No Feedback
 18+ * Shows nothing at all.
 19+ * 1. Share Your Feedback
1820 * Has a yes/no toggle on "Did you find what you were looking for?" and a
1921 * text area for comments.
20 - * 2. Make A Suggestion - NOT implemented
 22+ * 2. Make A Suggestion
2123 * Modeled after getsatisfaction.com; users can say that their comment is a
2224 * suggestion, question, problem, or praise.
23 - * 3. Review This Page - NOT implemented
 25+ * 3. Review This Page
2426 * Has a single star rating field and a comment box.
25 - * 4. Help Edit This Page - NOT implemented
 27+ * 4. Help Edit This Page
2628 * Has no input fields; just links to the Edit page.
2729 * 5. Rate This Page
2830 * The existing article feedback tool, except that it can use any of the
2931 * CTA types.
30 - * 0. No Feedback
31 - * Shows nothing at all.
3232 * The available CTAs are:
 33+ * 0. Just a confirmation notice
3334 * 1. Edit this page
3435 * Just a big glossy button to send the user to the edit page.
3536 * 2. Take a survey - NOT implemented
@@ -190,6 +191,13 @@
191192
192193 helpToolTipTrigger: '<div class="articleFeedbackv5-tooltip-trigger-wrap"><a class="articleFeedbackv5-tooltip-trigger"></a></div>',
193194
 195+ ctaTitleConfirm: '\
 196+ <div class="articleFeedbackv5-confirmation-text">\
 197+ <span class="articleFeedbackv5-confirmation-thanks"><html:msg key="cta1-thanks" /></span>\
 198+ <span class="articleFeedbackv5-confirmation-follow-up"><html:msg key="cta1-confirmation-followup" /></span>\
 199+ </div>\
 200+ ',
 201+
194202 clear: '<div class="clear"></div>'
195203
196204 };
@@ -1535,7 +1543,7 @@
15361544 * holder
15371545 */
15381546 afterBuild: function () {
1539 - // Drop the tooltip and trigger
 1547+ // Drop the tooltip trigger
15401548 $.articleFeedbackv5.$holder
15411549 .add( $.articleFeedbackv5.$dialog)
15421550 .find( '.articleFeedbackv5-tooltip-trigger' ).hide();
@@ -1787,6 +1795,40 @@
17881796 */
17891797 $.articleFeedbackv5.ctas = {
17901798
 1799+ // {{{ CTA 0: Just a confirmation message
 1800+
 1801+ '0': {
 1802+
 1803+ // {{{ build
 1804+
 1805+ /**
 1806+ * Builds the CTA
 1807+ *
 1808+ * @return Element the form
 1809+ */
 1810+ build: function () {
 1811+ return $( '<div></div>' );
 1812+ },
 1813+
 1814+ // }}}
 1815+ // {{{ afterBuild
 1816+
 1817+ /**
 1818+ * Handles any setup that has to be done once the markup is in the
 1819+ * holder
 1820+ */
 1821+ afterBuild: function () {
 1822+ // Drop the tooltip trigger
 1823+ $.articleFeedbackv5.$holder
 1824+ .add( $.articleFeedbackv5.$dialog)
 1825+ .find( '.articleFeedbackv5-tooltip-trigger' ).hide();
 1826+ }
 1827+
 1828+ // }}}
 1829+
 1830+ },
 1831+
 1832+ // }}}
17911833 // {{{ CTA 1: Encticement to edit
17921834
17931835 '1': {
@@ -1812,36 +1854,11 @@
18131855 <a href="&amp;action=edit" class="articleFeedbackv5-edit-cta-link"><span class="ui-button-text"><html:msg key="cta1-edit-linktext" /></span></a>\
18141856 <div class="clear"></div>\
18151857 </div>\
1816 - ',
1817 -
1818 - /**
1819 - * The title/confirmation
1820 - */
1821 - titleConfirm: '\
1822 - <div class="articleFeedbackv5-confirmation-text">\
1823 - <span class="articleFeedbackv5-confirmation-thanks"><html:msg key="cta1-thanks" /></span>\
1824 - <span class="articleFeedbackv5-confirmation-follow-up"><html:msg key="cta1-confirmation-followup" /></span>\
1825 - </div>\
18261858 '
18271859
18281860 },
18291861
18301862 // }}}
1831 - // {{{ getTitle
1832 -
1833 - /**
1834 - * Gets the title
1835 - *
1836 - * @return string the title
1837 - */
1838 - getTitle: function () {
1839 -
1840 - var $title = $( '<div></div>' ).html( $.articleFeedbackv5.currentCTA().templates.titleConfirm );
1841 - $title.localize( { 'prefix': 'articlefeedbackv5-' } );
1842 - return $title.html();
1843 - },
1844 -
1845 - // }}}
18461863 // {{{ build
18471864
18481865 /**
@@ -2374,9 +2391,15 @@
23752392
23762393 // Set the title in both places
23772394 if ( 'getTitle' in cta ) {
2378 - $.articleFeedbackv5.$dialog.dialog( 'option', 'title', cta.getTitle() );
2379 - $.articleFeedbackv5.find( '.articleFeedbackv5-title' ).html( cta.getTitle() );
 2395+ var title = cta.getTitle();
 2396+ } else {
 2397+ var title = $( '<div></div>' )
 2398+ .html( $.articleFeedbackv5.templates.ctaTitleConfirm )
 2399+ .localize( { 'prefix': 'articlefeedbackv5-' } )
 2400+ .html();
23802401 }
 2402+ $.articleFeedbackv5.$dialog.dialog( 'option', 'title', title );
 2403+ $.articleFeedbackv5.find( '.articleFeedbackv5-title' ).html( title );
23812404
23822405 // Set the tooltip link
23832406 $.articleFeedbackv5.find( '.articleFeedbackv5-tooltip-link' )
@@ -2391,6 +2414,11 @@
23922415 $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-title-wrap .articleFeedbackv5-tooltip-trigger' )
23932416 .before( $close );
23942417
 2418+ // Do anything special the CTA requires
 2419+ if ( 'afterBuild' in cta ) {
 2420+ cta.afterBuild();
 2421+ }
 2422+
23952423 // Reset the panel dimensions
23962424 $.articleFeedbackv5.setDialogDimensions();
23972425

Status & tagging log