d8a0a3db1627abe52b021c95b977ea7ffd9028a1
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Public / JavaScript / jsfunc.tbe_editor.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 * Contains JavaScript for TYPO3 Core Form generator - AKA "TCEforms"
16 *
17 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
18 * @coauthor Oliver Hader <oh@inpublica.de>
19 */
20
21
22 var TBE_EDITOR = {
23 /* Example:
24 elements: {
25 'data-parentPid-table-uid': {
26 'field': {
27 'range': [0, 100],
28 'rangeImg': '',
29 'required': true,
30 'requiredImg': ''
31 }
32 }
33 },
34 */
35
36 elements: {},
37 nested: {'field':{}, 'level':{}},
38 ignoreElements: [],
39 recentUpdatedElements: {},
40 actionChecks: { submit: [] },
41
42 formname: '',
43 formnameUENC: '',
44 isChanged: 0,
45
46 backPath: '',
47 prependFormFieldNames: 'data',
48 prependFormFieldNamesUENC: 'data',
49 prependFormFieldNamesCnt: 0,
50
51 isPalettedoc: null,
52 doSaveFieldName: 0,
53
54 labels: {},
55 images: {
56 req: new Image(),
57 cm: new Image(),
58 sel: new Image(),
59 clear: new Image()
60 },
61
62 clearBeforeSettingFormValueFromBrowseWin: [],
63
64 // Handling of data structures:
65 addElements: function(elements) {
66 TBE_EDITOR.recentUpdatedElements = elements;
67 TBE_EDITOR.elements = $H(TBE_EDITOR.elements).merge(elements).toObject();
68 },
69 addNested: function(elements) {
70 // Merge data structures:
71 if (elements) {
72 $H(elements).each(function(element) {
73 var levelMax, i, currentLevel, subLevel;
74 var nested = element.value;
75 if (nested.level && nested.level.length) {
76 // If the first level is of type 'inline', it could be created by a AJAX request to IRRE.
77 // So, try to get the upper levels this dynamic level is nested in:
78 if (typeof inline!='undefined' && nested.level[0][0]=='inline') {
79 nested.level = inline.findContinuedNestedLevel(nested.level, nested.level[0][1]);
80 }
81 levelMax = nested.level.length-1;
82 for (i=0; i<=levelMax; i++) {
83 currentLevel = TBE_EDITOR.getNestedLevelIdent(nested.level[i]);
84 if (typeof TBE_EDITOR.nested.level[currentLevel] == 'undefined') {
85 TBE_EDITOR.nested.level[currentLevel] = { 'clean': true, 'item': {}, 'sub': {} };
86 }
87 // Add next sub level to the current level:
88 if (i<levelMax) {
89 subLevel = TBE_EDITOR.getNestedLevelIdent(nested.level[i+1]);
90 TBE_EDITOR.nested.level[currentLevel].sub[subLevel] = true;
91 // Add the current item to the last level in nesting:
92 } else {
93 TBE_EDITOR.nested.level[currentLevel].item[element.key] = nested.parts;
94 }
95 }
96 }
97 });
98 // Merge the nested fields:
99 TBE_EDITOR.nested.field = $H(TBE_EDITOR.nested.field).merge(elements).toObject();
100 }
101 },
102 removeElement: function(record) {
103 if (TBE_EDITOR.elements && TBE_EDITOR.elements[record]) {
104 // Inform envolved levels the this record is removed and the missing requirements are resolved:
105 $H(TBE_EDITOR.elements[record]).each(
106 function(pair) {
107 TBE_EDITOR.notifyNested(record+'['+pair.key+']', true);
108 }
109 );
110 delete(TBE_EDITOR.elements[record]);
111 }
112 },
113 removeElementArray: function(removeStack) {
114 if (removeStack && removeStack.length) {
115 TBE_EDITOR.ignoreElements = removeStack;
116 for (var i=removeStack.length; i>=0; i--) {
117 TBE_EDITOR.removeElement(removeStack[i]);
118 }
119 TBE_EDITOR.ignoreElements = [];
120 }
121 },
122 getElement: function(record, field, type) {
123 var result = null;
124 var element;
125
126 if (TBE_EDITOR.elements && TBE_EDITOR.elements[record] && TBE_EDITOR.elements[record][field]) {
127 element = TBE_EDITOR.elements[record][field];
128 if (type) {
129 if (element[type]) result = element;
130 } else {
131 result = element;
132 }
133 }
134
135 return result;
136 },
137 checkElements: function(type, recentUpdated, record, field) {
138 var result = 1;
139 var elementName, elementData, elementRecord, elementField;
140 var source = (recentUpdated ? TBE_EDITOR.recentUpdatedElements : TBE_EDITOR.elements);
141
142 if (TBE_EDITOR.ignoreElements.length && TBE_EDITOR.ignoreElements.indexOf(record)!=-1) {
143 return result;
144 }
145
146 if (type) {
147 if (record && field) {
148 elementName = record+'['+field+']';
149 elementData = TBE_EDITOR.getElement(record, field, type);
150 if (elementData) {
151 if (!TBE_EDITOR.checkElementByType(type, elementName, elementData, recentUpdated)) {
152 result = 0;
153 }
154 }
155
156 } else {
157 var elementFieldList, elRecIndex, elRecCnt, elFldIndex, elFldCnt;
158 var elementRecordList = $H(source).keys();
159 for (elRecIndex=0, elRecCnt=elementRecordList.length; elRecIndex<elRecCnt; elRecIndex++) {
160 elementRecord = elementRecordList[elRecIndex];
161 elementFieldList = $H(source[elementRecord]).keys();
162 for (elFldIndex=0, elFldCnt=elementFieldList.length; elFldIndex<elFldCnt; elFldIndex++) {
163 elementField = elementFieldList[elFldIndex];
164 elementData = TBE_EDITOR.getElement(elementRecord, elementField, type);
165 if (elementData) {
166 elementName = elementRecord+'['+elementField+']';
167 if (!TBE_EDITOR.checkElementByType(type, elementName, elementData, recentUpdated)) {
168 result = 0;
169 }
170 }
171 }
172 }
173 }
174 }
175
176 return result;
177 },
178 checkElementByType: function(type, elementName, elementData, autoNotify) {
179 var form, result = 1;
180
181 if (type) {
182 if (type == 'required') {
183 form = document[TBE_EDITOR.formname][elementName];
184 if (form) {
185 // Check if we are within a deleted inline element
186 var testNode = $(form.parentNode);
187 while(testNode) {
188 if (testNode.hasClassName && testNode.hasClassName('inlineIsDeletedRecord')) {
189 return result;
190 }
191 testNode = $(testNode.parentNode);
192 }
193
194 var value = form.value;
195 if (!value || elementData.additional && elementData.additional.isPositiveNumber && (isNaN(value) || Number(value) <= 0)) {
196 result = 0;
197 if (autoNotify) {
198 TBE_EDITOR.setImage('req_'+elementData.requiredImg, TBE_EDITOR.images.req);
199 TBE_EDITOR.notifyNested(elementName, false);
200 }
201 }
202 }
203 } else if (type == 'range' && elementData.range) {
204 var numberOfElements = 0;
205 form = document[TBE_EDITOR.formname][elementName+'_list'];
206 if (!form) {
207 // special treatment for IRRE fields:
208 var tempObj = document[TBE_EDITOR.formname][elementName];
209 if (tempObj && (Element.hasClassName(tempObj, 'inlineRecord') || Element.hasClassName(tempObj, 'treeRecord'))) {
210 form = tempObj.value ? tempObj.value.split(',') : [];
211 numberOfElements = form.length;
212 }
213
214 } else {
215 // special treatment for file uploads
216 var tempObj = document[TBE_EDITOR.formname][elementName.replace(/^data/, 'data_files') + '[]'];
217 numberOfElements = form.length;
218
219 if (tempObj && tempObj.type == 'file' && tempObj.value) {
220 numberOfElements++; // Add new uploaded file to the number of elements
221 }
222 }
223
224 if (!TBE_EDITOR.checkRange(numberOfElements, elementData.range[0], elementData.range[1])) {
225 result = 0;
226 if (autoNotify) {
227 TBE_EDITOR.setImage('req_'+elementData.rangeImg, TBE_EDITOR.images.req);
228 TBE_EDITOR.notifyNested(elementName, false);
229 }
230 }
231 }
232 }
233
234 return result;
235 },
236 // Notify tabs and inline levels with nested requiredFields/requiredElements:
237 notifyNested: function(elementName, resolved) {
238 if (TBE_EDITOR.nested.field[elementName]) {
239 var i, nested, element, fieldLevels, fieldLevelIdent, nestedLevelType, nestedLevelName;
240 fieldLevels = TBE_EDITOR.nested.field[elementName].level;
241 TBE_EDITOR.nestedCache = {};
242
243 for (i=fieldLevels.length-1; i>=0; i--) {
244 nestedLevelType = fieldLevels[i][0];
245 nestedLevelName = fieldLevels[i][1];
246 fieldLevelIdent = TBE_EDITOR.getNestedLevelIdent(fieldLevels[i]);
247 // Construct the CSS id strings of the image/icon tags showing the notification:
248 if (nestedLevelType == 'tab') {
249 element = nestedLevelName+'-REQ';
250 } else if (nestedLevelType == 'inline') {
251 element = nestedLevelName+'_req';
252 } else {
253 continue;
254 }
255 // Set the icons:
256 if (resolved) {
257 if (TBE_EDITOR.checkNested(fieldLevelIdent)) {
258 TBE_EDITOR.setImage(element, TBE_EDITOR.images.clear);
259 } else {
260 break;
261 }
262 } else {
263 if (TBE_EDITOR.nested.level && TBE_EDITOR.nested.level[fieldLevelIdent]) {
264 TBE_EDITOR.nested.level[fieldLevelIdent].clean = false;
265 }
266 TBE_EDITOR.setImage(element, TBE_EDITOR.images.req);
267 }
268 }
269 }
270 },
271 // Check all the input fields on a given level of nesting - if only on is unfilled, the whole level is marked as required:
272 checkNested: function(nestedLevelIdent) {
273 var nestedLevel, isClean;
274 if (nestedLevelIdent && TBE_EDITOR.nested.level && TBE_EDITOR.nested.level[nestedLevelIdent]) {
275 nestedLevel = TBE_EDITOR.nested.level[nestedLevelIdent];
276 if (!nestedLevel.clean) {
277 if (typeof nestedLevel.item == 'object') {
278 $H(nestedLevel.item).each(
279 function(pair) {
280 if (isClean || typeof isClean == 'undefined') {
281 isClean = (
282 TBE_EDITOR.checkElements('required', false, pair.value[0], pair.value[1]) &&
283 TBE_EDITOR.checkElements('range', false, pair.value[0], pair.value[1])
284 );
285 }
286 }
287 );
288 if (typeof isClean != 'undefined' && !isClean) {
289 return false;
290 }
291 }
292 if (typeof nestedLevel.sub == 'object') {
293 $H(nestedLevel.sub).each(
294 function(pair) {
295 if (isClean || typeof isClean == 'undefined') {
296 isClean = TBE_EDITOR.checkNested(pair.key);
297 }
298 }
299 );
300 if (typeof isClean != 'undefined' && !isClean) {
301 return false;
302 }
303 }
304 // Store the result, that this level (the fields on this and the sub levels) are clean:
305 nestedLevel.clean = true;
306 }
307 }
308 return true;
309 },
310 getNestedLevelIdent: function(level) {
311 return level.join('::');
312 },
313 addActionChecks: function(type, checks) {
314 TBE_EDITOR.actionChecks[type].push(checks);
315 },
316
317 fieldChanged_fName: function(fName,el) {
318 var idx=2+TBE_EDITOR.prependFormFieldNamesCnt;
319 var table = TBE_EDITOR.split(fName, "[", idx);
320 var uid = TBE_EDITOR.split(fName, "[", idx+1);
321 var field = TBE_EDITOR.split(fName, "[", idx+2);
322
323 table = table.substr(0,table.length-1);
324 uid = uid.substr(0,uid.length-1);
325 field = field.substr(0,field.length-1);
326 TBE_EDITOR.fieldChanged(table,uid,field,el);
327 },
328 fieldChanged: function(table,uid,field,el) {
329 var theField = TBE_EDITOR.prependFormFieldNames+'['+table+']['+uid+']['+field+']';
330 var theRecord = TBE_EDITOR.prependFormFieldNames+'['+table+']['+uid+']';
331 TBE_EDITOR.isChanged = 1;
332
333 // modify the "field has changed" info by adding a class to the container element (based on palette or main field)
334 var $formField = TYPO3.jQuery('[name="' + el + '"]');
335 var $paletteField = $formField.closest('.t3js-formengine-palette-field');
336 $paletteField.addClass('has-change');
337
338 // Set required flag:
339 var imgReqObjName = "req_"+table+"_"+uid+"_"+field;
340 if (TBE_EDITOR.getElement(theRecord,field,'required') && document[TBE_EDITOR.formname][theField]) {
341 if (TBE_EDITOR.checkElements('required', false, theRecord, field)) {
342 TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.clear);
343 TBE_EDITOR.notifyNested(theField, true);
344 } else {
345 TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.req);
346 TBE_EDITOR.notifyNested(theField, false);
347 }
348 }
349 if (TBE_EDITOR.getElement(theRecord,field,'range') && document[TBE_EDITOR.formname][theField]) {
350 if (TBE_EDITOR.checkElements('range', false, theRecord, field)) {
351 TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.clear);
352 TBE_EDITOR.notifyNested(theField, true);
353 } else {
354 TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.req);
355 TBE_EDITOR.notifyNested(theField, false);
356 }
357 }
358
359 if (TBE_EDITOR.isPalettedoc) { TBE_EDITOR.setOriginalFormFieldValue(theField) };
360 },
361 setOriginalFormFieldValue: function(theField) {
362 if (TBE_EDITOR.isPalettedoc && (TBE_EDITOR.isPalettedoc).document[TBE_EDITOR.formname] && (TBE_EDITOR.isPalettedoc).document[TBE_EDITOR.formname][theField]) {
363 (TBE_EDITOR.isPalettedoc).document[TBE_EDITOR.formname][theField].value = document[TBE_EDITOR.formname][theField].value;
364 }
365 },
366 isFormChanged: function(noAlert) {
367 if (TBE_EDITOR.isChanged && !noAlert && confirm(TBE_EDITOR.labels.fieldsChanged)) {
368 return 0;
369 }
370 return TBE_EDITOR.isChanged;
371 },
372 checkAndDoSubmit: function(sendAlert) {
373 if (TBE_EDITOR.checkSubmit(sendAlert)) { TBE_EDITOR.submitForm(); }
374 },
375 /**
376 * Checks if the form can be submitted according to any possible restrains like required values, item numbers etc.
377 * Returns true if the form can be submitted, otherwise false (and might issue an alert message, if "sendAlert" is 1)
378 * If "sendAlert" is false, no error message will be shown upon false return value (if "1" then it will).
379 * If "sendAlert" is "-1" then the function will ALWAYS return true regardless of constraints (except if login has expired) - this is used in the case where a form field change requests a form update and where it is accepted that constraints are not observed (form layout might change so other fields are shown...)
380 */
381 checkSubmit: function(sendAlert) {
382 var funcIndex, funcMax, funcRes;
383 var OK=1;
384
385 // $this->additionalJS_submit:
386 if (TBE_EDITOR.actionChecks && TBE_EDITOR.actionChecks.submit) {
387 for (funcIndex=0, funcMax=TBE_EDITOR.actionChecks.submit.length; funcIndex<funcMax; funcIndex++) {
388 try {
389 eval(TBE_EDITOR.actionChecks.submit[funcIndex]);
390 } catch(error) {}
391 }
392 }
393
394 if(!OK) {
395 if (!confirm(unescape("SYSTEM ERROR: One or more Rich Text Editors on the page could not be contacted. This IS an error, although it should not be regular.\nYou can save the form now by pressing OK, but you will loose the Rich Text Editor content if you do.\n\nPlease report the error to your administrator if it persists."))) {
396 return false;
397 } else {
398 OK = 1;
399 }
400 }
401 // $reqLinesCheck
402 if (!TBE_EDITOR.checkElements('required', false)) { OK = 0; }
403 // $reqRangeCheck
404 if (!TBE_EDITOR.checkElements('range', false)) { OK = 0; }
405
406 if (OK || sendAlert==-1) {
407 return true;
408 } else {
409 if(sendAlert) alert(TBE_EDITOR.labels.fieldsMissing);
410 return false;
411 }
412 },
413 checkRange: function(numberOfElements, lower, upper) {
414 // for backwards compatibility, check if we're dealing with an element as first parameter
415 if(typeof numberOfElements == 'object') {
416 numberOfElements = numberOfElements.length;
417 }
418
419 if (numberOfElements >= lower && numberOfElements <= upper) {
420 return true;
421 } else {
422 return false;
423 }
424 },
425 initRequired: function() {
426 // $reqLinesCheck
427 TBE_EDITOR.checkElements('required', true);
428
429 // $reqRangeCheck
430 TBE_EDITOR.checkElements('range', true);
431 },
432 setImage: function(name,image) {
433 var object;
434 if (document[name]) {
435 object = document[name];
436 } else if (document.getElementById(name)) {
437 object = document.getElementById(name);
438 }
439 if (object) {
440 if (typeof image == 'object') {
441 document[name].src = image.src;
442 } else {
443 document[name].src = eval(image+'.src');
444 }
445 }
446 },
447 submitForm: function() {
448 if (TBE_EDITOR.doSaveFieldName) {
449 document[TBE_EDITOR.formname][TBE_EDITOR.doSaveFieldName].value=1;
450 }
451 // Set a short timeout to allow other JS processes to complete, in particular those from
452 // EXT:backend/Resources/Public/JavaScript/FormEngine.js (reference: http://forge.typo3.org/issues/58755).
453 // TODO: This should be solved in a better way when this script is refactored.
454 window.setTimeout('document[TBE_EDITOR.formname].submit()', 10);
455 },
456 split: function(theStr1, delim, index) {
457 var theStr = ""+theStr1;
458 var lengthOfDelim = delim.length;
459 sPos = -lengthOfDelim;
460 if (index<1) {index=1;}
461 for (var a=1; a<index; a++) {
462 sPos = theStr.indexOf(delim, sPos+lengthOfDelim);
463 if (sPos==-1) { return null; }
464 }
465 ePos = theStr.indexOf(delim, sPos+lengthOfDelim);
466 if(ePos == -1) { ePos = theStr.length; }
467 return (theStr.substring(sPos+lengthOfDelim,ePos));
468 },
469 curSelected: function(theField) {
470 var fObjSel = document[TBE_EDITOR.formname][theField];
471 var retVal="";
472 if (fObjSel) {
473 if (fObjSel.type=='select-multiple' || fObjSel.type=='select-one') {
474 var l=fObjSel.length;
475 for (a=0;a<l;a++) {
476 if (fObjSel.options[a].selected==1) {
477 retVal+=fObjSel.options[a].value+",";
478 }
479 }
480 }
481 }
482 return retVal;
483 },
484 rawurlencode: function(str,maxlen) {
485 var output = str;
486 if (maxlen) output = output.substr(0,200);
487 output = encodeURIComponent(output);
488 return output;
489 },
490 str_replace: function(match,replace,string) {
491 var input = ''+string;
492 var matchStr = ''+match;
493 if (!matchStr) { return string; }
494 var output = '';
495 var pointer=0;
496 var pos = input.indexOf(matchStr);
497 while (pos!=-1) {
498 output+=''+input.substr(pointer, pos-pointer)+replace;
499 pointer=pos+matchStr.length;
500 pos = input.indexOf(match,pos+1);
501 }
502 output+=''+input.substr(pointer);
503 return output;
504 },
505 toggle_display_states: function(id, state_1, state_2) {
506 var node = document.getElementById(id);
507 if (node) {
508 switch (node.style.display) {
509 case state_1:
510 node.style.display = state_2;
511 break;
512 case state_2:
513 node.style.display = state_1;
514 break;
515 }
516 }
517 return false;
518 },
519
520 /**
521 * Determines backend path to be used for e.g. ajax.php
522 * @return string
523 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
524 */
525 getBackendPath: function() {
526 if (typeof console != 'undefined') {
527 console.log('TS.getBackendPath() is deprecated since TYPO3 CMS 7, and will be removed in TYPO3 CMS 8.');
528 }
529 if (TYPO3) {
530 if (TYPO3.configuration && TYPO3.configuration.PATH_typo3) {
531 backendPath = TYPO3.configuration.PATH_typo3;
532 } else if (TYPO3.settings && TYPO3.settings.PATH_typo3) {
533 backendPath = TYPO3.settings.PATH_typo3;
534 }
535 }
536 return backendPath;
537 }
538 };
539
540 function typoSetup () {
541 this.passwordDummy = '********';
542 this.decimalSign = '.';
543 }
544 var TS = new typoSetup();
545 var evalFunc = new evalFunc();
546
547 // backwards compatibility for extensions
548 var TBE_EDITOR_setHiddenContent = TBE_EDITOR.setHiddenContent;
549 var TBE_EDITOR_isChanged = TBE_EDITOR.isChanged;
550 var TBE_EDITOR_fieldChanged_fName = TBE_EDITOR.fieldChanged_fName;
551 var TBE_EDITOR_fieldChanged = TBE_EDITOR.fieldChanged;
552 var TBE_EDITOR_setOriginalFormFieldValue = TBE_EDITOR.setOriginalFormFieldValue;
553 var TBE_EDITOR_isFormChanged = TBE_EDITOR.isFormChanged;
554 var TBE_EDITOR_checkAndDoSubmit = TBE_EDITOR.checkAndDoSubmit;
555 var TBE_EDITOR_checkSubmit = TBE_EDITOR.checkSubmit;
556 var TBE_EDITOR_checkRange = TBE_EDITOR.checkRange;
557 var TBE_EDITOR_initRequired = TBE_EDITOR.initRequired;
558 var TBE_EDITOR_setImage = TBE_EDITOR.setImage;
559 var TBE_EDITOR_submitForm = TBE_EDITOR.submitForm;
560 var TBE_EDITOR_split = TBE_EDITOR.split;
561 var TBE_EDITOR_curSelected = TBE_EDITOR.curSelected;
562 var TBE_EDITOR_rawurlencode = TBE_EDITOR.rawurlencode;
563 var TBE_EDITOR_str_replace = TBE_EDITOR.str_replace;
564
565
566 var typo3form = {
567 fieldSetNull: function(fieldName, isNull) {
568 if (document[TBE_EDITOR.formname][fieldName]) {
569 var formFieldItemWrapper = Element.up(document[TBE_EDITOR.formname][fieldName], '.t3js-formengine-field-item');
570
571 if (isNull) {
572 formFieldItemWrapper.addClassName('disabled');
573 } else {
574 formFieldItemWrapper.removeClassName('disabled');
575 }
576 }
577 },
578 fieldTogglePlaceholder: function(fieldName, showPlaceholder) {
579 if (!document[TBE_EDITOR.formname][fieldName]) {
580 return;
581 }
582
583 var formFieldItemWrapper = Element.up(document[TBE_EDITOR.formname][fieldName], '.t3js-formengine-field-item');
584 var placeholder = formFieldItemWrapper.select('.t3js-formengine-placeholder-placeholder')[0];
585 var formField = formFieldItemWrapper.select('.t3js-formengine-placeholder-formfield')[0];
586 if (showPlaceholder) {
587 placeholder.show();
588 formField.hide();
589 } else {
590 placeholder.hide();
591 formField.show();
592 }
593 },
594 fieldSet: function(theField, evallist, is_in, checkbox, checkboxValue) {
595 var i;
596
597 if (document[TBE_EDITOR.formname][theField]) {
598 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
599 var theValue = document[TBE_EDITOR.formname][theField].value;
600 if (checkbox && theValue==checkboxValue) {
601 document[TBE_EDITOR.formname][theField+"_hr"].value="";
602 if (document[TBE_EDITOR.formname][theField+"_cb"]) document[TBE_EDITOR.formname][theField+"_cb"].checked = "";
603 } else {
604 document[TBE_EDITOR.formname][theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
605 if (document[TBE_EDITOR.formname][theField+"_cb"]) document[TBE_EDITOR.formname][theField+"_cb"].checked = "on";
606 }
607 }
608 },
609 fieldGet: function(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off, checkSetValue) {
610 if (document[TBE_EDITOR.formname][theField]) {
611 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
612 if (checkbox_off) {
613 if (document[TBE_EDITOR.formname][theField+"_cb"].checked) {
614 var split = evallist.split(',');
615 for (var i = 0; split.length > i; i++) {
616 var el = split[i].replace(/ /g, '');
617 if (el == 'datetime' || el == 'date') {
618 var now = new Date();
619 checkSetValue = Date.parse(now)/1000 - now.getTimezoneOffset()*60;
620 break;
621 } else if (el == 'time' || el == 'timesec') {
622 checkSetValue = evalFunc_getTimeSecs(new Date());
623 break;
624 }
625 }
626 document[TBE_EDITOR.formname][theField].value=checkSetValue;
627 } else {
628 document[TBE_EDITOR.formname][theField].value=checkboxValue;
629 }
630 }else{
631 document[TBE_EDITOR.formname][theField].value = evalFunc.evalObjValue(theFObj, document[TBE_EDITOR.formname][theField+"_hr"].value);
632 }
633 typo3form.fieldSet(theField, evallist, is_in, checkbox, checkboxValue);
634 }
635 }
636 };
637
638 // backwards compatibility for extensions
639 var typo3FormFieldSet = typo3form.fieldSet;
640 var typo3FormFieldGet = typo3form.fieldGet;