define(['modules/inspects/editquestion'], function (Question) { var ctor = function (section, report) { this.section = section; this.report = report; }; var __proto = ctor.prototype; __proto.createContent = function (change) { var content = $('
'); if (this.section.StaticPictures && this.section.StaticPictures.length > 0) { var div_pic = $('
'); for (var i = 0; i < this.section.StaticPictures.length; i++) { var pic = this.section.StaticPictures[i]; var img = $('').attr('src', pic.Url).attr('title', pic.Name); img.click(pic.Url, function (e) { window.open(e.data, "_blank") }); div_pic.append(img); } content.append(div_pic); } var div_title = $('
').text(this.section.DisplayText); content.append(div_title); for (var i = 0; i < this.section.Questions.length; i++) { var question = this.section.Questions[i]; if (question.QuestionType === Question.types.YesOrNo || question.QuestionType === Question.types.DropDown || question.QuestionType === Question.types.List) { if (!question.SelectItems || question.SelectItems.length <= 0) { if (question.QuestionType !== Question.types.DropDown || question.LookupSource === 0) { continue; } } } var q = Question.factory(question); // get answer and media var answer = this.report.Answers.filter(function (a) { return Question.equals(a.QuestionId, question.Id) })[0]; var isPicture = question.QuestionType === Question.types.Picture || (question.QuestionType === Question.types.FuelRecords && question.SubType === Question.fueltypes.Picture) || question.QuestionType === Question.types.AssetStatus; var medias = isPicture && answer && this.report.Medias.filter(function (m) { return Question.equals(m.AnswerId, answer.Id) }); var qContent; if (question.QuestionType === Question.types.FuelRecords && (question.SubType === Question.fueltypes.Quantity || question.SubType === Question.fueltypes.UnitCost)) { qContent = q.createContent(answer, medias, change); } else { qContent = q.createContent(answer, medias); } qContent.data('question', q); content.append(qContent); } return content; }; return ctor; });