Skip to content

Commit d36cb7d

Browse files
committed
insertClass renamed to formatKey and moved to LanguageModel class
1 parent ae92d24 commit d36cb7d

File tree

7 files changed

+20
-44
lines changed

7 files changed

+20
-44
lines changed

examples/questionnaire/Example.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<a class="f-enter-desc"
5252
href="#"
5353
v-on:click.prevent="onSendData()"
54-
v-html="insertClass(language.pressEnter)">
54+
v-html="language.formatKey(language.pressEnter)">
5555
</a>
5656
</div>
5757

@@ -71,7 +71,6 @@
7171
import FlowForm from '../../src/components/FlowForm.vue'
7272
import QuestionModel, { QuestionType, ChoiceOption } from '../../src/models/QuestionModel'
7373
import LanguageModel from '../../src/models/LanguageModel'
74-
import { InsertClass } from '../../src/mixins/InsertClass'
7574
// If using the npm package, use the following line instead of the ones above.
7675
// import FlowForm, { QuestionModel, QuestionType, ChoiceOption, LanguageModel } from '@ditdot-dev/vue-flow-form'
7776
@@ -80,9 +79,6 @@
8079
components: {
8180
FlowForm
8281
},
83-
mixins: [
84-
InsertClass
85-
],
8682
data() {
8783
return {
8884
submitted: false,

examples/quiz/Example.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
class="f-enter-desc"
5050
href="#"
5151
v-on:click.prevent="onQuizSubmit()"
52-
v-html="insertClass(language.pressEnter)">
52+
v-html="language.formatKey(language.pressEnter)">
5353
</a>
5454
</div>
5555
<p class="text-success" v-if="submitted && score < 4">"You scored {{ score }} out of {{ total }}. There's a lot of room for improvement."</p>
@@ -70,7 +70,6 @@
7070
import FlowForm from '../../src/components/FlowForm.vue'
7171
import QuestionModel, { QuestionType, ChoiceOption} from '../../src/models/QuestionModel'
7272
import LanguageModel from '../../src/models/LanguageModel'
73-
import { InsertClass } from '../../src/mixins/InsertClass'
7473
// If using the npm package, use the following line instead of the ones above.
7574
// import FlowForm, { QuestionModel, QuestionType, ChoiceOption, LanguageModel } from '@ditdot-dev/vue-flow-form'
7675
@@ -79,9 +78,6 @@
7978
components: {
8079
FlowForm
8180
},
82-
mixins: [
83-
InsertClass
84-
],
8581
data() {
8682
return {
8783
submitted: false,

src/components/FlowForm.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
href="#"
4545
v-on:click.prevent="submit()"
4646
v-if="!submitted"
47-
v-html="insertClass(language.pressEnter)">
47+
v-html="language.formatKey(language.pressEnter)">
4848
</a>
4949
</slot>
5050
</div>
@@ -125,7 +125,6 @@
125125
126126
import FlowFormQuestion from './Question.vue'
127127
import LanguageModel from '../models/LanguageModel'
128-
import { InsertClass } from '../mixins/InsertClass'
129128
130129
export default {
131130
name: 'FlowForm',
@@ -139,9 +138,6 @@
139138
default: () => new LanguageModel()
140139
}
141140
},
142-
mixins: [
143-
InsertClass
144-
],
145141
data() {
146142
return {
147143
completed: false,

src/components/Question.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<span class="f-sub" v-if="question.subtitle || question.type === QuestionType.LongText || question.multiple">
3232
<span v-if="question.subtitle">{{ question.subtitle }}</span>
3333

34-
<span class="f-help" v-if="question.type === QuestionType.LongText && !isMobile" v-html="question.helpText || insertClass(language.longTextHelpText)"></span>
34+
<span class="f-help" v-if="question.type === QuestionType.LongText && !isMobile" v-html="question.helpText || language.formatKey(language.longTextHelpText)"></span>
3535

3636
<span class="f-help" v-if="question.multiple">{{ question.helpText || language.multipleChoiceHelpText }}</span>
3737
</span>
@@ -67,7 +67,7 @@
6767
href="#"
6868
v-if="question.type !== QuestionType.LongText || !isMobile"
6969
v-on:click.prevent="onEnter"
70-
v-html="insertClass(language.pressEnter)">
70+
v-html="language.formatKey(language.pressEnter)">
7171
</a>
7272
</div>
7373

@@ -96,7 +96,7 @@
9696
import FlowFormTextType from './QuestionTypes/TextType.vue'
9797
import FlowFormUrlType from './QuestionTypes/UrlType.vue'
9898
import { IsMobile } from '../mixins/IsMobile'
99-
import { InsertClass } from '../mixins/InsertClass'
99+
100100
101101
export default {
102102
name: 'FlowFormQuestion',
@@ -126,8 +126,7 @@
126126
}
127127
},
128128
mixins: [
129-
IsMobile,
130-
InsertClass
129+
IsMobile
131130
],
132131
data() {
133132
return {

src/components/QuestionTypes/BaseType.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import QuestionModel, { QuestionType } from '../../models/QuestionModel'
1111
import LanguageModel from '../../models/LanguageModel'
1212
import { IsMobile } from '../../mixins/IsMobile'
13-
import { InsertClass } from '../../mixins/InsertClass'
1413
1514
export default {
1615
name: 'FlowFormBaseType',
@@ -22,7 +21,6 @@
2221
},
2322
mixins: [
2423
IsMobile,
25-
InsertClass
2624
],
2725
data() {
2826
return {

src/mixins/InsertClass.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/models/LanguageModel.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,16 @@ export default class LanguageModel {
3131

3232
Object.assign(this, options || {})
3333
}
34-
}
34+
// Inserts a new CSS class into the language model string to format the :key
35+
formatKey(value) {
36+
if (!value) return ''
37+
let stringArr = value.toString().split(" ")
38+
for (let i = 0; i < stringArr.length; i++) {
39+
if (stringArr[i].slice(0,4) === ":key") {
40+
stringArr[i] = '<span class="f-language-key">' + stringArr[i].substring(5, stringArr[i].length - 1) + '</span>'
41+
}
42+
}
43+
return stringArr.join(" ")
44+
}
45+
}
46+

0 commit comments

Comments
 (0)