/*
* cadmo dialog plugin.
* $Id: jquery.cadmodialog.js,v 1.12 2013/02/01 17:04:26 aspinelli Exp $
* $Log: jquery.cadmodialog.js,v $
* Revision 1.12 2013/02/01 17:04:26 aspinelli
* *** empty log message ***
*
* Revision 1.11 2013/01/09 11:24:29 aspinelli
* Subtle bug of non-real fields in json
*
* Revision 1.10 2013/01/07 16:39:44 mrota
* *** empty log message ***
*
* Revision 1.9 2012/12/13 17:10:21 aspinelli
* *** empty log message ***
*
* Revision 1.8 2012/10/15 16:15:14 mrota
* *** empty log message ***
*
* Revision 1.7 2012/10/04 20:54:33 aspinelli
* Interaction with "attendere_prego" dialog
*
* Revision 1.6 2012/08/11 00:56:03 aspinelli
* *** empty log message ***
*
* Revision 1.5 2012/08/10 02:07:15 aspinelli
* Read the title from the page within the dialog
*
* Revision 1.4 2012/08/09 01:23:45 aspinelli
* avoid multiple inclusions in cadmodialog
*
* Revision 1.3 2012/08/08 00:31:23 aspinelli
* A little more horizontal space for the dialog
*
* Revision 1.2 2012/08/07 18:16:33 aspinelli
* *** empty log message ***
*
* Revision 1.1 2012/08/04 00:59:47 aspinelli
* Initial version
* dipende da:
* jquery
* ajaxform
* dialog
*/
; (function($) {
var defaultDialogParams = {
autoOpen : false,
draggable: true,
show:"fade",
hide:"fade",
modal:true,
title:"Titolo",
width:700,
zIndex: 99999,
postbackRequired:false
};
var stopPostback = function (jElement) {
jElement.find('#CADMOFORM').ajaxForm({
target: '#' + jElement.attr("id"),
success: function (responseText, statusText, xhr, $form) {
$('.CADMO_ATTENDERE#attendere_prego').dialog('close');
stopPostback(jElement);
},
error: function (obj, status, pippo, pluto) {
$('.CADMO_ATTENDERE#attendere_prego').dialog('close');
alert( $(obj.responseText).filter("span#errortext").html() );
}
});
jElement.find('#CADMOFORM').append(
'' );
jElement.find('#CADMOFORM').append(
'' );
}
$.fn.cadmodialog = function( params, value ){
var specificReturnValue = null;
this.each( function() {
if( typeof params == 'string' ) {
if( params == 'load') {
var jElement = $(this);
var dialogParams = $.data( this, 'cadmodialog' );
if( dialogParams == null ){
alert("Perdirindina, non trovo i parametri del dialog. Lascio perdere...");
return false;
}
$.ajax( value,
{
data: $.extend( {}, dialogParams.data, { _js_already_included: $('meta[name="cadmojavascriptalreadyinserted"]').attr("content"),
_css_already_included: $('meta[name="cadmocssalreadyinserted"]').attr("content")}),
success: function (data,textStatus,jqXHR){
$('.CADMO_ATTENDERE#attendere_prego').dialog('close');
jElement.html( data );
jElement.dialog({
title: $.trim(jElement.find('title').text())
});
if( dialogParams && dialogParams.postbackRequired ) {
} else {
stopPostback(jElement);
}
return false;
},
error: function (x,status,errorThrown) {
$('.CADMO_ATTENDERE#attendere_prego').dialog('close');
alert('' + status + ": " + errorThrown);
return false;
},
complete: function(jqXHR, textStatus) {
$("body").css("cursor", "auto");
if( dialogParams.complete ) {
dialogParams.complete(jqXHR, textStatus);
}
if (dialogParams.postbackRequired){
jElement.find('#CADMOFORM').unbind('submit').find('input:submit,input:image,button:submit').unbind('click');
}
}
}
);
}
} else {
var dialogParams = $.extend( {}, defaultDialogParams, params );
var jElement = $(this);
$("body").css("cursor", "progress");
jElement.dialog(dialogParams);
$.data( this, 'cadmodialog', dialogParams );
$.ajax(
dialogParams._url,
{
data: $.extend( {}, dialogParams.data, { _js_already_included: $('meta[name="cadmojavascriptalreadyinserted"]').attr("content"),
_css_already_included: $('meta[name="cadmocssalreadyinserted"]').attr("content")}),
success: function (data,textStatus,jqXHR){
$('.CADMO_ATTENDERE#attendere_prego').dialog('close');
jElement.html( data );
jElement.dialog({
title: $.trim(jElement.find('title').text())
});
jElement.dialog('open');
if( dialogParams && dialogParams.postbackRequired ) {
} else {
stopPostback(jElement);
}
return false;
},
error: function (x,status,errorThrown) {
$('.CADMO_ATTENDERE#attendere_prego').dialog('close');
alert('' + status + ": " + errorThrown);
return false;
},
complete: function(jqXHR, textStatus) {
$("body").css("cursor", "auto");
if( dialogParams.complete ) {
dialogParams.complete(jqXHR, textStatus);
}
if (dialogParams.postbackRequired){
jElement.find('#CADMOFORM').unbind('submit').find('input:submit,input:image,button:submit').unbind('click');
}
}
}
);
}
});
if( specificReturnValue ){
return specificReturnValue;
} else {
return this;
}
}
return this;
})(jQuery);