diff --git a/e107_admin/header.php b/e107_admin/header.php index 3dafbe679..ea699e5af 100644 --- a/e107_admin/header.php +++ b/e107_admin/header.php @@ -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 " "; + // [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 "\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 " \n"; diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 0a0365043..65c49ebf5 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -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() diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 81069eaf8..d5239e2c4 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -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 "; - e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2); + + e107::js('core','scriptaculous/controls.js','prototype', 2); //TODO - external JS e107::getJs()->footerInline(" //autocomplete fields diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 7962caca2..7adbb0bd5 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -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. */ - 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(); } /** diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index b1a669323..477648d24 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -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; diff --git a/e107_themes/jayya/admin_theme.php b/e107_themes/jayya/admin_theme.php index 13a2e73eb..4e5a266fc 100644 --- a/e107_themes/jayya/admin_theme.php +++ b/e107_themes/jayya/admin_theme.php @@ -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 "