1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-14 09:32:17 +02:00

Use Library Manager to load jQuery, jQuery UI... etc.

This commit is contained in:
lonalore 2016-12-22 14:16:52 +01:00
parent 46a7dd5d14
commit 8ef8a93407
4 changed files with 379 additions and 73 deletions

View File

@ -22,42 +22,14 @@ class e_jsmanager
'prototype/prototype.js' ,
'scriptaculous/scriptaculous.js',
'scriptaculous/effects.js',
'e107.js'),
/*
'e107.js',
),
'jquery' => array(
"http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css",
"http://code.jquery.com/jquery-1.8.2.js",
"http://code.jquery.com/ui/1.9.1/jquery-ui.js"
),
'jquery' => array(
"http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js",
"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/base/jquery-ui.css"
)
*/
'jquery' => array(
// "http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css",
// "http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"
// "http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js",
// "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
// "http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"
"https://cdn.jsdelivr.net/jquery/2.2.4/jquery.min.js",
// jQuery Once filters out all elements that had the same filter applied on them before. It can be used to
// ensure that a function is only applied once to an element. jQuery Once is used in e107.behaviors.
"https://cdnjs.cloudflare.com/ajax/libs/jquery-once/2.1.1/jquery.once.min.js"
// ,
// "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js",
// "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css",
// "http://code.jquery.com/jquery-1.8.3.js",
// "http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css",
// "http://code.jquery.com/ui/1.9.2/jquery-ui.js"
)
"https://cdnjs.cloudflare.com/ajax/libs/jquery-once/2.1.1/jquery.once.min.js",
),
);
/**
@ -267,18 +239,14 @@ class e_jsmanager
if($this->isInAdmin()) // Include jquery-ui in the admin-area only - Jquery-UI to eventually be removed from e107 completely if possible.
{
$this->_libraries['jquery'] = array(
"https://cdn.jsdelivr.net/jquery/2.2.4/jquery.min.js",
// jQuery Once filters out all elements that had the same filter applied on them before. It can be used
// to ensure that a function is only applied once to an element. jQuery Once is used in e107.behaviors.
"https://cdnjs.cloudflare.com/ajax/libs/jquery-once/2.1.1/jquery.once.min.js",
"https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.js",
"https://cdn.jsdelivr.net/jquery.ui/1.11.4/themes/smoothness/jquery-ui.min.css"
);
$minified = deftrue('e_DEBUG') == true ? null : 'minified';
// "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js",
// "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css",
//https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.css
e107::library('load', 'cdn.jquery', $minified);
// jQuery Once is used in e107.behaviors.
e107::library('load', 'cdn.jquery.once', $minified);
e107::library('load', 'cdn.jquery.ui', $minified);
$this->_libraries['jquery'] = array();
}
if(isset($_SERVER['E_DEV_LOCALJS']) && $_SERVER['E_DEV_LOCALJS'] === 'true' || !deftrue('e_CDN',true)) // Test with Local JS Framework files.

View File

@ -442,6 +442,17 @@ class e_library_manager
{
$libraries = array();
$coreLibrary = new core_library();
$info = $coreLibrary->config();
if(is_array($info))
{
foreach($info as $machine_name => $properties)
{
$properties['info_type'] = 'core';
$libraries[$machine_name] = $properties;
}
}
$plugins = array();
$themes = array();
@ -582,7 +593,7 @@ class e_library_manager
'pre_detect' => array(),
'post_detect' => array(),
'pre_dependencies_load' => array(),
'pre_load' => array(),
'pre_load' => array('preLoad'),
'post_load' => array(),
);
@ -739,21 +750,21 @@ class e_library_manager
{
// Always apply the callback to the top-level library.
// Params: $library, $version, $variant
$this->$callback($library, null, null);
$this->{$callback}($library, null, null);
// Apply the callback to versions.
if(isset($library['versions']))
{
foreach($library['versions'] as $version_string => &$version)
{
$this->$callback($version, $version_string, null);
$this->{$callback}($version, $version_string, null);
// Versions can include variants as well.
if(isset($version['variants']))
{
foreach($version['variants'] as $version_variant_name => &$version_variant)
{
$this->$callback($version_variant, $version_string, $version_variant_name);
$this->{$callback}($version_variant, $version_string, $version_variant_name);
}
}
}
@ -1135,4 +1146,341 @@ class e_library_manager
}
}
/**
* Alter library information before loading.
*/
private function preLoad(&$library)
{
if(defset('e_ADMIN_AREA', false) == true)
{
switch($library['machine_name'])
{
// Force to use 'smoothness' theme for Admin UI.
case 'cdn.jquery.ui':
$library['files']['css'] = array(
'themes/smoothness/jquery-ui.css' => array(
'zone' => 2,
),
);
$library['variants']['minified']['files']['css'] = array(
'themes/smoothness/jquery-ui.min.css' => array(
'zone' => 2,
),
);
break;
}
}
}
}
/**
* Class core_library.
*/
class core_library
{
/**
* Return information about external libraries.
*/
public function config()
{
$libraries = array();
// jQuery (CDN).
$libraries['cdn.jquery'] = array(
'name' => 'jQuery (CDN)',
'vendor_url' => 'https://jquery.com/',
'version_arguments' => array(
'file' => 'jquery.min.js',
'pattern' => '/jQuery\s+v(\d\.\d\.\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'jquery.js' => array(
'zone' => 1,
'type' => 'url',
),
),
),
'variants' => array(
// All properties defined for 'minified' override top-level properties.
'minified' => array(
'files' => array(
'js' => array(
'jquery.min.js' => array(
'zone' => 1,
'type' => 'url',
),
),
),
),
),
// Override library path to CDN.
'library_path' => 'https://cdn.jsdelivr.net/jquery/2.2.4/',
);
// jQuery Once (CDN).
$libraries['cdn.jquery.once'] = array(
'name' => 'jQuery Once (CDN)',
'vendor_url' => 'https://plugins.jquery.com/once/',
'version_arguments' => array(
'file' => 'jquery.once.min.js',
'pattern' => '/jQuery\sOnce\s++v(\d\.\d\.\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'jquery.once.min.js' => array( // There is no non-minified version.
'zone' => 2,
'type' => 'url',
),
),
),
'variants' => array(
// All properties defined for 'minified' override top-level properties.
'minified' => array(
'files' => array(
'js' => array(
'jquery.once.min.js' => array(
'zone' => 2,
'type' => 'url',
),
),
),
),
),
'dependencies' => array(
'cdn.jquery',
),
// Override library path to CDN.
'library_path' => 'https://cdn.jsdelivr.net/jquery.once/2.1.2/',
);
// jQuery UI (CDN).
$libraries['cdn.jquery.ui'] = array(
'name' => 'jQuery UI (CDN)',
'vendor_url' => 'https://jqueryui.com/',
'version_arguments' => array(
'file' => 'jquery-ui.min.js',
'pattern' => '/v(\d\.\d+\.\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'jquery-ui.min.js' => array( // There is no non-minified version.
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'jquery-ui.min.css' => array( // There is no non-minified version.
'zone' => 2,
),
),
),
'variants' => array(
// All properties defined for 'minified' override top-level properties.
'minified' => array(
'files' => array(
'js' => array(
'jquery-ui.min.js' => array(
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'jquery-ui.min.css' => array(
'zone' => 2,
),
),
),
),
),
'dependencies' => array(
'cdn.jquery',
),
// Override library path to CDN.
'library_path' => 'https://cdn.jsdelivr.net/jquery.ui/1.11.4/',
);
// Bootstrap (CDN).
$libraries['cdn.bootstrap'] = array(
'name' => 'Bootstrap (CDN)',
'vendor_url' => 'http://getbootstrap.com/',
'version_arguments' => array(
'file' => 'js/bootstrap.min.js',
'pattern' => '/Bootstrap\s+v(\d\.\d\.\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'js/bootstrap.js' => array(
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'css/bootstrap.css' => array(
'zone' => 2,
),
),
),
'variants' => array(
// All properties defined for 'minified' override top-level properties.
'minified' => array(
'files' => array(
'js' => array(
'js/bootstrap.min.js' => array(
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'css/bootstrap.min.css' => array(
'zone' => 2,
),
),
),
),
),
'dependencies' => array(
'cdn.jquery',
),
// Override library path to CDN.
'library_path' => 'https://cdn.jsdelivr.net/bootstrap/3.3.7/',
);
// Bootstrap Editable (Local).
$libraries['bootstrap.editable'] = array(
'name' => 'Bootstrap Editable (Local)',
'vendor_url' => 'https://vitalets.github.io/bootstrap-editable/',
'version_arguments' => array(
'file' => 'js/bootstrap-editable.min.js',
'pattern' => '/v(\d\.\d\.\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'js/bootstrap-editable.js' => array(
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'css/bootstrap-editable.css' => array(
'zone' => 2,
),
),
),
'variants' => array(
// All properties defined for 'minified' override top-level properties.
'minified' => array(
'files' => array(
'js' => array(
'js/bootstrap-editable.min.js' => array(
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'css/bootstrap-editable.min.css' => array(
'zone' => 2,
),
),
),
),
),
'dependencies' => array(
'cdn.bootstrap', // FIXME - bootstrap local version?
),
// Override library path.
'library_path' => '{e_WEB}js/bootstrap3-editable/',
);
// Bootstrap Editable (CDN).
$libraries['cdn.bootstrap.editable'] = array(
'name' => 'Bootstrap Editable (CDN)',
'vendor_url' => 'https://vitalets.github.io/bootstrap-editable/',
'version_arguments' => array(
'file' => 'js/bootstrap-editable.min.js',
'pattern' => '/v(\d\.\d\.\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'js/bootstrap-editable.js' => array(
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'css/bootstrap-editable.css' => array(
'zone' => 2,
),
),
),
'variants' => array(
// All properties defined for 'minified' override top-level properties.
'minified' => array(
'files' => array(
'js' => array(
'js/bootstrap-editable.min.js' => array(
'zone' => 2,
'type' => 'url',
),
),
'css' => array(
'css/bootstrap-editable.min.css' => array(
'zone' => 2,
),
),
),
),
),
'dependencies' => array(
'cdn.bootstrap',
),
// Override library path to CDN.
'library_path' => 'https://cdn.jsdelivr.net/bootstrap.editable/1.5.1/',
);
// Font-Awesome (CDN).
$libraries['cdn.fontawesome'] = array(
'name' => 'Font-Awesome (CDN)',
'vendor_url' => 'http://fontawesome.io/',
'version_arguments' => array(
'file' => 'css/font-awesome.min.css',
'pattern' => '/(\d\.\d\.\d+)/',
'lines' => 10,
),
'files' => array(
'css' => array(
'css/font-awesome.css' => array(
'zone' => 2,
),
),
),
'variants' => array(
// All properties defined for 'minified' override top-level properties.
'minified' => array(
'files' => array(
'css' => array(
'css/font-awesome.min.css' => array(
'zone' => 2,
),
),
),
),
),
// Override library path to CDN.
'library_path' => 'https://cdn.jsdelivr.net/fontawesome/4.7.0/',
);
return $libraries;
}
}

