hr-design-system-handlebars 1.114.5 → 1.114.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/assets/index.css +3 -3
- package/dist/assets/js/components/voting/js/votingDs.feature.js +6 -6
- package/dist/views/components/voting/voting.hbs +18 -16
- package/dist/views/components/voting/voting_result.hbs +17 -18
- package/dist/views/components/voting/voting_result_2F.hbs +1 -1
- package/dist/views_static/components/voting/voting.hbs +18 -16
- package/dist/views_static/components/voting/voting_result.hbs +17 -18
- package/dist/views_static/components/voting/voting_result_2F.hbs +1 -1
- package/package.json +1 -1
- package/src/assets/fixtures/voting/voting_email.json +4 -44
- package/src/stories/views/components/voting/fixtures/voting_email.json +1 -1
- package/src/stories/views/components/voting/js/votingDs.feature.js +6 -6
- package/src/stories/views/components/voting/voting.hbs +18 -16
- package/src/stories/views/components/voting/voting.stories.js +2 -2
- package/src/stories/views/components/voting/voting_result.hbs +17 -18
- package/src/stories/views/components/voting/{voting_success.stories.js → voting_result.stories.js} +8 -2
- package/src/stories/views/components/voting/voting_result_2F.hbs +1 -1
- package/dist/views/components/voting/voting_error.hbs +0 -10
- package/dist/views/components/voting/voting_success.hbs +0 -27
- package/dist/views/components/voting/voting_success_2F.hbs +0 -7
- package/dist/views_static/components/voting/voting_error.hbs +0 -10
- package/dist/views_static/components/voting/voting_success.hbs +0 -27
- package/dist/views_static/components/voting/voting_success_2F.hbs +0 -7
- package/src/stories/views/components/voting/js/voteValidatorDs.js +0 -195
- package/src/stories/views/components/voting/js/votingCookieCheckerDs.js +0 -31
- package/src/stories/views/components/voting/js/votingDs.js +0 -198
- package/src/stories/views/components/voting/voting_error.hbs +0 -10
- package/src/stories/views/components/voting/voting_error.stories.js +0 -35
- package/src/stories/views/components/voting/voting_success.hbs +0 -27
- package/src/stories/views/components/voting/voting_success_2F.hbs +0 -7
- package/src/stories/views/components/voting/voting_success_2F.stories.js +0 -35
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
<div class="{{#if this.isSimpleSecured}}js-load{{/if}}{{#if _addClass}} {{_addClass}}{{/if}}"
|
|
2
|
-
{{#unless
|
|
2
|
+
{{#unless this.form.isVotingOver}}
|
|
3
3
|
{{#if this.isSimpleSecured}}
|
|
4
4
|
data-hr-voting-result-cookie-ds='{"cookieLifetime":"{{this.cookieLifetime}}","votingId":"{{this.sophoraId}}"}'
|
|
5
5
|
{{/if}}
|
|
6
6
|
{{/unless}}
|
|
7
7
|
>
|
|
8
8
|
|
|
9
|
-
{{#unless
|
|
10
|
-
{{> components/voting/components/voting_header _title=
|
|
9
|
+
{{#unless this.hasRedirect}}
|
|
10
|
+
{{> components/voting/components/voting_header _title=this.title _topline=this.topline}}
|
|
11
11
|
{{/unless}}
|
|
12
12
|
|
|
13
13
|
{{#if _hideVotingResult}}
|
|
14
|
-
{{#if
|
|
15
|
-
<p class="mt-6
|
|
14
|
+
{{#if this.form.isVotingOver}}
|
|
15
|
+
<p class="mt-6 text-base font-bold sm:text-xl font-heading sm:mt-12">{{loca "votingform_voting_finished"}}</p>
|
|
16
16
|
{{else}}
|
|
17
17
|
{{~> components/base/image/icon _icon=(if _statusDone "status-done" "status-error") _iconmap="icons" _addClass=(if _statusDone "float-left w-6 h-6 text-success dark:text-success-dark fill-current mt-6 sm:mt-12" "float-left w-6 h-6 text-error dark:text-error-dark fill-current mt-6 sm:mt-12")}}
|
|
18
18
|
<p class="{{#if _statusDone}}text-success dark:text-success-dark{{else}}text-error dark:text-error-dark{{/if}} mt-6 ml-8 text-base font-bold sm:ml-9 sm:text-xl font-heading sm:mt-12">{{{_resultBoxMessageText}}}</p>
|
|
19
19
|
{{/if}}
|
|
20
20
|
{{else}}
|
|
21
|
-
<p class="mt-6 text-base font-bold sm:text-xl font-heading sm:mt-12">{{{_resultBoxMessageText}}}</p>
|
|
22
21
|
|
|
23
|
-
{{#
|
|
22
|
+
<p class="mt-6 text-base font-bold sm:text-xl font-heading sm:mt-12 dark:text-text-dark">{{#if this.form.isVotingOver}}{{loca "votingform_voting_finished"}}{{else}}{{{_resultBoxMessageText}}}{{/if}}</p>
|
|
23
|
+
|
|
24
|
+
{{#each this.votingResult}}
|
|
24
25
|
<div class="flex">
|
|
25
26
|
<div class="grow">
|
|
26
27
|
<div class="{{#if @first}}mt-7 sm:mt-9{{else}}mt-3 sm:mt-4{{/if}} text-base sm:text-lg font-copy dark:text-text-dark">{{this.label}}</div>
|
|
@@ -53,18 +54,16 @@
|
|
|
53
54
|
{{/if}}
|
|
54
55
|
{{/if}}
|
|
55
56
|
|
|
56
|
-
{{#
|
|
57
|
-
<p class="mt-6 text-base font-bold sm:text-xl font-heading sm:mt-12 dark:text-text-dark">{{loca "votingform_voting_finished"}}</p>
|
|
58
|
-
{{/if}}
|
|
59
|
-
|
|
60
|
-
{{#unless _isResultOnRedirectPage}}
|
|
57
|
+
{{#unless this.hasRedirect}}
|
|
61
58
|
{{#unless this.isSimpleSecured}}
|
|
62
|
-
{{#unless
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{{
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
{{#unless this.form.isVotingOver}}
|
|
60
|
+
{{#if _showBackButton}}
|
|
61
|
+
<div class="mt-6 sm:mt-12">
|
|
62
|
+
{{#> components/button/link_button _size="lg" _css="float-right"}}
|
|
63
|
+
{{> components/button/components/button_label _label=(loca "votingform_form_back")}}
|
|
64
|
+
{{/components/button/link_button}}
|
|
65
|
+
</div>
|
|
66
|
+
{{/if}}
|
|
68
67
|
{{/unless}}
|
|
69
68
|
{{/unless}}
|
|
70
69
|
{{/unless}}
|
package/src/stories/views/components/voting/{voting_success.stories.js → voting_result.stories.js}
RENAMED
|
@@ -23,13 +23,19 @@ export default {
|
|
|
23
23
|
const Template = (args) => {
|
|
24
24
|
let hbsTemplate = handlebars.compile(`
|
|
25
25
|
{{#>components/forms/components/backgroundBox }}
|
|
26
|
-
{{> components/voting/
|
|
26
|
+
{{> components/voting/voting_result this
|
|
27
|
+
_isInline=true
|
|
28
|
+
_statusDone=true
|
|
29
|
+
_hideVotingResult=this.form.hideVotingResult
|
|
30
|
+
_resultBoxMessageTitle="Danke für ihre Teilnahme!"
|
|
31
|
+
_resultBoxMessageText=this.votingSuccessText.richtext
|
|
32
|
+
}}
|
|
27
33
|
{{/components/forms/components/backgroundBox }}
|
|
28
34
|
`)
|
|
29
35
|
return hbsTemplate({ ...args })
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
export const
|
|
38
|
+
export const Voting_Result = {
|
|
33
39
|
render: Template.bind({}),
|
|
34
40
|
name: 'Ergebnis Barchart prozentual',
|
|
35
41
|
args: votingJson,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{{> components/voting/components/voting_header _title=
|
|
1
|
+
{{> components/voting/components/voting_header _title=this.title _topline=this.topline}}
|
|
2
2
|
|
|
3
3
|
{{~> components/base/image/icon _icon="status-done" _iconmap="icons" _addClass="float-left w-6 h-6 text-success fill-current mt-6 sm:mt-12"}}
|
|
4
4
|
<p class="mt-6 ml-8 text-base font-bold sm:ml-9 text-success sm:text-lg font-heading sm:mt-12">{{{_resultBoxMessageTitle}}}<br/>{{{_resultBoxMessageText}}}</p>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{{> components/voting/voting_result
|
|
2
|
-
_title=_title
|
|
3
|
-
_topline=_topline
|
|
4
|
-
_resultBoxMessageTitle=(loca "votingform_title_error")
|
|
5
|
-
_resultBoxMessageText=(loca "votingform_text_error")
|
|
6
|
-
_locaKeyText="votingform_text_error"
|
|
7
|
-
_isInline=_isInline
|
|
8
|
-
_hideVotingResult=true
|
|
9
|
-
_statusDone=false
|
|
10
|
-
}}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{{#if this.votingSuccessText}}
|
|
2
|
-
{{> components/voting/voting_result
|
|
3
|
-
_title=_title
|
|
4
|
-
_topline=_topline
|
|
5
|
-
_resultBoxMessageTitle=(loca "votingform_title_success")
|
|
6
|
-
_resultBoxMessageText=this.votingSuccessText.richtext
|
|
7
|
-
_isInline=_isInline
|
|
8
|
-
_voteResults=_voteResults
|
|
9
|
-
_isResultOnRedirectPage=_isResultOnRedirectPage
|
|
10
|
-
_hideVotingResult=this.hideVotingResult
|
|
11
|
-
_statusDone=_statusDone
|
|
12
|
-
|
|
13
|
-
}}
|
|
14
|
-
{{else}}
|
|
15
|
-
{{> components/voting/voting_result
|
|
16
|
-
_title=_title
|
|
17
|
-
_topline=_topline
|
|
18
|
-
_resultBoxMessageTitle=(loca "votingform_title_success")
|
|
19
|
-
_resultBoxMessageText=(loca "votingform_text_success")
|
|
20
|
-
_isInline=_isInline
|
|
21
|
-
_voteResults=_voteResults
|
|
22
|
-
_isResultOnRedirectPage=_isResultOnRedirectPage
|
|
23
|
-
_hideVotingResult=this.hideVotingResult
|
|
24
|
-
_statusDone=_statusDone
|
|
25
|
-
}}
|
|
26
|
-
{{/if}}
|
|
27
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{{> components/voting/voting_result
|
|
2
|
-
_title=_title
|
|
3
|
-
_topline=_topline
|
|
4
|
-
_resultBoxMessageTitle=(loca "votingform_title_error")
|
|
5
|
-
_resultBoxMessageText=(loca "votingform_text_error")
|
|
6
|
-
_locaKeyText="votingform_text_error"
|
|
7
|
-
_isInline=_isInline
|
|
8
|
-
_hideVotingResult=true
|
|
9
|
-
_statusDone=false
|
|
10
|
-
}}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{{#if this.votingSuccessText}}
|
|
2
|
-
{{> components/voting/voting_result
|
|
3
|
-
_title=_title
|
|
4
|
-
_topline=_topline
|
|
5
|
-
_resultBoxMessageTitle=(loca "votingform_title_success")
|
|
6
|
-
_resultBoxMessageText=this.votingSuccessText.richtext
|
|
7
|
-
_isInline=_isInline
|
|
8
|
-
_voteResults=_voteResults
|
|
9
|
-
_isResultOnRedirectPage=_isResultOnRedirectPage
|
|
10
|
-
_hideVotingResult=this.hideVotingResult
|
|
11
|
-
_statusDone=_statusDone
|
|
12
|
-
|
|
13
|
-
}}
|
|
14
|
-
{{else}}
|
|
15
|
-
{{> components/voting/voting_result
|
|
16
|
-
_title=_title
|
|
17
|
-
_topline=_topline
|
|
18
|
-
_resultBoxMessageTitle=(loca "votingform_title_success")
|
|
19
|
-
_resultBoxMessageText=(loca "votingform_text_success")
|
|
20
|
-
_isInline=_isInline
|
|
21
|
-
_voteResults=_voteResults
|
|
22
|
-
_isResultOnRedirectPage=_isResultOnRedirectPage
|
|
23
|
-
_hideVotingResult=this.hideVotingResult
|
|
24
|
-
_statusDone=_statusDone
|
|
25
|
-
}}
|
|
26
|
-
{{/if}}
|
|
27
|
-
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
var VoteValidator =
|
|
2
|
-
VoteValidator ||
|
|
3
|
-
function (options) {
|
|
4
|
-
'use strict'
|
|
5
|
-
|
|
6
|
-
// Production steps of ECMA-262, Edition 6, 22.1.2.1
|
|
7
|
-
if (!Array.from) {
|
|
8
|
-
Array.from = (function () {
|
|
9
|
-
var toStr = Object.prototype.toString
|
|
10
|
-
var isCallable = function (fn) {
|
|
11
|
-
return typeof fn === 'function' || toStr.call(fn) === '[object Function]'
|
|
12
|
-
}
|
|
13
|
-
var toInteger = function (value) {
|
|
14
|
-
var number = Number(value)
|
|
15
|
-
if (isNaN(number)) {
|
|
16
|
-
return 0
|
|
17
|
-
}
|
|
18
|
-
if (number === 0 || !isFinite(number)) {
|
|
19
|
-
return number
|
|
20
|
-
}
|
|
21
|
-
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number))
|
|
22
|
-
}
|
|
23
|
-
var maxSafeInteger = Math.pow(2, 53) - 1
|
|
24
|
-
var toLength = function (value) {
|
|
25
|
-
var len = toInteger(value)
|
|
26
|
-
return Math.min(Math.max(len, 0), maxSafeInteger)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// The length property of the from method is 1.
|
|
30
|
-
return function from(arrayLike /*, mapFn, thisArg */) {
|
|
31
|
-
// 1. Let C be the this value.
|
|
32
|
-
var C = this
|
|
33
|
-
|
|
34
|
-
// 2. Let items be ToObject(arrayLike).
|
|
35
|
-
var items = Object(arrayLike)
|
|
36
|
-
|
|
37
|
-
// 3. ReturnIfAbrupt(items).
|
|
38
|
-
if (arrayLike == null) {
|
|
39
|
-
throw new TypeError(
|
|
40
|
-
'Array.from requires an array-like object - not null or undefined'
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 4. If mapfn is undefined, then let mapping be false.
|
|
45
|
-
var mapFn = arguments.length > 1 ? arguments[1] : void undefined
|
|
46
|
-
var T
|
|
47
|
-
if (typeof mapFn !== 'undefined') {
|
|
48
|
-
// 5. else
|
|
49
|
-
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
|
|
50
|
-
if (!isCallable(mapFn)) {
|
|
51
|
-
throw new TypeError(
|
|
52
|
-
'Array.from: when provided, the second argument must be a function'
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
|
57
|
-
if (arguments.length > 2) {
|
|
58
|
-
T = arguments[2]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 10. Let lenValue be Get(items, "length").
|
|
63
|
-
// 11. Let len be ToLength(lenValue).
|
|
64
|
-
var len = toLength(items.length)
|
|
65
|
-
|
|
66
|
-
// 13. If IsConstructor(C) is true, then
|
|
67
|
-
// 13. a. Let A be the result of calling the [[Construct]] internal method
|
|
68
|
-
// of C with an argument list containing the single item len.
|
|
69
|
-
// 14. a. Else, Let A be ArrayCreate(len).
|
|
70
|
-
var A = isCallable(C) ? Object(new C(len)) : new Array(len)
|
|
71
|
-
|
|
72
|
-
// 16. Let k be 0.
|
|
73
|
-
var k = 0
|
|
74
|
-
// 17. Repeat, while k < len… (also steps a - h)
|
|
75
|
-
var kValue
|
|
76
|
-
while (k < len) {
|
|
77
|
-
kValue = items[k]
|
|
78
|
-
if (mapFn) {
|
|
79
|
-
A[k] =
|
|
80
|
-
typeof T === 'undefined'
|
|
81
|
-
? mapFn(kValue, k)
|
|
82
|
-
: mapFn.call(T, kValue, k)
|
|
83
|
-
} else {
|
|
84
|
-
A[k] = kValue
|
|
85
|
-
}
|
|
86
|
-
k += 1
|
|
87
|
-
}
|
|
88
|
-
// 18. Let putStatus be Put(A, "length", len, true).
|
|
89
|
-
A.length = len
|
|
90
|
-
// 20. Return A.
|
|
91
|
-
return A
|
|
92
|
-
}
|
|
93
|
-
})()
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
var element = hr$(options.selector)[0],
|
|
97
|
-
settings = options.data ? JSON.parse(options.data) : {},
|
|
98
|
-
minAnswerCount = settings.minAnswerCount,
|
|
99
|
-
maxAnswerCount = settings.maxAnswerCount,
|
|
100
|
-
isMultipleChoice = settings.isMultipleChoice || false,
|
|
101
|
-
selectedCheckboxes = 0,
|
|
102
|
-
votingOptions = Array.from(hr$('input[name=multivoting]', element)),
|
|
103
|
-
counter = hr$('.js-voting-counter', element),
|
|
104
|
-
submit = hr$('input[type=submit]', element)[0],
|
|
105
|
-
submitLabel = hr$('.js-voting-submit-button', element)[0],
|
|
106
|
-
countSelectedCheckboxes = function (event) {
|
|
107
|
-
console.log(submitLabel)
|
|
108
|
-
if (countCheckedCheckboxes() != 0) {
|
|
109
|
-
submit.disabled = false
|
|
110
|
-
submitLabel.classList.remove('-inactive')
|
|
111
|
-
} else {
|
|
112
|
-
submit.disabled = true
|
|
113
|
-
submitLabel.classList.add('-inactive')
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (selectedCheckboxes < maxAnswerCount) {
|
|
117
|
-
countSelectedCheckBoxesIfMaxHasNotReached(event)
|
|
118
|
-
|
|
119
|
-
if (selectedCheckboxes == maxAnswerCount) {
|
|
120
|
-
disableCheckboxesIfMaxHasReached()
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
enableCheckboxesIfMaxHasUndershot()
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
isUnchecked = function (checkbox) {
|
|
127
|
-
return checkbox.checked == false
|
|
128
|
-
},
|
|
129
|
-
isDisabled = function (checkbox) {
|
|
130
|
-
return checkbox.disabled == true
|
|
131
|
-
},
|
|
132
|
-
isChecked = function (checkbox) {
|
|
133
|
-
return checkbox.checked == true
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function countCheckedCheckboxes() {
|
|
137
|
-
var checkedOptions = votingOptions.filter(isChecked)
|
|
138
|
-
return checkedOptions.length
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function countSelectedCheckBoxesIfMaxHasNotReached(event) {
|
|
142
|
-
if (event.target.checked == false) {
|
|
143
|
-
selectedCheckboxes = selectedCheckboxes - 1
|
|
144
|
-
counter.innerHTML = selectedCheckboxes + '/' + maxAnswerCount
|
|
145
|
-
} else {
|
|
146
|
-
selectedCheckboxes = selectedCheckboxes + 1
|
|
147
|
-
counter.innerHTML = selectedCheckboxes + '/' + maxAnswerCount
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function disableCheckboxesIfMaxHasReached() {
|
|
152
|
-
var uncheckedOptions = votingOptions.filter(isUnchecked)
|
|
153
|
-
uncheckedOptions.map(function (uncheckedOptions) {
|
|
154
|
-
uncheckedOptions.disabled = true
|
|
155
|
-
var label = hr$('label[for=' + uncheckedOptions.id + ']')
|
|
156
|
-
label = label.item(0)
|
|
157
|
-
label.classList.add('-inactive')
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function enableCheckboxesIfMaxHasUndershot() {
|
|
162
|
-
selectedCheckboxes = selectedCheckboxes - 1
|
|
163
|
-
counter.innerHTML = selectedCheckboxes + '/' + maxAnswerCount
|
|
164
|
-
var disabledCheckboxes = votingOptions.filter(isDisabled)
|
|
165
|
-
disabledCheckboxes.map(function (disabledCheckboxes) {
|
|
166
|
-
disabledCheckboxes.disabled = false
|
|
167
|
-
var label = hr$('label[for=' + disabledCheckboxes.id + ']')
|
|
168
|
-
label = label.item(0)
|
|
169
|
-
label.classList.remove('-inactive')
|
|
170
|
-
})
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function initVotingValidation() {
|
|
174
|
-
if (isMultipleChoice) {
|
|
175
|
-
counter = counter.item(0)
|
|
176
|
-
submit.disabled = true
|
|
177
|
-
|
|
178
|
-
// Uncheck all checkboxes if User was faster than JS loading
|
|
179
|
-
for (var i = 0; i < votingOptions.length; i++) {
|
|
180
|
-
votingOptions[i].checked = false
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
for (var i = 0; i < votingOptions.length; i++) {
|
|
184
|
-
votingOptions[i].disabled = false
|
|
185
|
-
hr$.listen('click', countSelectedCheckboxes, votingOptions[i])
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
initVotingValidation()
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
hrScriptLoad.load('voteValidator', ['hrQueryOld'], function (options) {
|
|
194
|
-
new VoteValidator(options)
|
|
195
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var VotingCookieChecker =
|
|
2
|
-
VotingCookieChecker ||
|
|
3
|
-
function (options) {
|
|
4
|
-
'use strict'
|
|
5
|
-
|
|
6
|
-
var settings = JSON.parse(options.data),
|
|
7
|
-
element = hr$(options.selector)[0],
|
|
8
|
-
votingId = settings.votingId,
|
|
9
|
-
cookie = '',
|
|
10
|
-
votingWrapper = hr$('.js-voting-wrapper', element)[0],
|
|
11
|
-
hideVotingResult = settings.hideVotingResult,
|
|
12
|
-
alreadyVotedTmpl = '<p>' + settings.alreadyVotedHintText + '<p>',
|
|
13
|
-
checkForVotingCookie = function () {
|
|
14
|
-
cookie = hr$.getJSONCookie(votingId)
|
|
15
|
-
if (cookie) {
|
|
16
|
-
var voting = hr$('#' + votingId)[0]
|
|
17
|
-
var votingText = voting.querySelector('.c-voting-form__bottomWrapper')
|
|
18
|
-
hideVotingResult
|
|
19
|
-
? hr$.replaceAnimated(votingText, alreadyVotedTmpl, true)
|
|
20
|
-
: hr$.replaceAnimated(
|
|
21
|
-
votingWrapper,
|
|
22
|
-
hr$('.js-result', element)[0].innerHTML,
|
|
23
|
-
true
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
checkForVotingCookie()
|
|
28
|
-
}
|
|
29
|
-
hrScriptLoad.load('votingCookieChecker', ['hrQueryOld'], function (options) {
|
|
30
|
-
new VotingCookieChecker(options)
|
|
31
|
-
})
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
var Voting =
|
|
2
|
-
Voting ||
|
|
3
|
-
function (options) {
|
|
4
|
-
'use strict'
|
|
5
|
-
|
|
6
|
-
var element = hr$(options.selector)[0],
|
|
7
|
-
settings = options.data ? JSON.parse(options.data) : {},
|
|
8
|
-
jsonURL = settings.jsonURL,
|
|
9
|
-
votingWrapper = hr$('.js-voting-wrapper', element)[0],
|
|
10
|
-
votingTmpl = votingWrapper.innerHTML,
|
|
11
|
-
votingForm = hr$('.js-votingForm', element)[0],
|
|
12
|
-
actionUrl = votingForm && votingForm.getAttribute('action'),
|
|
13
|
-
ajaxOptions,
|
|
14
|
-
ajaxTimeout = 60 * 1000,
|
|
15
|
-
responseFormatParam = 'rf=inline',
|
|
16
|
-
isPosting = false,
|
|
17
|
-
preloadIcon,
|
|
18
|
-
loadingIcon,
|
|
19
|
-
validationErrors,
|
|
20
|
-
responseStatus,
|
|
21
|
-
checkForJsonURL = function () {
|
|
22
|
-
if (jsonURL) {
|
|
23
|
-
actionUrl = jsonURL
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
handleSubmit = function (event) {
|
|
27
|
-
event.preventDefault()
|
|
28
|
-
|
|
29
|
-
if (isPosting) {
|
|
30
|
-
return
|
|
31
|
-
} else {
|
|
32
|
-
isPosting = true
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//jedes mal neu holen,
|
|
36
|
-
//da das DOM mit innerHTML ersetzt wird
|
|
37
|
-
votingForm = hr$('.js-votingForm', element)[0]
|
|
38
|
-
|
|
39
|
-
// preloadIcon = hr$('.js-preloadIcon', formWrapper)[0];
|
|
40
|
-
// loadingIcon = hr$('.js-loadingIcon', formWrapper)[0];
|
|
41
|
-
//
|
|
42
|
-
// preloadIcon.classList.add('-isHidden');
|
|
43
|
-
// loadingIcon.classList.remove('-isHidden');
|
|
44
|
-
|
|
45
|
-
console.log('DATA: ' + $(votingForm).serialize())
|
|
46
|
-
ajaxOptions = {}
|
|
47
|
-
ajaxOptions.timeout = ajaxTimeout
|
|
48
|
-
|
|
49
|
-
ajaxOptions.type = 'POST'
|
|
50
|
-
ajaxOptions.url = actionUrl + '?' + responseFormatParam
|
|
51
|
-
ajaxOptions.data = $(votingForm).serialize()
|
|
52
|
-
ajaxOptions.contentType = 'application/x-www-form-urlencoded; charset=UTF-8'
|
|
53
|
-
ajaxOptions.dataType = ''
|
|
54
|
-
|
|
55
|
-
$.ajax(ajaxOptions)
|
|
56
|
-
|
|
57
|
-
//Add handlers to be called when the Deferred object is resolved.
|
|
58
|
-
.done(function (data, status, xhr) {
|
|
59
|
-
console.log('Done')
|
|
60
|
-
console.log(data)
|
|
61
|
-
|
|
62
|
-
if (settings.jsonURL) {
|
|
63
|
-
responseStatus = JSON.parse(data).status
|
|
64
|
-
switch (responseStatus) {
|
|
65
|
-
case 'VALIDATION_ERROR':
|
|
66
|
-
console.log('Validation Error')
|
|
67
|
-
validationErrors = JSON.parse(data).errors
|
|
68
|
-
handleValidationErrors(validationErrors)
|
|
69
|
-
break
|
|
70
|
-
case 'SERVER_ERROR':
|
|
71
|
-
hr$.replaceAnimated(
|
|
72
|
-
votingWrapper,
|
|
73
|
-
hr$('.js-errorMessage', element)[0].innerHTML,
|
|
74
|
-
true,
|
|
75
|
-
scrollIntoVoting()
|
|
76
|
-
)
|
|
77
|
-
break
|
|
78
|
-
case 'OK':
|
|
79
|
-
hr$.replaceAnimated(
|
|
80
|
-
votingWrapper,
|
|
81
|
-
hr$('.js-successMessage', element)[0].innerHTML,
|
|
82
|
-
true,
|
|
83
|
-
scrollIntoVoting()
|
|
84
|
-
)
|
|
85
|
-
break
|
|
86
|
-
default:
|
|
87
|
-
hr$.replaceAnimated(
|
|
88
|
-
votingWrapper,
|
|
89
|
-
hr$('.js-errorMessage', element)[0].innerHTML,
|
|
90
|
-
true,
|
|
91
|
-
scrollIntoVoting()
|
|
92
|
-
)
|
|
93
|
-
break
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
hr$.replaceAnimated(formWrapper, data, true)
|
|
97
|
-
scrollIntoVoting()
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
//Add handlers to be called when the Deferred object is rejected.
|
|
102
|
-
.fail(function (xhr, errorType, error) {
|
|
103
|
-
//anzeige irgendetwas hat nicht geklappt
|
|
104
|
-
console.log('Fail ' + errorType)
|
|
105
|
-
hr$.replaceAnimated(
|
|
106
|
-
votingWrapper,
|
|
107
|
-
hr$('.js-errorMessage', element)[0].innerHTML,
|
|
108
|
-
true,
|
|
109
|
-
setTimeout(function () {
|
|
110
|
-
scrollIntoVoting()
|
|
111
|
-
}, 850)
|
|
112
|
-
)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
//Add handlers to be called when the Deferred object is either resolved or rejected.
|
|
116
|
-
.always(function () {
|
|
117
|
-
//aufräumen wenn bedarf besteht.
|
|
118
|
-
console.log('Always')
|
|
119
|
-
|
|
120
|
-
isPosting = false
|
|
121
|
-
})
|
|
122
|
-
},
|
|
123
|
-
scrollIntoVoting = function (vertical) {
|
|
124
|
-
setTimeout(function () {
|
|
125
|
-
element.scrollIntoView({
|
|
126
|
-
behavior: 'smooth',
|
|
127
|
-
block: 'center',
|
|
128
|
-
})
|
|
129
|
-
}, 850)
|
|
130
|
-
},
|
|
131
|
-
handleFormReload = function (event) {
|
|
132
|
-
event.preventDefault()
|
|
133
|
-
hr$.replaceAnimated(votingWrapper, votingTmpl, false, reinitiateVotingForm)
|
|
134
|
-
scrollIntoVoting()
|
|
135
|
-
//hr$.ux('forms', 'formReload');
|
|
136
|
-
},
|
|
137
|
-
setValidationErrors = function (errors) {
|
|
138
|
-
var wrapperElement, errorElement, prop, InvalidFields
|
|
139
|
-
|
|
140
|
-
for (prop in errors) {
|
|
141
|
-
wrapperElement = element.getElementsByClassName('js-wrapper-' + prop)[0]
|
|
142
|
-
errorElement = document.createElement('p')
|
|
143
|
-
|
|
144
|
-
InvalidFields = document.getElementsByName(prop)
|
|
145
|
-
for (var i = 0; i < InvalidFields.length; i++) {
|
|
146
|
-
if (wrapperElement.contains(InvalidFields[i])) {
|
|
147
|
-
InvalidFields[i].classList.add('is-invalid')
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
errorElement.innerHTML = settings.errorMessages[errors[prop]]
|
|
152
|
-
errorElement.classList.add('c-form__errorMessage')
|
|
153
|
-
|
|
154
|
-
wrapperElement.insertBefore(errorElement, wrapperElement.firstChild)
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
resetValidationErrors = function () {
|
|
158
|
-
var oldInvalidFields = hr$('.is-invalid', element),
|
|
159
|
-
oldErrorMessages = hr$('.c-form__errorMessage', element)
|
|
160
|
-
|
|
161
|
-
for (var i = 0; i < oldInvalidFields.length; i++) {
|
|
162
|
-
oldInvalidFields[i].classList.remove('is-invalid')
|
|
163
|
-
oldErrorMessages[i].parentNode.removeChild(oldErrorMessages[i])
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
handleValidationErrors = function (errors) {
|
|
167
|
-
resetValidationErrors()
|
|
168
|
-
setValidationErrors(errors)
|
|
169
|
-
},
|
|
170
|
-
isFormAvailable = function () {
|
|
171
|
-
return !!votingForm
|
|
172
|
-
},
|
|
173
|
-
reinitiateVotingForm = function () {
|
|
174
|
-
hrScriptLoad.rescanForModulesAndVariants(element.parentElement)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (!isFormAvailable()) {
|
|
178
|
-
//skip code execution
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
//init
|
|
183
|
-
votingWrapper.style.WebkitTransition = 'opacity 0.8s ease-in-out'
|
|
184
|
-
votingWrapper.style.MozTransition = 'opacity 0.8s ease-in-out'
|
|
185
|
-
votingWrapper.style.transition = 'opacity 0.8s ease-in-out'
|
|
186
|
-
|
|
187
|
-
checkForJsonURL()
|
|
188
|
-
|
|
189
|
-
$(element).on('submit', '.js-votingForm', handleSubmit)
|
|
190
|
-
$(element).on('click', '.js-formReload', handleFormReload)
|
|
191
|
-
$(element).on('keydown', '.js-form-email', function (e) {
|
|
192
|
-
e.stopPropagation()
|
|
193
|
-
})
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
hrScriptLoad.load('voting', ['hrQueryOld', 'zepto'], function (options) {
|
|
197
|
-
new Voting(options)
|
|
198
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{{> components/voting/voting_result
|
|
2
|
-
_title=_title
|
|
3
|
-
_topline=_topline
|
|
4
|
-
_resultBoxMessageTitle=(loca "votingform_title_error")
|
|
5
|
-
_resultBoxMessageText=(loca "votingform_text_error")
|
|
6
|
-
_locaKeyText="votingform_text_error"
|
|
7
|
-
_isInline=_isInline
|
|
8
|
-
_hideVotingResult=true
|
|
9
|
-
_statusDone=false
|
|
10
|
-
}}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import votingErrorJson from './fixtures/voting_error.json'
|
|
2
|
-
|
|
3
|
-
const handlebars = require('hrHandlebars')
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Komponenten/Voting',
|
|
7
|
-
decorators: [
|
|
8
|
-
(Story) => {
|
|
9
|
-
return `<div class="grid grid-page">
|
|
10
|
-
<div class="grid bg-white grid-article">
|
|
11
|
-
${Story()}
|
|
12
|
-
</div>
|
|
13
|
-
</div>`
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
parameters: {
|
|
17
|
-
layout: 'fullscreen',
|
|
18
|
-
chromatic: { disableSnapshot: true }
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const Template = (args) => {
|
|
23
|
-
let hbsTemplate = handlebars.compile(`
|
|
24
|
-
{{#>components/forms/components/backgroundBox }}
|
|
25
|
-
{{> components/voting/voting_error _title=this.title _topline=this.topline}}
|
|
26
|
-
{{/components/forms/components/backgroundBox }}
|
|
27
|
-
`)
|
|
28
|
-
return hbsTemplate({ ...args })
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const Voting_Error = {
|
|
32
|
-
render: Template.bind({}),
|
|
33
|
-
name: 'Fehlermeldung',
|
|
34
|
-
args: votingErrorJson,
|
|
35
|
-
}
|