Click here to Skip to main content
15,887,596 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: jquery tabslideout plugin and want to detect when div slide in and out Pin
vbmike23-Dec-12 11:31
vbmike23-Dec-12 11:31 
QuestionConvert HTML to PDF (Client Side) Pin
Phanindra26116-Dec-12 20:07
Phanindra26116-Dec-12 20:07 
QuestionRe: Convert HTML to PDF (Client Side) Pin
ZurdoDev18-Dec-12 5:05
professionalZurdoDev18-Dec-12 5:05 
AnswerRe: Convert HTML to PDF (Client Side) Pin
Phanindra26118-Dec-12 17:50
Phanindra26118-Dec-12 17:50 
GeneralRe: Convert HTML to PDF (Client Side) Pin
J4amieC18-Dec-12 21:29
J4amieC18-Dec-12 21:29 
QuestionCan't figure out why the currentSlide goes 0-3-2 Pin
jkirkerx16-Dec-12 12:08
professionaljkirkerx16-Dec-12 12:08 
AnswerRe: Can't figure out why the currentSlide goes 0-3-2 Pin
jkirkerx17-Dec-12 8:40
professionaljkirkerx17-Dec-12 8:40 
AnswerSo I rewrote the program from scratch, works pretty good now, feel free to build on it Pin
jkirkerx19-Dec-12 17:45
professionaljkirkerx19-Dec-12 17:45 
So this takes all the div and makes a filmstrip out of them, and moves each cell left, and then rewinds and starts again. I think it's simple in design. Feel free to comment on it.

///////////////////////////////////////////////////////////////////////////////
//  jquery.displayadvertising.js
//
//  writen by Jim Kirker on December 18, 2012
//  Copyright by redCopper, Inc. 2013
//
//  Jquery and dynamic javascript to build a filmstrip out of current elements,
//  destroy the current elements and run the new filmstrip instead in the container;
//  then run the filmstrip in a loop, and rewind, then run again until a stop command is issued.
//
///////////////////////////////////////////////////////////////////////////////

$(document).ready(function () {
    
    load_DisplayAdvertising_Horizontal();
});

///////////////////////////////////////////////////////////////////////////////
//  load_DisplayAdvertising_Horizontal
//  Create a dynamic filmstrip in the DOM from current webform elements of text
//  We will run the filmstrip in another function below
///////////////////////////////////////////////////////////////////////////////
function load_DisplayAdvertising_Horizontal() {

    // Some fixed preset values
    var view_Width = 980;   // width of each filmstrip cell
    var view_Height = 250;  // height of each filmstrip cell
    var view_Time = 4000;   // amount of time to view the filmstrip cell
    var ease_Time = 1400;   // amount of time to pan the filmstrip cell left
    
    // Count how many Display Ads that we have in the slide container
    var child_Count = parseInt($('[id*="_slide_container"]').children().length);

    // We should build a dynamic message if no child objects exist


    //Prepare the slide_container as a fixed object with the correct css
    $('[id*="_slide_container"]').css({
        "position": "relative",
        "width": view_Width + "px",
        "height": view_Height + "px",
        "overflow": "hidden"        
    });

    // Alright, Setup all the the Child Panels 
    // within the Parent Container as a long film strip of panels
    var fsWidth = 0;
    var fsHeight = 0;

    // Loop through the Display Ads and reprogram the CSS
    $('[id*="_slide_container"]').find("._slide_child").css({
        //Program each child container to display and othe specs
        "display": "inline",
        "position": "relative",
        "float": "left",
        "top": "0px",
        "left": "0px"                        
    }).each(function (index) {
        // Measure the total width and max height of all child containers
        // to make a long horizontal filmstrip that just pans left to right
        fsWidth = fsWidth + parseInt($(this).css("width"));
        if (fsHeight < parseInt($(this).css("height"))) {
            fsHeight = parseInt($(this).css("height"));
        }
    })

    // Create a dynamic long FilmStrip container 
    // to put all the child panels in like movie film
    var div_filmStrip = document.createElement("div");
    div_filmStrip.style.textAlign = "left";
    div_filmStrip.style.width = fsWidth + "px";
    div_filmStrip.style.height = fsHeight + "px";
    div_filmStrip.style.position = "relative";
    div_filmStrip.style.left = "0px";
    div_filmStrip.style.top = "0px";
    
    // Copy the html from each child container to reinsert into the Dom
    var temp_InnerHTML = $('[id*="_slide_container"]').html();
    div_filmStrip.innerHTML = temp_InnerHTML;

    // Replace the old container content with this new filmstrip and copied content
    $('[id*="_slide_container"]').empty();
    $('[id*="_slide_container"]').append(div_filmStrip);

    // Run the Display Advertising in a seperate function for play and rewinding
    // The function should be just below this function
    run_DisplayAdvertising_Horizontal(
        div_filmStrip,
        fsWidth,
        view_Width,
        child_Count,
        view_Time,
        ease_Time
    ); 
}

