From 56f251ca0c2d96d8e5328b68d399188e538a5730 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Sun, 20 Oct 2013 08:40:05 +0200 Subject: [PATCH] tab size in editor settings and better options management --- applications/admin/controllers/default.py | 4 ++-- applications/admin/views/default/edit.html | 24 ++++++++++++------- applications/admin/views/default/edit_js.html | 5 ++-- .../admin/views/default/editor_settings.html | 8 +++++++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 9b3a0772..8cdd0cb6 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -563,7 +563,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': 'default', 'closetag': 'true', 'codefolding': 'false'} + editor_defaults={'theme':'web2py', 'editor': 'default', 'closetag': 'true', 'codefolding': 'false', 'tabwidth':'4', 'indentwithtabs':'false'} config = Config(os.path.join(request.folder, 'settings.cfg'), section='editor', default_values=editor_defaults) preferences = config.read() @@ -580,7 +580,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_editor('%(theme)s', '%(editor)s', %(closetag)s, %(codefolding)s);jQuery('a[href=#editor_settings] button.close').click();" % (config.read()) + response.headers["web2py-component-command"] = "update_editor(%s);jQuery('a[href=#editor_settings] button.close').click();" % response.json(config.read()) return else: details = {'filename':'settings', 'id':'editor_settings', 'force': False} diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index e33115a5..61525612 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -57,6 +57,8 @@ var current_editor = "{{=editor_settings['editor']}}"; //Default editor var current_closetag = false; //Default closetag {{pass}} var current_codefolding = {{=editor_settings['codefolding']}}; //Default codefolding +var current_indentwithtabs = {{=editor_settings['indentwithtabs']}}; +var current_tabwidth = {{=editor_settings['tabwidth']}}; var current_font_incr = 0; // Default font-size, 0 means don't set jQuery(document).on('shown click', 'a[data-toggle="tab"]', function (e) { @@ -110,8 +112,8 @@ jQuery(document).on('click', 'a.editor_filelink, a#editor_settingslink', functio load_file(url); }); -function update_editor(editor_theme, editor_name, editor_closetag, editor_codefolding) { - var href = "{{="%s/theme/" % cm}}" + editor_theme + ".css"; +function update_editor(config) { + var href = "{{="%s/theme/" % cm}}" + config.theme + ".css"; var link = jQuery(""); link.attr({ type: 'text/css', @@ -119,8 +121,8 @@ function update_editor(editor_theme, editor_name, editor_closetag, editor_codefo href: href }); jQuery("head").append( link ); - if (editor_name !='default'){ - var src = "{{='%s/keymap/' % cm}}" + editor_name + ".js"; + if ( config.editor != 'default'){ + var src = "{{='%s/keymap/' % cm}}" + config.editor + ".js"; //var src = "/admin/static/codemirror/keymap/" + editor_name + ".js"; var script = jQuery("