-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
123 lines (104 loc) · 3.19 KB
/
index.html
File metadata and controls
123 lines (104 loc) · 3.19 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Font Awesome Selector</title>
<meta name="author" content="Jeroen Fürst">
<!-- Kentico Custom element CSS-->
<link rel="stylesheet" type="text/css" href="./custom-element.min.css">
<link rel="stylesheet" type="text/css" href="./fontawesome-iconpicker.min.css">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" rel="stylesheet">
<!-- Kentico Custom elements API-->
<script src="https://app.kontent.ai/js-api/custom-element.js"></script>
<script src="//code.jquery.com/jquery-2.2.1.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="./fontawesome-iconpicker.min.js"></script>
<!-- jquery -->
<!-- Custom elements styles -->
<style>
body {
margin: 0;
}
.disabled_overlay {
position: fixed;
z-index: 10;
cursor: not-allowed;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
}
.iconpicker-popover.popover {
width: 100%;
margin: 0;
border-radius: 0;
}
.iconpicker-container input{
border-radius: 0;
}
.input-group-addon {
cursor: default;
}
</style>
</head>
<body>
<!-- Custom element HTML -->
<div class="disabled_overlay"></div>
<div>
<div class="text-field">
<div class="input-group">
<input data-placement="inline" class="form-control icp icp-auto" type="text" disabled="true"/>
<span class="input-group-addon" disabled="true"></span>
</div>
</div>
</div>
<!-- Custom element code -->
<script>
var isDisabled = false;
function updateDisabled(disabled) {
isDisabled = disabled;
if (disabled) {
$('.disabled_overlay').show();
}
else {
$('.disabled_overlay').hide();
}
}
function setup(value) {
$('.icp').iconpicker({
defaultValue: value,
collision: 'none'
});
$('.icp').on('iconpickerSelected', function (e) {
CustomElement.setValue(e.iconpickerValue);
});
$(".input-group-addon").off("click");
}
function updateSize() {
// Update the custom element height in the Kentico UI
const height = Math.ceil($("html").height());
CustomElement.setHeight(height);
}
function initCustomElement() {
try {
CustomElement.init((element, _context) => {
// Setup with initial value and disabled state
setup(element.value);
updateDisabled(element.disabled);
updateSize();
});
// React on disabled changed (e.g. when publishing the item)
CustomElement.onDisabledChanged(updateDisabled);
} catch (err) {
// Initialization with Kentico Custom element API failed
// (page displayed outside of the Kentico UI)
console.error(err);
updateDisabled(true);
}
}
initCustomElement();
</script>
</body>
</html>