Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Modify jkpanel source code (help needed)

    jkpanel: http://javascriptkit.com/script/scri...ownpanel.shtml

    On initialization, jkpanel loads an external file.
    But I want to paste html elements directly in the source code, so it can initialize without making an extra http request.

    Here's the source code
    var jkpanel={
    controltext: 'Panel Content',
    $mainpanel: null, contentdivheight: 0,

    openclose:function($, speed){
    this.$mainpanel.stop() //stop any animation
    if (this.$mainpanel.attr('openstate')=='closed')
    this.$mainpanel.animate({top: 0}, speed).attr({openstate: 'open'})
    else
    this.$mainpanel.animate({top: -this.contentdivheight+'px'}, speed).attr({openstate: 'closed'})
    },

    init:function(file, height, speed){
    jQuery(document).ready(function($){
    jkpanel.$mainpanel=$('<div id="dropdownpanel"><div class="contentdiv"></div><div class="control">'+jkpanel.controltext+'</div></div>').prependTo('body')
    var $contentdiv=jkpanel.$mainpanel.find('.contentdiv')
    var $controldiv=jkpanel.$mainpanel.find('.control').css({cursor: 'wait'})
    $contentdiv.load(file, '', function($){
    var heightattr=isNaN(parseInt(height))? 'auto' : parseInt(height)+'px'
    $contentdiv.css({height: heightattr})
    jkpanel.contentdivheight=parseInt($contentdiv.get(0).offsetHeight)
    jkpanel.$mainpanel.css({top:-jkpanel.contentdivheight+'px', visibility:'visible'}).attr('openstate', 'closed')
    $controldiv.css({cursor:'hand', cursor:'pointer'})
    })
    jkpanel.$mainpanel.click(function(){jkpanel.openclose($, speed)})
    })
    }
    }

    //Initialize script: jkpanel.init('path_to_content_file', 'height of content DIV in px', animation_duration)
    jkpanel.init('panelcontent.htm', '200px', 500)
    I'm sure it's rather easy to do. I'm just not familiar with javascript functions. And I have tried pasting hmtl elements at obvious (but wrong) location with no result.

    Thanks a lot.
    Last edited by halfemptycup; 08-27-2008 at 08:03 PM. Reason: resolved

  • #2
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, I found the solution this morning.

  • #3
    New to the CF scene
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you tell me the solution?


  •  

    Posting Permissions

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