Updated aoi code, prevented unwanted browser selection, row is only selectable when a checkbox is found

This commit is contained in:
Andreas Stöckel 2011-03-22 19:55:57 +00:00
parent f6d0edbdc1
commit 20b769678f

View File

@ -1,5 +1,20 @@
/**
* eGroupWare eTemplate nextmatch row action object interface
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Andreas Stöckel (as AT stylite.de)
* @version $Id$
*/
// An action object interface for the listbox - "inherits" from /**
* Contains the action object interface implementation for the nextmatch widget
* row.
*/
// An action object interface for each nextmatch widget row - "inherits" from
// egwActionObjectInterface // egwActionObjectInterface
function nextmatchRowAOI(_node) function nextmatchRowAOI(_node)
{ {
@ -8,14 +23,25 @@ function nextmatchRowAOI(_node)
aoi.node = _node; aoi.node = _node;
aoi.checkBox = ($(":checkbox", aoi.node))[0]; aoi.checkBox = ($(":checkbox", aoi.node))[0];
aoi.checkBox.checked = false;
// Rows without a checkbox are unselectable
if (typeof aoi.checkBox != "undefined")
{
aoi.doGetDOMNode = function() { aoi.doGetDOMNode = function() {
return aoi.node; return aoi.node;
} }
// Prevent the browser from selecting the content of the element, when
// a special key is pressed.
$(_node).mousedown(egwPreventSelect);
// Now append some action code to the node // Now append some action code to the node
$(_node).click(function(e) { $(_node).click(function(e) {
// Reset the prevent selection code (in order to allow wanted
// selection of text)
_node.onselectstart = null;
if (e.target != aoi.checkBox) if (e.target != aoi.checkBox)
{ {
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED); var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
@ -33,12 +59,18 @@ function nextmatchRowAOI(_node)
aoi.doSetState = function(_state) { aoi.doSetState = function(_state) {
var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED); var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED);
if (this.checkBox)
{
this.checkBox.checked = selected; this.checkBox.checked = selected;
}
$(this.node).toggleClass('focused', $(this.node).toggleClass('focused',
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED)); egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
$(this.node).toggleClass('selected', $(this.node).toggleClass('selected',
selected); selected);
} }
}
return aoi; return aoi;
} }