View File

@ -5,28 +5,11 @@ define("SEP"," <span class='fa fa-play e-breadcrumb'></span> ");
define("BOOTSTRAP", 3);
define('FONTAWESOME', 4);
$minified = deftrue('e_DEBUG') == true ? null : 'minified';
// e107::js("url", "https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js",'jquery', 2);
// e107::css('url', 'http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css');
// e107::css('url', "https://netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css");
e107::js("url", "https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js", 'jquery', 2);
// e107::css('url', 'https://cdn.jsdelivr.net/bootstrap/3.3.5/css/bootstrap.min.css');
e107::css('url', 'https://cdn.jsdelivr.net/fontawesome/4.5.0/css/font-awesome.min.css');
// Too slow.
// e107::css('url', "http://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css");
// e107::js('url', "http://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js");
e107::css('core', 'bootstrap3-editable/css/bootstrap-editable.css', 'jquery');
e107::js('core', 'bootstrap3-editable/js/bootstrap-editable.min.js', 'jquery', 4);
// e107::css('url', 'http://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/slate/bootstrap.min.css');
// e107::css('url', 'http://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/cyborg/bootstrap.min.css');
// e107::css('url', "https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/cosmo/bootstrap.min.css");
// e107::css('url', "https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/darkly/bootstrap.min.css");
e107::library('load', 'cdn.bootstrap', $minified);
e107::library('load', 'cdn.fontawesome', $minified);
e107::library('load', 'bootstrap.editable', $minified);
e107::css('theme','css/bootstrap-dark.min.css');
e107::css('theme','admin_style.css');
@ -34,8 +17,6 @@ e107::css('theme','admin_dark.css');
e107::css('theme','ie_all.css',null,'all',"<!--[if IE]>","<![endif]-->");
e107::css('inline', "
.mce-menubar .mce-caret { border-top-color: #C6C6C6!important }
.mce-menubar:hover .mce-caret { border-top-color: #FFFFFF!important }
.mce-menubar .mce-btn button { color: #C6C6C6!important; }
@ -48,7 +29,6 @@ e107::css('inline', "
.mce-menubtn:focus { background-color:transparent!important; color: #FFFFFF!important; border-color:transparent!important; }
.mce-menubar .mce-btn.mce-active { color:white!important; border-color:transparent!important; background-color: transparent!important; }
body.forceColors { margin:0; background-color: #373737; !important}
body.forceColors a { color: white}
body.forceColors li a { color: silver}
@ -56,8 +36,6 @@ body.forceColors li a { color: silver}
div#media-manager div.mce-window-head { background-color: #373737; !important }
div#media-manager div.mce-title { color:white; }
div#media-manager, html { color: silver; background-color: #2F2F2F; !important}
");
/*

File diff suppressed because one or more lines are too long