Results 1 to 7 of 7

Thread: combination of functions isn't working

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

    Default combination of functions isn't working

    hi all!
    hope everyone had a great christmas?

    i have been pulling my hair out for some time trying to get something working.

    i have tried to integrate the script from this thread...

    with a floating menu that moves around the browser when clicked and also fades in the relevant div too - i have got this working nicely.

    but for some reason i can not (for the life of me) include additional div's into the div that fades in???

    in particular i need to use the iscroll.js within the div's as this is going to aimed primarily at a mobile audience.

    on one occassion i managed to get the scrolling div within the faded div - but without the webkit scroller (in other words it's not going to scroll on the mobile stage) - but no sooner had i got that far - i broke it and it didn't even show up anymore

    so i am hoping that someone can show me the error of my ways?

    my actual code for this is too long for this thread so here is the original code that john provided - my code is included in the .zip file attached to this post (fading_styles.html)
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd"
    >
    <
    html>
    <
    head>
    <
    title>SEO Detail click Demo</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    style type="text/css">
    * {
    background-color:white;
    }
    #triggers {
    float:left;
    border:1px solid #ccc;
    }
    #triggers div {
    cursor:pointer;
    }
    #zero {
    display:none;
    color:red;
    }
    #first {
    color:blue;
    }
    #second {
    color:green;
    }
    #third {
    color:#a52a2a;
    }
    </
    style>
    <
    script type="text/javascript">
    if(
    document.getElementById)
    document.write('<style type="text/css">.detail {float:left;display:none;}#zero {display:block;}<\/style>');
    function 
    reveal(det){
    if(!
    document.getElementById) return;
    if (!
    document.getElementsByClassName){
    document.getElementsByClassName = function(cn){
    cn cn.replace(/ +/g' ').split(' ');
    var 
    ar = [], testname = function(n){
    for (var 
    recn.length 1> -1; --i){
    re = new RegExp('(^|\W)' cn[i] + '(\W|$)');
    if(!
    re.test(n)) return false;
    }
    return 
    true;
    }
    for(var 
    document.all || document.getElementsByTagName('*'), 0d.length; ++i)
    if(
    testname(d[i].className))
    ar[ar.length] = d[i];
    return 
    ar;
    };
    document.getElementsByClassName.spoof true;
    }
    for (var 
    document.getElementsByClassName('detail'), d.length 1> -1; --i)
    d[i].style.display 'none';
    document.getElementById(det).style.display 'block';
    if (
    document.getElementsByClassName.spoof)
    document.getElementsByClassName.spoof document.getElementsByClassName null;
    }
    </script>
    </head>
    <body>
    <div id="triggers">
    <div onclick="reveal('first');">
    1st Trigger
    </div>
    <div onclick="reveal('second');">
    2nd Trigger
    </div>
    <div onclick="reveal('third');">
    3rd Trigger
    </div>
    </div>
    <div class="detail" id="zero">
    This would be what people would see at page load.
    </div>
    <div class="detail" id="first">
    This would be what people would see for the first clicked content.
    </div>
    <div class="detail" id="second">
    This would be what people would see for the second clicked content.
    </div>
    <div class="detail" id="third">
    This would be what people would see for the third clicked content.
    </div>
    </body>
    </html> 
    and this is the code for the iscroll elements that i want to sit inside the fading div's in the code above...

    PHP Code:
    <!DOCTYPE html>
    <
    html>
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <
    meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <
    meta name="apple-mobile-web-app-capable" content="yes">
    <
    meta name="apple-mobile-web-app-status-bar-style" content="black">
    <
    title>iScroll demozoom</title>

    <
    script type="application/javascript" src="iscroll.js"></script>

    <script type="text/javascript">

    var myScroll;
    function loaded() {
        myScroll = new iScroll('wrapper', { zoom:true });
    }

    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

    document.addEventListener('DOMContentLoaded', loaded, false);

    </script>



    <style type="text/css" media="all">
    body,ul,li,p {
        padding:0;
        margin:0;
        border:0;
    }

    body {
        font-size:12px;
        -webkit-user-select:none;
        -webkit-text-size-adjust:none;
        font-family:arial;
    }

    #header {
        position:absolute;
        top:0; left:0;
        width:100%;
        height:45px;
        line-height:45px;
        background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #fe96c9), color-stop(0.05, #d51875), color-stop(1, #7b0a2e));
        background-image:-moz-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
        background-image:-o-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
        padding:0;
        color:#eee;
        font-size:20px;
        text-align:center;
    }

    #header a {
        color:#f3f3f3;
        text-decoration:none;
        font-weight:bold;
        text-shadow:0 -1px 0 rgba(0,0,0,0.5);
    }

    #footer {
        position:absolute;
        bottom:0; left:0;
        width:100%;
        height:48px;
        background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #999), color-stop(0.02, #666), color-stop(1, #222));
        background-image:-moz-linear-gradient(top, #999, #666 2%, #222);
        background-image:-o-linear-gradient(top, #999, #666 2%, #222);
        padding:0;
        border-top:1px solid #444;
    }

    #wrapper {
        position:absolute;
        z-index:1;
        top:0;
        bottom:48px;
        left:0;
        width:250px;
        overflow:auto;
        height: 300px;
    }


    #scroller {
        position:relative;
    /*    -webkit-touch-callout:none;*/
        -webkit-tap-highlight-color:rgba(0,0,0,0);

        width:240px;
        padding:0;
    }



    p {
        display:block;
        width:224px;
        margin-bottom:1em;
        padding:8px;
        font-size:11px;
    }

    p img {
        margin:4px 8px;
        -webkit-transform:translate3d(0,0,0);
    }
    #phonescroll1 {
        position:absolute;
        left:149px;
        top:89px;
        width:238px;
        height:323px;
        z-index:1;
    }

    </style>
    </head>
    <body>
    <div id="phonescroll1">
      <div id="wrapper">
        <div id="scroller">
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
          <p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
        </div>
      </div>
    </div>

    </body>
    </html> 
    i have also included the files as attachments - if that helps?

    i have spent so many hours/days/weeks trying to get this working properly - i have gone a little snow blind!!!!

    hope someone can help me out

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I've updated the fading_styles.html page:

    Attachment 4257
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ...hi john thanks for that

    any idea of how i can get the scrolling div (apdiv1) to display within the divs that fade in?? so it is placed within - if you test the attachment doc - it works and shows up fine when just placed outside of the fades but i can't get it to even show on the screen when it is placed inside any of the div's?

    any idea what i am doing wrong?

    i had a similar thing and i solved it by placing a div inside the fader - making the position relative and then pasting elements into the relative div - it seemed to work okay - but this time even that isn't working?!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm not real clear on what you want to happen. It shows up in the place I think you say you want it in Firefox. In IE there are script errors. These are not supported:

    Code:
    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    
    document.addEventListener('DOMContentLoaded', loaded, false);
    A good cross browser substitute is:

    Code:
    jQuery(function($){
    	loaded();
    });
    document.ontouchmove = function(e){e = e || event; if(e.preventDefault){ e.preventDefault(); } e.returnValue = false; return false;};
    Also in IE, where you have (8 places):

    Code:
    color: transparent;
    Although it's technically invalid, IE is doing it. As a result no text is seen - it's transparent. Perhaps you meant:

    Code:
    background-color: transparent;
    If so, do that. If not, just get rid of them or define a visible color.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Oct 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    hi john, thanks for replying (once again!)

    basically, i am trying to work out how i can add content the panels/items that fade in and out...
    (at the moment i only manage to show the text)

    it's almost like making each fading div into a picture frame (maybe not the best metaphor) and any element/image/text that is pasted into the fading div, fades in and out.

    i guess ultimately i want to make the faders panels into containers for other, additional, content - and integrate some css styling in there too?

    but at the moment i am not able to do this.

    not sure how much sense that makes?! but if i clicked the trigger for panel two it might show text and an image - click trigger three maybe just an image... so on and so forth!

    do you know what i mean? how to add custom content to the fading div?

    the scroll script that i added to the last attachment works fine whilst it sits alone but if i add it to one of the fades it simply doesn't show up!

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Adding content to one of the detail divisions is easy, just add it. For example you currently have:

    Code:
    <div class="details">
      <div id="default">This is the default</div>
      <div id="first">
     this is the first</div>
      <div id="second">2nd The order in which the triggers appear determines which details division they activate.</div>
      <div id="third">3rd The id's of the details division are only for styling. They're not required for the script. </div>
      <div id="fourth">4rth The id's of the details division are only for styling. They're not required for the script. </div>
      <div id="fifth">5th The id's of the details division are only for styling. They're not required for the script. </div>
      <div id="sixth">6th The id's of the details division are only for styling. They're not required for the script. </div>
    </div>
    You could do:

    Code:
    <div class="details">
      <div id="default">This is the default</div>
      <div id="first"><img src="some.jpg" alt="original image" title="">
     this is the first</div>
      <div id="second">2nd The order in which the triggers appear determines which details division they activate.</div>
      <div id="third">3rd The id's of the details division are only for styling. They're not required for the script. </div>
      <div id="fourth">4rth The id's of the details division are only for styling. They're not required for the script. </div>
      <div id="fifth">5th The id's of the details division are only for styling. They're not required for the script. </div>
      <div id="sixth">6th The id's of the details division are only for styling. They're not required for the script. </div>
    </div>
    etc.

    As for putting a floating div inside a fading div, I'm sure it can be done. Or at the very least one could modify the script(s) and markup to place it over the fading div, yet bounded by that fading div's dimensions, its being revealed tied to a specific trigger.

    Either way (actually placing it in a fading div or superimposing it upon a given fading div), would probably be a bit of coding. I'm not really inclined to do that for just a demo. If you have specific content that would actually benefit from being so organized, and at that point still can't make it work, when I have more time I'll look into it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Oct 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    hi john, i've been beavering away, trying to get things working, and have had some success in getting things to show up with the div's

    ...but for some reason, which i simply can't work out, the iscroll.js will only work when placed inside of the "default" panel - the first panel that is displayed onload - when i add another div with text to the "first" panel in the stack - it is only half working - it has some elasticity in as much as it will let you drag it and revela more text but springs straight back to the top and doesn't display a js scroll bar like it does on the initial panel?

    i am not sure if it is my css that is causing this or if it is the way i am calling the function? i have tried a few things now - like adding a reference to the div that contains the scrolling div and it's text - but nothing seems to make it happy!

    if you open the attaced .zip you will see what i mean - the main panel on load shows a nicely scrolling text box - but when you click on the first link "top left" it just shows the text - and if you click, hold and drag the text - it does move down but springs back to the top when you release????

    i'm totally bemused as to why it will work in one div but not the other?
    i have labelled them individually and added the specific css ref's and js function refs - but with no luck

    any ideas? or thoughts as to what i am not doing right?
    hope you can point me in the right direction

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
  •