Fehler auf taz.de entdeckt?
Wir freuen uns über eine
Mail an fehlerhinweis@taz.de!
Inhaltliches Feedback?
Gerne als Leser*innenkommentar unter dem Text auf taz.de oder über das
Kontaktformular.
'
);
// var callback = callback;
var altFormNs = $(); // keep track of form nodes we may insert from server responses
var clear4reset = function(){
altFormNs.slideUp( function(){
altFormNs.remove(); altFormNs = $();
});
};
var back2start = function( val ){
if( typeof val == 'string' ) {
form1N.find('>.sectbody >span >textarea')
.val( val )
.trigger('blur')
;
}
// ToDo: show hint -> change filOtaz_de.Form first
mirror.toShow.prop('disabled', false);
mirror.toHide.slideDown();
form1N.slideDown();
};
var reset = function( val ){
clear4reset();
back2start( val );
};
var handle200 = ( options.handle200 instanceof Function )? options.handle200 : function( data, status, req ){
//console.log( data.documentElement.outerHTML );
if( options.onSuccess instanceof Function ) options.onSuccess();
clear4reset(); // hide follow-up forms
var message = $(data).filter('.message');
if( message.length && message.text() >'' ) { // show success message
var messageN = $('').append( message.addClass('sectbody') );
$('').appendTo( message ).click( function(){
messageN.slideUp( function(){ messageN.remove(); });
back2start(''); // reset to original form
return false;
});
messageN.hide().prependTo( form1N.parent() ).slideDown();
form1N.slideUp();
}
}
var asySubmit = function( formN ){
var formN = formN;
var action;
var clickLock = false;
formN.find('>.sectbody >input:submit').click( function(){
if( clickLock ) return false; clickLock = true;
action = formN.attr('action'); if( !action ) return; // ToDo: handle missing action
action = action.replace(/^http:/,'https:'); // ToDo: handle relative action URL
var handle422 = function( data ) { // we sent incomplete Data. Show forms from response body!
//console.log( data[0].documentElement.outerHTML );
var formNs = data.find('form');
if( !formNs.length ) {
alert('error: server response fails expectations: no form found.');
return false;
}
var anchor = $('').hide()[ mirror.node.length ?'insertAfter' :'insertBefore' ]( formN );
formN.not( mirror.node ).slideUp( function(){
formN.not( form1N ).remove();
});
mirror.toShow.attr({ disabled : true });
mirror.toHide.slideUp();
var last = anchor;
formNs.each( function(i,e){ var n = $(e);
var have = $('#'+ n.attr('id') );
if(! n.children('.secthead').length )
have.children('.secthead').first().clone(true).prependTo( n );
var have = have.not( form1N );
have.slideUp( function(){
altFormNs = altFormNs.not( have );
have.remove(); // remove old incarnation
});
n.find('script').remove(); // don't import scripts
n.hide().insertAfter( last );
anchor.remove();
last = n;
altFormNs = altFormNs.add( n );
/*
*/
var ccN = n.find('#captcha-code');
var captchaCode = ccN.attr('name');
if( ccN.length && captchaCode ) // this form needs a captcha, make one!
Recaptcha.create( captchaCode, 'captcha-code', {
theme: 'red'
} );
(new filOtaz_de.Form( n )).cancel( function(){
reset();
});
asySubmit( n );
n.slideDown();
});
//console.log( altFormNs.length +' forms found' );
} //handle422
var post = {};
formN.find('input,textarea').each( function(i,n){ var N = $(n);
post[N.attr('name')] = N.val();
});
$.ajax({
type : 'POST',
url : action,
cache : false,
data : post,
dataType : 'html', // 'xml',
xhrFields: {
withCredentials: true
},
// chrisso: Disabled beforeSend manipulation because first parameter ("req") is now jqXHR and not original XMLHttpRequest object. (see above "xhrFields")
//
// beforeSend : function( req, settings ){
// req.responseType = 'document';
// req.withCredentials = true;
// //req.overrideMimeType('text/xml');
// },
success : function( data, status, req ){ // our post was accepted, show response message!
handle200( data, status, req );
},
error : function( req, status, message ){
//console.log('status: '+ status +' :: '+ message );
var data = $( req.response );
if( !data.length ) { // data is not document
var text;
try{ text = req.responseText;
if( text ) text = text.replace(/http:/g, ""); // have src'es protocol relative
data = $('').html( text );
//console.log('response text: '+ text );
} catch(e) {
//console.log('error reading responseText: '+ e );
}
}
if( !data.length ) {
try{
//console.log( req.response.head.parentElement.outerHTML );
} catch(e) {
//console.log('error reading response.head: '+ e );
}
}
({ 0 : function() {
alert('Error: Can not see server answer. CORS missing?'); // seems a Cross-Origin problem
//console.log( data );
},
200 : function() { // 200 but error, IE9 ends up here
handle200( data, status, req );
},
422 : function() { handle422( data ); }
})[ req.status ]();
}, //error
/* not available befor jQ 1.5
statusCode : {
422 : function( req, status, message ){}
},
*/
complete : function( req, status ){
//try{ console.log('response headers:\n'+ req.getAllResponseHeaders() ); } catch(e){ console.log('getAllResponseHeaders() failed'); }
//console.log('responseXML: '+ req.responseXML );
//if( req.response ) console.log( req.response.head.parentElement.outerHTML )
//else console.log('no data');
clickLock = false;
}
}); //ajax
return false;
}); //click
}; //asySubmit
asySubmit( form1N );
}; //filOtaz_de.ajaxifyForm
})();
'
);
// var callback = callback;
var altFormNs = $(); // keep track of form nodes we may insert from server responses
var clear4reset = function(){
altFormNs.slideUp( function(){
altFormNs.remove(); altFormNs = $();
});
};
var back2start = function( val ){
if( typeof val == 'string' ) {
form1N.find('>.sectbody >span >textarea')
.val( val )
.trigger('blur')
;
}
// ToDo: show hint -> change filOtaz_de.Form first
mirror.toShow.prop('disabled', false);
mirror.toHide.slideDown();
form1N.slideDown();
};
var reset = function( val ){
clear4reset();
back2start( val );
};
var handle200 = ( options.handle200 instanceof Function )? options.handle200 : function( data, status, req ){
//console.log( data.documentElement.outerHTML );
if( options.onSuccess instanceof Function ) options.onSuccess();
clear4reset(); // hide follow-up forms
var message = $(data).filter('.message');
if( message.length && message.text() >'' ) { // show success message
var messageN = $('').append( message.addClass('sectbody') );
$('').appendTo( message ).click( function(){
messageN.slideUp( function(){ messageN.remove(); });
back2start(''); // reset to original form
return false;
});
messageN.hide().prependTo( form1N.parent() ).slideDown();
form1N.slideUp();
}
}
var asySubmit = function( formN ){
var formN = formN;
var action;
var clickLock = false;
formN.find('>.sectbody >input:submit').click( function(){
if( clickLock ) return false; clickLock = true;
action = formN.attr('action'); if( !action ) return; // ToDo: handle missing action
action = action.replace(/^http:/,'https:'); // ToDo: handle relative action URL
var handle422 = function( data ) { // we sent incomplete Data. Show forms from response body!
//console.log( data[0].documentElement.outerHTML );
var formNs = data.find('form');
if( !formNs.length ) {
alert('error: server response fails expectations: no form found.');
return false;
}
var anchor = $('').hide()[ mirror.node.length ?'insertAfter' :'insertBefore' ]( formN );
formN.not( mirror.node ).slideUp( function(){
formN.not( form1N ).remove();
});
mirror.toShow.attr({ disabled : true });
mirror.toHide.slideUp();
var last = anchor;
formNs.each( function(i,e){ var n = $(e);
var have = $('#'+ n.attr('id') );
if(! n.children('.secthead').length )
have.children('.secthead').first().clone(true).prependTo( n );
var have = have.not( form1N );
have.slideUp( function(){
altFormNs = altFormNs.not( have );
have.remove(); // remove old incarnation
});
n.find('script').remove(); // don't import scripts
n.hide().insertAfter( last );
anchor.remove();
last = n;
altFormNs = altFormNs.add( n );
/*
*/
var ccN = n.find('#captcha-code');
var captchaCode = ccN.attr('name');
if( ccN.length && captchaCode ) // this form needs a captcha, make one!
Recaptcha.create( captchaCode, 'captcha-code', {
theme: 'red'
} );
(new filOtaz_de.Form( n )).cancel( function(){
reset();
});
asySubmit( n );
n.slideDown();
});
//console.log( altFormNs.length +' forms found' );
} //handle422
var post = {};
formN.find('input,textarea').each( function(i,n){ var N = $(n);
post[N.attr('name')] = N.val();
});
$.ajax({
type : 'POST',
url : action,
cache : false,
data : post,
dataType : 'html', // 'xml',
xhrFields: {
withCredentials: true
},
// chrisso: Disabled beforeSend manipulation because first parameter ("req") is now jqXHR and not original XMLHttpRequest object. (see above "xhrFields")
//
// beforeSend : function( req, settings ){
// req.responseType = 'document';
// req.withCredentials = true;
// //req.overrideMimeType('text/xml');
// },
success : function( data, status, req ){ // our post was accepted, show response message!
handle200( data, status, req );
},
error : function( req, status, message ){
//console.log('status: '+ status +' :: '+ message );
var data = $( req.response );
if( !data.length ) { // data is not document
var text;
try{ text = req.responseText;
if( text ) text = text.replace(/http:/g, ""); // have src'es protocol relative
data = $('').html( text );
//console.log('response text: '+ text );
} catch(e) {
//console.log('error reading responseText: '+ e );
}
}
if( !data.length ) {
try{
//console.log( req.response.head.parentElement.outerHTML );
} catch(e) {
//console.log('error reading response.head: '+ e );
}
}
({ 0 : function() {
alert('Error: Can not see server answer. CORS missing?'); // seems a Cross-Origin problem
//console.log( data );
},
200 : function() { // 200 but error, IE9 ends up here
handle200( data, status, req );
},
422 : function() { handle422( data ); }
})[ req.status ]();
}, //error
/* not available befor jQ 1.5
statusCode : {
422 : function( req, status, message ){}
},
*/
complete : function( req, status ){
//try{ console.log('response headers:\n'+ req.getAllResponseHeaders() ); } catch(e){ console.log('getAllResponseHeaders() failed'); }
//console.log('responseXML: '+ req.responseXML );
//if( req.response ) console.log( req.response.head.parentElement.outerHTML )
//else console.log('no data');
clickLock = false;
}
}); //ajax
return false;
}); //click
}; //asySubmit
asySubmit( form1N );
}; //filOtaz_de.ajaxifyForm
})();