File tree Expand file tree Collapse file tree 7 files changed +45
-18
lines changed Expand file tree Collapse file tree 7 files changed +45
-18
lines changed Original file line number Diff line number Diff line change 4646 v-on:click.prevent =" onSendData()"
4747 aria-label =" Press to submit"
4848 >
49- <span >{{ language.submitText }}</span >
49+ <span >{{ language.submitText }}</span >
5050 </button >
5151 <a class =" f-enter-desc"
5252 href =" #"
53- v-on:click.prevent =" onSendData()" >
54- {{ language.pressEnter }}</a >
53+ v-on:click.prevent =" onSendData()"
54+ v-html =" language.formatString(language.pressEnter)" >
55+ </a >
5556 </div >
5657
5758 <p class =" text-success" v-if =" submitted" >Submitted succesfully.</p >
291292
292293 return data
293294 }
294- }
295+ },
295296 }
296297 </script >
297298
Original file line number Diff line number Diff line change 4848 <a
4949 class =" f-enter-desc"
5050 href =" #"
51- v-on:click.prevent =" onQuizSubmit()" >
52- {{ language.pressEnter }}</a >
51+ v-on:click.prevent =" onQuizSubmit()"
52+ v-html =" language.formatString(language.pressEnter)" >
53+ </a >
5354 </div >
5455 <p class =" text-success" v-if =" submitted && score < 4" >"You scored {{ score }} out of {{ total }}. There's a lot of room for improvement."</p >
5556 <p class =" text-success" v-else-if =" submitted && score < 7" >"You scored {{ score }} out of {{ total }}. Not bad at all!"</p >
331332 this .submitted = true
332333 this .calculateScore ()
333334 }
334- }
335+ },
335336 }
336337 </script >
337338
Original file line number Diff line number Diff line change @@ -176,6 +176,10 @@ svg.logo {
176176 margin-bottom : 20px ;
177177}
178178
179+ .f-uppercase {
180+ text-transform : uppercase;
181+ }
182+
179183/*v-form*/
180184.v-form {
181185 margin-top : 26vh ;
@@ -399,7 +403,7 @@ span.f-sub {
399403 margin-top : 6px ;
400404}
401405
402- span .f-sub span {
406+ span .f-sub span : not (. f-uppercase ) {
403407 margin-right : .4rem ;
404408}
405409
Original file line number Diff line number Diff line change 4343 class =" f-enter-desc"
4444 href =" #"
4545 v-on:click.prevent =" submit()"
46- v-if =" !submitted" >
47- {{ language.pressEnter }}</a >
46+ v-if =" !submitted"
47+ v-html =" language.formatString(language.pressEnter)" >
48+ </a >
4849 </slot >
4950 </div >
5051 </div >
466467 */
467468 blurFocus () {
468469 document .activeElement && document .activeElement .blur && document .activeElement .blur ()
469- }
470+ },
470471 }
471472 }
472473 </script >
Original file line number Diff line number Diff line change 3131 <span class =" f-sub" v-if =" question.subtitle || question.type === QuestionType.LongText || question.type === QuestionType.MultipleChoice" >
3232 <span v-if =" question.subtitle" >{{ question.subtitle }}</span >
3333
34- <span class =" f-help" v-if =" question.type === QuestionType.LongText && !isMobile" >{{ question.helpText || language.longTextHelpText }} </span >
34+ <span class =" f-help" v-if =" question.type === QuestionType.LongText && !isMobile" v-html = " question.helpText || language.formatString(language. longTextHelpText) " > </span >
3535
3636 <span class =" f-help" v-if =" question.type === QuestionType.MultipleChoice && question.multiple" >{{ question.helpText || language.multipleChoiceHelpText }}</span >
3737 <span class =" f-help" v-else-if =" question.type === QuestionType.MultipleChoice" >{{ question.helpText || language.multipleChoiceHelpTextSingle }}</span >
6767 class =" f-enter-desc"
6868 href =" #"
6969 v-if =" question.type !== QuestionType.LongText || !isMobile"
70- v-on:click.prevent =" onEnter" >
71- {{ language.pressEnter }}</a >
70+ v-on:click.prevent =" onEnter"
71+ v-html =" language.formatString(language.pressEnter)" >
72+ </a >
7273 </div >
7374
7475 <div v-if =" showInvalid()" class =" f-invalid" role =" alert" aria-live =" assertive" >{{ language.invalidPrompt }}</div >
9697 import FlowFormTextType from ' ./QuestionTypes/TextType.vue'
9798 import FlowFormUrlType from ' ./QuestionTypes/UrlType.vue'
9899 import { IsMobile } from ' ../mixins/IsMobile'
100+
99101
100102 export default {
101103 name: ' FlowFormQuestion' ,
Original file line number Diff line number Diff line change 2020 value: [String , Array ]
2121 },
2222 mixins: [
23- IsMobile
23+ IsMobile,
2424 ],
2525 data () {
2626 return {
Original file line number Diff line number Diff line change 88
99export default class LanguageModel {
1010 constructor ( options ) {
11+ this . enterKey = 'Enter'
12+ this . shiftKey = 'Shift'
1113 this . ok = 'OK'
1214 this . continue = 'Continue'
13- this . pressEnter = 'Press ENTER '
15+ this . pressEnter = 'Press :enterKey '
1416 this . multipleChoiceHelpText = 'Choose as many as you like'
1517 this . multipleChoiceHelpTextSingle = 'Choose only one answer'
1618 this . otherPrompt = 'Other'
1719 this . placeholder = 'Type your answer here...'
1820 this . submitText = 'Submit'
19- this . longTextHelpText = 'SHIFT + ENTER to make a line break.'
21+ this . longTextHelpText = ':shiftKey + :enterKey to make a line break.'
2022 this . prev = 'Prev'
2123 this . next = 'Next'
2224 this . percentCompleted = ':percent% completed'
@@ -32,4 +34,20 @@ export default class LanguageModel {
3234
3335 Object . assign ( this , options || { } )
3436 }
35- }
37+
38+ /**
39+ * Inserts a new CSS class into the language model string to format the :string
40+ * Use it in a component's v-html directive: v-html="language.formatString(language.languageString)"
41+ */
42+ formatString ( string ) {
43+ return string . replace ( / : ( \w + ) / g, ( match , word ) => {
44+ if ( this [ word ] ) {
45+ return '<span class="f-uppercase">' + this [ word ] + '</span>'
46+ }
47+
48+ return match
49+ } )
50+ }
51+ }
52+
53+
You can’t perform that action at this time.
0 commit comments