From 7e33ae9f7645ba5388877e67dca71bc98ef34c18 Mon Sep 17 00:00:00 2001
From: Felix Kopp <felix-source@phorax.com>
Date: Wed, 8 May 2013 18:32:26 +0200
Subject: [PATCH] [TASK] Move js files to EXT: backend

The global js/ directory should be resolved. Moves several files
to EXT: backend that are only used in EXT: backend classes.

Change-Id: I79c80f60699750a5aff46ac554cb8d92c8a37236
Resolves: #48063
Releases: 6.2
Reviewed-on: https://review.typo3.org/20644
Reviewed-by: Thomas Maroschik
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
---
 typo3/js/backendsearch.js                     | 153 ------------------
 .../Classes/Controller/BackendController.php  |  10 +-
 .../PageTreeNavigationController.php          |   2 +-
 .../Classes/Template/DocumentTemplate.php     |   6 +-
 .../Classes/Toolbar/ClearCacheToolbarItem.php |   2 +-
 .../Classes/Toolbar/LiveSearchToolbarItem.php |   2 +-
 .../Classes/Toolbar/ShortcutToolbarItem.php   |   2 +-
 .../Resources/Public/JavaScript}/backend.js   |   0
 .../Public/JavaScript}/clearcachemenu.js      |   0
 .../Resources/Public/JavaScript}/common.js    |   0
 .../Public/JavaScript}/iecompatibility.js     |   0
 .../Public/JavaScript}/livesearch.js          |   0
 .../Public/JavaScript}/modulemenu.js          |   0
 .../Public/JavaScript}/pagetreefiltermenu.js  |   0
 .../Public/JavaScript}/shortcutmenu.js        |   0
 .../Resources/Public/JavaScript}/tabmenu.js   |   0
 .../Public/JavaScript}/toolbarmanager.js      |   0
 17 files changed, 12 insertions(+), 165 deletions(-)
 delete mode 100644 typo3/js/backendsearch.js
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/backend.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/clearcachemenu.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/common.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/iecompatibility.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/livesearch.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/modulemenu.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/pagetreefiltermenu.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/shortcutmenu.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/tabmenu.js (100%)
 rename typo3/{js => sysext/backend/Resources/Public/JavaScript}/toolbarmanager.js (100%)

