Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How customize content modal tooltip?
13th September, 22:29 (This post was last modified: 13th September 22:30 by mobilemike.)
Post: #1
How customize content modal tooltip?
Hi, i have used your script
JS Code
<script type="text/javascript">
$(document).ready(function()
{
   $('a[rel="modal"]:first').qtip(
   {
      content: {
         title: {
            text: 'Modal qTip',
            button: 'Chiudi'
         },
         text: 'Heres an example of a rather bizarre use for qTip... a tooltip as a <b>modal dialog</b>! ' +
               'Much like the <a href="http://onehackoranother.com/projects/jquery/boxy/">Boxy</a> plugin, ' +
               'but if you\'re already using tooltips on your page... <i>why not utilise qTip<i> as a modal dailog instead?'
      },
      position: {
         target: $(document.body), // Position it via the document body...
         corner: 'center' // ...at the center of the viewport
      },
      show: {
         when: 'mouseover', // Show it on click
         solo: true // And hide all other tooltips
      },
      hide: false,
      style: {
         width: { max: 350 },
         padding: '14px',
         border: {
            width: 9,
            radius: 9,
            color: '#666666'
         },
         name: 'light'
      },
      api: {
         beforeShow: function()
         {
            // Fade in the modal "blanket" using the defined show speed
            $('#qtip-blanket').fadeIn(this.options.show.effect.length);
         },
         beforeHide: function()
         {
            // Fade out the modal "blanket" using the defined hide speed
            $('#qtip-blanket').fadeOut(this.options.hide.effect.length);
         }
      }
   });
 
   // Create the modal backdrop on document load so all modal tooltips can use it
   $('<div id="qtip-blanket">')
      .css({
         position: 'absolute',
         top: $(document).scrollTop(), // Use document scrollTop so it's on-screen even if the window is scrolled
         left: 0,
         height: '200%', // Span the full document height...
         width: '100%', // ...and full width
 
         opacity: 0.7, // Make it slightly transparent
         backgroundColor: 'black',
         zIndex: 5000  // Make sure the zIndex is below 6000 to keep it below tooltips!
      })
      .appendTo(document.body) // Append to the document body
      .hide(); // Hide it initially
});
</script>


But this script work only for one modal tooltip... for make more modals tooltips in my page, with different contents how do? Sorry for my bad english.. i'm italian. Thanks.
Find all posts by this user
Quote this message in a reply
14th September, 12:28
Post: #2
How customize content modal tooltip?
dannythegreat, you can do this by setting un an initial settings object and supplying different content on a tip to tip basis like so:

JS Code
$(document).ready(function()
{
   // Setup a content array
   var contents = [
      'Heres an example of a rather bizarre use for qTip... a tooltip as a <b>modal dialog</b>!',
      $('#tooltipContent')
   ];
 
   // Create a common qTip configuration
   var config = {
      content: {
         title: {
            text: 'Modal qTip',
            button: 'Chiudi'
         }
      },
      position: {
         target: $(document.body), // Position it via the document body...
         corner: 'center' // ...at the center of the viewport
      },
      show: {
         when: 'mouseover', // Show it on click
         solo: true // And hide all other tooltips
      },
      hide: false,
      style: {
         width: { max: 350 },
         padding: '14px',
         border: {
            width: 9,
            radius: 9,
            color: '#666666'
         },
         name: 'light'
      },
      api: {
         beforeShow: function()
         {
            // Fade in the modal "blanket" using the defined show speed
            $('#qtip-blanket').fadeIn(this.options.show.effect.length);
         },
         beforeHide: function()
         {
            // Fade out the modal "blanket" using the defined hide speed
            $('#qtip-blanket').fadeOut(this.options.hide.effect.length);
         }
      }
   };
 
   $('a[rel="modal"]').each(function(i) // Notice the i variable
   {
      // Create a new 'config' object and add the right content from our content array
      var options = $.extend(true, {}, config, { content: contents[i] });
 
      // Create the tooltip
      $(this).qtip(options);
   })
 
   // Create the modal backdrop on document load so all modal tooltips can use it
   $('<div id="qtip-blanket">')
      .css({
         position: 'absolute',
         top: $(document).scrollTop(), // Use document scrollTop so it's on-screen even if the window is scrolled
         left: 0,
         height: '200%', // Span the full document height...
         width: '100%', // ...and full width
 
         opacity: 0.7, // Make it slightly transparent
         backgroundColor: 'black',
         zIndex: 5000  // Make sure the zIndex is below 6000 to keep it below tooltips!
      })
      .appendTo(document.body) // Append to the document body
      .hide(); // Hide it initially
});

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
14th September, 14:20
Post: #3
How customize content modal tooltip?
Thank for your reply, i have two questions..
1- How i do to insert pngfix "$(document).pngFix();" if already exist "$(document).ready(function()" in your code?
2- How i do to insert image <img src="myimage"/> into tooltip title?

Thanks.
Find all posts by this user
Quote this message in a reply
14th September, 14:37
Post: #4
How customize content modal tooltip?
You can simply add the "$(document).pngFix();" statement before the contents array:

JS Code
$(document).ready(function(){
   $(document).pngFix();
 
   var contentes= [];
   ...


And you can use a simple HTML string for the title button:

JS Code
var config = {
      content: {
         title: {
            text: 'Modal qTip',
            button: '<img src="img/chiudi.png" alt="Chiudi" />'
         }
      }

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
14th September, 16:24
Post: #5
How customize content modal tooltip?
Yes, for png fix I had tried so, but don't work.
For image in tooltip, no in modaltoptip but insert image into tooltip, how i do?
Find all posts by this user
Quote this message in a reply
14th September, 16:46
Post: #6
How customize content modal tooltip?
Hmm if you want the PNG fix applied to the tooltip also you'll have to stick the method in the onRender callback also:

JS Code
var config = {
   ...
   api: {
      onRender: function(){ $(document).pngFix(); }
   }
}


Can't make out what you're trying to ask in your second sentence, could you elaborate?

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
23rd December, 12:44
Post: #7
How customize content modal tooltip?
dannythegreat Wrote:Yes, for png fix I had tried so, but don't work.
For image in tooltip, no in modaltoptip but insert image into tooltip, how i do?
If you want to insert image as the close button for tooltip without title
JS Code
var config = {
      content: {
         title: {
            text: '',
            button: '<img src="img/chiudi.png" alt="Chiudi" />'
         }
      }


If you want just the image in the title
JS Code
var config = {
      content: {
         title: {
            text: '<img src="img/chiudi.png" alt="Chiudi" />'
         }
      }
Find all posts by this user
Quote this message in a reply
25th December, 16:49 (This post was last modified: 25th December 16:53 by Spoonless Eddie.)
Post: #8
RE: How customize content modal tooltip?
Man, I cannot BELIEVE how easy this was. This is exactly what I've been looking for. I didn't know I could do this.

" button: '<img src="(path)" title="Close on click" />' "

This makes my day.
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] Take tooltip content from the element attributes AndyG 17 16,041 31st January 07:14
Last Post: eggpoker
  [Solved] Using Complex HTML as Tooltip Content sylvia 1 2,378 3rd November 02:07
Last Post: Craig
  close modal dialog from inside the content siriusblack 3 2,490 21st April 17:57
Last Post: Craig
  Accessing cloned tooltip content root66 2 1,396 29th June 16:23
Last Post: Craig



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