Skip to content

Commit

Permalink
Have HordeCore handle loading of javascript files
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 9, 2013
1 parent ea5480e commit 69f84ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
8 changes: 0 additions & 8 deletions horde/js/topbar.js
Expand Up @@ -5,7 +5,6 @@ var HordeTopbar = {

// Vars used and defaulting to null/false:
// conf, searchGhost
jsfiles: $H(),

/**
* Updates the date in the sub bar.
Expand Down Expand Up @@ -33,14 +32,7 @@ var HordeTopbar = {
onUpdateTopbar: function(r)
{
$('horde-navigation').update();

this._renderTree(r.nodes, r.root_nodes);
r.files.each(function(file) {
if (!this.jsfiles.get(file)) {
$$('head')[0].insert(new Element('script', { src: file }));
this.jsfiles.set(file, 1);
}
}.bind(this));
},

_renderTree: function(nodes, root_nodes)
Expand Down
23 changes: 18 additions & 5 deletions horde/lib/Ajax/Application/Handler.php
Expand Up @@ -25,17 +25,30 @@ class Horde_Ajax_Application_Handler extends Horde_Core_Ajax_Application_Handler
/**
* AJAX action: Update topbar.
*
* @return object See Horde_Tree_Renderer_Menu#renderNodeDefinitions().
* @return Horde_Core_Ajax_Response_HordeCore Response object.
*/
public function topbarUpdate()
{
$GLOBALS['registry']->pushApp($this->vars->app);
return $GLOBALS['injector']
->getInstance('Horde_Core_Factory_Topbar')
global $injector, $registry;

$registry->pushApp($this->vars->app);
$node_defs = $injector->getInstance('Horde_Core_Factory_Topbar')
->create('Horde_Tree_Renderer_Menu', array('nosession' => true))
->getTree()
->renderNodeDefinitions();
$GLOBALS['registry']->popApp();
$registry->popApp();

if (isset($node_defs->files)) {
$jsfiles = $node_defs->files;
unset($node_defs->files);
} else {
$jsfiles = array();
}

$ob = new Horde_Core_Ajax_Response_HordeCore($node_defs);
$ob->jsfiles = $jsfiles;

return $ob;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion horde/package.xml
Expand Up @@ -1630,7 +1630,7 @@
<package>
<name>Horde_Core</name>
<channel>pear.horde.org</channel>
<min>2.7.0</min>
<min>2.10.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down

0 comments on commit 69f84ee

Please sign in to comment.