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

     
    2525        $scripts->add( 'jquery-ui-selectable', null, array('jquery-ui'), '1.8' ); 
    2626        $scripts->add( 'jquery-ui-tabs', null, array('jquery-ui'), '1.8' ); 
    2727        $scripts->add( 'common', '/common.js', array( 'jquery' ), '20100423' ); 
    28         $scripts->add( 'editor', '/editor.js', array( 'common', 'google-js-api' ), '20100614' ); 
     28        $scripts->add( 'editor', '/editor.js', array( 'common', 'google-js-api' ), '20100713' ); 
    2929        $scripts->add( 'translations-page', '/translations-page.js', array( 'common' ), '20100423' ); 
    3030        $scripts->add( 'mass-create-sets-page', '/mass-create-sets-page.js', array( 'common' ), '20100423' ); 
    3131        $scripts->add( 'google-js-api', 'http://www.google.com/jsapi', array(), '' ); 
  • js/editor.js

     
    2626                $('tr:first', $gp.editor.table).hide(); 
    2727                $('textarea:first', editor).focus(); 
    2828        }, 
     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        }, 
    2938        next: function() { 
    3039                if (!$gp.editor.current) return; 
    3140                //TODO: go to next page if needed 
     
    5261                $('button.ok', 'tr.editor').live('click', $gp.editor.hooks.ok); 
    5362                $('tr.preview', $gp.editor.table).live('dblclick', $gp.editor.hooks.show); 
    5463                $('select.priority', $gp.editor.table).live('change', $gp.editor.hooks.set_priority); 
     64                $('textarea', 'tr.editor').live('keydown', $gp.editor.hooks.keydown); 
    5565        }, 
     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        }, 
    5683        replace_current: function(html) { 
    5784                if (!$gp.editor.current) return; 
    5885                $gp.editor.current.after(html); 
     
    73100                }).get().join('&'); 
    74101                $.ajax({type: "POST", url: $gp_editor_options.url, data: data, dataType: 'json', 
    75102                        success: function(data){ 
    76                                 button.attr('disabled', ''); 
     103                                button.removeAttr('disabled'); 
    77104                                $gp.notices.success('Saved!'); 
    78105                                for(original_id in data) { 
    79106                                        $gp.editor.replace_current(data[original_id]); 
     
    85112                                } 
    86113                        }, 
    87114                        error: function(xhr, msg, error) { 
    88                                 button.attr('disabled', ''); 
     115                                button.removeAttr('disabled'); 
    89116                                msg = xhr.responseText? 'Error: '+ xhr.responseText : 'Error saving the translation!'; 
    90117                                $gp.notices.error(msg); 
    91118                        } 
     
    176203                        $gp.editor.save($(this)); 
    177204                        return false; 
    178205                }, 
     206                keydown: function(e) { 
     207                        return $gp.editor.keydown(e); 
     208                }, 
    179209                copy: function() { 
    180210                        $gp.editor.copy($(this)); 
    181211                        return false;