Index: trunk/extensions/Survey/specials/SpecialSurvey.php |
— | — | @@ -169,6 +169,15 @@ |
170 | 170 | ); |
171 | 171 | } |
172 | 172 | |
| 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 | + */ |
173 | 182 | protected function getNumericalOptions( array $numbers ) { |
174 | 183 | $lang = $this->getLang(); |
175 | 184 | |
Index: trunk/extensions/Survey/resources/ext.survey.tag.js |
— | — | @@ -21,12 +21,10 @@ |
22 | 22 | } |
23 | 23 | |
24 | 24 | 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 ) ); |
31 | 29 | } |
32 | 30 | |
33 | 31 | function hasCookie( options ) { |
— | — | @@ -39,6 +37,26 @@ |
40 | 38 | return rand < options.ratio; |
41 | 39 | } |
42 | 40 | |
| 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 | + |
43 | 61 | function initTag( $tag ) { |
44 | 62 | var ratioAttr = $tag.attr( 'survey-data-ratio' ); |
45 | 63 | var expiryAttr = $tag.attr( 'survey-data-expiry' ); |
— | — | @@ -61,27 +79,11 @@ |
62 | 80 | return; |
63 | 81 | } |
64 | 82 | |
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 ); |
83 | 85 | } |
84 | 86 | else { |
85 | | - setCookie( options, 'done' ); |
| 87 | + $tag.mwSurvey( options ); |
86 | 88 | } |
87 | 89 | } |
88 | 90 | |
Index: trunk/extensions/Survey/resources/jquery.survey.js |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | $q = $( '<div />' ).html( $input ); |
125 | 125 | |
126 | 126 | 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 ) ); |
128 | 128 | } |
129 | 129 | else { |
130 | 130 | $q.prepend( $( '<p />' ).text( question.text ) ); |