mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Implement change events for group view when multiselect is on.
This commit is contained in:
@@ -1004,6 +1004,8 @@ GuacUI.GroupView = function(root_group, multiselect) {
|
||||
var guacui_connection = new GuacUI.Connection(connection);
|
||||
GuacUI.addClass(guacui_connection.getElement(), "list-item");
|
||||
|
||||
(function(connection) {
|
||||
|
||||
// If multiselect, add checkbox for each connection
|
||||
if (multiselect) {
|
||||
|
||||
@@ -1014,16 +1016,31 @@ GuacUI.GroupView = function(root_group, multiselect) {
|
||||
connection_choice.appendChild(guacui_connection.getElement());
|
||||
appendChild(connection_choice);
|
||||
|
||||
function fire_connection_change(e) {
|
||||
|
||||
// Prevent click from affecting parent
|
||||
e.stopPropagation();
|
||||
|
||||
// Fire event if handler defined
|
||||
if (group_view.onconnectionchange)
|
||||
group_view.onconnectionchange(connection, this.checked);
|
||||
|
||||
}
|
||||
|
||||
// Fire change events when checkbox modified
|
||||
connection_checkbox.addEventListener("click", fire_connection_change, false);
|
||||
connection_checkbox.addEventListener("change", fire_connection_change, false);
|
||||
|
||||
}
|
||||
else
|
||||
appendChild(guacui_connection.getElement());
|
||||
|
||||
// Set onclick event
|
||||
(function(connection) {
|
||||
// Fire click events when connection clicked
|
||||
guacui_connection.onclick = function() {
|
||||
if (group_view.onconnectionclick)
|
||||
group_view.onconnectionclick(connection);
|
||||
};
|
||||
|
||||
})(connection);
|
||||
|
||||
} // end for each connection
|
||||
@@ -1041,6 +1058,8 @@ GuacUI.GroupView = function(root_group, multiselect) {
|
||||
// Add element to display
|
||||
GuacUI.addClass(list_group.getElement(), "list-item");
|
||||
|
||||
(function(child_group) {
|
||||
|
||||
// If multiselect, add checkbox for each group
|
||||
if (multiselect) {
|
||||
|
||||
@@ -1051,16 +1070,31 @@ GuacUI.GroupView = function(root_group, multiselect) {
|
||||
group_choice.appendChild(list_group.getElement());
|
||||
appendChild(group_choice);
|
||||
|
||||
function fire_group_change(e) {
|
||||
|
||||
// Prevent click from affecting parent
|
||||
e.stopPropagation();
|
||||
|
||||
// Fire event if handler defined
|
||||
if (group_view.ongroupchange)
|
||||
group_view.ongroupchange(child_group, this.checked);
|
||||
|
||||
}
|
||||
|
||||
// Fire change events when checkbox modified
|
||||
group_checkbox.addEventListener("click", fire_group_change, false);
|
||||
group_checkbox.addEventListener("change", fire_group_change, false);
|
||||
|
||||
}
|
||||
else
|
||||
appendChild(list_group.getElement());
|
||||
|
||||
// Set onclick event
|
||||
(function(child_group) {
|
||||
// Fire click events when group clicked
|
||||
list_group.onclick = function() {
|
||||
if (group_view.ongroupclick)
|
||||
group_view.ongroupclick(child_group);
|
||||
};
|
||||
|
||||
})(child_group);
|
||||
|
||||
} // end for each gorup
|
||||
|
Reference in New Issue
Block a user