Merge pull request #472 from ilvalle/fix_editor
editor:potential fix for requests cancelled due to same origin policy
This commit is contained in:
@@ -249,14 +249,7 @@ function keepalive(url) {
|
||||
}
|
||||
|
||||
function load_file(url, lineno) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
contentType: 'application/json',
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
timeout: 1000,
|
||||
success: function (json) {
|
||||
$.getJSON(url, function (json) {
|
||||
if(typeof (json['plain_html']) !== undefined) {
|
||||
if($('#' + json['id']).length === 0 || json['force'] === true) {
|
||||
// Create a tab and put the code in it
|
||||
@@ -271,11 +264,10 @@ function load_file(url, lineno) {
|
||||
}
|
||||
$("a[href='#" + json['id'] + "']").trigger('click', lineno);
|
||||
}
|
||||
},
|
||||
error: function (x) {
|
||||
}).fail(function() {
|
||||
on_error();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function set_font(editor, incr) {
|
||||
|
||||
@@ -199,11 +199,6 @@ $(document).on('click', 'a.font_button', function (e) {
|
||||
});
|
||||
current_font_incr = (new_incr !== 0) ? current_font_incr + new_incr : 0;
|
||||
});
|
||||
|
||||
{{if len(request.args) > 1:}}
|
||||
load_file('{{=URL(f='edit', args=request.args, vars=request.get_vars)}}', {{=request.vars.lineno or 1}});
|
||||
{{pass}}
|
||||
|
||||
</script>
|
||||
|
||||
{{block sectionclass}}edit{{end}}
|
||||
@@ -305,6 +300,9 @@ $(document).ready(function() {
|
||||
$('#files').css('left', '-'+ow+'px');
|
||||
$.web2py.trap_form('url', 'form');
|
||||
$('#form form').addClass('no_trap'); // Let to reuse the same form
|
||||
{{if len(request.args) > 1:}}
|
||||
load_file('{{=URL(f='edit', args=request.args, vars=request.get_vars)}}', {{=request.vars.lineno or 1}});
|
||||
{{pass}}
|
||||
});
|
||||
</script>
|
||||
<!-- Typeahead scripts here so the page load faster -->
|
||||
|
||||
Reference in New Issue
Block a user