1$.widget("ui.jPopover", { 2 options: { 3 titulo: "Titulo", 4 posicion: "left", 5 contenedor: null, 6 botones: [], 7 _contenido: "" 8 }, 9 ocultar: function () { 10 $(this.element).popover('hide'); 11 this.destroy(); 12 }, 13 _create: function () { 14 this._Inicializar(); 15 this._AgregarBotones(); 16 $(this.element).popover('show'); 17 }, 18 _Inicializar: function () { 19 var that = this; 20 $('.onPopover').popover('hide').jPopover('destroy'); 21 // $('.onPopover').destroy(); 22 $(this.element).popover({ 23 title: '<b>' + this.options.titulo +'</b>', 24 html: true, 25 sanitize: false, 26 container: this.options.contenedor, 27 placement: function (tip, element) { 28 that._AgregarEventoBoton(tip, element); 29 $(tip).on("mouseleave mouseup",function(event) { 30 $(that.element).popover('hide'); 31 that.destroy(); 32 }); 33 return that.options.posicion; 34 }, 35 content: function () { 36 return that.options._contenido; 37 }, 38 trigger: "manual" 39 }).addClass('onPopover'); 40 if (this.options.contenedor != null) { 41 $(this.options.contenedor).on('scroll', function(event) { 42 $(that.element).popover('hide'); 43 that.destroy(); 44 }); 45 }; 46 }, 47 _AgregarBotones: function() { 48 var that = this; 49 that.options._contenido += '<div class="btn-group-vertical">'; 50 $.each(this.options.botones, function(index, boton) { 51 boton = that._ValidarBoton(boton); 52 if (boton.mostrar) 53 that.options._contenido += that._CrearBoton(boton); 54 }); 55 that.options._contenido += '</div>'; 56 }, 57 _ValidarBoton: function (boton) { 58 return $.extend(true,{ 59 nombre: "boton", 60 mostrar: true, 61 tipo: "default", 62 icono: "fa fa-asterisk", 63 etiqueta: "Botón", 64 estilo: "", 65 accion: null 66 }, boton); 67 68 }, 69 _CrearBoton: function (boton) { 70 return '<button name="' + boton.nombre + '" type="button" class="btn btn-' + boton.tipo + '" style="' + boton.estilo + '">'+ 71 '<span style="margin-right: 7px;"class="' + boton.icono + '"></span>'+ 72 '<span class="etiqueta">' + boton.etiqueta + '</span>'+ 73 '</button>'; 74 }, 75 _AgregarEventoBoton: function($tip, $element) { 76 $.each(this.options.botones, function(index, boton) { 77 $('[name="' + boton.nombre + '"]', $tip).click(function(event) { 78 if ($.isFunction(boton.accion)) 79 boton.accion.call($element); 80 }); 81 }); 82 }, 83 _AgregarEventoPopover: function($popover) { 84 var that = this; 85 $popover.mouseleave(function(event) { 86 $popover.popover('hide'); 87 that.destroy(); 88 }); 89 }, 90 destroy: function () { 91 $(this.element).removeClass('onPopover'); 92 $.Widget.prototype.destroy.apply(this, arguments); 93 } 94});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.