';
contenido += '
';
contenido += '';
contenido += '
';
if (defaults.message == '')
message = desescapeIGEPjs(msgLoad);
else
message = desescapeIGEPjs(defaults.message);
contenido += '
'+message+'';
contenido += '
';
$('#load').html(contenido);
}
}
else
{
$('#load-cover').hide();
$('#load').hide();
$('#load-cover').remove();
$('#load').remove();
}
}
/*
* formActionSubmit()
* FUNCIÓN: submit del formulario. 3 opciones: Nueva ventana / Con mensaje de confirmación / submit directo
* PARAMS: id - del botón para el que se van a activar los campos
* prefijo - si los campos se activan para inserción o modificación ('ins'/'cam')
* css - estilo que se le aplicará al campo
* panel - panel donde se encuentran los campos
*/
$.fn.formActionSubmit = function(options)
{
var defaults = $.extend({
id: '',
panel: '',
destino: '',
newWindow: 'false',
target: "oculto",
confirm: '',
claseM: ''
},options);
formulario = "F_"+defaults.panel;
if (defaults.newWindow == 'true')
{
$('#'+defaults.id).popupWindow({
windowURL: '',
centerScreen: 1,
scrollbars: 1,
height: '600',
width: '900',
windowName:'newWindow'
});
$('#'+formulario).prop("target",'newWindow');
}
else if (defaults.confirm != '')
{
//$datos = defaults.confirm.split('/');
$datos = defaults.confirm.split('___');
$(this).showConfirm({
id: $(this).attr('id'),
codigo: $datos[0],
descBreve: desescapeIGEPjs($datos[1]),
text: desescapeIGEPjs($datos[2]),
btnOk: desescapeIGEPjs($datos[3]),
btnCancel: desescapeIGEPjs($datos[4]),
destino: defaults.destino,
claseM: defaults.claseM
})
}
else
{
if (defaults.panel != 'fil')
{
$(this).formSendJSON({
id: defaults.id,
destino: defaults.destino,
panelDestino: defaults.panel,
claseM: defaults.claseM
})
}
else {
/*destinoOriginal = $('#'+formulario).attr("action");
targetOriginal = $('#'+formulario).attr("target");*/
if (defaults.destino != '')
{
$('#'+formulario).prop("action",defaults.destino);
$('#'+formulario).prop("target","oculto");
$('#'+formulario).submit();
}
else
{
$('#'+formulario).submit();
}
}
}
};
/*
* formSendJSON()
* FUNCIÓN: inserción pasando por negocio // botón particular
* USO: inserción desde búsqueda
* inserción en patrón Tabular-Registro
* inserción con preNuevo()
* botón acción particular
* PARAMS: id - del BOTÓN tooltip
* destino - action del formulario
*/
$.fn.formSendJSON = function(options)
{
var defaults = $.extend({
id: '',
destino: '',
panelDestino: 'edi',
claseM: ''
},options);
panelJSON = defaults.panelDestino;
if (defaults.panelDestino == 'lisDetalle')
panelJSON = 'lis';
else if (defaults.panelDestino == 'ediDetalle')
panelJSON = 'edi';
raizJSON = datosJSON[defaults.claseM][panelJSON];
if (defaults.destino != '')
{
if ((raizJSON == null) || (raizJSON['gvhJSON'] == 'false'))
{
$('#'+defaults.id).loading();
$('#'+defaults.id).closest('form').prop("action",defaults.destino);
$('#'+defaults.id).closest('form').prop("target", "oculto");
$('#'+defaults.id).closest('form').submit();
}
else
{
claseM = defaults.claseM;
action = defaults.destino;
$.ajax({
data: datosJSON,
type: "POST",
datatype: "json",
url: action+"&gvhcache=true&claseManejadora="+claseM+"&gvhpanel="+panelJSON,
beforeSend: function() {
$(this).loading();
},
success: function(response) {
console.log('response');//console.log(response);
console.log('stringfigy ');console.log(decodeURIComponent(response));
window.location.href = decodeURIComponent(jQuery.parseJSON(response));
},
fail: function() {
alert('fail');
},
complete: function() {
$('div[id=loading]').hide();
}
})
}
}
};
/*
* FUNCIÓN: Abrir una ventana flotante
*/
$.openWindow = function(options)
{
var defaults = $.extend({
windowURL: 'igep/blanco.htm',
w: '700',
h: '500',
nameWindow: 'nWindow'
},options);
LeftPosition = (screen.width) ? (screen.width-defaults.w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-defaults.h)/2 : 0;
//settings = 'top='+TopPosition+',left='+LeftPosition+',toolbar='+toolbar+',location='+location+',status='+status+',menubar='+menubar+',scrollbars=yes,resizable='+resizable+',width='+w+',height='+h;
settings = 'top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+defaults.w+',height='+defaults.h;
//Si firefox o Mozilla eliminamos todas las barras, la hacemos modal,dependiente y que flote sobre el resto
if (navigator.appCodeName =='Mozilla')
settings = settings+',directories=no,personalbar=no,minimizable=no,alwaysRaised=yes,modal=yes,dependent=yes';
win = window.open(defaults.windowURL,defaults.nameWindow,settings);
win.focus();
}
/*
* popupWindow()
* FUNCIÓN: Abrir una ventana emergente como respuesta a evento sobre el DOM
*/
$.fn.popupWindow = function(instanceSettings)
{
$.fn.popupWindow.defaultSettings = {
centerBrowser:0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left
centerScreen:0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left
height:500, // sets the height in pixels of the window.
left:0, // left position when the window appears.
location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
width:500, // sets the width in pixels of the window.
windowName:null, // name of window set from the name attribute of the element that invokes the click
windowURL:null, // url used for the popup
top:0, // top position when the window appears.
toolbar:0 // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
};
$(this).loading({
modo: 'off'
});
settings = $.extend({}, $.fn.popupWindow.defaultSettings, instanceSettings || {});
var windowFeatures = 'height=' + settings.height +
',width=' + settings.width +
',toolbar=' + settings.toolbar +
',scrollbars=' + settings.scrollbars +
',status=' + settings.status +
',resizable=' + settings.resizable +
',location=' + settings.location +
',menuBar=' + settings.menubar;
settings.windowName = this.name || settings.windowName;
settings.windowURL = this.href || settings.windowURL;
var centeredY,centeredX;
if(settings.centerBrowser)
{
if ($.browser.msie)
{//hacked together for IE browsers
centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
}
else
{
centeredY = window.screenY + (((window.outerHeight/2) - (settings.height/2)));
centeredX = window.screenX + (((window.outerWidth/2) - (settings.width/2)));
}
window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
}
else if(settings.centerScreen)
{
centeredY = (screen.height - settings.height)/2;
centeredX = (screen.width - settings.width)/2;
window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
}
else
{
window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top).focus();
}
return false;
};
/*
* createTree()
* FUNCIÓN: Crea un árbol jquery con el plugin jstree
* PARAMS: idTree - del BOTÓN para el que se van a activar los campos
* node -
*/
$.fn.createTree = function(options)
{
var defaults = $.extend({
idTree: '',
node: '',
multiple: 'false',
url: '',
claseM: '',
destino: '',
actualizaA: '',
idForm: ''
},options);
console.log(defaults.idTree);
if (defaults.multiple == "true")
multiple = true;
else
multiple = false;
// Comprobar si existe la variable datosJSON
raizJSON = datosJSON[defaults.claseM][defaults.panel];
var data = [];
if (raizJSON['gvhJSON'] == 'false')
{
data = JSON.stringify($("#"+defaults.idForm).serialize());
url = defaults.url;
}
else {
data = datosJSON;
//url = "phrame.php?action="+claseManejadora+"__"+destino+"&gvhcache=true&claseManejadora="+claseManejadora+"&gvhpanel="+panel;
url = defaults.url+"&gvhcache=true&claseManejadora="+defaults.claseM+"&gvhpanel="+defaults.panel;
}
console.log(data);
$('#'+defaults.idTree).jstree({
"types" : {
"default" : {
"icon" : "glyphicon glyphicon-flash"
},
"root" : {
"icon" : "fa fa-chevron-down"
},
"users" : {
"icon" : "fa fa-users"
},
"volley" : {
"icon" : "fa fa-anchor"
},
"ciclismo" : {
"icon" : "fa fa-bicycle"
},
"child" : {
"icon" : "fa fa-child"
}
},
"core" : {
"multiple": multiple,
"checkbox": true,
"ajax": true,
"worker": true,
"data": {
"url": url,
//"url": "phrame.php?action=TreeSelector__treeAjax",
"data": function(data) {
console.log('data '+data);
//json = node;
return data;//{ "id" : node.id, "nodo": node };
},
"success": function (node) {
console.log('success '+node);
},
/*'data': function(node) {
console.log('getJSONData '+node);
json = node;
return { "id" : node.id, "nodo": node };
}*/
"search": {
"case_insensitive": true,
"ajax" : {
"url": "phrame.php?action=TreeSelector__treeAjax&value=search",
'dataType': 'json',
'type': 'POST',
"data": function (node) {
console.log('search '+node.id)
return { "id": node.id };
}
}
},
},
"themes": {
'name': 'proton',
'responsive': true
},
},
/*"changed": function (e, data) {
console.log("Nodo seleccionado:");
selectedNodes = data.selected;
if (selectedNodes.length > 0)
{
$.each(selectedNodes, function( index, value ) {
console.log(value.id+' '+value.text);
});
}
else {
console.log('no hay seleccionados');
}
},
"search": {
"case_insensitive": true,
"ajax" : {
"url": "phrame.php?action=TreeSelector__treeAjax&value=search",
'dataType': 'json',
'type': 'POST',
"data": function (node) {
console.log('search '+node.id)
return { "id": node.id };
}
}
},*/
"plugins" : [ "types", "wholerow", "search", "themes", "html_data", "checkbox", "sort", "ui" ]
});
}
})(jQuery);
/* ***********************************************
* INICIALIZACIÓ“N DE COLUMNAS RESIZABLES AL INICIO
*************************************************/
/*var i=0;
$("table[id*=tablePanel_]").each(function() {
colResizable = $(this).attr('data-gvhcolresizable');
if (colResizable == 'true')
{
$(this).colResizable({
liveDrag:true,
gripInnerHtml:"