-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom.js
151 lines (133 loc) · 4.21 KB
/
custom.js
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
/*************************************************************************
* Your custom JS file
*************************************************************************/
(function () {
"use strict";
// The widget object
var widgets;
function createShareButtonAndDialog() {
var $share_url_copy_prompt = $("#share-url-copy-prompt");
// Create the share dialog
var $share_dialog = widgets.createCustomDialog({
selector: "#share-dialog",
full_width_button: true,
action_text: "Copy to clipboard",
close_dialog_on_action: false,
show_cancel_btn: false,
action_callback: function () {
widgets.copyText("share-url");
$share_url_copy_prompt.show();
}
});
$share_dialog.on("dialogclose", function () {
$share_url_copy_prompt.hide();
});
// Set the event of the share url textbox
var $share_url = $("#share-url");
$share_url.focus(function () {
$(this).select();
}).click(function () {
$(this).select();
}).mouseup(function (e) {
e.preventDefault();
});
// Set the event of the share button
$("#share-btn").on("click", function () {
$share_dialog.dialog("open");
});
}
function init() {
// Create the widget object
widgets = new edaplotjs.Widgets();
// Set custom dropdown
widgets.setCustomDropdown($("#custom-dropdown"), {
items: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"],
//init_index: 0, // You can use this parameter to set the initial item for displaying
init_text: "Dropdown Menu (With JavaScript)",
on_item_click_callback: function ($ui) {
console.log($ui.text());
}
});
widgets.setCustomDropdown($("#custom-dropdown-large"), {
items: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"],
//init_index: 0, // You can use this parameter to set the initial item for displaying
init_text: "Large Dropdown Menu (With JavaScript)",
on_item_click_callback: function ($ui) {
console.log($ui.text());
}
});
// Set custom radio
$("input:radio[name='playback-speed']").on("change", function () {
console.log($(this).val());
});
// Set custom dialog type 1
var $dialog_1 = widgets.createCustomDialog({
selector: "#dialog-1",
full_width_button: true
});
$("#dialog-btn-1").on("click", function () {
$dialog_1.dialog("open");
});
// Set custom dialog type 2
var $dialog_2 = widgets.createCustomDialog({
selector: "#dialog-2",
action_callback: function () {
console.log("confirm");
},
cancel_callback: function () {
console.log("cancel");
}
});
$("#dialog-btn-2").on("click", function () {
$dialog_2.dialog("open");
});
// Set custom dialog type 3
var $dialog_3 = widgets.createCustomDialog({
selector: "#dialog-3",
parent: $(".content"),
show_cancel_btn: false,
cancel_callback: function () {
console.log("cancel");
},
});
$("#dialog-btn-3").on("click", function () {
$dialog_3.dialog("open");
});
// Set custom dialog type 4
var $dialog_4 = widgets.createCustomDialog({
selector: "#dialog-4",
action_text: "Action",
reverse_button_positions: true,
full_width_button: true,
action_callback: function () {
console.log("action");
},
cancel_text: "Back",
cancel_callback: function () {
console.log("back");
}
});
$("#dialog-btn-4").on("click", function () {
$dialog_4.dialog("open");
});
// Create the share button and dialog
createShareButtonAndDialog();
// Create the gallery
var $gallery = $(".gallery");
// In practice, these images urls may come from your server via http ajax requests.
for (var i = 0; i < 8; i++) {
var item = "<a href=\"javascript:void(0)\" class=\"flex-column\">" +
"<img src=\"img/dummay-img.png\">" +
"<div>Image Caption</div>" +
"</a>";
$gallery.append($(item));
}
// Create custom tabs
widgets.createCustomTab({
selector: "#custom-tab"
});
// Set the custom legend
widgets.setCustomLegend($("#custom-legend"));
}
$(init);
})();