Results 1 to 6 of 6

Thread: Sticky Tooltip for Ipad

  1. #1
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Sticky Tooltip for Ipad

    Hello!

    http://www.dynamicdrive.com/dynamici...ckytooltip.htm

    I love this simple and great tooltip.
    I would to make this sticky tooltip responsive to ipad, iphone and Android.
    For example, "mouseenter" event will be changed "click" or "touchstart" event, if we access by the touch device.

    I would really appreciate someone's help and advice.

    Thank you!
    mimi
    Last edited by mimi; 09-19-2012 at 02:50 PM.

  2. #2
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format when asking a question.
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  3. The Following User Says Thank You to bernie1227 For This Useful Post:

    mimi (09-19-2012)

  4. #3
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Hi Bernie,

    Thank you for pointing that out.

    mimi

  5. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    /* Sticky Tooltip script (v1.0)
    * Created: Nov 25th, 2009. This notice must stay intact for usage
    * Author: Dynamic Drive at http://www.dynamicdrive.com/
    * Visit http://www.dynamicdrive.com/ for full source code
    */
    
    
    var stickytooltip={
    	tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    	fadeinspeed: 200, //duration of fade effect in milliseconds
    	rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    	stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    	stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    	stickynotice2: "Click outside this box to hide it", //customize tooltip status message
    
    	//***** NO NEED TO EDIT BEYOND HERE
    
    	isdocked: false,
    
    	positiontooltip:function($, $tooltip, e){
    		var x=e.pageX+this.tooltipoffsets[0], y=e.pageY+this.tooltipoffsets[1]
    		var tipw=$tooltip.outerWidth(), tiph=$tooltip.outerHeight(),
    		x=(x+tipw>$(document).scrollLeft()+$(window).width())? x-tipw-(stickytooltip.tooltipoffsets[0]*2) : x
    		y=(y+tiph>$(document).scrollTop()+$(window).height())? $(document).scrollTop()+$(window).height()-tiph-10 : y
    		$tooltip.css({left:x, top:y})
    	},
    
    	showbox:function($, $tooltip, e){
    		$tooltip.fadeIn(this.fadeinspeed)
    		this.positiontooltip($, $tooltip, e)
    	},
    
    	hidebox:function($, $tooltip){
    		if (!this.isdocked){
    			$tooltip.stop(false, true).hide()
    			$tooltip.css({borderColor:'black'}).find('.stickystatus:eq(0)').css({background:this.stickybordercolors[0]}).html(this.stickynotice1)
    		}
    	},
    
    	docktooltip:function($, $tooltip, e){
    		this.isdocked=true
    		$tooltip.css({borderColor:'darkred'}).find('.stickystatus:eq(0)').css({background:this.stickybordercolors[1]}).html(this.stickynotice2)
    	},
    
    
    	init:function(targetselector, tipid){
        	jQuery(document).ready(function($){
    			var $targets=$(targetselector)
    			var $tooltip=$('#'+tipid).appendTo(document.body)
    			if ($targets.length==0)
    				return
    			var $alltips=$tooltip.find('div.atip')
    			if (!stickytooltip.rightclickstick)
    				stickytooltip.stickynotice1[1]=''
    			stickytooltip.stickynotice1=stickytooltip.stickynotice1.join(' ')
    			stickytooltip.hidebox($, $tooltip)
    			$targets.bind('mouseenter', function(e){
     //				$alltips.hide().filter('#'+$(this).attr('data-tooltip')).show()
     //				stickytooltip.showbox($, $tooltip, e)
    			})
    			$targets.bind('mouseleave', function(e){
     //				stickytooltip.hidebox($, $tooltip)
    			})
    			$targets.bind('mousemove', function(e){
     				$alltips.hide().filter('#'+$(this).attr('data-tooltip')).show()
    				stickytooltip.showbox($, $tooltip, e)
    		    	if (!stickytooltip.isdocked){
    					stickytooltip.positiontooltip($, $tooltip, e)
    				}
    			})
    			$tooltip.bind("mouseenter", function(){
    				stickytooltip.hidebox($, $tooltip)
    			})
    			$tooltip.bind("click", function(e){
    				e.stopPropagation()
    			})
    			$(this).bind("click", function(e){
    				if (e.button==0){
    					stickytooltip.isdocked=false
    					stickytooltip.hidebox($, $tooltip)
    				}
    			})
    			$(this).bind("contextmenu", function(e){
    				if (stickytooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length==1){ //if oncontextmenu over a target element
    					stickytooltip.docktooltip($, $tooltip, e)
    					return false
    				}
    			})
    			$(this).bind('keypress', function(e){
    				var keyunicode=e.charCode || e.keyCode
    				if (keyunicode==115){ //if "s" key was pressed
    					stickytooltip.docktooltip($, $tooltip, e)
    				}
    			})
    		}) //end dom ready
    	}
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  6. The Following User Says Thank You to vwphillips For This Useful Post:

    mimi (09-19-2012)

  7. #5
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks! but it doesn't work:'(

  8. #6
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Hiya Mina,
    With the version on the dynamic drive page, on an iPad, it displays the same functionality that you are describing. For example, both Thailand and British columbia's tooltips appear when the links clicked on and diissapears when clicked away, however the one with the lank, Japan, does not work. Try looking example script for where those two links are and attempt to imitate that.
    Thanks,
    Bernie
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

Similar Threads

  1. sticky tooltip
    By oferke in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 09-18-2012, 05:41 PM
  2. Expandable Sticky Bar on iPad
    By symbiose in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 04-27-2011, 04:10 PM
  3. Sticky Tooltip script - not sticky
    By jscheuer1 in forum Bug reports
    Replies: 0
    Last Post: 11-09-2010, 03:01 PM
  4. Replies: 1
    Last Post: 08-17-2010, 10:25 AM
  5. Sticky Tooltip
    By dark_s in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 01-16-2010, 02:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •