Results 1 to 5 of 5

Thread: Sticky note v2.0 hide automatically after showing manual by clicking link

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

    Default Sticky note v2.0 hide automatically after showing manual by clicking link

    1) Script Title: Sticky Note script v2.0

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...stickynote.htm

    3) Describe problem:

    Is there a chance to let the note disappear after x seconds after having activated it manually by clicking a link (as it does when it's called via new stickynote fct)? As this activation works with the showhidenote function I don't know how to put the hidebox possibility in there.

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

    Default

    requires a new function and minor change

    Code:
    	delayshowhide:function(action,ms){
         var oop=this;
         clearTimeout(oop.to);
         if(typeof(ms)=='number'&&(action=="show"||action=="hide")){
          oop.to=setTimeout(function(){ oop.showhidenote(action); },ms);
         }
        },
    
    	showhidenote:function(action, callback){
            clearTimeout(this.to);
    		var $=jQuery
    		var thisobj=this
    		if (action=="show"){
    			this.$note.css('zIndex', stickynote.startingzindex++)
    			this.positionnote($, this.s.pos[0], this.s.pos[1])
    			if (this.s.fixed){
    				$(window).bind(this.reposevtstring, function(){thisobj.positionnote(jQuery, thisobj.s.pos[0], thisobj.s.pos[1])})
    			}
    			this.$note.fadeIn(this.s.fade? 500 : 0, function(){
    				thisobj.positionnote($, thisobj.s.pos[0], thisobj.s.pos[1])
    				if (typeof callback=="function")
    					callback()
    				if (document.all && this.style && this.style.removeAttribute)
    					this.style.removeAttribute('filter') //fix IE clearType problem
    			})
    		}
    		else if (action=="hide"){
    			this.$note.hide()
    			if (this.s.fixed){
    				$(window).unbind(this.reposevtstring)
    			}
    		}
    	},
    then use

    Code:
    <a href="#" onClick="mysticky.delayshowhide('show',2000);return false">Show Box 1</a>
    <a href="#" onClick="mysticky.delayshowhide('hide',2000);return false">Hide Box 1</a>
    where 2000 is the delay
    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/

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

    Default

    Thanks Vic, the script works, but I don't nee a delay for opening but an automatic hiding after 20 seconds when I opened the note by clicking a link.

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

    Default

    new function

    Code:
    	hideafter:function(ms){
         var oop=this;
         clearTimeout(oop.to);
         oop.showhidenote('show');
         if(typeof(ms)=='number'){
          oop.to=setTimeout(function(){ oop.showhidenote('hide'); },ms);
         }
        },
    modify function

    Code:
    	init:function($, setting){
    		var thisobj=this
    		this.$note=$('#'+setting.content.divid)
    		if (this.s.fixed && this.cssfixedsupport){
    			this.$note.css({position:'fixed'})
    		}
    		this.$note.css({visibility:'visible', display:'none'})
    		var showfrequency=this.s.showfrequency
    		var randomnumber=Math.floor(Math.random()*showfrequency)
    		if ((showfrequency=="session" && !stickynote.routines.getCookie(this.s.divid+"_persist")) || showfrequency=="always" || (!isNaN(randomnumber) && randomnumber==0)){
    			if (showfrequency=="session")
    				stickynote.routines.setCookie(this.s.divid+"_persist", 1)
    			this.showhidenote("show", this.s.hidebox>0? function(){thisobj.to=setTimeout(function(){thisobj.showhidenote("hide")}, thisobj.s.hidebox*1000)} : null)
    		}
    	}

    link

    Code:
    <a href="#" onClick="mysticky.hideafter(20000);return false">Hide Box After 20 seconds</a>
    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/

  5. #5
    Join Date
    Sep 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks Vic, this works absolutely perfect!
    Cheers, Chuck

Similar Threads

  1. Sticky Note showing up behind flash object
    By Seannal in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 07-13-2010, 08:16 AM
  2. Sticky Note Script as link mouseover
    By ianp in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 07-07-2009, 02:38 AM
  3. Sticky Note - Please Help =)
    By Seannal in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-27-2007, 06:14 PM
  4. Sticky Note - More than 1
    By kitten2781 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 04-06-2007, 05:40 PM
  5. Replies: 0
    Last Post: 09-04-2005, 11:57 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
  •