Skip to content

Commit

Permalink
Fixed issue: bootstrap load order in admin GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed May 13, 2016
1 parent 7df188d commit 04b15b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions application/config/third_party.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
'bootstrap' => array(
'basePath' => 'bootstrap',
'css'=> array(
'css/bootstrap.css',
'yiistrap.css',
),
'depends' => array(
'jquery',
Expand Down
17 changes: 14 additions & 3 deletions application/models/AdminTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ public function setAdminTheme()
public function registerStylesAndScripts()
{
// First we register the different needed packages
App()->bootstrap->register(); // Bootstrap

// We don't want to use any more the register functionality, to be able to set dependencies between packages
// ie: to control load order setting 'depends' in our package
// So, we take the usual Bootstrap extensions TbApi::register (called normally with App()->bootstrap->register()) see: https://github.com/LimeSurvey/LimeSurvey/blob/master/application/extensions/bootstrap/components/TbApi.php#l162-l169
// keep here the necessary (registerMetaTag and registerAllScripts),
// and move the rest to the bootstrap package.
// NB: registerAllScripts could be replaced by js definition in package. If needed: not a problem to do it

Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport'); // See: https://github.com/LimeSurvey/LimeSurvey/blob/master/application/extensions/bootstrap/components/TbApi.php#l108-l115
App()->bootstrap->registerAllScripts(); // See : https://github.com/LimeSurvey/LimeSurvey/blob/master/application/extensions/bootstrap/components/TbApi.php#l153-l160

App()->getClientScript()->registerPackage('jqueryui'); // jqueryui
App()->getClientScript()->registerPackage('jquery-cookie'); // jquery-cookie
App()->getClientScript()->registerPackage('fontawesome'); // fontawesome ??? TODO: check if needed
Expand Down Expand Up @@ -173,8 +183,9 @@ public function registerStylesAndScripts()
$package['baseUrl'] = $this->sTemplateUrl; // add the base url to the package, so it will not use the asset manager
}

$package['css'] = $aCssFiles; // add the css files to the package
$package['js'] = $aJsFiles; // add the js files to the package
$package['css'] = $aCssFiles; // add the css files to the package
$package['js'] = $aJsFiles; // add the js files to the package
$package['depends'] = array('bootstrap');

Yii::app()->clientScript->addPackage( 'admin-theme', $package); // add the package
Yii::app()->clientScript->registerPackage('admin-theme'); // register the package
Expand Down
2 changes: 1 addition & 1 deletion application/models/TemplateConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function setTemplateConfiguration($sTemplateName='', $iSurveyId='')
$this->packages = (array) $this->config->engine->packages->package;
$this->otherFiles = $this->setOtherFiles();
$this->depends = $this->packages;
$this->depends[] = (string) $this->cssFramework;
//$this->depends[] = (string) $this->cssFramework; // Bootstrap CSS is no more needed for Bootstrap templates (their custom css like "flat_and_modern.css" is a custom version of bootstrap.css )

$this->createTemplatePackage();

Expand Down

0 comments on commit 04b15b1

Please sign in to comment.