From: pdontthink Date: Thu, 9 Aug 2007 06:48:59 +0000 (+0000) Subject: Allow use of checkall=1 in URI for message list pages when JavaScript is enabled... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e0a6645e6b2e610bcd26c21b1fb0c79b2ceca788;p=squirrelmail.git Allow use of checkall=1 in URI for message list pages when JavaScript is enabled. Currently, this seems to be broken in IE for reasons I cannot understand. Please help debug. Sample URI would be something like example.org/webmail/src/right_main.php&checkall=1 git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12574 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/src/right_main.php b/src/right_main.php index 575b5f50..ce7d77f1 100644 --- a/src/right_main.php +++ b/src/right_main.php @@ -67,8 +67,8 @@ if ( sqgetGlobalVar('showall', $temp, SQ_GET) ) { $showall = (int) $temp; } -if ( sqgetGlobalVar('checkall', $temp, SQ_GET) ) { - $checkall = (int) $temp; +if (!sqgetGlobalVar('checkall',$checkall,SQ_GET)) { + $checkall = false; } /* future work */ @@ -336,6 +336,7 @@ if ($aMailbox['EXISTS'] > 0) { $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors: false); $oTemplate->assign('color', $color); $oTemplate->assign('align', $align); + $oTemplate->assign('checkall', $checkall); $oTemplate->display('message_list.tpl'); diff --git a/src/search.php b/src/search.php index 114f8d9c..061b3e85 100644 --- a/src/search.php +++ b/src/search.php @@ -893,8 +893,8 @@ function sqimap_asearch_get_selectable_unformatted_mailboxes(&$boxes) /* get globals we will need */ sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); -if ( sqgetGlobalVar('checkall', $temp, SQ_GET) ) { - $checkall = (int) $temp; +if (!sqgetGlobalVar('checkall',$checkall,SQ_GET)) { + $checkall = false; } /** @@ -1616,6 +1616,7 @@ if ($submit == $search_button_text) { $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors: false); $oTemplate->assign('color', $color); $oTemplate->assign('align', $align); + $oTemplate->assign('checkall', $checkall); $oTemplate->display('message_list.tpl'); } diff --git a/templates/default/css/default.css b/templates/default/css/default.css index ad5871b9..c01045b2 100644 --- a/templates/default/css/default.css +++ b/templates/default/css/default.css @@ -180,6 +180,13 @@ tr.odd { background: #ffffff /* __COLOR4__*/; } +tr.clicked_even { + background: #ff9933 /* __COLOR16__*/; +} +tr.clicked_odd { + background: #ff9933 /* __COLOR16__*/; +} + .table_standard { border:1px solid #dcdcdc /* __COLOR0__ */; width: 100%; diff --git a/templates/default/js/default.js b/templates/default/js/default.js index 44c0c0eb..ec3d24b1 100644 --- a/templates/default/js/default.js +++ b/templates/default/js/default.js @@ -20,6 +20,8 @@ function row_click(chkboxName) { // initialize orig_row_color if not defined already if (!orig_row_colors[chkboxName]) { orig_row_colors[chkboxName] = chkbox.parentNode.getAttribute('bgcolor'); + if (orig_row_colors[chkboxName].indexOf("clicked_") == 0) + orig_row_colors[chkboxName] = orig_row_colors[chkboxName].substring(8, orig_row_colors[chkboxName].length); } chkbox.checked = (chkbox.checked ? false : true); } @@ -66,19 +68,21 @@ function rowOver(chkboxName) { chkbox = document.getElementById(chkboxName); if (chkbox) { if (!orig_row_colors[chkboxName]) { - rowClass = getCSSClass(chkbox.parentNode.parentNode); + rowClass = getCSSClass(chkbox.parentNode.parentNode); + if (rowClass.indexOf("clicked_") == 0) + rowClass = rowClass.substring(8, rowClass.length); orig_row_colors[chkboxName] = rowClass; } else { rowClass = orig_row_colors[chkboxName]; } - j = chkbox.name.length - 1 + rowNum = chkboxName.substring(chkboxName.length - 1, chkboxName.length); /* * The mouseover and clicked CSS classes are always the same name! */ overClass = 'mouse_over'; clickedClass = 'clicked'; - setPointer(chkbox.parentNode.parentNode, j,'over' , rowClass, overClass, clickedClass); + setPointer(chkbox.parentNode.parentNode, rowNum, 'over' , rowClass, overClass, clickedClass); } } @@ -97,15 +101,15 @@ function toggle_all(formname, fancy) { if (TargetForm.elements[i].type == 'checkbox' && TargetForm.elements[i].name.substring(0,3) == 'msg') { if (fancy) { array_key = TargetForm.elements[i].getAttribute('id'); - if (TargetForm.elements[i].checked == false) { - // initialize orig_row_color if not defined already - if (!orig_row_colors[array_key]) { - rowClass = getCSSClass(TargetForm.elements[i].parentNode.parentNode); - orig_row_colors[array_key] = rowClass; - } + // initialize orig_row_color if not defined already + if (!orig_row_colors[array_key]) { + rowClass = getCSSClass(TargetForm.elements[i].parentNode.parentNode); + if (rowClass.indexOf("clicked_") == 0) + rowClass = rowClass.substring(8, rowClass.length); + orig_row_colors[array_key] = rowClass; } origClass = orig_row_colors[array_key]; - clickedClass = 'clicked'; + clickedClass = 'clicked'; setPointer(TargetForm.elements[i].parentNode.parentNode, j,'click' , origClass, origClass, clickedClass); j++ } @@ -117,20 +121,20 @@ function toggle_all(formname, fancy) { /* * Sets/unsets the pointer and marker in browse mode * - * @param object the table row - * @param integer the row number - * @param string the action calling this script (over, out or click) - * @param string the default background CSS class - * @param string the CSS class to use for mouseover - * @param string the CSS class to use for marking a row + * @param object theRow the table row + * @param integer theRowNum the row number + * @param string theAction the action calling this script (over, out or click) + * @param string defaultClass the default background CSS class + * @param string mouseoverClass the CSS class to use for mouseover + * @param string clickedClass the CSS class to use for marking a row * * @return boolean whether pointer is set or not */ -function setPointer(theRow, theRowNum, theAction, theDefaultClass, thePointerClass, theMarkClass) +function setPointer(theRow, theRowNum, theAction, defaultClass, mouseoverClass, clickedClass) { // 1. Pointer and mark feature are disabled or the browser can't get the // row -> exits - if ((thePointerClass == '' && theMarkClass == '') + if ((mouseoverClass == '' && clickedClass == '') || typeof(theRow.className) == 'undefined') { return false; } @@ -149,16 +153,18 @@ function setPointer(theRow, theRowNum, theAction, theDefaultClass, thePointerCla // 3. Gets the current CSS class... var newClass = null; var currentClass = getCSSClass(theRow); + if (currentClass.indexOf("clicked_") == 0) + currentClass = 'clicked'; // 4. Defines the new class // 4.1 Current class is the default one if (currentClass == '' - || currentClass.toLowerCase() == theDefaultClass.toLowerCase()) { - if (theAction == 'over' && thePointerClass != '') { - newClass = thePointerClass; + || currentClass.toLowerCase() == defaultClass.toLowerCase()) { + if (theAction == 'over' && mouseoverClass != '') { + newClass = mouseoverClass; } - else if (theAction == 'click' && theMarkClass != '') { - newClass = theMarkClass; + else if (theAction == 'click' && clickedClass != '') { + newClass = clickedClass; marked_row[theRowNum] = true; // deactivated onclick marking of the checkbox because it's also executed // when an action (clicking on the checkbox itself) on a single item is @@ -168,27 +174,25 @@ function setPointer(theRow, theRowNum, theAction, theDefaultClass, thePointerCla //document.getElementById('msg[' + theRowNum + ']').checked = true; } } - // 4.1.2 Current class is the pointer one - else if (currentClass.toLowerCase() == thePointerClass.toLowerCase() + // 4.1.2 Current class is the mouseover one + else if (currentClass.toLowerCase() == mouseoverClass.toLowerCase() && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) { if (theAction == 'out') { - newClass = theDefaultClass; + newClass = defaultClass; } - else if (theAction == 'click' && theMarkClass != '') { - newClass = theMarkClass; + else if (theAction == 'click' && clickedClass != '') { + newClass = clickedClass; marked_row[theRowNum] = true; //document.getElementById('msg[' + theRowNum + ']').checked = true; } } - // 4.1.3 Current color is the marker one - else if (currentClass.toLowerCase() == theMarkClass.toLowerCase()) { + // 4.1.3 Current color is the clicked one + else if (currentClass.toLowerCase() == clickedClass.toLowerCase()) { if (theAction == 'click') { - newClass = (thePointerClass != '') - ? thePointerClass - : theDefaultClass; - marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) - ? true - : null; + newClass = (mouseoverClass != '') + ? mouseoverClass + : defaultClass; + marked_row[theRowNum] = false; //document.getElementById('msg[' + theRowNum + ']').checked = false; } } // end 4 diff --git a/templates/default/message_list.tpl b/templates/default/message_list.tpl index 6b2b3972..9e8052ca 100644 --- a/templates/default/message_list.tpl +++ b/templates/default/message_list.tpl @@ -62,6 +62,7 @@ * $show_label_columns * $compact_paginator * $aErrors + * $checkall * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License @@ -105,13 +106,6 @@ if ($pageOffset < $end_msg) { */ -// set this to an empty string to turn off extra -// highlighting of checked rows -// -//$clickedColor = ''; -$clickedColor = (empty($color[16])) ? $color[2] : $color[16]; - - ?>
@@ -196,14 +190,12 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16]; switch ($iCol) { case SQM_COL_CHECK: if ($javascript_on) { - echo ''."\n"; + $checked = ($checkall ? ' checked="checked" ' : ''); + echo ''."\n"; } else { - $link = $baseurl . "&startMessage=$pageOffset&checkall="; - if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) { - $link .= ($checkall) ? '0' : '1'; - } else { - $link .= '1'; - } + $link = $baseurl + . "&startMessage=$pageOffset&checkall=" + . ($checkall ? '0' : '1'); echo ""._("All").''; } break; @@ -267,7 +259,6 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16]; if ($javascript_on && $fancy_index_highlite) { $mouseoverColor = $color[5]; $checkbox_javascript = ' onclick="this.checked = !this.checked;"'; - // $clickedColor is defined at top of this file } else { $checkbox_javascript = ''; } @@ -315,13 +306,16 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16]; $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue; } - $class = 'even'; + $class = ($checkall && $javascript_on && $fancy_index_highlite ? 'clicked_even' : 'even'); + $non_clicked_class = 'even'; + /** * If alternating row colors is set, adapt the CSS class */ if (isset($alt_index_colors) && $alt_index_colors) { if (!($i % 2)) { - $class = 'odd'; + $class = ($checkall && $javascript_on && $fancy_index_highlite ? 'clicked_odd' : 'odd'); + $non_clicked_class = 'odd'; } } @@ -337,7 +331,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16]; // this stuff does the auto row highlighting on mouseover // if ($javascript_on && $fancy_index_highlite) { - $row_extra = ' onmouseover="rowOver(\''.$form_id . '_msg' . $i.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $class . '\', \'mouse_over\', \'clicked\');"'; + $row_extra = ' onmouseover="rowOver(\''.$form_id . '_msg' . $i.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $non_clicked_class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $non_clicked_class . '\', \'mouse_over\', \'clicked\');"'; } // this does the auto-checking of the checkbox no matter // where on the row you click @@ -353,7 +347,8 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16]; * mouseover functionality. There is no harm in doing this when the mouseover * functionality is disabled */ -if ($class != 'even' && $class != 'odd') +if ($class != 'even' && $class != 'odd' + && $class != 'even_checked' && $class != 'odd_checked') { ?>