6717196d893f38a660ae82ad2e91d58fb890aa82
[Packages/TYPO3.CMS.git] / typo3 / sysext / pagetree / components / pagetree / javascript / actions.js
1 Ext.namespace('TYPO3.Components.PageTree');
2
3 TYPO3.Components.PageTree.Actions = {
4 evaluateResponse: function(response) {
5 if (response.success === false) {
6 TYPO3.Flashmessage.display(4, 'Exception', response.message);
7 return false;
8 }
9
10 return true;
11 },
12
13 removeNode: function(node) {
14 TYPO3.Components.PageTree.Commands.deleteNode(
15 node.attributes.nodeData,
16 function(response) {
17 if (this.evaluateResponse(response)) {
18 node.remove();
19 }
20 },
21 this
22 );
23 },
24
25 restoreNode: function(node) {
26 TYPO3.Components.PageTree.Commands.restoreNode(node.attributes.nodeData);
27 },
28
29 stub: function() {
30 alert('Just a Stub! Don\'t Panic!');
31 },
32
33 viewPage: function(node) {
34 TYPO3.Components.PageTree.Commands.getViewLink(
35 node.attributes.nodeData,
36 (TYPO3.configuration.workspaceFrontendPreviewEnabled && TYPO3.configuration.currentWorkspace != 0),
37 function(result) {
38 openUrlInWindow(result, 'typo3-contextMenu-view');
39 }
40 );
41 },
42
43 editPageProperties: function(node) {
44 TYPO3.Backend.ContentContainer.setUrl(
45 'alt_doc.php?edit[pages][' + node.attributes.id + ']=edit'
46 );
47 },
48
49 newPageWizard: function(node) {
50 TYPO3.Backend.ContentContainer.setUrl(
51 'db_new.php?id=' + node.attributes.id + '&pagesOnly=1'
52 );
53 },
54
55 openInfoPopUp: function(node) {
56 launchView('pages', node.attributes.id);
57 },
58
59 openHistoryPopUp: function(node) {
60 TYPO3.Backend.ContentContainer.setUrl(
61 'show_rechis.php?element=pages:' + node.attributes.id
62 );
63 },
64
65 enableCutMode: function(node, pageTree) {
66 this.disableCopyMode(node, pageTree);
67 node.attributes.nodeData.t3InCutMode = true;
68 pageTree.tree.t3ContextInfo.inCutMode = true;
69 pageTree.tree.t3ContextNode = node;
70 },
71
72 disableCutMode: function(node, pageTree) {
73 this.releaseCutAndCopyModes(pageTree);
74 node.attributes.nodeData.t3InCutMode = false;
75 },
76
77 enableCopyMode: function(node, pageTree) {
78 this.disableCutMode(node, pageTree);
79 node.attributes.nodeData.t3InCopyMode = true;
80 pageTree.tree.t3ContextInfo.inCopyMode = true;
81 pageTree.tree.t3ContextNode = node;
82 },
83
84 disableCopyMode: function(node, pageTree) {
85 this.releaseCutAndCopyModes(pageTree);
86 node.attributes.nodeData.t3InCopyMode = false;
87 },
88
89 pasteIntoNode: function(node, pageTree) {
90 this.releaseCutAndCopyModes(pageTree);
91 this.stub();
92 },
93
94 pasteAfterNode: function(node, pageTree) {
95 this.releaseCutAndCopyModes(pageTree);
96 this.stub();
97 },
98
99 releaseCutAndCopyModes: function(pageTree) {
100 pageTree.tree.t3ContextInfo.inCutMode = false;
101 pageTree.tree.t3ContextInfo.inCopyMode = false;
102
103 if (pageTree.tree.t3ContextNode) {
104 pageTree.tree.t3ContextNode.attributes.nodeData.t3InCutMode = false;
105 pageTree.tree.t3ContextNode.attributes.nodeData.t3InCopyMode = false;
106 pageTree.tree.t3ContextNode = null;
107 }
108 },
109
110 moveNodeToFirstChildOfDestination: function(node, newParent) {
111 TYPO3.Components.PageTree.Commands.moveNodeToFirstChildOfDestination(
112 node.attributes.nodeData,
113 newParent
114 );
115 },
116
117 moveNodeAfterDestination: function(node, newParent) {
118 TYPO3.Components.PageTree.Commands.moveNodeAfterDestination(
119 node.attributes.nodeData,
120 newParent
121 );
122 },
123
124 insertNodeAfterDestination: function(node, callback) {
125 TYPO3.Components.PageTree.Commands.insertNodeAfterDestination(
126 node.parentNode.attributes.nodeData,
127 node.previousSibling.id,
128 node.serverNodeType,
129 callback.createDelegate(node)
130 );
131 },
132
133 insertNodeToFirstChildOfDestination: function(node, callback) {
134 TYPO3.Components.PageTree.Commands.insertNodeToFirstChildOfDestination(
135 node.parentNode.attributes.nodeData,
136 node.serverNodeType,
137 callback.createDelegate(node)
138 );
139 },
140
141 copyNodeToFirstChildOfDestination: function(node, callback) {
142 TYPO3.Components.PageTree.Commands.copyNodeToFirstChildOfDestination(
143 node.attributes.nodeData,
144 node.parentNode.id,
145 callback.createDelegate(node)
146 );
147 },
148
149 copyNodeAfterDestination: function(node, callback) {
150 TYPO3.Components.PageTree.Commands.copyNodeAfterDestination(
151 node.attributes.nodeData,
152 node.previousSibling.id,
153 callback.createDelegate(node)
154 );
155 },
156
157 enablePage: function(node) {
158 TYPO3.Components.PageTree.Commands.visiblyNode(
159 node.attributes.nodeData,
160 function(response) {
161 if (this.evaluateResponse(response)) {
162 this.updateNode(node, response);
163 }
164 },
165 this
166 );
167 },
168
169 disablePage: function(node) {
170 TYPO3.Components.PageTree.Commands.disableNode(
171 node.attributes.nodeData,
172 function(response) {
173 if (this.evaluateResponse(response)) {
174 this.updateNode(node, response);
175 }
176 },
177 this
178 );
179 },
180
181 updateNode: function(node, updatedNode) {
182 updatedNode.uiProvider = TYPO3.Components.PageTree.PageTreeUI;
183 var newTreeNode = new Ext.tree.TreeNode(updatedNode);
184 node.parentNode.replaceChild(newTreeNode, node);
185 newTreeNode.getOwnerTree().refreshNode(newTreeNode);
186 },
187
188 singleClick: function(node) {
189 TYPO3.Backend.ContentContainer.setUrl(
190 TS.PATH_typo3 + currentSubScript + '?id=' + node.attributes.id
191 );
192 },
193
194 saveTitle: function(node, newText, oldText) {
195 if (newText === oldText) {
196 return;
197 }
198
199 TYPO3.Components.PageTree.Commands.updateLabel(
200 node.editNode.attributes.nodeData,
201 newText,
202 this.evaluateResponse
203 );
204 }
205 };