Index: trunk/extensions/Survey/resources/jquery.survey.js |
— | — | @@ -36,13 +36,43 @@ |
37 | 37 | }; |
38 | 38 | |
39 | 39 | this.submitSurvey = function() { |
| 40 | + // TODO |
| 41 | + }; |
| 42 | + |
| 43 | + this.getSurveyQuestion = function( question ) { |
| 44 | + return ''; // TODO |
| 45 | + }; |
| 46 | + |
| 47 | + this.getSurveyQuestions = function( questions ) { |
| 48 | + $questions = $( '<div />' ); |
40 | 49 | |
| 50 | + for ( i in questions ) { |
| 51 | + $questions.append( this.getSurveyQuestion( questions[i] ) ); |
| 52 | + } |
| 53 | + |
| 54 | + return $questions; |
41 | 55 | }; |
42 | 56 | |
| 57 | + this.getSurveyBody = function( surveyData ) { |
| 58 | + $survey = $( '<div />' ); |
| 59 | + |
| 60 | + $survey.append( this.getSurveyQuestions( surveyData.questions ) ); |
| 61 | + |
| 62 | + $survey.append( JSON.stringify( surveyData ) ); |
| 63 | + |
| 64 | + return $survey; |
| 65 | + }; |
| 66 | + |
43 | 67 | this.initSurvey = function( surveyElement, surveyData ) { |
44 | | - // TODO |
45 | | - $div = $( '<div />' ).attr( { 'style': 'display:none' } ).html( $( '<div />' ).attr( { 'id': 'data' } ).html( JSON.stringify( surveyData ) ) ); |
46 | | - $link = $( '<a />' ).attr( { 'href': '#data', 'id': 'inline' } ).html( $div ).append( $('<p />') ); |
| 68 | + $div = $( '<div />' ).attr( { |
| 69 | + 'style': 'display:none' |
| 70 | + } ).html( $( '<div />' ).attr( { 'id': 'survey-' + surveyData.id } ).html( this.getSurveyBody( surveyData ) ) ); |
| 71 | + |
| 72 | + $link = $( '<a />' ).attr( { |
| 73 | + 'href': '#survey-' + surveyData.id, |
| 74 | + 'id': 'inline' |
| 75 | + } ).html( $div ); |
| 76 | + |
47 | 77 | surveyElement.html( $link ); |
48 | 78 | $link.fancybox(); |
49 | 79 | $link.click(); |