简体   繁体   English

需要帮助修改网站上的javascript

[英]Need help modifying a javascript from a website

I downloaded an html5 template and tried customizing it, but I'm in over my head. 我下载了一个html5模板并尝试对其进行自定义,但是我不知所措。 The website I want is very simple. 我想要的网站非常简单。 You can see the demo here: Demo Website 您可以在此处查看演示: 演示网站

As you can see when the menu is clicked, there's slide-in content comes up on the right. 正如您所看到的,单击菜单时,右侧出现了滑入式内容。 So there's two things I'm hoping I could get advice on: 因此,我希望可以从两件事上获得建议:

1.) I would like to modify the width and height of this content and can't figure out how to do it. 1.)我想修改此内容的宽度和高度,但不知道该怎么做。

Here is the javascript I believe is responsible for it: 这是我认为对此负责的JavaScript:

$(window).load(function() { 
var act='';

$('#content > ul > li').css({position:'absolute', display:'none'});
$('#content > ul > li').find('.box1').css({height:'0'})

$('#menu > li > a span').css({opacity:'0'})

$('#menu > li > a').hover(function(){
    $(this).find(' > span').stop().animate({opacity:'1'},600);                         
}, function(){
    if (!$(this).hasClass('active')) {
        $(this).find(' > span').stop().animate({opacity:'0'},600);                         
    }
})

$('#menu > li').each(function(num){
    $(this).data({num:num})
})
if (location.hash.slice(0,3)=='#!/') {
    page=location.hash.slice(3);
    open_page('#'+page);
}
if ((location.hash=='#')||(location.hash=='')) {
    open_page('');
}
$('#menu a').click(function(){
    $('#menu a').removeClass('active').find(' > span').stop().animate({opacity:'0'},600);
    Cufon.replace('#menu a', { fontFamily: 'Questrial', hover:true });
    $(this).addClass('active').find(' > span').stop().animate({opacity:'1'},600);   
})
$('a').click(function(){
    if ($(this).attr('href').slice(0,3)=='#!/') {
        page=$(this).attr('href').slice(3); 
        open_page('#'+page);
        return false;
    }
    if ($(this).attr('data-type')=='close') {
        close_page()    
    }
})
function open_page(page){
    location.hash='#!/'+page.slice(1);
    if (act!='') {
        $(act).find('.box1').stop().animate({height:'0'},700,'easeOutCirc', function(){
            $(act).css({display:'none'});
            $(page).css({display:'block'}).find('.box1').stop().animate({height:'100%'},700, 'easeOutCirc', function(){
                act=page;           
            }); 
        })
    } else {
        $(page).css({display:'block'}).find('.box1').stop().animate({height:'100%'},700, 'easeOutCirc', function(){
            act=page;           
        });     
    }
}
function close_page(page){
    $('#menu a').removeClass('active').find(' > span').stop().animate({opacity:'0'},600);
    Cufon.replace('#menu a', { fontFamily: 'Questrial', hover:true });
    location.hash='#';
    $(act).find('.box1').stop().animate({height:'0'},700,'easeOutCirc', function(){
        $(act).css({display:'none'});
        act='';
    }); 
    return false;
}

}) })

2.) I would like to open another page (not hosted on the same server) within that slide-in content space, like a jquery pop-up but embedded inside that slide-in window. 2.)我想在该插入式内容空间中打开另一个页面(不在同一服务器上托管),例如一个jQuery弹出窗口,但嵌入到该插入式窗口内。 Currently, all the content there is written in the index.html 当前,所有内容都写在index.html中

Should I do so with an iframe? 我应该使用iframe这样做吗? I haven't tried yet because I need to figure out step 1 first. 我还没有尝试过,因为我需要先弄清楚步骤1。

Like this: 像这样:

<li id="page_Teachers">
                    <div class="box1">
                        <div class="inner">
                            <a href="#" class="close" data-type="close"><span></span></a>
                            <div class="wrapper">
                                <h2>Our Staff</h2>
                                <div class="wrapper pad_bot2">
                                    <figure class="left marg_right1"><img src="images/page2_img1.jpg" alt=""></figure>
                                    <p class="pad_bot2"><strong>Helen Williams</strong></p>
                                    <p class="pad_bot1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor inciddunt ut labore et dolore magna aliqua nostrud exercitation.</p>
                                    <p class="pad_bot2"><a href="#!/page_More" class="link1">Read More</a></p>
                                </div>
                                <div class="wrapper pad_bot2">
                                    <figure class="left marg_right1"><img src="images/page2_img2.jpg" alt=""></figure>
                                    <p class="pad_bot2"><strong>Jessy Hamper</strong></p>
                                    <p class="pad_bot1">Ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolorreprehenderit in voluptate velit esse cillum dolore.</p>
                                    <p class="pad_bot2"><a href="#!/page_More" class="link1">Read More</a></p>
                                </div>
                                <div class="wrapper pad_bot2">
                                    <figure class="left marg_right1"><img src="images/page2_img3.jpg" alt=""></figure>
                                    <p class="pad_bot2"><strong>Chester Hamper</strong></p>
                                    <p class="pad_bot1">Cupidatat non proident sunt culpa officia deserunt mollit anim idst laborum. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet.</p>
                                    <p class="pad_bot2"><a href="#!/page_More" class="link1">Read More</a></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>

You need to take your CSS into account as well. 您还需要考虑CSS。 Maybe start by playing with your css values, for example: 也许从玩css值开始,例如:

.main { width: 980; }
#content { width: xxx }

The CSS id selectors for those containers are: 这些容器的CSS id选择器是:

page_about, page_teachers, page_schedule, page_prices, page_more . page_about, page_teachers, page_schedule, page_prices, page_more As seen here: 如此处所示:

<li id="page_About" style="position: absolute; display: block;height: 400px;width: 600px;">
<li id="page_Teachers" style="position: absolute; display: none;">
<li id="page_Schedule" style="position: absolute; display: none;">
...

So, you need to add some CSS width and height to them. 因此,您需要为其添加一些CSS widthheight For example: 例如:

#page_about, #page_teachers, #page_schedules, #page_prices, #page_more {
    height: 200px;
    width: 300px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM