diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 02c7855d..dc2f98e3 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -583,7 +583,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(%s);jQuery('a[href=#editor_settings] button.close').click();" % response.json(config.read()) + response.headers["web2py-component-command"] = "update_editor(%s);$('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/static/js/ajax_editor.js b/applications/admin/static/js/ajax_editor.js index 6cad1c24..4ff9fc6b 100644 --- a/applications/admin/static/js/ajax_editor.js +++ b/applications/admin/static/js/ajax_editor.js @@ -1,3 +1,5 @@ +var template_js = '
{{{a_tag}}}
{{address}}'; + function prepareDataForSave(name, data) { var obj = new Object(); obj.Name = name; @@ -22,8 +24,8 @@ function prepareMultiPartPOST(data) { } function on_error() { - jQuery("input[name='saved_on']").attr('style', 'background-color:red'); - jQuery("input[name='saved_on']").val('communication error'); + $("input[name='saved_on']").attr('style', 'background-color:red'); + $("input[name='saved_on']").val('communication error'); } function doHighlight(highlight) { @@ -36,24 +38,24 @@ function doHighlight(highlight) { function doClickSave() { - var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id'); - var editor = jQuery(currentTabID + ' textarea').data('editor'); + var currentTabID = '#' + $('#edit_placeholder div.tab-pane.active').attr('id'); + var editor = $(currentTabID + ' textarea').data('editor'); var data = editor.getValue(); var dataForPost = prepareMultiPartPOST(new Array( prepareDataForSave('data', data), prepareDataForSave('file_hash', - jQuery(currentTabID + " input[name='file_hash']").val()), + $(currentTabID + " input[name='file_hash']").val()), prepareDataForSave('saved_on', - jQuery(currentTabID + " input[name='saved_on']").val()), + $(currentTabID + " input[name='saved_on']").val()), prepareDataForSave('saved_on', - jQuery(currentTabID + " input[name='saved_on']").val()), + $(currentTabID + " input[name='saved_on']").val()), prepareDataForSave('from_ajax', 'true'))); // console.info(area.textarea.value); - jQuery(currentTabID + " input[name='saved_on']").attr('style', + $(currentTabID + " input[name='saved_on']").attr('style', 'background-color:yellow'); - jQuery(currentTabID + " input[name='saved_on']").val('saving now...') - currentUrl = jQuery(currentTabID + ' form').attr('action'); - jQuery.ajax({ + $(currentTabID + " input[name='saved_on']").val('saving now...') + currentUrl = $(currentTabID + ' form').attr('action'); + $.ajax({ type: "POST", contentType: 'multipart/form-data;boundary="' + dataForPost[1] + '"', url: currentUrl, @@ -67,38 +69,38 @@ function doClickSave() { 'doClickSave'); }, success: function (json, text, xhr) { - jQuery(editor).data('saved', true); // Set as saved + $(editor).data('saved', true); // Set as saved editor.on("change", store_changes_function); // Re-enable change watcher // reenable disabled submit button - var t = jQuery("input[name='save']"); + var t = $("input[name='save']"); t.attr('class', ''); t.attr('disabled', ''); var flash = xhr.getResponseHeader('web2py-component-flash'); if(flash) { - jQuery('.flash').html(decodeURIComponent(flash)) + $('.flash').html(decodeURIComponent(flash)) .append('×') .slideDown(); - } else jQuery('.flash').hide(); + } else $('.flash').hide(); try { if(json.error) { window.location.href = json.redirect; } else { // console.info( json.file_hash ); - jQuery(currentTabID + " input[name='file_hash']").val(json.file_hash); - jQuery(currentTabID + " input[name='saved_on']").val(json.saved_on); + $(currentTabID + " input[name='file_hash']").val(json.file_hash); + $(currentTabID + " input[name='saved_on']").val(json.saved_on); if(json.highlight) { doHighlight(json.highlight); } else { - jQuery(currentTabID + " input[name='saved_on']").attr('style', 'background-color:#99FF99'); - //jQuery(".flash").delay(1000).fadeOut('slow'); + $(currentTabID + " input[name='saved_on']").attr('style', 'background-color:#99FF99'); + //$(".flash").delay(1000).fadeOut('slow'); } - // console.info(jQuery("input[name='file_hash']").val()); + // console.info($("input[name='file_hash']").val()); var output = 'exposes: '; for(var i in json.functions) { output += ' ' + json.functions[i] + ','; } if(output != 'exposes: ') { - jQuery(currentTabID + " .exposed").html(output.substring(0, output.length - 1)); + $(currentTabID + " .exposed").html(output.substring(0, output.length - 1)); } } } catch(e) { @@ -113,8 +115,8 @@ function doClickSave() { } function getActiveEditor() { - var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id'); - var editor = jQuery(currentTabID + ' textarea').data('editor'); + var currentTabID = '#' + $('#edit_placeholder div.tab-pane.active').attr('id'); + var editor = $(currentTabID + ' textarea').data('editor'); return editor; } @@ -139,7 +141,7 @@ function doToggleBreakpoint(filename, url, sel) { prepareDataForSave('sel_start', sel["start"]), prepareDataForSave('sel_end', sel["end"]), prepareDataForSave('data', sel['data']))); - jQuery.ajax({ + $.ajax({ type: "POST", contentType: 'multipart/form-data;boundary="' + dataForPost[1] + '"', url: url, @@ -156,10 +158,10 @@ function doToggleBreakpoint(filename, url, sel) { // show flash message (if any) var flash = xhr.getResponseHeader('web2py-component-flash'); if(flash) { - jQuery('.flash').html(decodeURIComponent(flash)) + $('.flash').html(decodeURIComponent(flash)) .append('×') .slideDown(); - } else jQuery('.flash').hide(); + } else $('.flash').hide(); try { if(json.error) { window.location.href = json.redirect; @@ -189,7 +191,7 @@ function doListBreakpoints(filename, url, editor) { var dataForPost = prepareMultiPartPOST(new Array( prepareDataForSave('filename', filename) )); - jQuery.ajax({ + $.ajax({ type: "POST", contentType: 'multipart/form-data;boundary="' + dataForPost[1] + '"', url: url, @@ -235,7 +237,7 @@ function makeMarker() { function keepalive(url) { - jQuery.ajax({ + $.ajax({ type: "GET", url: url, timeout: 1000, @@ -247,7 +249,7 @@ function keepalive(url) { } function load_file(url) { - jQuery.ajax({ + $.ajax({ type: "GET", contentType: 'application/json', cache: false, @@ -256,18 +258,18 @@ function load_file(url) { timeout: 1000, success: function (json) { if(typeof (json['plain_html']) !== undefined) { - if(jQuery('#' + json['id']).length === 0 || json['force'] === true) { + if($('#' + json['id']).length === 0 || json['force'] === true) { // Create a tab and put the code in it var tab_header = '{{{a_tag}}}
{{address}}'; + diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index 61525612..670fb0e5 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -15,6 +15,8 @@ return A(file, _class='editor_filelink', _href=url, _style='word-wrap: nowrap;') }} {{cm=URL('static%s' % (response.static_version and '/_' + response.static_version or ''),'codemirror')}} +{{js_url=URL('static%s' % (response.static_version and '/_' + response.static_version or ''),'js')}} +{{css_url=URL('static%s' % (response.static_version and '/_' + response.static_version or ''),'css')}} @@ -45,9 +47,9 @@ - - - + + + diff --git a/applications/admin/views/default/editor_settings.html b/applications/admin/views/default/editor_settings.html index f8898e95..ab4c0dda 100644 --- a/applications/admin/views/default/editor_settings.html +++ b/applications/admin/views/default/editor_settings.html @@ -39,7 +39,7 @@ diff --git a/applications/admin/views/layout.html b/applications/admin/views/layout.html index 41e4a71b..d1bdbe37 100644 --- a/applications/admin/views/layout.html +++ b/applications/admin/views/layout.html @@ -12,7 +12,6 @@ response.files.append(URL('static','css/bootstrap-responsive.min.css')) }} {{include 'web2py_ajax.html'}} -