Commit 8051d9cf authored by Bartek Górny's avatar Bartek Górny

css file inclusion mechanism (same as for javascript files)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20271 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b450bf9b
......@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PageTemplates.ZopePageTemplate</string>
<string>ZopePageTemplate</string>
</tuple>
<none/>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -76,11 +73,8 @@ IDEAS:\n
<meta http-equiv="Content-Style-Type" content="text/css" />\n
<title tal:define="title title | string:ERP5"\n
tal:content="python: \'%s | %s\' % (title, here.getPortalObject().title_or_id())"></title>\n
<tal:block tal:repeat="css css_list">\n
<link tal:attributes="href css" type="text/css" rel="stylesheet" />\n
</tal:block>\n
<tal:block tal:replace="nothing">\n
<!-- Render each field\'s css and javascript. -->\n
<!-- Render each field\'s css and include css\'s and javascripts. -->\n
</tal:block>\n
<tal:block tal:condition="python: form is not None">\n
<tal:block tal:repeat="group python: [x for x in form.get_groups(include_empty=0) if x != \'hidden\']">\n
......@@ -91,11 +85,15 @@ IDEAS:\n
tal:attributes="type python:\'text/css\'">\n
</style>\n
</tal:block>\n
<tal:block tal:define="dummy python: css_list.extend(field.get_css_list(REQUEST=request))" />\n
<tal:block tal:define="dummy python: js_list.extend(field.get_javascript_list(REQUEST=request))" />\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
<!-- May need to remove duplicates -->\n
<tal:block tal:repeat="css css_list">\n
<link tal:attributes="href css" type="text/css" rel="stylesheet" />\n
</tal:block>\n
<tal:block tal:repeat="js js_list">\n
<script tal:attributes="src js" type="text/javascript"></script>\n
</tal:block>\n
......
......@@ -496,6 +496,15 @@ def Widget_render_css(self, field, REQUEST):
pass
Widget.render_css = Widget_render_css
def Widget_get_css_list(self, field, REQUEST):
"""
Return CSS needed by the widget - to be overwritten in field classes.
Should return a list of CSS file names.
These names will be appended to global css_list and included in a rendered page.
"""
return []
Widget.get_css_list = Widget_get_css_list
def Widget_get_javascript_list(self, field, REQUEST):
"""
Return JS needed by the widget - to be overwritten in field classes.
......@@ -1456,16 +1465,26 @@ Field.render_pdf = Field_render_pdf
def Field_render_css(self, REQUEST=None):
"""
Generate css content which will be added in the html header.
Generate css content which will be added inline.
XXX key parameter may be needed.
"""
return self.widget.render_css(self, REQUEST)
Field.render_css = Field_render_css
def Field_get_css_list(self, REQUEST=None):
"""
Returns list of css sheets needed by the field
to be included in global css imports
"""
return self.widget.get_css_list(self, REQUEST)
Field.get_css_list = Field_get_css_list
def Field_get_javascript_list(self, REQUEST=None):
"""
Returns list of javascript needed by the field
Returns list of javascript needed by the field
to be included in global js imports
"""
return self.widget.get_javascript_list(self, REQUEST)
Field.get_javascript_list = Field_get_javascript_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment