Foros del Web » Creando para Internet » CSS »

Problemas con el tooltip

Estas en el tema de Problemas con el tooltip en el foro de CSS en Foros del Web. Hola gente, A ver si alguien me puede ayudar con este tema que estoy atascado. He descargado un plugin de un tipo de tooltip que ...
  #1 (permalink)  
Antiguo 16/07/2014, 07:35
 
Fecha de Ingreso: junio-2014
Mensajes: 70
Antigüedad: 9 años, 10 meses
Puntos: 0
Problemas con el tooltip

Hola gente,

A ver si alguien me puede ayudar con este tema que estoy atascado.
He descargado un plugin de un tipo de tooltip que me interesa mucho porque hace justo lo que quiero. El problema es que los diferentes botones que aparecen tienen siempre la misma imagen, y yo quiero que cada uno de ellos tenga una imagen diferente.

Tengo algo de idea de CSS pero nada de JS y ahi es donde creo que me lio. Quite las opciones de CSS que no me interesaban, pero en el JS no me atrevi a quitar nada.

La web de donde la descargue es esta para que veais el efecto
http://ipicture.justmybit.com/index.php

Yo conseguí cambiar los botones, el texto, y hacer el hover. El fondo aunque a mi me aparezca en blanco, quiero poner una imagen de fondo, lo de ahora es temporal. Lo dicho, el problema es que no se como hace para que cada botón tenga una imagen diferente.
  #2 (permalink)  
Antiguo 16/07/2014, 07:36
 
Fecha de Ingreso: junio-2014
Mensajes: 70
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: Problemas con el tooltip

Código CSS:
Ver original
  1. #iPicture{
  2.   font-family: 'Lucida Sans Unicode','Lucida Grande',Tahoma,Arial,san-serif;
  3.     font-size: 62.5%;
  4.     color: #000000;
  5. }
  6. .more32 {
  7.     height: 55px;
  8.     overflow: hidden;
  9.     padding: 0;
  10.     position: absolute;
  11.     text-align: left;
  12.     width: 225px;
  13. }
  14.  
  15. .more32 span {
  16.     font-family: "Century Gothic", Arial;
  17.     font-size: 12px;
  18.     text-align:center;
  19.     padding: 13px 0 0 0;
  20.     position: absolute;
  21.     width: 250px;
  22. }
  23.  
  24. .ltr-slide {
  25.     width:55px;
  26.     padding: 0;
  27. }
  28. .bgblack{
  29.    background: url("../images/bg.png") repeat scroll 0 0 transparent;
  30.    border-radius: 30px 30px 30px 30px;
  31.   -moz-border-radius: 30px 30px 30px 30px;
  32.   -webkit-border-radius: 30px 30px 30px 30px;
  33. }
  34.  
  35. .bgblack span{
  36.   color: #FFFFFF;
  37.   text-shadow: 1px 1px 0 #000000;
  38. }
  39.  
  40. .imgButton{
  41.     margin: 5px 0 0 5px;
  42.   width: 45px;
  43.   height: 45px;
  44.   overflow: hidden;
  45.   float: left !important;
  46.   background: url(../../../../Dropbox/Public/Web%20Fotografia/Iconos%20Redes%20Sociales/Icono%20Email%20desmarcado.png) left top no-repeat;
  47. }
  48.  
  49. .imgButton:hover {
  50.     background-position: left bottom;
  51. }
  52.  
  53. .imgButtonDrag{
  54.   cursor: move;
  55.   width: 45px;
  56.   height: 45px;
  57.   float: left!important;
  58. }
  59.  
  60. .noborder{
  61.   border: 0;
  62.   border-radius: 0;
  63. }
  64. .inputDiv{
  65.   width:80%
  66. }
  #3 (permalink)  
Antiguo 16/07/2014, 07:39
 
Fecha de Ingreso: junio-2014
Mensajes: 70
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: Problemas con el tooltip

