From 2ebf0d12ed223f2ca10723e40fe7e640e1c00065 Mon Sep 17 00:00:00 2001 From: Roberto Perdomo Date: Sun, 22 Sep 2013 18:36:28 -0430 Subject: [PATCH] Fix lost flash message in case of error when save editor (crtl-s). Change Esc to Ctrl-Esc to exit from Fullscreen mode, because this cause collision with the Vim mode (Esc key). Add a select into the config button to select 'default', 'vim' or 'emacs' editor --- applications/admin/controllers/default.py | 7 +++--- applications/admin/static/js/ajax_editor.js | 6 +++++ applications/admin/views/default/edit.html | 24 ++++++++++++++++--- applications/admin/views/default/edit_js.html | 9 +++---- .../admin/views/default/editor_settings.html | 3 +++ 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 5afec708..4c3c1ee1 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -562,7 +562,7 @@ def edit(): # Load json only if it is ajax edited... app = get_app(request.vars.app) app_path = apath(app, r=request) - editor_defaults={'theme':'web2py'} + editor_defaults={'theme':'web2py', 'editor': 'default'} config = Config(os.path.join(request.folder, 'settings.cfg'), section='editor', default_values=editor_defaults) preferences = config.read() @@ -588,7 +588,7 @@ def edit(): response.headers["web2py-component-flash"] = T('Preferences saved correctly') else: response.headers["web2py-component-flash"] = T('Preferences saved on session only') - response.headers["web2py-component-command"] = "update_theme('%s'); jQuery('a[href=#editor_settings] button.close').click();" % config.read()['theme'] + response.headers["web2py-component-command"] = "update_theme('%s');update_editor('%s');jQuery('a[href=#editor_settings] button.close').click();" % (config.read()['theme'], config.read()['editor']) return else: details = {'filename':'settings', 'id':'editor_settings', 'force': False} @@ -604,7 +604,7 @@ def edit(): path = abspath(filename) else: path = apath(filename, r=request) - # Try to discover the file type + # Try to discover the file type if filename[-3:] == '.py': filetype = 'python' elif filename[-5:] == '.html': @@ -700,7 +700,6 @@ def edit(): offset and ' ' + T('at char %s', offset) or '', PRE(str(e))) - if data_or_revert and request.args[1] == 'modules': # Lets try to reload the modules try: diff --git a/applications/admin/static/js/ajax_editor.js b/applications/admin/static/js/ajax_editor.js index e23b3481..38a47225 100644 --- a/applications/admin/static/js/ajax_editor.js +++ b/applications/admin/static/js/ajax_editor.js @@ -73,6 +73,12 @@ function doClickSave() { var t = jQuery("input[name='save']"); t.attr('class', ''); t.attr('disabled', ''); + var flash = xhr.getResponseHeader('web2py-component-flash'); + if(flash) { + jQuery('.flash').html(decodeURIComponent(flash)) + .append('×') + .slideDown(); + } else jQuery('.flash').hide(); try { if(json.error) { window.location.href = json.redirect; diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index 35ff2865..68eebb8f 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -16,13 +16,12 @@ }} {{cm=URL('static','codemirror')}} - + -{{if TEXT_EDITOR_KEYBINDING == 'emacs':}}{{pass}} -{{if TEXT_EDITOR_KEYBINDING == 'vi':}}{{pass}} +{{if editor_settings['editor'] != 'default':}}{{pass}} @@ -43,6 +42,7 @@