Posts that Alon is monitoring
|
May 28, 2007
|
Topic: Windows.close() Thank you for your reply! I’ve encountered another problem with Windows.close() function. It works fine in Firefox but not with IE :(
AIM.AjaxFormSave = Class.create();
Object.extend(AIM.AjaxFormSave.prototype, {
initialize: function(formId, button, checks, redirect){
this.form = $(formId);
this.checks = checks;
this.redirect = redirect;
this.callback = null;
this.events = $H({ onSave: [],
onSuccess: [] });
var count = 0, node = $('AjaxFormSaveTarget'+count);
while(node){
count++;
node = $('AjaxFormSaveTarget'+count);
}
this.target = document.createElement('iframe');
this.target.id = 'AjaxFormSaveTarget'+count;
this.target.name = 'AjaxFormSaveTarget'+count;
this.target.style.display = 'none';
document.body.appendChild(this.target);
this.form.target = 'AjaxFormSaveTarget'+count;
Event.observe($(button), 'click', this.doSave.bind(this));
Event.observe(this.target, 'load', this.finishSave.bind(this));
},
registerEvent: function(event, handler){
if(this.events.keys().member(event))
this.events[event].push(handler);
},
fireEvent: function(){
var args = $A(arguments);
var event = args.shift();
if(this.events.keys().member(event)){
return this.events[event].all(function(value, index){ return value.apply(null, args); });
}
return true;
},
doSave: function(){
if(this.saving)
return;
this.startSaving();
this.callback = null;
if(arguments.length > 0 && typeof arguments[0] == 'function')
this.callback = arguments[0];
var result;
for(var i = 0; i < this.checks.length; i++){
result = this.checks[i]();
if(result !== true){
Dialog.alert(result, AIM.Control.dialogOptions());
this.stopSaving();
return false;
}
}
if(!this.fireEvent('onSave')){
Dialog.alert('An error occurred while preparing to save!', AIM.Control.dialogOptions());
this.stopSaving();
return false;
}
this.form.submit();
},
startSaving: function(){
this.saving = true;
Dialog.info("Saving...", Object.extend(AIM.Control.dialogOptions(), { showProgress: true, id: 'savingMsg' }));
},
stopSaving: function(){
this.saving = false;
Windows.close('savingMsg');
},
finishSave: function(){
if(!this.saving)
return;
var retVal, responseText;
try {
var responseTexts = this.target.contentWindow.document.getElementsByTagName('textarea');
if(responseTexts.length > 0){
responseText = responseTexts[0].value;
} else {
Dialog.alert("ERROR: There was an error in processing the request!", AIM.Control.dialogOptions());
this.target.style.display = 'block'; //DEBUGGING ONLY!!!
retVal = false;
responseText = null;
}
if(responseText){
var response = eval("("+responseText+")");
if(response.result == 0){
Dialog.info("Saved Successfully", AIM.Control.dialogOptions());
if(this.redirect){
window.location.href = this.redirect;
} else {
setTimeout(function(){ Dialog.closeInfo(); }, 1000);
this.fireEvent('onSuccess');
}
retVal = true;
} else {
Dialog.alert("ERROR: "+response.errorMsg, AIM.Control.dialogOptions());
retVal = false;
}
}
} catch(e){
if(console) console.log(e);
retVal = false;
}
this.stopSaving();
if(this.callback) this.callback(retVal);
}
});
|
|
May 21, 2007
|
Topic: Windows.close() You have to do top.Windows.close(“window_id”); |
|
May 21, 2007
|
Topic: Windows.close() Hi, I’m a novice in javascript and trying to use prototype window however I encountered a problem. On the parent page (template1.php): Oh the javascript page (brochure.js): What the code should do is when you click on the image link in (media_lib.php, i.e the pop up window), the parent should load that image and the pop up window will close. On the media_lib.php, I have also included the necessary files Can anyone help? I’ve spent one whole day trying to figure out what’s wrong and no luck so far :( |