/* * Codificación UTF-8 * Eventos asociados a los campos de la pantalla * Eventos del menú de pantalla entrada */ var gvh = gvh || {}; $('[data-gvhArbolLink]').on({ click: function() { console.log($(this).attr('data-gvhArbolLink')); $(this).showLinkTree({ id: $(this).attr('id'), linkRama: $(this).attr('data-gvhArbolLink') }); } }); $('[data-gvhTypeDate=numeric]').inputmask(); $('[data-gvhTypeDate=float]').inputmask({ 'alias': 'decimal', rightAlign: true, 'groupSeparator': '.', 'radixPoint': ',', 'autoGroup': true }); /* *********************************************************************************************************************** * EVENTOS ASOCIADOS A LOS CAMBIOS EN CUALQUIER CAMPO */ // RADIO $('#gvhPage').offon( 'click', 'input[type=radio][data-gvhCWSource=cwlistaradio]', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); gvh.changeJSONField($(this)); }); // CAMPO DE TEXTO $('#gvhPage').offon( 'change', 'input[type=text][data-gvhCWSource=cwcampotexto]', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); if ($(this).attr('data-inputmask') != undefined) { gvh.semaforoChange('changeInputMask',$(this)); } else gvh.changeJSONField($(this)); }); // TEXTAREA $('#gvhPage').offon( 'change', 'textarea', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); gvh.changeJSONField($(this)); }); // SELECT $('#gvhPage').offon( 'change', 'select[data-gvhCWSource=cwlista]', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); console.log('change lista'); gvh.changeJSONField($(this)); }); // ÁREA DE TEXTO ENRIQUECIDO $('#gvhPage').offon( 'focusout', '.jqte_editor', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); gvh.changeJSONField($(this)); id = $(this).attr('id'); if ($('#l'+id).length > 0) { $('#l'+id).val($('#'+id).val()); } }); // TEXTAREA $('textarea[data-textEditor=true][data-gvhWindow='+ambito+']').each(function (index) { var id = $(this).attr('id'); $("div[id*=editor_"+id+"]").attr('contenteditable','false'); $('textarea[data-gvhposition=panel_fil]').each(function (index) { var idFil = $(this).attr('id'); $("div[id*='editor_"+idFil+"']").attr('contenteditable','true'); }) if ( ($('textarea[id*='+id+']').hasClass('noEdit') == true) || ($('textarea[id*='+id+']').hasClass('tableNoEdit') == true) ) { $('div[id=editor_'+id+']').attr('contenteditable','false'); } if (($('textarea[id*='+id+']').hasClass('modify') == true)) { $('div[id=editor_'+id+']').attr('contenteditable','true'); } }); /* *********************************************************************************************************************** * EVENTOS ASOCIADOS A LAS OPCIONES DE MENÚ DE LA PANTALLA PRINCIPAL */ $('#gvhPage').offon( 'click', 'a[data-gvhLinkMenu=true] , div.item > a', function(e) { e.stopImmediatePropagation(); var text = $(this).attr('title'); if (text.length == 0) { text = $(this).attr('data-original-title'); } gvh.loading('on',text); }); /* *********************************************************************************************************************** * EVENTOS ASOCIADOS A LOS TAB N-DETALLES */ $('#gvhPage').offon( 'click', 'a[data-gvhFunction=nDetalles]', function(e) { e.stopImmediatePropagation(); gvh.callControllerJS($(this)); }); /* *********************************************************************************************************************** * EVENTOS ASOCIADO ETIQUETA URL */ $('#gvhPage').offon( 'click', 'a[data-gvhLabel=url]', function(e) { e.stopImmediatePropagation(); if ($(this).attr('data-gvhNewWindow')) { var id = $(this).attr('id'); url = $(this).attr('data-gvhDestino'); var http = url.indexOf("http"); var ftp = url.indexOf("ftp"); if ((url != '') && (url.indexOf("http") == -1) && (url.indexOf("ftp") == -1)) { url = "http://"+url; } if (((url != '') && ((url.indexOf("http") > -1) || (url.indexOf("ftp") > -1))) && ($(this).attr('disabled') != 'disabled')) { gvh.callControllerJS($(this)); } } else { return ($(this).attr('disabled')) ? false : true; } }); /* *********************************************************************************************************************** * EVENTOS ASOCIADO check tablas */ /*$('#gvhPage').offon( 'click', 'input[id*=checkAll_][data-gvhPanelOn*=lis]', function(e) { e.stopImmediatePropagation(); panel = $(this).attr('data-gvhPanelOn'); claseM = $(this).attr('data-gvhClaseManejadora'); id = $(this).attr('id'); checked = 'false'; if ($(this).is(':checked')) checked = 'selected'; $(this).checkAll({ id: id, check: checked, panel: panel, claseM: claseM }); });*/ $('#gvhPage').offon( 'click', 'input[data-gvhFunction=checkRow]', function(e) { e.stopImmediatePropagation(); panel = $(this).attr('data-gvhPanelOn'); claseM = $(this).attr('data-gvhClaseManejadora'); id = $(this).attr('id'); row = id.split('_')[2]; claseM = $(this).attr('data-gvhClaseManejadora'); json = false; if ($(this).attr('data-gvhMD') == 'maestro') { $(this).checkUnique({ id: $(this).attr('id'), fila: row, json: true, claseManejadora: claseM, panel: $(this).attr('data-gvhPanelOn') }); action = $(this).attr('data-gvhDestino'); gvh.callControllerJS($(this)); } else { checked = 'false'; if ($(this).is(':checked')) checked = 'selected'; $(this).checkRow({ id: id, fila: row, check: checked, panel: panel, type: $(this).attr('data-gvhCheck'), claseM: claseM }); } }); $('#gvhPage').offon( 'click', 'input[type=checkbox][data-gvhCWSource=cwcheckbox]', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); console.log($(this)); var claseM = $(this).attr('data-gvhClaseManejadora'); if (claseM != '') { var panelJSON = $(this).attr('data-gvhPanelJSON'); if (panelJSON != '') { id = $(this).attr('id'); if (panelJSON != 'fil') { vId = id.split('___'); rowCheckBox = vId[2].split('_')[1]; id = vId[1]; } var raizJSON = gvh.getRoot(claseM,panelJSON); if (panelJSON == 'lis') { var indiceJSON = gvh.indexDataJSON(raizJSON,rowCheckBox); } else { var indiceJSON = gvh.getPagActive(raizJSON); } var value = gvh.getValue(raizJSON,id,indiceJSON); gvh.setValueOld(raizJSON,id,indiceJSON,value); if ($(this).is(':checked')) { valueCheck = $(this).attr('data-gvhValueCheck'); gvh.setValue(raizJSON,id,indiceJSON,valueCheck); } else { valueUnCheck = $(this).attr('data-gvhValueUnCheck'); gvh.setValue(raizJSON,id,indiceJSON,valueUnCheck); } gvh.changeJSONField($(this)); } else { console.log('¡¡¡ checkbox no tiene atributo data-gvhPanelJSON !!!'); } } else { console.log('¡¡¡ checkbox no tiene atributo data-gvhClaseManejadora !!!'); } });