add $prepend option to addStyle() & addVendorStyle()
This commit is contained in:
parent
5a11e145da
commit
2e42f99d00
|
@ -92,26 +92,26 @@ class OC_Template extends \OC\Template\Base {
|
||||||
public static function initTemplateEngine() {
|
public static function initTemplateEngine() {
|
||||||
if (self::$initTemplateEngineFirstRun){
|
if (self::$initTemplateEngineFirstRun){
|
||||||
|
|
||||||
//apps that started before the template initialization can load their own scripts
|
//apps that started before the template initialization can load their own scripts/styles
|
||||||
//so to make sure this scripts here are loaded first we use OC_Util::addScript() with $prepend=true
|
//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
|
||||||
//meaning the last scripts in this list will be loaded first
|
//meaning the last script/style in this list will be loaded first
|
||||||
if (\OC::$server->getSystemConfig ()->getValue ( 'installed', false ) && ! \OCP\Util::needUpgrade ()) {
|
if (\OC::$server->getSystemConfig ()->getValue ( 'installed', false ) && ! \OCP\Util::needUpgrade ()) {
|
||||||
if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
|
if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
|
||||||
OC_Util::addScript ( 'backgroundjobs', null, true );
|
OC_Util::addScript ( 'backgroundjobs', null, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OC_Util::addStyle("styles");
|
OC_Util::addStyle("tooltip",null,true);
|
||||||
OC_Util::addStyle("header");
|
OC_Util::addStyle('jquery-ui-fixes',null,true);
|
||||||
OC_Util::addStyle("mobile");
|
OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
|
||||||
OC_Util::addStyle("icons");
|
OC_Util::addStyle("multiselect",null,true);
|
||||||
OC_Util::addStyle("fonts");
|
OC_Util::addStyle("fixes",null,true);
|
||||||
OC_Util::addStyle("apps");
|
OC_Util::addStyle("apps",null,true);
|
||||||
OC_Util::addStyle("fixes");
|
OC_Util::addStyle("fonts",null,true);
|
||||||
OC_Util::addStyle("multiselect");
|
OC_Util::addStyle("icons",null,true);
|
||||||
OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui');
|
OC_Util::addStyle("mobile",null,true);
|
||||||
OC_Util::addStyle('jquery-ui-fixes');
|
OC_Util::addStyle("header",null,true);
|
||||||
OC_Util::addStyle("tooltip");
|
OC_Util::addStyle("styles",null,true);
|
||||||
|
|
||||||
// avatars
|
// avatars
|
||||||
if (\OC::$server->getSystemConfig()->getValue('enable_avatars', true) === true) {
|
if (\OC::$server->getSystemConfig()->getValue('enable_avatars', true) === true) {
|
||||||
|
|
|
@ -507,28 +507,38 @@ class OC_Util {
|
||||||
*
|
*
|
||||||
* @param string $application application id
|
* @param string $application application id
|
||||||
* @param string|null $file filename
|
* @param string|null $file filename
|
||||||
|
* @param bool $prepend prepend the Style to the beginning of the list
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function addStyle($application, $file = null) {
|
public static function addStyle($application, $file = null, $prepend = false) {
|
||||||
$path = OC_Util::generatePath($application, 'css', $file);
|
$path = OC_Util::generatePath($application, 'css', $file);
|
||||||
if (!in_array($path, self::$styles)) {
|
if (!in_array($path, self::$styles)) {
|
||||||
|
if ($prepend === true) {
|
||||||
|
array_unshift ( self::$styles, $path );
|
||||||
|
} else {
|
||||||
self::$styles[] = $path;
|
self::$styles[] = $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a css file from the vendor sub folder
|
* add a css file from the vendor sub folder
|
||||||
*
|
*
|
||||||
* @param string $application application id
|
* @param string $application application id
|
||||||
* @param string|null $file filename
|
* @param string|null $file filename
|
||||||
|
* @param bool $prepend prepend the Style to the beginning of the list
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function addVendorStyle($application, $file = null) {
|
public static function addVendorStyle($application, $file = null, $prepend = false) {
|
||||||
$path = OC_Util::generatePath($application, 'vendor', $file);
|
$path = OC_Util::generatePath($application, 'vendor', $file);
|
||||||
if (!in_array($path, self::$styles)) {
|
if (!in_array($path, self::$styles)) {
|
||||||
|
if ($prepend === true) {
|
||||||
|
array_unshift ( self::$styles, $path );
|
||||||
|
} else {
|
||||||
self::$styles[] = $path;
|
self::$styles[] = $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a custom element to the header
|
* Add a custom element to the header
|
||||||
|
|
Loading…
Reference in New Issue