Skip to content

Remove Joomla namespace from sidebar script#5259

Merged
roland-d merged 3 commits intojoomla:stagingfrom
dgrammatiko:__sidebar_joomla_undefined
Dec 14, 2014
Merged

Remove Joomla namespace from sidebar script#5259
roland-d merged 3 commits intojoomla:stagingfrom
dgrammatiko:__sidebar_joomla_undefined

Conversation

@dgrammatiko
Copy link
Copy Markdown
Contributor

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

Solves #5258

@dgrammatiko
Copy link
Copy Markdown
Contributor Author

To test go to Banners -> Tracks and press the button export
screen shot 2014-11-30 at 4 11 50

Apply the patch and retest!

@Bakual
Copy link
Copy Markdown
Contributor

Bakual commented Nov 30, 2014

How about you just load core.js where the namespace is defined?

I think it's a bit strange when we start defining the same namespace in various places.
We should either load core.js or use a different/own/no namespace for the methods in the Isis template

@dgrammatiko
Copy link
Copy Markdown
Contributor Author

@Bakual The question here is: do we really need to define the function as Joomla.tooggleSidebar ?
A function toggleSidebar I think is unique enough...

@phproberto
Copy link
Copy Markdown
Contributor

The Joomla.toggleSidebar function has been removed in the latest sidebar PR.

@dgrammatiko
Copy link
Copy Markdown
Contributor Author

@phproberto I am afraid it is still there! The problem is that right now is not in core.js but is also dependent on core.js, which is not optimal. Take a look here:
https://github.com/joomla/joomla-cms/blob/staging/administrator/templates/isis/js/template.js#L60

@dgrammatiko
Copy link
Copy Markdown
Contributor Author

@phproberto The problem is that whenever a bootstrap modal is rendered an error:
ReferenceError: Can't find variable: Joomla is getting logged

screen shot 2014-11-30 at 3 41 36

@Fedik
Copy link
Copy Markdown
Member

Fedik commented Nov 30, 2014

@phproberto it was just moved from core.js to template.js 😉

@Bakual
Copy link
Copy Markdown
Contributor

Bakual commented Nov 30, 2014

The question here is: do we really need to define the function as Joomla.tooggleSidebar ?
A function toggleSidebar I think is unique enough...

Imho, it's better without the Joomla namespace because it's template specific 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not safe function definition 😄 ...
Javascript Best Practices say: always use var prefix for define a new variable 😏
But for current case I would recommend use:

window.toggleSidebar = function(force)

to be sure that toggleSidebar in the right scope 😉

@infograf768
Copy link
Copy Markdown
Member

@test
works here.

@dgrammatiko
Copy link
Copy Markdown
Contributor Author

@JoomliC can you test this one?

@cyrez
Copy link
Copy Markdown
Contributor

cyrez commented Dec 2, 2014

@DGT41 yes i can, but it could be better in think to change Joomla.toggleSidebar into JtoggleSidebar, so that, no undefined namespace as @Bakual suggested :

use a different/own/no namespace for the methods in the Isis template

...

The Joomla.toggleSidebar function has been removed in the latest sidebar PR.

@phproberto i thought core.js was always loaded in backend... so i've not changed it. But we can!

@DGT41 EDIT : yes, didn't view files before...

@dgrammatiko
Copy link
Copy Markdown
Contributor Author

@JoomliC Hehe I already did this, take a look at https://github.com/joomla/joomla-cms/pull/5259/files

@cyrez
Copy link
Copy Markdown
Contributor

cyrez commented Dec 2, 2014

@DGT41 Yes sorry! A little headache this morning, need more coffee !!!

@test success ! Tested with Isis, and a third-party admin template, all is ok! 👍

Well done Dimitris!

@dgrammatiko
Copy link
Copy Markdown
Contributor Author

@JoomliC Yes, thats the weird thing core.js is called in layouts/joomla/sidebars/submenu.php but for an unknown to me reason the modals throw an error. core.js will still be needed for the strings translations, so all that this is doing is removing the strange javascript error whenever a modal is fired!

@dgrammatiko dgrammatiko changed the title Make sure that Joomla namespace is defined otherwise define it! Remove Joomla namespace from sidebar script Dec 2, 2014
@waader
Copy link
Copy Markdown
Contributor

waader commented Dec 11, 2014

@test works!

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5259.

roland-d added a commit that referenced this pull request Dec 14, 2014
Remove Joomla namespace from sidebar script
@roland-d roland-d merged commit bd53946 into joomla:staging Dec 14, 2014
@dgrammatiko dgrammatiko deleted the __sidebar_joomla_undefined branch December 14, 2014 15:19
@rdeutz rdeutz added this to the Joomla! 3.4.0 milestone Feb 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants