Simplification de la gestion des scripts et styles

This commit is contained in:
Michael RICOIS 2015-07-07 12:16:24 +00:00
parent 1840e464d3
commit 42579572e7
4 changed files with 62 additions and 94 deletions

View File

@ -3,13 +3,15 @@ class IdentiteController extends Zend_Controller_Action
{
protected $siret = null;
protected $id = 0;
protected $theme;
public function init()
{
$request = $this->getRequest();
$theme = Zend_Registry::get('theme');
// --- Theme
$this->theme = Zend_Registry::get('theme');
//Get standard parameters
// --- Get standard parameters
$request = $this->getRequest();
$this->siret = $request->getParam('siret');
$this->id = $request->getParam('id', 0);
@ -657,6 +659,7 @@ class IdentiteController extends Zend_Controller_Action
{
$nbMonthForRecentLien = 3;
$this->view->headScript()->appendFile($this->theme->pathScript.'/identite-groupe.js', 'text/javascript');
$request = $this->getRequest();
$autrePage = $this->getRequest()->getParam('apage');
$lienRef = $request->getParam('lienref', null);
@ -1574,7 +1577,8 @@ class IdentiteController extends Zend_Controller_Action
*/
public function groupeAction()
{
$this->view->headTitle()->prepend("Groupe");
$this->view->headScript()->appendFile($this->theme->pathScript.'/identite-groupe.js', 'text/javascript');
$this->view->headTitle()->prepend("Groupe");
$this->view->headTitle()->prepend("Siret ".$this->siret);
$siren = substr($this->siret,0,9);

View File

@ -142,76 +142,6 @@ class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstrac
->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')
* )
*/
$scripts = array(
'identite-fiche' => array(
'identite-fiche.js' => 'inline',
),
'identite-fichepc' => array(
'identite-fiche.js' => 'inline',
),
'identite-groupe' => array(
'identite-groupe.js' => 'inline',
),
'identite-liens' => array(
'identite-groupe.js' => 'inline',
),
'evaluation-indiscore3' => array(
'identite-fiche.js' => 'inline',
),
);
if ( count($scripts)>0 ) {
//Controller
$key = null;
if ( array_key_exists($controller, $scripts) ) {
$key = $controller;
}
if ( $key ) {
$options = $scripts[$key];
if ( is_array($options) ) {
foreach ( $options as $file => $type ) {
switch ( $type ) {
case 'inline':
$view->inlineScript()->appendFile($paramsTheme->pathScript.'/'.$file);
break;
case 'file':
$view->headScript()->appendFile($paramsTheme->pathScript.'/'.$file, 'text/javascript');
break;
}
}
}
}
//Controller-Action
$key = null;
if ( array_key_exists($controller.'-'.$action, $scripts) ) {
$key = $controller.'-'.$action;
}
if ( $key ) {
$options = $scripts[$key];
if ( is_array($options) ) {
foreach ( $options as $file => $type ) {
switch ( $type ) {
case 'inline':
$view->inlineScript()->appendFile($paramsTheme->pathScript.'/'.$file);
break;
case 'file':
$view->headScript()->appendFile($paramsTheme->pathScript.'/'.$file, 'text/javascript');
break;
}
}
}
}
}
break;
case 'mobile': //@todo

View File

@ -1,19 +0,0 @@
(function($){
$.fn.reportprogress = function(val,maxVal){
var max=100;if(maxVal)
max=maxVal;
return this.each(function(){
var div=$(this);
var innerdiv=div.find(".progress");
if(innerdiv.length!=1){
innerdiv=$("<div class='progress'></div>");
div.append("<div class='text'> </div>");
$("<span class='text'> </span>").css("width",div.width()).appendTo(innerdiv);
div.append(innerdiv);
}
var width=Math.round(val/max*100);
innerdiv.css("width",width+"%");
div.find(".text").html(width+" %")
;})
;}
;})(jQuery);

View File

@ -58,5 +58,58 @@ $(document).ready(function(){
var href = $(this).attr('href');
$('span#bodacc').html('Chargement du bodacc...').load(href);
});
//Tooltip date de maj
if ($('a.datemaj').length){
$('a.datemaj').qtip({
content: $('a.datemaj span').html(),
style: { width: 200, classes: "ui-tooltip-cream" },
position: { my: "top center", at: "bottom center" }
});
}
//Tooltip de domiciliation
if ($('div.domiciliation').length){
$('div.domiciliation').qtip({
show: { event: "click" },
hide: { event: "unfocus" },
content: { title: {button: true}, text: $('div.domiciliation span').html() },
style: { width: 200 },
position: { my: "top center", at: "bottom center" }
});
}
//Tooltip AncienSiege
if ($('a.AncienSiege').length){
$('a.AncienSiege').qtip({
hide: { event: "unfocus" },
content: { title: {button: true}, text: $('a.AncienSiege').attr('title') },
style: { width: 350, classes: "ui-tooltip-cream" },
position: { my: "top center", at: "bottom center" }
});
$('a.AncienSiege').attr('title', "Cliquez pour consulter les informations d'activité.");
}
//Tooltip RNVP
if ($('a.rnvp').length){
$('a.rnvp').qtip({
hide: { event: "click" },
content: {
title: {button: true, text: $('a.rnvp').attr('title')},
text: function(event,api) {
$.ajax({ url: $(this).data('href') })
.done(function(html) {
api.set('content.text', html)
})
.fail(function(xhr, status, error) {
api.set('content.text', status + ': ' + error)
})
return 'Chargement...';
}
},
style: { width: 350, classes: "ui-tooltip-cream" },
position: { my: "top center", at: "bottom center" }
});
}
});