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 |
---|
25 | from hurry.resource import Library, ResourceInclusion |
---|
26 | from hurry.jqueryui import jqueryui, base, blitzer, ui_lightness, humanity |
---|
27 | from hurry.jquery import jquery |
---|
28 | |
---|
29 | |
---|
30 | #: All local resources are registered under the name ``waeup_sirp``. |
---|
31 | waeup_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 | datepicker = ResourceInclusion(waeup_sirp, 'datepicker.js', |
---|
65 | depends=[jqueryui]) |
---|
66 | |
---|
67 | |
---|
68 | #: If you want generate alert or confirm messages then you have to perform |
---|
69 | #: two steps: |
---|
70 | #: * In the `update()` method of the responsible view/page/form |
---|
71 | #: require the JavaScript code to be rendered into the page: |
---|
72 | #: |
---|
73 | #: from waeup.sirp.browser.resources import datepicker |
---|
74 | #: ... |
---|
75 | #: class MyPage(...): |
---|
76 | #: ... |
---|
77 | #: def update(self): |
---|
78 | #: warning.need() |
---|
79 | #: |
---|
80 | #: This way all required JavaScripts will be rendered correctly |
---|
81 | #: into the HTML page generated. |
---|
82 | #: |
---|
83 | #: In your HTML code add some <input> or <a> tag with onClick event: |
---|
84 | #: |
---|
85 | #: <input type="submit" name="xyz" value="abc"/> |
---|
86 | #: onclick="return confirmPost('Are you sure?')"> |
---|
87 | warning = 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 | #: |
---|
132 | tabs = ResourceInclusion(waeup_sirp, 'tabs.js', |
---|
133 | depends=[jquery, jqueryui]) |
---|
134 | |
---|
135 | #: Resource that makes datatables for jQuery UI available. |
---|
136 | #: |
---|
137 | #: We register a normal version and a minified version. To make real |
---|
138 | #: use of datatables you might want to add some specialized CSS like |
---|
139 | #: `datatable_css` below. |
---|
140 | datatables = ResourceInclusion(waeup_sirp, 'jquery.dataTables.js', |
---|
141 | minified='jquery.dataTables.min.js', |
---|
142 | depends=[jquery]) |
---|
143 | |
---|
144 | #: A stylesheet for datatables |
---|
145 | datatables_css = ResourceInclusion(waeup_sirp, 'datatables.css') |
---|
146 | |
---|
147 | #: A resource that turns HTML tables into sortable, searchable and : |
---|
148 | #: multi-page widgets using jQuery and the dataTables plugin available |
---|
149 | #: from http://www.datatables.net. |
---|
150 | #: |
---|
151 | #: If you want jQuery datatables for some <table> in your page then you |
---|
152 | #: have to perform two steps: |
---|
153 | #: |
---|
154 | #: * In the `update()` method of the responsible view/page/form |
---|
155 | #: require the JavaScript code to be rendered into the page: |
---|
156 | #: |
---|
157 | #: from waeup.sirp.browser.resources import datatable |
---|
158 | #: ... |
---|
159 | #: class MyPage(...): |
---|
160 | #: ... |
---|
161 | #: def update(self): |
---|
162 | #: datatable.need() |
---|
163 | #: |
---|
164 | #: This way all required JavaScripts will be rendered correctly |
---|
165 | #: into the HTML page generated. |
---|
166 | #: |
---|
167 | #: * Assign a ``datatable`` id to the HTML table you want to tune: |
---|
168 | #: |
---|
169 | #: <table id="datatable"> |
---|
170 | #: <thead> |
---|
171 | #: <tr> |
---|
172 | #: <th>Name</th><th>Title</th> |
---|
173 | #: </tr> |
---|
174 | #: </thead> |
---|
175 | #: <tbody> |
---|
176 | #: <tr class="gradeA"> |
---|
177 | #: <td>Manfred</td><td>Mammoth of the year</td> |
---|
178 | #: </tr> |
---|
179 | #: <tr class="gradeA"> |
---|
180 | #: <td>Wolfgang</td><td>Junior</td> |
---|
181 | #: </tr> |
---|
182 | #: </tbody> |
---|
183 | #: </table> |
---|
184 | #: |
---|
185 | #: When the HTML is rendered, clicking into one of the tabs will make |
---|
186 | #: other <div>s disappear. See |
---|
187 | #: |
---|
188 | #: http://jqueryui.com/demos/tabs/ |
---|
189 | #: |
---|
190 | #: for details. |
---|
191 | #: |
---|
192 | datatable = ResourceInclusion(waeup_sirp, 'datatable.js', |
---|
193 | depends=[datatables, datatables_css]) |
---|
194 | |
---|
195 | #: Register basic YUI based CSS as a resource. |
---|
196 | yuiapp_css = ResourceInclusion( |
---|
197 | waeup_sirp, 'yuiapp.css', |
---|
198 | depends=[yui.reset_fonts_grids, yui.sam]) |
---|
199 | |
---|
200 | #: Register basic WAeUP base CSS (which is based on ``yuiapp.css`` as a |
---|
201 | #: resource. |
---|
202 | waeup_base_css = ResourceInclusion( |
---|
203 | waeup_sirp, 'waeup-base.css', |
---|
204 | depends=[yuiapp_css]) |
---|
205 | |
---|
206 | #: The red WAeUP theme registered as a resource. |
---|
207 | waeuptheme_red1 = ResourceInclusion( |
---|
208 | waeup_sirp, 'waeuptheme-red1.css', |
---|
209 | depends=[waeup_base_css, base]) |
---|
210 | |
---|
211 | #: The gray WAeUP theme registered as a resource. |
---|
212 | waeuptheme_gray1 = ResourceInclusion( |
---|
213 | waeup_sirp, 'waeuptheme-gray1.css', |
---|
214 | depends=[waeup_base_css]) |
---|
215 | |
---|
216 | #: A basic theme based on jQuery only (crappy yet). |
---|
217 | waeuptheme_base = ResourceInclusion( |
---|
218 | waeup_sirp, 'empty.css', |
---|
219 | depends=[humanity]) |
---|