jQuery-fy the auto-checking of the other checkbox
This commit is contained in:
@@ -1256,29 +1256,6 @@ function setCheckboxes( container_id, state ) {
|
||||
return true;
|
||||
} // end of the 'setCheckboxes()' function
|
||||
|
||||
|
||||
// copy the checked from left to right or from right to left
|
||||
// so it's easier for users to see, if $cfg['ModifyAtRight']=true, what they've checked ;)
|
||||
function copyCheckboxesRange(the_form, the_name, the_clicked)
|
||||
{
|
||||
if (typeof(document.forms[the_form].elements[the_name]) != 'undefined' && typeof(document.forms[the_form].elements[the_name + 'r']) != 'undefined') {
|
||||
if (the_clicked !== 'r') {
|
||||
if (document.forms[the_form].elements[the_name].checked == true) {
|
||||
document.forms[the_form].elements[the_name + 'r'].checked = true;
|
||||
}else {
|
||||
document.forms[the_form].elements[the_name + 'r'].checked = false;
|
||||
}
|
||||
} else if (the_clicked == 'r') {
|
||||
if (document.forms[the_form].elements[the_name + 'r'].checked == true) {
|
||||
document.forms[the_form].elements[the_name].checked = true;
|
||||
}else {
|
||||
document.forms[the_form].elements[the_name].checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// - this was directly written to each td, so why not a function ;)
|
||||
// setCheckboxColumn(\'id_rows_to_delete' . $row_no . ''\');
|
||||
function setCheckboxColumn(theCheckbox){
|
||||
@@ -2678,3 +2655,29 @@ $(function() {
|
||||
$(window).resize(menuResize);
|
||||
menuResize();
|
||||
});
|
||||
|
||||
/**
|
||||
* When there is a checkbox on both ends of the row, propagate the click on
|
||||
* one of them to the other one
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
$('.verify_other_checkbox').live('click',function() {
|
||||
var current_checkbox_id = this.id;
|
||||
var left_checkbox_id = current_checkbox_id.replace('_right', '_left');
|
||||
var right_checkbox_id = current_checkbox_id.replace('_left', '_right');
|
||||
var other_checkbox_id = '';
|
||||
if (current_checkbox_id == left_checkbox_id) {
|
||||
other_checkbox_id = right_checkbox_id;
|
||||
} else {
|
||||
other_checkbox_id = left_checkbox_id;
|
||||
}
|
||||
|
||||
// the default action has not been prevented so if we have
|
||||
// just clicked this "if" is true
|
||||
if ($('#' + current_checkbox_id).is(':checked')) {
|
||||
$('#' + other_checkbox_id).attr('checked', true);
|
||||
} else {
|
||||
$('#' + other_checkbox_id).attr('checked', false);
|
||||
}
|
||||
});
|
||||
}) // end of $(document).ready() for verify other checkbox
|
||||
|
@@ -1515,7 +1515,7 @@ function PMA_displayVerticalTable()
|
||||
echo '<th></th>' . "\n";
|
||||
}
|
||||
|
||||
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_l', $val);
|
||||
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_left', $val);
|
||||
$foo_counter++;
|
||||
} // end while
|
||||
echo '</tr>' . "\n";
|
||||
@@ -1586,7 +1586,7 @@ function PMA_displayVerticalTable()
|
||||
echo '<th></th>' . "\n";
|
||||
}
|
||||
|
||||
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_r', $val);
|
||||
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_right', $val);
|
||||
$foo_counter++;
|
||||
} // end while
|
||||
echo '</tr>' . "\n";
|
||||
@@ -2463,7 +2463,8 @@ function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_cla
|
||||
$ret .= $column_style_vertical;
|
||||
$ret .= ' align="center">'
|
||||
. '<input type="checkbox" id="id_rows_to_delete' . $row_no . $id_suffix . '" name="rows_to_delete[' . $where_clause_html . ']"'
|
||||
. ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'' . $id_suffix . '\');"'
|
||||
. ' onclick="' . $column_marker_vertical . '"'
|
||||
. ' class="verify_other_checkbox"'
|
||||
. ' value="' . htmlspecialchars($del_query) . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />'
|
||||
. ' </td>';
|
||||
}
|
||||
@@ -2549,7 +2550,7 @@ function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no,
|
||||
$ret = '';
|
||||
|
||||
if ($position == 'left') {
|
||||
$ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_l', '', '', '');
|
||||
$ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_left', '', '', '');
|
||||
|
||||
$ret .= PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html, '');
|
||||
|
||||
@@ -2560,7 +2561,7 @@ function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no,
|
||||
|
||||
$ret .= PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html, '');
|
||||
|
||||
$ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_r', '', '', '');
|
||||
$ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_right', '', '', '');
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user