mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
Added basic support for the egw_action framework in the nextmatch widget (currently not active)
This commit is contained in:
parent
8d81db64af
commit
f6d0edbdc1
@ -945,6 +945,72 @@ class etemplate extends boetemplate
|
||||
$div_style=' style="'.($width?"width: $width; ":'').($height ? "height: $height; ":'')."overflow: $overflow;\"";
|
||||
$html = html::div($html,$div_style);
|
||||
}
|
||||
|
||||
/* if ($options[3] == 'action')
|
||||
{
|
||||
// JS action objects generated for this widget are prefixed with the
|
||||
// prefix given here
|
||||
$prefix = "egw_";
|
||||
|
||||
$html .= '
|
||||
<script type="text/javascript">
|
||||
//Temporary function called on onExecute
|
||||
function alertClicked(_action, _senders)
|
||||
{
|
||||
var ids = "";
|
||||
for (var i = 0; i < _senders.length; i++)
|
||||
ids += _senders[i].id + ((i < _senders.length - 1) ? ", " : "");
|
||||
|
||||
alert("Action \'" + _action.caption + "\' executed on elements \'"
|
||||
+ ids + "\'");
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
// Initialize the action manager and add some actions to it
|
||||
'.$prefix.'actionManager = new egwActionManager();
|
||||
'.$prefix.'objectManager = new egwActionObjectManager("", '.$prefix.'actionManager);
|
||||
|
||||
// Add some dummy actions to the actionManager
|
||||
'.$prefix.'actionManager.updateActions(
|
||||
[
|
||||
{
|
||||
"id": "folder_open",
|
||||
"iconUrl": "imgs/folder.png",
|
||||
"caption": "Open folder",
|
||||
"onExecute": "javaScript:alertClicked",
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"id": "file_view",
|
||||
"iconUrl": "imgs/view.png",
|
||||
"caption": "View",
|
||||
"onExecute": "javaScript:alertClicked",
|
||||
"allowOnMultiple": false,
|
||||
"type": "popup",
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
var actionLinks = ["folder_open", "file_view"];
|
||||
|
||||
// Create a new action object for each table row
|
||||
// TODO: only apply function to outer level
|
||||
$("table.action>tbody >tr").each(function(index, elem) {
|
||||
|
||||
console.log(elem);
|
||||
// Create a new action object
|
||||
var obj = '.$prefix.'objectManager.addObject(elem.id, new nextmatchRowAOI(elem));
|
||||
|
||||
obj.updateActionLinks(actionLinks);
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
}*/
|
||||
|
||||
return "\n\n<!-- BEGIN grid $grid[name] -->\n$html<!-- END grid $grid[name] -->\n\n";
|
||||
}
|
||||
|
||||
|
@ -245,6 +245,20 @@ class nextmatch_widget
|
||||
$extension_data['old_value'] = $value;
|
||||
return $extra_label;
|
||||
}
|
||||
|
||||
// Load some JS files needed for the egw_action framework
|
||||
egw_framework::includeCSS('/phpgwapi/js/egw_action/test/skins/dhtmlxmenu_egw.css');
|
||||
|
||||
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/dhtmlxcommon');
|
||||
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/dhtmlxmenu');
|
||||
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/ext/dhtmlxmenu_ext');
|
||||
egw_framework::validate_file('egw_action','egw_action');
|
||||
egw_framework::validate_file('egw_action','egw_action_common');
|
||||
egw_framework::validate_file('egw_action','egw_action_popup');
|
||||
egw_framework::validate_file('egw_action','egw_menu');
|
||||
egw_framework::validate_file('egw_action','egw_menu_dhtmlx');
|
||||
egw_framework::validate_file('.', 'nextmatch_action', 'etemplate');
|
||||
|
||||
// does NOT work with php5.2.6+
|
||||
if (version_compare(PHP_VERSION,'5.2.6','>='))
|
||||
{
|
||||
|
45
etemplate/js/nextmatch_action.js
Normal file
45
etemplate/js/nextmatch_action.js
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
// An action object interface for the listbox - "inherits" from
|
||||
// egwActionObjectInterface
|
||||
function nextmatchRowAOI(_node)
|
||||
{
|
||||
var aoi = new egwActionObjectInterface();
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
$(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);
|
||||
this.checkBox.checked = selected;
|
||||
$(this.node).toggleClass('focused',
|
||||
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
|
||||
$(this.node).toggleClass('selected',
|
||||
selected);
|
||||
}
|
||||
|
||||
return aoi;
|
||||
}
|
||||
|
@ -154,3 +154,21 @@
|
||||
overflow: auto;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
/* CSS styles for egw_action */
|
||||
|
||||
table.action tr.row_off.selected {
|
||||
background-color: #2b5d9b;
|
||||
color: white;
|
||||
}
|
||||
|
||||
table.action tr.row_on.selected {
|
||||
background-color: #234b7d !important;
|
||||
}
|
||||
|
||||
table.action .focused {
|
||||
border: 1px dotted black;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user