Skip to content

Instantly share code, notes, and snippets.

@blatyo
Created August 17, 2009 13:25
Show Gist options
  • Select an option

  • Save blatyo/169117 to your computer and use it in GitHub Desktop.

Select an option

Save blatyo/169117 to your computer and use it in GitHub Desktop.
//Called on dom:ready
buttonDiv.observe('click', instantEstimate.submitOrder.bindAsEventListener(instantEstimate));
//instance method on instantEstimate
submitOrder: function(event){
event.stop();
if(this.isSubmitting){
return;
}
if(this.pendingSave || this.request){
$waitWindow( //wait window is a lightboxish window
jsText.getLocalizedText('fulfillment.message.savepending'), //that displays this text
'saving:done', //and closes on this event
{'wait_window:close': /*and this is the thing that only gets called after the first time*/
PriceConfirmation.confirmQuotedPrice.bindAsEventListener(PriceConfirmation)} //never makes it into this method
);
} else {
PriceConfirmation.confirmQuotedPrice(event);
return;
}
if(this.pendingSave){
this.quickSave();
}
},
//Wait window
var $waitWindow = function(){
var args = $A(arguments);
var message = args.shift() || '';
var closeEvent = args.shift() || '';
document.observeAll(args.shift());
var waitWindow = Window.getOrCreateWindow(WaitWindow);
waitWindow.setMessage(message);
waitWindow.setCloseEvent(closeEvent);
waitWindow.open();
};
//method added to Element and element instances
observeAll: function(element, eventHandlers){
$H(eventHandlers).each(function(handler){
Event.observe(element, handler.key, handler.value);
});
return element;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment