Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created September 17, 2009 21:55
Show Gist options
  • Select an option

  • Save lsmith/188752 to your computer and use it in GitHub Desktop.

Select an option

Save lsmith/188752 to your computer and use it in GitHub Desktop.
(function () {
YAHOO.namespace('KVC');
// YAHOO.util.Event.throwErrors = true; // for debugging.
var xdrConfig = {
id : 'flash',
yid : Y.id,
src : '/assets/scripts/kvc/io.swf?t=' + new Date().valueOf().toString()
};
// Look up how to configure the XDR in YUI 2
Y.io.transport(xdrConfig);
YAHOO.Bubbling.on('onScriptReady', function (layer, args) {
if(typeof sparta !== 'undefined' && typeof sparta.submitAjaxRequest !== 'undefined') {
sparta.submitAjaxRequest = function(url, loadableDivLayer, dynamicMessageLayer) {
YAHOO.KVC.crossDomainAjaxRequest(url, loadableDivLayer);
};
}
if(typeof sparta !== 'undefined' && typeof sparta.submitAjaxFormRequest !== 'undefined') {
sparta.submitAjaxFormRequest = function(url, formname) {
YAHOO.KVC.handleFormPost(url, formname);
};
}
});
var handleSuccess = function(id, o, a) {
var area = YAHOO.util.Dom.get(a.layer);
YAHOO.plugin.Dispatcher.process(area, o.responseText, {rel:'main-area'});
}
var handleFailure = function(id, o, a) {
}
YAHOO.KVC.crossDomainAjaxRequest = function(url, responseContainer) {
var obj = Y.io(url, {
method: "POST",
xdr: {use: 'flash'},
data: "user=yahoo",
on: {
success: handleSuccess,
failure: handleFailure
},
arguments: {"layer": responseContainer}
});
};
YAHOO.KVC.handleFormPost = function(url, formname) {
var formObj = YAHOO.util.Dom.get(formname);
var f = Y.io._serialize(formObj);
var obj = Y.io(url, {
method: "POST",
xdr: {use: 'flash'},
data: f,
form: {id: "MailForm", useDisabled: true},
on: {
success: handleSuccess,
failure: handleFailure
},
arguments: {"layer": "output"}
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment