From f6d0edbdc19586bba7521e6885c7ad62b1dcf465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Tue, 22 Mar 2011 17:06:02 +0000 Subject: [PATCH] Added basic support for the egw_action framework in the nextmatch widget (currently not active) --- etemplate/inc/class.etemplate.inc.php | 66 ++++++++++++++++++++ etemplate/inc/class.nextmatch_widget.inc.php | 14 +++++ etemplate/js/nextmatch_action.js | 45 +++++++++++++ etemplate/templates/default/app.css | 18 ++++++ 4 files changed, 143 insertions(+) create mode 100644 etemplate/js/nextmatch_action.js diff --git a/etemplate/inc/class.etemplate.inc.php b/etemplate/inc/class.etemplate.inc.php index 211664f9d8..5c7a990180 100644 --- a/etemplate/inc/class.etemplate.inc.php +++ b/etemplate/inc/class.etemplate.inc.php @@ -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 .= ' +'; + }*/ + return "\n\n\n$html\n\n"; } diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index 1862ef04f8..86826fae87 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -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','>=')) { diff --git a/etemplate/js/nextmatch_action.js b/etemplate/js/nextmatch_action.js new file mode 100644 index 0000000000..e8bbc32113 --- /dev/null +++ b/etemplate/js/nextmatch_action.js @@ -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; +} + diff --git a/etemplate/templates/default/app.css b/etemplate/templates/default/app.css index 66ba33f78c..16dfce9481 100644 --- a/etemplate/templates/default/app.css +++ b/etemplate/templates/default/app.css @@ -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; +} + +