Switch back to inline script at the end of document (after page loading) - prepare the future of all script at the bottom of page
This commit is contained in:
parent
ccecb31c6c
commit
f02b246292
@ -9,6 +9,9 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
|
||||
$theme = !empty($auth->getIdentity()->theme) ? $auth->getIdentity()->theme : 'default';
|
||||
}
|
||||
|
||||
$controller = $request->getControllerName();
|
||||
$action = $request->getActionName();
|
||||
|
||||
//Sauvegarde des paramètres du themes pour gérer les scripts et styles à utiliser
|
||||
$paramsTheme = new stdClass();
|
||||
$paramsTheme->name = $theme;
|
||||
@ -52,13 +55,18 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
|
||||
$view->headLink()
|
||||
->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/favicon.ico'));
|
||||
|
||||
/**
|
||||
* Detect IE
|
||||
*/
|
||||
$isIE6 = false;
|
||||
if ( $device->getFeature('browser_name')=='Internet Explorer'
|
||||
&& $device->getFeature('browser_version')=='6.0' ) {
|
||||
$isIE6 = true;
|
||||
}
|
||||
|
||||
//===> Style
|
||||
/**
|
||||
* ===> Standard Styles
|
||||
*/
|
||||
$view->headLink()->appendStylesheet($paramsTheme->pathStyle.'/main.css', 'all');
|
||||
if ($isIE6) {
|
||||
//Old CSS for IE6
|
||||
@ -71,10 +79,13 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
|
||||
}
|
||||
$view->headLink()->appendStylesheet('/libs/qtip/jquery.qtip.css', 'all');
|
||||
|
||||
$view->headScript()
|
||||
->appendFile('/libs/jquery/jquery-1.10.1.min.js', 'text/javascript');
|
||||
|
||||
//===> JavaScript
|
||||
/**
|
||||
* ===> Standard Javascript
|
||||
*/
|
||||
$view->headScript()
|
||||
->appendFile('/libs/jquery/jquery-1.10.2.min.js', 'text/javascript');
|
||||
|
||||
if ($isIE6) {
|
||||
//Old JQuery version for IE6
|
||||
$view->headScript()
|
||||
@ -90,13 +101,13 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
|
||||
->appendFile('/libs/qtip/jquery.qtip.js', 'text/javascript')
|
||||
->appendFile($paramsTheme->pathScript.'/script.js', 'text/javascript');
|
||||
|
||||
/*
|
||||
/**
|
||||
* ===> Specific Style and Script by Controller/Action
|
||||
* Specialized Controller - Action javascript
|
||||
* controllerName.js || controllerName-actionName.js
|
||||
* array(
|
||||
* 'controller-action' => array('file.js'=> 'inline|file')
|
||||
* 'controller-action' => array('file.js'=> 'inline|file')
|
||||
* )
|
||||
*
|
||||
*/
|
||||
$scripts = array(
|
||||
'identite-fiche' => array(
|
||||
@ -118,9 +129,6 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
|
||||
);
|
||||
|
||||
if ( count($scripts)>0 ) {
|
||||
$controller = $request->getControllerName();
|
||||
$action = $request->getActionName();
|
||||
|
||||
//Controller
|
||||
$key = null;
|
||||
if ( array_key_exists($controller, $scripts) ) {
|
||||
@ -132,9 +140,7 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
|
||||
foreach ( $options as $file => $type ) {
|
||||
switch ( $type ) {
|
||||
case 'inline':
|
||||
$file = APPLICATION_PATH.'/../public/'.$paramsTheme->pathScript.'/'.$file;
|
||||
$contentScript = file_get_contents($file);
|
||||
$view->inlineScript()->appendScript($contentScript);
|
||||
$view->inlineScript()->appendFile($paramsTheme->pathScript.'/'.$file);
|
||||
break;
|
||||
case 'file':
|
||||
$view->headScript()->appendFile($paramsTheme->pathScript.'/'.$file, 'text/javascript');
|
||||
@ -155,9 +161,7 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
|
||||
foreach ( $options as $file => $type ) {
|
||||
switch ( $type ) {
|
||||
case 'inline':
|
||||
$file = APPLICATION_PATH.'/../public/'.$paramsTheme->pathScript.'/'.$file;
|
||||
$contentScript = file_get_contents($file);
|
||||
$view->inlineScript()->appendScript($contentScript);
|
||||
$view->inlineScript()->appendFile($paramsTheme->pathScript.'/'.$file);
|
||||
break;
|
||||
case 'file':
|
||||
$view->headScript()->appendFile($paramsTheme->pathScript.'/'.$file, 'text/javascript');
|
||||
|
Loading…
Reference in New Issue
Block a user