Revision: 2540
https://sourceforge.net/p/mrbs/code/2540/
Author: cimorrison
Date: 2012-10-30 09:04:46 +0000 (Tue, 30 Oct 2012)
Log Message:
-----------
Added a server side check for Opera so that autocomplete can be turned on for
datalists, in case JavaScript is disabled. (Left the client side check in
just in case the server isn't passing through the user agent string).
Modified Paths:
--------------
mrbs/trunk/web/functions.inc
mrbs/trunk/web/grab_globals.inc.php
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2012-10-29 15:44:45 UTC (rev 2539)
+++ mrbs/trunk/web/functions.inc 2012-10-30 09:04:46 UTC (rev 2540)
@@ -1078,6 +1078,8 @@
//
function generate_datalist($params)
{
+ global $HTTP_USER_AGENT;
+
// some sanity checking on params
foreach (array('label', 'name', 'id', 'options', 'force_assoc',
'force_indexed', 'value',
'disabled', 'create_hidden', 'mandatory', 'attributes') as
$key)
@@ -1131,7 +1133,14 @@
$html .= ($params['disabled']) ? " disabled=\"disabled\"" : "";
$html .= ($params['mandatory']) ? " required aria-required=\"true\"" : "";
$html .= (isset($params['attributes'])) ? " " . $params['attributes'] : "";
- $html .= " autocomplete=\"off\">\n";
+ // We normally have the autocomplete atribute set to off because in most
browsers
+ // this stops the browser suggesting previous input and confines the list to
our
+ // options. However in Opera turning off autocomplete turns off our
options as
+ // well, so we have to turn it on. (We'll also turn it on for Opera in the
JavaScript,
+ // for good measure, just in case the server isn't passing through the user
agent).
+ $html .= " autocomplete=\"";
+ $html .= (strpos(strtolower($HTTP_USER_AGENT), 'opera') === FALSE) ? 'off' :
'on';
+ $html .= "\">\n";
$html .= "<datalist id=\"" . $params['id'] . "_options\">";
// Put a <select> wrapper around the options so that browsers that don't
Modified: mrbs/trunk/web/grab_globals.inc.php
===================================================================
--- mrbs/trunk/web/grab_globals.inc.php 2012-10-29 15:44:45 UTC (rev 2539)
+++ mrbs/trunk/web/grab_globals.inc.php 2012-10-30 09:04:46 UTC (rev 2540)
@@ -199,6 +199,16 @@
$HTTP_REFERER = $HTTP_SERVER_VARS['HTTP_REFERER'];
}
+// -- HTTP_USER_AGENT --
+if (!empty($_SERVER) && isset($_SERVER['HTTP_USER_AGENT']))
+{
+ $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
+}
+else if (!empty($HTTP_SERVER_VARS) &&
isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']))
+{
+ $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
+}
+
// -- HTTP_HOST --
if (!empty($_SERVER) && isset($_SERVER['HTTP_HOST']))
{
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits