This repository was archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathcustomize_style.html
212 lines (192 loc) · 9.48 KB
/
customize_style.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Those meta make the capture of handwriting inputs easier on mobile devices -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="HandheldFriendly" content="true"/>
<title>Customize style</title>
<link rel="stylesheet" href="../examples.css">
<style>
nav {
display: flex;
justify-content: baseline;
align-items: center;
flex-wrap: wrap;
padding: 12px;
}
nav span {
align-items: center;
display: flex;
flex-wrap: wrap;
}
.flex-item {
margin: 12px 12px 0 0;
}
#prompter-css {
height: 110px;
width: 70%;
margin-left: 36px;
padding: 24px;
position: absolute;
bottom: 60px;
z-index: 30;
border-radius: 6px;
background: rgba(240, 240, 240, 0.9);
}
.hidden {
display: none;
}
myscript-math-web {
height: calc(100% - 60px);
}
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
myscript-math-web {
height: calc(100vh - 200px);
}
#prompter-css {
position: fixed;
bottom: 12px;
}
}
</style>
<script src="../../../webcomponentsjs/webcomponents-loader.js"></script>
<script src="../../../pepjs/dist/pep.min.js"></script>
<link rel="import" href="../../../paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../../../paper-swatch-picker/paper-swatch-picker.html">
<link rel="import" href="../../../paper-slider/paper-slider.html">
<link rel="import" href="../../../neon-animation/web-animations.html">
<link rel="import" href="../../myscript-math-web.html">
<custom-style>
<style>
myscript-math-web {
--myscript-math-web-exports-color: #FF9917;
--myscript-math-web-background: url(https://farm6.staticflickr.com/5526/10976824044_aebaebdb12_z_d.jpg) no-repeat center center / cover;
--myscript-math-web-color: #ff7314;
--myscript-math-web-hover-color: #A44200;
--myscript-math-web-disabled-color: #FFD7BC;
--myscript-editor-line-pattern_-_background-image: repeating-linear-gradient(to bottom, #F5F6F7, #F5F6F7 1px, transparent 1px, transparent 72px);
;
--myscript-math-web-line-pattern_-_background-size: none;
--myscript-math-web-error-background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNzYgMjc2IiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWluWU1pbiBtZWV0Ij4KICAgIDxjaXJjbGUgY3g9IjEzOCIgY3k9IjEzOCIgcj0iMTI0IiBzdHJva2U9IiNCMzAwMDAiIHN0cm9rZS13aWR0aD0iMjgiIGZpbGw9Im5vbmUiLz4KICAgIDxsaW5lIHgxPSI0NSIgeTE9IjQ1IiB4Mj0iMjMxIiB5Mj0iMjMxIiBzdHJva2U9IiNCMzAwMDAiIHN0cm9rZS13aWR0aD0iMjIiLz4KPC9zdmc+Cg==);
--myscript-math-web-loader: {
background: url(http://myscript.com/wp-content/uploads/2014/01/math-logo.png) no-repeat center center / cover;
border: none;
border-radius: 0;
-webkit-animation: rotate-plan 2.4s infinite ease-in-out;
animation: rotate-plan 2.4s infinite ease-in-out;
};
}
</style>
</custom-style>
</head>
<body>
<nav>
<paper-toggle-button class="flex-item" id="penstyleclasses" checked>Apply pen style classes (greenThickPen)
</paper-toggle-button>
<span class="flex-item">
<paper-toggle-button id="penenabled">Enable pen color/width</paper-toggle-button>
<span id="pensettings" class="hidden">
<paper-swatch-picker id="pencolor" color="#ff7314"></paper-swatch-picker>
<paper-slider id="penwidth" snaps min="1" max="5" value="2"></paper-slider>
</span>
</span>
<span>
<label for="theme" class="flex-item">Theme:</label>
<select id="theme" class="flex-item">
<option value="normal-white">Normal white theme</option>
<option value="thin-green">Thin green theme</option>
<option value="bold-red">Bold red theme</option>
</select>
</span>
</nav>
<!-- Please change applicationkey and hmackey below with those send by mail during your registration. You can re-access them by connecting to your dashboard at developer.myscript.com with your myscript account -->
<myscript-math-web scheme="https"
host="webdemoapi.myscript.com"
applicationkey="515131ab-35fa-411c-bb4d-3917e00faf60"
hmackey="54b2ca8a-6752-469d-87dd-553bb450e9ad"
themewidth="2"
themecolor="#FFFFFF"
solvercolor="#A8A8A8"
touch-action="none"
theme='{".green": {"color": "#00FF00", "-myscript-pen-width": "3"}}'
penstyleclasses="green">
</myscript-math-web>
<div id="prompter-css">
<div id="prompter-css-text">
Theme or pen style applied will be written here (where component is myscript-math-web).
</div>
</div>
<script>
const themes = [{
name: 'normal-white',
color: '#FFFFFF',
resultColor: '#A8A8A8',
width: 2
}, {
name: 'thin-green',
color: '#00FF00',
resultColor: '#2E7D32',
width: 1
}, {
name: 'bold-red',
color: '#FF0000',
resultColor: '#B71C1C',
width: 3
}];
const component = document.querySelector('myscript-math-web');
const penSettings = document.querySelector('#pensettings');
const penColor = document.querySelector('#pencolor');
const penWidth = document.querySelector('#penwidth');
const penStyleClasses = document.querySelector('#penstyleclasses');
const prompterText = document.getElementById('prompter-css-text');
function updatePrompter(values) {
prompterText.innerText = '';
values.forEach(function(value) {
prompterText.innerText += `${value[0]} = ${JSON.stringify(value[1])} \n`;
});
}
document.querySelector('#theme').addEventListener('change', (event) => {
const selectedTheme = themes.find(theme => theme.name === event.target.value);
if (selectedTheme) {
component.themecolor = selectedTheme.color;
component.themewidth = selectedTheme.width;
component.solvercolor = selectedTheme.resultColor;
updatePrompter([['component.themecolor', selectedTheme.color], ['component.themewidth', selectedTheme.width], ['component.solvercolor', selectedTheme.resultColor]]);
}
});
document.querySelector('#penenabled').addEventListener('change', (event) => {
if (event.target.checked) {
penSettings.classList.remove('hidden');
component.pencolor = penColor.color;
component.penwidth = penWidth.value;
updatePrompter([['component.pencolor', penColor.color], ['component.penwidth', penWidth.value]]);
} else {
penSettings.classList.add('hidden');
component.pencolor = undefined;
component.penwidth = undefined;
updatePrompter([['component.pencolor', undefined], ['component.penwidth', undefined]]);
}
});
penColor.addEventListener('color-changed', (event) => {
component.pencolor = event.target.color;
updatePrompter([['component.pencolor', event.target.color]])
});
penWidth.addEventListener('change', (event) => {
component.penwidth = event.target.value;
updatePrompter([['component.pencolor', event.target.value]])
});
penStyleClasses.addEventListener('change', (event) => {
if (event.target.checked) {
component.penstyleclasses = 'green';
updatePrompter([['component.penstyleclasses ', 'green']]);
} else {
component.penstyleclasses = '';
updatePrompter([['component.penstyleclasses', '']]);
}
});
</script>
</body>
</html>