Skip to content

Commit 342ddb2

Browse files
committed
Added language model string modifier
1 parent 3689388 commit 342ddb2

File tree

6 files changed

+75
-13
lines changed

6 files changed

+75
-13
lines changed

examples/questionnaire/Example.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@
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="insertClass(language.pressEnter)">
55+
</a>
5556
</div>
5657

5758
<p class="text-success" v-if="submitted">Submitted succesfully.</p>
@@ -289,8 +290,22 @@
289290
})
290291
291292
return data
293+
},
294+
295+
/**
296+
* Inserts new class into the language model string
297+
*/
298+
insertClass(value) {
299+
if (!value) return ''
300+
let stringArr = value.toString().split(" ")
301+
for (let i=0; i < stringArr.length; i++){
302+
if (stringArr[i][0]=== ":" && stringArr[i].length > 1){
303+
stringArr[i] = '<span class="f-language-key">' + stringArr[i].substring(1) + '</span>'
304+
}
305+
}
306+
return stringArr.join(" ")
292307
}
293-
}
308+
},
294309
}
295310
</script>
296311

examples/quiz/Example.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
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="insertClass(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>
@@ -330,8 +331,22 @@
330331
331332
this.submitted = true
332333
this.calculateScore()
334+
},
335+
336+
/**
337+
* Inserts new class into the language model string
338+
*/
339+
insertClass(value) {
340+
if (!value) return ''
341+
let stringArr = value.toString().split(" ")
342+
for (let i=0; i < stringArr.length; i++){
343+
if (stringArr[i][0]=== ":" && stringArr[i].length > 1){
344+
stringArr[i] = '<span class="f-language-key">' + stringArr[i].substring(1) + '</span>'
345+
}
346+
}
347+
return stringArr.join(" ")
333348
}
334-
}
349+
},
335350
}
336351
</script>
337352

src/assets/css/common.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ svg.logo {
176176
margin-bottom: 20px;
177177
}
178178

179+
.f-language-key {
180+
text-transform: uppercase;
181+
}
182+
179183
/*v-form*/
180184
.v-form {
181185
margin-top: 26vh;

src/components/FlowForm.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
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="insertClass(language.pressEnter)">
48+
</a>
4849
</slot>
4950
</div>
5051
</div>
@@ -466,7 +467,20 @@
466467
*/
467468
blurFocus() {
468469
document.activeElement && document.activeElement.blur && document.activeElement.blur()
469-
}
470+
},
471+
/**
472+
* Inserts new class into the language model string
473+
*/
474+
insertClass(value) {
475+
if (!value) return ''
476+
let stringArr = value.toString().split(" ")
477+
for (let i=0; i < stringArr.length; i++){
478+
if (stringArr[i][0] === ":" && stringArr[i].length > 1){
479+
stringArr[i] = '<span class="f-language-key">' + stringArr[i].substring(1) + '</span>'
480+
}
481+
}
482+
return stringArr.join(" ")
483+
},
470484
}
471485
}
472486
</script>

src/components/Question.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@
6666
class="f-enter-desc"
6767
href="#"
6868
v-if="question.type !== QuestionType.LongText || !isMobile"
69-
v-on:click.prevent="onEnter">
70-
{{ language.pressEnter }}</a>
69+
v-on:click.prevent="onEnter"
70+
v-html="insertClass(language.pressEnter)">
71+
</a>
7172
</div>
7273

7374
<div v-if="showInvalid()" class="f-invalid" role="alert" aria-live="assertive">{{ language.invalidPrompt }}</div>
@@ -223,6 +224,19 @@
223224
}
224225
225226
return q.showInvalid()
227+
},
228+
/**
229+
* Inserts new class into the language model string
230+
*/
231+
insertClass(value) {
232+
if (!value) return ''
233+
let stringArr = value.toString().split(" ")
234+
for (let i=0; i < stringArr.length; i++){
235+
if (stringArr[i][0] === ":" && stringArr[i].length > 1){
236+
stringArr[i] = '<span class="f-language-key">' + stringArr[i].substring(1) + '</span>'
237+
}
238+
}
239+
return stringArr.join(" ")
226240
}
227241
},
228242
computed: {

src/models/LanguageModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class LanguageModel {
1010
constructor(options) {
1111
this.ok = 'OK'
1212
this.continue = 'Continue'
13-
this.pressEnter = 'Press ENTER'
13+
this.pressEnter = 'Press :enter'
1414
this.multipleChoiceHelpText = 'Choose as many as you like'
1515
this.otherPrompt = 'Other'
1616
this.placeholder = 'Type your answer here...'

0 commit comments

Comments
 (0)