ability to add bower resources
* add addVendorScript & addVendorStyle * refactoring of addScript and addStyle * add shortcuts vendorScript and vendorStyle
This commit is contained in:
parent
d2276215a4
commit
d763b32048
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "ownCloud",
|
||||||
|
"version": "8.0 pre alpha",
|
||||||
|
"homepage": "http://www.owncloud.org",
|
||||||
|
"license": "AGPL",
|
||||||
|
"private": true,
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"node_modules",
|
||||||
|
"bower_components",
|
||||||
|
"core/vendor",
|
||||||
|
"test",
|
||||||
|
"tests"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,6 +39,22 @@ function script($app, $file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for adding vendor scripts to a page
|
||||||
|
* @param string $app the appname
|
||||||
|
* @param string|string[] $file the filename,
|
||||||
|
* if an array is given it will add all scripts
|
||||||
|
*/
|
||||||
|
function vendorScript($app, $file) {
|
||||||
|
if(is_array($file)) {
|
||||||
|
foreach($file as $f) {
|
||||||
|
OC_Util::addVendorScript($app, $f);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OC_Util::addVendorScript($app, $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut for adding styles to a page
|
* Shortcut for adding styles to a page
|
||||||
* @param string $app the appname
|
* @param string $app the appname
|
||||||
|
@ -55,6 +71,22 @@ function style($app, $file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for adding vendor styles to a page
|
||||||
|
* @param string $app the appname
|
||||||
|
* @param string|string[] $file the filename,
|
||||||
|
* if an array is given it will add all styles
|
||||||
|
*/
|
||||||
|
function vendorStyle($app, $file) {
|
||||||
|
if(is_array($file)) {
|
||||||
|
foreach($file as $f) {
|
||||||
|
OC_Util::addVendorStyle($app, $f);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OC_Util::addVendorStyle($app, $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut for adding translations to a page
|
* Shortcut for adding translations to a page
|
||||||
* @param string $app the appname
|
* @param string $app the appname
|
||||||
|
|
|
@ -330,6 +330,26 @@ class OC_Util {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generates a path for JS/CSS files. If no application is provided it will create the path for core.
|
||||||
|
*
|
||||||
|
* @param $application application to get the files from
|
||||||
|
* @param $directory directory withing this application (css, js, vendor, etc)
|
||||||
|
* @param $file the file inside of the above folder
|
||||||
|
* @return string the path
|
||||||
|
*/
|
||||||
|
private static function generatePath($application, $directory, $file) {
|
||||||
|
if (is_null($file)) {
|
||||||
|
$file = $application;
|
||||||
|
$application = "";
|
||||||
|
}
|
||||||
|
if (!empty($application)) {
|
||||||
|
return "$application/$directory/$file";
|
||||||
|
} else {
|
||||||
|
return "$directory/$file";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a javascript file
|
* add a javascript file
|
||||||
*
|
*
|
||||||
|
@ -338,15 +358,18 @@ class OC_Util {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function addScript($application, $file = null) {
|
public static function addScript($application, $file = null) {
|
||||||
if (is_null($file)) {
|
self::$scripts[] = OC_Util::generatePath($application, 'js', $file);
|
||||||
$file = $application;
|
}
|
||||||
$application = "";
|
|
||||||
}
|
/**
|
||||||
if (!empty($application)) {
|
* add a javascript file from the vendor sub folder
|
||||||
self::$scripts[] = "$application/js/$file";
|
*
|
||||||
} else {
|
* @param string $application application id
|
||||||
self::$scripts[] = "js/$file";
|
* @param string|null $file filename
|
||||||
}
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function addVendorScript($application, $file = null) {
|
||||||
|
self::$scripts[] = OC_Util::generatePath($application, 'vendor', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -375,15 +398,18 @@ class OC_Util {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function addStyle($application, $file = null) {
|
public static function addStyle($application, $file = null) {
|
||||||
if (is_null($file)) {
|
self::$styles[] = OC_Util::generatePath($application, 'css', $file);
|
||||||
$file = $application;
|
}
|
||||||
$application = "";
|
|
||||||
}
|
/**
|
||||||
if (!empty($application)) {
|
* add a css file from the vendor sub folder
|
||||||
self::$styles[] = "$application/css/$file";
|
*
|
||||||
} else {
|
* @param string $application application id
|
||||||
self::$styles[] = "css/$file";
|
* @param string|null $file filename
|
||||||
}
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function addVendorStyle($application, $file = null) {
|
||||||
|
self::$styles[] = OC_Util::generatePath($application, 'vendor', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue