mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 21:51:23 +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);
|
var guacui_connection = new GuacUI.Connection(connection);
|
||||||
GuacUI.addClass(guacui_connection.getElement(), "list-item");
|
GuacUI.addClass(guacui_connection.getElement(), "list-item");
|
||||||
|
|
||||||
|
(function(connection) {
|
||||||
|
|
||||||
// If multiselect, add checkbox for each connection
|
// If multiselect, add checkbox for each connection
|
||||||
if (multiselect) {
|
if (multiselect) {
|
||||||
|
|
||||||
@@ -1014,16 +1016,31 @@ GuacUI.GroupView = function(root_group, multiselect) {
|
|||||||
connection_choice.appendChild(guacui_connection.getElement());
|
connection_choice.appendChild(guacui_connection.getElement());
|
||||||
appendChild(connection_choice);
|
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
|
else
|
||||||
appendChild(guacui_connection.getElement());
|
appendChild(guacui_connection.getElement());
|
||||||
|
|
||||||
// Set onclick event
|
// Fire click events when connection clicked
|
||||||
(function(connection) {
|
|
||||||
guacui_connection.onclick = function() {
|
guacui_connection.onclick = function() {
|
||||||
if (group_view.onconnectionclick)
|
if (group_view.onconnectionclick)
|
||||||
group_view.onconnectionclick(connection);
|
group_view.onconnectionclick(connection);
|
||||||
};
|
};
|
||||||
|
|
||||||
})(connection);
|
})(connection);
|
||||||
|
|
||||||
} // end for each connection
|
} // end for each connection
|
||||||
@@ -1041,6 +1058,8 @@ GuacUI.GroupView = function(root_group, multiselect) {
|
|||||||
// Add element to display
|
// Add element to display
|
||||||
GuacUI.addClass(list_group.getElement(), "list-item");
|
GuacUI.addClass(list_group.getElement(), "list-item");
|
||||||
|
|
||||||
|
(function(child_group) {
|
||||||
|
|
||||||
// If multiselect, add checkbox for each group
|
// If multiselect, add checkbox for each group
|
||||||
if (multiselect) {
|
if (multiselect) {
|
||||||
|
|
||||||
@@ -1051,16 +1070,31 @@ GuacUI.GroupView = function(root_group, multiselect) {
|
|||||||
group_choice.appendChild(list_group.getElement());
|
group_choice.appendChild(list_group.getElement());
|
||||||
appendChild(group_choice);
|
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
|
else
|
||||||
appendChild(list_group.getElement());
|
appendChild(list_group.getElement());
|
||||||
|
|
||||||
// Set onclick event
|
// Fire click events when group clicked
|
||||||
(function(child_group) {
|
|
||||||
list_group.onclick = function() {
|
list_group.onclick = function() {
|
||||||
if (group_view.ongroupclick)
|
if (group_view.ongroupclick)
|
||||||
group_view.ongroupclick(child_group);
|
group_view.ongroupclick(child_group);
|
||||||
};
|
};
|
||||||
|
|
||||||
})(child_group);
|
})(child_group);
|
||||||
|
|
||||||
} // end for each gorup
|
} // end for each gorup
|
||||||
|
Reference in New Issue
Block a user