Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Google Calendar style bubble
8th May, 19:13
Post: #1
Google Calendar style bubble
Hi,

i've like to create a tooltip for a calendar that functions like that of the Google calendar.

[list=*]
[*]Load content from hidden div or span
Open on click
Close button and close on click outside tip
Not to exceed the current pages width[/*]
[/list]

If this can't be done with qTip can it be done with any others?

Thanks.
Find all posts by this user
Quote this message in a reply
8th May, 20:29
Post: #2
Google Calendar style bubble
This can indeed be done with qTip. Try out this little code snippet:

JS Code
$('.elementToGiveTooltip').qtip(
{
   content: {
      text: $('.elementWithTheContent'),
      title: {
         text: 'Title for the tooltip, or blank... either will do!',
         button: 'x' // can put an <img /> tag or any other valid HTML in here. Clicking it closes the tooltip.
      }
   },
   position: {
      corner: {
         tooltip: 'bottomLeft', // Display at the top right hand corner like Google Calendar
         target: 'topRight'
      },
      adjust: {
         screen: true // Keep the tooltip within the viewport at all times
      }
   },
   show: 'click',
   hide: 'unfocus', // Close the tooltip when it loses focus e.g. anywhere except the tooltip is clicked
   style: {
      background: 'white',
      border: {
         color: '#ABABAB', // Grey style border
         radius: 5 // Give it some rounded corners (Note 1px rounded borders aren't supported at the moment)
      },
      tip: true // Give it a speech bubble tip (corner is automatically detected)
   }
});

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
9th May, 17:30 (This post was last modified: 10th May 06:57 by berko.)
Post: #3
Google Calendar style bubble
Excellent! Just what i was after!

One problem I have though (pardon my ignorance) is how to I get it to only display the hidden content associated with the link you click on?

So basically if there are lots of events on the calendar and each has it's own info, how do i show only the info of only the event that was clicking? At the moment is shows all content wrapped in the "event_bubble" class.

My markup goes like this....

JS Code
<div class="cal_event">
<div class="event_bubble"><p>Info to be displayed in bubble when event link is clicked</p></div>
<p><a href="#" class="event" title="Event Title">My Event</a></p>
</div>
 
<div class="cal_event">
<div class="event_bubble"><p>Info to be displayed in bubble when event link is clicked</p></div>
<p><a href="#" class="event" title="Event Title 2">My Event 2</a></p>
</div>


Also can I make the title of the tooltip the same as the title of the link or the same as a h4 inside the "event_bubble" class?

Thanks for your help.
Find all posts by this user
Quote this message in a reply
9th May, 23:57
Post: #4
Google Calendar style bubble
Sure. Try this code out:

JS Code
$('a.event').each(function()
{
$(this).qtip(
{
   content: {
      text: $(this).prev('.event_bubble'), // Find the event bubble element located BEFORE the link on the page
      title: {
         text: $(this).attr('title'), // Use the link title
         button: 'x' // can put an <img /> tag or any other valid HTML in here. Clicking it closes the tooltip.
      }
   },
   position: {
      corner: {
         tooltip: 'bottomLeft', // Display at the top right hand corner like Google Calendar
         target: 'topRight'
      },
      adjust: {
         screen: true // Keep the tooltip within the viewport at all times
      }
   },
   show: 'click',
   hide: 'unfocus', // Close the tooltip when it loses focus e.g. anywhere except the tooltip is clicked
   style: {
      background: 'white',
      border: {
         color: '#ABABAB', // Grey style border
         radius: 5 // Give it some rounded corners (Note 1px rounded borders aren't supported at the moment)
      },
      tip: true // Give it a speech bubble tip (corner is automatically detected)
   }
});
});

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
10th May, 06:56 (This post was last modified: 10th May 06:56 by berko.)
Post: #5
Google Calendar style bubble
Thanks for your patience. I'm almost there!

If the "event" link is wrapped in a p tag it doesn't pick-up the event bubble.

JS Code
<div class="event_bubble"><p>Info to be displayed in bubble when event link is clicked</p></div>
<p><a href="#" class="event" title="Event Title">My Event</a></p>


Also how can i hide the .event_bubble content until the link is clicked? I tried setting "display: none;" in the CSS but that stops it from being displayed even when clicked.

Thanks again for your help. Wink
Find all posts by this user
Quote this message in a reply
10th May, 07:03
Post: #6
Google Calendar style bubble
I fixed the issue with hiding the content with the following CSS

JS Code
.event_bubble {
display: none;
}
 
.qtip-content .event_bubble {
display: block;
}


But I still have the problem of the tooltip not working if link is wrapped in a p tag.
Find all posts by this user
Quote this message in a reply
10th May, 23:40
Post: #7
Google Calendar style bubble
It isn't picking up the element because its basically searching for sibling elements within the p element for your event bubble content. Try this code out instead, which should also fix the display problem you're facing (remove the display: none in your CSS):

JS Code
$('a.event').each(function()
{
$(this).qtip(
{
   content: {
      text: $(this).parent('p').prev('.event_bubble').remove(), // Find the event bubble element located BEFORE the link on the page
      title: {
         text: $(this).attr('title'), // Use the link title
         button: 'x' // can put an <img /> tag or any other valid HTML in here. Clicking it closes the tooltip.
      }
   },
   position: {
      corner: {
         tooltip: 'bottomLeft', // Display at the top right hand corner like Google Calendar
         target: 'topRight'
      },
      adjust: {
         screen: true // Keep the tooltip within the viewport at all times
      }
   },
   show: 'click',
   hide: 'unfocus', // Close the tooltip when it loses focus e.g. anywhere except the tooltip is clicked
   style: {
      background: 'white',
      border: {
         color: '#ABABAB', // Grey style border
         radius: 5 // Give it some rounded corners (Note 1px rounded borders aren't supported at the moment)
      },
      tip: true // Give it a speech bubble tip (corner is automatically detected)
   }
});
});

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] IE 8 "Style > Tip" not displaying shameless hacker 30 8,905 9th February 18:49
Last Post: nickast
  Google Calendar like bubble for Jquery FullCalendar tdmohr 13 12,947 18th October 07:22
Last Post: jokepondy
  How to style/theme tooltip? petiar 3 954 26th June 12:37
Last Post: Craig
  [Solved] Style font-size verlager 2 1,326 30th March 04:01
Last Post: verlager
  [Solved] My style and position hizard 3 809 13th January 16:47
Last Post: Craig
  [Solved] qtip off in firefox and google chrome mickey 9 2,494 29th December 17:51
Last Post: Craig
  Safari CSS Style not showing inside qtip tonyabra 1 1,672 20th December 19:34
Last Post: Craig
  Style Title not working for font-size and font-family ForgotMyOrange 2 1,972 19th December 21:50
Last Post: ForgotMyOrange
  Google Chrome Error: Uncaught TypeError nrml 1 1,853 6th December 03:32
Last Post: Craig
  [Solved] Changing content font-style. acuariano91 3 931 3rd November 20:49
Last Post: Craig



User(s) browsing this thread: 1 Guest(s)