-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaper-speech-rec-button.html
More file actions
89 lines (70 loc) · 1.92 KB
/
paper-speech-rec-button.html
File metadata and controls
89 lines (70 loc) · 1.92 KB
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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../iron-icons/av-icons.html">
<link rel="import" href="../paper-material/paper-material.html">
<link rel="import" href="../paper-spinner/paper-spinner.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../speech-recognition/speech-recognition-behavior.html">
<!--
An element providing a solution to no problem in particular.
Example:
<paper-speech-rec-button></paper-speech-rec-button>
@group Seed Elements
@element paper-speech-rec-button
@demo demo/index.html
@hero hero.svg
-->
<dom-module id="paper-speech-rec-button">
<template>
<style>
:host {
display: block;
position: relative;
}
.action-button-container {
position: relative;
}
.action-button-container paper-material {
border-radius: 50%;
position: relative;
}
.action-button-container paper-material paper-spinner {
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
}
</style>
<div class="action-button-container">
<paper-material id="materialContainer" elevation="[[_cptElevation(isListening)]]" animated>
<paper-spinner active="[[isListening]]"></paper-spinner>
<paper-icon-button icon="av:mic" on-tap="_onToggleListening"></paper-icon-button>
<paper-material>
</div>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-speech-rec-button',
behaviors: [
WebCoreElem.SpeechRecognitionBehavior
],
properties: {
},
_cptElevation: function (isListening) {
if (isListening) {
return 3;
} else {
return 0;
}
},
_onToggleListening: function () {
if (!this.isListening) {
this.start();
} else {
this.stop();
}
},
});
</script>