ozdenui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +14 -0
- data/NOTICE +5 -0
- data/README.md +242 -0
- data/exe/ozdenui +17 -0
- data/lib/ozdenui/AGENTS.md +210 -0
- data/lib/ozdenui/COMPONENTS.md +3017 -0
- data/lib/ozdenui/app.rb +749 -0
- data/lib/ozdenui/command.rb +107 -0
- data/lib/ozdenui/components.rb +368 -0
- data/lib/ozdenui/dialogs.rb +212 -0
- data/lib/ozdenui/files.rb +124 -0
- data/lib/ozdenui/icon.png +0 -0
- data/lib/ozdenui/kit.json +1 -0
- data/lib/ozdenui/kit.rb +115 -0
- data/lib/ozdenui/look.rb +229 -0
- data/lib/ozdenui/objects.rb +652 -0
- data/lib/ozdenui/server.rb +270 -0
- data/lib/ozdenui/values.rb +273 -0
- data/lib/ozdenui/version.rb +15 -0
- data/lib/ozdenui/web/basic/LICENSE +14 -0
- data/lib/ozdenui/web/basic/basic.min.css +1 -0
- data/lib/ozdenui/web/basic/basic.min.js +78 -0
- data/lib/ozdenui/web/basic/font/open-sans/LICENSE.txt +206 -0
- data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
- data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
- data/lib/ozdenui/web/basic/scroll-bar.min.js +3 -0
- data/lib/ozdenui/web/bridge.js +584 -0
- data/lib/ozdenui/web/comp/accordion.js +659 -0
- data/lib/ozdenui/web/comp/action-button/add.png +0 -0
- data/lib/ozdenui/web/comp/action-button.js +521 -0
- data/lib/ozdenui/web/comp/action-tab-bar.js +383 -0
- data/lib/ozdenui/web/comp/app-bar.js +237 -0
- data/lib/ozdenui/web/comp/badge.js +292 -0
- data/lib/ozdenui/web/comp/bottom-bar.js +555 -0
- data/lib/ozdenui/web/comp/breadcrumbs.js +524 -0
- data/lib/ozdenui/web/comp/canvas.js +652 -0
- data/lib/ozdenui/web/comp/chat-view.js +827 -0
- data/lib/ozdenui/web/comp/check-box.js +490 -0
- data/lib/ozdenui/web/comp/code-editor.js +965 -0
- data/lib/ozdenui/web/comp/color-picker.js +636 -0
- data/lib/ozdenui/web/comp/context-menu.js +951 -0
- data/lib/ozdenui/web/comp/currency-field.js +209 -0
- data/lib/ozdenui/web/comp/data-table/arrow.svg +2 -0
- data/lib/ozdenui/web/comp/data-table.js +937 -0
- data/lib/ozdenui/web/comp/date-picker.js +1055 -0
- data/lib/ozdenui/web/comp/dialog.js +992 -0
- data/lib/ozdenui/web/comp/email-field.js +65 -0
- data/lib/ozdenui/web/comp/file-picker.js +920 -0
- data/lib/ozdenui/web/comp/filters.js +807 -0
- data/lib/ozdenui/web/comp/form.js +602 -0
- data/lib/ozdenui/web/comp/full-screen-select/arrow.svg +2 -0
- data/lib/ozdenui/web/comp/full-screen-select/cancel.svg +2 -0
- data/lib/ozdenui/web/comp/full-screen-select.js +614 -0
- data/lib/ozdenui/web/comp/gauge.js +439 -0
- data/lib/ozdenui/web/comp/graph-box.js +3911 -0
- data/lib/ozdenui/web/comp/grid-group.js +185 -0
- data/lib/ozdenui/web/comp/hold-to-confirm-button/trash-red.png +0 -0
- data/lib/ozdenui/web/comp/hold-to-confirm-button/trash.png +0 -0
- data/lib/ozdenui/web/comp/hold-to-confirm-button.js +289 -0
- data/lib/ozdenui/web/comp/image-view.js +598 -0
- data/lib/ozdenui/web/comp/item-list.js +1740 -0
- data/lib/ozdenui/web/comp/json-editor.js +3221 -0
- data/lib/ozdenui/web/comp/json-view.js +597 -0
- data/lib/ozdenui/web/comp/label-editor.js +1140 -0
- data/lib/ozdenui/web/comp/left-menu/data-table.png +0 -0
- data/lib/ozdenui/web/comp/left-menu/home.png +0 -0
- data/lib/ozdenui/web/comp/left-menu/reports.png +0 -0
- data/lib/ozdenui/web/comp/left-menu/setting.png +0 -0
- data/lib/ozdenui/web/comp/left-menu.js +548 -0
- data/lib/ozdenui/web/comp/line-progress-bar.js +343 -0
- data/lib/ozdenui/web/comp/loading-screen.js +413 -0
- data/lib/ozdenui/web/comp/log-view.js +530 -0
- data/lib/ozdenui/web/comp/login-page.js +685 -0
- data/lib/ozdenui/web/comp/markdown-view.js +1045 -0
- data/lib/ozdenui/web/comp/menu-bar.js +624 -0
- data/lib/ozdenui/web/comp/mini-graph-box.js +492 -0
- data/lib/ozdenui/web/comp/minimal-accent.js +208 -0
- data/lib/ozdenui/web/comp/notice.js +229 -0
- data/lib/ozdenui/web/comp/number-field.js +128 -0
- data/lib/ozdenui/web/comp/numeric-keyboard.js +298 -0
- data/lib/ozdenui/web/comp/page-control.js +762 -0
- data/lib/ozdenui/web/comp/page-header.js +191 -0
- data/lib/ozdenui/web/comp/password-field/hide-btn.png +0 -0
- data/lib/ozdenui/web/comp/password-field/hide-btn2.png +0 -0
- data/lib/ozdenui/web/comp/password-field/show-btn.png +0 -0
- data/lib/ozdenui/web/comp/password-field/show-btn2.png +0 -0
- data/lib/ozdenui/web/comp/password-field.js +192 -0
- data/lib/ozdenui/web/comp/period-bar.js +436 -0
- data/lib/ozdenui/web/comp/phone-field.js +322 -0
- data/lib/ozdenui/web/comp/progress-bar.js +992 -0
- data/lib/ozdenui/web/comp/property-panel.js +3639 -0
- data/lib/ozdenui/web/comp/radio-button.js +527 -0
- data/lib/ozdenui/web/comp/range-slider.js +569 -0
- data/lib/ozdenui/web/comp/rich-text-editor.js +1064 -0
- data/lib/ozdenui/web/comp/scroll-area.js +308 -0
- data/lib/ozdenui/web/comp/scrolling-text.js +297 -0
- data/lib/ozdenui/web/comp/search-input/clear-round.svg +1 -0
- data/lib/ozdenui/web/comp/search-input/clear.svg +1 -0
- data/lib/ozdenui/web/comp/search-input/filter.png +0 -0
- data/lib/ozdenui/web/comp/search-input/filter.svg +1 -0
- data/lib/ozdenui/web/comp/search-input/search.svg +1 -0
- data/lib/ozdenui/web/comp/search-input.js +725 -0
- data/lib/ozdenui/web/comp/search-results.js +596 -0
- data/lib/ozdenui/web/comp/select-box.js +1862 -0
- data/lib/ozdenui/web/comp/settings-row.js +299 -0
- data/lib/ozdenui/web/comp/side-panel.js +616 -0
- data/lib/ozdenui/web/comp/slider-field.js +952 -0
- data/lib/ozdenui/web/comp/slider.js +838 -0
- data/lib/ozdenui/web/comp/smart-button/alert-black.png +0 -0
- data/lib/ozdenui/web/comp/smart-button/clock.png +0 -0
- data/lib/ozdenui/web/comp/smart-button.js +981 -0
- data/lib/ozdenui/web/comp/smart-table/clock.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/down.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/scroll.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/sort.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/up.png +0 -0
- data/lib/ozdenui/web/comp/smart-table.js +1883 -0
- data/lib/ozdenui/web/comp/sortable-list.js +1181 -0
- data/lib/ozdenui/web/comp/spark-line-box.js +738 -0
- data/lib/ozdenui/web/comp/splitter.js +411 -0
- data/lib/ozdenui/web/comp/status-bar.js +408 -0
- data/lib/ozdenui/web/comp/step-bar.js +345 -0
- data/lib/ozdenui/web/comp/stepper.js +753 -0
- data/lib/ozdenui/web/comp/tabs.js +1366 -0
- data/lib/ozdenui/web/comp/tag-input.js +1107 -0
- data/lib/ozdenui/web/comp/tap-effect.js +170 -0
- data/lib/ozdenui/web/comp/text-area-field.js +233 -0
- data/lib/ozdenui/web/comp/text-field.js +1006 -0
- data/lib/ozdenui/web/comp/time-line.js +398 -0
- data/lib/ozdenui/web/comp/time-picker.js +1032 -0
- data/lib/ozdenui/web/comp/tiny-select/arrow.svg +1 -0
- data/lib/ozdenui/web/comp/tiny-select.js +322 -0
- data/lib/ozdenui/web/comp/tiny-table.js +283 -0
- data/lib/ozdenui/web/comp/toast.js +891 -0
- data/lib/ozdenui/web/comp/toggle.js +757 -0
- data/lib/ozdenui/web/comp/tool-bar.js +760 -0
- data/lib/ozdenui/web/comp/tooltip.js +534 -0
- data/lib/ozdenui/web/comp/tree-view.js +1179 -0
- data/lib/ozdenui/web/comp/ui-effects.js +1097 -0
- data/lib/ozdenui/web/comp/ui-standards.js +403 -0
- data/lib/ozdenui/web/comp/url-field.js +190 -0
- data/lib/ozdenui/web/comp/web-view.js +588 -0
- data/lib/ozdenui/web/components.js +123 -0
- data/lib/ozdenui/web/index.html +39 -0
- data/lib/ozdenui/window.rb +188 -0
- data/lib/ozdenui/window_cocoa.rb +221 -0
- data/lib/ozdenui.rb +32 -0
- metadata +200 -0
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
/* Bismillah */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
|
|
5
|
+
Component Template - v25.07
|
|
6
|
+
|
|
7
|
+
UI COMPONENT TEMPLATE
|
|
8
|
+
- You can customize, this template code as you need:
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Started Date: June 2024
|
|
12
|
+
Webpage: https://bug7a.github.io/js-components/
|
|
13
|
+
|
|
14
|
+
Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
|
|
15
|
+
Licensed under the Apache License, Version 2.0
|
|
16
|
+
SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
// Default values:
|
|
23
|
+
const FormDefaults = {
|
|
24
|
+
minWidth: 500,
|
|
25
|
+
maxWidth: 700,
|
|
26
|
+
buttonColor: "#65A293",
|
|
27
|
+
buttonText: "SEND",
|
|
28
|
+
allowHtml: 0, // 1: buttonText and the texts of showMessage() are HTML (only for your own texts)
|
|
29
|
+
showDetailWarning: 1,
|
|
30
|
+
missingEntryText: "{{count}} missing entry",
|
|
31
|
+
missingEntriesText: "{{count}} missing entries",
|
|
32
|
+
warningText: "<b>{{name}}</b> can't be empty", // HTML of the page; {{name}}: the title of the field, as it is written
|
|
33
|
+
errorText: "<b>{{name}}</b> is not valid", // HTML of the page, as warningText
|
|
34
|
+
minimalButton: 0,
|
|
35
|
+
doubleInputAlwaysHorizontal: 0,
|
|
36
|
+
showPassiveButtonHint: 1, // 1: A hint is shown when the mouse is over the passive send button.
|
|
37
|
+
passiveButtonHintText: "Please fill in the missing fields to send the form.",
|
|
38
|
+
// px: the round corners of the hints of the form: the list of the missing entries and the hint of the passive
|
|
39
|
+
// send button (one value, so they have the same corners)
|
|
40
|
+
hintRound: 4,
|
|
41
|
+
onChange: function(self, input) {}, // the user changed an input of the form
|
|
42
|
+
onSendClick: function(self, json) {},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const Form = function(params = {}) {
|
|
46
|
+
|
|
47
|
+
// Merge params:
|
|
48
|
+
mergeIntoIfMissing(params, FormDefaults);
|
|
49
|
+
|
|
50
|
+
// Edit params, if needed:
|
|
51
|
+
params.left = 0;
|
|
52
|
+
params.top = 0;
|
|
53
|
+
params.width = "100%";
|
|
54
|
+
params.height = "100%";
|
|
55
|
+
params.color = "transparent";
|
|
56
|
+
|
|
57
|
+
// BOX: Component container
|
|
58
|
+
let box = startObject(params);
|
|
59
|
+
|
|
60
|
+
// NOTE: Parent container is box.containerBox
|
|
61
|
+
|
|
62
|
+
// *** PRIVATE VARIABLES:
|
|
63
|
+
const PRESS_TIME = 200; // ms: the send button stays pressed this long (the same as its motion).
|
|
64
|
+
const MESSAGE_FADE_TIME = 200; // ms: the motion of the message box, then it is removed.
|
|
65
|
+
const NARROW_EXTRA_WIDTH = 50; // A page narrower than minWidth + this puts the double inputs under each other.
|
|
66
|
+
|
|
67
|
+
// *** PUBLIC VARIABLES:
|
|
68
|
+
// Input Objects list [var]
|
|
69
|
+
box.inputList = [];
|
|
70
|
+
// DoubleInput group list [var]
|
|
71
|
+
box.groupList = [];
|
|
72
|
+
|
|
73
|
+
// NOTE: Default values are also public variables.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// *** PRIVATE FUNCTIONS:
|
|
77
|
+
|
|
78
|
+
const setText = function (label, text) {
|
|
79
|
+
const value = (text === undefined || text === null) ? "" : String(text);
|
|
80
|
+
if (box.allowHtml == 1) label.text = value;
|
|
81
|
+
else label.plainText = value;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Give effects to a button
|
|
85
|
+
const actionButtonEffect = function(btn) {
|
|
86
|
+
|
|
87
|
+
btn.setMotion("filter 0.2s, transform 0.2s");
|
|
88
|
+
|
|
89
|
+
btn.on("mouseover", function() {
|
|
90
|
+
btn.css.filter = "brightness(120%)";
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
btn.on("mouseout", function() {
|
|
94
|
+
btn.css.filter = "brightness(100%)";
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
btn.on("mousedown", function() {
|
|
98
|
+
btn.css = { transform: "scale(0.95)", filter: "brightness(80%)" };
|
|
99
|
+
|
|
100
|
+
setTimeout(function(){
|
|
101
|
+
btn.css = { transform: "scale(1)", filter: "brightness(120%)" };
|
|
102
|
+
}, PRESS_TIME);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// The message over the form after sending. A key that messageData does not give comes from the success message.
|
|
108
|
+
box.showMessage = function(messageData) {
|
|
109
|
+
|
|
110
|
+
messageData = Object.assign({
|
|
111
|
+
iconColor: "#3C8553",
|
|
112
|
+
iconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" preserveAspectRatio="none" fill="none" stroke="#141414" stroke-width="8"><path d="M24 63L50 89L104 35"/></svg>'), // a check mark (drawn inverted: white)
|
|
113
|
+
messageText: "Data sent successfully.",
|
|
114
|
+
buttonText: "OKAY",
|
|
115
|
+
backgroundColor: "rgba(255,255,255,0.85)",
|
|
116
|
+
onClose: function() {},
|
|
117
|
+
}, messageData);
|
|
118
|
+
|
|
119
|
+
// GROUP: Sent Message
|
|
120
|
+
const messageBox = VGroup({
|
|
121
|
+
color: messageData.backgroundColor,
|
|
122
|
+
gap: 10,
|
|
123
|
+
clickable: 1, // WHY: Dont scroll the main page
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Animated message
|
|
127
|
+
that.opacity = 0;
|
|
128
|
+
that.css.transform = "scale(0.8) translateY(40px)";
|
|
129
|
+
that.setMotion("transform 0.2s, opacity 0.2s");
|
|
130
|
+
that.withMotion((self) => {
|
|
131
|
+
self.css.transform = "scale(1) translateY(0px)";
|
|
132
|
+
self.opacity = 1;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// GROUP: Round icon background
|
|
136
|
+
VGroup({
|
|
137
|
+
width: "auto",
|
|
138
|
+
height: "auto",
|
|
139
|
+
color: messageData.iconColor,
|
|
140
|
+
round: 100,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// ICON: Message icon
|
|
144
|
+
Icon({
|
|
145
|
+
width: 32,
|
|
146
|
+
height: 32,
|
|
147
|
+
});
|
|
148
|
+
that.load(messageData.iconFile);
|
|
149
|
+
that.css.filter = "invert(100%)";
|
|
150
|
+
|
|
151
|
+
endGroup();
|
|
152
|
+
|
|
153
|
+
// LABEL: Message
|
|
154
|
+
Label();
|
|
155
|
+
setText(that, messageData.messageText);
|
|
156
|
+
|
|
157
|
+
// LABEL: Close button
|
|
158
|
+
Label({
|
|
159
|
+
padding: [12, 4],
|
|
160
|
+
round: 12,
|
|
161
|
+
color: "#373836",
|
|
162
|
+
textColor: "#EBEBEB",
|
|
163
|
+
fontSize: 14,
|
|
164
|
+
clickable: 1,
|
|
165
|
+
});
|
|
166
|
+
setText(that, messageData.buttonText);
|
|
167
|
+
that.cursor = "pointer";
|
|
168
|
+
that.on("click", function(self) {
|
|
169
|
+
messageData.onClose();
|
|
170
|
+
self.clickable = 0;
|
|
171
|
+
messageBox.opacity = 0;
|
|
172
|
+
messageBox.css.transform = "scale(0.8) translateY(0px)";
|
|
173
|
+
setTimeout(() => {
|
|
174
|
+
messageBox.remove();
|
|
175
|
+
}, MESSAGE_FADE_TIME);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
endGroup();
|
|
179
|
+
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Puts the cover exactly over the send button. (The button width is 100%.)
|
|
183
|
+
const layoutSendCover = function() {
|
|
184
|
+
if (!box.btnSendCover) return;
|
|
185
|
+
box.btnSendCover.left = box.btnSend.left;
|
|
186
|
+
box.btnSendCover.top = box.btnSend.top;
|
|
187
|
+
box.btnSendCover.width = box.btnSend.elem.offsetWidth || box.btnSend.width;
|
|
188
|
+
box.btnSendCover.height = box.btnSend.elem.offsetHeight || box.btnSend.height;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// The cover works only while the send button is passive.
|
|
192
|
+
// WHY: With the form ready the cover would be over the button and would eat the click.
|
|
193
|
+
const setPassiveButtonCover = function(isOn) {
|
|
194
|
+
if (!box.btnSendCover) return;
|
|
195
|
+
box.btnSendCover.clickable = isOn;
|
|
196
|
+
if (!isOn && box.btnSendCover.tooltip) box.btnSendCover.tooltip.visible = 0;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// The detail line of one input. status: 1 empty, 2 not valid ("" for any other status)
|
|
200
|
+
const getWarningLine = function(item) {
|
|
201
|
+
const name = basic.escapeHtml(item.titleText);
|
|
202
|
+
if (item.status == 1) return box.warningText.replace("{{name}}", name) + "<br>";
|
|
203
|
+
if (item.status == 2) return box.errorText.replace("{{name}}", name) + "<br>";
|
|
204
|
+
return "";
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const getMissingText = function(warningCount) {
|
|
208
|
+
const text = (warningCount == 1) ? box.missingEntryText : box.missingEntriesText;
|
|
209
|
+
return text.replace("{{count}}", warningCount);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// Check the form and create warnings, active the send button
|
|
213
|
+
const checkForm = function() {
|
|
214
|
+
|
|
215
|
+
let warningCount = 0;
|
|
216
|
+
let warningDetailMessage = "";
|
|
217
|
+
|
|
218
|
+
box.inputList.forEach((item) => {
|
|
219
|
+
if (item.status === 0) return;
|
|
220
|
+
warningDetailMessage += getWarningLine(item);
|
|
221
|
+
warningCount++;
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
box.lblWarningDetail.text = warningDetailMessage;
|
|
225
|
+
|
|
226
|
+
if (warningCount > 0) {
|
|
227
|
+
box.btnSend.clickable = 0;
|
|
228
|
+
box.btnSend.css.filter = "grayscale(100%)";
|
|
229
|
+
setPassiveButtonCover(1);
|
|
230
|
+
box.lblWarning.text = getMissingText(warningCount);
|
|
231
|
+
box.lblWarning.opacity = 1;
|
|
232
|
+
box.lblWarning.clickable = 1;
|
|
233
|
+
|
|
234
|
+
} else {
|
|
235
|
+
box.lblWarning.opacity = 0;
|
|
236
|
+
box.lblWarning.clickable = 0;
|
|
237
|
+
box.btnSend.clickable = 1;
|
|
238
|
+
box.btnSend.css.filter = "grayscale(0%)";
|
|
239
|
+
setPassiveButtonCover(0);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const createJSON = function() {
|
|
245
|
+
|
|
246
|
+
const result = [];
|
|
247
|
+
|
|
248
|
+
box.inputList.forEach((item) => {
|
|
249
|
+
const itemData = {};
|
|
250
|
+
itemData.key = item.key;
|
|
251
|
+
itemData.type = item.type;
|
|
252
|
+
itemData.titleText = item.titleText;
|
|
253
|
+
itemData.value = item.getValue();
|
|
254
|
+
|
|
255
|
+
result.push(itemData);
|
|
256
|
+
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
return result;
|
|
260
|
+
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const postJSON = function(url, data, callback) {
|
|
264
|
+
|
|
265
|
+
const xhr = new XMLHttpRequest();
|
|
266
|
+
xhr.open("POST", url);
|
|
267
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
|
268
|
+
|
|
269
|
+
xhr.onreadystatechange = function () {
|
|
270
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
271
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
272
|
+
try {
|
|
273
|
+
const result = JSON.parse(xhr.responseText);
|
|
274
|
+
callback(null, result); // a successful answer
|
|
275
|
+
} catch (e) {
|
|
276
|
+
callback(new Error("Geçersiz JSON cevabı"));
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
callback(new Error(`HTTP Hatası: ${xhr.status}`));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
xhr.onerror = function () {
|
|
285
|
+
callback(new Error("İstek gönderilirken bir hata oluştu."));
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
xhr.send(JSON.stringify(data));
|
|
289
|
+
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// On page resized call
|
|
293
|
+
const pageResized = function() {
|
|
294
|
+
|
|
295
|
+
page.fit(box.minWidth);
|
|
296
|
+
// NOTE: Page width will not be smaller than box.minWidth but page.zoom (1) will start get smaller
|
|
297
|
+
|
|
298
|
+
const isNarrow = (page.width < (box.minWidth + NARROW_EXTRA_WIDTH));
|
|
299
|
+
const isVertical = (isNarrow && box.doubleInputAlwaysHorizontal != 1);
|
|
300
|
+
const flow = isVertical ? "vertical" : "horizontal";
|
|
301
|
+
|
|
302
|
+
box.groupList.forEach(group => {
|
|
303
|
+
group.flow = flow;
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Center form onResize
|
|
307
|
+
box.formContainer.center("left");
|
|
308
|
+
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// *** PUBLIC FUNCTIONS:
|
|
312
|
+
|
|
313
|
+
// WHY: box.superRemove is overwritten by a component that extends this one, so the local copy is called below.
|
|
314
|
+
const superRemove = box.remove;
|
|
315
|
+
box.superRemove = superRemove;
|
|
316
|
+
box.remove = function () {
|
|
317
|
+
|
|
318
|
+
if (!box) return; // WHY: remove() can be called twice (also by the parent's remove()).
|
|
319
|
+
// WHY: The form itself scrolls, so its scroll bar is on the parent (page), not in the box.
|
|
320
|
+
if (box.scrollBar) box.scrollBar.remove();
|
|
321
|
+
|
|
322
|
+
superRemove.call(box); // NOTE: basic.js remove(). It cleans all the events and the objects inside.
|
|
323
|
+
box = null;
|
|
324
|
+
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
box.setPassiveButtonHintText = function(text) {
|
|
328
|
+
box.passiveButtonHintText = text;
|
|
329
|
+
if (box.btnSendCover && box.btnSendCover.tooltip) box.btnSendCover.tooltip.setHintText(text);
|
|
330
|
+
};
|
|
331
|
+
// USAGE: get: form.passiveButtonHintText, set: form.setPassiveButtonHintText("...")
|
|
332
|
+
|
|
333
|
+
// If you need to change a param after it is created. You can write a setter function for it.
|
|
334
|
+
box.addInput = function(input) {
|
|
335
|
+
|
|
336
|
+
box.inputGroup.add(input);
|
|
337
|
+
input.width = "100%";
|
|
338
|
+
input.position = "relative";
|
|
339
|
+
|
|
340
|
+
box.inputList.push(input);
|
|
341
|
+
|
|
342
|
+
watchInput(input);
|
|
343
|
+
box.refresh();
|
|
344
|
+
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
box.addTitle = function(obj) {
|
|
348
|
+
|
|
349
|
+
box.titleGroup.add(obj);
|
|
350
|
+
obj.position = "relative";
|
|
351
|
+
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
box.addDoubleInput = function(input, input2) {
|
|
355
|
+
|
|
356
|
+
// GROUP: First Name, Last Name
|
|
357
|
+
const nameGroup = AutoLayout({
|
|
358
|
+
flow: "horizontal",
|
|
359
|
+
gap: 20,
|
|
360
|
+
width: "100%",
|
|
361
|
+
height: "auto",
|
|
362
|
+
});
|
|
363
|
+
endAutoLayout(); // GROUP: First Name, Last Name (the inputs are added below)
|
|
364
|
+
|
|
365
|
+
nameGroup.add(input);
|
|
366
|
+
input.width = "100%";
|
|
367
|
+
input.position = "relative";
|
|
368
|
+
|
|
369
|
+
nameGroup.add(input2);
|
|
370
|
+
input2.width = "100%";
|
|
371
|
+
input2.position = "relative";
|
|
372
|
+
|
|
373
|
+
box.inputGroup.add(nameGroup);
|
|
374
|
+
nameGroup.position = "relative";
|
|
375
|
+
|
|
376
|
+
box.groupList.push(nameGroup);
|
|
377
|
+
|
|
378
|
+
box.inputList.push(input);
|
|
379
|
+
box.inputList.push(input2);
|
|
380
|
+
|
|
381
|
+
watchInput(input);
|
|
382
|
+
watchInput(input2);
|
|
383
|
+
box.refresh();
|
|
384
|
+
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
box.refresh = function() {
|
|
388
|
+
|
|
389
|
+
checkForm();
|
|
390
|
+
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// The form is checked again on every edit, focus and blur of the input.
|
|
394
|
+
const watchInput = function(input) {
|
|
395
|
+
|
|
396
|
+
input.onChange = function() {
|
|
397
|
+
checkForm();
|
|
398
|
+
box.onChange(box, input);
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
input.onFocus = function() {
|
|
402
|
+
checkForm();
|
|
403
|
+
};
|
|
404
|
+
input.onBlur = function() {
|
|
405
|
+
checkForm();
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// *** OBJECT VIEW:
|
|
411
|
+
box.scrollY = 1;
|
|
412
|
+
|
|
413
|
+
// Form container
|
|
414
|
+
box.formContainer = startBox(0, 0, {
|
|
415
|
+
height: "auto",
|
|
416
|
+
width: "100%",
|
|
417
|
+
color: "transparent",
|
|
418
|
+
});
|
|
419
|
+
that.css = { minWidth: box.minWidth + "px", maxWidth: box.maxWidth + "px" };
|
|
420
|
+
|
|
421
|
+
// GROUP: Form Items
|
|
422
|
+
AutoLayout({
|
|
423
|
+
flow: "vertical",
|
|
424
|
+
align: "top center",
|
|
425
|
+
gap: 20,
|
|
426
|
+
padding: [40, 40],
|
|
427
|
+
height: "auto",
|
|
428
|
+
position: "relative", // Because box.formContainer.height = "auto"
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// GROUP: Title, Description
|
|
432
|
+
box.titleGroup = AutoLayout({
|
|
433
|
+
flow: "vertical",
|
|
434
|
+
align: "left top",
|
|
435
|
+
gap: 0,
|
|
436
|
+
width: "100%",
|
|
437
|
+
height: "auto",
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
// NOTE: The titles are added with box.addTitle().
|
|
441
|
+
|
|
442
|
+
endAutoLayout(); // GROUP: Title, Description
|
|
443
|
+
box.titleGroup.css.marginBottom = "20px";
|
|
444
|
+
|
|
445
|
+
// GROUP: Input Items
|
|
446
|
+
box.inputGroup = AutoLayout({
|
|
447
|
+
flow: "vertical",
|
|
448
|
+
align: "top center",
|
|
449
|
+
gap: 20,
|
|
450
|
+
padding: [0, 0],
|
|
451
|
+
width: "100%",
|
|
452
|
+
height: "auto",
|
|
453
|
+
position: "relative", // Because box.formContainer.height = "auto"
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// NOTE: The inputs are added with box.addInput() and box.addDoubleInput().
|
|
457
|
+
|
|
458
|
+
endAutoLayout();
|
|
459
|
+
|
|
460
|
+
// GROUP: Form send button
|
|
461
|
+
AutoLayout({
|
|
462
|
+
width: "100%",
|
|
463
|
+
height: "auto",
|
|
464
|
+
clipContent: 0,
|
|
465
|
+
});
|
|
466
|
+
that.css.marginTop = "20px";
|
|
467
|
+
|
|
468
|
+
// BUTTON: Send Button
|
|
469
|
+
box.btnSend = Button({
|
|
470
|
+
width: "100%",
|
|
471
|
+
color: box.buttonColor,
|
|
472
|
+
minimal: box.minimalButton,
|
|
473
|
+
});
|
|
474
|
+
setText(box.btnSend, box.buttonText);
|
|
475
|
+
actionButtonEffect(that);
|
|
476
|
+
// WHY click, not mousedown: a right click, or a press dragged away from the button, sent the
|
|
477
|
+
// form; and Enter / Space on the focused button (a <button>: they give a click) did nothing
|
|
478
|
+
that.on("click", function(self, event) {
|
|
479
|
+
// NOTE: The button is ready only when the form is checked (checkForm). The keyboard reaches
|
|
480
|
+
// a passive button too, so it is checked here.
|
|
481
|
+
if (box.btnSend.clickable != 1) return;
|
|
482
|
+
if (event.detail > 1) return; // (the second click of a double click)
|
|
483
|
+
const formJSON = createJSON();
|
|
484
|
+
box.onSendClick(box, formJSON);
|
|
485
|
+
});
|
|
486
|
+
that.on("keydown", function(self, event) {
|
|
487
|
+
// WHY: a held Enter repeats the click of a <button>
|
|
488
|
+
if (event.repeat && (event.key == "Enter" || event.key == " ")) event.preventDefault();
|
|
489
|
+
});
|
|
490
|
+
box.btnSend.clickable = 0; // NOTE: checkForm() makes it clickable when the form is ready.
|
|
491
|
+
box.btnSend.css.filter = "grayscale(100%)";
|
|
492
|
+
|
|
493
|
+
// BOX: Catches the mouse while the send button is passive.
|
|
494
|
+
// WHY: clickable: 0 puts "pointer-events: none" on the button, so the button
|
|
495
|
+
// itself can not see the mouse and can not show a hint.
|
|
496
|
+
// NOTE: A Button can NOT hold other objects, only a Box can. So the cover is a
|
|
497
|
+
// brother of the button in the same group and is put over it, the same way
|
|
498
|
+
// box.lblWarning is. (A box created inside the button would also send its
|
|
499
|
+
// mouse events up to the button and colour it on hover.)
|
|
500
|
+
// It is turned off as soon as the form is ready, so it never eats a click.
|
|
501
|
+
if (box.showPassiveButtonHint == 1 && typeof Tooltip !== "undefined") {
|
|
502
|
+
|
|
503
|
+
box.btnSendCover = Box({
|
|
504
|
+
position: "absolute",
|
|
505
|
+
color: "transparent",
|
|
506
|
+
clickable: 1,
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
box.btnSendCover.tooltip = Tooltip({
|
|
510
|
+
target: box.btnSendCover,
|
|
511
|
+
hintText: box.passiveButtonHintText,
|
|
512
|
+
hintPosition: "top",
|
|
513
|
+
lbl_color: "white",
|
|
514
|
+
lbl_textColor: "#141414",
|
|
515
|
+
lbl_borderColor: "#141414",
|
|
516
|
+
lbl_border: 1,
|
|
517
|
+
lbl_fontSize: 14,
|
|
518
|
+
lbl_round: box.hintRound,
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
layoutSendCover();
|
|
522
|
+
box.btnSend.onResize(layoutSendCover); // The button is 100% wide.
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// LABEL: box.lblWarning
|
|
527
|
+
box.lblWarning = Label({
|
|
528
|
+
text: "2 Warnings",
|
|
529
|
+
textColor: "#373836",
|
|
530
|
+
color: "#F1C74A",
|
|
531
|
+
padding: [8, 2],
|
|
532
|
+
position: "absolute",
|
|
533
|
+
fontSize: 14,
|
|
534
|
+
round: 4,
|
|
535
|
+
border: 1,
|
|
536
|
+
opacity: 0,
|
|
537
|
+
});
|
|
538
|
+
that.setMotion("opacity 0.2s");
|
|
539
|
+
box.lblWarning.left = box.btnSend.left + 5;
|
|
540
|
+
box.lblWarning.top = box.btnSend.top + 5;
|
|
541
|
+
|
|
542
|
+
// LABEL: box.lblWarningDetail
|
|
543
|
+
box.lblWarningDetail = Label({
|
|
544
|
+
text: "",
|
|
545
|
+
textColor: "#373836",
|
|
546
|
+
color: "whitesmoke",
|
|
547
|
+
padding: [8, 2],
|
|
548
|
+
position: "absolute",
|
|
549
|
+
fontSize: 12,
|
|
550
|
+
round: box.hintRound,
|
|
551
|
+
border: 1,
|
|
552
|
+
opacity: 0,
|
|
553
|
+
});
|
|
554
|
+
that.css.transform = "scale(0.7)";
|
|
555
|
+
that.setMotion("opacity 0.2s, transform 0.2s");
|
|
556
|
+
|
|
557
|
+
// Show box.lblWarningDetail
|
|
558
|
+
box.lblWarning.on("mouseover", function() {
|
|
559
|
+
if (box.showDetailWarning != 1) return;
|
|
560
|
+
box.lblWarningDetail.opacity = 1;
|
|
561
|
+
box.lblWarningDetail.aline(box.lblWarning, "top", 8, "left");
|
|
562
|
+
box.lblWarningDetail.css.transform = "scale(1)";
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
// Hide box.lblWarningDetail
|
|
566
|
+
box.lblWarning.on("mouseout", function() {
|
|
567
|
+
box.lblWarningDetail.opacity = 0;
|
|
568
|
+
box.lblWarningDetail.css.transform = "scale(0.7)";
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
endAutoLayout(); // GROUP: Form send button
|
|
572
|
+
|
|
573
|
+
endAutoLayout(); // GROUP: Form Items
|
|
574
|
+
|
|
575
|
+
endBox(); // Form container
|
|
576
|
+
|
|
577
|
+
// SCROLL BAR: Scrollable page container (only if basic/scroll-bar.js is loaded)
|
|
578
|
+
if (typeof ScrollBar === "function") box.scrollBar = ScrollBar({
|
|
579
|
+
scrollableBox: box,
|
|
580
|
+
bar_border: 0,
|
|
581
|
+
bar_round: 2,
|
|
582
|
+
bar_borderColor: "rgba(0, 0, 0, 1)",
|
|
583
|
+
bar_width: 4,
|
|
584
|
+
bar_mouseOverWidth: 4,
|
|
585
|
+
bar_mouseOverColor: "#373836",
|
|
586
|
+
bar_opacity: 0.4,
|
|
587
|
+
bar_mouseOverOpacity: 0.9,
|
|
588
|
+
bar_padding: 2,
|
|
589
|
+
bar_color: "#373836",
|
|
590
|
+
neverHide: 0,
|
|
591
|
+
showDots: 1,
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// *** OBJECT INIT CODE:
|
|
595
|
+
box.refresh();
|
|
596
|
+
|
|
597
|
+
pageResized();
|
|
598
|
+
box.onPageResize(pageResized);
|
|
599
|
+
|
|
600
|
+
return endObject(box);
|
|
601
|
+
|
|
602
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" id="Outline" viewBox="0 0 24 24" width="512" height="512"><path d="M18.71,8.21a1,1,0,0,0-1.42,0l-4.58,4.58a1,1,0,0,1-1.42,0L6.71,8.21a1,1,0,0,0-1.42,0,1,1,0,0,0,0,1.41l4.59,4.59a3,3,0,0,0,4.24,0l4.59-4.59A1,1,0,0,0,18.71,8.21Z"/></svg>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="512" height="512"><g id="_01_align_center" data-name="01 align center"><polygon points="24 1.414 22.586 0 12 10.586 1.414 0 0 1.414 10.586 12 0 22.586 1.414 24 12 13.414 22.586 24 24 22.586 13.414 12 24 1.414"/></g></svg>
|