author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 24 Jan 2011 11:39:53 +0100 | |
branch | stable |
changeset 6880 | 4be32427b2b9 |
parent 6858 | 393300fc3fdd |
child 7069 | 8bf2337a6f3b |
permissions | -rw-r--r-- |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
1 |
/* in CW 3.10, we should move these functions in this namespace */ |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
2 |
cw.htmlhelpers = new Namespace('cw.htmlhelpers'); |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
3 |
|
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
4 |
jQuery.extend(cw.htmlhelpers, { |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
5 |
popupLoginBox: function(loginboxid, focusid) { |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
6 |
$('#'+loginboxid).toggleClass('hidden'); |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
7 |
jQuery('#' + focusid +':visible').focus(); |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
8 |
} |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
9 |
}); |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
10 |
|
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
11 |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
12 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
13 |
* .. function:: baseuri() |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
14 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
15 |
* returns the document's baseURI. (baseuri() uses document.baseURI if |
0 | 16 |
* available and inspects the <base> tag manually otherwise.) |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
17 |
*/ |
0 | 18 |
function baseuri() { |
19 |
var uri = document.baseURI; |
|
20 |
if (uri) { // some browsers don't define baseURI |
|
6858
393300fc3fdd
[js] always lowercase baseuri #1433305
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6389
diff
changeset
|
21 |
return uri.toLowerCase(); |
0 | 22 |
} |
6858
393300fc3fdd
[js] always lowercase baseuri #1433305
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6389
diff
changeset
|
23 |
return jQuery('base').attr('href').toLowerCase(); |
0 | 24 |
} |
25 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
26 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
27 |
* .. function:: setProgressCursor() |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
28 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
29 |
* set body's cursor to 'progress' |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
30 |
*/ |
0 | 31 |
function setProgressCursor() { |
32 |
var body = document.getElementsByTagName('body')[0]; |
|
33 |
body.style.cursor = 'progress'; |
|
34 |
} |
|
35 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
36 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
37 |
* .. function:: resetCursor(result) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
38 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
39 |
* reset body's cursor to default (mouse cursor). The main |
0 | 40 |
* purpose of this function is to be used as a callback in the |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
41 |
* deferreds' callbacks chain. |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
42 |
*/ |
0 | 43 |
function resetCursor(result) { |
44 |
var body = document.getElementsByTagName('body')[0]; |
|
45 |
body.style.cursor = 'default'; |
|
46 |
// pass result to next callback in the callback chain |
|
47 |
return result; |
|
48 |
} |
|
49 |
||
50 |
function updateMessage(msg) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
51 |
var msgdiv = DIV({ |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
52 |
'class': 'message' |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
53 |
}); |
0 | 54 |
// don't pass msg to DIV() directly because DIV will html escape it |
55 |
// and msg should alreay be html escaped at this point. |
|
56 |
msgdiv.innerHTML = msg; |
|
57 |
jQuery('#appMsg').removeClass('hidden').empty().append(msgdiv); |
|
58 |
} |
|
59 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
60 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
61 |
* .. function:: asURL(props) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
62 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
63 |
* builds an url from an object (used as a dictionnary) |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
64 |
* |
1419 | 65 |
* >>> asURL({'rql' : "RQL", 'x': [1, 2], 'itemvid' : "oneline"}) |
0 | 66 |
* rql=RQL&vid=list&itemvid=oneline&x=1&x=2 |
3781
c7ef58db0e4b
[javascript] asURL now escapes request arguments
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3494
diff
changeset
|
67 |
* >>> asURL({'rql' : "a&b", 'x': [1, 2], 'itemvid' : "oneline"}) |
c7ef58db0e4b
[javascript] asURL now escapes request arguments
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3494
diff
changeset
|
68 |
* rql=a%26b&x=1&x=2&itemvid=oneline |
0 | 69 |
*/ |
1419 | 70 |
function asURL(props) { |
0 | 71 |
var chunks = []; |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
72 |
for (key in props) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
73 |
var value = props[key]; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
74 |
// generate a list of couple key=value if key is multivalued |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
75 |
if (cw.utils.isArrayLike(value)) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
76 |
for (var i = 0; i < value.length; i++) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
77 |
chunks.push(key + '=' + urlEncode(value[i])); |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
78 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
79 |
} else { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
80 |
chunks.push(key + '=' + urlEncode(value)); |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
81 |
} |
0 | 82 |
} |
83 |
return chunks.join('&'); |
|
84 |
} |
|
85 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
86 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
87 |
* .. function:: firstSelected(selectNode) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
88 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
89 |
* return selected value of a combo box if any |
0 | 90 |
*/ |
91 |
function firstSelected(selectNode) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
92 |
var $selection = $(selectNode).find('option:selected:first'); |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
93 |
return ($selection.length > 0) ? $selection[0] : null; |
0 | 94 |
} |
95 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
96 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
97 |
* .. function:: toggleVisibility(elemId) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
98 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
99 |
* toggle visibility of an element by its id |
0 | 100 |
*/ |
101 |
function toggleVisibility(elemId) { |
|
6220
e23231d482fb
[js] jqNode is more robust here wrt some node ids
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5699
diff
changeset
|
102 |
cw.jqNode(elemId).toggleClass('hidden'); |
0 | 103 |
} |
104 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
105 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
106 |
* .. function:: popupLoginBox() |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
107 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
108 |
* toggles visibility of login popup div |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
109 |
*/ |
2385
8fa16dc4b8c8
[js] shrink htmlhelpers, extract massmailing functionality, jslint
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2378
diff
changeset
|
110 |
// XXX used exactly ONCE in basecomponents |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
111 |
popupLoginBox = cw.utils.deprecatedFunction( |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
112 |
function() { |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
113 |
$('#popupLoginBox').toggleClass('hidden'); |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
114 |
jQuery('#__login:visible').focus(); |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6220
diff
changeset
|
115 |
}); |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
116 |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
117 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
118 |
* .. function getElementsMatching(tagName, properties, \/* optional \*\/ parent) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
119 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
120 |
* returns the list of elements in the document matching the tag name |
0 | 121 |
* and the properties provided |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
122 |
* |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
123 |
* * `tagName`, the tag's name |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
124 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
125 |
* * `properties`, a js Object used as a dict |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
126 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
127 |
* Return an iterator (if a *real* array is needed, you can use the |
0 | 128 |
* list() function) |
129 |
*/ |
|
130 |
function getElementsMatching(tagName, properties, /* optional */ parent) { |
|
131 |
parent = parent || document; |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
132 |
return jQuery.grep(parent.getElementsByTagName(tagName), function elementMatches(element) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
133 |
for (prop in properties) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
134 |
if (jQuery(element).attr(prop) != properties[prop]) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
135 |
return false; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
136 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
137 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
138 |
return true; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
139 |
}); |
0 | 140 |
} |
141 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
142 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
143 |
* .. function:: setCheckboxesState(nameprefix, value, checked) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
144 |
* |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
145 |
* sets checked/unchecked status of checkboxes |
0 | 146 |
*/ |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
147 |
|
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
148 |
function setCheckboxesState(nameprefix, value, checked) { |
0 | 149 |
// XXX: this looks in *all* the document for inputs |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
150 |
jQuery('input:checkbox[name^=' + nameprefix + ']').each(function() { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
151 |
if (value == null || this.value == value) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
152 |
this.checked = checked; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
153 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
154 |
}); |
0 | 155 |
} |
156 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
157 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
158 |
* .. function:: html2dom(source) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
159 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
160 |
* this function is a hack to build a dom node from html source |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
161 |
*/ |
0 | 162 |
function html2dom(source) { |
163 |
var tmpNode = SPAN(); |
|
164 |
tmpNode.innerHTML = source; |
|
165 |
if (tmpNode.childNodes.length == 1) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
166 |
return tmpNode.firstChild; |
0 | 167 |
} |
168 |
else { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
169 |
// we leave the span node when `source` has no root node |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
170 |
// XXX This is cleary not the best solution, but css/html-wise, |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
171 |
/// a span not should not be too much disturbing |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
172 |
return tmpNode; |
0 | 173 |
} |
174 |
} |
|
175 |
||
176 |
// *** HELPERS **************************************************** // |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
177 |
function rql_for_eid(eid) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
178 |
return 'Any X WHERE X eid ' + eid; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
179 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
180 |
function isTextNode(domNode) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
181 |
return domNode.nodeType == 3; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
182 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
183 |
function isElementNode(domNode) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
184 |
return domNode.nodeType == 1; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
185 |
} |
0 | 186 |
|
187 |
function autogrow(area) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
188 |
if (area.scrollHeight > area.clientHeight && ! window.opera) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
189 |
if (area.rows < 20) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
190 |
area.rows += 2; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
191 |
} |
0 | 192 |
} |
193 |
} |
|
194 |
//============= page loading events ==========================================// |
|
5699
f4f6ee3af50b
[javascript] move CubicWeb object declaration to cubicweb.js, remove CubicWeb.provide/require, use cw instead of CubicWeb
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5658
diff
changeset
|
195 |
cw.rounded = [['div.sideBoxBody', 'bottom 6px'], |
f4f6ee3af50b
[javascript] move CubicWeb object declaration to cubicweb.js, remove CubicWeb.provide/require, use cw instead of CubicWeb
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5658
diff
changeset
|
196 |
['div.boxTitle, div.sideBoxTitle, th.month', 'top 6px']]; |
2338
3f7c7fbae94e
call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2232
diff
changeset
|
197 |
|
3f7c7fbae94e
call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2232
diff
changeset
|
198 |
function roundedCorners(node) { |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
199 |
if (jQuery.fn.corner !== undefined) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
200 |
node = jQuery(node); |
5699
f4f6ee3af50b
[javascript] move CubicWeb object declaration to cubicweb.js, remove CubicWeb.provide/require, use cw instead of CubicWeb
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5658
diff
changeset
|
201 |
for (var r = 0; r < cw.rounded.length; r++) { |
f4f6ee3af50b
[javascript] move CubicWeb object declaration to cubicweb.js, remove CubicWeb.provide/require, use cw instead of CubicWeb
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5658
diff
changeset
|
202 |
node.find(cw.rounded[r][0]).corner(cw.rounded[r][1]); |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
203 |
} |
2338
3f7c7fbae94e
call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2232
diff
changeset
|
204 |
} |
0 | 205 |
} |
206 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
207 |
jQuery(document).ready(function() { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
208 |
roundedCorners(this.body); |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
209 |
}); |