Revision: 2066
http://mrbs.svn.sourceforge.net/mrbs/?rev=2066&view=rev
Author: cimorrison
Date: 2011-10-07 10:43:10 +0000 (Fri, 07 Oct 2011)
Log Message:
-----------
Improved the performance of the day/week/month views, especially the day view
in IE with large tables (many rooms and many periods/time slots). xbLib.js is
now redundant and has been removed (jQuery is the new cross browser library)
and the config variables $highlight_method and $javascript_cursor are also now
redundant. See also SF ID 3419007.
Modified Paths:
--------------
mrbs/trunk/web/Themes/classic126/styling.inc
mrbs/trunk/web/Themes/default/header.inc
mrbs/trunk/web/Themes/default/styling.inc
mrbs/trunk/web/day.php
mrbs/trunk/web/functions.inc
mrbs/trunk/web/internalconfig.inc.php
mrbs/trunk/web/month.php
mrbs/trunk/web/mrbs.css.php
mrbs/trunk/web/style.inc
mrbs/trunk/web/systemdefaults.inc.php
mrbs/trunk/web/week.php
Removed Paths:
-------------
mrbs/trunk/web/xbLib.js
Modified: mrbs/trunk/web/Themes/classic126/styling.inc
===================================================================
--- mrbs/trunk/web/Themes/classic126/styling.inc 2011-10-04 10:18:01 UTC
(rev 2065)
+++ mrbs/trunk/web/Themes/classic126/styling.inc 2011-10-07 10:43:10 UTC
(rev 2066)
@@ -65,8 +65,6 @@
$row_even_color = "#ffffff"; // even rows in the day
and week views
$row_odd_color = "#eeeeee"; // even rows in the day
and week views
$row_highlight_color = "#ffc0da"; // used for highlighting a
row
- // NOTE: this colour is
also used in xbLib.js (in more than one place)and
- // if you change it here
you will also need to change it there.
$help_highlight_color = "#ffe6f0"; // highlighting text on
the help page
Modified: mrbs/trunk/web/Themes/default/header.inc
===================================================================
--- mrbs/trunk/web/Themes/default/header.inc 2011-10-04 10:18:01 UTC (rev
2065)
+++ mrbs/trunk/web/Themes/default/header.inc 2011-10-07 10:43:10 UTC (rev
2066)
@@ -113,7 +113,7 @@
require_once "style.inc";
?>
<title><?php echo get_vocab("mrbs") ?></title>
-
+
<?php
// We are using the jQuery UI library, which has been custom built to
include the following components:
// - Core
@@ -584,8 +584,6 @@
}
}
-
-
<?php
if ($page == 'edit_area_room')
{
@@ -1237,7 +1235,29 @@
rightCol);
<?php
}
+
+
+ // DAY.PHP, WEEK.PHP, MONTH.PHP
+ // If we're running IE6 or below then we need to make bookable slots
clickable
+ // and respond to a mouse hovering over them (IE6 only supports the :hover
pseudo
+ // class on anchors). We do this by toggling the class of the cell in
question and also
+ // the row_labels cells when the cell is hovered over.
+ if (in_array($page, array('day', 'week', 'month')))
+ {
+ ?>
+ if (lteIE6)
+ {
+ $('table.dwm_main a.new_booking').parent().parent()
+ .hover(function() {
+
$(this).not('.multiple_booking').toggleClass('hover');
+
$(this).parent().find('td.row_labels').toggleClass('row_labels_hover');
+ });
+ }
+
+ <?php
+ }
+
// EDIT_AREA_ROOM.PHP
if ($page == 'edit_area_room')
{
Modified: mrbs/trunk/web/Themes/default/styling.inc
===================================================================
--- mrbs/trunk/web/Themes/default/styling.inc 2011-10-04 10:18:01 UTC (rev
2065)
+++ mrbs/trunk/web/Themes/default/styling.inc 2011-10-07 10:43:10 UTC (rev
2066)
@@ -65,8 +65,6 @@
$row_even_color = "#ffffff"; // even rows in the day
and week views
$row_odd_color = "#f2f4f6"; // even rows in the day
and week views
$row_highlight_color = "#ffc0da"; // used for highlighting a
row
- // NOTE: this colour is
also used in xbLib.js (in more than one place)and
- // if you change it here
you will also need to change it there.
$help_highlight_color = "#ffe6f0"; // highlighting text on
the help page
Modified: mrbs/trunk/web/day.php
===================================================================
--- mrbs/trunk/web/day.php 2011-10-04 10:18:01 UTC (rev 2065)
+++ mrbs/trunk/web/day.php 2011-10-07 10:43:10 UTC (rev 2066)
@@ -234,24 +234,6 @@
// and output them
print $before_after_links_html;
- // Include the active cell content management routines.
- // Must be included before the beginnning of the main table.
- if ($javascript_cursor) // If authorized in config.inc.php, include the
javascript cursor management.
- {
- echo "<script type=\"text/javascript\" src=\"xbLib.js\"></script>\n";
- echo "<script type=\"text/javascript\">\n";
- echo "//<![CDATA[\n";
- echo "InitActiveCell("
- . ($show_plus_link ? "true" : "false") . ", "
- . "true, "
- . ((FALSE != $row_labels_both_sides) ? "true" : "false") . ", "
- . "\"$highlight_method\", "
- . "\"" . get_vocab("click_to_reserve") . "\""
- . ");\n";
- echo "//]]>\n";
- echo "</script>\n";
- }
-
// START DISPLAYING THE MAIN TABLE
echo "<table class=\"dwm_main\" id=\"day_main\">\n";
( $dst_change != -1 ) ? $j = 1 : $j = 0;
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2011-10-04 10:18:01 UTC (rev 2065)
+++ mrbs/trunk/web/functions.inc 2011-10-07 10:43:10 UTC (rev 2066)
@@ -1572,7 +1572,7 @@
global $main_cell_height, $main_table_cell_border_width;
global $area, $year, $month, $timetohighlight;
- global $javascript_cursor, $enable_periods, $times_along_top;
+ global $enable_periods, $times_along_top, $show_plus_link;
global $approval_enabled, $confirmation_enabled;
// if the time slot has got multiple bookings, then draw a mini-table
@@ -1758,37 +1758,14 @@
if (!isset($id))
{
echo "<div class=\"celldiv slots1\">\n"; // a bookable slot is only
one unit high
-
- if ($javascript_cursor)
+ echo "<a class=\"new_booking\" href=\"edit_entry.php?" .
+ (($enable_periods) ? $query_strings['new_periods'] :
$query_strings['new_times']) .
+ "\">\n";
+ if ($show_plus_link)
{
- echo "<script type=\"text/javascript\">\n";
- echo "//<![CDATA[\n";
- echo "BeginActiveCell();\n";
- echo "//]]>\n";
- echo "</script>\n";
- }
-
- if( $enable_periods )
- {
- echo "<a class=\"new_booking\" href=\"edit_entry.php?" .
$query_strings['new_periods'] . "\">\n";
echo "<img src=\"images/new.gif\" alt=\"New\" width=\"10\"
height=\"10\">\n";
- echo "</a>\n";
}
- else
- {
- echo "<a class=\"new_booking\" href=\"edit_entry.php?" .
$query_strings['new_times'] . "\">\n";
- echo "<img src=\"images/new.gif\" alt=\"New\" width=\"10\"
height=\"10\">\n";
- echo "</a>\n";
- }
-
- if ($javascript_cursor)
- {
- echo "<script type=\"text/javascript\">\n";
- echo "//<![CDATA[\n";
- echo "EndActiveCell();\n";
- echo "//]]>\n";
- echo "</script>\n";
- }
+ echo "</a>\n";
echo "</div>\n";
}
else // if it is booked then show the booking
Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php 2011-10-04 10:18:01 UTC (rev
2065)
+++ mrbs/trunk/web/internalconfig.inc.php 2011-10-07 10:43:10 UTC (rev
2066)
@@ -39,7 +39,12 @@
$strftime_format['daymonth'] = "%d %b";
}
+// Variables no longer used in versions of MRBS > 1.4.7
+// $highlight_method
+// $javascript_cursor
+
+
/********************************************************
* Checking
********************************************************/
Modified: mrbs/trunk/web/month.php
===================================================================
--- mrbs/trunk/web/month.php 2011-10-04 10:18:01 UTC (rev 2065)
+++ mrbs/trunk/web/month.php 2011-10-07 10:43:10 UTC (rev 2066)
@@ -345,24 +345,6 @@
echo "</pre>\n";
}
-// Include the active cell content management routines.
-// Must be included before the beginnning of the main table.
-if ($javascript_cursor) // If authorized in config.inc.php, include the
javascript cursor management.
-{
- echo "<script type=\"text/javascript\" src=\"xbLib.js\"></script>\n";
- echo "<script type=\"text/javascript\">\n";
- echo "//<![CDATA[\n";
- echo "InitActiveCell("
- . ($show_plus_link ? "true" : "false") . ", "
- . "false, "
- . "false, "
- . "\"$highlight_method\", "
- . "\"" . get_vocab("click_to_reserve") . "\""
- . ");\n";
- echo "//]]>\n";
- echo "</script>\n";
-}
-
echo "<table class=\"dwm_main\" id=\"month_main\">\n";
// Weekday name header row:
@@ -434,34 +416,23 @@
echo "<a class=\"monthday\"
href=\"day.php?year=$year&month=$month&day=$cday&area=$area\">$cday</a>\n";
echo "</div>\n";
// then the link to make a new booking
- if ($javascript_cursor)
- {
- echo "<script type=\"text/javascript\">\n";
- echo "//<![CDATA[\n";
- echo "BeginActiveCell();\n";
- echo "//]]>\n";
- echo "</script>\n";
- }
+
+ $query_string =
"room=$room&area=$area&year=$year&month=$month&day=$cday";
if ($enable_periods)
{
- echo "<a class=\"new_booking\"
href=\"edit_entry.php?room=$room&area=$area&period=0&year=$year&month=$month&day=$cday\">\n";
- echo "<img src=\"images/new.gif\" alt=\"New\" width=\"10\"
height=\"10\">\n";
- echo "</a>\n";
+ $query_string .= "&period=0";
}
else
{
- echo "<a class=\"new_booking\"
href=\"edit_entry.php?room=$room&area=$area&hour=$morningstarts&minute=0&year=$year&month=$month&day=$cday\">\n";
- echo "<img src=\"images/new.gif\" alt=\"New\" width=\"10\"
height=\"10\">\n";
- echo "</a>\n";
+ $query_string .= "&hour=$morningstarts&minute=0";
}
- if ($javascript_cursor)
+
+ echo "<a class=\"new_booking\" href=\"edit_entry.php?$query_string\">\n";
+ if ($show_plus_link)
{
- echo "<script type=\"text/javascript\">\n";
- echo "//<![CDATA[\n";
- echo "EndActiveCell();\n";
- echo "//]]>\n";
- echo "</script>\n";
+ echo "<img src=\"images/new.gif\" alt=\"New\" width=\"10\"
height=\"10\">\n";
}
+ echo "</a>\n";
// then any bookings for the day
if (isset($d[$cday]["id"][0]))
Modified: mrbs/trunk/web/mrbs.css.php
===================================================================
--- mrbs/trunk/web/mrbs.css.php 2011-10-04 10:18:01 UTC (rev 2065)
+++ mrbs/trunk/web/mrbs.css.php 2011-10-07 10:43:10 UTC (rev 2066)
@@ -63,10 +63,6 @@
fieldset fieldset {position: relative; clear: left; width: 100%; padding: 0;
border: 0; margin: 0} /* inner fieldsets are invisible */
fieldset fieldset legend {font-size: 0} /* for IE: even if there is no
legend text, IE allocates space */
-.naked {margin: 0; padding: 0; border-width: 0} /* Invisible tables used for
internal needs */
-table.naked {width: 100%; height: 100%}
-table:hover.naked {cursor: pointer} /* set cursor to pointer; if you don't
it doesn't show up when show_plus_link is false */
-
table.admin_table {border-spacing: 0px; border-collapse: collapse;
border-color: <?php echo $admin_table_border_color ?>; border-style: solid;
border-top-width: 0; border-right-width: 1px; border-bottom-width: 1px;
border-left-width: 0}
.admin_table th, .admin_table td {vertical-align: middle; text-align: left;
@@ -238,13 +234,10 @@
// with the small gap at the end of odd rows is probably a small price worth
paying to ensure that the date and the
// new booking link remain visible when you scroll.]
?>
-div.cell_container {position: relative; float: left; width: 100%; /*
the containing div for a.new_booking and the naked table */
+div.cell_container {position: relative; float: left; width: 100%; /*
the containing div for a.new_booking */
<?php echo ($month_cell_scrolling ? 'height:' : 'min-height:') ?> 100px} /*
NOTE: if you change the value of (min-)height, make sure you */
/*
also change the value of height in mrbs-ielte6.css */
.month a.new_booking {position: absolute; top: 0; left: 0; z-index: 10} /*
needs to be above the base, but below the date (monthday) */
-
-.dwm_main#month_main table.naked {position: absolute; top: 0; left: 0; /*
used when javascript cursor set - similar to new_booking */
- width: 100%; height: 100%; z-index: 10}
div.cell_header {position: relative; width: 2.0em; z-index: 20; /*
needs to be above the new booking anchor */
min-height: 20%; height: 20%; max-height: 20%; overflow: hidden}
@@ -252,7 +245,7 @@
a.monthday {display: block; width: 100%; font-size: medium} /* the
date in the top left corner */
div.booking_list {position: relative; z-index: 20; /*
contains the list of bookings */
- max-height: 80%; font-size: x-small; /*
needs to be above new_booking and naked table */
+ max-height: 80%; font-size: x-small; /*
needs to be above new_booking */
overflow: <?php echo ($month_cell_scrolling ? 'auto' : 'visible') ?>}
.booking_list a {font-size: x-small}
@@ -290,23 +283,7 @@
<?php
// HIGHLIGHTING: Set styles for the highlighted cells under the cursor (the
time/period cell and the current cell)
-//
-// There are two methods of highlighting: (1) CSS Highlighting and (2)
JavaScript highlighting. Javascript highlighting
-// has itself three different modes of highlighting: 'class', 'hybrid' and
'bgcolor'. See xbLib.js for an explanation of
-// the three modes. JavaScript highlighting was originally the only method
of highlighting cells, but now that support is
-// common for the :hover pseudo-class used with elements other than <a>, CSS
highlighting is used by default and JavaScript
-// highlighting is only used for old browsers, eg IE6 and before, where the
:hover pseudo-class is not supported.
-// Note that CSS highlighting is essential for IE7 and IE8 where the
performance of JavaScript highlighting is very poor. This
-// is why CSS highlighting was introduced, though it is also simpler and
produces smaller pages.
-//
-// (1) CSS HIGHLIGHTING
-//
-// The next four rules are used to implement CSS highlighting. CSS
highlighting is used because the performance
-// of JavaScript highlighting - both in 'class' and 'hybrid' modes - is very
poor in IE7 and IE8Beta2 (the latest version of
-// IE at the time of writing) when there are a large number of table rows, ie
when $resolution is small compared to the length
-// of the booking day. As the performance of CSS highlighting is as good as
JavaScript highlighting in recent versions of
-// non-IE browsers, it is used as the default method of highlighting since it
is simpler than the JavaScript method.
-//
+
// The first two rules (both on the same line) highlight the cell that you are
actually hovering over.
//
// The next two disable this behaviour for multiple booking cells. That's
because we don't want the highlight colour showing
@@ -324,35 +301,26 @@
// are <th> and not <td>) nor the empty cells in the month view (because
odd_row and even_row are not used
// in the month view). However the fifth rule does have the useful effect of
highlighting the time slot that
// corresponds to the start of a booking when you hover over a booked cell.
The sixth rule provides highlighting in the month view.
+//
+// The row_labels_hover class is applied by JavaScript when running IE6
because IE6 does
+// not support the :hover pseudo class on anything other than an anchor.
?>
-.dwm_main td:hover.odd_row, .dwm_main td:hover.even_row {background-color:
<?php echo $row_highlight_color ?>}
+.dwm_main td:hover.odd_row, .dwm_main td:hover.even_row, .dwm_main td.hover
{background-color: <?php echo $row_highlight_color ?>}
.dwm_main td:hover.multiple_booking.odd_row {background-color: <?php echo
$row_odd_color ?>}
.dwm_main td:hover.multiple_booking.even_row {background-color: <?php echo
$row_even_color ?>}
-.dwm_main tr:hover td.row_labels {background-color: <?php echo
$row_highlight_color ?>; color: <?php echo $standard_font_color ?>}
+.dwm_main tr:hover td.row_labels, .dwm_main td.row_labels_hover
{background-color: <?php echo $row_highlight_color ?>; color: <?php echo
$standard_font_color ?>}
.dwm_main#month_main td:hover.valid {background-color: <?php echo
$row_highlight_color ?>}
-
-
<?php
-// (2) JAVASCRIPT HIGHLIGHTING
-//
-// See xbLib.js for an explanation.
-?>
-
-td.highlight {background-color: <?php echo $row_highlight_color ?>;
color: <?php echo $standard_font_color ?>}
-<?php
// would be nicer to use color: inherit in the four rules below, but inherit
is not supported by IE until IE8.
// inherit would mean that (1) you didn't have to specify the colour again and
(2) you needn't use the tbody selector to
// stop the header links changing colour.
?>
-.highlight a:link {font-weight: normal; color: <?php echo
$standard_font_color ?>} /* used for JavaScript highlighting */
-.highlight a:visited {font-weight: normal; color: <?php echo
$standard_font_color ?>} /* used for JavaScript highlighting */
-.dwm_main tbody tr:hover a:link {color: <?php echo $anchor_link_color ?>}
/* used for CSS highlighting (but will also be used in JavaScript highlighting
*/
-.dwm_main tbody tr:hover a:visited {color: <?php echo $anchor_link_color ?>}
/* used for CSS highlighting (but will also be used in JavaScript highlighting
*/
-.month .highlight a:link {font-weight: bold}
-.month .highlight a:visited {font-weight: bold}
+.dwm_main tbody tr:hover a:link, td.row_labels_hover a:link {color:
<?php echo $anchor_link_color ?>}
+.dwm_main tbody tr:hover a:visited, td.row_labels_hover a:visited {color:
<?php echo $anchor_link_color ?>}
+
<?php
/* SLOTS CLASSES
Modified: mrbs/trunk/web/style.inc
===================================================================
--- mrbs/trunk/web/style.inc 2011-10-04 10:18:01 UTC (rev 2065)
+++ mrbs/trunk/web/style.inc 2011-10-07 10:43:10 UTC (rev 2066)
@@ -2,11 +2,6 @@
// $Id$
-// NOTE: The filename for the stylesheet for <= IE6 must contain the string
'ielte6'.
-// The href strings in the <link> tags below are used by InitActiveCell in
xbLib.js to
-// test whether the browser is IE6 or below - and therefore whether to use
JavaScript
-// highlighting instead of CSS highlighting. In particular the href string
for the
-// stylesheet for browsers IE6 or below must contain the string 'ielte6'.
?>
<link href="jquery/ui/css/sunny/jquery-ui-1.8.16.custom.css"
rel="stylesheet" type="text/css">
Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php 2011-10-04 10:18:01 UTC (rev
2065)
+++ mrbs/trunk/web/systemdefaults.inc.php 2011-10-07 10:43:10 UTC (rev
2066)
@@ -394,20 +394,8 @@
// Default report span in days:
$default_report_days = 60;
-// Control the active cursor in day/week/month views. By default,
highlighting
-// is implemented using the CSS :hover pseudo-class. For old browers such as
-// IE6, this is not supported and MRBS will automatically switch over to use
-// JavaScript highlighting - for which there are three different modes:
'bgcolor',
-// 'class' and 'hybrid'. If clients have VERY old browsers, then you may even
want
-// to disable the JavaScript highlighting by setting $javascript_cursor to
false.
-$javascript_cursor = TRUE; // Change to FALSE if clients have very old browsers
- // incompatible with JavaScript.
$show_plus_link = FALSE; // Change to TRUE to always show the (+) link as in
// MRBS 1.1.
-$highlight_method = "hybrid"; // One of "bgcolor", "class", "hybrid".
"hybrid" is recommended as it is
- // faster in old browsers such as IE6 - which is
the only time that
- // JavaScript highlighting is used anyway.
The rest of the time CSS
- // highlighting is used, whether or not
$javascript_cursor is set.
// PRIVATE BOOKINGS SETTINGS
Modified: mrbs/trunk/web/week.php
===================================================================
--- mrbs/trunk/web/week.php 2011-10-04 10:18:01 UTC (rev 2065)
+++ mrbs/trunk/web/week.php 2011-10-07 10:43:10 UTC (rev 2066)
@@ -206,26 +206,6 @@
}
}
-
-
-// Include the active cell content management routines.
-// Must be included before the beginnning of the main table.
-if ($javascript_cursor) // If authorized in config.inc.php, include the
javascript cursor management.
-{
- echo "<script type=\"text/javascript\" src=\"xbLib.js\"></script>\n";
- echo "<script type=\"text/javascript\">\n";
- echo "//<![CDATA[\n";
- echo "InitActiveCell("
- . ($show_plus_link ? "true" : "false") . ", "
- . "true, "
- . ((FALSE != $row_labels_both_sides) ? "true" : "false") . ", "
- . "\"$highlight_method\", "
- . "\"" . get_vocab("click_to_reserve") . "\""
- . ");\n";
- echo "//]]>\n";
- echo "</script>\n";
-}
-
// START DISPLAYING THE MAIN TABLE
echo "<table class=\"dwm_main\" id=\"week_main\">";
// if the first day of the week to be displayed contains as DST change then
Deleted: mrbs/trunk/web/xbLib.js
===================================================================
--- mrbs/trunk/web/xbLib.js 2011-10-04 10:18:01 UTC (rev 2065)
+++ mrbs/trunk/web/xbLib.js 2011-10-07 10:43:10 UTC (rev 2066)
@@ -1,798 +0,0 @@
-/*
- * Cross-Browser Library of JavaScript Functions
- *
- * Inspired by the excellent xbDOM.js (and using it for debugging)
- *
- * $Id$
- */
-
-var doAlert = false;
-var xbDump = function(string, tag) {return;} // If indeed not defined, define
as a dummy routine.
-
-// var xbDump = function(string, tag) {alert(string);} // If indeed not
defined, define as a dummy routine.
-
-if (doAlert)
-{
- alert("Started xbLib.js v4");
-}
-xbDump("Started xbLib.js v4");
-
-/*****************************************************************************\
-* Part 1: Generic Cross-Browser Library routines *
-\*****************************************************************************/
-
-// Browser-independent background color management
-function xblGetNodeBgColor(node)
-{
- if (!node)
- {
- return null;
- }
-
- // Have to use currentStyle or ComputedStyle here because node.style will
just give you
- // what's in the style attribute (ie <td style="xxx">), rather than what the
actual style
- // is computed from the cascade. As there is no style attribute this does
not work (ie
- // will return null). Although xblSetNodeBgColor() will cope with null
values, we will
- // try and avoid them in the first place.
-
- if (node.currentStyle) // The IE way
- {
- return node.currentStyle.backgroundColor;
- }
- if (window.getComputedStyle) // All other browsers
- {
- var compStyle = document.defaultView.getComputedStyle(node, "");
- return compStyle.getPropertyValue("background-color");
- }
- // Else this browser is not DOM compliant. Try getting a classic attribute.
- return node.bgColor;
-}
-
-function xblSetNodeBgColor(node, color)
-{
- if (!node)
- {
- return;
- }
- if (node.style)
- {
- if (node.style.setProperty) // If DOM level 2 supported, the NS 6 way
- {
- if (color)
- {
- node.style.setProperty("background-color", color, "");
- }
- else
- // Need to cater for the case when color is null. Although most
browsers will do what you might expect
- // when you use setProperty or setAttribute with null, there are some,
eg Konqueror, that don't.
- {
- node.style.removeProperty("background-color");
- }
- return;
- }
- if (node.style.setAttribute) // If DOM level 2 supported, the IE 6 way
- {
- if (color)
- {
- node.style.setAttribute("backgroundColor", color);
- }
- else // see comment above
- {
- node.style.removeAttribute("backgroundColor");
- }
- return;
- }
- // Else this browser has very limited DOM support. Try setting the
attribute directly.
- node.style.backgroundColor = color; // Works on Opera 6
- return;
- }
- // Else this browser is not DOM compliant. Try setting a classic attribute.
- node.bgColor = color;
-}
-
-// Browser-independant node tree traversal
-function xblChildNodes(node)
-{
- if (!node)
- {
- return null;
- }
- if (node.childNodes)
- {
- return node.childNodes; // DOM-compliant browsers
- }
- if (node.children)
- {
- return node.children; // Pre-DOM browsers like Opera 6
- }
- return null;
-}
-
-function xblFirstSibling(node)
-{
- if (!node)
- {
- return null;
- }
- var siblings = xblChildNodes(node.parentNode);
- if (!siblings)
- {
- return null;
- }
- return siblings[0];
-}
-
-function xblLastSibling(node)
-{
- if (!node)
- {
- return null;
- }
- var siblings = xblChildNodes(node.parentNode);
- if (!siblings)
- {
- return null;
- }
- return siblings[siblings.length - 1];
-}
-
-var xbGetElementById;
-if (document.getElementById) // DOM level 2
-{
- xblGetElementById = function(id) { return document.getElementById(id); };
-}
-else if (document.layers) // NS 4
-{
- xblGetElementById = function(id) { return document.layers[id]; };
-}
-else if (document.all) // IE 4
-{
- xblGetElementById = function(id) { return document.all[id]; };
-}
-else
-{
- xblGetElementById = function(id) { return null; };
-}
-
-// Browser-independant style sheet rules scan.
-function xbForEachCssRule(callback, ref)
-{
- if (document.styleSheets) for (var i=0; i<document.styleSheets.length; i++)
- {
- var sheet = document.styleSheets.item(i);
- // xbDump("Style sheet " + i, "h3");
- // xbDumpProps(sheet);
- // If the browser is kind enough for having already split the CSS rules as
specified by DOM... (NS6)
- if (sheet.cssRules) for (var j=0; j<sheet.cssRules.length; j++)
- {
- var rule = sheet.cssRules.item(j);
- // xbDump("Rule " + j, "h4");
- // xbDumpProps(rule);
- var result = callback(rule, ref);
- if (result)
- {
- return result;
- }
- }
- else if (sheet.cssText) // Else pass it the whole set at once (IE6)
- {
- // TO DO EVENTUALLY: Split the list into individual rules!
- var result = callback(sheet, ref);
- if (result)
- {
- return result;
- }
- }
- }
- return false;
-}
-
-/*---------------------------------------------------------------------------*\
-* *
-| Function: ForEachChild |
-| |
-| Description: Apply a method to each child node of an object. |
-| |
-| Parameters: Object obj The object. Typically a DOM node. |
-| Function callback Callback function. |
-| Object ref Reference object. |
-| |
-| Returns: The first non-null result reported by the callback. |
-| |
-| Support: NS4 No. Returns null. |
-| IE5+, NS6+ Yes. |
-| Opera 6 Yes. |
-| |
-| Notes: The callback prototype is: |
-| int callback(obj, ref); |
-| If the callback returns !null, the loop stops. |
-| |
-| History: |
-| |
-| 2002/03/04 JFL Initial implementation. |
-| 2002/03/25 JFL Simplified the implementation. |
-* *
-\*---------------------------------------------------------------------------*/
-
-function ForEachChild(obj, callback, ref)
-{
- if (!obj)
- {
- return null;
- }
-
- var children = null;
- if (obj.childNodes) // DOM-compliant browsers
- {
- children = obj.childNodes;
- }
- else if (obj.children) // Pre-DOM browsers like Opera 6
- {
- children = obj.children;
- }
- else
- {
- return null;
- }
-
- var nChildren = children.length;
- for (var i=0; i<nChildren; i++)
- {
- var result = callback(children[i], ref);
- if (result)
- {
- return result;
- }
- }
- return null;
-}
-
-/*---------------------------------------------------------------------------*\
-* *
-| Function: ForEachDescendant |
-| |
-| Description: Apply a method to each descendant node of an object. |
-| |
-| Parameters: Object obj The object. Typically a DOM node. |
-| Function callback Callback function. |
-| Object ref Reference object. |
-| |
-| Returns: The first non-null result reported by the callback. |
-| |
-| Support: NS4 No. Returns null. |
-| IE5+, NS6+ Yes. |
-| Opera 6 Yes. |
-| |
-| Notes: The callback prototype is: |
-| int callback(obj, ref); |
-| If the callback returns !null, the loop stops. |
-| |
-| History: |
-| |
-| 2002/10/29 JFL Initial implementation. |
-* *
-\*---------------------------------------------------------------------------*/
-
-function ForEachDescendantCB(obj, ref)
-{
- var result = ref.cb(obj, ref.rf);
- if (result)
- {
- return result;
- }
- return ForEachChild(obj, ForEachDescendantCB, ref);
-}
-
-function ForEachDescendant(obj, callback, ref)
-{
- if (!obj)
- {
- return null;
- }
- var ref1 = {cb:callback, rf:ref};
- var result = ForEachChild(obj, ForEachDescendantCB, ref1);
- delete ref1;
- return result;
-}
-
-/*****************************************************************************\
-* Part 2: MRBS-specific Active Cell Management routines *
-\*****************************************************************************/
-
-// Define global variables that control the behaviour of the Active Cells.
-// Set conservative defaults, to get the "classic" behaviour if JavaScript is
half broken.
-
-var useJS = false; // If true, use JavaScript for cell user interface. If
null, use a plain Anchor link.
-var highlight_left_column = false;
-var highlight_right_column = false;
-var highlightColor = "#ffc0da"; // Default highlight color, if we don't find
the one in the CSS.
-var statusBarMsg = "Click on the cell to make a reservation."; // Message to
write on the status bar when activating a cell.
-
-// Duplicate at JavaScript level the relevant PHP configuration variables.
-var show_plus_link = true;
-var highlight_method = "hybrid";
-
-var GetNodeColorClass = function(node)
-{
- return node.className;
-}
-var SetNodeColorClass = function(node, colorClass)
-{
- node.className = colorClass; // Use the td.highlight color from
mrbs.css.php.
-}
-
-// Helper routines for searching text in the td.highlight CSS class.
-function SearchTdHighlightText(ruleText, ref) // Callback called by the CSS
scan routine
-{
- xbDump("SearchTdHighlightText() called back");
- if (!ruleText)
- {
- return null;
- }
- ruleText = ruleText.toLowerCase(); // Make sure search is using a known case.
- var k = ruleText.indexOf("td.highlight");
- if (k == -1)
- {
- return null; // td.highlight not found in this rule.
- }
- k = ruleText.indexOf("background-color:", k) + 17;
- if (k == 16)
- {
- return null; // td.highlight background-color not defined.
- }
- while (ruleText.charAt(k) <= ' ')
- {
- k += 1; // Strip blanks before the color value.
- }
- var l = ruleText.length;
- var m = ruleText.indexOf(";", k); // Search the separator with the next
attribute.
- if (m == -1)
- {
- m = l;
- }
- var n = ruleText.indexOf("}", k); // Search the end of the rule.
- if (n == -1)
- {
- n = l;
- }
- if (m < n)
- {
- n = m; // n = index of the first of the above two.
- }
- while (ruleText.charAt(n-1) <= ' ')
- {
- n -= 1; // Strip blanks after the color value
- }
- var color = ruleText.substr(k, n-k);
- xbDump("SearchTdHighlightText() found color = " + color);
- return color;
-}
-
-function isAlphaNum(c)
-{
- return
("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".indexOf(c) >=
0);
-}
-
-// Callback called by the CSS scan routine
-function SearchTdHighlight(rule, ref)
-{
- if (!rule)
- {
- return null;
- }
- if (rule.selectorText) // DOM. NS6, Konqueror.
- {
- var selector = rule.selectorText.toLowerCase();
- var i = selector.indexOf("td.highlight");
- if (i == -1)
- {
- return null;
- }
- if (i > 0)
- {
- return null;
- }
- // var c = selector.charAt(i+12);
- // if ((!c) || isAlphaNum(c)) return null;
- if (!rule.style)
- {
- return null;
- }
-
- if (rule.style.getPropertyValue) // If DOM level 2 supported, the NS 6 way
- {
- return rule.style.getPropertyValue("background-color");
- }
- if (rule.style.getAttribute) // If DOM level 2 supported, the IE 6 way
- {
- return rule.style.getAttribute("backgroundColor");
- }
- return rule.style.backgroundColor; // Else DOM support is very limited.
- }
-
- if (rule.cssText) // Alternative for IE6
- {
- return SearchTdHighlightText(rule.cssText);
- }
- return null;
-}
-
-/*---------------------------------------------------------------------------*\
-* *
-| Function: InitActiveCell |
-| |
-| Description: Initialize the active cell management. |
-| |
-| Parameters: Boolean show Whether to show the (+) link. |
-| Boolean left Whether to highlight the left column. |
-| Boolean right Whether to highlight the right column.|
-| String method One of "bgcolor", "class", "hybrid". |
-| String message The message to put on the status bar. |
-| |
-| Returns: Nothing. |
-| |
-| Support: NS4 No. Returns null. |
-| IE5+, NS6+ Yes. |
-| Opera 6 Yes. |
-| |
-| Notes: For all browsers other than IE6 and below, highlighting |
-| is done using CSS, i.e. by using tr:hover and td:hover. |
-| But since IE6 and below do not support the hover pseudo- |
-| class on elements other than <a>, we have to use |
-| JavaScript for those browsers. (Theoretically we |
-| would also have to for early versions of other browsers, |
-| but we are making the assumption that if people are |
-| using non-IE browsers, then they will have upgraded at |
-| least to a version that properly supports the :hover |
-| pseudo-class). |
-| |
-| For IE6 and below, this code implements 3 methods for |
-| highlighting cells, all using JavaScript: |
-| |
-| highlight_method="bgcolor" |
-| Dynamically changes the cell background color. |
-| Advantage: Works with most javascript-capable browsers.
-| Drawback: The color is hardwired in this module.(grey)|
-| highlight_method="class" |
-| Highlights active cells by changing their color class.|
-| The highlight color is the background-color defined |
-| in class td.highlight in the CSS. |
-| Advantage: The class definition in the CSS can set |
-| anything, not just the color. |
-| Drawback: Slooow on Internet Explorer 6 on slow PCs. |
-| highlight_method="hybrid" |
-| Extracts the color from the CSS DOM if possible, and |
-| uses it it like in the bgcolor method. |
-| Advantage: Fast on all machines; color defined in CSS.|
-| Drawback: Not as powerful as the class method. |
-| |
-| (Note that if you try and force newer browsers to use |
-| JavaScript highlighting, by forcing use_css_highlighting |
-| to be false, then this won't work unless you remove the |
-| CSS rules. What can happen is that if the CSS :hover |
-| event gets triggered before the onMouseOver event, then |
-| the CSS will change the background colour, and when |
-| JavaScript eventually arrives and reads what it thinks is |
-| the "old" background colour it actually reads the |
-| highlight colour that has just been set by CSS. So the |
-| cell gets stuck at the highlight colour.) |
-| |
-| History: |
-| |
-| 2004/03/01 JFL Initial implementation. |
-* *
-\*---------------------------------------------------------------------------*/
-
-function InitActiveCell(show, left, right, method, message)
-{
- show_plus_link = show;
- highlight_method = method;
- highlight_left_column = left;
- highlight_right_column = right;
- statusBarMsg = message;
-
- xbDump("show_plus_link = " + show_plus_link);
- xbDump("highlight_method = " + highlight_method);
- xbDump("highlight_left_column = " + highlight_left_column);
- xbDump("highlight_right_column = " + highlight_right_column);
- xbDump("statusBarMsg = " + statusBarMsg);
-
- // Check to see whether we are using IE6 or below. This is done by
checking the
- // href string of the stylesheets that have been loaded (see style.inc for
the titles).
- //
- // If we are using IE6 or below then the :hover pseudo-class
- // is not supported for elements other than <a> and we will have to use
JavaScript highlighting
- // instead of CSS highlighting. If we can't even read the href string,
then it's a good bet that
- // the :hover pseudo-class isn't supported either.
- var use_css_highlighting = true;
- if (document.styleSheets)
- {
- var nStyleSheets = document.styleSheets.length;
- for (var i=0; i < nStyleSheets; i++)
- {
- // check to see if the stylesheet is an 'ielte6' sheet;
- // if it is, then we can't use CSS highlighting
- if (document.styleSheets[i].href != null) // will be null in the case
of an embedded style sheet
- {
- if (document.styleSheets[i].href.search(/ielte6/i) != -1)
- {
- use_css_highlighting = false;
- break;
- }
- }
- }
- }
- else
- {
- use_css_highlighting = false;
- }
-
- // If we are to use CSS highlighting then redefine the begin/end active cell
functions as empty
- // functions, because we don't need them.
- if (use_css_highlighting)
- {
- BeginActiveCell = function() {};
- EndActiveCell = function() {};
- return;
- }
-
- // Javascript feature detection: Check if a click handler can be called by
the browser for a table.
- // For example Netscape 4 only supports onClick for forms.
- // For that, create a hidden table, and check if it has an onClick handler.
- // document.write("<table id=\"test_table\" onClick=\"return true\" border=0
style=\"display:none\"><tr><td id=\"test_td\"
class=\"highlight\"> </td></tr></table>\n");
- // Note: The previous line, also technically correct, silently breaks
JavaScript on Netscape 4.
- // (The processing of this file completes successfully, but the next
script is not processed.)
- // The next line, with the bare minimum content for our purpose, works
on all browsers I've tested, included NS4.
- document.write("<table id=\"test_table\" onClick=\"return true\"
border=0></table>\n");
- var test_table = xblGetElementById("test_table"); // Use this test table to
detect the browser capabilities.
- if (test_table && test_table.onclick)
- {
- useJS = true; // If the browser supports click event handlers on tables,
then use JavaScript.
- }
-
- xbDump("JavaScript feature detection: Table onClick supported = " + useJS);
-
- //----------------------------------------------------//
-
- // Javascript feature detection: Check if the browser supports dynamically
setting style properties.
- var useCssClass = ((highlight_method=="class") && test_table &&
test_table.style
- && (test_table.style.setProperty ||
test_table.style.setAttribute) && true);
- if (useCssClass)
- {
- // DOM-compliant browsers
- GetNodeColorClass = function(node) { return node.className; }
- }
- else
- {
- // Pre-DOM browsers like Opera 6
- GetNodeColorClass = function(node) { return xblGetNodeBgColor(node); } //
Can't get class, so get color.
- }
-
- xbDump("JavaScript feature detection: Table class setting supported = " +
useCssClass);
-
- //----------------------------------------------------//
-
- // Now search in the CSS objects the background color of the td.highlight
class.
- // This is done as a performance optimization for IE6: Only change the td
background color, but not its class.
- highlightColor = null;
- if (highlight_method!="bgcolor")
- {
- highlightColor = xbForEachCssRule(SearchTdHighlight, 0);
- }
- if (!highlightColor)
- {
- highlightColor = "#ffc0da"; // Set default for DOM-challenged browsers
- xbDump("Using defaut highlight color = " + highlightColor);
- }
- else
- {
- xbDump("Found CSS highlight color = " + highlightColor);
- }
-
- //----------------------------------------------------//
-
- // Finally combine the last 2 results to generate the SetNodeColorClass
function.
- if (useCssClass)
- {
- // DOM-compliant browsers
- SetNodeColorClass = function(node, colorClass)
- {
- xbDump("SetNodeColorClass(" + colorClass + ")");
- node.className = colorClass; // Use the td.highlight color from
mrbs.css.php.
- }
- }
- else
- {
- // Pre-DOM browsers like Opera 6
- SetNodeColorClass = function(node, colorClass)
- {
- xbDump("SetNodeColorClass(" + colorClass + ")");
- if (colorClass == "highlight")
- {
- colorClass = highlightColor; // Cannot use the CSS color class. Use
the color computed above.
- }
- xblSetNodeBgColor(node, colorClass);
- }
- }
-}
-
-//----------------------------------------------------//
-
-// Cell activation
-function HighlightNode(node) // Change one td cell color class
-{
- node.oldColorClass = GetNodeColorClass(node);
- SetNodeColorClass(node, "highlight");
-}
-
-// Activate the td cell under the mouse, and optionally the corresponding
-// hour cells on both sides of the table.
-function ActivateCell(cell)
-{
- if (cell.isActive)
- {
- return; // Prevent problems with reentrancy. (It happens on slow systems)
- }
- cell.isActive = true;
- if (statusBarMsg)
- {
- window.status = statusBarMsg; // Write into the status bar.
- }
- // First find the enclosing table data cell.
- for (var tdCell=cell.parentNode; tdCell; tdCell=tdCell.parentNode)
- {
- if (tdCell.tagName == "TD")
- {
- break;
- }
- }
- if (!tdCell)
- {
- return;
- }
- HighlightNode(tdCell);
- if (highlight_left_column)
- {
- // Locate the head node for the current row.
- var leftMostCell = xblFirstSibling(tdCell);
- if (leftMostCell)
- {
- HighlightNode(leftMostCell);
- }
- }
- if (highlight_right_column)
- {
- // Locate the last node for the current row. (Only when configured to
display times at right too.)
- var rightMostCell = xblLastSibling(tdCell);
- // Now work around a Netscape peculiarity: The #text object is a sibling
and not a child of the TD!
- while (rightMostCell && (rightMostCell.tagName != "TD"))
- {
- rightMostCell = rightMostCell.previousSibling;
- }
- if (rightMostCell) HighlightNode(rightMostCell);
- }
-}
-
-// Cell unactivation
-function UnactivateCell(cell)
-{
- if (!cell.isActive)
- {
- return; // Prevent problems with reentrancy.
- }
- cell.isActive = null;
- window.status = ""; // Clear the status bar.
- // First find the enclosing table data cell.
- for (var tdCell=cell.parentNode; tdCell; tdCell=tdCell.parentNode)
- {
- if (tdCell.tagName == "TD")
- {
- break;
- }
- }
- if (!tdCell)
- {
- return;
- }
- SetNodeColorClass(tdCell, tdCell.oldColorClass);
- if (highlight_left_column)
- {
- // Locate the head node for the current row.
- var leftMostCell= xblFirstSibling(tdCell);
- if (leftMostCell)
- {
- SetNodeColorClass(leftMostCell, leftMostCell.oldColorClass);
- }
- }
- if (highlight_right_column)
- {
- // Locate the last node for the current row. (Only when configured to
display times at right too.)
- var rightMostCell = xblLastSibling(tdCell);
- // Now work around a NetScape peculiarity: The #text object is a sibling
and not a child of the TD!
- while (rightMostCell && (rightMostCell.tagName != "TD"))
- {
- rightMostCell = rightMostCell.previousSibling;
- }
- if (rightMostCell)
- {
- SetNodeColorClass(rightMostCell, rightMostCell.oldColorClass);
- }
- }
-}
-
-xbDump("Cell activation routines defined.");
-
-//----------------------------------------------------//
-
-// Cell click handling
-
-// Callback used to find the A link inside the cell clicked.
-function GotoLinkCB(node, ref)
-{
- var tag = null;
- if (node.tagName)
- {
- tag = node.tagName; // DOM-compliant tag name.
- }
- else if (node.nodeName)
- {
- tag = node.nodeName; // Implicit nodes, such as #text.
- }
- if (tag && (tag.toUpperCase() == "A"))
- {
- return node;
- }
- return null;
-}
-
-// Handler for going to the period reservation edition page.
-function GotoLink(node)
-{
- xbDump("GotoLink()");
- link = ForEachDescendant(node, GotoLinkCB, null);
- if (link)
- {
- window.location = link.href;
- }
-}
-
-xbDump("Cell click handlers defined.");
-
-//----------------------------------------------------//
-
-// Cell content generation
-
-function BeginActiveCell()
-{
- if (useJS)
- {
- document.write("<table class=\"naked\" cellSpacing=\"0\"
onMouseOver=\"ActivateCell(this)\" onMouseOut=\"UnactivateCell(this)\"
onClick=\"GotoLink(this)\">\n<td class=\"naked\" style=\"border: 0\">\n");
- // Note: The below is necessary to fill-up the cell. Empty cells
behave badly in some browsers.
- if (!show_plus_link)
- {
- document.write(" <div style=\"display:none\">\n"); // This will
hide the (+) link.
- }
- }
-}
-
-function EndActiveCell()
-{
- if (useJS)
- {
- if (!show_plus_link)
- {
- document.write("</div>");
- }
- document.write("</td></table>\n");
- }
-}
-
-xbDump("Cell content generation routines defined.");
-
-//----------------------------------------------------//
-
-if (doAlert)
-{
- alert("Ended xbLib.js");
-}
-xbDump("Ended xbLib.js.php");
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits