Make sure that Joomla namespace is defined otherwise define it!

This prevents error if core.js is not loaded by defining the Joomla namespace

Solves #5258 


not safe function definition :smile: ... 
Javascript Best Practices say: always use `var` prefix for define a new variable  :smirk: 
But for current case I would recommend  use:
```javascript
window.toggleSidebar = function(force)
```
to be sure that `toggleSidebar` in the right (global) scope :wink: