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 4
Expand file tree
/
Copy pathcustomize_style.html
More file actions
202 lines (185 loc) · 9.37 KB
/
customize_style.html
File metadata and controls
202 lines (185 loc) · 9.37 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
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
<!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: space-between;
align-items: center;
flex-wrap: wrap;
padding: 0 12px 12px;
}
nav span {
align-items: center;
display: flex;
flex-wrap: wrap;
}
.flex-item {
margin-top: 12px;
margin-right: 12px;
}
#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-common-element {
height: calc(100% - 60px);
}
</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-common-element.html">
<custom-style>
<style>
myscript-common-element {
--myscript-common-element-background: url(https://farm6.staticflickr.com/5526/10976824044_aebaebdb12_z_d.jpg) no-repeat center center / cover;
--myscript-common-element-color: #FF7314;
--myscript-common-element-hover-color: #A44200;
--myscript-common-element-focus-color: #D05400;
--myscript-common-element-disabled-color: #FFD7BC;
--myscript-editor-line-pattern_-_background-image: repeating-linear-gradient(to bottom, #F5F6F7, #F5F6F7 1px, transparent 1px, transparent 72px);
--myscript-common-element-line-pattern_-_background-size: none;
;
--myscript-common-element-error-background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNzYgMjc2IiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWluWU1pbiBtZWV0Ij4KICAgIDxjaXJjbGUgY3g9IjEzOCIgY3k9IjEzOCIgcj0iMTI0IiBzdHJva2U9IiNCMzAwMDAiIHN0cm9rZS13aWR0aD0iMjgiIGZpbGw9Im5vbmUiLz4KICAgIDxsaW5lIHgxPSI0NSIgeTE9IjQ1IiB4Mj0iMjMxIiB5Mj0iMjMxIiBzdHJva2U9IiNCMzAwMDAiIHN0cm9rZS13aWR0aD0iMjIiLz4KPC9zdmc+Cg==);
--myscript-common-element-loader: {
background: url(http://myscript.com/wp-content/uploads/2014/01/text-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"></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-common-element scheme="https"
host="webdemoapi.myscript.com"
applicationkey="515131ab-35fa-411c-bb4d-3917e00faf60"
hmackey="54b2ca8a-6752-469d-87dd-553bb450e9ad"
themewidth="2"
themecolor="#FFFFFF"
touch-action="none"
disableconvertcontrol
disableclearcontrol
theme='{".green": {"color": "#00FF00", "-myscript-pen-width": "3"}}'
penstyleclasses="green">
</myscript-common-element>
<div id="prompter-css">
<div id="prompter-css-text">
Theme or pen style applied will be written here (where component is myscript-common-element).
</div>
</div>
<script>
const themes = [{
name: 'normal-white',
color: '#FFFFFF',
width: '2'
}, {
name: 'thin-green',
color: '#2E7D32',
width: '1'
}, {
name: 'bold-red',
color: '#B71C1C',
width: '3'
}];
const component = document.querySelector('myscript-common-element');
const penSettings = document.querySelector('#pensettings');
const penColor = document.querySelector('#pencolor');
const penWidth = document.querySelector('#penwidth');
const prompterText = document.getElementById('prompter-css-text');
function updatePrompter(category, value, category2, value2) {
if (category && value) {
prompterText.innerText = `${category} = ${JSON.stringify(value)}`;
if (category2 && value2) {
prompterText.innerText += `\n${category2} = ${JSON.stringify(value2)}`;
}
} else if (category) {
prompterText.innerText = category;
}
}
// Set penColor after to prevent taken into account too early
penColor.color = '#ff7314';
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;
updatePrompter('component.themecolor', selectedTheme.color, 'component.themewidth', selectedTheme.width);
}
});
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 \n 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.penwidth', event.target.value)
});
document.querySelector('#penstyleclasses').addEventListener('change', (event) => {
if (event.target.checked) {
component.penstyleclasses = 'green';
updatePrompter('component.penstyleclasses ', 'green');
} else {
component.penstyleclasses = '';
updatePrompter('component.penstyleclasses = \'\'');
}
});
</script>
</body>
</html>