Bug #20829 » tceforms_datepicker_v6.diff
t3lib/class.t3lib_tceforms.php (working copy) | ||
---|---|---|
}
|
||
$GLOBALS['SOBE']->doc->loadPrototype();
|
||
$GLOBALS['SOBE']->doc->loadExtJS();
|
||
$this->loadJavascriptLib('../t3lib/jsfunc.evalfield.js');
|
||
// @TODO: Change to loadJavascriptLib(), but fix "TS = new typoScript()" issue first - see bug #9494
|
||
$jsFile[] = '<script type="text/javascript" src="'.$this->backPath.'jsfunc.tbe_editor.js"></script>';
|
||
|
||
//needed for tceform manipulation (datePicker)
|
||
$typo3Settings = array(
|
||
'datePickerIcon' => t3lib_iconWorks::skinImg($this->backPath, 'gfx/datepicker.gif', '', 1),
|
||
'useDatePicker' => 1,
|
||
'datePickerUSmode' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? 1 : 0,
|
||
'dateFormat' => array('j-n-Y', 'G:i j-n-Y'),
|
||
'dateFormatUS' => array('n-j-Y', 'G:i n-j-Y'),
|
||
);
|
||
$out .= '
|
||
Ext.ns("TYPO3");
|
||
TYPO3.settings = ' . json_encode($typo3Settings) . ';';
|
||
|
||
$this->loadJavascriptLib('../t3lib/js/extjs/tceforms.js');
|
||
|
||
// if IRRE fields were processed, add the JavaScript functions:
|
||
if ($this->inline->inlineCount) {
|
||
$GLOBALS['SOBE']->doc->loadScriptaculous();
|
t3lib/js/extjs/tceforms.js (revision 0) | ||
---|---|---|
/***************************************************************
|
||
* extJS for TCEforms
|
||
*
|
||
* $Id$
|
||
*
|
||
* Copyright notice
|
||
*
|
||
* (c) 2009 Steffen Kamper <info@sk-typo3.de>
|
||
* 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!
|
||
***************************************************************/
|
||
|
||
Ext.ns('TYPO3');
|
||
// class for manipulate TCEFORMS
|
||
TYPO3.TCEFORMS = {
|
||
|
||
init: function() {
|
||
Ext.QuickTips.init();
|
||
|
||
if (TYPO3.settings.useDatePicker) {
|
||
this.convertDateFieldsToDatePicker();
|
||
}
|
||
},
|
||
|
||
convertDateFieldsToDatePicker: function() {
|
||
var dateFields = Ext.select("*[id^=tceforms-datefield-], *[id^=tceforms-datetimefield-]");
|
||
dateFields.each(function(element) {
|
||
var index = element.dom.id.match(/tceforms-datefield-/) ? 0 : 1;
|
||
var format = TYPO3.settings.datePickerUSmode ? TYPO3.settings.dateFormatUS : TYPO3.settings.dateFormat;
|
||
var datepicker = Ext.DomHelper.insertAfter(element, {
|
||
tag: 'img',
|
||
src: TYPO3.settings.datePickerIcon,
|
||
style: 'cursor:pointer;vertical-align:middle;'
|
||
}, true);
|
||
|
||
var menu = new Ext.menu.DateMenu({
|
||
id: 'p' + element.dom.id,
|
||
format: format[index],
|
||
value: Date.parseDate(element.dom.value, format[index]),
|
||
handler: function(picker, date){
|
||
var relElement = Ext.getDom(picker.id.substring(1));
|
||
relElement.value = date.format(format[index]);
|
||
if (Ext.isFunction(relElement.onchange)) {
|
||
relElement.onchange.call(relElement);
|
||
}
|
||
},
|
||
});
|
||
|
||
datepicker.on('click', function(){
|
||
menu.show(datepicker);
|
||
});
|
||
});
|
||
}
|
||
}
|
||
Ext.onReady(TYPO3.TCEFORMS.init, TYPO3.TCEFORMS);
|