| 39 | | log("ajax post response success."); |
| 40 | | log("status:" + textStatus); |
| 41 | | if (data.indexOf("</body>") != -1) { |
| 42 | | // FIXME: We should find a way to handle a |
| 43 | | // redirect directly. But we always get the |
| 44 | | // html data of the redirected page. |
| 45 | | |
| 46 | | log("redirect work-a-round: replace the complete page"); |
| 47 | | log("</body> index:" + data.indexOf("</body>")); |
| 48 | | replace_complete_page(data) |
| 49 | | } else { |
| 50 | | $("#page_content").html(data); |
| 51 | | $("#page_content").animate({opacity: 1}, 500 ); |
| 52 | | } |
| 53 | | load_normal_link = false; |
| | 39 | log("ajax post response success."); |
| | 40 | log("status:" + textStatus); |
| | 41 | if (data.indexOf("</body>") != -1) { |
| | 42 | // FIXME: We should find a way to handle a |
| | 43 | // redirect directly. But we always get the |
| | 44 | // html data of the redirected page. |
| | 45 | |
| | 46 | log("redirect work-a-round: replace the complete page"); |
| | 47 | log("</body> index:" + data.indexOf("</body>")); |
| | 48 | replace_complete_page(data) |
| | 49 | } else { |
| | 50 | $("#page_content").html(data); |
| | 51 | $("#page_content").animate({ |
| | 52 | opacity: 1 |
| | 53 | }, 500 ); |
| | 54 | } |
| | 55 | load_normal_link = false; |
| 62 | | log("ajax get response error!"); |
| 63 | | log(XMLHttpRequest); |
| 64 | | var response_text = XMLHttpRequest.responseText; |
| 65 | | log("response_text: '" + response_text + "'"); |
| 66 | | if (!response_text) { |
| 67 | | response_text = "<h1>Ajax response error without any response text.</h1>"; |
| 68 | | } |
| 69 | | replace_complete_page(response_text); |
| 70 | | load_normal_link = true; |
| | 64 | log("ajax get response error!"); |
| | 65 | log(XMLHttpRequest); |
| | 66 | var response_text = XMLHttpRequest.responseText; |
| | 67 | log("response_text: '" + response_text + "'"); |
| | 68 | if (!response_text) { |
| | 69 | response_text = "<h1>Ajax response error without any response text.</h1>"; |
| | 70 | } |
| | 71 | replace_complete_page(response_text); |
| | 72 | load_normal_link = true; |
| 187 | | $('a.openinwindow').each(function(){ |
| 188 | | var url = $(this).attr("href"); |
| 189 | | var org_title = $(this).attr("title"); |
| 190 | | |
| 191 | | $(this).attr({ |
| 192 | | onclick: "return OpenInWindow(this);", |
| 193 | | title: org_title + " (Opens in a new window)" |
| 194 | | }); |
| 195 | | //$(this).append(" [^]") |
| 196 | | }); |
| | 193 | $('a.openinwindow').each(function(){ |
| | 194 | var url = $(this).attr("href"); |
| | 195 | var org_title = $(this).attr("title"); |
| | 196 | |
| | 197 | $(this).attr({ |
| | 198 | onclick: "return OpenInWindow(this);", |
| | 199 | title: org_title + " (Opens in a new window)" |
| | 200 | }); |
| | 201 | //$(this).append(" [^]") |
| | 202 | }); |
| 210 | | $(".resize_textarea" ).click(function () { |
| 211 | | button_id = $(this).attr('id'); |
| 212 | | // log("Clicked on: " + button_id); |
| 213 | | var pos = button_id.indexOf("_"); |
| 214 | | var action = button_id.slice(0, pos); |
| 215 | | var textarea_id = button_id.slice(pos+1, button_id.length); |
| 216 | | // log("action:" + action); |
| 217 | | // log("textarea id:" + textarea_id); |
| 218 | | var textarea = $("#"+textarea_id); |
| 219 | | var old_rows = textarea.attr("rows"); |
| 220 | | |
| 221 | | var new_rows = false; |
| 222 | | if (action=="smaller") { |
| 223 | | if (old_rows<3) { |
| 224 | | log("no more smaller ;)") |
| 225 | | return; |
| 226 | | } |
| 227 | | new_rows = Math.floor(old_rows / RESIZE_FACTOR); |
| 228 | | } |
| 229 | | if (action=="bigger") { |
| 230 | | new_rows = Math.ceil(old_rows * RESIZE_FACTOR); |
| 231 | | } |
| 232 | | |
| 233 | | if (new_rows == false) { |
| 234 | | log("Error: Wrong textarea resize action:" + action); |
| 235 | | return; |
| 236 | | } |
| 237 | | // log("old rows:" + old_rows + " - new rows:" + new_rows); |
| 238 | | textarea.animate({rows: new_rows}, 100 ); |
| 239 | | }); |
| 240 | | |
| 241 | | /************************************************************************* |
| | 216 | $(".resize_textarea" ).click(function () { |
| | 217 | button_id = $(this).attr('id'); |
| | 218 | // log("Clicked on: " + button_id); |
| | 219 | var pos = button_id.indexOf("_"); |
| | 220 | var action = button_id.slice(0, pos); |
| | 221 | var textarea_id = button_id.slice(pos+1, button_id.length); |
| | 222 | // log("action:" + action); |
| | 223 | // log("textarea id:" + textarea_id); |
| | 224 | var textarea = $("#"+textarea_id); |
| | 225 | var old_rows = textarea.attr("rows"); |
| | 226 | |
| | 227 | var new_rows = false; |
| | 228 | if (action=="smaller") { |
| | 229 | if (old_rows<3) { |
| | 230 | log("no more smaller ;)") |
| | 231 | return; |
| | 232 | } |
| | 233 | new_rows = Math.floor(old_rows / RESIZE_FACTOR); |
| | 234 | } |
| | 235 | if (action=="bigger") { |
| | 236 | new_rows = Math.ceil(old_rows * RESIZE_FACTOR); |
| | 237 | } |
| | 238 | |
| | 239 | if (new_rows == false) { |
| | 240 | log("Error: Wrong textarea resize action:" + action); |
| | 241 | return; |
| | 242 | } |
| | 243 | // log("old rows:" + old_rows + " - new rows:" + new_rows); |
| | 244 | textarea.animate({ |
| | 245 | rows: new_rows |
| | 246 | }, 100 ); |
| | 247 | }); |
| | 248 | |
| | 249 | /************************************************************************* |
| 251 | | $('a.add_openinwindow').each(function(){ |
| 252 | | |
| 253 | | var url = $(this).attr("href"); |
| 254 | | var org_title = $(this).attr("title"); |
| 255 | | |
| 256 | | var new_link = ' <a href="'+url+'" onclick="return OpenInWindow(this);" title="'+org_title+' (Opens in a new window)">[^]</a>' |
| 257 | | |
| 258 | | $(this).after(new_link); |
| 259 | | }) |
| 260 | | |
| 261 | | /************************************************************************* |
| | 259 | $('a.add_openinwindow').each(function(){ |
| | 260 | |
| | 261 | var url = $(this).attr("href"); |
| | 262 | var org_title = $(this).attr("title"); |
| | 263 | |
| | 264 | var new_link = ' <a href="'+url+'" onclick="return OpenInWindow(this);" title="'+org_title+' (Opens in a new window)">[^]</a>' |
| | 265 | |
| | 266 | $(this).after(new_link); |
| | 267 | }) |
| | 268 | |
| | 269 | /************************************************************************* |
| 264 | | $("textarea").each(function() { |
| 265 | | rows = this.value.split("\n").length; |
| 266 | | if (rows > MAX_ROWS) {rows = MAX_ROWS;} |
| 267 | | if (rows < MIN_ROWS) {rows = MIN_ROWS;} |
| 268 | | log("set textarea row to:" + rows) |
| 269 | | this.rows = rows; |
| 270 | | }); |
| 271 | | |
| 272 | | /************************************************************************* |
| | 272 | $("textarea").each(function() { |
| | 273 | rows = this.value.split("\n").length; |
| | 274 | if (rows > MAX_ROWS) { |
| | 275 | rows = MAX_ROWS; |
| | 276 | } |
| | 277 | if (rows < MIN_ROWS) { |
| | 278 | rows = MIN_ROWS; |
| | 279 | } |
| | 280 | log("set textarea row to:" + rows) |
| | 281 | this.rows = rows; |
| | 282 | }); |
| | 283 | |
| | 284 | /************************************************************************* |
| 287 | | $(".pylucid_form .form_hide").nextAll().hide(); |
| 288 | | $(".pylucid_form .form_collapse").each(function() { |
| 289 | | $(this).css("cursor","n-resize"); |
| 290 | | }); |
| 291 | | $(".pylucid_form .form_collapse").click(function () { |
| 292 | | if ($(this).css("cursor") == "n-resize") { |
| 293 | | $(this).css("cursor","s-resize"); |
| 294 | | } else { |
| 295 | | $(this).css("cursor","n-resize"); |
| 296 | | } |
| 297 | | $(this).nextAll().slideToggle("fast"); |
| 298 | | }); |
| | 301 | $(".pylucid_form .form_hide").nextAll().hide(); |
| | 302 | $(".pylucid_form .form_collapse").each(function() { |
| | 303 | $(this).css("cursor","n-resize"); |
| | 304 | }); |
| | 305 | $(".pylucid_form .form_collapse").click(function () { |
| | 306 | if ($(this).css("cursor") == "n-resize") { |
| | 307 | $(this).css("cursor","s-resize"); |
| | 308 | } else { |
| | 309 | $(this).css("cursor","n-resize"); |
| | 310 | } |
| | 311 | $(this).nextAll().slideToggle("fast"); |
| | 312 | }); |