Ticket #52: esc-to-cancel.patch
| File esc-to-cancel.patch, 3.2 KB (added by Nightgunner5, 23 months ago) |
|---|
-
gp-includes/assets-loader.php
25 25 $scripts->add( 'jquery-ui-selectable', null, array('jquery-ui'), '1.8' ); 26 26 $scripts->add( 'jquery-ui-tabs', null, array('jquery-ui'), '1.8' ); 27 27 $scripts->add( 'common', '/common.js', array( 'jquery' ), '20100423' ); 28 $scripts->add( 'editor', '/editor.js', array( 'common', 'google-js-api' ), '20100 614' );28 $scripts->add( 'editor', '/editor.js', array( 'common', 'google-js-api' ), '20100713' ); 29 29 $scripts->add( 'translations-page', '/translations-page.js', array( 'common' ), '20100423' ); 30 30 $scripts->add( 'mass-create-sets-page', '/mass-create-sets-page.js', array( 'common' ), '20100423' ); 31 31 $scripts->add( 'google-js-api', 'http://www.google.com/jsapi', array(), '' ); -
js/editor.js
26 26 $('tr:first', $gp.editor.table).hide(); 27 27 $('textarea:first', editor).focus(); 28 28 }, 29 prev: function() { 30 if (!$gp.editor.current) return; 31 //TODO: go to previous page if needed 32 var prev = $gp.editor.current.prevAll('tr.editor'); 33 if (prev.length) 34 $gp.editor.show(next.filter(':last')); 35 else 36 $gp.editor.hide(); 37 }, 29 38 next: function() { 30 39 if (!$gp.editor.current) return; 31 40 //TODO: go to next page if needed … … 52 61 $('button.ok', 'tr.editor').live('click', $gp.editor.hooks.ok); 53 62 $('tr.preview', $gp.editor.table).live('dblclick', $gp.editor.hooks.show); 54 63 $('select.priority', $gp.editor.table).live('change', $gp.editor.hooks.set_priority); 64 $('textarea', 'tr.editor').live('keydown', $gp.editor.hooks.keydown); 55 65 }, 66 keydown: function(e) { 67 if (e.keyCode == 27) 68 $gp.editor.hide(); 69 else if (e.keyCode == 33) 70 $gp.editor.prev(); 71 else if (e.keyCode == 34) 72 $gp.editor.next(); 73 else if (e.keyCode == 13 && e.shiftKey) { 74 var target = $(e.target); 75 if (target.nextAll('textarea').length) 76 target.nextAll('textarea').eq(0).focus() 77 else 78 $gp.editor.save(target.parents('tr.editor').find('button.ok')); 79 } else 80 return true; 81 return false; 82 }, 56 83 replace_current: function(html) { 57 84 if (!$gp.editor.current) return; 58 85 $gp.editor.current.after(html); … … 73 100 }).get().join('&'); 74 101 $.ajax({type: "POST", url: $gp_editor_options.url, data: data, dataType: 'json', 75 102 success: function(data){ 76 button. attr('disabled', '');103 button.removeAttr('disabled'); 77 104 $gp.notices.success('Saved!'); 78 105 for(original_id in data) { 79 106 $gp.editor.replace_current(data[original_id]); … … 85 112 } 86 113 }, 87 114 error: function(xhr, msg, error) { 88 button. attr('disabled', '');115 button.removeAttr('disabled'); 89 116 msg = xhr.responseText? 'Error: '+ xhr.responseText : 'Error saving the translation!'; 90 117 $gp.notices.error(msg); 91 118 } … … 176 203 $gp.editor.save($(this)); 177 204 return false; 178 205 }, 206 keydown: function(e) { 207 return $gp.editor.keydown(e); 208 }, 179 209 copy: function() { 180 210 $gp.editor.copy($(this)); 181 211 return false;
