var MEDialogs = {
alertDialog: null,
closealertDialog: function()
{
if (this.alertDialog)
if (this.alertDialog._wrapper)
this.alertDialog.close();
},
alert: function(content,donemsg)
{
this.closeDialogs();
this.alertDialog = new Dialog(
{
width:300,
parent: document.getElementById("cuadroMapa"),
title: '
',
content: content,
buttons:
{
button1:
{
title : donemsg,
'action': Dialog.prototype.close
}
}
});
this.alertDialog.content.innerHTML = content;
this.alertDialog.open();
},
closeDialogs: function()
{
this.closecenteredMessage();
this.closeupperLeftMessage();
this.closeMailForm();
this.closeTextForm();
this.closealertDialog();
},
centeredMessageDialog: null,
closecenteredMessage: function()
{
if (this.centeredMessageDialog)
if (this.centeredMessageDialog._wrapper)
this.centeredMessageDialog.close();
},
centeredMessage: function(msg,img)
{
this.closeDialogs();
this.centeredMessageDialog = new Dialog(
{
notbuttons:true,
width:160,
parent: document.getElementById("cuadroMapa"),
title: ' | ' + msg + ' |
',
content: ''
});
this.centeredMessageDialog.header.style.backgroundImage = 'none';
},
upperLeftDialog: null,
closeupperLeftMessage: function()
{
if (this.upperLeftDialog)
if (this.upperLeftDialog._wrapper)
this.upperLeftDialog.close();
},
upperLeftMessage: function(msg)
{
this.closeDialogs();
this.upperLeftDialog = new Dialog(
{
notcentered:true,
notbuttons:true,
top:40,
left:20,
width:300,
parent: document.getElementById("cuadroMapa"),
title: msg,
content: ''
});
this.upperLeftDialog.header.style.backgroundImage = 'none';
},
mailDialog: null,
closeMailForm: function()
{
if (this.mailDialog)
if (this.mailDialog._wrapper)
this.mailDialog.close();
},
openMailForm: function(params)
{
this.closeDialogs();
this.mailDialog = new Dialog({
mailparams: params,
parent: document.getElementById("cuadroMapa"),
title: params.mailtitle,
content: '' + params.mailfrom + ':
' + params.mailto + ':
',
buttons:
{
button1:
{
title : params.mailsendbutton,
'action' : function()
{
var mail_from = this.trimAll($('#mail-from').val());
var mail_to = this.trimAll($('#mail-to').val());
var mail_text = this.trimAll($('#mail-text').val());
if (!this.isValidEmail(mail_from))
{
alert(this.options.mailparams.mailwrong.mp_replaceAll('?',this.options.mailparams.mailfrom));
return;
}
if (!this.isValidEmail(mail_to))
{
alert(this.options.mailparams.mailwrong.mp_replaceAll('?',this.options.mailparams.mailto));
return;
}
if (mail_text == '')
{
alert(this.options.mailparams.mailvoid);
return;
}
this.header.style.backgroundImage = 'none';
this.content.innerHTML = '
' + this.options.mailparams.mailwaitmsg + '';
this.actions.innerHTML = '';
this.updateContent();
var param = "mail_from=" + mail_from +
"&mail_to=" + mail_to +
"&mail_text=" + mail_text +
"&urlImage=" + getMapImage(this.options.mailparams.imagewidth,this.options.mailparams.imageheight).mp_replaceAll('&','') +
"&map_width=" + this.options.mailparams.imagewidth +
"&map_height=" + this.options.mailparams.imageheight;
$.ajax(
{
type: "POST",
url: "web/SendMailMap",
data: param,
error: function()
{
alert('Error loading document');
},
success: function(msg)
{
MEDialogs.mailDone(msg,mail_to);
}
});
}
}
,
button2:
{
title : params.mailcancelbutton,
'action': Dialog.prototype.close
}
}
});
},
mailDone: function(msg,email)
{
var d = this.mailDialog;
d.header.style.backgroundImage = 'none';
d.content.innerHTML = (msg.indexOf('Error') != -1) ? msg : d.options.mailparams.maildonemsg + ' ' + email;
d.addButtons({button1:{title : d.options.mailparams.donebutton,'action': Dialog.prototype.close}});
d.updateContent();
},
textDialog: null,
closeTextForm: function()
{
if (this.textDialog)
if (this.textDialog._wrapper)
this.textDialog.close();
},
openTextForm: function(params)
{
this.closeDialogs();
var selectline;
if (params.textarray.length > 0)
{
selectline = '';
}
else
selectline = "";
this.textDialog = new Dialog({
textparams: params,
parent: document.getElementById("cuadroMapa"),
title: params.texttitle,
content: '' +
'' + selectline,
buttons:
{
button1:
{
title : params.textinsertbutton,
'action' : function()
{
var text = this.trimAll($('#text-text').val());
if (text == '')
{
alert(this.options.textparams.textvoid);
return;
}
this.close();
this.options.textparams.textinsertfunction(text.mp_replaceAll('\n','
'));
}
},
button2:
{
title : params.textcancelbutton,
'action': Dialog.prototype.close
}
}
});
var text_delete = $("#text-delete")[0];
if (text_delete)
bindEventHandler(text_delete, 'click', this.textDialog._makeHandler(
function()
{
var value = $("#text-select").val();
if (parseInt(value) != -1)
{
this.textDialog.options.textparams.textremovefunction(value);
this.textDialog.close();
}
},
this));
var text_center = $("#text-center")[0];
if (text_center)
bindEventHandler(text_center, 'click', this.textDialog._makeHandler(
function()
{
var value = $("#text-select").val();
if (parseInt(value) != -1)
{
this.textDialog.options.textparams.textcenterfunction(value);
this.textDialog.close();
}
},
this));
var text_select = $("#text-select")[0];
if (text_select)
bindEventHandler(text_select, 'change', this.textDialog._makeHandler(
function()
{
var value = $("#text-select").val();
var text_center = $("#text-center");
var text_delete = $("#text-delete");
if (parseInt(value) == -1)
{
if (text_center)
text_center.hide();
if (text_delete)
text_delete.hide();
}
else
{
if (text_center)
text_center.show();
if (text_delete)
text_delete.show();
}
},
this));
}
};