111 } |
111 } |
112 |
112 |
113 /* builds an url from an object (used as a dictionnary) |
113 /* builds an url from an object (used as a dictionnary) |
114 * Notable difference with MochiKit's queryString: as_url does not |
114 * Notable difference with MochiKit's queryString: as_url does not |
115 * *url_quote* each value found in the dictionnary |
115 * *url_quote* each value found in the dictionnary |
116 * |
116 * |
117 * >>> as_url({'rql' : "RQL", 'x': [1, 2], 'itemvid' : "oneline"}) |
117 * >>> as_url({'rql' : "RQL", 'x': [1, 2], 'itemvid' : "oneline"}) |
118 * rql=RQL&vid=list&itemvid=oneline&x=1&x=2 |
118 * rql=RQL&vid=list&itemvid=oneline&x=1&x=2 |
119 */ |
119 */ |
120 function as_url(props) { |
120 function as_url(props) { |
121 var chunks = []; |
121 var chunks = []; |
131 } |
131 } |
132 } |
132 } |
133 return chunks.join('&'); |
133 return chunks.join('&'); |
134 } |
134 } |
135 |
135 |
136 /* return selected value of a combo box if any |
136 /* return selected value of a combo box if any |
137 */ |
137 */ |
138 function firstSelected(selectNode) { |
138 function firstSelected(selectNode) { |
139 var selection = filter(attrgetter('selected'), selectNode.options); |
139 var selection = filter(attrgetter('selected'), selectNode.options); |
140 return (selection.length>0) ? getNodeAttribute(selection[0], 'value'):null; |
140 return (selection.length>0) ? getNodeAttribute(selection[0], 'value'):null; |
141 } |
141 } |
142 |
142 |
143 /* toggle visibility of an element by its id |
143 /* toggle visibility of an element by its id |
144 */ |
144 */ |
145 function toggleVisibility(elemId) { |
145 function toggleVisibility(elemId) { |
146 jqNode(elemId).toggleClass('hidden'); |
146 jqNode(elemId).toggleClass('hidden'); |
|
147 } |
|
148 |
|
149 |
|
150 /* toggles visibility of login popup div */ |
|
151 function popupLoginBox() { |
|
152 toggleVisibility('popupLoginBox'); |
|
153 jQuery('#__login:visible').focus(); |
147 } |
154 } |
148 |
155 |
149 /* |
156 /* |
150 * return true (resp. false) if <element> (resp. doesn't) matches <properties> |
157 * return true (resp. false) if <element> (resp. doesn't) matches <properties> |
151 */ |
158 */ |
158 return true; |
165 return true; |
159 } |
166 } |
160 |
167 |
161 /* returns the list of elements in the document matching the tag name |
168 /* returns the list of elements in the document matching the tag name |
162 * and the properties provided |
169 * and the properties provided |
163 * |
170 * |
164 * @param tagName the tag's name |
171 * @param tagName the tag's name |
165 * @param properties a js Object used as a dict |
172 * @param properties a js Object used as a dict |
166 * @return an iterator (if a *real* array is needed, you can use the |
173 * @return an iterator (if a *real* array is needed, you can use the |
167 * list() function) |
174 * list() function) |
168 */ |
175 */ |
171 parent = parent || document; |
178 parent = parent || document; |
172 return filter(filterfunc, parent.getElementsByTagName(tagName)); |
179 return filter(filterfunc, parent.getElementsByTagName(tagName)); |
173 } |
180 } |
174 |
181 |
175 /* |
182 /* |
176 * sets checked/unchecked status of checkboxes |
183 * sets checked/unchecked status of checkboxes |
177 */ |
184 */ |
178 function setCheckboxesState(nameprefix, checked){ |
185 function setCheckboxesState(nameprefix, checked){ |
179 // XXX: this looks in *all* the document for inputs |
186 // XXX: this looks in *all* the document for inputs |
180 var elements = getElementsMatching('input', {'type': "checkbox"}); |
187 var elements = getElementsMatching('input', {'type': "checkbox"}); |
181 filterfunc = function(cb) { return nameprefix && cb.name.startsWith(nameprefix); }; |
188 filterfunc = function(cb) { return nameprefix && cb.name.startsWith(nameprefix); }; |
240 } |
247 } |
241 } |
248 } |
242 |
249 |
243 //============= page loading events ==========================================// |
250 //============= page loading events ==========================================// |
244 function roundedCornersOnLoad() { |
251 function roundedCornersOnLoad() { |
245 roundClass("div", "sideBox", {corners: "bottom", compact:false}); |
252 roundClass("div", "sideBox", {corners: "bottom", compact:false}); |
246 roundClass("div", "boxTitle", {corners: "top", compact:true}); |
253 roundClass("div", "boxTitle", {corners: "top", compact:true}); |
247 roundClass("div", "boxPrefTitle", {corners: "top", compact:true}); |
254 roundClass("div", "boxPrefTitle", {corners: "top", compact:true}); |
248 roundClass("div", "sideBoxTitle", {corners: "top", compact:true}); |
255 roundClass("div", "sideBoxTitle", {corners: "top", compact:true}); |
249 roundClass("th", "month", {corners: "top", compact:true}); |
256 roundClass("th", "month", {corners: "top", compact:true}); |
250 } |
257 } |
251 |
258 |
252 // jQuery(document).ready(roundedCornersOnLoad); |
259 // jQuery(document).ready(roundedCornersOnLoad); |
253 |
260 |
254 |
261 |
255 CubicWeb.provide('htmlhelpers.js'); |
262 CubicWeb.provide('htmlhelpers.js'); |
256 |
263 |