Skip to content
Snippets Groups Projects
Commit 4cfc2fa9 authored by Michael Fairchild's avatar Michael Fairchild
Browse files

Restore the admin interface JS

RequireJS was not being loaded/configured correctly for the admin interface because it is not in the framework
parent cc4ba700
No related branches found
No related tags found
4 merge requests!15WIP: Support WDN version 5.3,!8Update for elgg upgrade,!3Develop,!1Git fixes
...@@ -51,10 +51,11 @@ function unl_theme_init() { ...@@ -51,10 +51,11 @@ function unl_theme_init() {
// 'src' => "{$bower}fuelux/dist/js/fuelux.js", // 'src' => "{$bower}fuelux/dist/js/fuelux.js",
// )); // ));
if (elgg_get_context() != "admin") {
/** /**
* Elgg has its own requireJS, and expects a different baseURL than the UNL framework. Reset back to the framework. * Elgg has its own requireJS, and expects a different baseURL than the UNL framework. Reset back to the framework.
* Only do this for the main interface, the admin interface requires requirejs.
*/ */
$base_url = elgg_get_site_url(); $base_url = elgg_get_site_url();
//Add paths stuff to the requirejs config //Add paths stuff to the requirejs config
...@@ -65,16 +66,10 @@ function unl_theme_init() { ...@@ -65,16 +66,10 @@ function unl_theme_init() {
_elgg_services()->amdConfig->addPath('bootstrap', $base_url.'mod/unl_theme/vendors/bower_components/bootstrap/dist/js/bootstrap'); _elgg_services()->amdConfig->addPath('bootstrap', $base_url.'mod/unl_theme/vendors/bower_components/bootstrap/dist/js/bootstrap');
_elgg_services()->amdConfig->addPath('moment', $base_url.'mod/unl_theme/vendors/bower_components/moment/moment'); _elgg_services()->amdConfig->addPath('moment', $base_url.'mod/unl_theme/vendors/bower_components/moment/moment');
//Reset the base_url
//_elgg_services()->amdConfig->setBaseUrl('//unlcms.unl.edu/wdn/templates_4.1/scripts/compressed/');
//Tell elgg not to load its own version of require //Tell elgg not to load its own version of require
elgg_unregister_js('require'); elgg_unregister_js('require');
elgg_unregister_js('jquery-ui'); elgg_unregister_js('jquery-ui');
if (elgg_get_context() != "admin") {
//elgg_load_js("agency"); //elgg_load_js("agency");
elgg_load_js('respond'); elgg_load_js('respond');
elgg_load_js("bootstrap"); elgg_load_js("bootstrap");
......
...@@ -9,10 +9,16 @@ unset($amdConfig['deps']); ...@@ -9,10 +9,16 @@ unset($amdConfig['deps']);
?> ?>
// <script> // <script>
var elgg_require_config = <?php echo json_encode($amdConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ?>;
<?php unset($amdConfig['baseUrl']); ?>
var unl_require_config = <?php echo json_encode($amdConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ?>;
//load jquery-ui ourselves from the framework and override the global $ variable. //load jquery-ui ourselves from the framework and override the global $ variable.
if (typeof WDN !== 'undefined') {
require(['jquery', 'jqueryui'], function($) { require(['jquery', 'jqueryui'], function($) {
window.$ = $; window.$ = $;
}); });
<?php <?php
/** /**
* Elgg ships with is own baseUrl, which conflicts with the framework baseUrl. * Elgg ships with is own baseUrl, which conflicts with the framework baseUrl.
...@@ -20,12 +26,12 @@ require(['jquery', 'jqueryui'], function($) { ...@@ -20,12 +26,12 @@ require(['jquery', 'jqueryui'], function($) {
* 1) remove Elgg's base url (in favor of the framework's) * 1) remove Elgg's base url (in favor of the framework's)
* 2) define absolute paths to elgg's modules (see start.php) * 2) define absolute paths to elgg's modules (see start.php)
*/ */
unset($amdConfig['baseUrl']);
?>
//Merge the framework require config with elgg's require config (prefer UNL's settings) ?>
require.config(<?php echo json_encode($amdConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ?>); require.config(unl_require_config);
} else {
require = elgg_require_config;
}
<?php
// Note we don't process the require() queue yet because it may require('elgg') // Note we don't process the require() queue yet because it may require('elgg')
// and we have to load that synchronously a little later // and we have to load that synchronously a little later
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment