-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
400 lines (365 loc) · 19.2 KB
/
index.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" contents="width=device-width, initial-scale=1.0">
<title>bootstrap Nested Sortable</title>
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
<link rel="icon" href="./favicon.ico" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css"
integrity="sha512-q3eWabyZPc1XTCmF+8/LuE1ozpg5xxn7iO89yfSOd5/oKvyqLngoNGsx8jq92Y8eXJ/IRxQbEC+FGSYxtk2oiw=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"> -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> -->
<script src="./js/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js" integrity="sha512-0bEtK0USNd96MnO4XhH8jhv3nyRF0eK87pJke6pkYf3cM0uDIhNJy9ltuzqgypoIFXw3JSuiy04tVk4AjpZdZw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link href="./css/BsNestedSortable.css" rel="stylesheet" />
<script src="./js/BsNestedSortable.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<p></p>
<ul id="tree" class="list-group"></ul>
</div>
<div class="row">
<div class="form-group">
<label for="catObj">catObj</label>
<textarea id="catObj" class="form-control" ></textarea>
</div>
<div class="form-group">
<label for="catObj2">catObj2</label>
<input type="text" id="catObj2" class="form-control" >
</div>
<div class="form-group">
<label for="parentArr">parentArr</label>
<input type="text" id="parentArr" class="form-control" >
</div>
<div class="form-group">
<label for="childrenArr">childrenArr</label>
<input type="text" id="childrenArr" class="form-control" >
</div>
<div class="form-group">
<label for="hierarchy">hierarchy</label>
<input type="text" id="hierarchy" class="form-control" >
</div>
<div class="form-group">
<label for="minHierarchy">minHierarchy</label>
<input type="text" id="minHierarchy" class="form-control" >
</div>
<div class="form-group">
<label for="allParentsArr">allParentsArr</label>
<input type="text" id="allParentsArr" class="form-control" >
</div>
<div class="form-group">
<label for="allChildrenArr">allChildrenArr</label>
<input type="text" id="allChildrenArr" class="form-control" >
</div>
<div class="modal fade" id="proceeding-error" tabindex="-1" role="dialog" aria-labelledby="myEroorLabel">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content bg-danger text-white">
<div class="modal-body text-center">
<h3 class="text-white mb-15" id="myEroorLabel"><i class="fa fa-exclamation-triangle"></i> ERROR!
</h3>
<span>proceeding Failed.</span>
<p>
<div id="errorDesc"></div>
</p>
<p></p>
<button type="button" class="btn btn-light close" data-dismiss="modal"
data-bs-dismiss="modal">Ok</button>
</div>
</div>
</div>
</div>
<div class="modal hide fade" id="proceeding-modal">
<div class="modal-dialog modal-dialog-centered " role="document">
<div class="modal-content">
<div class="modal-body text-center">
<div class="loader">
<div class="fa-3x">
<i class="fas fa-circle-notch fa-spin" style="color:blue ;"></i>
</div>
</div>
<div class="loader-txt" id="proceedingLabel">
<p>Please wait while the server is proceeding.</p>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Custom sized Modal</h4>
<button type="button" class="close" data-bs-dismiss="modal" data-dismiss="modal"
aria-label="Close"><i class="bi bi-x-lg"></i></button>
</div>
<div class="modal-body">
<div id="test"></div>
<input type="hidden" id="parentOfThis" />
<input type="hidden" id="IsAddItem" />
<input type="hidden" id="oldNameOfBranch" />
<input type="hidden" id="oldImgName" />
<div class="form-group">
<input type="text" class="form-control validate[required,minSize[2],maxSize[20]]" id="CatName"
placeholder="Item name" data-prompt-position="topLeft">
</div>
<div class="form-group">
<textarea class="summernote" name="CatDesc" id="CatDescId"
style="min-width: 100%;height: 10rem;" placeholder="Item description"></textarea>
</div>
<div class="form-group">
<div style="max-height: 2rem;" id="uploadedImage"></div>
<div class="input-group">
<div class="custom-file">
<div class="branch-leftdivImage" id="uploadedImage"></div>
<input type="text" class="form-control" id="image" placeholder="Item image"
data-prompt-position="topLeft">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn btn-primary submit" data-dismiss="modal"
data-bs-dismiss="modal">OK</button>
<button type="button" class="btn btn-orange close" data-dismiss="modal"
data-bs-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<!-- Modal HTML -->
<div id="myModalDelete" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Confirmation</h5>
<button type="button" class="btn-close" data-dismiss="modal" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<input type="hidden" id="IdOfDelete" />
<div class="text-center fs-1"><i class="bi bi-x-octagon" style="color:red"></i></div>
<p>Do you want to delete This Branch?</p>
<p class="text-secondary"><small>If you don't save, your changes will be lost.</small></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary close" data-dismiss="modal"
data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary Delete">Delete</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
const myData = [
{
id: 1,
parent_id: 0,
title: 'Branch 1',
description: '<p>Check out the <a href="http://api.jquery.com/text/" rel="noreferrer">text</a> method.</p>',
},
{
id: 2,
parent_id: 1,
title: 'Branch 2',
img: 'images/profile.jpg'
},
{
id: 3,
parent_id: 2,
title: 'Branch 3',
description: 'Description of Branch 3',
},
{
id: 4,
parent_id: 3,
title: 'Branch 4',
description: '',
myorder: 2,
},
{
id: 5,
parent_id: 4,
title: 'Branch 5',
img: 'images/snow.jpeg',
description: '<div class="comment-body js-comment-edit-hide">\nTest description</div>',
},
{
id: 6,
parent_id: 2,
title: 'Branch 6',
}, {
id: 8,
parent_id: 6,
img: 'images/coding.jpg',
title: 'Branch 8',
description: '',
},
{
id: 9,
parent_id: 3,
title: 'Branch 9',
description: '',
myorder: 1
},
{
id: 7,
img: 'images/coding.jpg',
parent_id: 10,
title: 'Branch 7',
},
{
title: 'Branch 10',
id: 10,
parent_id: 9,
description: '',
},
];
$(document).ready(function () {
const myAjaxRequest = async function (obj, type, url = "proceeding.php") {
await $("#proceeding-modal").modal({ backdrop: 'static', keyboard: false, }).modal("show");
let theResult = false;
await $.ajax({
url: url,
type: "POST",
data: {
postArray: obj,
type: type
},
success: function (data) {
const returnVals = JSON.parse(data);
console.log(returnVals.message);
$("#proceeding-modal").modal("hide");
if ($("#proceeding-modal").css("display") == "none") {
$('#proceeding-modal').on('shown.bs.modal', function (e) {
$("#proceeding-modal").modal("hide");
})
}
theResult = true;
},
error: function (error, exception) {
$("#proceeding-modal").modal("hide");
if ($("#proceeding-modal").css("display") == "none") {
$('#proceeding-modal').on('shown.bs.modal', function (e) {
$("#proceeding-modal").modal("hide");
})
}
theResult = false;
errorAlert(error, exception);
},
})
return theResult;
}
const input = {
data: myData, // {}, myData
options: {
modal: {
id: "#myModal",
ModalDelete: "#myModalDelete",
name: "#CatName",
description: "#CatDescId",
image: "#image"
},
maxLevel: 10,
dataAttributes: {
id: 'id__',
parent: 'parent__',
},
dataKeys: {
id: 'id',
parent: 'parent_id',
title: 'title',
description: 'description',
image: 'img',
order: "myorder"
}
},
language: {
createTheFirstBranch: "Insert New Branch and Make new data",
newItem: "New Item created",
editBranch: "Edit this Branch",
addBranch: "Add a new child here",
removeBranch: "Remove the Branch"
},
serializeOption: {
method: "JSON", // JSON alert console asVar
call: "val", // html val text jquery .html() ,.val() or .text()
outPuts: {
catObj: "#catObj", // the places which will have all categories
parentArr: "#parentArr", // parents array
childrenArr: "#childrenArr", // children array
Hierarchy: "#hierarchy", // expanded hierarchical array
minHierarchy: "#minHierarchy", // minimized hierarchical array
allParentsArr: "#allParentsArr", // all of parents
allChildrenArr: "#allChildrenArr" // all of children
}
},
eventsOptions: {
onComplete: async function (_, newSer) {
await $("#proceeding-modal").modal({ backdrop: 'static', keyboard: false, }).modal("show");
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
await timeout(500);
console.log("Completed");
console.log(JSON.stringify(newSer));
$("#proceeding-modal").modal("hide");
if ($("#proceeding-modal").css("display") == "none") {
$('#proceeding-modal').on('shown.bs.modal', function (e) {
$("#proceeding-modal").modal("hide");
})
}
return true;
},
onDelete: async function (_, deletedObj) {
return await myAjaxRequest(deletedObj, "delete");
},
onEdit: async function (_, editedObj) {
// return await myAjaxRequest(editedObj, "edit");
await $("#proceeding-modal").modal({ backdrop: 'static', keyboard: false, }).modal("show");
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
await timeout(1000);
$("#proceeding-modal").modal("hide");
if ($("#proceeding-modal").css("display") == "none") {
$('#proceeding-modal').on('shown.bs.modal', function (e) {
$("#proceeding-modal").modal("hide");
})
}
console.log("Edited"); console.log(editedObj);
return true;
},
onAdd: async function (_, addedObj) {
await $("#proceeding-modal").modal({ backdrop: 'static', keyboard: false, }).modal("show");
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
await timeout(1000);
$("#proceeding-modal").modal("hide");
if ($("#proceeding-modal").css("display") == "none") {
$('#proceeding-modal').on('shown.bs.modal', function (e) {
$("#proceeding-modal").modal("hide");
})
}
console.log("Added"); console.log(addedObj);
return true;
},
}
}
$("#tree").BsNestedSortable(input)//.serializeList()
})
</script>
</body>
</html>