author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 22 Sep 2009 18:59:00 +0200 | |
branch | stable |
changeset 3372 | 26b89dfe4170 |
parent 3283 | 4f53eb3f1331 |
child 3441 | bdeb91e08278 |
permissions | -rw-r--r-- |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8 -*- |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
2 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
3 |
Javascript |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
4 |
---------- |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
5 |
|
3283 | 6 |
*CubicWeb* uses quite a bit of javascript in its user interface and |
7 |
ships with jquery (1.3.x) and parts of the jquery UI |
|
8 |
library, plus a number of homegrown files and also other thirparty |
|
9 |
libraries. |
|
10 |
||
11 |
All javascript files are stored in cubicweb/web/data/. There are |
|
12 |
around thirty js files there. In a cube it goes to data/. |
|
13 |
||
14 |
Obviously one does not want javascript pieces to be loaded all at |
|
15 |
once, hence the framework provides a number of mechanisms and |
|
16 |
conventions to deal with javascript resources. |
|
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
17 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
18 |
Conventions |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
19 |
~~~~~~~~~~~ |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
20 |
|
3283 | 21 |
It is good practice to name cube specific js files after the name of |
22 |
the cube, like this : 'cube.mycube.js', so as to avoid name clashes. |
|
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
23 |
|
3283 | 24 |
XXX external_resources variable (which needs love) |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
25 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
26 |
CubicWeb javascrip api |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
27 |
~~~~~~~~~~~~~~~~~~~~~~ |
3283 | 28 |
|
29 |
Javascript resources are typically loaded on demand, from views. The |
|
30 |
request object (available as self.req from most application objects, |
|
31 |
for instance views and entities objects) has a few methods to do that: |
|
32 |
||
33 |
* `add_js(self, jsfiles, localfile=True)` which takes a sequence of |
|
34 |
javascript files and writes proper entries into the HTML header |
|
35 |
section. The localfile parameter allows to declare resources which |
|
36 |
are not from web/data (for instance, residing on a content delivery |
|
37 |
network). |
|
38 |
||
39 |
* `add_onload(self, jscode)` which adds one raw javascript code |
|
40 |
snippet inline in the html headers. This is quite useful for setting |
|
41 |
up early jQuery(document).ready(...) initialisations. |
|
42 |
||
43 |
Overview of what's available |
|
44 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
45 |
||
46 |
* jquery.* : jquery and jquery UI library |
|
47 |
||
48 |
* cubicweb.python.js : adds a number of practical extension to stdanrd |
|
49 |
javascript objects (on Date, Array, String, some list and dictionary |
|
50 |
operations), and a pythonesque way to build classes. Defines a |
|
51 |
CubicWeb namespace. |
|
52 |
||
53 |
* cubicweb.htmlhelpers.js : a small bag of convenience functions used |
|
54 |
in various other cubicweb javascript resources (baseuri, progress |
|
55 |
cursor handling, popup login box, html2dom function, etc.) |
|
56 |
||
57 |
* cubicweb.ajax.js : concentrates all ajax related facilities (it |
|
58 |
extends jQuery with the loahxhtml function, provides a handfull of |
|
59 |
high-level ajaxy operations like asyncRemoteExec, reloadComponent, |
|
60 |
replacePageChunk, getDomFromResponse) |
|
61 |
||
62 |
* cubicweb.widgets.js : provides a widget namespace and constructors |
|
63 |
and helpers for various widgets (mainly facets and timeline) |
|
64 |
||
65 |
* cubicweb.edition.js : used by edition forms |
|
66 |
||
67 |
* cubicweb.preferences.js : used by the preference form |
|
68 |
||
69 |
* cubicweb.facets.js : used by the facets mechanism |
|
70 |
||
71 |
xxx massmailing, gmap, fckcwconfig, timeline-bundle, timeline-ext, |
|
72 |
calendar, goa, flotn tazy, tabs, bookmarks |