Rob
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
On 25.03.2011 14:25, Rob Stocker wrote:
> Hi Elin,
> the reason I am using sub templates is because 50% of the template will be
> consistent across each of the views, eg view/building/tmpl/default.php
>
> The remaining subtemplates being based on the individual building type for
> example view/building/default_bank.php or view/building_shop.php
>
> (using community builder was a bad example.)
>
> But even something as simple as the following will not work if it is placed
> in the code that is to be shown in the modal
>
> alert();
>
> function alert(){
> alert('this is a test')
> }
>
Well, since nobody here seems to be familiar with SqueezeBox/MooTools,
I'll give it a try (though I'm not an expert in how Joomla integrates
SqueezeBox).
=> You said earlier, that you do *not* use the iframe handler of SqueezeBox.
That's *exactly* the reason, why it does *not* execute any JavaScript in
it's content. Apparently, you are using either "adopt" mode or "ajax"
mode (I don't know which one, because I don't know which default is used
by Joomla in the SqueezeBox's initializer-options).
If using "ajax" mode, you can set ajaxOptions.evalScripts to true, like
this (JS-Code):
options = {handler: 'ajax', size{x: 500, y: 400}, ajaxOptions:
{evalScripts: true}};
SqueezeBox.initialize(options);
Joomla's PHP equivalent would be (i believe):
$mopts = array('handler' => 'ajax', ... , 'ajaxOptions' =
array('evalScripts' => true));
echo JHTML::_('behavior.modal', $mopts);
Have a look into media/system/js/modal-uncompressed.js
At the beginning of this file, you see all the supported optons and
their defaults.
If you are using "adopt" mode however, then you are pretty much on your
own, because in that mode, JavaScript (re-)execution doesn't make much
sense and therefore is is not implemented at all. Theoretically, you
could do that from within an event handler. However: Specifying an
event-handler requires it to be a JavaScript object of type "function",
*BUT* Joomla's JavaScript wrapper (which is responsible for converting
PHP arrays into JavaScript objects) does not support that. (It only
supports strings, booleans, numbers and sub-objects). So it basically
boils down to initializing SqueezeBox yourself from within JavaScript.
E.g.
1. Do *not* use JHTML::_('behavior.modal'); // Doesn't support
eventhandler functions.
2. Instead, use JHTML::_('behavior.mootools');
3. Then, in your invoking page header, initialize SqueezeBox yourself:
window.addEvent("domready", function() {
var game = new myCuteGameClass();
var opts = {
handler: 'adopt',
onOpen: game.onOpen.bind(game),
size: {
x: 500,
y: 600,
},
// ... other options
};
SqueezeBox.initialize(opts);
// The following is actually only needed, if you want to
// stick to Joomla's mechanism of instrumenting onclick
// events into all A-Elements of class "modal".
// Instead, you could call SqueezeBox.fromElement(...)
// programmatically. The argument of $$() has the same
// syntax like a CSS-Selector.
$$("a.modal").each(function(el) {
el.addEvent("click", function(e) {
new Event(e).stop();
SqueezeBox.fromElement(el);
});
});
});
4. In your event handler, iterate over all DOM-Elements of the modal
content, and for each script object, call eval (resp. mootool's $exec).
E.g.
var myCuteGameClass = new Class({
initialize: function() {
// whatever ...
},
onOpen: function(content) {
content.each(el) {
// check el for type 'src/javascript'
// if true, check for text, if non-empty
// exec it, otherwise check for src, if
// non-empty, load and exec it.
}
}
});
Hope, this gives at least some hints...
- -Fritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD4DBQFNjRtmboM4mAMyprARAkK8AJUcV0UYlsPJosASHsQmbvdScO0QAJ0d6HBa
1INvivGsMIeEEMgHQnixcA==
=ED6T
-----END PGP SIGNATURE-----
On 25.03.2011 23:47, Fritz Elfert wrote:
> On 25.03.2011 14:25, Rob Stocker wrote:
...
Another tip for debugging JavaScript in Joomla using FireBug:
Use J1.5, not J1.6.
Reason:
In 1.5, Joomla checks for the string 'konqueror' in the User-Agent
header. If it finds it, it sends the -uncompressed variant of all
scripts like mootools etc. So you fetch some FF-Plugin for altering your
User-Agent, use that to append 'konqueror' to your User-Agent and voila,
JS-Debugging in FireBug made easy.
In J1.6, this useful check is gone and you only can enable uncompressed
scripts by enabling the global debug flag. This however is bad because
as a side-effect, you get tons of debugging-output in which you are not
really interested and which destroys your carefully designed page-layout
of the modal content.
- -Fritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNjR6wboM4mAMyprARApnZAJ4+wOV5svHrr/eGmsHLNAv9SLGBugCfZCjL
b78BnhQy4HZijbz+o6B3o0A=
=4xFL
-----END PGP SIGNATURE-----
-----END PGP SIGNATURE-----
On 25.03.2011 14:25, Rob Stocker wrote:
> I don't actually know what a modal does, and this is my issue
Umhh just noticed that, ok - you probably should read my responses in
reverse order ;) otherwise me talking about SqueezeBox doesn't really
makes sense:
Joomla's "behavior.modal" uses a script named "SqueezeBox", which uses
MooTools and which facilitates the creation of a lightbox filled with
content from a varety of sources: url's inside iframes, iframes filled
by JS-HTTPRequests, content aquired by MooTool's "adopt" method from an
existing DOM-Tree, images...
BTW: This script has it's own homepage:
http://digitarald.de/project/squeezebox/
In Joomla, this script is normally used in one mode only: The 'iframe'
mode. If you write JHTML::_('behavior.modal'), then this triggers
several actions:
- - mootools.js inclusion is added to the headers (if not already added)
- - modal.j (which contains the SqueezeBox code) is added, (again, only if
not yet doen)
- - In the head section of the document, an event handler for the domready
event is installed which instruments all A-Elements of class "modal"
with onclick-handlers invoking SqueezeBox.fromElement(...)
So: When using Joomla's "modal" (with default settings), you actually
use SqueezeBox's 'iframe' mode to load another Joomla page inside that
iframe.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNjSSpboM4mAMyprARAhTVAJ4y/AaV9YrmOFcSw/zGKnode4kouwCgpFq3
yi81Pq9D58/hdo8gcxraxiY=
=2og5
-----END PGP SIGNATURE-----
On 26.03.2011 00:13, Mark Dexter wrote:
> Fritz, it would be great if you had a specific suggestion for how to make
> this work better in 1.6. Even better would be to suggest a patch. Thanks!
> Mark
>
No problem. Ad hoc, three solutions come to mind:
1. (Re-)add a check for a specific string in the User-Agent (just like
in J1.5) - simple.
2. Add another global debug variable, just for javascript - again: simple.
3. Extend the global debug flag to be used as a bit value instead of
just a boolean. Then assign bitmasks to various debug categories like
JDEBUG_MASK_DB, JDEBUG_MASK_FOO, JDEBUG_MASK_BAR (similar to PHP's error
stuff) one of them could be JDEBUG_MASK_JAVASCRIPT - complex, lots of
changes all over the code ... but most versatile and extendable.
For 1. and 2. i could have a patch by next week. For 3. i'm afraid I
have to postpone that until I finished the my component's support for
J1.6 (in about 2 weeks).
So, which one would you like?
- -Fritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNjSkYboM4mAMyprARArGfAJ9DgYW89HxJjlGQfm5JbQFiG9apDwCZAetw
vz/537JWpMCs/A76dMMH7Yw=
=VYRm
-----END PGP SIGNATURE-----
On 26.03.2011 00:51, Mark Dexter wrote:
> Do you have a preference between 1 and 2?
My personal preference is 1.), because you can enable/disable debugging
just by setting your UserAgent string. No action on the server-side
required. This has been *very* handy in the past when doing support for
Users - just visit their site with your modified UserAgent and be able
to set breakpoints in JavaScript right away.
- -Fritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNjS1/boM4mAMyprARAlflAKCCDkDbI0SxN4NgjeWaqvchPuT/TQCeLnJY
7AnOHo5Yai4B7hC/L4WpFtM=
=DzxR
-----END PGP SIGNATURE-----
-----END PGP SIGNATURE-----
On 26.03.2011 01:08, Mark Dexter wrote:
> In that case, I would agree and say go with option (1). If you can get a
> patch done, I'll try to get it into the next release. We are planning to
> freeze trunk for the release of 1.6.2 in about 1 week, so if you can get it
> done in the next few days, we can try to get it into 1.6.2. Thanks. Mark
Just got a better idea (a mixture of 1 and 2): Like in (2), use a
separate debug flag, but add a single global check for the UserAgent
string which can set this flag.
This reduces the checking part to a single function in the code (not
like in 1.5 where those checks were spread all over the code) and also
gives the ability to enable it from both backend and via UserAgent...
The changes in existing code would be even less.
I think I'll do that one.
-Fritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNjTPTboM4mAMyprARAsI1AKCMsKabmnmEe0z3irjRzj10ZISsMgCgmJUo
ExA6WhFSiIr7uER0ehjrDT4=
=yxr/
-----END PGP SIGNATURE-----
-----END PGP SIGNATURE-----
-----END PGP SIGNATURE-----
On 26.03.2011 03:30, Ian MacLennan wrote:
> I have also found myself in situations where it would be useful to be able
> to get uncompressed javascript output.
>
> I don't like the idea of using the user agent - that was intended to
> workaround Konqueror issues - not specifically for debugging javascript.
>
> I would be more in favour of another debugging parameter called 'Javascript
> Debugging' or something like that which would have three possible settings:
> 1. Off (default)
> 2. On (Switchable)
> 3. On (Permanent)
>
> Setting 1 and 3 should be self explanatory. Setting 2 would add a check for
> a request variable that could be used to turn debugging on or off for the
> duration of the session. This would be a lot easier to work with and would
> be a lot more accessible than having to set the user agent.
I like the idea of having 3 states. This way, admins can decide if they
want to make this feature accessible remotely or not.
What I don't like is the Request-variable. I personally find the
UA-header less intrusive, especially if you don't change the original
content but just append some keyword.
Having it in a regular request is more intrusive. Cookies, POST- or
URL-params are processed by Joomla's "regular" request handling. This
could - in theory - lead to different code paths depending on existence
of the debug param. (Just imagine some extension handling a GET request,
checking if there are any request parameters at all.) The UA however is
normally only checked for specific fragments like "Mozilla" etc, never
for equality of the whole UA string. Therefore, a change of code paths
other than setting the debug flag is *very* unlikely.
Furthermore, setting a Cookie requires one additional Request/Response
cycle to precede the actual debugging. Again, this can have side effects
on the state of the debugged code.
About ability to set the keyword:
All major browsers - even IE - have support for changing the UA either
natively, or a plugin is available for that.
- -Fritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNjWnSboM4mAMyprARAl3zAJ9w6otJfn9oTTaRyOzJ372g6KE0TACfWgnR
Dzr3zWCYbinhigbPCUgTe34=
=VcW0
-----END PGP SIGNATURE-----
On 26.03.2011 03:30, Ian MacLennan wrote:
> I have also found myself in situations where it would be useful to be able
> to get uncompressed javascript output.
>
I've added Item #25454 in the Feature Request Tracker with a patch
against trunk attached.
I implemented Ian's suggestion of having a 3-state setting and - for now
- - implemented my variant of using the UA header. But that can easily be
changed in just 2 lines (one code line, one description tooltip in the
language ini). Let's see if there are more opinions than just ours.
- -Fritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNjW7nboM4mAMyprARAo6JAJ9/QPYuhOwqEsYSxwYppDJAmKnwigCeL2PC
kBMadzJuUKw4peG9p43BRgM=
=DoxQ
-----END PGP SIGNATURE-----
-----END PGP SIGNATURE-----