mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +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);
|
||||
}
|
||||
|
||||
|
||||
// [JSManager] Load JS Includes - Zone 1 - Before Library
|
||||
e107::getJs()->renderJs('header', 1);
|
||||
e107::getJs()->renderJs('header_inline', 1);
|
||||
@@ -368,6 +369,7 @@ $body_onload = "";
|
||||
* TODO - remove it from here
|
||||
*/
|
||||
require_once (e_HANDLER.'js_helper.php');
|
||||
|
||||
echo "
|
||||
<script type='text/javascript'>
|
||||
(".e_jshelper::toString(LAN_JSCONFIRM).").addModLan('core', 'delete_confirm');
|
||||
@@ -375,23 +377,26 @@ echo "
|
||||
</script>
|
||||
";
|
||||
|
||||
|
||||
// [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_inline', 5);
|
||||
|
||||
|
||||
/*
|
||||
* Fire Event e107:loaded
|
||||
* TODO - remove it from here, should be registered to e_jsmanager
|
||||
* or better - moved to core init.js(.php)
|
||||
*/
|
||||
echo "<script type='text/javascript'>\n";
|
||||
echo "<!--\n";
|
||||
echo "\$('e-js-css').remove();\n"; // unobtrusive JS - moved here from external e_css.php
|
||||
echo "document.observe('dom:loaded', function () {\n";
|
||||
echo "e107Event.trigger('loaded', null, document);\n";
|
||||
echo "});\n";
|
||||
echo "// -->\n";
|
||||
echo "</script>\n";
|
||||
|
||||
e107::js('inline',"\$('e-js-css').remove();
|
||||
document.observe('dom:loaded', function () {
|
||||
e107Event.trigger('loaded', null, document);
|
||||
});",'prototype',5);
|
||||
|
||||
e107::getJs()->renderJs('header_inline', 5);
|
||||
|
||||
echo "</head>
|
||||
<body".$body_onload.">\n";
|
||||
|
@@ -38,7 +38,8 @@ $gen = new convert();
|
||||
//Handle Ajax Calls
|
||||
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()
|
||||
|
@@ -3695,8 +3695,8 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
*/
|
||||
public function ListHeader()
|
||||
{
|
||||
e107::getJs()->headerCore('core/tabs.js')
|
||||
->headerCore('core/admin.js');
|
||||
e107::js('core','core/tabs.js','prototype');
|
||||
e107::js('core','core/admin.js','prototype');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4364,7 +4364,8 @@ class e_admin_form_ui extends e_form
|
||||
</form>
|
||||
";
|
||||
|
||||
e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2);
|
||||
|
||||
e107::js('core','scriptaculous/controls.js','prototype', 2);
|
||||
//TODO - external JS
|
||||
e107::getJs()->footerInline("
|
||||
//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 $data depends on the type - path/url or inline js source
|
||||
* @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->setDependency($dep);
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'core':
|
||||
@@ -1402,6 +1405,8 @@ class e107
|
||||
else $jshandler->requirePluginLib($type, $data);
|
||||
break;
|
||||
}
|
||||
|
||||
$jshandler->resetDependency();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1412,9 +1417,11 @@ class e107
|
||||
* @param string $preComment possible comment e.g. <!--[if lt IE 7]>
|
||||
* @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->setDependency($dep);
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'core':
|
||||
@@ -1443,6 +1450,7 @@ class e107
|
||||
if(self::isInstalled($type)) $jshandler->pluginCSS($type, $data, $media, $preComment, $postComment);
|
||||
break;
|
||||
}
|
||||
$jshandler->resetDependency();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -14,6 +14,21 @@ global $pref, $eplug_admin, $THEME_JSLIB, $THEME_CORE_JSLIB;
|
||||
|
||||
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
|
||||
*
|
||||
@@ -126,6 +141,13 @@ class e_jsmanager
|
||||
* @var e_jsmanager
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
/**
|
||||
* Current Framework Dependency
|
||||
*
|
||||
* @var string null | prototype | jquery
|
||||
*/
|
||||
protected $_dependence = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -509,6 +531,17 @@ class e_jsmanager
|
||||
$this->addJs('footer_inline', $js_content, $priority);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
function setDependency($dep)
|
||||
{
|
||||
$this->_dependence = $dep;
|
||||
}
|
||||
|
||||
public function resetDependency()
|
||||
{
|
||||
$this->_dependence = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require JS file(s). Used by corresponding public proxy methods.
|
||||
@@ -534,6 +567,7 @@ class e_jsmanager
|
||||
// ie. e107 Core Minimum: JS similar to e107 v1.0 should be loaded "e_js.php" (no framwork dependency)
|
||||
// with basic functions like SyncWithServerTime() and expandit(), externalLinks() etc.
|
||||
|
||||
|
||||
|
||||
if(empty($file_path))
|
||||
{
|
||||
@@ -544,7 +578,16 @@ class e_jsmanager
|
||||
{
|
||||
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.
|
||||
{
|
||||
$type = 'header';
|
||||
@@ -565,6 +608,12 @@ class e_jsmanager
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
if($runtime_location == 'front' && $this->isInAdmin())
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
$tp = e107::getParser();
|
||||
$runtime = false;
|
||||
|
@@ -42,13 +42,47 @@ define("IMODE", "lite");
|
||||
$no_core_css = TRUE;
|
||||
|
||||
//temporary fixed - awaiting theme.xml addition
|
||||
e107::getJs()->requireCoreLib(array(
|
||||
'core/decorate.js' => 2,
|
||||
'core/tabs.js' => 2
|
||||
));
|
||||
e107::js('core', 'core/decorate.js', 'prototype', 2);
|
||||
e107::js('core', 'core/tabs.js', 'prototype', 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()
|
||||
{
|
||||
return '';
|
||||
|
||||
return "
|
||||
<script type='text/javascript'>
|
||||
/**
|
||||
|
Reference in New Issue
Block a user