(function ernestfaxWrapper() {
function ernestfaxGrabPreview( e ) {
// grabbing the preview button
var txt = $( "#wpTextbox1" ),
alltext = txt.val(),
reflist = /<references|\{\{reflist/i ; // |\{\{refbegin/i refbegin seems unnecessary here
if ( -1 !== alltext.search( "<ref" ) && -1 === alltext.search( reflist ) ) {
txt.val( alltext + "{{reflist}}" ); // add in a </references> just for the ajax preview
doLivePreview(e);
txt.val( alltext ); // restore it as it was, before the above insertions
} else {
doLivePreview(e);
}
return false;
}
function ernestfaxgo(e) { // once page is ready
$("#wpPreview").
unbind( "click", doLivePreview ). // remove the ajax preview handler. it will get called from ernestfaxGrabPreview
click( ernestfaxGrabPreview ); // add the call to prepare for the preview
}
try {
$( document ).ready( ernestfaxgo );
} catch ( err ) {
// no jquery present, so not on an edit page, so don't do anything
}
}() );