Le 22 janv. 2011 à 19:14, Kevin Gill a écrit :

> Sorry, that should be...
> 
>          expression="here/view/test_js_require:is_js_required"

Unless your JS potentially conflicts with standard javascripts, I would say 
"try to make this JS as less intrusive as possible, avoid dependencies on other 
javascripts where possible, expose as less global symbols as possible (hint : 
use Firebug to check for available symbols), and leave the TALES expression 
empty".

Otherwise, just add a view that does this in your browser/utils.py that makes 
the check :

<browser:view
   name="plonetheme-xxx-is-js-required"
   for="Products.CMFPlone.interfaces.IPloneSiteRoot"
   class=".utils.JSCondition"
   permission="zope.Public" />

class JSCondition(BrowserView):
    def __call__(self):
        # Your own cooking
        return TrueOrFalse

and use "portal/@@plonetheme-xxx-is-js-required" in the TALES condition field 
in the JS registry. Same can apply to other registries.

HTH
-- 
Gilles Lenfant

> 
> On 22/01/11 13:14, Kevin Gill wrote:
>> I have a map widget that requires javascript includes. It is written for 
>> dexterity / z3c.forms.
>> 
>> What is the best / current approach to handling the conditional includes.
>> 
>> If I put it into portal_javascripts it is managed by plone. However, I have 
>> to work out whether to include it using tal. How will I compose the tal 
>> statement to include the view - the examples I have seen work on the context 
>> object. I assume I should have something like
>> 
>> <?xml version="1.0"?>
>> <object  name="portal_javascripts">
>> <javascript
>>        id="++resource++plonetheme.xxx.scripts/cufon-yui.js"
>>        cacheable="True"  compression="safe"  cookable="True"
>>        enabled="True"  inline="False"  insert-after="toc.js"
>> 
>>        expression="view/test_js_require:is_js_required"
>> />
>> </object>
>> 
>> Where test_js_require is a path adapter for my view.
>> 
>> Any suggestions?
>> 
>> Thanks
>> 
>> Kevin
>> 
>> 
>> _______________________________________________
>> Product-Developers mailing list
>> [email protected]
>> https://lists.plone.org/mailman/listinfo/product-developers
> 
> _______________________________________________
> Product-Developers mailing list
> [email protected]
> https://lists.plone.org/mailman/listinfo/product-developers

_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/product-developers

Reply via email to