r96436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96435‎ | r96436 | r96437 >
Date:14:10, 7 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on survey ui
Modified paths:
  • /trunk/extensions/Survey/Survey.i18n.php (modified) (history)
  • /trunk/extensions/Survey/Survey.php (modified) (history)
  • /trunk/extensions/Survey/resources/jquery.survey.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Survey/Survey.php
@@ -169,6 +169,7 @@
170170 'dependencies' => array( 'ext.survey', 'jquery.ui.button', 'ext.survey.numeric' ),
171171 'messages' => array(
172172 'survey-jquery-submit',
 173+ 'survey-jquery-finish',
173174 )
174175 );
175176
Index: trunk/extensions/Survey/Survey.i18n.php
@@ -78,4 +78,5 @@
7979
8080 // Survey jQuery
8181 'survey-jquery-submit' => 'Submit',
 82+ 'survey-jquery-finish' => 'Finish',
8283 );
Index: trunk/extensions/Survey/resources/jquery.survey.js
@@ -38,12 +38,6 @@
3939 );
4040 };
4141
42 - this.submitSurvey = function() {
43 - // TODO
44 -
45 - // $survey.append( $( '<p />' ).text( surveyData.thanks ) );
46 - };
47 -
4842 this.getQuestionInput = function( question ) {
4943 survey.log( 'getQuestionInput: ' + question.id );
5044
@@ -111,6 +105,27 @@
112106 return $questions;
113107 };
114108
 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+
115130 this.getSurveyBody = function( surveyData ) {
116131 $survey = $( '<div />' );
117132
@@ -120,8 +135,34 @@
121136
122137 $survey.append( this.getSurveyQuestions( surveyData.questions ) );
123138
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+ } );
125164
 165+ $survey.append( submissionButton );
 166+
126167 $survey.append( $( '<p />' ).text( surveyData.footer ) );
127168
128169 return $survey;

Status & tagging log