1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-12 08:58:17 +03:00

Add custom_context when initialising buttons section

This commit is contained in:
Daniel Molina 2013-06-24 19:41:42 +02:00
parent ab0c98a746
commit 0c5beb5da1
2 changed files with 12 additions and 10 deletions

View File

@ -142,9 +142,9 @@ function deleteElement(dataTable,tag){
//Handle the activation of action buttons and the check_all box
//when elements in a datatable are modified.
function recountCheckboxes(dataTable){
function recountCheckboxes(dataTable, custom_context){
var table = $('tbody',dataTable);
var context = table.parents('form');
var context = custom_context||table.parents('form');
var nodes = $('tr',table); //visible nodes
var total_length = nodes.length;
var checked_length = $('input.check_item:checked',nodes).length;
@ -176,9 +176,9 @@ function recountCheckboxes(dataTable){
}
//Init action buttons and checkboxes listeners
function tableCheckboxesListener(dataTable){
function tableCheckboxesListener(dataTable, custom_context){
//Initialization - disable all buttons
var context = dataTable.parents('form');
var context = custom_context||dataTable.parents('form');
$('.last_action_button',context).attr('disabled', true);
$('.top_button, .list_button',context).attr('disabled', true);
@ -200,7 +200,7 @@ function tableCheckboxesListener(dataTable){
$(this).parents('tr').children().removeClass('markrowselected');
}
recountCheckboxes(datatable);
recountCheckboxes(datatable, context);
});
}
@ -393,7 +393,7 @@ function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_to
//Add a listener to the check-all box of a datatable, enabling it to
//check and uncheck all the checkboxes of its elements.
function initCheckAllBoxes(datatable){
function initCheckAllBoxes(datatable, custom_context){
//small css hack
$('input.check_all').css({"border":"2px"});
@ -407,7 +407,9 @@ function initCheckAllBoxes(datatable){
$('tbody input.check_item',table).removeAttr('checked');
$('td',table).removeClass('markrowchecked');
};
recountCheckboxes(table);
var context = custom_context||table.parents('form');
recountCheckboxes(table, context);
});
}

View File

@ -590,15 +590,15 @@ function insertButtons(){
//If we have defined a block of action buttons in a tab,
//this function takes care of inserting them in the DOM.
function insertButtonsInTab(tab_name, panel_name, panel_buttons){
function insertButtonsInTab(tab_name, panel_name, panel_buttons, custom_context){
var buttons = panel_buttons ? panel_buttons : SunstoneCfg["tabs"][tab_name]["buttons"];
var button_code="";
var sel_obj=null;
var condition=null;
var context;
if (panel_name) {
context = $('li#'+panel_name+'Tab', $("#dialog"));
if (custom_context) {
context = custom_context;
} else {
context = $('div#'+tab_name, main_tabs_context);
}