Project

General

Profile

Feature #19543 » 9703.diff

Administrator Admin, 2008-10-30 23:41

View differences:

t3lib/js/adminpanelDnD.js (revision 0)
/***************************************************************
*
* Admin Panel drag and drop
*
* $Id$
*
* Copyright notice
*
* (c) 2008 Ingo Renner
* All rights reserved
*
* This script is part of the TYPO3 t3lib/ library provided by
* Ingo Renner <ingo@typo3.org> together with TYPO3
*
* Released under GNU/GPL (see license file in typo3/sysext/cms/tslib/)
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* This copyright notice MUST APPEAR in all copies of this script
***************************************************************/
var restoreOnce = 0;
function saveposition(panel) {
var admPanelPosX = panel.offsetLeft;
var admPanelPosY = panel.offsetTop;
setCookie("admPanelPosX", admPanelPosX);
setCookie("admPanelPosY", admPanelPosY);
}
function restorePosition() {
if (restoreOnce == 0) {
var admPanelPosX = getCookie("admPanelPosX");
if (admPanelPosX > 0) {
document.getElementById("admPanel").style.left = admPanelPosX
+ "px";
}
var admPanelPosY = getCookie("admPanelPosY");
if (admPanelPosY > 0) {
document.getElementById("admPanel").style.top = admPanelPosY + "px";
}
restoreOnce = 1;
}
}
function setCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + escape(value)
+ ((expires) ? "; expires=" + expires.toGMTString() : "")
+ ((path) ? "; path=" + path : "")
+ ((domain) ? "; domain=" + domain : "")
+ ((secure) ? "; secure" : "");
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0)
return null;
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
};
var dragobjekt = null;
var dragx = 0;
var dragy = 0;
var posx = 0;
var posy = 0;
function draginit() {
document.onmousemove = drag;
document.onmouseup = dragstop;
};
function dragstart(element) {
dragobjekt = element;
dragx = posx - dragobjekt.offsetLeft;
dragy = posy - dragobjekt.offsetTop;
};
function dragstop() {
dragobjekt = null;
};
function drag(ereignis) {
posx = document.all ? window.event.clientX : ereignis.pageX;
posy = document.all ? window.event.clientY : ereignis.pageY;
if (dragobjekt != null) {
dragobjekt.style.left = (posx - dragx) + "px";
dragobjekt.style.top = (posy - dragy) + "px";
}
}
t3lib/class.t3lib_tsfebeuserauth.php (working copy)
</form>';
if ($this->uc['TSFE_adminConfig']['display_top']) {
$out.= '<script type="text/javascript" src="t3lib/js/adminpanelDnD.js"></script>';
$out.= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
$out.= '
<script type="text/javascript">
......
</script>
<script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
}
return "\n\n\n\n".$out.'<br />';
$out = '
<div onmousedown="dragstart(this)" onmouseup="saveposition(this)" id="admPanel" style="position:absolute; left:10px; top:100px; width:30px; z-index:5">
' . $out . '
<br /></div>
<script type="text/javascript">
draginit();
restorePosition();
</script>';
return $out;
}
/**
(1-1/8)