@ -603,7 +603,7 @@ define([
var to _absolute _cursor _pos = function ( cm , cursor ) {
console . warn ( '`utils.to_absolute_cursor_pos(cm, pos)` is deprecated. Use `cm.indexFromPos(cursor)`' ) ;
return cm . indexFromPos ( cu s rsor) ;
return cm . indexFromPos ( cu rsor) ;
} ;
var from _absolute _cursor _pos = function ( cm , cursor _pos ) {
@ -752,6 +752,29 @@ define([
return wrapped _error ;
} ;
var ajax = function ( url , settings ) {
// like $.ajax, but ensure Authorization header is set
settings = _add _auth _header ( settings ) ;
return $ . ajax ( url , settings ) ;
} ;
var _add _auth _header = function ( settings ) {
/ * *
* Adds auth header to jquery ajax settings
* /
settings = settings || { } ;
if ( ! settings . headers ) {
settings . headers = { } ;
}
if ( ! settings . headers . Authorization ) {
var xsrf _token = get _body _data ( 'xsrfToken' ) ;
if ( xsrf _token ) {
settings . headers [ 'X-XSRFToken' ] = xsrf _token ;
}
}
return settings ;
} ;
var promising _ajax = function ( url , settings ) {
/ * *
* Like $ . ajax , but returning an ES6 promise . success and error settings
@ -766,7 +789,7 @@ define([
log _ajax _error ( jqXHR , status , error ) ;
reject ( wrap _ajax _error ( jqXHR , status , error ) ) ;
} ;
$. ajax( url , settings ) ;
ajax( url , settings ) ;
} ) ;
} ;
@ -1010,10 +1033,11 @@ define([
is _or _has : is _or _has ,
is _focused : is _focused ,
mergeopt : mergeopt ,
ajax _error _msg : ajax _error _msg ,
log _ajax _error : log _ajax _error ,
requireCodeMirrorMode : requireCodeMirrorMode ,
XHR _ERROR : XHR _ERROR ,
ajax : ajax ,
ajax _error _msg : ajax _error _msg ,
log _ajax _error : log _ajax _error ,
wrap _ajax _error : wrap _ajax _error ,
promising _ajax : promising _ajax ,
WrappedError : WrappedError ,