author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Wed, 08 Sep 2010 10:32:46 +0200 | |
branch | stable |
changeset 6193 | a58097ee4f15 |
parent 5699 | f4f6ee3af50b |
child 6220 | e23231d482fb |
permissions | -rw-r--r-- |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
1 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
2 |
* .. function:: baseuri() |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
3 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
4 |
* returns the document's baseURI. (baseuri() uses document.baseURI if |
0 | 5 |
* 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
|
6 |
*/ |
0 | 7 |
function baseuri() { |
8 |
var uri = document.baseURI; |
|
9 |
if (uri) { // some browsers don't define baseURI |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
10 |
return uri; |
0 | 11 |
} |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
12 |
return jQuery('base').attr('href'); |
0 | 13 |
} |
14 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
15 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
16 |
* .. function:: setProgressCursor() |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
17 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
18 |
* 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
|
19 |
*/ |
0 | 20 |
function setProgressCursor() { |
21 |
var body = document.getElementsByTagName('body')[0]; |
|
22 |
body.style.cursor = 'progress'; |
|
23 |
} |
|
24 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
25 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
26 |
* .. function:: resetCursor(result) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
27 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
28 |
* reset body's cursor to default (mouse cursor). The main |
0 | 29 |
* 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
|
30 |
* deferreds' callbacks chain. |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
31 |
*/ |
0 | 32 |
function resetCursor(result) { |
33 |
var body = document.getElementsByTagName('body')[0]; |
|
34 |
body.style.cursor = 'default'; |
|
35 |
// pass result to next callback in the callback chain |
|
36 |
return result; |
|
37 |
} |
|
38 |
||
39 |
function updateMessage(msg) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
40 |
var msgdiv = DIV({ |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
41 |
'class': 'message' |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
42 |
}); |
0 | 43 |
// don't pass msg to DIV() directly because DIV will html escape it |
44 |
// and msg should alreay be html escaped at this point. |
|
45 |
msgdiv.innerHTML = msg; |
|
46 |
jQuery('#appMsg').removeClass('hidden').empty().append(msgdiv); |
|
47 |
} |
|
48 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
49 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
50 |
* .. function:: asURL(props) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
51 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
52 |
* 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
|
53 |
* |
1419 | 54 |
* >>> asURL({'rql' : "RQL", 'x': [1, 2], 'itemvid' : "oneline"}) |
0 | 55 |
* 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
|
56 |
* >>> 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
|
57 |
* rql=a%26b&x=1&x=2&itemvid=oneline |
0 | 58 |
*/ |
1419 | 59 |
function asURL(props) { |
0 | 60 |
var chunks = []; |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
61 |
for (key in props) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
62 |
var value = props[key]; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
63 |
// 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
|
64 |
if (cw.utils.isArrayLike(value)) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
65 |
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
|
66 |
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
|
67 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
68 |
} else { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
69 |
chunks.push(key + '=' + urlEncode(value)); |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
70 |
} |
0 | 71 |
} |
72 |
return chunks.join('&'); |
|
73 |
} |
|
74 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
75 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
76 |
* .. function:: firstSelected(selectNode) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
77 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
78 |
* return selected value of a combo box if any |
0 | 79 |
*/ |
80 |
function firstSelected(selectNode) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
81 |
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
|
82 |
return ($selection.length > 0) ? $selection[0] : null; |
0 | 83 |
} |
84 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
85 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
86 |
* .. function:: toggleVisibility(elemId) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
87 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
88 |
* toggle visibility of an element by its id |
0 | 89 |
*/ |
90 |
function toggleVisibility(elemId) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
91 |
$('#' + elemId).toggleClass('hidden'); |
0 | 92 |
} |
93 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
94 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
95 |
* .. function:: popupLoginBox() |
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 |
* 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
|
98 |
*/ |
2385
8fa16dc4b8c8
[js] shrink htmlhelpers, extract massmailing functionality, jslint
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2378
diff
changeset
|
99 |
// XXX used exactly ONCE in basecomponents |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
100 |
function popupLoginBox() { |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
101 |
$('#popupLoginBox').toggleClass('hidden'); |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
102 |
jQuery('#__login:visible').focus(); |
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
103 |
} |
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
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 getElementsMatching(tagName, properties, \/* optional \*\/ parent) |
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 |
* returns the list of elements in the document matching the tag name |
0 | 109 |
* and the properties provided |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
110 |
* |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
111 |
* * `tagName`, the tag's name |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
112 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
113 |
* * `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
|
114 |
* |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
115 |
* Return an iterator (if a *real* array is needed, you can use the |
0 | 116 |
* list() function) |
117 |
*/ |
|
118 |
function getElementsMatching(tagName, properties, /* optional */ parent) { |
|
119 |
parent = parent || document; |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
120 |
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
|
121 |
for (prop in properties) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
122 |
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
|
123 |
return false; |
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 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
126 |
return true; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
127 |
}); |
0 | 128 |
} |
129 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
130 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
131 |
* .. function:: setCheckboxesState(nameprefix, value, checked) |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
132 |
* |
29
7d14f1eadded
fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
133 |
* sets checked/unchecked status of checkboxes |
0 | 134 |
*/ |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
135 |
|
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
136 |
function setCheckboxesState(nameprefix, value, checked) { |
0 | 137 |
// 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
|
138 |
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
|
139 |
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
|
140 |
this.checked = checked; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
141 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
142 |
}); |
0 | 143 |
} |
144 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
145 |
/** |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
146 |
* .. function:: html2dom(source) |
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 |
* 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
|
149 |
*/ |
0 | 150 |
function html2dom(source) { |
151 |
var tmpNode = SPAN(); |
|
152 |
tmpNode.innerHTML = source; |
|
153 |
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
|
154 |
return tmpNode.firstChild; |
0 | 155 |
} |
156 |
else { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
157 |
// 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
|
158 |
// 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
|
159 |
/// 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
|
160 |
return tmpNode; |
0 | 161 |
} |
162 |
} |
|
163 |
||
164 |
// *** HELPERS **************************************************** // |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
165 |
function rql_for_eid(eid) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
166 |
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
|
167 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
168 |
function isTextNode(domNode) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
169 |
return domNode.nodeType == 3; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
170 |
} |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
171 |
function isElementNode(domNode) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
172 |
return domNode.nodeType == 1; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
173 |
} |
0 | 174 |
|
175 |
function autogrow(area) { |
|
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
176 |
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
|
177 |
if (area.rows < 20) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
178 |
area.rows += 2; |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
179 |
} |
0 | 180 |
} |
181 |
} |
|
182 |
//============= 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
|
183 |
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
|
184 |
['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
|
185 |
|
3f7c7fbae94e
call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2232
diff
changeset
|
186 |
function roundedCorners(node) { |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
187 |
if (jQuery.fn.corner !== undefined) { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
188 |
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
|
189 |
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
|
190 |
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
|
191 |
} |
2338
3f7c7fbae94e
call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
2232
diff
changeset
|
192 |
} |
0 | 193 |
} |
194 |
||
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
195 |
jQuery(document).ready(function() { |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
196 |
roundedCorners(this.body); |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5479
diff
changeset
|
197 |
}); |