Results 1 to 2 of 2

Thread: StickyBar contents showing on load of page and not on click

  1. #1
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question StickyBar contents showing on load of page and not on click

    1) Script Title: Expandable Sticky Bar

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

    3) Describe problem: Once the page is loaded the contents of the bar are visible and i have to click on the toggle to get it to hide. i would like to know what must i change in the code so i can get it to work where I have to click the toggle for the contents to show instead of them being shown since the begining. I do not know much about javascripts, im just starting to get into that part of coding in my self taught stuides on coding.

    im using jquery-1.8.2.min for my jquery lib.

    this is the code of the script with the way i've changed it to.

    Code:
    /*Expandable Sticky Bar (Initial: Nov 1st, 2010)
    * This notice must stay intact for usage 
    * Author: Dynamic Drive at http://www.dynamicdrive.com/
    * Visit http://www.dynamicdrive.com/ for full source code
    */
    
    jQuery.noConflict()
    
    function expstickybar(usersetting){
    	var setting=jQuery.extend({position:'bottom', peekamount:30, revealtype:'mouseover', speed:200}, usersetting)
    	var thisbar=this
    	var cssfixedsupport=!document.all || document.all && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //check for CSS fixed support
    if (!cssfixedsupport || window.opera || navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i))
    		return
    	jQuery(function($){ //on document.ready
    		if (setting.externalcontent){
    			thisbar.$ajaxstickydiv=$('<div id="ajaxstickydiv_'+setting.id+'"></div>').appendTo(document.body) //create blank div to house sticky bar DIV
    			thisbar.loadcontent($, setting)
    			}
    		else
    			thisbar.init($, setting)
    	})
    }
    
    expstickybar.prototype={
    
    	loadcontent:function($, setting){
    		var thisbar=this
    		var ajaxfriendlyurl=setting.externalcontent.replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/") 
    		$.ajax({
    			url: ajaxfriendlyurl, //path to external content
    			async: true,
    			error:function(ajaxrequest){
    				alert('Error fetching Ajax content.<br />Server Response: '+ajaxrequest.responseText)
    			},
    			success:function(content){
    				thisbar.$ajaxstickydiv.html(content)
    				thisbar.init($, setting)
    			}
    		})
    
    	},
    
    	showhide:function(keyword, anim){
    		var thisbar=this, $=jQuery
    		var finalpx=(keyword=="show")? 0 : -(this.height-this.setting.peekamount)
    		var positioncss=(this.setting.position=="bottom")? {bottom:finalpx} : {top:finalpx}
    		this.$stickybar.stop().animate(positioncss, (anim)? this.setting.speed : 0, function(){
    			thisbar.$indicators.each(function(){
    				var $indicator=$(this)
    				$indicator.attr('src', (thisbar.currentstate=="hide")? $indicator.attr('data-openimage') : $indicator.attr('data-closeimage'))
    			})
    		})
    		
    		thisbar.currentstate=keyword
    	},
    
    	toggle:function(){
    		var state=(this.currentstate=="show")? "hide" : "show"
    		this.showhide(state, true)
    	},
    
    	init:function($, setting){
    		var thisbar=this
    		this.$stickybar=$('#'+setting.id).css('visibility', 'visible')
    		this.height=this.$stickybar.outerHeight()
    		this.currentstate="hide"
    		setting.peekamount=Math.min(this.height, setting.peekamount)
    		this.setting=setting
    		if (setting.revealtype=="mouseover")
    			this.$stickybar.bind("mouseenter mouseleave", function(e){
    				thisbar.showhide((e.type=="mouseenter")? "show" : "hide", true)
    		})
    		this.$indicators=this.$stickybar.find('img[data-openimage]')
    //find images within bar with data-openimage attribute
    		this.$stickybar.find('a[href=#togglebar]').click(function(){
    //find links within bar with href=#togglebar and assign toggle behavior to them
    			thisbar.toggle()
    			return true
    		})
    		setTimeout(function(){
    			thisbar.height=thisbar.$stickybar.outerHeight() //refetch height of bar after 1 second (last change to properly get height of sticky bar)
    		}, 1000)
    		this.showhide("show")
    	}
    }
    
    
    /////////////Initialization code://///////////////////////////
    
    //Usage: var unqiuevar=new expstickybar(setting)
    
    var mystickybar=new expstickybar({
    	id: "stickybar", //id of sticky bar DIV
    	position:'bottom', //'top' or 'bottom'
    	revealtype:'manual', //'mouseover' or 'manual'
    	peekamount:35, //number of pixels to reveal when sticky bar is closed
    	externalcontent:'', //path to sticky bar content file on your server, or "" if content is defined inline on the page
    	speed:200 //duration of animation (in millisecs)
    })

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    The Sticky Bar does appear "contracted" initially actually, with only a portion of the bar (as dedicated by the peekamount setting) and the "+" button visible. Are you asking how to hide the bar entirely? If so how do you envision the "+" button be shown?
    DD Admin

Similar Threads

  1. Replies: 0
    Last Post: 05-31-2011, 04:04 PM
  2. Interstitial Content Box (v1.1) on click instead of onl page load?
    By cozzy1984 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 10-15-2009, 07:24 PM
  3. showing form contents when a checkbox is checked
    By thedash in forum JavaScript
    Replies: 4
    Last Post: 05-19-2009, 06:58 PM
  4. click on image on page load
    By lord22 in forum JavaScript
    Replies: 11
    Last Post: 08-03-2008, 09:05 PM
  5. Auto click link on page load
    By cameling in forum Dynamic Drive scripts help
    Replies: 7
    Last Post: 03-20-2007, 06:09 AM

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
  •