add wz_dragdrop code to resize the sidebox menu. It uses ajax to store the new size

This commit is contained in:
Pim Snel 2007-01-02 14:08:32 +00:00
parent 733e2cfe2d
commit 498fd3be96
4 changed files with 145 additions and 20 deletions

View File

@ -0,0 +1,55 @@
<?php
/**
* eGW idots template ajax server
*
* @link http://www.egroupware.org
* @author Pim Snel <pim@lingewoud.nl> author of the idots template set
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage framework
* @access public
* @abstract script which is called by idots template set to store prefs using AJAX
* @version $Id$
*/
if(!$_GET['currentapp'])
{
$_GET['currentapp']='preferences';
}
$egw_flags = Array(
'currentapp' => $_GET['currentapp'],
'noheader' => True,
'nonavbar' => True,
'noappheader' => True,
'noappfooter' => True,
'nofooter' => True
);
$GLOBALS['egw_info']['flags'] = $egw_flags;
require('../../../header.inc.php');
require_once(EGW_API_INC.'/xajax.inc.php');
$xajax = new xajax($GLOBALS['egw_info']['server']['webserver_url']."/phpgwapi/templates/idots/ajaxStorePrefs.php");
$xajax->registerFunction("storeEGWPref");
/**
* storeEGWPref
*
* @param mixed $repository egroupware preferences repository
* @param mixed $key key to preference
* @param mixed $value new value
* @access public
* @return mixed returns null when no erro, else return error message.
*/
function storeEGWPref($repository,$key,$value)
{
$objResponse = new xajaxResponse();
$GLOBALS['egw']->preferences->read_repository();
$GLOBALS['egw']->preferences->change($repository,$key,$value);
$GLOBALS['egw']->preferences->save_repository(True);
return $objResponse;
}
$xajax->processRequests();
?>

View File

