r96897 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96896‎ | r96897 | r96898 >
Date:20:32, 12 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r96896, also added docs and tweaked checkbox input layout
Modified paths:
  • /trunk/extensions/Survey/resources/ext.survey.tag.js (modified) (history)
  • /trunk/extensions/Survey/resources/jquery.survey.js (modified) (history)
  • /trunk/extensions/Survey/specials/SpecialSurvey.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Survey/specials/SpecialSurvey.php
@@ -169,6 +169,15 @@
170170 );
171171 }
172172
 173+ /**
 174+ * Get an array of numbers with as keys the formatted version of the values.
 175+ *
 176+ * @since 0.1
 177+ *
 178+ * @param array $numbers
 179+ *
 180+ * @return array
 181+ */
173182 protected function getNumericalOptions( array $numbers ) {
174183 $lang = $this->getLang();
175184
Index: trunk/extensions/Survey/resources/ext.survey.tag.js
@@ -21,12 +21,10 @@
2222 }
2323
2424 function setCookie( options, cookieValue ) {
25 - if ( options.cookie ) {
26 - var date = new Date();
27 - date.setTime( date.getTime() + options.expiry * 1000 );
28 - $.cookie( getCookieName( options ), cookieValue, { 'expires': date, 'path': '/' } );
29 - survey.log( 'wrote "' + cookieValue + '" to cookie ' + getCookieName( options ) );
30 - }
 25+ var date = new Date();
 26+ date.setTime( date.getTime() + options.expiry * 1000 );
 27+ $.cookie( getCookieName( options ), cookieValue, { 'expires': date, 'path': '/' } );
 28+ survey.log( 'wrote "' + cookieValue + '" to cookie ' + getCookieName( options ) );
3129 }
3230
3331 function hasCookie( options ) {
@@ -39,6 +37,26 @@
4038 return rand < options.ratio;
4139 }
4240
 41+ function initCookieSurvey( options ) {
 42+ if ( hasCookie( options ) || options.ratio === 1 || winsLottery( options ) ) {
 43+ var cookie = getCookie( options );
 44+
 45+ if ( cookie !== 'done' ) {
 46+ if ( ( options.pages === 0 || parseInt( cookie ) >= options.pages ) ) {
 47+ $tag.mwSurvey( options );
 48+ setCookie( options, 'done' );
 49+ }
 50+ else if ( options.pages !== 0 ) {
 51+ var nr = parseInt( getCookie( options ) );
 52+ setCookie( options, ( isNaN( nr ) ? 0 : nr ) + 1 )
 53+ }
 54+ }
 55+ }
 56+ else {
 57+ setCookie( options, 'done' );
 58+ }
 59+ }
 60+
4361 function initTag( $tag ) {
4462 var ratioAttr = $tag.attr( 'survey-data-ratio' );
4563 var expiryAttr = $tag.attr( 'survey-data-expiry' );
@@ -61,27 +79,11 @@
6280 return;
6381 }
6482
65 - if ( hasCookie( options ) || options.ratio === 1 || winsLottery( options ) ) {
66 - if ( !options.cookie ) {
67 - $tag.mwSurvey( options );
68 - }
69 - else {
70 - var cookie = getCookie( options );
71 -
72 - if ( cookie !== 'done' ) {
73 - if ( ( options.pages === 0 || parseInt( cookie ) >= options.pages ) ) {
74 - $tag.mwSurvey( options );
75 - setCookie( options, 'done' );
76 - }
77 - else if ( options.pages !== 0 ) {
78 - var nr = parseInt( getCookie( options ) );
79 - setCookie( options, ( isNaN( nr ) ? 0 : nr ) + 1 )
80 - }
81 - }
82 - }
 83+ if ( options.cookie ) {
 84+ initCookieSurvey( options );
8385 }
8486 else {
85 - setCookie( options, 'done' );
 87+ $tag.mwSurvey( options );
8688 }
8789 }
8890
Index: trunk/extensions/Survey/resources/jquery.survey.js
@@ -123,7 +123,7 @@
124124 $q = $( '<div />' ).html( $input );
125125
126126 if ( question.type === type.CHECK ) {
127 - $q.append( $( '<label />' ).text( question.text ).attr( 'for', id ) );
 127+ $q.prepend( $( '<label />' ).text( question.text ).attr( 'for', id ) );
128128 }
129129 else {
130130 $q.prepend( $( '<p />' ).text( question.text ) );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96896Follow up to r96855; i18n docs++jeroendedauw20:20, 12 September 2011

Status & tagging log