Código Javascript:
Ver original
  1. (function( $ ) {
  2.  
  3.   $.widget( "justmybit.iPicture", {
  4.     options: {
  5.         animation:false,
  6.         animationBg: "bgblack",
  7.         animationType:"ltr-slide",
  8.         button: "moreblack",
  9.         modify:false,
  10.         initialize: false,
  11.         moreInfos: {},
  12.         pictures: []    
  13.     },
  14.  
  15.     // Set up the widget
  16.     _create: function() {
  17.         var self = this;
  18.         if(self.options.initialize){
  19.             this.initialization();
  20.         }else{
  21.        
  22.         //each picture
  23.         $.each(self.options.pictures, function( index, value ) {
  24.             var picture = $( '#'+value );
  25.             var info = (self.options.moreInfos[value]);
  26.             if(info!=undefined){
  27.                 // each more infos on that picture
  28.                 $.each(info, function( index, value ){
  29.                     var div = $('<div id="'+value.id+'" class="more more32"></div>' )
  30.                         .css('top',value.top).css('left',value.left).appendTo(picture);
  31.                     var imgButton;
  32.                     if(self.options.modify){
  33.                       imgButton = $('<div class="imgButtonDrag '+self.options.button+'" title="drag in the picture"></div>').appendTo(div);
  34.                       var divInput = $('<div class="inputDiv"></div>').insertAfter(imgButton);
  35.                       var input = $('<input type="text" title="type here this tooltip" value="'+value.descr+'" />').appendTo(divInput);
  36.                       $('<p class="pDelete" title="delete this tooltip"></p>').insertAfter(input).bind('click', function() {
  37.                         $(div).remove();
  38.                       });
  39.                     }else{
  40.                       var imgButton = $('<div class="imgButton '+self.options.button+'"></div>').appendTo(div);
  41.                          $('<span class="descr">'+value.descr+'</span>').appendTo(div);
  42.                     }
  43.                     // href populating
  44.                     if(value.href){
  45.                         $('#'+value.id+' a').attr('href',value.href);
  46.                     }
  47.                        
  48.                     //modify option management
  49.                     if(self.options.modify){
  50.                         var descr;
  51.                         $('#'+value.id).draggable({
  52.                           //containment: picture,
  53.                         });
  54.                     }
  55.                 });
  56.             }
  57.         });
  58.         //move option management
  59.         if(self.options.modify){
  60.          
  61.         //add selected animationBg if animation set true
  62.         if(self.options.animation){
  63.           $(".more").addClass(self.options.animationBg);
  64.         }else{
  65.           $(".more").addClass('noAnimation');
  66.         }
  67.         //workaround for firefox issue on trimming border-radius content
  68.           $(".more32").css('overflow','visible');
  69.             this.initialization();
  70.             return;
  71.         }
  72.         //set animation
  73.         if (self.options.animation) {
  74.             this.animation();
  75.         }
  76.         }
  77.     },
  78.  
  79. //animation for tooltips
  80.     animation: function() {
  81.         var self = this;
  82.         switch( self.options.animationType ) {
  83.             case "ltr-slide":
  84.             $(".more").addClass('ltr-slide '+self.options.animationBg);
  85.             //Animation function left to right sliding
  86.             $(".more").hover(function(){  
  87.                 $(this).stop().animate({width: '300px' }, 200).css({'z-index' : '10'});  
  88.             }, function () {  
  89.                 $(this).stop().animate({width: '55px' }, 200).css({'z-index' : '1'});  
  90.             });
  91.             break;
  92.         }
  93.     },
  94.    
  95.     initialization: function(){
  96.         var self = this;
  97.        
  98.         $.each(self.options.pictures, function( index, value ) {
  99.             var picture = $( '#'+value );
  100.  
  101.             // list of buttons to change tooltip color
  102.             var listContainer = $('<div class="listContainer"><ul><li class="'+value+'-button '+self.options.button+'" title="drag in the picture"></li></ul><div class="bgList" title="choose another background for tooltips"></div><div class="buttonsList" title="choose another color for tooltips"></div></div>').appendTo('#'+value);
  103.             var buttonsDropp = $('<div class="buttonsDropp"></div>').insertAfter(listContainer);
  104.             $('<li id="moreblack" class="moreblack"></li>'
  105.                 +'</ul>').appendTo(buttonsDropp);
  106.             chooseButtons = $('ul.buttons').find('li');
  107.             $.each(chooseButtons, function( index, button ){
  108.                 $(button).bind('click', function(){
  109.                   $.each(self.options.pictures, function( index, pic ) {
  110.                     $('.'+pic+'-button').removeClass(self.options.button);
  111.                       $('.'+pic+'-button').addClass(button.id);
  112.                   });
  113.                     $(buttonsDropp).css('display','none');
  114.                     buttons = self.element.find('.imgButtonDrag');
  115.                     $.each(buttons, function( index, value ){
  116.                         $(value).removeClass(self.options.button);
  117.                         $(value).addClass(button.id);
  118.                     });
  119.                     self.options.button=button.id;
  120.                     clickCounter=0;
  121.                     return false;
  122.                 });
  123.                 $(button).bind('mouseover', function(){
  124.                     $(button).css('width','36');
  125.                     $(button).css('height','36');
  126.                     $(button).css('background-size','36px');
  127.                     $(button).css('z-index','10');
  128.                 });
  129.                 $(button).bind('mouseout', function(){
  130.                   $(button).css('width','32');
  131.                     $(button).css('height','36');
  132.                     $(button).css('background-size','32px');
  133.                     $(button).css('z-index','1');
  134.                 });
  135.             });
  136.             var clickCounter=0;
  137.             $('#'+value +' .buttonsList').bind('click', function(){
  138.               if(clickCounter==0){
  139.                $(buttonsDropp).css('display','block');
  140.                clickCounter=1;
  141.               }else if(clickCounter==1){
  142.                 $(buttonsDropp).css('display','none');
  143.                 clickCounter=0;
  144.               }
  145.               return false;
  146.             });
  147.        
  148.         // list of backgrounds to change tooltip background
  149.         if (self.options.animation) {
  150.           $('.listContainer').addClass(self.options.animationBg);
  151.             var bgDropp = $('<div class="bgDropp"></div>').insertAfter(listContainer);
  152.             $('<ul class="inline bg">'
  153.                 +'<li id="bgblack" class="bgblack noborder"></li>'
  154.               +'<li id="bgwhite" class="bgwhite noborder"></li>'
  155.               +'</ul>').appendTo(bgDropp);
  156.             chooseBg = $('ul.bg').find('li');
  157.             $.each(chooseBg, function( index, bg ){
  158.                 $(bg).bind('click', function(){
  159.                   $('.listContainer').removeClass(self.options.animationBg);
  160.                   $('.listContainer').addClass(bg.id);
  161.                     $(bgDropp).css('display','none');
  162.                     more = self.element.find('.more');
  163.                   $.each(more, function( index, value ){
  164.                       $(value).removeClass(self.options.animationBg);
  165.                       $(value).addClass(bg.id);
  166.                   });
  167.                     self.options.animationBg=bg.id;
  168.                  
  169.                     clickCounter2=0;
  170.                     return false;
  171.                 });
  172.                 $(bg).bind('mouseover', function(){
  173.                     $(bg).css('border','1px solid red');
  174.                     $(bg).css('z-index','10');
  175.                 });
  176.                 $(bg).bind('mouseout', function(){
  177.                   $(bg).css('border','0');
  178.                     $(bg).css('z-index','1');
  179.                 });
  180.             });
  181.             var clickCounter2=0;
  182.             $('#'+value +' .bgList').bind('click', function(){
  183.               if(clickCounter2==0){
  184.                $(bgDropp).css('display','block');
  185.                clickCounter2=1;
  186.               }else if(clickCounter2==1){
  187.                 $(bgDropp).css('display','none');
  188.                 clickCounter2=0;
  189.               }
  190.               return false;
  191.             });
  192.         } else{
  193.           $('#'+value +' .bgList').bind('click', function(){
  194.               alert('animation is off, set animation:true');
  195.             });
  196.         }
  197.            
  198.             //Create a new tooltip
  199.             $('.'+value+'-button').draggable({
  200.                 helper:'clone',
  201.                 //containment: picture,
  202.                 stop: function(event, ui){
  203.                     $('<p class="top">'+ui.position.top+'</p><p class="left">'+ui.position.left+'</p>').appendTo(this);
  204.                 }
  205.             });
  206.             var plus=0;
  207.             $('#'+value).droppable({
  208.                 accept: '.'+value+'-button',
  209.                 drop: function( event, ui ) {
  210.                     plus++;
  211.                     var div = $('<div id="'+value+'-more'+plus+'" class="'+value+' more more32"></div>' )
  212.                         .css('top',ui.position.top+"px").css('left',ui.position.left+"px").draggable(
  213.                         //{containment: picture}
  214.                         ).appendTo(picture);
  215.                     //add selected animationBg if animation set true
  216.               if(self.options.animation){
  217.                 $(".more").addClass(self.options.animationBg);
  218.               }else{
  219.                 $(".more").addClass('noAnimation');
  220.               }
  221.               //workaround for firefox issue on trimming border-radius content
  222.               $(".more32").css('overflow','visible');
  223.                     var imgButton = $('<div class="imgButtonDrag '+self.options.button+'" title="drag in the picture"></div>').appendTo(div);
  224.                     var divInput = $('<div clas="inputDiv"></div>').insertAfter(imgButton);
  225.                     var input = $('<input type="text" title="type here this tooltip"/>').appendTo(divInput).focus();
  226.                     $('<p class="pDelete" title="delete this tooltip"></p>').insertAfter(input).bind('click', function() {
  227.                       $(div).remove();
  228.                     });
  229.                 }
  230.             });
  231.         });
  232.         if(self.options.initialize){
  233.             $('<div class="buttonSave"><p>Initialization mode</p><input type="button" value="save" class="save" title="get code!"/></div>').prependTo(self.element);
  234.             $('<div class="buttonSave"><p>Initialization mode</p><input type="button" value="save" class="save" title="get code!"/></div>').appendTo(self.element);
  235.         }
  236.         if(self.options.modify){
  237.             $('<div class="buttonSave"><p>Modify mode</p><input type="button" value="save" class="save" title="get code!"/></div>').prependTo(self.element);
  238.             $('<div class="buttonSave"><p>Modify mode</p><input type="button" value="save" class="save" title="get code!"/></div>').appendTo(self.element);
  239.         }
  240.         $('#'+self.element.attr('id')+' .save').bind('click', function() {
  241.         var moreInfos = 'moreInfos:{';
  242.             //each picture
  243.         $.each(self.options.pictures, function( index, value ) {
  244.             if(index>0){
  245.                 moreInfos=moreInfos+',';
  246.             }
  247.             var picture = $( '#'+value );
  248.             var divs = $(picture).find('.more32');
  249.             moreInfos = moreInfos+'"'+value+'":[';
  250.             // each more infos on that picture
  251.             $.each(divs, function( index, value ){
  252.                 if(index>0){
  253.                     moreInfos=moreInfos+',';
  254.                 }
  255.                 descr=$(value).find('input').val();
  256.                 if(descr==undefined){
  257.                     descr="";
  258.                 }
  259.                 topPosition=$(value).css('top');
  260.                 leftPosition=$(value).css('left');
  261.                 moreInfos = moreInfos+'{"id":"'+value.id+'","descr":"'+descr+'","top":"';
  262.                 moreInfos = moreInfos+topPosition+'","left":"'+leftPosition+'"';
  263.                
  264.                 if(value.href){
  265.                     moreInfos=moreInfos+',"href":"'+$('#'+value.id+' a').attr('href')+'"';
  266.                 }
  267.                 moreInfos=moreInfos+'}';
  268.             });
  269.             moreInfos=moreInfos+']';
  270.         });
  271.         moreInfos=moreInfos+'}';
  272.         if(self.options.animation){
  273.           alert('animation: true, animationType: "'+self.options.animationType+'", animationBg: "'+self.options.animationBg+'", button: "'+self.options.button+'", '+moreInfos);
  274.         }else{
  275.           alert('animation: false, button: "'+self.options.button+'", '+moreInfos);
  276.         }
  277.         });
  278.     },
  279.    
  280.    
  281.     });
  282.  
  283. }( jQuery ) );

Etiquetas: hover, tooltip
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:54.