db65a90f79b6ac559eeb51c7535f67dd8b3b7fe1
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Public / JavaScript / backend.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14
15 /**
16 * common storage and global object, could later hold more information about the current user etc.
17 */
18 var TYPO3 = TYPO3 || {};
19
20 /**
21 * jump the backend to a module
22 */
23 function jump(url, modName, mainModName, pageId) {
24 if (isNaN(pageId)) {
25 pageId = -2;
26 }
27 // clear information about which entry in nav. tree that might have been highlighted.
28 top.fsMod.navFrameHighlightedID = [];
29 top.fsMod.recentIds['web'] = pageId;
30
31 top.nextLoadModuleUrl = url;
32 top.TYPO3.ModuleMenu.App.showModule(modName);
33 }
34
35 /**
36 * Function similar to PHPs rawurlencode();
37 */
38 function rawurlencode(str) {
39 var output = encodeURIComponent(str);
40 output = str_replace("*", "%2A", output);
41 output = str_replace("+", "%2B", output);
42 output = str_replace("/", "%2F", output);
43 output = str_replace("@", "%40", output);
44 return output;
45 }
46
47
48 /**
49 * String-replace function
50 */
51 function str_replace(match, replace, string) { //
52 var input = "" + string;
53 var matchStr = "" + match;
54 if (!matchStr) {
55 return string;
56 }
57 var output = "";
58 var pointer = 0;
59 var pos = input.indexOf(matchStr);
60 while (pos !== -1) {
61 output += "" + input.substr(pointer, pos - pointer) + replace;
62 pointer = pos + matchStr.length;
63 pos = input.indexOf(match, pos + 1);
64 }
65 output += "" + input.substr(pointer);
66 return output;
67 }
68
69
70 /**
71 * Launcing information window for records/files (fileref as "table" argument)
72 */
73 function launchView(table, uid) {
74 console.warn('Calling launchView() has been deprecated in v9 and will be removed in v10.0');
75 var thePreviewWindow = window.open(TYPO3.settings.ShowItem.moduleUrl + '&table=' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
76 "ShowItem" + Math.random().toString(16).slice(2),
77 "width=650,height=600,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
78 if (thePreviewWindow && thePreviewWindow.focus) {
79 thePreviewWindow.focus();
80 }
81 }
82
83 /**
84 * Opens plain window with url
85 */
86 function openUrlInWindow(url, windowName) { //
87 regularWindow = window.open(
88 url,
89 windowName,
90 "status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
91 regularWindow.focus();
92 return false;
93 }
94
95 /**
96 * Loads a page id for editing in the page edit module:
97 */
98 function loadEditId(id, addGetVars) { //
99 top.fsMod.recentIds.web = id;
100 top.fsMod.navFrameHighlightedID.web = "pages" + id + "_0"; // For highlighting
101
102 if (top.nav_frame && top.nav_frame.refresh_nav) {
103 top.nav_frame.refresh_nav();
104 }
105 if (TYPO3.configuration.pageModule) {
106 top.goToModule(TYPO3.configuration.pageModule, 0, addGetVars ? addGetVars : "");
107 }
108 }
109
110 /**
111 * Returns incoming URL (to a module) unless nextLoadModuleUrl is set. If that is the case nextLoadModuleUrl is returned (and cleared)
112 * Used by the shortcut frame to set a "intermediate URL"
113 */
114 var nextLoadModuleUrl = "";
115
116 function getModuleUrl(inUrl) { //
117 var nMU;
118 if (top.nextLoadModuleUrl) {
119 nMU = top.nextLoadModuleUrl;
120 top.nextLoadModuleUrl = "";
121 return nMU;
122 } else {
123 return inUrl;
124 }
125 }
126
127 // Used by Frameset Modules
128 var currentSubScript = "";