mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
Updated aoi code, prevented unwanted browser selection, row is only selectable when a checkbox is found
This commit is contained in:
parent
f6d0edbdc1
commit
20b769678f
@ -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
|
||||
function nextmatchRowAOI(_node)
|
||||
{
|
||||
@ -8,36 +23,53 @@ function nextmatchRowAOI(_node)
|
||||
aoi.node = _node;
|
||||
|
||||
aoi.checkBox = ($(":checkbox", aoi.node))[0];
|
||||
aoi.checkBox.checked = false;
|
||||
|
||||
aoi.doGetDOMNode = function() {
|
||||
return aoi.node;
|
||||
}
|
||||
|
||||
// Now append some action code to the node
|
||||
$(_node).click(function(e) {
|
||||
if (e.target != aoi.checkBox)
|
||||
{
|
||||
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
|
||||
var state = egwGetShiftState(e);
|
||||
|
||||
aoi.updateState(EGW_AO_STATE_SELECTED,
|
||||
!egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
|
||||
state);
|
||||
// Rows without a checkbox are unselectable
|
||||
if (typeof aoi.checkBox != "undefined")
|
||||
{
|
||||
aoi.doGetDOMNode = function() {
|
||||
return aoi.node;
|
||||
}
|
||||
});
|
||||
|
||||
$(aoi.checkBox).change(function() {
|
||||
aoi.updateState(EGW_AO_STATE_SELECTED, this.checked, EGW_AO_SHIFT_STATE_MULTI);
|
||||
});
|
||||
// Prevent the browser from selecting the content of the element, when
|
||||
// a special key is pressed.
|
||||
$(_node).mousedown(egwPreventSelect);
|
||||
|
||||
aoi.doSetState = function(_state) {
|
||||
var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED);
|
||||
this.checkBox.checked = selected;
|
||||
$(this.node).toggleClass('focused',
|
||||
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
|
||||
$(this.node).toggleClass('selected',
|
||||
selected);
|
||||
// Now append some action code to the node
|
||||
$(_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)
|
||||
{
|
||||
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
|
||||
var state = egwGetShiftState(e);
|
||||
|
||||
aoi.updateState(EGW_AO_STATE_SELECTED,
|
||||
!egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
|
||||
state);
|
||||
}
|
||||
});
|
||||
|
||||
$(aoi.checkBox).change(function() {
|
||||
aoi.updateState(EGW_AO_STATE_SELECTED, this.checked, EGW_AO_SHIFT_STATE_MULTI);
|
||||
});
|
||||
|
||||
aoi.doSetState = function(_state) {
|
||||
var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED);
|
||||
|
||||
if (this.checkBox)
|
||||
{
|
||||
this.checkBox.checked = selected;
|
||||
}
|
||||
|
||||
$(this.node).toggleClass('focused',
|
||||
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
|
||||
$(this.node).toggleClass('selected',
|
||||
selected);
|
||||
}
|
||||
}
|
||||
|
||||
return aoi;
|
||||
|
Loading…
Reference in New Issue
Block a user