-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocumentation.html
1612 lines (1439 loc) · 76.1 KB
/
documentation.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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!-- Sorry for the all-in-one-"franken"-html-page, but it's just to keep it all in one DEMO file -->
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="robots" content="index, follow" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>EasyDialogBox - Examples and documentation</title>
<style>
/* General page classes ***************************************/
.ital
{
font-style:italic;
}
.bold
{
font-weight:bold;
}
.small
{
font-size:0.75em;
}
.medium
{
font-size:1.15em;
}
.large
{
font-size:1.3em;
}
.larger
{
font-size:1.6em;
}
.xlarge
{
font-size:2.5em;
}
.right_side
{
margin-left:auto;
margin-right:0;
text-align:center;
width:50px;
}
.center
{
text-align:center;
}
.word
{
color:#0366d6;
}
.blue
{
color:#0366d6;
border-color:#0366d6;
}
.help
{
cursor:help;
}
.end_begin
{
border:none;
border-top:4px dashed #ccc;
}
.examples
{
margin-top:50px;
padding:15px 0;
border-bottom:1px solid #ccc;
}
.examples:last-of-type
{
border:none;
}
.section
{
margin-top:100px;
}
.headings
{
}
.small_note
{
font-size:0.75em;
color:#999;
}
/* END: General page classes */
/* Page elements **********************************************/
body
{
margin:0;
padding:0;
padding-bottom:200px;
background-color:#f1f1f1;
font-family:"Segoe UI", Roboto, Ubuntu, "Lucida Grande", Arial, Helvetica, sans-serif;
font-size:16px;
color:#000;
line-height:1.63em;
}
#page
{
margin:0 auto;
margin-top:20px;
max-width:1200px;
padding:20px;
background-color:#fff;
border:1px solid #ddd;
border-radius:3px;
}
h1, h2, h3, h4, h5, h6
{
font-family:inherit;
font-weight:400;
margin-left:0;
padding-left:0;
}
h1
{
font-size:2.6em;
line-height:1.0em;
}
h2
{
font-size:2.0em;
padding-bottom:10px;
border-bottom:1px solid #eaecef;
line-height:1.0em;
}
#main_heading
{
padding:15px;
background-color:#3d6da8;
border:1px solid #000;
border-radius:3px 3px 0 0;
}
#main_heading h1
{
font-size:2.7em;
color:#fff;
font-style:italic;
line-height:0.5em;
}
#sub_heading
{
padding:15px;
border:1px solid #000;
border-top:none;
border-radius:0 0 3px 3px;
font-size:1.04em;
}
code
{
font-family:Consolas, Monaco, "Ubuntu Mono", monospace;
font-size:1.0em;
font-weight:normal;
color:#000;
background-color:#f3f4f4;
padding:0 2px 1px 2px;
border:2px solid #f3f4f4;
border-radius:3px;
}
kbd
{
background-color:#eee;
border-radius:3px;
border:1px solid #b4b4b4;
box-shadow:0 1px 1px rgb(0 0 0 / 20%), 0 2px 0 0 rgb(255 255 255 / 70%) inset;
color:#333;
display:inline-block;
line-height:1;
padding:4px 4px 1px;
white-space:nowrap;
}
button
{
font-family:inherit;
font-size:inherit;
}
a
{
color:#000;
text-decoration:none;
border-bottom:1px dotted #000;
overflow-wrap:break-word;
word-wrap:break-word;
}
hr
{
border:none;
border-top:1px solid #ccc;
}
/* Table elements *********************************************/
table
{
border-collapse:collapse;
background-color:#fdfdfd;
margin:0;
margin-top:20px;
}
table th
{
background-color:#ddeaff;
border:1px #c8e1ff solid;
padding:5px;
text-align:left;
}
table td
{
border:1px #d4dde4 solid;
padding:6px;
}
table td:first-child
{
font-family:Consolas, Monaco, "Ubuntu Mono", monospace;
}
table td+td
{
font-weight:normal;
color:inherit;
}
#objTable tbody td+td,
.returnTable tbody td+td
{
font-style:italic;
color:#0366d6;
}
#objTable tbody td+td+td,
.returnTable tbody td+td+td
{
font-style:normal;
color:inherit;
}
.returnTable tbody td
{
text-align:center;
}
.returnTable tbody td+td
{
text-align:left;
}
/* END: page and table elements */
/* Codeview ***************************************************/
.codeview
{
display:block;
margin:0;
margin-bottom:10px;
padding:0;
padding-right:10px;
font-family:Consolas, Monaco, "Ubuntu Mono", monospace;
font-size:inherit;
line-height:normal;
background-color:#222;
color:#fff;
border:4px #ddd solid;
border-radius:3px;
overflow:scroll;
white-space:pre;
}
/* Code line numbers ******************************************/
.codeview:before
{
counter-reset:listing;
margin:0;
padding:0;
}
.codeview i
{
counter-increment:listing;
margin:0;
padding:0;
}
.codeview i::before
{
color:#ccc;
background-color:#666;
content:counter(listing) ".";
display:inline-block;
width:30px;
padding:0;
padding-left:2px;
padding-right:2px;
padding-bottom:0;
margin-left:0;
margin-right:20px;
margin-bottom:0;
text-align:right;
position:absolute;
}
/* END: Code line numbers */
/* Codeview syntax coloring ***********************************/
b,i
{
font-weight:normal; /* abusing b tag for syntax coloring */
font-style:normal; /* abusing i tag for syntax formatting */
}
b:first-child
{
margin-left:40px;
}
.tag
{
color:#b2e7f5;
}
.att
{
color:#e5c0ff;
}
.val
{
color:#99f1e0;
}
.val a
{
color:#99f1e0;
text-decoration:none;
border-bottom:1px dotted #99f1e0;
}
.comment
{
color:#d2eba7;
}
.obj
{
color:#e99449;
}
.func
{
color:#f8e981;
}
.prop
{
color:#f8e981;
}
.param
{
color:#e5c0ff;
}
.param_def
{
color:#99ffff;
}
.keyword
{
color:#99ffff;
}
.num
{
color:#ff8490;
}
.equal
{
color:#aaddff;
}
/* END: Codeview syntax coloring */
/* Scroll to top button ***************************************/
#scrollTopBtn
{
display:none;
margin:0;
padding:0;
width:50px;
height:50px;
position:fixed;
bottom:20px;
right:20px;
z-index:100;
}
#scrollTopBtn a
{
display:inline-block;
margin:0;
padding:0;
width:100%;
height:100%;
text-decoration:none;
background-color:#bbb; /* fallback */
background-color:rgba(100,100,100,.3);
border:none;
border-radius:50%; /* circle */
background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAALCAMAAABFyS02AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////////VXz1bAAAAAJ0Uk5T/wDltzBKAAAAOUlEQVR42lzN0Q4AMARD0dv//+klQ1fzojkE1AVOFhtPxghpI6WMETdF9Eh5+MZ89R/de1KajgADADNJAHVdmgJVAAAAAElFTkSuQmCC');
background-repeat:no-repeat;
background-position:center 40%;
}
#scrollTopBtn a:hover
{
background-color:#666; /* fallback */
background-color:rgba(50,50,50,.4);
}
/* END: Scroll to top button */
/* Small screen ***********************************************/
@media screen and (max-width:600px)
{
body
{
margin:0;
padding:0;
font-size:13px;
}
#page
{
margin:0;
padding:4px;
}
}
/* END: Small screen */
/* Print ******************************************************/
@media print
{
*
{
background-color:transparent !important;
border-color:#ddd !important;
border-width:1px !important;
border-radius:0 !important;
color:#000 !important;
}
body
{
margin:0;
padding:0;
font-size:12px;
line-height:22px;
}
#page,
#main_heading,
#sub_heading,
a
{
border:none !important;
}
.codeview
{
font-size:11px;
border-width:1px;
overflow:visible;
white-space:pre-wrap;
}
.codeview i::before
{
background-color:transparent !important;
color:#999 !important;
border-right:1px #ddd solid;
}
button,
#scrollTopBtn
{
display:none !important;
}
}
/* END: Print */
</style>
<!-- Including the necessary files here CSS and JS -->
<link type="text/css" rel="stylesheet" href="css/easydlg.css" />
<!-- Not using the minified version here since this page is also used for testing and debugging -->
<script src="js/easydlg.js"></script>
<!-- END: Including the necessary files here CSS and JS -->
<script>
//-----------------------------------------------------------------------------------------------------------------
// ** Add event listener (xbrowser-legacy)
//-----------------------------------------------------------------------------------------------------------------
var attachEventListener = function(target, eventType, functionRef, capture)
{
if(typeof target.addEventListener !== 'undefined')
{
target.addEventListener(eventType, functionRef, capture);
}
else if(typeof target.attachEvent !== 'undefined')
{
var functionString = eventType + functionRef;
target['e' + functionString] = functionRef;
target[functionString] = function(event)
{
if(typeof event === 'undefined')
{
event = window.event;
}
target['e' + functionString](event);
};
target.attachEvent('on' + eventType, target[functionString]);
}
else
{
eventType = 'on' + eventType;
if(typeof target[eventType] === 'function')
{
var oldListener = target[eventType];
target[eventType] = function()
{
oldListener();
return functionRef();
}
}
else
{
target[eventType] = functionRef;
}
}
};
//-----------------------------------------------------------------------------------------------------------------
// ** END: Add event listener (xbrowser-legacy)
//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
// ** Callback Examples
//-----------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------
// ** EasyDialogBox object return values
//---------------------------------------------------------------------
//
// object.nRetCode:
//
// 0 = "Close" button, outside box or [X] clicked
// 1 = "Yes" button clicked
// 2 = "No" button clicked
// 3 = "OK" button clicked
// 4 = "Cancel" button clicked
//
// object.strInput = string
//
//---------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// ** Example of a callback function
//---------------------------------------------------------------------------------------
var myCallbackFunc = function(nRetCode, strInput)
{
if(nRetCode === 0)
{
console.log('CALLBACK: User clicked "Close" button, outside box or [X], returncode = ' + nRetCode);
}
else if(nRetCode === 1)
{
console.log('CALLBACK: User clicked "Yes" button, returncode = ' + nRetCode);
// ** Example: Create a dialog on the fly!
var myFlyBox = EasyDialogBox.create(0, 'dlg dlg-success', 'Testing on the fly dialog', '<p>Hello on the fly!</p>', myOtherCallbackFunc);
if(myFlyBox)
{
// ** Override the initial callback function that was set
/*myFlyBox.callback = function()
{
console.log('Hello this is a callback override! :-)');
}*/
// ** Show the new box
myFlyBox.show();
}
}
else if(nRetCode === 2)
{
console.log('CALLBACK: User clicked "No" button, returncode = ' + nRetCode);
}
else if(nRetCode === 3)
{
console.log('CALLBACK: User clicked "OK" button, returncode = ' + nRetCode);
}
else if(nRetCode === 4)
{
console.log('CALLBACK: User clicked "Cancel" button, returncode = ' + nRetCode);
}
// ** Check if any text was typed in input
if(strInput)
{
console.log('CALLBACK: User typed in inputfield, returnvalue = ' + strInput);
}
};
//---------------------------------------------------------------------------------------
// ** Another regular function used as callback
//---------------------------------------------------------------------------------------
var myOtherCallbackFunc = function(nRetCode, strInput)
{
console.log('Hello from myOtherCallbackFunc: nRetCode = ' + nRetCode + ', strInput = ' + strInput);
};
//-----------------------------------------------------------------------------------------------------------------
// ** END: Callback Examples
//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
// ** Window load event-listener
//-----------------------------------------------------------------------------------------------------------------
attachEventListener(window, 'load', function()
{
//---------------------------------------------------------------------------------------
// ** Run simple example from page when button is clicked
//---------------------------------------------------------------------------------------
attachEventListener(document.getElementById('jsSimpleExampleRunBtn'), 'click', function()
{
// ** Create a new dialogbox object
var myBox = EasyDialogBox.create('someId1', 'dlg', 'My title', '<p>Hello there!</p>');
// ** Clean up after closing
myBox.onClose = myBox.destroy;
// ** Show the newly created box
myBox.show();
}, false);
//---------------------------------------------------------------------------------------
// ** END: Run simple example from page when button is clicked
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// ** Run example Yes/No from page when button is clicked
//---------------------------------------------------------------------------------------
attachEventListener(document.getElementById('jsExampleRunBtn'), 'click', function()
{
// ** Create a new dialogbox object
var myBox = EasyDialogBox.create('someId2', 'dlg-yes-no', 'My title', '<p>Hello there!</p><p>Click Yes or No button!</p>');
// ** Create a custom onShow function
myBox.onShow = function()
{
console.log('Example onShow function fired');
};
// ** Create a custom onClose function
myBox.onClose = function()
{
// ** Handle user button click
if(myBox.nRetCode === 1)
{
// ... user clicked "Yes" button
console.log('"Yes" button was clicked');
}
else if(myBox.nRetCode === 2)
{
// ... user clicked "No" button
console.log('"No" button was clicked');
}
// ** Delete dialogbox on close (clean up)
myBox.destroy();
console.log('Example onClose function fired');
};
// ** Show the newly created box
myBox.show();
}, false);
//---------------------------------------------------------------------------------------
// ** END: jsExampleRunBtn
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// ** Run example with multiple dialogboxes
//---------------------------------------------------------------------------------------
attachEventListener(document.getElementById('jsExampleMultiRunBtn'), 'click', function()
{
// ** Create two dialogboxes, give them some color and open them
var myBox1 = EasyDialogBox.create('box1', 'dlg dlg-multi dlg-rounded dlg-shadow', 'Box 1', '<p>This is box 1, drag and drop it around!</p><p>This box is NOT resizable!</p>', null, 100, 100);
myBox1.color('#bb0000').show();
var myBox2 = EasyDialogBox.create('box2', 'dlg dlg-multi dlg-rounded dlg-shadow dlg-resize', 'Box 2', '<p>This is box 2, drag and drop it around!</p><p>This box is also resizable!</p>', null, 180, 180);
myBox2.color('#009955').show();
var myBox3 = EasyDialogBox.create('box3', 'dlg dlg-multi dlg-rounded dlg-shadow dlg-resize', 'Box 3', '<p>This is box 3, drag and drop it around!</p><p>This box is also resizable!</p>', null, 260, 260);
myBox3.color('#005599').show();
}, false);
//---------------------------------------------------------------------------------------
// ** END: Run example with multiple dialogboxes
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// ** Run example toast
//---------------------------------------------------------------------------------------
attachEventListener(document.getElementById('jsExampleToastRunBtn'), 'click', function()
{
var strToast = '<p class="medium bold">TOASTY! --- This will close 3 seconds after it\'s displayed!</p>';
var myToast = EasyDialogBox.create(null, 'dlg-toast dlg-fade', null, strToast, null, null, 20, 500);
myToast.el.style.backgroundColor = '#ddeaff';
myToast.el.style.borderColor = '#0072b3';
myToast.onHide = myToast.destroy;
myToast.show().hide(3000);
}, false);
//---------------------------------------------------------------------------------------
// ** END: Run example toast
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// ** Scroll to top button
//---------------------------------------------------------------------------------------
var scrollTopBtn = document.getElementById('scrollTopBtn');
var scrollTopFunc = function()
{
var minVal = 100;
if(document.body.scrollTop > minVal
|| document.documentElement.scrollTop > minVal)
{
scrollTopBtn.style.display = 'block';
}
else
{
scrollTopBtn.style.display = 'none';
}
};
// ** Scroll event listener
attachEventListener(window, 'scroll', function()
{
scrollTopFunc();
}, false);
//---------------------------------------------------------------------------------------
// ** END: Scroll to top button
//---------------------------------------------------------------------------------------
// ** END: window load
}, false);
// ** END: window load
//-----------------------------------------------------------------------------------------------------------------
// ** END: Window load event-listener
//-----------------------------------------------------------------------------------------------------------------
</script>
</head>
<body>
<div id="page">
<div id="main_heading">
<h1>EasyDialogBox</h1>
</div>
<div id="sub_heading" class="bold">
<p>Easy to use Javascript dialog box, messagebox, alert, confirm, prompt, toast.</p>
<p>Plain vanilla Javascript, no libraries.</p>
<p>Customizable, responsive, draggable, resizable, lightweight.</p>
<p>Using standard Javascript (<a href="https://www.google.com/search?q=ecmascript+5" title="ECMAScript 5">ES5</a>), HTML and CSS.<br/>
Crossbrowser, legacy browser support as much as possible.</p>
<p><a class="blue" href="https://github.com/keejelo/EasyDialogBox" title="Go to github repository">https://github.com/keejelo/EasyDialogBox</a></p>
</div>
<p> </p>
<p> </p>
<div>
<h2>HOW TO ?</h2>
<p>Include the CSS and Javascript files between <code><head></code> and <code></head></code> as you would normally do in a HTML file:</p>
</div>
<div class="codeview"><i><b class="tag"><!DOCTYPE html></b></i>
<i><b class="tag"><html></b></i>
<i><b class="tag"><head></b></i>
<i><b class="tag"><meta</b> <b class="att">charset</b><b class="equal">=</b><b class="val">"utf-8"</b> <b class="tag">/></b></i>
<i> </i>
<i><b class="tag"><link</b> <b class="att">type</b><b class="equal">=</b><b class="val">"text/css"</b> <b class="att">rel</b><b class="equal">=</b><b class="val">"stylesheet"</b> <b class="att">href</b><b class="equal">=</b><b class="val">"<a href="css/easydlg.css" title="source">css/easydlg.css</a>"</b> <b class="tag">/></b></i>
<i> </i>
<i><b class="tag"><script</b> <b class="att">src</b><b class="equal">=</b><b class="val">"<a href="js/easydlg.min.js" title="source">js/easydlg.min.js</a>"</b> <b class="att">charset</b><b class="equal">=</b><b class="val">"utf-8"</b><b class="tag">></script></b></i>
<i> </i>
<i> </i>
</div>
<div>
<p>Then it can be used like the <a href="#js_example" class="blue bold larger" title="Go to examples">examples below</a>. Boxes can also be created with <a href="#html_box" class="blue bold" title="..read more and see examples">pre-written HTML.</a></p>
<p>All dialogboxes are <span class="ital help" title="Displayed in front with a semi transparent background overlay">modal</span> by default, but this can be changed among other things, by using <a class="blue bold" href="#paramTable" title="Go to optional flags and dialogtypes">optional flags</a>.<br />Displaying <a class="blue bold" href="#js_example_multi" title="Go to example">multiple boxes</a> at the same time is also possible, or how about a <a class="blue bold" href="#js_example_toast" title="Go to example">Toast!</a></p>
</div>
<div id="code_info_heading" class="section">
<h2>The base module (object)</h2>
<p><code class="large bold"> EasyDialogBox </code></p>
<p>As long as the script-file is included as above then the module will be initialized automatically when page loads, after that all the functions and methods are available.</p>
<p> </p>
<h2>Create dialog</h2>
<p>
Minimum syntax:<br />
<code>let myObj = EasyDialogBox.create(id, strBoxTypeClass, strTitle, strMessage);</code>
</p>
<p>
Full syntax:<br />
<code>let myObj = EasyDialogBox.create(id, strBoxTypeClass, strTitle, strMessage, fnCallback, x, y, w, h);</code>
</p>
<p>Return value = <span class="ital word">object</span>, or <span class="ital word">null</span> if could not be created.</p>
<p> </p>
<p class="bold">Parameters:</p>
<p><code>id</code> = custom id 'string' , if not used then you must set it to a <code>false</code>, <code>null</code> or <code>0</code> (zero)</p>
<p> </p>
<div>
<code>strBoxTypeClass</code> = can be any of the strings in the table below, by itself or combined with others separated by a space:
<table id="paramTable">
<tr><th>Dialogtype</th><th>Description</th></tr>
<tr><td>dlg</td><td>Default dialog with Close button.</td></tr>
<tr><td>dlg-close</td><td>Dialog with Close button, add Close button to dialog.</td></tr>
<tr><td>dlg-prompt</td><td>Dialog with an inputfield, OK + Cancel buttons.</td></tr>
<tr><td>dlg-yes</td><td>Dialog with Yes button, add Yes button to dialog.</td></tr>
<tr><td>dlg-no</td><td>Dialog with No button, add No button to dialog.</td></tr>
<tr><td>dlg-yes-no</td><td>Dialog with Yes + No buttons, add Yes + No buttons to dialog.</td></tr>
<tr><td>dlg-ok</td><td>Dialog with OK button, add OK button to dialog.</td></tr>
<tr><td>dlg-cancel</td><td>Dialog with Cancel button, add Cancel button to dialog.</td></tr>
<tr><td>dlg-ok-cancel</td><td>Dialog with OK + Cancel buttons, add OK + Cancel buttons to dialog.</td></tr>
<tr><td>dlg-toast</td>
<td>
Toast dialogbox, shorthand that combines the flags below:<br />
<code>dlg</code> <code>dlg-disable-heading</code> <code>dlg-disable-footer</code> <code>dlg-disable-drag</code> <code>dlg-disable-overlay</code>
</td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr><th>Optional flags <sup class="small"><a href="#opt_flags" title="Must be used in combination with a dialogtype, separated by a space">1</a></sup></th><th>Description</th></tr>
<tr><td>dlg-disable-heading</td><td>Dialog without heading.</td></tr>
<tr><td>dlg-disable-footer</td><td>Dialog without footer.</td></tr>
<tr><td>dlg-disable-btns</td><td>Dialog without any buttons in the footer.</td></tr>
<tr><td>dlg-disable-drag</td><td>Disable drag'n'drop, dialogbox cannot be moved by dragging its heading.</td></tr>
<tr><td>dlg-disable-esc</td><td>Disable Esc-key so it won't close the box.</td></tr>
<tr><td>dlg-disable-clickout</td><td>Disable the ability to click outside the box to close it.</td></tr>
<tr><td>dlg-disable-overlay</td><td>Disable translucent overlay/background color and makes the dialogbox <span class="ital">modeless</span>.</td></tr>
<tr><td colspan="2"> </td></tr>
<tr><td>dlg-nomodal</td><td>Same as <code>dlg-disable-overlay</code></td></tr>
<tr>
<td id="flag_multi">dlg-multi</td>
<td>
Makes it possible and easier to use multiple dialogboxes at the same time.<br />Shorthand that combines the flags below:<br />
<code>dlg-disable-overlay</code> <code>dlg-disable-esc</code> <code>dlg-disable-clickout</code><br />
<span class="small help" title="Internet Explorer 8/9/10 - to switch between dialogs you have to click on some text or visible element">Note: IE 8/9/10 - to switch between dialogs you have to click on some text or visible element.</span>
</td>
</tr>
<tr><td>dlg-resize</td><td>Makes the dialogbox resizable, adds a small resize-handle on the bottom-right side.</td></tr>
<tr><td colspan="2"> </td></tr>
<tr><td>dlg-info</td><td>Display information icon on the left inside box.</td></tr>
<tr><td>dlg-question</td><td>Display question icon on the left inside box.</td></tr>
<tr><td>dlg-error</td><td>Display error icon on the left inside box.</td></tr>
<tr><td>dlg-success</td><td>Display success icon on the left inside box.</td></tr>
<tr><td>dlg-exclamation</td><td>Display exclamation icon on the left inside box.</td></tr>
<tr><td colspan="2"> </td></tr>
<tr><td>dlg-rounded</td><td>Add rounded corners to box.</td></tr>
<tr><td>dlg-shadow</td><td>Add shadow behind box.</td></tr>
<tr><td>dlg-fade</td><td>Dialogbox fades in when shown, not when closed, only fades out if used with <a href="#dialog_hide">timed hiding</a></td></tr>
</table>
<p class="small" id="opt_flags">1. must be used in combination with a dialogtype, separated by a space.</p>
</div>
<p> </p>
<p><code>strTitle</code> = title text of the box, text only recommended, but can contain HTML.</p>
<p> </p>
<p><code>strMessage</code> = HTML content to custom and build as you wish, images, forms, anything you want, or just plain text.</p>
<p> </p>
<p class="bold">Optional parameters:</p>
<p><code>fnCallback</code> = callback function that executes when box closes (or you can just use <code>myObj.onClose()</code> function instead)</p>
<p>If using full syntax, but not using the <code>fnCallback</code> parameter, then you must set it to a <code>false</code>, <code>null</code> or <code>0</code> (zero)</p>
<p> </p>
<p><code>x</code> = initial horizontal position of the box. If not used then you can set it to <code>null</code> and it defaults to horizontal center in viewport.</p>
<p><code>y</code> = initial vertical position of the box. If not used then you can set it to <code>null</code> and it defaults to vertical center in viewport.</p>
<p><code>w</code> = initial width of the box. If not used then you can set it to <code>null</code> and it defaults to 600px as defined in the css-file.</p>
<p><code>h</code> = initial height of the box. If not used then you can set it to <code>null</code> and the height is adjusted by content.</p>
<p>
<span class="bold">Note:</span> Use of <code>x</code>, <code>y</code>, <code>w</code>, <code>h</code> can possibly break the dialogbox "<a href="https://www.google.com/search?q=responsive+web+design" title="https://www.google.com/search?q=responsive+web+design" target="_blank">responsiveness</a>".
</p>
<p> </p>
<p> </p>
<h2>Properties of a created object</h2>
<table id="objTable">
<tr><th>Name</th><th>Type</th><th>Description</th></tr>
<tr><td>id</td><td>string</td><td>dialogbox ID</td></tr>
<tr><td>strTypeClass</td><td>string</td><td>dialogbox type</td></tr>
<tr><td>strTitle</td><td>string</td><td>dialogbox heading title</td></tr>
<tr><td>strMessage</td><td>string</td><td>dialogbox contents (text and HTML)</td></tr>
<tr><td>callback()</td><td>method</td><td>custom function that fires when dialog is closed (works the same way as onClose/onHide)</td></tr>
<tr><td>x</td><td>number</td><td>dialogbox horizontal position</td></tr>
<tr><td>y</td><td>number</td><td>dialogbox vertical position</td></tr>
<tr><td>w</td><td>number</td><td>dialogbox width</td></tr>
<tr><td>h</td><td>number</td><td>dialogbox height</td></tr>
<tr><td><a href="#dialog_returnValues">strInput</a></td><td>string</td><td>returned string value from user input when using <code>dlg-prompt</code></td></tr>
<tr><td><a href="#dialog_returnValues">nRetCode</a></td><td>number</td><td>returns the value of the dialog-button the user clicked</td></tr>
<tr><td>bVisible</td><td>boolean</td><td>variable that indicates if dialog is visible or not</td></tr>
<tr><td>bExistInDOM</td><td>boolean</td><td>variable that indicates if dialog exist in DOM</td></tr>
<tr><td>bFade</td><td>boolean</td><td>variable that indicates if dialog should fade. Using <code>dlg-fade</code> sets this to <span class="ital word">true</span></td></tr>
<tr><td>nTimeId</td><td>number</td><td>variable that holds the timeout ID when using <a href="#dialog_hide">timed hiding</a></td></tr>
<tr><td><a href="#dialog_show">show()</a></td><td>method</td><td>shows dialog</td></tr>
<tr><td><a href="#dialog_hide">hide()</a></td><td>method</td><td>hides dialog</td></tr>
<tr><td><a href="#dialog_destroy">destroy()</a></td><td>method</td><td>destroys dialog</td></tr>
<tr><td><a href="#dialog_onCreate">onCreate()</a></td><td>method</td><td>fires when dialog is created</td></tr>
<tr><td><a href="#dialog_onShow">onShow()</a></td><td>method</td><td>fires when dialog is shown</td></tr>
<tr><td><a href="#dialog_onHide">onHide()</a></td><td>method</td><td>fires when dialog is hidden/closed</td></tr>
<tr><td><a href="#dialog_onClose">onClose()</a></td><td>method</td><td>fires when dialog is closed</td></tr>
<tr><td><a href="#dialog_onDestroy">onDestroy()</a></td><td>method</td><td>fires when dialog is destroyed</td></tr>
<tr><td><a href="#dialog_el">el</a></td><td>element</td><td>reference to dialogbox element itself</td></tr>
<tr><td><a href="#dialog_getEl">$()</a></td><td>method</td><td>get elements inside dialog</td></tr>
<tr><td><a href="#dialog_width">width()</a></td><td>method</td><td>set dialogbox width (px)</td></tr>
<tr><td><a href="#dialog_height">height()</a></td><td>method</td><td>set dialogbox height (px)</td></tr>
<tr><td><a href="#dialog_xpos">xPos()</a></td><td>method</td><td>change dialogbox X position (pixels from left)</td></tr>
<tr><td><a href="#dialog_ypos">yPos()</a></td><td>method</td><td>change dialogbox Y position (pixels from top)</td></tr>
<tr><td><a href="#dialog_center">center()</a></td><td>method</td><td>position dialogbox in center of window/viewport</td></tr>
<tr><td><a href="#dialog_color">colorBorder()</a></td><td>method</td><td>set dialog bordercolor</td></tr>
<tr><td><a href="#dialog_color">colorHeading()</a></td><td>method</td><td>set dialog heading backgroundcolor</td></tr>
<tr><td><a href="#dialog_color">color()</a></td><td>method</td><td>shorthand, set both heading and border same color</td></tr>
<tr><td><a href="#dialog_addbutton">addButton()</a></td><td>method</td><td>add custom button to dialog footer</td></tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<h2 id="dialog_show">Show dialog</h2>
<p><code>myObj.show();</code></p>
<p>Return value = the <span class="ital word">object</span> itself if the box could be shown, <span class="ital word">false</span> if not.</p>
<p> </p>
<p> </p>
<h2 id="dialog_hide">Hide dialog (close)</h2>
<p>Default use is without any parameters: <code>myObj.hide();</code>, use this if you just want to hide right away without any more fuzz.</p>
<p>Return value = the <span class="ital word">object</span> itself</p>
<p>(Pressing the keyboard escape-key <kbd title="Escape keyboard key">Esc</kbd> also fires this function)</p>
<p class="bold">Optional parameters:</p>
<p>Else you can use it with paramters like this: <code>myObj.hide(msec);</code> or this <code>myObj.hide(msec, skip);</code> if using both.</p>
<p><code>msec</code> is a value in milliseconds of type <span class="ital word">number</span>, to delay the hiding/closing of the dialogbox.<br />The timeout ID is stored in variable <code>myObj.nTimeId</code> so it can be used with <code>clearTimeout(nTimeId);</code> or some other custom codestuff.</p>
<p><code>skip</code> is a value of type <span class="ital word">boolean</span>, to skip execution of the objects <code>.onHide()</code> function. Only skips if value is <span class="ital word">true boolean</span>, using <code>true</code>, else it executes as normal which is also default.</p>
<p> </p>
<p> </p>
<h2 id="dialog_destroy">Destroy dialog</h2>
<p><code>myObj.destroy();</code></p>
<p>Return value = <span class="ital word">true</span> if object was deleted, <span class="ital word">false</span> if not.</p>
<p>
All dialogboxes will be kept in the DOM by default once created, they are only removed from the DOM when the user executes the "destroy" function.<br />
The user is responsible for deleting/destroying the dialogbox objects to prevent DOM-fill and "memory leaks".
</p>
<p>
<span class="bold">Tip:</span> By specifying an ID when creating a box, the existing box are reused when hiding and showing, instead of a new box being created each time the box is hidden and shown, filling up the DOM and leak memory if not destroyed.
</p>
<p>
It's good practice to destroy a dialogbox when it's not going to be used again and no longer needs to exist in DOM.
<p>
<p>
The simplest way to do this is in the functions <code>myObj.onClose()</code> or <code>myObj.onHide()</code>.
</p>
<p>
Like this <code>myObj.onClose = myObj.destroy;</code> if nothing else is going on in the "onClose" function.
</p>
<p>
If you need to do other stuff in that function also, then you can do something like below:
</p>
<div class="codeview"><i> </i>
<i><b>myObj</b><b class="func">.onClose</b> <b class="equal">=</b> <b class="keyword">function</b><b class="func">()</b></i>
<i><b class="func">{</b></i>
<i> <b class="comment">// .. other stuff ..</b></i>
<i> </i>
<i> <b>myObj</b><b class="func">.destroy</b><b class="func">()</b>;</i>
<i><b class="func">};</b></i>
<i> </i>
</div>
<p> </p>
<p> </p>
<p> </p>
<h2 id="dialog_el">Get the dialogbox HTML element itself</h2>