@ -14,6 +14,7 @@
require_once(EGW_API_INC.'/class.egw_framework.inc.php'); require_once(EGW_API_INC.'/class.egw_framework.inc.php');
require_once(EGW_API_INC.'/class.Template.inc.php'); require_once(EGW_API_INC.'/class.Template.inc.php');
require_once(EGW_API_INC.'/class.dragdrop.inc.php');
/** /**
* eGW idots template * eGW idots template
@ -90,6 +91,9 @@ class idots_framework extends egw_framework
*/ */
function navbar() function navbar()
{ {
$this->tplsav2 = CreateObject('phpgwapi.tplsavant2');
$this->tplsav2->set_tpl_path(EGW_SERVER_ROOT.SEP.'phpgwapi'.SEP.'templates'.SEP.'idots');
$this->navbar_done = true; $this->navbar_done = true;
// the navbar // the navbar
@ -158,15 +162,52 @@ class idots_framework extends egw_framework
} }
else else
{ {
$var['menu_link'] = ''; $GLOBALS['phpgw']->preferences->read_repository();
$var['sideboxcolstart'] = '<td id="tdSidebox" valign="top">';
$var['remove_padding'] = '';
$this->tpl->set_var($var);
$content .= $this->tpl->parse('out','appbox');
$content .= $this->sidebox_content; $prefs = array();
$var['sideboxcolend'] = '</td>'; if ($GLOBALS['egw_info']['user']['preferences']['common'])
{
$sideboxwidth = $GLOBALS['egw_info']['user']['preferences']['common']['idotssideboxwidth'];
}
if(intval($sideboxwidth)<1)
{
$sideboxwidth = 203;
}
$var['menu_link'] = '';
$var['sideboxcolstart'] = '<td id="tdSidebox" valign="top"><div id="thesideboxcolumn" style="width:'.$sideboxwidth.'px">';
$var['sideboxcolstart'] .= '<div style="width:13px;height:13px;right:1px;top:1px;position:absolute;z-index:9999;" id="sideresize">
<img src="'.$GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/default/images'.'/resize.png" alt="resize"/>
</div>';
$var['remove_padding'] = '';
$this->tpl->set_var($var);
$content .= $this->tpl->parse('out','appbox');
$content .= $this->sidebox_content;
$var['sideboxcolend'] = '</div></td>';
// Add DHTML for resizing sidebox menu
// include wz_dragdrop once
if(!$GLOBALS['egw_info']['flags']['wz_dragdrop_included'])
{
$GLOBALS['egw_info']['flags']['need_footer'] .= "<!-- BEGIN JavaScript for wz_dragdrop.js -->\n";
$GLOBALS['egw_info']['flags']['need_footer'] .= '<script language="JavaScript" type="text/javascript" src="'.$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'."\n";
$GLOBALS['egw_info']['flags']['wz_dragdrop_included'] = True;
}
require_once(EGW_API_INC.'/xajax.inc.php');
$xajax = new xajax($GLOBALS['egw_info']['server']['webserver_url']."/phpgwapi/templates/idots/ajaxStorePrefs.php");
$xajax->registerFunction("storeEGWPref");
$this->tplsav2->assign('sideboxwidth', $sideboxwidth);
$this->tplsav2->assign('xajaxobj',&$xajax);
$this->tplsav2->assign('xajaxincdir',$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js');
$GLOBALS['egw_info']['flags']['need_footer'] .= $this->tplsav2->fetch('sidebox_dhtml.tpl.php');
} }
$this->tpl->set_var($var); $this->tpl->set_var($var);
@ -559,17 +600,18 @@ class idots_framework extends egw_framework
*/ */
function sidebox($appname,$menu_title,$file) function sidebox($appname,$menu_title,$file)
{ {
if(!$appname || ($appname==$GLOBALS['egw_info']['flags']['currentapp'] && $file))
{
$this->tpl->set_var('lang_title',$menu_title);
$this->sidebox_content .= $this->tpl->fp('out','extra_blocks_header');
foreach($file as $text => $url) if(!$appname || ($appname==$GLOBALS['egw_info']['flags']['currentapp'] && $file))
{ {
$this->sidebox_content .= $this->_sidebox_menu_item($url,$text); $this->tpl->set_var('lang_title',$menu_title);
} $this->sidebox_content .= $this->tpl->fp('out','extra_blocks_header');
$this->sidebox_content .= $this->tpl->parse('out','extra_blocks_footer');
} foreach($file as $text => $url)
{
$this->sidebox_content .= $this->_sidebox_menu_item($url,$text);
}
$this->sidebox_content .= $this->tpl->parse('out','extra_blocks_footer');
}
} }
/** /**

View File

@ -153,8 +153,13 @@ input[type=image]
border: 0; border: 0;
} }
.divLoginbox,.divSidebox #thesideboxcolumn
{
width: 177px;
position:relative;
}
.divLoginbox
{ {
position:relative; position:relative;
width: 370px; width: 370px;
@ -163,7 +168,8 @@ input[type=image]
.divSidebox .divSidebox
{ {
width: 177px; position:relative;
border: #9c9c9c 1px solid;
} }
.divSideboxHeader,.divLoginboxHeader .divSideboxHeader,.divLoginboxHeader

View File

@ -0,0 +1,22 @@
<!-- Savant template - sidebox dhtml -->
<?php $this->xajaxobj->printJavascript($this->xajaxincdir); ?>
<script language="JavaScript" type="text/javascript">SET_DHTML("thesideboxcolumn"+NO_DRAG)</script>
<script language="JavaScript" type="text/javascript">ADD_DHTML("sideresize"+CURSOR_W_RESIZE+MAXOFFBOTTOM+0+MAXOFFTOP+0+MAXOFFLEFT+1000+MAXOFFRIGHT+1000)</script>
<script language="JavaScript" type="text/javascript">
var mainbox = dd.elements.thesideboxcolumn;
var rt = dd.elements.sideresize;
var rtxstart= rt.x;
function my_DragFunc()
{
if (dd.obj == rt)
{
mainbox.resizeTo(rt.x-rtxstart+<?=$this->sideboxwidth?>, mainbox.h);
}
}
function my_DropFunc()
{
xajax_storeEGWPref('common','idotssideboxwidth',mainbox.w);
}
</script>