mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
JS framework on-demand (working in admin-area right now)
This commit is contained in:
@@ -241,6 +241,7 @@ else
|
|||||||
define("e_WYSIWYG", FALSE);
|
define("e_WYSIWYG", FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// [JSManager] Load JS Includes - Zone 1 - Before Library
|
// [JSManager] Load JS Includes - Zone 1 - Before Library
|
||||||
e107::getJs()->renderJs('header', 1);
|
e107::getJs()->renderJs('header', 1);
|
||||||
e107::getJs()->renderJs('header_inline', 1);
|
e107::getJs()->renderJs('header_inline', 1);
|
||||||
@@ -368,6 +369,7 @@ $body_onload = "";
|
|||||||
* TODO - remove it from here
|
* TODO - remove it from here
|
||||||
*/
|
*/
|
||||||
require_once (e_HANDLER.'js_helper.php');
|
require_once (e_HANDLER.'js_helper.php');
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
(".e_jshelper::toString(LAN_JSCONFIRM).").addModLan('core', 'delete_confirm');
|
(".e_jshelper::toString(LAN_JSCONFIRM).").addModLan('core', 'delete_confirm');
|
||||||
@@ -375,23 +377,26 @@ echo "
|
|||||||
</script>
|
</script>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|
||||||
// [JSManager] Load JS Includes - Zone 5 - After theme_head, before e107:loaded trigger
|
// [JSManager] Load JS Includes - Zone 5 - After theme_head, before e107:loaded trigger
|
||||||
|
|
||||||
|
// unobtrusive JS - moved here from external e_css.php
|
||||||
|
|
||||||
e107::getJs()->renderJs('header', 5);
|
e107::getJs()->renderJs('header', 5);
|
||||||
e107::getJs()->renderJs('header_inline', 5);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fire Event e107:loaded
|
* Fire Event e107:loaded
|
||||||
* TODO - remove it from here, should be registered to e_jsmanager
|
* TODO - remove it from here, should be registered to e_jsmanager
|
||||||
* or better - moved to core init.js(.php)
|
* or better - moved to core init.js(.php)
|
||||||
*/
|
*/
|
||||||
echo "<script type='text/javascript'>\n";
|
|
||||||
echo "<!--\n";
|
e107::js('inline',"\$('e-js-css').remove();
|
||||||
echo "\$('e-js-css').remove();\n"; // unobtrusive JS - moved here from external e_css.php
|
document.observe('dom:loaded', function () {
|
||||||
echo "document.observe('dom:loaded', function () {\n";
|
e107Event.trigger('loaded', null, document);
|
||||||
echo "e107Event.trigger('loaded', null, document);\n";
|
});",'prototype',5);
|
||||||
echo "});\n";
|
|
||||||
echo "// -->\n";
|
e107::getJs()->renderJs('header_inline', 5);
|
||||||
echo "</script>\n";
|
|
||||||
|
|
||||||
echo "</head>
|
echo "</head>
|
||||||
<body".$body_onload.">\n";
|
<body".$body_onload.">\n";
|
||||||
|
@@ -38,7 +38,8 @@ $gen = new convert();
|
|||||||
//Handle Ajax Calls
|
//Handle Ajax Calls
|
||||||
if($newspost->ajax_observer()) exit;
|
if($newspost->ajax_observer()) exit;
|
||||||
|
|
||||||
e107::getJs()->requireCoreLib('core/admin.js');
|
e107::js('core','core/admin.js','prototype');
|
||||||
|
//e107::getJs()->requireCoreLib('core/admin.js');
|
||||||
|
|
||||||
|
|
||||||
function headerjs()
|
function headerjs()
|
||||||
|
@@ -3695,8 +3695,8 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
*/
|
*/
|
||||||
public function ListHeader()
|
public function ListHeader()
|
||||||
{
|
{
|
||||||
e107::getJs()->headerCore('core/tabs.js')
|
e107::js('core','core/tabs.js','prototype');
|
||||||
->headerCore('core/admin.js');
|
e107::js('core','core/admin.js','prototype');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4364,7 +4364,8 @@ class e_admin_form_ui extends e_form
|
|||||||
</form>
|
</form>
|
||||||
";
|
";
|
||||||
|
|
||||||
e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2);
|
|
||||||
|
e107::js('core','scriptaculous/controls.js','prototype', 2);
|
||||||
//TODO - external JS
|
//TODO - external JS
|
||||||
e107::getJs()->footerInline("
|
e107::getJs()->footerInline("
|
||||||
//autocomplete fields
|
//autocomplete fields
|
||||||
|
@@ -1352,10 +1352,13 @@ class e107
|
|||||||
* @param string $type core|theme|footer|inline|footer-inline|url or any existing plugin_name
|
* @param string $type core|theme|footer|inline|footer-inline|url or any existing plugin_name
|
||||||
* @param string $data depends on the type - path/url or inline js source
|
* @param string $data depends on the type - path/url or inline js source
|
||||||
* @param integer $zone [optional] leave it null for default zone
|
* @param integer $zone [optional] leave it null for default zone
|
||||||
|
* @param string $dep dependence : null | prototype | jquery
|
||||||
*/
|
*/
|
||||||
public static function js($type, $data, $zone = null)
|
public static function js($type, $data, $dep = null, $zone = null)
|
||||||
{
|
{
|
||||||
$jshandler = e107::getJs();
|
$jshandler = e107::getJs();
|
||||||
|
$jshandler->setDependency($dep);
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
case 'core':
|
case 'core':
|
||||||
@@ -1402,6 +1405,8 @@ class e107
|
|||||||
else $jshandler->requirePluginLib($type, $data);
|
else $jshandler->requirePluginLib($type, $data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$jshandler->resetDependency();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1412,9 +1417,11 @@ class e107
|
|||||||
* @param string $preComment possible comment e.g. <!--[if lt IE 7]>
|
* @param string $preComment possible comment e.g. <!--[if lt IE 7]>
|
||||||
* @param string $postComment possible comment e.g. <![endif]-->
|
* @param string $postComment possible comment e.g. <![endif]-->
|
||||||
*/
|
*/
|
||||||
public static function css($type, $data, $media = 'all', $preComment = '', $postComment = '')
|
public static function css($type, $data, $dep = null, $media = 'all', $preComment = '', $postComment = '', $dependence = null)
|
||||||
{
|
{
|
||||||
$jshandler = e107::getJs();
|
$jshandler = e107::getJs();
|
||||||
|
$jshandler->setDependency($dep);
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
case 'core':
|
case 'core':
|
||||||
@@ -1443,6 +1450,7 @@ class e107
|
|||||||
if(self::isInstalled($type)) $jshandler->pluginCSS($type, $data, $media, $preComment, $postComment);
|
if(self::isInstalled($type)) $jshandler->pluginCSS($type, $data, $media, $preComment, $postComment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$jshandler->resetDependency();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -14,6 +14,21 @@ global $pref, $eplug_admin, $THEME_JSLIB, $THEME_CORE_JSLIB;
|
|||||||
|
|
||||||
class e_jsmanager
|
class e_jsmanager
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Supported Libraries (Front-End) - loaded on demand.
|
||||||
|
*/
|
||||||
|
protected $_libraries = array(
|
||||||
|
'prototype' => array(
|
||||||
|
'prototype/prototype.js' ,
|
||||||
|
'scriptaculous/scriptaculous.js',
|
||||||
|
'scriptaculous/effects.js',
|
||||||
|
'e107.js'),
|
||||||
|
|
||||||
|
'jquery' => array(
|
||||||
|
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
|
||||||
|
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js")
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core JS library files, loaded via e_jslib.php
|
* Core JS library files, loaded via e_jslib.php
|
||||||
*
|
*
|
||||||
@@ -127,6 +142,13 @@ class e_jsmanager
|
|||||||
*/
|
*/
|
||||||
protected static $_instance = null;
|
protected static $_instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current Framework Dependency
|
||||||
|
*
|
||||||
|
* @var string null | prototype | jquery
|
||||||
|
*/
|
||||||
|
protected $_dependence = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@@ -510,6 +532,17 @@ class e_jsmanager
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setDependency($dep)
|
||||||
|
{
|
||||||
|
$this->_dependence = $dep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetDependency()
|
||||||
|
{
|
||||||
|
$this->_dependence = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Require JS file(s). Used by corresponding public proxy methods.
|
* Require JS file(s). Used by corresponding public proxy methods.
|
||||||
*
|
*
|
||||||
@@ -535,6 +568,7 @@ class e_jsmanager
|
|||||||
// with basic functions like SyncWithServerTime() and expandit(), externalLinks() etc.
|
// with basic functions like SyncWithServerTime() and expandit(), externalLinks() etc.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(empty($file_path))
|
if(empty($file_path))
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
@@ -545,6 +579,15 @@ class e_jsmanager
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load Required Library (prototype | jquery)
|
||||||
|
if($pre != 'noloop' && $this->_dependence != null && isset($this->_libraries[$this->_dependence])) // load framework
|
||||||
|
{
|
||||||
|
foreach($this->_libraries[$this->_dependence] as $inc)
|
||||||
|
{
|
||||||
|
$this->addJs('core', $inc, 'all', 'noloop');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($type == 'core' && !is_array($file_path) && substr($file_path,0,4)=='http' ) // Core using CDN.
|
if($type == 'core' && !is_array($file_path) && substr($file_path,0,4)=='http' ) // Core using CDN.
|
||||||
{
|
{
|
||||||
$type = 'header';
|
$type = 'header';
|
||||||
@@ -566,6 +609,12 @@ class e_jsmanager
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($runtime_location == 'front' && $this->isInAdmin())
|
||||||
|
{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$runtime = false;
|
$runtime = false;
|
||||||
switch($type)
|
switch($type)
|
||||||
|
@@ -42,13 +42,47 @@ define("IMODE", "lite");
|
|||||||
$no_core_css = TRUE;
|
$no_core_css = TRUE;
|
||||||
|
|
||||||
//temporary fixed - awaiting theme.xml addition
|
//temporary fixed - awaiting theme.xml addition
|
||||||
e107::getJs()->requireCoreLib(array(
|
e107::js('core', 'core/decorate.js', 'prototype', 2);
|
||||||
'core/decorate.js' => 2,
|
e107::js('core', 'core/tabs.js', 'prototype', 2);
|
||||||
'core/tabs.js' => 2
|
|
||||||
));
|
e107::js('inline',"
|
||||||
|
/**
|
||||||
|
* Decorate all tables having e-list class
|
||||||
|
* TODO: add 'adminlist' class to all list core tables, allow theme decorate.
|
||||||
|
*/
|
||||||
|
e107.runOnLoad( function(event) {
|
||||||
|
var element = event.memo['element'] ? $(event.memo.element) : $$('body')[0];
|
||||||
|
|
||||||
|
element.select('table.adminlist:not(.no-decorate)').each(function(element) {
|
||||||
|
e107Utils.Decorate.table(element, {tr_td: 'first last'});
|
||||||
|
});
|
||||||
|
element.select('div.admintabs').each(function(element) {
|
||||||
|
//show tab navaigation
|
||||||
|
element.select('ul.e-tabs').each( function(el){
|
||||||
|
el.show();
|
||||||
|
el.removeClassName('e-hideme');//prevent hideme re-register (e.g. ajax load)
|
||||||
|
});
|
||||||
|
//init tabs
|
||||||
|
new e107Widgets.Tabs(element);
|
||||||
|
//hide legends if any
|
||||||
|
element.select('legend').invoke('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
}, document, true);
|
||||||
|
"
|
||||||
|
,'prototype');
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// e107::getJs()->requireCoreLib(array(
|
||||||
|
// 'core/decorate.js' => 2,
|
||||||
|
// 'core/tabs.js' => 2
|
||||||
|
// ));
|
||||||
|
|
||||||
function theme_head()
|
function theme_head()
|
||||||
{
|
{
|
||||||
|
return '';
|
||||||
|
|
||||||
return "
|
return "
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user