2012-03-27 12:18:42 +02:00
|
|
|
/**
|
2013-04-13 21:00:13 +02:00
|
|
|
* EGroupware eTemplate2 - Contains interfaces used inside the dataview
|
2012-03-27 12:18:42 +02:00
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage dataview
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Andreas Stöckel
|
|
|
|
* @copyright Stylite 2012
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*egw:uses
|
|
|
|
egw_action.egw_action_common;
|
|
|
|
egw_action.egw_action;
|
2014-12-04 17:35:17 +01:00
|
|
|
/phpgwapi/js/jquery/TouchSwipe/jquery.touchSwipe.js;
|
2012-03-27 12:18:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains the action object interface implementation for the nextmatch widget
|
|
|
|
* row.
|
|
|
|
*/
|
|
|
|
|
2012-03-27 16:51:16 +02:00
|
|
|
var EGW_SELECTMODE_DEFAULT = 0;
|
|
|
|
var EGW_SELECTMODE_TOGGLE = 1;
|
|
|
|
|
2012-03-27 12:18:42 +02:00
|
|
|
/**
|
|
|
|
* An action object interface for each nextmatch widget row - "inherits" from
|
|
|
|
* egwActionObjectInterface
|
|
|
|
*/
|
|
|
|
function et2_dataview_rowAOI(_node)
|
|
|
|
{
|
|
|
|
var aoi = new egwActionObjectInterface();
|
|
|
|
|
|
|
|
aoi.node = _node;
|
|
|
|
|
2012-03-27 16:51:16 +02:00
|
|
|
aoi.selectMode = EGW_SELECTMODE_DEFAULT;
|
|
|
|
|
2012-03-27 12:18:42 +02:00
|
|
|
aoi.checkBox = null; //($j(":checkbox", aoi.node))[0];
|
|
|
|
|
|
|
|
// Rows without a checkbox OR an id set are unselectable
|
|
|
|
aoi.doGetDOMNode = function() {
|
|
|
|
return aoi.node;
|
2013-04-13 21:00:13 +02:00
|
|
|
};
|
2012-03-27 12:18:42 +02:00
|
|
|
|
|
|
|
// Prevent the browser from selecting the content of the element, when
|
|
|
|
// a special key is pressed.
|
|
|
|
$j(_node).mousedown(egwPreventSelect);
|
|
|
|
|
2013-04-13 21:00:13 +02:00
|
|
|
/**
|
|
|
|
* Now append some action code to the node
|
|
|
|
*
|
|
|
|
* @memberOf et2_dataview_rowAOI
|
|
|
|
*/
|
2014-12-04 17:35:17 +01:00
|
|
|
var selectHandler = function(e, _params) {
|
2012-03-27 12:18:42 +02:00
|
|
|
// Reset the focus so that keyboard navigation will work properly
|
|
|
|
// after the element has been clicked
|
|
|
|
egwUnfocus();
|
|
|
|
|
|
|
|
// Reset the prevent selection code (in order to allow wanted
|
|
|
|
// selection of text)
|
|
|
|
_node.onselectstart = null;
|
2014-12-04 17:35:17 +01:00
|
|
|
|
2012-03-27 12:18:42 +02:00
|
|
|
if (e.target != aoi.checkBox)
|
|
|
|
{
|
|
|
|
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
|
2012-03-27 16:51:16 +02:00
|
|
|
var state = egwGetShiftState(e);
|
2014-12-04 17:35:17 +01:00
|
|
|
|
|
|
|
if (_params)
|
|
|
|
{
|
|
|
|
if (egwIsMobile())
|
|
|
|
{
|
|
|
|
switch (_params.swip)
|
|
|
|
{
|
|
|
|
case "left":
|
|
|
|
case "right":
|
|
|
|
state = 1;
|
2015-02-19 12:45:05 +01:00
|
|
|
// Hide context menu on swip actions
|
|
|
|
if(_egw_active_menu) _egw_active_menu.hide();
|
2014-12-04 17:35:17 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-27 16:51:16 +02:00
|
|
|
switch (aoi.selectMode)
|
|
|
|
{
|
|
|
|
case EGW_SELECTMODE_DEFAULT:
|
|
|
|
aoi.updateState(EGW_AO_STATE_SELECTED,
|
|
|
|
!egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
|
|
|
|
state);
|
|
|
|
break;
|
|
|
|
case EGW_SELECTMODE_TOGGLE:
|
|
|
|
aoi.updateState(EGW_AO_STATE_SELECTED, !selected,
|
|
|
|
egwSetBit(state, EGW_AO_SHIFT_STATE_MULTI, true));
|
|
|
|
break;
|
|
|
|
}
|
2012-03-27 12:18:42 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (egwIsMobile()) {
|
2014-12-04 17:35:17 +01:00
|
|
|
$j(_node).swipe({
|
|
|
|
allowPageScroll: "vertical",
|
|
|
|
swipe: function (event, direction)
|
|
|
|
{
|
|
|
|
selectHandler(event, {swip:direction});
|
|
|
|
},
|
|
|
|
click: function (event)
|
|
|
|
{
|
|
|
|
selectHandler(event);
|
2015-02-19 12:45:05 +01:00
|
|
|
}
|
2014-12-04 17:35:17 +01:00
|
|
|
|
|
|
|
});
|
2012-03-27 12:18:42 +02:00
|
|
|
} else {
|
|
|
|
$j(_node).click(selectHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
$j(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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$j(this.node).toggleClass('focused',
|
|
|
|
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
|
|
|
|
$j(this.node).toggleClass('selected',
|
|
|
|
selected);
|
2013-04-13 21:00:13 +02:00
|
|
|
};
|
2012-03-27 12:18:42 +02:00
|
|
|
|
|
|
|
return aoi;
|
|
|
|
}
|
|
|
|
|