Added feature #9703: Integrate EXT: ingmar_admpanelwrap
authorIngo Renner <ingo.renner@typo3.org>
Fri, 3 Apr 2009 10:00:49 +0000 (10:00 +0000)
committerIngo Renner <ingo.renner@typo3.org>
Fri, 3 Apr 2009 10:00:49 +0000 (10:00 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5263 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/js/adminpanel.js [new file with mode: 0644]
typo3/sysext/fe_edit/view/class.tx_feedit_adminpanel.php

index 9d180e8..e919846 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-03  Ingo Renner  <ingo@typo3.org>
+
+       * Added feature #9703: Integrate EXT: ingmar_admpanelwrap
+
 2009-04-02  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed issue #10834: htmlArea RTE: IE8 now uses standard name for DOM class attribute
 2009-04-02  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed issue #10834: htmlArea RTE: IE8 now uses standard name for DOM class attribute
@@ -11,7 +15,7 @@
 
        * Fixed bug #10567: Added IE8+ support / Get rid of browser version dependent t3lib_div::clientInfo() (Thanks to Steffen Gebert)
        * #10717: Introduced a new function to t3lib_div::getMaxUploadFileSize() to have a central
 
        * Fixed bug #10567: Added IE8+ support / Get rid of browser version dependent t3lib_div::clientInfo() (Thanks to Steffen Gebert)
        * #10717: Introduced a new function to t3lib_div::getMaxUploadFileSize() to have a central
-         function to detect the maximum upload limit, was: No simple way to get the maximum 
+         function to detect the maximum upload limit, was: No simple way to get the maximum
          upload size in TYPO3
 
 2009-03-31  Oliver Hader  <oliver@typo3.org>
          upload size in TYPO3
 
 2009-03-31  Oliver Hader  <oliver@typo3.org>
diff --git a/t3lib/js/adminpanel.js b/t3lib/js/adminpanel.js
new file mode 100644 (file)
index 0000000..d947ba3
--- /dev/null
@@ -0,0 +1,123 @@
+/***************************************************************
+ * Admin Panel drag and drop
+ *
+ * $Id$
+ *
+ * Copyright notice
+ *
+ * (c) 2009 Ingo Renner <ingo@typo3.org>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * 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.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * @author  Ingo Renner  <ingo@typo3.org>
+ * @author     Oliver Hader <oliver@typo3.org>
+ * @author  Ingmar Schlecht <ingmar@typo3.org>
+ * @author  Jonas Dübi <jd@cabag.ch>
+ */
+
+var TYPO3AdminPanel = {
+
+       positionRestored: false,
+       dragObject: null,
+       dragX: 0,
+       dragY: 0,
+       posX: 0,
+       posY: 0,
+
+       savePosition: function(panel) {
+               var admPanelPosX = panel.offsetLeft;
+               var admPanelPosY = panel.offsetTop;
+
+               TYPO3AdminPanel.setCookie('admPanelPosX', admPanelPosX, '', '/');
+               TYPO3AdminPanel.setCookie('admPanelPosY', admPanelPosY, '', '/');
+       },
+
+       restorePosition: function() {
+               if (TYPO3AdminPanel.positionRestored == false) {
+
+                       var admPanelPosX = TYPO3AdminPanel.getCookie('admPanelPosX');
+                       if (admPanelPosX > 0) {
+                               document.getElementById('admPanel').style.left = admPanelPosX + 'px';
+                       }
+
+                       var admPanelPosY = TYPO3AdminPanel.getCookie('admPanelPosY');
+                       if (admPanelPosY > 0) {
+                               document.getElementById('admPanel').style.top = admPanelPosY + 'px';
+                       }
+
+                       TYPO3AdminPanel.positionRestored = true;
+               }
+       },
+
+       setCookie: function(name, value, expires, path, domain, secure) {
+               document.cookie = name + '=' + escape(value)
+                       + (expires ? '; expires=' + expires.toGMTString() : '')
+                       + (path ? '; path=' + path : '')
+                       + (domain ? '; domain=' + domain : '')
+                       + (secure ? '; secure' : '');
+       },
+
+       getCookie: function(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 = dc.indexOf(';', begin);
+               if (end == -1) {
+                       end = dc.length;
+               }
+
+               return unescape(dc.substring(begin + prefix.length, end));
+       },
+
+       dragInit: function() {
+               document.onmousemove = TYPO3AdminPanel.drag;
+               document.onmouseup = TYPO3AdminPanel.dragStop;
+       },
+
+       dragStart: function(element) {
+               TYPO3AdminPanel.dragObject = element;
+               TYPO3AdminPanel.dragX = TYPO3AdminPanel.posX - TYPO3AdminPanel.dragObject.offsetLeft;
+               TYPO3AdminPanel.dragY = TYPO3AdminPanel.posY - TYPO3AdminPanel.dragObject.offsetTop;
+       },
+
+       dragStop: function() {
+               TYPO3AdminPanel.dragObject = null;
+       },
+
+       drag: function(dragEvent) {
+               TYPO3AdminPanel.posX = document.all ? window.event.clientX : dragEvent.pageX;
+               TYPO3AdminPanel.posY = document.all ? window.event.clientY : dragEvent.pageY;
+
+               if (TYPO3AdminPanel.dragObject != null) {
+                       TYPO3AdminPanel.dragObject.style.left = (TYPO3AdminPanel.posX - TYPO3AdminPanel.dragX) + 'px';
+                       TYPO3AdminPanel.dragObject.style.top = (TYPO3AdminPanel.posY - TYPO3AdminPanel.dragY) + 'px';
+               }
+       }
+};
index bb58f2b..46309fd 100644 (file)
@@ -50,7 +50,8 @@ class tx_feedit_adminpanel {
         * @return      string          HTML for the Admin Panel
         */
        public function display() {
         * @return      string          HTML for the Admin Panel
         */
        public function display() {
-               $out='';
+               $out = '<script type="text/javascript" src="t3lib/js/adminpanel.js"></script>';
+
                if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
                        if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('preview')) {
                                $out .= $this->getPreviewModule();
                if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
                        if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('preview')) {
                                $out .= $this->getPreviewModule();
@@ -78,7 +79,7 @@ class tx_feedit_adminpanel {
                $row .= $this->extFw(': ' . $GLOBALS['BE_USER']->user['username']);
 
                $header = '
                $row .= $this->extFw(': ' . $GLOBALS['BE_USER']->user['username']);
 
                $header = '
-                       <tr class="typo3-adminPanel-hRow" style="background-color:#9ba1a8;">
+                       <tr class="typo3-adminPanel-hRow" style="background-color: #9ba1a8; cursor: move;">
                                <td colspan="4" style="text-align:left; white-space:nowrap;">' .
                                        $this->extItemLink('top',$row) . '
                                        <img src="clear.gif" width="40" height="1" alt="" />
                                <td colspan="4" style="text-align:left; white-space:nowrap;">' .
                                        $this->extItemLink('top',$row) . '
                                        <img src="clear.gif" width="40" height="1" alt="" />
@@ -143,7 +144,17 @@ $query . '
                        </script>
                        <script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
                }
                        </script>
                        <script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
                }
-               return "\n\n\n\n" . $out . '<br />';
+
+               $out = '
+               <div onmousedown="TYPO3AdminPanel.dragStart(this)" onmouseup="TYPO3AdminPanel.savePosition(this)" id="admPanel" style="position:absolute; left:10px; top:100px; width:30px; z-index:5;">
+               ' . $out . '
+               <br /></div>
+               <script type="text/javascript">
+                       TYPO3AdminPanel.dragInit();
+                       TYPO3AdminPanel.restorePosition();
+               </script>';
+
+               return $out;
        }
 
        /**
        }
 
        /**