Changeset 5958 for main/waeup.sirp/trunk


Ignore:
Timestamp:
22 Apr 2011, 02:00:44 (14 years ago)
Author:
uli
Message:

Register the CSS files in static/ as resources. This way we can
include them programmatically in views without knowing about any real
filesystem locations, dependencies and the like. hurry.resource will
inject correctly formed links to these CSS files for us.

Also add a javascript file as resource that can render jQuery tabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/resources.py

    r5929 r5958  
    2222"""Special JavaScript and CSS resources provided by waeup.sirp.
    2323"""
     24from hurry import yui
    2425from hurry.resource import Library, ResourceInclusion
    25 from hurry.jqueryui import jqueryui
     26from hurry.jqueryui import jqueryui, base, blitzer, ui_lightness, humanity
     27from hurry.jquery import jquery
     28
    2629
    2730#: All local resources are registered under the name ``waeup_sirp``.
     
    8285#:   <input type="submit" name="xyz" value="abc"/>
    8386#:          onclick="return confirmPost('Are you sure?')">
    84                                
    8587warning = ResourceInclusion(waeup_sirp, 'warning.js')       
     88
     89#: A resource that binds jQueryUI tabs to <div> tags with class
     90#: ``tabs``.
     91#:
     92#:
     93#: If you want jQuery tabs for some <div>s in your page then you
     94#: have to perform two steps:
     95#:
     96#: * In the `update()` method of the responsible view/page/form
     97#:   require the JavaScript code to be rendered into the page:
     98#:
     99#:     from waeup.sirp.browser.resources import tabs
     100#:     ...
     101#:     class MyPage(...):
     102#:       ...
     103#:       def update(self):
     104#:         tabs.need()
     105#:
     106#:   This way all required JavaScripts will be rendered correctly
     107#:   into the HTML page generated.
     108#:
     109#: * In your HTML code add some ``<div>`` tag with ``class`` set to
     110#    ``tabs``, like this::
     111#:   
     112#:      <div id="tabs">
     113#:        <ul>
     114#:          <li><a href="#tab-1"><span>Tab 1 Heading</span></a></li>
     115#:          <li><a href="#tab-2"><span>Tab 2 Heading</span></a></li>
     116#:        </ul>
     117#:        <div id="tab-1">
     118#:          Content of tab 1
     119#:        </div>
     120#:        <div id="tab-2">
     121#:          Content of tab 2
     122#:        </div>
     123#:      </div>
     124#:
     125#: When the HTML is rendered, clicking into one of the tabs will make
     126#: other <div>s disappear. See
     127#:
     128#:   http://jqueryui.com/demos/tabs/
     129#:
     130#: for details.
     131#:
     132tabs = ResourceInclusion(waeup_sirp, 'tabs.js',
     133                         depends=[base, jquery, jqueryui])
     134
     135#: Register basic YUI based CSS as a resource.
     136yuiapp_css = ResourceInclusion(
     137    waeup_sirp, 'yuiapp.css',
     138    depends=[yui.reset_fonts_grids, yui.sam])
     139
     140#: Register basic WAeUP base CSS (which is based on ``yuiapp.css`` as a
     141#: resource.
     142waeup_base_css = ResourceInclusion(
     143    waeup_sirp, 'waeup-base.css',
     144    depends=[yuiapp_css])
     145
     146#: The red WAeUP theme registered as a resource.
     147waeuptheme_red1 = ResourceInclusion(
     148    waeup_sirp, 'waeuptheme-red1.css',
     149    depends=[waeup_base_css, base])
     150
     151#: The gray WAeUP theme registered as a resource.
     152waeuptheme_gray1 = ResourceInclusion(
     153    waeup_sirp, 'waeuptheme-gray1.css',
     154    depends=[waeup_base_css])
Note: See TracChangeset for help on using the changeset viewer.