source: main/waeup.sirp/trunk/src/waeup/sirp/browser/resources.py @ 6247

Last change on this file since 6247 was 6064, checked in by Henrik Bettermann, 13 years ago

Change hierarchy of depencies of resources.

File size: 8.1 KB
Line 
1##
2## resources.py
3## Login : <uli@pu.smp.net>
4## Started on  Fri Mar 11 10:49:59 2011 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2011 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22"""Special JavaScript and CSS resources provided by waeup.sirp.
23"""
24#from hurry import yui
25from hurry.resource import Library, ResourceInclusion
26from hurry.jqueryui import jqueryui, base, blitzer, ui_lightness, humanity
27from hurry.jquery import jquery
28
29
30#: All local resources are registered under the name ``waeup_sirp``.
31waeup_sirp = Library('waeup_sirp', 'static')
32
33#: A resource that binds a jQueryUI datepicker widget to each
34#: <div> or <input> tag with class ``datepicker``.
35#: If you want to let a JavaScript datepicker appear when
36#: clicking into some input field, then you have to perform
37#: two steps:
38#:
39#: * In the `update()` method of the responsible view/page/form
40#:   require the JavaScript code to be rendered into the page:
41#:
42#:     from waeup.sirp.browser.resources import datepicker
43#:     ...
44#:     class MyPage(...):
45#:       ...
46#:       def update(self):
47#:         datepicker.need()
48#:
49#:   This way all required JavaScripts will be rendered correctly
50#:   into the HTML page generated.
51#:
52#: * In your HTML code add some ``<input>`` or ``<div>`` tag with
53#:   ``class`` set to ``datepicker``, like this::
54#:
55#:     <input type="text" name="entrydate" class="datepicker" />
56#:
57#: When the HTML is rendered, clicking into the field will open
58#: a datepicker widget. The datepicker functionality will be
59#: delivered by jQueryUI for every ``<div>/<input>`` field with class
60#: ``datepicker`` set.
61#:
62#: That means, you can also have several date input fields on a
63#: single page as long as each one has class ``datepicker``.
64#:
65#: Furthermore :func:`datepicker` supports different kinds of date
66#: representation from which you can choose simply by setting a
67#: different CSS class. The ``datepicker`` CSS mentioned above is
68#: only one of the following possibilities:
69#:
70#: ``"datepicker"``
71#:    renders date in format ``YYYY-MM-DD`` (ISO standard)
72#:
73#: ``"datepicker-year"``
74#:    same but also adds a select field for year
75#:
76#: ``"datepicker-le"``
77#:    renders date in format ``DD/MM/YYYY`` (little endian)
78#:
79#: ``"datepicker-le-year"``
80#:    same but also adds a select field for year
81#:
82#: ``"datepicker-de"``
83#:    renders date in format ``DD.MM.YYYY`` (german format)
84#:
85#: ``"datepicker-de-year"``
86#:    same but also adds a select field for year
87#:
88#: ``"datepicker-us"``
89#:    renders date in format ``MM/DD/YYYY`` (U.S. format)
90#:
91#: ``"datepicker-us-year"``
92#:    same but also adds a select field for year
93datepicker = ResourceInclusion(waeup_sirp, 'datepicker.js',
94                               depends=[jqueryui])
95
96
97#: If you want generate alert or confirm messages then you have to perform
98#: two steps:
99#: * In the `update()` method of the responsible view/page/form
100#:   require the JavaScript code to be rendered into the page:
101#:
102#:     from waeup.sirp.browser.resources import datepicker
103#:     ...
104#:     class MyPage(...):
105#:       ...
106#:       def update(self):
107#:         warning.need()
108#:
109#:   This way all required JavaScripts will be rendered correctly
110#:   into the HTML page generated.
111#:
112#:   In your HTML code add some <input> or <a> tag with onClick event:
113#:
114#:   <input type="submit" name="xyz" value="abc"/>
115#:          onclick="return confirmPost('Are you sure?')">
116warning = ResourceInclusion(waeup_sirp, 'warning.js')       
117
118#: A resource that binds jQueryUI tabs to <div> tags with class
119#: ``tabs``.
120#:
121#:
122#: If you want jQuery tabs for some <div>s in your page then you
123#: have to perform two steps:
124#:
125#: * In the `update()` method of the responsible view/page/form
126#:   require the JavaScript code to be rendered into the page:
127#:
128#:     from waeup.sirp.browser.resources import tabs
129#:     ...
130#:     class MyPage(...):
131#:       ...
132#:       def update(self):
133#:         tabs.need()
134#:
135#:   This way all required JavaScripts will be rendered correctly
136#:   into the HTML page generated.
137#:
138#: * In your HTML code add some ``<div>`` tag with ``class`` set to
139#    ``tabs``, like this::
140#:   
141#:      <div id="tabs">
142#:        <ul>
143#:          <li><a href="#tab-1"><span>Tab 1 Heading</span></a></li>
144#:          <li><a href="#tab-2"><span>Tab 2 Heading</span></a></li>
145#:        </ul>
146#:        <div id="tab-1">
147#:          Content of tab 1
148#:        </div>
149#:        <div id="tab-2">
150#:          Content of tab 2
151#:        </div>
152#:      </div>
153#:
154#: When the HTML is rendered, clicking into one of the tabs will make
155#: other <div>s disappear. See
156#:
157#:   http://jqueryui.com/demos/tabs/
158#:
159#: for details.
160#:
161tabs = ResourceInclusion(waeup_sirp, 'tabs.js',
162                         depends=[jquery, jqueryui])
163
164#: Resource that makes datatables for jQuery UI available.
165#:
166#: We register a normal version and a minified version. To make real
167#: use of datatables you might want to add some specialized CSS like
168#: `datatable_css` below.
169datatables = ResourceInclusion(waeup_sirp, 'jquery.dataTables.js',
170                               minified='jquery.dataTables.min.js',
171                               depends=[jquery])
172
173#: A stylesheet for datatables
174datatables_css = ResourceInclusion(waeup_sirp, 'datatables.css')
175                                 
176#: A resource that turns HTML tables into sortable, searchable and :
177#: multi-page widgets using jQuery and the dataTables plugin available
178#: from http://www.datatables.net.
179#:
180#: If you want jQuery datatables for some <table> in your page then you
181#: have to perform two steps:
182#:
183#: * In the `update()` method of the responsible view/page/form
184#:   require the JavaScript code to be rendered into the page:
185#:
186#:     from waeup.sirp.browser.resources import datatable
187#:     ...
188#:     class MyPage(...):
189#:       ...
190#:       def update(self):
191#:         datatable.need()
192#:
193#:   This way all required JavaScripts will be rendered correctly
194#:   into the HTML page generated.
195#:
196#: * Assign a ``display dataTable`` class to the HTML table you want to tune:
197#:   
198#:      <table class="display dataTable">
199#:        <thead>
200#:          <tr>
201#:            <th>Name</th><th>Title</th>
202#:          </tr>
203#:        </thead>
204#:        <tbody>
205#:          <tr class="gradeA">
206#:            <td>Manfred</td><td>Mammoth of the year</td>
207#:          </tr>
208#:          <tr class="gradeA">
209#:            <td>Wolfgang</td><td>Junior</td>
210#:          </tr>
211#:        </tbody>
212#:      </table>
213#:
214#: When the HTML is rendered, clicking into one of the tabs will make
215#: other <div>s disappear. See
216#:
217#:   http://www.datatables.net/
218#:
219#: for details.
220#:
221datatable = ResourceInclusion(waeup_sirp, 'datatable.js',
222                              depends=[datatables, datatables_css])
223
224#: Register basic YUI based CSS as a resource.
225reset_fonts_grids = ResourceInclusion(
226    waeup_sirp, 'yuirfg.css')   
227   
228yuiapp_css = ResourceInclusion(
229    waeup_sirp, 'yuiapp.css',
230    depends=[reset_fonts_grids])     
231
232#: Register basic WAeUP base CSS (which is based on ``yuiapp.css`` as a
233#: resource.
234waeup_base_css = ResourceInclusion(
235    waeup_sirp, 'waeup-base.css',
236    depends=[yuiapp_css, base])
237
238#: The red WAeUP theme registered as a resource.
239waeuptheme_red1 = ResourceInclusion(
240    waeup_sirp, 'waeuptheme-red1.css',
241    depends=[waeup_base_css])
242
243#: The gray WAeUP theme registered as a resource.
244waeuptheme_gray1 = ResourceInclusion(
245    waeup_sirp, 'waeuptheme-gray1.css',
246    depends=[waeup_base_css])
247
248#: A basic theme based on jQuery only (crappy yet).
249waeuptheme_base = ResourceInclusion(
250    waeup_sirp, 'empty.css',
251    depends=[humanity])
Note: See TracBrowser for help on using the repository browser.