-
Notifications
You must be signed in to change notification settings - Fork 1
/
wizard-view.html
114 lines (96 loc) · 2.63 KB
/
wizard-view.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<link rel="import" href="../polymer/polymer.html">
<!--
`<wizard-view>` allows you to advance through multiple screens/views. It has
minimal styles applied for functional purposes (show and hide).
To define its steps use the `<wizard-step>` elements inside of `<wizard-view>`.
If you want to trigger the next view by tapping an element in
`<wizard-step>`, assign it the `proceed-trigger` class.
Example:
<wizard-view>
<wizard-step active>
<span>First step</span>
<a href="#" class="proceed-trigger">Next</a>
</wizard-step>
<wizard-step>Second step</wizard-step>
</wizard-view>
@element wizard-view
@blurb Element providing solution to [...].
@status [...]
@homepage http://zinkkrysty.github.io/wizard-view/components/wizard-view/
-->
<polymer-element name="wizard-step" attributes="active completed">
<template>
<style>
:host {
display: none;
}
:host([active]) {
display: block;
}
</style>
<content></content>
</template>
<script>
Polymer({
/**
* Determines which step is the active one
*
* @attribute active
* @type boolean
* @default false
*/
active: false,
completed: false,
domReady: function(){
this.proceedTrigger = this.querySelector('.proceed-trigger');
var parent = this;
if(this.proceedTrigger) {
this.proceedTrigger.onclick = function(){
parent.proceed();
};
}
},
proceed: function(){
this.completed = true;
this.fire('wizard-step-done');
},
activeChanged: function(){
// Sets the attribute on the element to follow the property (useful for styling)
if(this.active)
this.setAttribute('active', '')
else
this.removeAttribute('active');
}
});
</script>
</polymer-element>
<polymer-element name="wizard-view">
<template>
<style>
:host {
display: block;
}
</style>
<div class="steps" on-wizard-step-done="{{proceed}}">
<content select="wizard-step"></content>
</div>
</template>
<script>
Polymer({
ready: function() {
this.steps = this.querySelectorAll('wizard-step');
},
proceed: function() {
this.changeActiveStep();
},
changeActiveStep: function() {
var currentActiveStep = this.querySelector('wizard-step[active]');
currentActiveStep.active = null;
var nextStep = currentActiveStep.nextElementSibling;
if(nextStep) {
nextStep.active = true;
}
},
});
</script>
</polymer-element>