Index: trunk/extensions/Survey/Survey.php |
— | — | @@ -169,6 +169,7 @@ |
170 | 170 | 'dependencies' => array( 'ext.survey', 'jquery.ui.button', 'ext.survey.numeric' ), |
171 | 171 | 'messages' => array( |
172 | 172 | 'survey-jquery-submit', |
| 173 | + 'survey-jquery-finish', |
173 | 174 | ) |
174 | 175 | ); |
175 | 176 | |
Index: trunk/extensions/Survey/Survey.i18n.php |
— | — | @@ -78,4 +78,5 @@ |
79 | 79 | |
80 | 80 | // Survey jQuery |
81 | 81 | 'survey-jquery-submit' => 'Submit', |
| 82 | + 'survey-jquery-finish' => 'Finish', |
82 | 83 | ); |
Index: trunk/extensions/Survey/resources/jquery.survey.js |
— | — | @@ -38,12 +38,6 @@ |
39 | 39 | ); |
40 | 40 | }; |
41 | 41 | |
42 | | - this.submitSurvey = function() { |
43 | | - // TODO |
44 | | - |
45 | | - // $survey.append( $( '<p />' ).text( surveyData.thanks ) ); |
46 | | - }; |
47 | | - |
48 | 42 | this.getQuestionInput = function( question ) { |
49 | 43 | survey.log( 'getQuestionInput: ' + question.id ); |
50 | 44 | |
— | — | @@ -111,6 +105,27 @@ |
112 | 106 | return $questions; |
113 | 107 | }; |
114 | 108 | |
| 109 | + this.submitSurvey = function( surveyId, callback ) { |
| 110 | + // TODO |
| 111 | + |
| 112 | + callback(); |
| 113 | + }; |
| 114 | + |
| 115 | + this.doCompletion = function() { |
| 116 | + $.fancybox.close(); |
| 117 | + }; |
| 118 | + |
| 119 | + this.showCompletion = function( surveyData ) { |
| 120 | + $div = $( '#survey-' + surveyData.id ); |
| 121 | + |
| 122 | + $div.html( $( '<p />' ).text( surveyData.thanks ) ); |
| 123 | + |
| 124 | + $div.append( $( '<button />' ) |
| 125 | + .button( { label: mw.msg( 'survey-jquery-finish' ) } ) |
| 126 | + .click( this.doCompletion ) |
| 127 | + ); |
| 128 | + }; |
| 129 | + |
115 | 130 | this.getSurveyBody = function( surveyData ) { |
116 | 131 | $survey = $( '<div />' ); |
117 | 132 | |
— | — | @@ -120,8 +135,34 @@ |
121 | 136 | |
122 | 137 | $survey.append( this.getSurveyQuestions( surveyData.questions ) ); |
123 | 138 | |
124 | | - $survey.append( $( '<button />' ).button( { label: mw.msg( 'survey-jquery-submit' ) } ) ); |
| 139 | + var submissionButton = $( '<button />' ) |
| 140 | + .button( { label: mw.msg( 'survey-jquery-submit' ) } ) |
| 141 | + .click( function() { |
| 142 | + var $this = $( this ); |
| 143 | + $this.button( 'disable' ); |
| 144 | + |
| 145 | + if ( true /* isValid */ ) { |
| 146 | + _this.submitSurvey( |
| 147 | + surveyData.id, |
| 148 | + function() { |
| 149 | + if ( surveyData.thanks == '' ) { |
| 150 | + _this.doCompletion(); |
| 151 | + } |
| 152 | + else { |
| 153 | + _this.showCompletion( surveyData ); |
| 154 | + } |
| 155 | + } |
| 156 | + ); |
| 157 | + } |
| 158 | + else { |
| 159 | + // TODO |
| 160 | + |
| 161 | + $this.button( 'enable' ); |
| 162 | + } |
| 163 | + } ); |
125 | 164 | |
| 165 | + $survey.append( submissionButton ); |
| 166 | + |
126 | 167 | $survey.append( $( '<p />' ).text( surveyData.footer ) ); |
127 | 168 | |
128 | 169 | return $survey; |