///////////////////////////////////////////////////////////////////////////////
//  run_DisplayAdvertising_Horizontal
//  External run function that plays and rewinds over and over
///////////////////////////////////////////////////////////////////////////////
function run_DisplayAdvertising_Horizontal(obj, cW, vW, cC, vT, eT) {
    if (cC > 0)
    {
        var fsWidth = parseInt(cW - vW);
        var fsRewind = parseInt(vT / cC);
        for (var i = 0; i < cC-1; i++)
        {
            $(obj).delay(vT).animate({
                left: '-=' + vW
            }, eT, "linear", function () {
                //Animate Complete             
                var fsPosition = parseInt($(obj).css("left"));
                if (fsPosition == -fsWidth) {
                    $(obj).delay(vT).animate({
                        left: '0px'
                    }, fsRewind, "linear", function () {
                        // rewind complete, run the Display Ad again
                        run_DisplayAdvertising_Horizontal(obj, cW, vW, cC, vT, eT);

                    });
                }
            });            
        }       
    }
}


The HTML Side
<div id="_slide_container" style="width: 980px; height: 254px; text-align: center; margin: 0px auto; display: block;">

       <div id="slideChild_0" class="_slide_child" style="width: 980px; height: 250px; display: block;">
           <asp:Image ID="img_slideshow_child_0" runat="server"
               ImageUrl="~/EN-US/images/SlideShows/SS_StrategyPlanning_980x250.png" />
       </div>

       <div id="slideChild_1" class="_slide_child" style="width: 980px; height: 250px; display: none;">
           <asp:Image ID="img_slideshow_child_1" runat="server"
               ImageUrl="~/EN-US/images/SlideShows/SS_WebDesign_980x250.png" />
       </div>

       <div id="slideChild_2" class="_slide_child" style="width: 980px; height: 250px; display: none;">
           <asp:Image ID="img_slideshow_child_2" runat="server"
               ImageUrl="~/EN-US/images/SlideShows/SS_WebDevelopment_980x250.png" />
       </div>

       <div id="slideChild_3" class="_slide_child" style="width: 980px; height: 250px; display: none;">
           <asp:Image ID="img_slideshow_child_3" runat="server"
               ImageUrl="~/EN-US/images/SlideShows/SS_HKB_Project_2_980x250.png" />
       </div>

       <div id="slideChild_4" class="_slide_child" style="width: 980px; height: 250px; display: none;">
           <asp:Image ID="img_slideshow_child_4" runat="server"
               ImageUrl="~/EN-US/images/SlideShows/SS_InternetCommerceEngine-5_980x250.png" />
       </div>

   </div>

GeneralRe: So I rewrote the program from scratch, works pretty good now, feel free to build on it Pin
Richard MacCutchan19-Dec-12 23:15
mveRichard MacCutchan19-Dec-12 23:15 
GeneralRe: So I rewrote the program from scratch, works pretty good now, feel free to build on it Pin
jkirkerx20-Dec-12 6:18
professionaljkirkerx20-Dec-12 6:18 
GeneralRe: So I rewrote the program from scratch, works pretty good now, feel free to build on it Pin
Richard MacCutchan20-Dec-12 6:39
mveRichard MacCutchan20-Dec-12 6:39 
QuestionJava Script Pin
manoj s sherje14-Dec-12 1:05
manoj s sherje14-Dec-12 1:05 
QuestionRe: Java Script Pin
Thomas Daniels14-Dec-12 1:33
mentorThomas Daniels14-Dec-12 1:33 
QuestionRe: Java Script Pin
ZurdoDev18-Dec-12 5:06
professionalZurdoDev18-Dec-12 5:06 
AnswerRe: Java Script Pin
manoj s sherje19-Dec-12 1:01
manoj s sherje19-Dec-12 1:01 
AnswerRe: Java Script Pin
ZurdoDev19-Dec-12 1:37
professionalZurdoDev19-Dec-12 1:37 
AnswerRe: Java Script Pin
vbmike19-Dec-12 4:28
vbmike19-Dec-12 4:28 
QuestionUsing datePicker to disable dates already selected Pin
xnaLearner11-Dec-12 3:39
xnaLearner11-Dec-12 3:39 
Questionjquery tabslideout plugin and wired behavior Pin
Tridip Bhattacharjee9-Dec-12 21:13
professionalTridip Bhattacharjee9-Dec-12 21:13 
AnswerRe: jquery tabslideout plugin and wired behavior Pin
Mayor Daily17-Dec-12 4:22
Mayor Daily17-Dec-12 4:22 
GeneralRe: jquery tabslideout plugin and wired behavior Pin
Tridip Bhattacharjee18-Dec-12 0:55
professionalTridip Bhattacharjee18-Dec-12 0:55 
QuestionNeed help understanding binding Pin
Steve Bondy7-Dec-12 14:00
Steve Bondy7-Dec-12 14:00 
QuestionText replace Pin
rakeshs3126-Dec-12 23:06
rakeshs3126-Dec-12 23:06 
AnswerRe: Text replace Pin
Richard MacCutchan7-Dec-12 0:43
mveRichard MacCutchan7-Dec-12 0:43 
GeneralRe: Text replace Pin
rakeshs3129-Dec-12 5:40
rakeshs3129-Dec-12 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.