diff --git a/example/cards/tutorial/survey_card.html b/example/cards/tutorial/survey_card.html new file mode 100644 index 0000000..e7f0942 --- /dev/null +++ b/example/cards/tutorial/survey_card.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/example/cards/tutorial/survey_card.js b/example/cards/tutorial/survey_card.js index bd2a2f5..dedfee4 100644 --- a/example/cards/tutorial/survey_card.js +++ b/example/cards/tutorial/survey_card.js @@ -1,72 +1,9 @@ -/*global Handlebars*/ - -Conductor.require('/vendor/jquery.js'); -Conductor.require('/example/libs/handlebars-1.0.0-rc.3.js'); - -var gradingTemplate = '
{{#each grades}}{{this}}
{{/each}}
'; -var gradeResultTemplate = '
Your rating: {{grade}}
'; - Conductor.card({ - consumers: { survey: Conductor.Oasis.Consumer }, - - grade: null, - grades: ["A", "B", "C", "D", "F"], - renderMode: 'survey', - activate: function( data ) { - this.consumers.height.autoUpdate = false; - this.compileTemplates(); - }, - - compileTemplates: function() { - gradingTemplate = Handlebars.compile(gradingTemplate); - gradeResultTemplate = Handlebars.compile(gradeResultTemplate); + this.message = "
hello world
"; }, render: function () { - if (this.renderMode === 'survey') { - this.renderSurvey(); - } else { - this.renderReport(); - } - }, - - renderReport: function() { - var card = this; - this.renderMode = 'report'; - - $('body').html(gradeResultTemplate( this )); - - $('#changeGrade').click( function( event ) { - $(this).off('click'); - card.renderSurvey(); - }); - }, - - renderSurvey: function() { - var card = this; - this.renderMode = 'survey'; - - $('body').html(gradingTemplate(this)); - - if (this.grade) { - $('input:radio[name=survey][value="' + this.grade + '"]').attr('checked', 'checked'); - } - - $('#grade').click( function( event ) { - var grade = $('input:radio[name=survey]:checked').val(); - if (grade) { - $(this).off('click'); - if (card.consumers.survey) { - if (!card.grade) { - card.consumers.survey.send('surveyTaken', grade); - } else { - card.consumers.survey.send('gradeChanged', grade); - } - } - card.grade = grade; - card.renderReport(); - } - }); + document.body.innerHTML = this.message; } }); diff --git a/example/playground/js/playground.js b/example/playground/js/playground.js index b992cb3..598baa7 100644 --- a/example/playground/js/playground.js +++ b/example/playground/js/playground.js @@ -37,7 +37,7 @@ window.Playground = { this.cardTemplate = $('.card-wrapper').hide(); - this.addCard('../cards/superbowl/card.js', 1, []); + this.addCard('../cards/tutorial/survey_card.js', 1, []); } };