Ivan's fun Bag

by iscrow

HTML

<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="SomeScrollTrigger">click to scroll</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="toggle1">Toggle Something</div>
<div class="toggle2">Toggle Something Else(This has a direction set to only show)</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="">filler</div>
<div class="SomeToggleClass hide">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean commodo urna vel arcu imperdiet condimentum. 
    <div class="toggle3">Toggle Something Inside Something Else</div>
    Duis imperdiet dignissim quam non imperdiet. Duis tristique ac turpis ac ultrices. Ut mattis risus quam, et egestas metus vehicula ac. Curabitur consectetur nisl mauris, et viverra ipsum laoreet at. Suspendisse blandit volutpat volutpat. 
    <div class="SomeInsideToggleClass hide">Nullam auctor convallis posuere. Duis molestie nunc quis congue feugiat. Morbi vestibulum orci vitae orci venenatis, sed aliquet ligula eleifend. Suspendisse volutpat nisi porttitor ligula accumsan, vel mollis turpis molestie. Ut id tincidunt dolor. Ut laoreet nec felis auctor consectetur. Integer vestibulum sit amet sem nec molestie. Ut tempus neque pellentesque tincidunt cursus. Donec purus nunc, fringilla ac turpis sed, tincidunt vestibulum velit.</div>
    Nulla ac ante id eros condimentum lacinia ut sed neque. Pellentesque vitae mollis dolor. Nullam posuere metus quis diam tristique molestie. Ut scelerisque semper justo, vitae elementum risus sollicitudin vitae. Donec tortor augue, imperdiet et luctus ut, molestie ac turpis. Nam sodales aliquet nunc vitae malesuada. Phasellus sed nunc sem. In hac habitasse platea dictumst. Phasellus quis sodales odio. Nunc tortor elit, suscipit dignissim mattis vel, condimentum id...

CSS

.hide {
    display: none;
}

.ifb-active {
    color: red;
}
.SomeToggleClass, .SomeOtherToggleClass {
    width: 50%;
    float: left;
}

.SomeToggleClass {
    background-color: green;
}

.SomeOtherToggleClass {
    background-color: red;
}

.toggle3, .SomeInsideToggleClass {
    background-color: blue;
}

.SomeScrollTarget {
    background-color: pink;
}

JavaScript

/*
 * Ivan's Fun Bag (...as in a bag of fun)
 *
 * Authored by Ivan Ivanov
 *
 * Copyright 2014, Ivan Ivanov
 * License: GNU General Public License, version 3 (GPL-3.0)
 * http://www.opensource.org/licenses/gpl-3.0.html
 *
 * Revision: 2015-03-23
 */

;(function($) {

    "use strict";
    
    $.fn.ifbToggle = function (target, options) {
        var settings = $.extend({
            // These are the defaults.
            toggleTarget: target,                   // The target element to scroll to
            ToggleSpeed: "slow",                    // The speed with which to toggle the element (slow/fast/number in ms). slow=600ms, fast=200ms
            ToggleType: "vertical",                 // Type of toggle. Vertical is open: Down, close: Up, Anything else is Open: Slide down and to the right, Close: Slide up and to the left
            ToggleEasing: "swing",                  // Toggle easing. swing, linear or if jQueryUI/other jQuery easing library is included any of the easing function supported there.
            OtherElementsToHide: $(''),             // What other elements should we hide when closing this toggle?
            OtherTogglesToMarkInactive: $(''),      // What other elements' toggles to mark inactive when closing this toggle?
            ElementsToHideBeforeShowingThis: $(''), // What elements to hide before opening this toggle?
            AutoHideSpeed: "fast",                  // If we hide other elements on Open/Close what speed should we use?
            ScrollToElement: $(''),                 // What element do we scroll to on open? Takes a $("some element").
            ScrollToSpeed: "slow",                  // If we scroll, what speed should we use?
            ScrollToDelay: "fast",                  // If we scroll, how long shold we wait before we do it? For example for other elements to rearrange on the page so we scroll to an acurate location.
            ScrollToOffsetTop: 0,                   // If we scroll to an element, should...