Index: jqtouch_actioncontroller.php =================================================================== --- jqtouch_actioncontroller.php (revision 0) +++ jqtouch_actioncontroller.php (revision 0) @@ -0,0 +1,200 @@ + +* 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! +***************************************************************/ + +/** + * An abstract controller for jQTouch web applications. + * + * @category Controllers + * @package TYPO3 + * @subpackage tx_myext + * @author Xavier Perseguers + * @license http://www.gnu.org/copyleft/gpl.html + * @version SVN: $Id$ + */ +abstract class Tx_MyExt_Controller_AbstractJQTouchController extends Tx_Extbase_MVC_Controller_ActionController { + + /** + * @var string + */ + protected $extKey; + + /** + * @var string + */ + protected $publicResources; + + /** + * Initialize the actions. + * + * @return void + */ + public function initializeAction() { + parent::initializeAction(); + + $this->extKey = Tx_Extbase_Utility_Extension::convertCamelCaseToLowerCaseUnderscored($this->extensionName); + $this->publicResources = substr(t3lib_extMgm::extPath($this->extKey), strlen(PATH_site)) . 'Resources/Public/'; + } + + /** + * Adds JS file + * + * @param string $file + * @param string $type + * @return void + */ + protected function addJsFile($file, $type = 'text/javascript') { + if ($this->request->isCached()) { + $GLOBALS['TSFE']->backPath = TYPO3_mainDir; + $GLOBALS['TSFE']->getPageRenderer()->addJsFile($file, $type); + } else { + $this->response->addAdditionalHeaderData( + '' + ); + } + } + + /** + * Adds JS inline code. + * + * @param string $name + * @param string $block + * @return void + */ + public function addJsInlineCode($name, $block) { + if ($this->request->isCached()) { + $GLOBALS['TSFE']->backPath = TYPO3_mainDir; + $GLOBALS['TSFE']->getPageRenderer()->addJsInlineCode($name, $block); + } else { + $this->response->addAdditionalHeaderData( + '' + ); + } + } + + /** + * Adds CSS file. + * + * @param string $file + * @param string $rel + * @param string $media + * @return void + */ + public function addCssFile($file, $rel = 'stylesheet', $media = 'all') { + if ($this->request->isCached()) { + $GLOBALS['TSFE']->backPath = TYPO3_mainDir; + $GLOBALS['TSFE']->getPageRenderer()->addCssFile($file, $rel, $media); + } else { + $this->response->addAdditionalHeaderData( + '' + ); + } + } + + /** + * Adds CSS inline code. + * + * @param string $name + * @param string $block + * @return void + */ + public function addCssInlineBlock($name, $block) { + if ($this->request->isCached()) { + $GLOBALS['TSFE']->backPath = TYPO3_mainDir; + $GLOBALS['TSFE']->getPageRenderer()->addCssInlineBlock($name, $block); + } else { + $this->response->addAdditionalHeaderData( + '' + ); + } + } + + /** + * Loads the jQTouch framework. + * + * @return void + */ + protected function loadJQTouch() { + $this->addCssFile($this->publicResources . 'jqtouch/jqtouch/jqtouch.min.css'); + $this->addCssFile($this->publicResources . 'jqtouch/themes/jqt/theme.min.css'); + $this->addJsFile($this->publicResources . 'jqtouch/jqtouch/jquery.1.3.2.min.js'); + $this->addJsFile($this->publicResources . 'jqtouch/jqtouch/jqtouch.min.js', 'application/x-javascript'); + + $this->addJsInlineCode( + 'jQT', + "var jQT = new $.jQTouch({ + icon: '" . $this->publicResources . "Icons/iphone_icon.png', + addGlossToIcon: true, + startupScreen: '" . $this->publicResources . "Images/startup.png', + statusBar: 'black', + preloadImages: [ + '" . $this->publicResources . "jqtouch/themes/jqt/img/back_button.png', + '" . $this->publicResources . "jqtouch/themes/jqt/img/back_button_clicked.png', + '" . $this->publicResources . "jqtouch/themes/jqt/img/button_clicked.png', + '" . $this->publicResources . "jqtouch/themes/jqt/img/grayButton.png', + '" . $this->publicResources . "jqtouch/themes/jqt/img/whiteButton.png', + '" . $this->publicResources . "jqtouch/themes/jqt/img/loading.gif' + ] + });" + ); + + $this->addCssInlineBlock( + 'jQT', + 'body.fullscreen #home .info { + display: none; + } + #about { + padding: 100px 10px 40px; + text-shadow: rgba(255, 255, 255, 0.3) 0px -1px 0; + font-size: 13px; + text-align: center; + background: #161618; + } + #about p { + margin-bottom: 8px; + } + #about a { + color: #fff; + font-weight: bold; + text-decoration: none; + }' + ); + } + +} + +?> \ No newline at end of file