Changeset 2524
- Timestamp:
- 02/04/10 15:42:29 (6 weeks ago)
- Location:
- branches/0.9/pylucid_project
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/media/PyLucid/pylucid_js_tools.js
r2516 r2524 1 2 1 3 2 // helper function for console logging … … 8 7 window.console.log(Array.prototype.join.call(arguments,'')); 9 8 } 9 log("pylucid_js_tools.js loaded."); 10 10 11 11 … … 48 48 replace_complete_page(data) 49 49 } else { 50 // log("put in #page_content:" + data); 50 51 $("#page_content").html(data); 51 52 $("#page_content").animate({ … … 74 75 75 76 77 76 78 function pylucid_ajax_form_view(form_id) { 77 79 /************************************************************************* … … 90 92 *************************************************************************/ 91 93 $(form_id).bind('submit', function() { 94 var form = $(this); 95 log("pylucid_ajax_form_view submit form:" + form); 92 96 93 97 $("#page_content").html('<h2>send...</h2>'); … … 95 99 opacity: 0.3 96 100 }, 500 ); 97 98 var form = $(this); 101 99 102 var form_data = form.serialize(); 100 103 log("form data:" + form_data); … … 119 122 log("complete:" + XMLHttpRequest.status); 120 123 log("complete:" + XMLHttpRequest.getResponseHeader('Location')); 121 124 122 125 if(XMLHttpRequest.status.toString()[0]=='3'){ 123 126 top.location.href = XMLHttpRequest.getResponseHeader('Location'); … … 130 133 log("ajax done:" + XMLHttpRequest.getResponseHeader('Location')); 131 134 return load_normal_link; // <-- important: Don't send the form in normal way. 132 }); 135 }); 133 136 } 134 137 … … 206 209 207 210 208 MIN_ROWS = 5; 209 MAX_ROWS = 25; 210 MAX_LENGTH = 100; 211 RESIZE_FACTOR = 1.3; 212 jQuery(document).ready(function($) { 213 /************************************************************************* 214 * textarea resize buttons 215 */ 211 var MIN_ROWS = 5; 212 var MAX_ROWS = 25; 213 var MAX_LENGTH = 100; 214 var RESIZE_FACTOR = 1.3; 215 216 function activate_resize_textarea_buttons() { 217 /************************************************************************* 218 * textarea resize buttons 219 */ 220 log("activate_resize_textarea_buttons()"); 216 221 $(".resize_textarea" ).click(function () { 217 222 button_id = $(this).attr('id'); 218 // log("Clicked on: " + button_id);223 // log("Clicked on: " + button_id); 219 224 var pos = button_id.indexOf("_"); 220 225 var action = button_id.slice(0, pos); 221 226 var textarea_id = button_id.slice(pos+1, button_id.length); 222 // log("action:" + action);223 // log("textarea id:" + textarea_id);227 // log("action:" + action); 228 // log("textarea id:" + textarea_id); 224 229 var textarea = $("#"+textarea_id); 225 230 var old_rows = textarea.attr("rows"); 226 231 227 232 var new_rows = false; 228 233 if (action=="smaller") { … … 236 241 new_rows = Math.ceil(old_rows * RESIZE_FACTOR); 237 242 } 238 243 239 244 if (new_rows == false) { 240 245 log("Error: Wrong textarea resize action:" + action); 241 246 return; 242 247 } 243 // log("old rows:" + old_rows + " - new rows:" + new_rows);248 // log("old rows:" + old_rows + " - new rows:" + new_rows); 244 249 textarea.animate({ 245 250 rows: new_rows 246 251 }, 100 ); 247 252 }); 253 } 254 255 jQuery(document).ready(function($) { 256 activate_resize_textarea_buttons(); 248 257 249 258 /************************************************************************* -
branches/0.9/pylucid_project/pylucid_plugins/page_admin/templates/page_admin/edit_inline_form.html
r2449 r2524 20 20 21 21 <script type="text/javascript"> 22 $(document).ready(function(){ 22 var textarea_changed = false; 23 24 jQuery(document).ready(function($) { 25 log("edit_inline_form.html ready."); 26 23 27 $("#ajax_preview").show(); // unhide ajax preview button 24 28 29 $("#edit_page_form").change(function() { 30 log("edit page form change"); 31 textarea_changed = true; 32 }); 33 $("#edit_page_form").keypress(function() { 34 log("edit page form keypress"); 35 textarea_changed = true; 36 }); 37 $("#edit_page_form").bind('submit', function() { 38 log("submit: set textarea_changed = false"); 39 textarea_changed = false; 40 // $("#preview_fieldset").slideUp("slow"); 41 $("#edit_page_form").before('<h2 class="ajax_msg">{% trans "submit" %}...</h2>'); 42 }); 43 44 // $(window).bind('beforeunload', function() { 45 // ^ this doesn't work! 46 window.onbeforeunload = function() { 47 log("beforeunload evend called. textarea_changed:" + textarea_changed); 48 if (textarea_changed == true) { 49 return "{% trans "Textarea has been changed! Changes are not saved if you leave." %}"; 50 } 51 } 52 25 53 // from media/PyLucid/pylucid_js_tools.js 26 pylucid_ajax_form_view('#edit_page_form');54 // pylucid_ajax_form_view('#edit_page_form'); 27 55 replace_openinwindow_links(); 28 56 … … 30 58 31 59 $("#ajax_preview").click(function() { 32 $("#edit_page_preview").html("<h2>loading...</h2>"); 60 log("ajax preview clicked"); 61 {# It's important here to add a class in h2 tag to make it invisible for the headline ancor! #} 62 $("#edit_page_preview").html('<h2 class="ajax_msg">{% trans "loading" %}...</h2>'); 33 63 $("#preview_fieldset").slideDown(); 34 64 … … 43 73 }); 44 74 }); 45 $("#submit_preview").hide(); 75 $("#submit_preview").hide(); 76 77 $("#abort_button").click(function() { 78 $("#edit_page_form").before('<h2 class="ajax_msg">{% trans "abort" %}...</h2>'); 79 self.location.href='{{ abort_url }}'; 80 }); 81 82 activate_resize_textarea_buttons(); 46 83 }); 47 84 </script> … … 64 101 {% trans 'markup preview' %} 65 102 </button> 66 <input onclick="self.location.href='{{ abort_url }}'" name="abort" value="{% trans 'abort' %}" type="reset" />103 <input type="button" id="abort_button" name="abort" value="{% trans 'abort' %}" /> 67 104 <a href="{{ pagelinklist_url }}" class="openinwindow" title="{% trans 'List of all pages for creating links' %}"> 68 105 <button type="button" class="button">{% trans 'page list' %}</button>