diff --git a/typo3/js/backendsearch.js b/typo3/js/backendsearch.js
deleted file mode 100644
index aef8331cc286..000000000000
--- a/typo3/js/backendsearch.js
+++ /dev/null
@@ -1,153 +0,0 @@
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2007-2011 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.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  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!
-***************************************************************/
-
-/**
- * class to handle the backend search
- */
-var BackendSearch = Class.create({
-
-	/**
-	 * registers for resize event listener and executes on DOM ready
-	 */
-	initialize: function() {
-		Ext.onReady(function() {
-			Event.observe(
-				window, 'resize',
-				function() { TYPO3BackendToolbarManager.positionMenu('backend-search-menu'); }
-			);
-			TYPO3BackendToolbarManager.positionMenu('backend-search-menu');
-			this.toolbarItemIcon = $$('#backend-search-menu .toolbar-item span.t3-icon')[0];
-
-			$('search-query').observe('keypress', function(event) {
-				var keyCode;
-
-				if (!event) {
-					var event = window.event;
-				}
-
-				if (event.keyCode) {
-					keyCode = event.keyCode;
-				} else if (event.which) {
-					keyCode = event.which;
-				}
-
-				if (keyCode === Event.KEY_RETURN) {
-					TYPO3BackendSearchMenu.invokeSearch();
-				}
-			});
-
-			$$('#backend-search-menu .toolbar-item')[0].observe('click', this.toggleMenu)
-		}.bindAsEventListener(this));
-	},
-
-
-	/**
-	 * toggles the visibility of the menu and places it under the toolbar icon
-	 */
-	toggleMenu: function(event) {
-		var toolbarItem = $$('#backend-search-menu > a')[0];
-		var menu        = $$('#backend-search-menu .toolbar-item-menu')[0];
-		toolbarItem.blur();
-
-		if (!toolbarItem.hasClassName('toolbar-item-active')) {
-			toolbarItem.addClassName('toolbar-item-active');
-			Effect.Appear(menu, {duration: 0.2});
-			TYPO3BackendToolbarManager.hideOthers(toolbarItem);
-
-			setTimeout(function() {
-				$('search-query').activate();
-			}, 200);
-		} else {
-			toolbarItem.removeClassName('toolbar-item-active');
-			Effect.Fade(menu, {duration: 0.1});
-
-			setTimeout(function() {
-				$('search-query').clear();
-			}, 100);
-		}
-
-		if (event) {
-			Event.stop(event);
-		}
-	},
-
-	/**
-	 * calls the actual clear cache URL using an asynchronious HTTP request
-	 */
-	invokeSearch: function() {
-		new Ajax.Request('alt_shortcut.php?ajax=1&editPage=' + top.rawurlencodeAndRemoveSiteUrl($F('search-query')), {
-			method: 'get',
-			requestHeaders: {Accept: 'application/json'},
-			onSuccess: function(transport) {
-				var jsonResponse = transport.responseText.evalJSON(true);
-
-				switch(jsonResponse.type) {
-					case 'page':
-						top.loadEditId(jsonResponse.editRecord);
-						break;
-					case 'alternative':
-						this.jump(
-							unescape('alt_doc.php?returnUrl=dummy.php&edit[' + jsonResponse.alternativeTable + '][' + jsonResponse.alternativeUid + ']=edit'),
-							'web_list',
-							'web'
-						);
-						break;
-					case 'search':
-						this.jump(
-							unescape(TYPO3.configuration.listModulePath + 'db_list.php?id=' + jsonResponse.firstMountPoint + '&search_field=' + jsonResponse.searchFor + '&search_levels=' + (jsonResponse.firstMountPoint > 0 ? '4' : '-1')),
-							'web_list',
-							'web'
-						);
-						break;
-				}
-			}.bind(this)
-		});
-
-		$('search-query').clear();
-		this.toggleMenu();
-	},
-
-	/**
-	 * jumps to a given URL in the content iframe, taken from alt_shortcut.php
-	 *
-	 * @param	string		the URL to jump to
-	 * @param	string		module name
-	 * @param	string		main module name
-	 */
-	jump: function(url, modName, mainModName) {
-			// Clear information about which entry in nav. tree that might have been highlighted.
-		top.fsMod.navFrameHighlightedID = new Array();
-		if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
-			top.content.nav_frame.refresh_nav();
-		}
-
-		top.nextLoadModuleUrl = url;
-		top.goToModule(modName);
-	}
-
-});
-
-var TYPO3BackendSearchMenu = new BackendSearch();
diff --git a/typo3/sysext/backend/Classes/Controller/BackendController.php b/typo3/sysext/backend/Classes/Controller/BackendController.php
index d5645dafb66a..f867947d8283 100644
--- a/typo3/sysext/backend/Classes/Controller/BackendController.php
+++ b/typo3/sysext/backend/Classes/Controller/BackendController.php
@@ -99,18 +99,18 @@ class BackendController {
 		// Add default BE javascript
 		$this->js = '';
 		$this->jsFiles = array(
-			'common' => 'js/common.js',
+			'common' => 'sysext/backend/Resources/Public/JavaScript/common.js',
 			'locallang' => $this->getLocalLangFileName(),
 			'modernizr' => 'contrib/modernizr/modernizr.min.js',
 			'md5' => 'md5.js',
-			'toolbarmanager' => 'js/toolbarmanager.js',
-			'modulemenu' => 'js/modulemenu.js',
-			'iecompatibility' => 'js/iecompatibility.js',
+			'toolbarmanager' => 'sysext/backend/Resources/Public/JavaScript/toolbarmanager.js',
+			'modulemenu' => 'sysext/backend/Resources/Public/JavaScript/modulemenu.js',
+			'iecompatibility' => 'sysext/backend/Resources/Public/JavaScript/iecompatibility.js',
 			'evalfield' => '../t3lib/jsfunc.evalfield.js',
 			'flashmessages' => '../t3lib/js/extjs/ux/flashmessages.js',
 			'tabclosemenu' => '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js',
 			'notifications' => '../t3lib/js/extjs/notifications.js',
-			'backend' => 'js/backend.js',
+			'backend' => 'sysext/backend/Resources/Public/JavaScript/backend.js',
 			'loginrefresh' => 'js/loginrefresh.js',
 			'debugPanel' => 'js/extjs/debugPanel.js',
 			'viewport' => 'js/extjs/viewport.js',
diff --git a/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php b/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php
index 81355d50a2f8..ea6208fccea5 100644
--- a/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php
+++ b/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php
@@ -156,7 +156,7 @@ class PageTreeNavigationController {
 		$this->doc->getPageRenderer()->loadScriptaculous('effects');
 		$this->doc->getPageRenderer()->loadExtJS();
 		if ($this->hasFilterBox) {
-			$this->doc->getPageRenderer()->addJsFile('js/pagetreefiltermenu.js');
+			$this->doc->getPageRenderer()->addJsFile('sysext/backend/Resources/Public/JavaScript/pagetreefiltermenu.js');
 		}
 		$this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
 		// setting prefs for pagetree and drag & drop
diff --git a/typo3/sysext/backend/Classes/Template/DocumentTemplate.php b/typo3/sysext/backend/Classes/Template/DocumentTemplate.php
index cd8272dd6132..c2115962a143 100644
--- a/typo3/sysext/backend/Classes/Template/DocumentTemplate.php
+++ b/typo3/sysext/backend/Classes/Template/DocumentTemplate.php
@@ -1564,7 +1564,7 @@ class DocumentTemplate {
 	 */
 	public function getDragDropCode($table) {
 		$this->pageRenderer->loadPrototype();
-		$this->loadJavascriptLib('js/common.js');
+		$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/common.js');
 		$this->loadJavascriptLib('js/tree.js');
 		// Setting prefs for drag & drop
 		$this->JScodeArray['dragdrop'] = '
@@ -1684,7 +1684,7 @@ class DocumentTemplate {
 	 */
 	public function getDynTabMenu($menuItems, $identString, $toggle = 0, $foldout = FALSE, $noWrap = TRUE, $fullWidth = FALSE, $defaultTabIndex = 1, $dividers2tabs = 2) {
 		// Load the static code, if not already done with the function below
-		$this->loadJavascriptLib('js/tabmenu.js');
+		$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/tabmenu.js');
 		$content = '';
 		if (is_array($menuItems)) {
 			// Init:
@@ -1848,7 +1848,7 @@ class DocumentTemplate {
 	public function setModuleTemplate($filename) {
 		// Load Prototype lib for IE event
 		$this->pageRenderer->loadPrototype();
-		$this->loadJavascriptLib('js/iecompatibility.js');
+		$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/iecompatibility.js');
 		$this->moduleTemplate = $this->getHtmlTemplate($filename);
 	}
 
diff --git a/typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem.php b/typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem.php
index 38aef2b8097f..c94258b8f68b 100644
--- a/typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem.php
+++ b/typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem.php
@@ -149,7 +149,7 @@ class ClearCacheToolbarItem implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHoo
 	 * @return void
 	 */
 	protected function addJavascriptToBackend() {
-		$this->backendReference->addJavascriptFile('js/clearcachemenu.js');
+		$this->backendReference->addJavascriptFile('sysext/backend/Resources/Public/JavaScript/clearcachemenu.js');
 	}
 
 	/**
diff --git a/typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem.php b/typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem.php
index 1c376010df32..80a3bcc89aef 100644
--- a/typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem.php
+++ b/typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem.php
@@ -89,7 +89,7 @@ class LiveSearchToolbarItem implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHoo
 	 */
 	protected function addJavascriptToBackend() {
 		$pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
-		$this->backendReference->addJavascriptFile('js/livesearch.js');
+		$this->backendReference->addJavascriptFile('sysext/backend/Resources/Public/JavaScript/livesearch.js');
 	}
 
 	/**
diff --git a/typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem.php b/typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem.php
index b04a49ef5d42..de33f35c8c62 100644
--- a/typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem.php
+++ b/typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem.php
@@ -204,7 +204,7 @@ class ShortcutToolbarItem implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookI
 	 * @return void
 	 */
 	protected function addJavascriptToBackend() {
-		$this->backendReference->addJavascriptFile('js/shortcutmenu.js');
+		$this->backendReference->addJavascriptFile('sysext/backend/Resources/Public/JavaScript/shortcutmenu.js');
 	}
 
 	/**
diff --git a/typo3/js/backend.js b/typo3/sysext/backend/Resources/Public/JavaScript/backend.js
similarity index 100%
rename from typo3/js/backend.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/backend.js
diff --git a/typo3/js/clearcachemenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/clearcachemenu.js
similarity index 100%
rename from typo3/js/clearcachemenu.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/clearcachemenu.js
diff --git a/typo3/js/common.js b/typo3/sysext/backend/Resources/Public/JavaScript/common.js
similarity index 100%
rename from typo3/js/common.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/common.js
diff --git a/typo3/js/iecompatibility.js b/typo3/sysext/backend/Resources/Public/JavaScript/iecompatibility.js
similarity index 100%
rename from typo3/js/iecompatibility.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/iecompatibility.js
diff --git a/typo3/js/livesearch.js b/typo3/sysext/backend/Resources/Public/JavaScript/livesearch.js
similarity index 100%
rename from typo3/js/livesearch.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/livesearch.js
diff --git a/typo3/js/modulemenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js
similarity index 100%
rename from typo3/js/modulemenu.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js
diff --git a/typo3/js/pagetreefiltermenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/pagetreefiltermenu.js
similarity index 100%
rename from typo3/js/pagetreefiltermenu.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/pagetreefiltermenu.js
diff --git a/typo3/js/shortcutmenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/shortcutmenu.js
similarity index 100%
rename from typo3/js/shortcutmenu.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/shortcutmenu.js
diff --git a/typo3/js/tabmenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/tabmenu.js
similarity index 100%
rename from typo3/js/tabmenu.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/tabmenu.js
diff --git a/typo3/js/toolbarmanager.js b/typo3/sysext/backend/Resources/Public/JavaScript/toolbarmanager.js
similarity index 100%
rename from typo3/js/toolbarmanager.js
rename to typo3/sysext/backend/Resources/Public/JavaScript/toolbarmanager.js
-- 
GitLab