From 4a0af9f977f1d7667dcb17d52a5a83f3d75f9fed Mon Sep 17 00:00:00 2001 From: Christian Binder Date: Fri, 5 Jan 2007 13:56:28 +0000 Subject: [PATCH] dragdrop: make class aware of multiple instances and make wz_dragdrop::ADD_DTHML() more performant --- phpgwapi/inc/class.dragdrop.inc.php | 32 +++++++++++++++++++++----- phpgwapi/js/wz_dragdrop/wz_dragdrop.js | 11 +++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/phpgwapi/inc/class.dragdrop.inc.php b/phpgwapi/inc/class.dragdrop.inc.php index 3f5b1c4bbe..9af15f37c6 100644 --- a/phpgwapi/inc/class.dragdrop.inc.php +++ b/phpgwapi/inc/class.dragdrop.inc.php @@ -120,7 +120,7 @@ class dragdrop if(!$GLOBALS['egw_info']['flags']['wz_dragdrop_included']) { $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; - $GLOBALS['egw_info']['flags']['wz_dragdrop_included'] = True; + $GLOBALS['egw_info']['flags']['wz_dragdrop_included'] = true; } // include actionScripts @@ -128,7 +128,7 @@ class dragdrop { foreach($this->actionScripts as $i => $actionScript) { - $GLOBALS['egw_info']['flags']['need_footer'] .= "\n"; + $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; } } @@ -137,20 +137,22 @@ class dragdrop { foreach($this->draggables as $i=>$element) { - $element_names_array[] = "\"".$element['name']."\""; + $element_names_array[] = '"'.$element['name'].'"+CURSOR_HAND+TRANSPARENT+SCROLL'; } } if(is_array($this->droppables)) { foreach($this->droppables as $i=>$element) { - $element_names_array[] = "\"".$element['name']."\""; + $element_names_array[] = '"'.$element['name'].'"'; } } if(is_array($element_names_array)) { - $element_names=implode(",",$element_names_array); - $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; + $element_names=implode(',',$element_names_array); + $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; } // set special params for draggable elements @@ -315,4 +317,22 @@ class dragdrop return false; } + /** + * evaluate the right DHTML command for adding DHTML objects + * + * @return string 'SET_DHTML' or 'ADD_DHTML' + */ + function DHTMLcommand() + { + if(!$GLOBALS['egw_info']['flags']['wz_dragdrop_runonce_SET_DHTML']) + { + $GLOBALS['egw_info']['flags']['wz_dragdrop_runonce_SET_DHTML'] = true; + return 'SET_DHTML'; + } + else + { + return 'ADD_DHTML'; + } + } + } diff --git a/phpgwapi/js/wz_dragdrop/wz_dragdrop.js b/phpgwapi/js/wz_dragdrop/wz_dragdrop.js index 5c678379ee..79b4e09b17 100644 --- a/phpgwapi/js/wz_dragdrop/wz_dragdrop.js +++ b/phpgwapi/js/wz_dragdrop/wz_dragdrop.js @@ -1360,11 +1360,14 @@ function SET_DHTML() window.onunload = dd.finlz; dd.setDwnHdl(PICK); } -function ADD_DHTML(d_o) // layers only! +function ADD_DHTML() // layers only! { - d_o = new DDObj(d_o); - dd.addElt(d_o); - dd.addProps(d_o); + var d_a = arguments, d_o, d_i = d_a.length; while(d_i--) + { + d_o = new DDObj(d_a[d_i]); + dd.addElt(d_o); + dd.addProps(d_o); + } dd.mkWzDom(); }