2011-03-22 20:55:57 +01:00
|
|
|
/**
|
|
|
|
* 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$
|
|
|
|
*/
|
2011-03-22 18:06:02 +01:00
|
|
|
|
2011-03-22 20:55:57 +01:00
|
|
|
/**
|
|
|
|
* Contains the action object interface implementation for the nextmatch widget
|
|
|
|
* row.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// An action object interface for each nextmatch widget row - "inherits" from
|
2011-03-22 18:06:02 +01:00
|
|
|
// egwActionObjectInterface
|
|
|
|
function nextmatchRowAOI(_node)
|
|
|
|
{
|
|
|
|
var aoi = new egwActionObjectInterface();
|
|
|
|
|
|
|
|
aoi.node = _node;
|
|
|
|
|
|
|
|
aoi.checkBox = ($(":checkbox", aoi.node))[0];
|
|
|
|
|
2011-03-22 20:55:57 +01:00
|
|
|
// Rows without a checkbox are unselectable
|
|
|
|
if (typeof aoi.checkBox != "undefined")
|
|
|
|
{
|
|
|
|
aoi.doGetDOMNode = function() {
|
|
|
|
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
|
|
|
|
$(_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() {
|
2011-03-23 21:07:07 +01:00
|
|
|
aoi.updateState(EGW_AO_STATE_SELECTED, this.checked, EGW_AO_SHIFT_STATE_MULTI);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Don't execute the default action when double clicking on an entry
|
|
|
|
$(aoi.checkBox).dblclick(function() {
|
|
|
|
return false;
|
|
|
|
});
|
2011-03-22 20:55:57 +01:00
|
|
|
|
|
|
|
aoi.doSetState = function(_state) {
|
|
|
|
var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED);
|
2011-03-22 18:06:02 +01:00
|
|
|
|
2011-03-22 20:55:57 +01:00
|
|
|
if (this.checkBox)
|
|
|
|
{
|
|
|
|
this.checkBox.checked = selected;
|
|
|
|
}
|
2011-03-22 18:06:02 +01:00
|
|
|
|
2011-03-22 20:55:57 +01:00
|
|
|
$(this.node).toggleClass('focused',
|
|
|
|
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
|
|
|
|
$(this.node).toggleClass('selected',
|
|
|
|
selected);
|
2011-03-22 18:06:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aoi;
|
|
|
|
}
|
|
|
|
|