Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | $.articleFeedbackv5.feedbackId = 0; |
135 | 135 | |
136 | 136 | // }}} |
137 | | - // {{{ Templates shared by multiple buckets/ctas |
| 137 | + // {{{ Templates |
138 | 138 | |
139 | 139 | $.articleFeedbackv5.templates = { |
140 | 140 | |
— | — | @@ -245,14 +245,9 @@ |
246 | 246 | // Start up the block to return |
247 | 247 | var $block = $( $.articleFeedbackv5.currentBucket().templates.block ); |
248 | 248 | |
249 | | - // Add the help tooltip to the title |
250 | | - $block.find( '.title-wrap' ) |
251 | | - .append( $.articleFeedbackv5.templates.helpToolTip ) |
252 | | - .append( $.articleFeedbackv5.templates.clear ); |
| 249 | + // Add the help button |
| 250 | + $.articleFeedbackv5.addHelpButton( $block ); |
253 | 251 | |
254 | | - // Start out the tooltip hidden |
255 | | - $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
256 | | - |
257 | 252 | // Fill in the disclosure text |
258 | 253 | $block.find( '.articlefeedbackv5-shared-on-feedback' ) |
259 | 254 | .html( $.articleFeedbackv5.buildLink( |
— | — | @@ -295,11 +290,6 @@ |
296 | 291 | */ |
297 | 292 | bindEvents: function ( $block ) { |
298 | 293 | |
299 | | - // Tooltip |
300 | | - $block.find( '.articleFeedbackv5-tooltip-trigger' ).click( function () { |
301 | | - $.articleFeedbackv5.find( '.articleFeedbackv5-tooltip' ).toggle(); |
302 | | - } ); |
303 | | - |
304 | 294 | // Enable submission and switch out the comment default on toggle selection |
305 | 295 | $block.find( '.articleFeedbackv5-button-placeholder' ) |
306 | 296 | .click( function ( e ) { |
— | — | @@ -514,17 +504,11 @@ |
515 | 505 | $tag.appendTo( $( this ) ); |
516 | 506 | } |
517 | 507 | $( $.articleFeedbackv5.templates.clear ).appendTo( $( this ) ); |
518 | | - |
519 | 508 | } ); |
520 | 509 | |
521 | | - // Add the help tooltip to the title |
522 | | - $block.find( '.title-wrap' ) |
523 | | - .append( $.articleFeedbackv5.templates.helpToolTip ) |
524 | | - .append( $.articleFeedbackv5.templates.clear ); |
| 510 | + // Add the help button |
| 511 | + $.articleFeedbackv5.addHelpButton( $block ); |
525 | 512 | |
526 | | - // Start out the tooltip hidden |
527 | | - $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
528 | | - |
529 | 513 | // Fill in the disclosure text |
530 | 514 | $block.find( '.articlefeedbackv5-shared-on-feedback' ) |
531 | 515 | .html( $.articleFeedbackv5.buildLink( |
— | — | @@ -567,11 +551,6 @@ |
568 | 552 | */ |
569 | 553 | bindEvents: function ( $block ) { |
570 | 554 | |
571 | | - // Tooltip |
572 | | - $block.find( '.articleFeedbackv5-tooltip-trigger' ).click( function () { |
573 | | - $.articleFeedbackv5.find( '.articleFeedbackv5-tooltip' ).toggle(); |
574 | | - } ); |
575 | | - |
576 | 555 | // Enable submission and switch out the comment default on toggle selection |
577 | 556 | $block.find( '.articleFeedbackv5-tags li' ) |
578 | 557 | .click( function ( e ) { |
— | — | @@ -775,14 +754,9 @@ |
776 | 755 | // Start up the block to return |
777 | 756 | var $block = $( $.articleFeedbackv5.currentBucket().templates.block ); |
778 | 757 | |
779 | | - // Add the help tooltip to the title |
780 | | - $block.find( '.title-wrap' ) |
781 | | - .append( $.articleFeedbackv5.templates.helpToolTip ) |
782 | | - .append( $.articleFeedbackv5.templates.clear ); |
| 758 | + // Add the help button |
| 759 | + $.articleFeedbackv5.addHelpButton( $block ); |
783 | 760 | |
784 | | - // Start out the tooltip hidden |
785 | | - $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
786 | | - |
787 | 761 | // Fill in the rating clear title |
788 | 762 | var clear_msg = mw.msg( 'articlefeedbackv5-bucket3-clear-rating' ); |
789 | 763 | $block.find( '.articleFeedback-rating-clear' ) |
— | — | @@ -835,11 +809,6 @@ |
836 | 810 | */ |
837 | 811 | bindEvents: function ( $block ) { |
838 | 812 | |
839 | | - // Tooltip |
840 | | - $block.find( '.articleFeedbackv5-tooltip-trigger' ).click( function () { |
841 | | - $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-tooltip' ).toggle(); |
842 | | - } ); |
843 | | - |
844 | 813 | // Set up rating behavior |
845 | 814 | var rlabel = $block.find( '.articleFeedbackv5-rating-label' ); |
846 | 815 | rlabel.hover( function () { |
— | — | @@ -1040,14 +1009,9 @@ |
1041 | 1010 | // Start up the block to return |
1042 | 1011 | var $block = $( $.articleFeedbackv5.currentBucket().templates.block ); |
1043 | 1012 | |
1044 | | - // Add the help tooltip to the title |
1045 | | - $block.find( '.title-wrap' ) |
1046 | | - .append( $.articleFeedbackv5.templates.helpToolTip ) |
1047 | | - .append( $.articleFeedbackv5.templates.clear ); |
| 1013 | + // Add the help button |
| 1014 | + $.articleFeedbackv5.addHelpButton( $block ); |
1048 | 1015 | |
1049 | | - // Start out the tooltip hidden |
1050 | | - $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
1051 | | - |
1052 | 1016 | // Fill in the learn to edit link |
1053 | 1017 | $block.find( '.articleFeedbackv5-learn-to-edit' ) |
1054 | 1018 | .attr( 'href', mw.config.get( 'wgArticleFeedbackv5LearnToEdit' ) ); |
— | — | @@ -1073,23 +1037,6 @@ |
1074 | 1038 | .addClass( 'ui-button-blue' ) |
1075 | 1039 | |
1076 | 1040 | return $block; |
1077 | | - }, |
1078 | | - |
1079 | | - // }}} |
1080 | | - // {{{ bindEvents |
1081 | | - |
1082 | | - /** |
1083 | | - * Binds any events |
1084 | | - * |
1085 | | - * @param $block element the form block |
1086 | | - */ |
1087 | | - bindEvents: function ( $block ) { |
1088 | | - |
1089 | | - // Tooltip |
1090 | | - $block.find( '.articleFeedbackv5-tooltip-trigger' ).click( function () { |
1091 | | - $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-tooltip' ).toggle(); |
1092 | | - } ); |
1093 | | - |
1094 | 1041 | } |
1095 | 1042 | |
1096 | 1043 | // }}} |
— | — | @@ -1842,6 +1789,8 @@ |
1843 | 1790 | // }}} |
1844 | 1791 | // {{{ Initialization |
1845 | 1792 | |
| 1793 | + // {{{ init |
| 1794 | + |
1846 | 1795 | /** |
1847 | 1796 | * Initializes the object |
1848 | 1797 | * |
— | — | @@ -1870,6 +1819,9 @@ |
1871 | 1820 | } ); |
1872 | 1821 | }; |
1873 | 1822 | |
| 1823 | + // }}} |
| 1824 | + // {{{ selectBucket |
| 1825 | + |
1874 | 1826 | /** |
1875 | 1827 | * Chooses a bucket and loads the appropriate form |
1876 | 1828 | * |
— | — | @@ -1909,8 +1861,12 @@ |
1910 | 1862 | }; |
1911 | 1863 | |
1912 | 1864 | // }}} |
| 1865 | + |
| 1866 | + // }}} |
1913 | 1867 | // {{{ Utility methods |
1914 | 1868 | |
| 1869 | + // {{{ prefix |
| 1870 | + |
1915 | 1871 | /** |
1916 | 1872 | * Utility method: Prefixes a key for cookies or events with extension and |
1917 | 1873 | * version information |
— | — | @@ -1923,6 +1879,9 @@ |
1924 | 1880 | return 'ext.articleFeedbackv5@' + version + '-' + key; |
1925 | 1881 | }; |
1926 | 1882 | |
| 1883 | + // }}} |
| 1884 | + // {{{ currentBucket |
| 1885 | + |
1927 | 1886 | /** |
1928 | 1887 | * Utility method: Get the current bucket |
1929 | 1888 | * |
— | — | @@ -1932,6 +1891,9 @@ |
1933 | 1892 | return $.articleFeedbackv5.buckets[$.articleFeedbackv5.bucketId]; |
1934 | 1893 | }; |
1935 | 1894 | |
| 1895 | + // }}} |
| 1896 | + // {{{ currentCTA |
| 1897 | + |
1936 | 1898 | /** |
1937 | 1899 | * Utility method: Get the current CTA |
1938 | 1900 | * |
— | — | @@ -1941,7 +1903,31 @@ |
1942 | 1904 | return $.articleFeedbackv5.ctas[$.articleFeedbackv5.ctaId]; |
1943 | 1905 | }; |
1944 | 1906 | |
| 1907 | + // }}} |
| 1908 | + // {{{ addHelpButton |
| 1909 | + |
1945 | 1910 | /** |
| 1911 | + * Utility method: add a help button to the titlebar (with bound event) |
| 1912 | + * |
| 1913 | + * @param Element $block the form block |
| 1914 | + */ |
| 1915 | + $.articleFeedbackv5.addHelpButton = function ( $block ) { |
| 1916 | + // Add the help tooltip to the title |
| 1917 | + $block.find( '.title-wrap' ) |
| 1918 | + .append( $.articleFeedbackv5.templates.helpToolTip ) |
| 1919 | + .append( $.articleFeedbackv5.templates.clear ); |
| 1920 | + // Start out the tooltip hidden |
| 1921 | + $block.find( '.articleFeedbackv5-tooltip' ).hide(); |
| 1922 | + // Toogle on click |
| 1923 | + $block.find( '.articleFeedbackv5-tooltip-trigger' ).click( function () { |
| 1924 | + $.articleFeedbackv5.find( '.articleFeedbackv5-tooltip' ).toggle(); |
| 1925 | + } ); |
| 1926 | + }; |
| 1927 | + |
| 1928 | + // }}} |
| 1929 | + // {{{ buildLink |
| 1930 | + |
| 1931 | + /** |
1946 | 1932 | * Utility method: Build a link from a href and message keys for the full |
1947 | 1933 | * text (with $1 where the link goes) and link text |
1948 | 1934 | * |
— | — | @@ -1977,6 +1963,9 @@ |
1978 | 1964 | return full; |
1979 | 1965 | }; |
1980 | 1966 | |
| 1967 | + // }}} |
| 1968 | + // {{{ enableSubmission |
| 1969 | + |
1981 | 1970 | /** |
1982 | 1971 | * Utility method: Enables or disables submission of the form |
1983 | 1972 | * |
— | — | @@ -1994,6 +1983,9 @@ |
1995 | 1984 | } |
1996 | 1985 | }; |
1997 | 1986 | |
| 1987 | + // }}} |
| 1988 | + // {{{ find |
| 1989 | + |
1998 | 1990 | /** |
1999 | 1991 | * Utility method: Find an element, whether it's in the dialog or not |
2000 | 1992 | * |
— | — | @@ -2009,8 +2001,12 @@ |
2010 | 2002 | }; |
2011 | 2003 | |
2012 | 2004 | // }}} |
2013 | | - // {{{ Form loading methods |
2014 | 2005 | |
| 2006 | + // }}} |
| 2007 | + // {{{ Process methods |
| 2008 | + |
| 2009 | + // {{{ loadForm |
| 2010 | + |
2015 | 2011 | /** |
2016 | 2012 | * Build the form and load it into the document |
2017 | 2013 | */ |
— | — | @@ -2065,7 +2061,7 @@ |
2066 | 2062 | }; |
2067 | 2063 | |
2068 | 2064 | // }}} |
2069 | | - // {{{ Form submission methods |
| 2065 | + // {{{ submitForm |
2070 | 2066 | |
2071 | 2067 | /** |
2072 | 2068 | * Submits the form |
— | — | @@ -2163,54 +2159,29 @@ |
2164 | 2160 | }; |
2165 | 2161 | |
2166 | 2162 | // }}} |
2167 | | - // {{{ Outside interaction methods |
| 2163 | + // {{{ showCTA |
2168 | 2164 | |
2169 | 2165 | /** |
2170 | | - * Sets the link ID |
2171 | | - * |
2172 | | - * @param int linkId the link ID |
| 2166 | + * Shows a CTA |
2173 | 2167 | */ |
2174 | | - $.articleFeedbackv5.setLinkId = function ( linkId ) { |
2175 | | - var knownLinks = { '0': true, '1': true, '2': true, '3': true, '4': true }; |
2176 | | - if ( linkId in knownLinks ) { |
2177 | | - $.articleFeedbackv5.linkId = linkId + ''; |
| 2168 | + $.articleFeedbackv5.showCTA = function () { |
| 2169 | + var cta = $.articleFeedbackv5.currentCTA(); |
| 2170 | + if ( !( 'build' in cta ) ) { |
| 2171 | + return; |
2178 | 2172 | } |
2179 | | - }; |
2180 | | - |
2181 | | - /** |
2182 | | - * Opens the feedback tool as a modal window |
2183 | | - * |
2184 | | - * @param linkId string the link ID to set on open |
2185 | | - */ |
2186 | | - $.articleFeedbackv5.openAsModal = function ( linkId ) { |
2187 | | - $.articleFeedbackv5.setLinkId( linkId ); |
2188 | | - if ( !$.articleFeedbackv5.isLoaded ) { |
2189 | | - $.articleFeedbackv5.loadForm(); |
| 2173 | + var $block = cta.build(); |
| 2174 | + if ( 'bindEvents' in cta ) { |
| 2175 | + cta.bindEvents( $block ); |
2190 | 2176 | } |
2191 | | - if ( !$.articleFeedbackv5.inDialog ) { |
2192 | | - $inner = $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-panel' ).detach(); |
2193 | | - $.articleFeedbackv5.$dialog.append( $inner ); |
2194 | | - $.articleFeedbackv5.setLinkId( linkId ); |
2195 | | - $.articleFeedbackv5.$dialog.dialog( 'open' ); |
2196 | | - $.articleFeedbackv5.inDialog = true; |
2197 | | - } |
| 2177 | + $.articleFeedbackv5.$holder.html( $block ); |
2198 | 2178 | }; |
2199 | 2179 | |
2200 | | - /** |
2201 | | - * Closes the feedback tool as a modal window |
2202 | | - */ |
2203 | | - $.articleFeedbackv5.closeAsModal = function () { |
2204 | | - if ( $.articleFeedbackv5.inDialog ) { |
2205 | | - $.articleFeedbackv5.setLinkId( '0' ); |
2206 | | - $inner = $.articleFeedbackv5.$dialog.find( '.articleFeedbackv5-panel' ).detach(); |
2207 | | - $.articleFeedbackv5.$holder.append( $inner ); |
2208 | | - $.articleFeedbackv5.inDialog = false; |
2209 | | - } |
2210 | | - }; |
2211 | | - |
2212 | 2180 | // }}} |
| 2181 | + // }}} |
2213 | 2182 | // {{{ UI methods |
2214 | 2183 | |
| 2184 | + // {{{ markShowstopperError |
| 2185 | + |
2215 | 2186 | /** |
2216 | 2187 | * Marks a showstopper error |
2217 | 2188 | * |
— | — | @@ -2233,6 +2204,9 @@ |
2234 | 2205 | veil.show(); |
2235 | 2206 | }; |
2236 | 2207 | |
| 2208 | + // }}} |
| 2209 | + // {{{ lockForm |
| 2210 | + |
2237 | 2211 | /** |
2238 | 2212 | * Locks the form |
2239 | 2213 | */ |
— | — | @@ -2242,6 +2216,9 @@ |
2243 | 2217 | $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-lock' ).show(); |
2244 | 2218 | }; |
2245 | 2219 | |
| 2220 | + // }}} |
| 2221 | + // {{{ unlockForm |
| 2222 | + |
2246 | 2223 | /** |
2247 | 2224 | * Unlocks the form |
2248 | 2225 | */ |
— | — | @@ -2252,25 +2229,65 @@ |
2253 | 2230 | }; |
2254 | 2231 | |
2255 | 2232 | // }}} |
2256 | | - // {{{ CTA methods |
2257 | 2233 | |
| 2234 | + // }}} |
| 2235 | + // {{{ Outside interaction methods |
| 2236 | + |
| 2237 | + // {{{ setLinkId |
| 2238 | + |
2258 | 2239 | /** |
2259 | | - * Shows a CTA |
| 2240 | + * Sets the link ID |
| 2241 | + * |
| 2242 | + * @param int linkId the link ID |
2260 | 2243 | */ |
2261 | | - $.articleFeedbackv5.showCTA = function () { |
2262 | | - var cta = $.articleFeedbackv5.currentCTA(); |
2263 | | - if ( !( 'build' in cta ) ) { |
2264 | | - return; |
| 2244 | + $.articleFeedbackv5.setLinkId = function ( linkId ) { |
| 2245 | + var knownLinks = { '0': true, '1': true, '2': true, '3': true, '4': true }; |
| 2246 | + if ( linkId in knownLinks ) { |
| 2247 | + $.articleFeedbackv5.linkId = linkId + ''; |
2265 | 2248 | } |
2266 | | - var $block = cta.build(); |
2267 | | - if ( 'bindEvents' in cta ) { |
2268 | | - cta.bindEvents( $block ); |
| 2249 | + }; |
| 2250 | + |
| 2251 | + // }}} |
| 2252 | + // {{{ openAsModal |
| 2253 | + |
| 2254 | + /** |
| 2255 | + * Opens the feedback tool as a modal window |
| 2256 | + * |
| 2257 | + * @param linkId string the link ID to set on open |
| 2258 | + */ |
| 2259 | + $.articleFeedbackv5.openAsModal = function ( linkId ) { |
| 2260 | + $.articleFeedbackv5.setLinkId( linkId ); |
| 2261 | + if ( !$.articleFeedbackv5.isLoaded ) { |
| 2262 | + $.articleFeedbackv5.loadForm(); |
2269 | 2263 | } |
2270 | | - $.articleFeedbackv5.$holder.html( $block ); |
| 2264 | + if ( !$.articleFeedbackv5.inDialog ) { |
| 2265 | + $inner = $.articleFeedbackv5.$holder.find( '.articleFeedbackv5-panel' ).detach(); |
| 2266 | + $.articleFeedbackv5.$dialog.append( $inner ); |
| 2267 | + $.articleFeedbackv5.setLinkId( linkId ); |
| 2268 | + $.articleFeedbackv5.$dialog.dialog( 'open' ); |
| 2269 | + $.articleFeedbackv5.inDialog = true; |
| 2270 | + } |
2271 | 2271 | }; |
2272 | 2272 | |
2273 | 2273 | // }}} |
| 2274 | + // {{{ closeAsModal |
2274 | 2275 | |
| 2276 | + /** |
| 2277 | + * Closes the feedback tool as a modal window |
| 2278 | + */ |
| 2279 | + $.articleFeedbackv5.closeAsModal = function () { |
| 2280 | + if ( $.articleFeedbackv5.inDialog ) { |
| 2281 | + $.articleFeedbackv5.setLinkId( '0' ); |
| 2282 | + $inner = $.articleFeedbackv5.$dialog.find( '.articleFeedbackv5-panel' ).detach(); |
| 2283 | + $.articleFeedbackv5.$holder.append( $inner ); |
| 2284 | + $.articleFeedbackv5.inDialog = false; |
| 2285 | + } |
| 2286 | + }; |
| 2287 | + |
| 2288 | + // }}} |
| 2289 | + |
| 2290 | + // }}} |
| 2291 | + |
2275 | 2292 | // }}} |
2276 | 2293 | // {{{ articleFeedbackv5 plugin |
2277 | 2294 | |