addet websites to test

This commit is contained in:
piecka 2025-02-28 07:43:39 +01:00
parent 78e00c2fcc
commit d8a0746af2
102 changed files with 28717 additions and 0 deletions

View file

@ -0,0 +1,598 @@
// ------------------------------------------------------------------------------ //
//
// Template name : Bootsnav - Multi Purpose Header
// Categorie : Bootstrap Menu in CSS
// Author : adamnurdin01
// Version : v.1.2
// Created : 2016-06-02
// Last update : 2016-10-19
//
// ------------------------------------------------------------------------------ //
(function ($) {
"use strict";
var bootsnav = {
initialize: function() {
this.event();
this.hoverDropdown();
this.navbarSticky();
this.navbarScrollspy();
},
event : function(){
// ------------------------------------------------------------------------------ //
// Variable
// ------------------------------------------------------------------------------ //
var getNav = $("nav.navbar.bootsnav");
// ------------------------------------------------------------------------------ //
// Navbar Sticky
// ------------------------------------------------------------------------------ //
var navSticky = getNav.hasClass("navbar-sticky");
if( navSticky ){
// Wraped navigation
getNav.wrap("<div class='wrap-sticky'></div>");
}
// ------------------------------------------------------------------------------ //
// Navbar Center
// ------------------------------------------------------------------------------ //
if( getNav.hasClass("brand-center")){
var postsArr = new Array(),
index = $("nav.brand-center"),
$postsList = index.find('ul.navbar-nav');
index.prepend("<span class='storage-name' style='display:none;'></span>");
//Create array of all posts in lists
index.find('ul.navbar-nav > li').each(function(){
if( $(this).hasClass("active") ){
var getElement = $("a", this).eq(0).text();
$(".storage-name").html(getElement);
}
postsArr.push($(this).html());
});
//Split the array at this point. The original array is altered.
var firstList = postsArr.splice(0, Math.round(postsArr.length / 2)),
secondList = postsArr,
ListHTML = '';
var createHTML = function(list){
ListHTML = '';
for (var i = 0; i < list.length; i++) {
ListHTML += '<li>' + list[i] + '</li>'
}
}
//Generate HTML for first list
createHTML(firstList);
$postsList.html(ListHTML);
index.find("ul.nav").first().addClass("navbar-left");
//Generate HTML for second list
createHTML(secondList);
//Create new list after original one
$postsList.after('<ul class="nav navbar-nav"></ul>').next().html(ListHTML);
index.find("ul.nav").last().addClass("navbar-right");
//Wrap navigation menu
index.find("ul.nav.navbar-left").wrap("<div class='col-half left'></div>");
index.find("ul.nav.navbar-right").wrap("<div class='col-half right'></div>");
//Selection Class
index.find('ul.navbar-nav > li').each(function(){
var dropDown = $("ul.dropdown-menu", this),
megaMenu = $("ul.megamenu-content", this);
dropDown.closest("li").addClass("dropdown");
megaMenu.closest("li").addClass("megamenu-fw");
});
var getName = $(".storage-name").html();
if( !getName == "" ){
$( "ul.navbar-nav > li:contains('" + getName + "')" ).addClass("active");
}
}
// ------------------------------------------------------------------------------ //
// Navbar Sidebar
// ------------------------------------------------------------------------------ //
if( getNav.hasClass("navbar-sidebar")){
// Add Class to body
$("body").addClass("wrap-nav-sidebar");
getNav.wrapInner("<div class='scroller'></div>");
}else{
$(".bootsnav").addClass("on");
}
// ------------------------------------------------------------------------------ //
// Menu Center
// ------------------------------------------------------------------------------ //
if( getNav.find("ul.nav").hasClass("navbar-center")){
getNav.addClass("menu-center");
}
// ------------------------------------------------------------------------------ //
// Navbar Full
// ------------------------------------------------------------------------------ //
if( getNav.hasClass("navbar-full")){
// Add Class to body
$("nav.navbar.bootsnav").find("ul.nav").wrap("<div class='wrap-full-menu'></div>");
$(".wrap-full-menu").wrap("<div class='nav-full'></div>");
$("ul.nav.navbar-nav").prepend("<li class='close-full-menu'><a href='#'><i class='fa fa-times'></i></a></li>");
}else if( getNav.hasClass("navbar-mobile")){
getNav.removeClass("no-full");
}else{
getNav.addClass("no-full");
}
// ------------------------------------------------------------------------------ //
// Navbar Mobile
// ------------------------------------------------------------------------------ //
if( getNav.hasClass("navbar-mobile")){
// Add Class to body
$('.navbar-collapse').on('shown.bs.collapse', function() {
$("body").addClass("side-right");
});
$('.navbar-collapse').on('hide.bs.collapse', function() {
$("body").removeClass("side-right");
});
$(window).on("resize", function(){
$("body").removeClass("side-right");
});
}
// ------------------------------------------------------------------------------ //
// Navbar Fixed
// ------------------------------------------------------------------------------ //
if( getNav.hasClass("no-background")){
$(window).on("scroll", function(){
var scrollTop = $(window).scrollTop();
if(scrollTop >34){
$(".navbar-fixed").removeClass("no-background");
}else {
$(".navbar-fixed").addClass("no-background");
}
});
}
// ------------------------------------------------------------------------------ //
// Navbar Fixed
// ------------------------------------------------------------------------------ //
if( getNav.hasClass("navbar-transparent")){
$(window).on("scroll", function(){
var scrollTop = $(window).scrollTop();
if(scrollTop >34){
$(".navbar-fixed").removeClass("navbar-transparent");
}else {
$(".navbar-fixed").addClass("navbar-transparent");
}
});
}
// ------------------------------------------------------------------------------ //
// Button Cart
// ------------------------------------------------------------------------------ //
$(".btn-cart").on("click", function(e){
e.stopPropagation();
});
// ------------------------------------------------------------------------------ //
// Toggle Search
// ------------------------------------------------------------------------------ //
$("nav.navbar.bootsnav .attr-nav").each(function(){
$("li.search > a", this).on("click", function(e){
e.preventDefault();
$(".top-search").slideToggle();
});
});
$(".input-group-addon.close-search").on("click", function(){
$(".top-search").slideUp();
});
// ------------------------------------------------------------------------------ //
// Toggle Side Menu
// ------------------------------------------------------------------------------ //
$("nav.navbar.bootsnav .attr-nav").each(function(){
$("li.side-menu > a", this).on("click", function(e){
e.preventDefault();
$("nav.navbar.bootsnav > .side").toggleClass("on");
$("body").toggleClass("on-side");
});
});
$(".side .close-side").on("click", function(e){
e.preventDefault();
$("nav.navbar.bootsnav > .side").removeClass("on");
$("body").removeClass("on-side");
});
// ------------------------------------------------------------------------------ //
// Wrapper
// ------------------------------------------------------------------------------ //
$("body").wrapInner( "<div class='wrapper'></div>");
},
// ------------------------------------------------------------------------------ //
// Change dropdown to hover on dekstop
// ------------------------------------------------------------------------------ //
hoverDropdown : function(){
var getNav = $("nav.navbar.bootsnav"),
getWindow = $(window).width(),
getHeight = $(window).height(),
getIn = getNav.find("ul.nav").data("in"),
getOut = getNav.find("ul.nav").data("out");
if( getWindow < 991 ){
// Height of scroll navigation sidebar
$(".scroller").css("height", "auto");
// Disable mouseenter event
$("nav.navbar.bootsnav ul.nav").find("li.dropdown").off("mouseenter");
$("nav.navbar.bootsnav ul.nav").find("li.dropdown").off("mouseleave");
$("nav.navbar.bootsnav ul.nav").find(".title").off("mouseenter");
$("nav.navbar.bootsnav ul.nav").off("mouseleave");
$(".navbar-collapse").removeClass("animated");
// Enable click event
$("nav.navbar.bootsnav ul.nav").each(function(){
$(".dropdown-menu", this).addClass("animated");
$(".dropdown-menu", this).removeClass(getOut);
// Dropdown Fade Toggle
$("a.dropdown-toggle", this).off('click');
$("a.dropdown-toggle", this).on('click', function (e) {
e.stopPropagation();
$(this).closest("li.dropdown").find(".dropdown-menu").first().stop().fadeToggle().toggleClass(getIn);
$(this).closest("li.dropdown").first().toggleClass("on");
return false;
});
// Hidden dropdown action
$('li.dropdown', this).each(function () {
$(this).find(".dropdown-menu").stop().fadeOut();
$(this).on('hidden.bs.dropdown', function () {
$(this).find(".dropdown-menu").stop().fadeOut();
});
return false;
});
// Megamenu style
$(".megamenu-fw", this).each(function(){
$(".col-menu", this).each(function(){
$(".content", this).addClass("animated");
$(".content", this).stop().fadeOut();
$(".title", this).off("click");
$(".title", this).on("click", function(){
$(this).closest(".col-menu").find(".content").stop().fadeToggle().addClass(getIn);
$(this).closest(".col-menu").toggleClass("on");
return false;
});
$(".content", this).on("click", function(e){
e.stopPropagation();
});
});
});
});
// Hidden dropdown
var cleanOpen = function(){
$('li.dropdown', this).removeClass("on");
$(".dropdown-menu", this).stop().fadeOut();
$(".dropdown-menu", this).removeClass(getIn);
$(".col-menu", this).removeClass("on");
$(".col-menu .content", this).stop().fadeOut();
$(".col-menu .content", this).removeClass(getIn);
}
// Hidden om mouse leave
$("nav.navbar.bootsnav").on("mouseleave", function(){
cleanOpen();
});
// Enable click atribute navigation
$("nav.navbar.bootsnav .attr-nav").each(function(){
$(".dropdown-menu", this).removeClass("animated");
$("li.dropdown", this).off("mouseenter");
$("li.dropdown", this).off("mouseleave");
$("a.dropdown-toggle", this).off('click');
$("a.dropdown-toggle", this).on('click', function (e) {
e.stopPropagation();
$(this).closest("li.dropdown").find(".dropdown-menu").first().stop().fadeToggle();
$(".navbar-toggle").each(function(){
$(".fa", this).removeClass("fa-times");
$(".fa", this).addClass("fa-bars");
$(".navbar-collapse").removeClass("in");
$(".navbar-collapse").removeClass("on");
});
});
$(this).on("mouseleave", function(){
$(".dropdown-menu", this).stop().fadeOut();
$("li.dropdown", this).removeClass("on");
return false;
});
});
// Toggle Bars
$(".navbar-toggle").each(function(){
$(this).off("click");
$(this).on("click", function(){
$(".fa", this).toggleClass("fa-bars");
$(".fa", this).toggleClass("fa-times");
cleanOpen();
});
});
}else if( getWindow > 991 ){
// Height of scroll navigation sidebar
$(".scroller").css("height", getHeight + "px");
// Navbar Sidebar
if( getNav.hasClass("navbar-sidebar")){
// Hover effect Sidebar Menu
$("nav.navbar.bootsnav ul.nav").each(function(){
$("a.dropdown-toggle", this).off('click');
$("a.dropdown-toggle", this).on('click', function (e) {
e.stopPropagation();
});
$(".dropdown-menu", this).addClass("animated");
$("li.dropdown", this).on("mouseenter", function(){
$(".dropdown-menu", this).eq(0).removeClass(getOut);
$(".dropdown-menu", this).eq(0).stop().fadeIn().addClass(getIn);
$(this).addClass("on");
return false;
});
$(".col-menu").each(function(){
$(".content", this).addClass("animated");
$(".title", this).on("mouseenter", function(){
$(this).closest(".col-menu").find(".content").stop().fadeIn().addClass(getIn);
$(this).closest(".col-menu").addClass("on");
return false;
});
});
$(this).on("mouseleave", function(){
$(".dropdown-menu", this).stop().removeClass(getIn);
$(".dropdown-menu", this).stop().addClass(getOut).fadeOut();
$(".col-menu", this).find(".content").stop().fadeOut().removeClass(getIn);
$(".col-menu", this).removeClass("on");
$("li.dropdown", this).removeClass("on");
return false;
});
});
}else{
// Hover effect Default Menu
$("nav.navbar.bootsnav ul.nav").each(function(){
$("a.dropdown-toggle", this).off('click');
$("a.dropdown-toggle", this).on('click', function (e) {
e.stopPropagation();
});
$(".megamenu-fw", this).each(function(){
$(".title", this).off("click");
$("a.dropdown-toggle", this).off("click");
$(".content").removeClass("animated");
});
$(".dropdown-menu", this).addClass("animated");
$("li.dropdown", this).on("mouseenter", function(){
$(".dropdown-menu", this).eq(0).removeClass(getOut);
$(".dropdown-menu", this).eq(0).stop().fadeIn().addClass(getIn);
$(this).addClass("on");
return false;
});
$("li.dropdown", this).on("mouseleave", function(){
$(".dropdown-menu", this).eq(0).removeClass(getIn);
$(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
$(this).removeClass("on");
});
$(this).on("mouseleave", function(){
$(".dropdown-menu", this).removeClass(getIn);
$(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
$("li.dropdown", this).removeClass("on");
return false;
});
});
}
// ------------------------------------------------------------------------------ //
// Hover effect Atribute Navigation
// ------------------------------------------------------------------------------ //
$("nav.navbar.bootsnav .attr-nav").each(function(){
$("a.dropdown-toggle", this).off('click');
$("a.dropdown-toggle", this).on('click', function (e) {
e.stopPropagation();
});
$(".dropdown-menu", this).addClass("animated");
$("li.dropdown", this).on("mouseenter", function(){
$(".dropdown-menu", this).eq(0).removeClass(getOut);
$(".dropdown-menu", this).eq(0).stop().fadeIn().addClass(getIn);
$(this).addClass("on");
return false;
});
$("li.dropdown", this).on("mouseleave", function(){
$(".dropdown-menu", this).eq(0).removeClass(getIn);
$(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
$(this).removeClass("on");
});
$(this).on("mouseleave", function(){
$(".dropdown-menu", this).removeClass(getIn);
$(".dropdown-menu", this).eq(0).stop().fadeOut().addClass(getOut);
$("li.dropdown", this).removeClass("on");
return false;
});
});
}
// ------------------------------------------------------------------------------ //
// Menu Fullscreen
// ------------------------------------------------------------------------------ //
if( getNav.hasClass("navbar-full")){
var windowHeight = $(window).height(),
windowWidth = $(window).width();
$(".nav-full").css("height", windowHeight + "px");
$(".wrap-full-menu").css("height", windowHeight + "px");
$(".wrap-full-menu").css("width", windowWidth + "px");
$(".navbar-collapse").addClass("animated");
$(".navbar-toggle").each(function(){
var getId = $(this).data("target");
$(this).off("click");
$(this).on("click", function(e){
e.preventDefault();
$(getId).removeClass(getOut);
$(getId).addClass("in");
$(getId).addClass(getIn);
return false;
});
$("li.close-full-menu").on("click", function(e){
e.preventDefault();
$(getId).addClass(getOut);
setTimeout(function(){
$(getId).removeClass("in");
$(getId).removeClass(getIn);
}, 500);
return false;
});
});
}
},
// ------------------------------------------------------------------------------ //
// Navbar Sticky
// ------------------------------------------------------------------------------ //
navbarSticky : function(){
var getNav = $("nav.navbar.bootsnav"),
navSticky = getNav.hasClass("navbar-sticky");
if( navSticky ){
// Set Height Navigation
var getHeight = getNav.height();
$(".wrap-sticky").height(getHeight);
// Windown on scroll
var getOffset = $(".wrap-sticky").offset().top;
$(window).on("scroll", function(){
var scrollTop = $(window).scrollTop();
if(scrollTop > getOffset){
getNav.addClass("sticked");
}else {
getNav.removeClass("sticked");
}
});
}
},
// ------------------------------------------------------------------------------ //
// Navbar Scrollspy
// ------------------------------------------------------------------------------ //
navbarScrollspy : function(){
var navScrollSpy = $(".navbar-scrollspy"),
$body = $('body'),
getNav = $('nav.navbar.bootsnav'),
offset = getNav.outerHeight();
if( navScrollSpy.length ){
$body.scrollspy({target: '.navbar', offset: offset });
// Animation Scrollspy
$('.scroll').on('click', function(event) {
event.preventDefault();
// Active link
$('.scroll').removeClass("active");
$(this).addClass("active");
// Remove navbar collapse
$(".navbar-collapse").removeClass("in");
// Toggle Bars
$(".navbar-toggle").each(function(){
$(".fa", this).removeClass("fa-times");
$(".fa", this).addClass("fa-bars");
});
// Scroll
var scrollTop = $(window).scrollTop(),
$anchor = $(this).find('a'),
$section = $($anchor.attr('href')).offset().top,
$window = $(window).width(),
$minusDesktop = getNav.data("minus-value-desktop"),
$minusMobile = getNav.data("minus-value-mobile"),
$speed = getNav.data("speed");
if( $window > 992 ){
var $position = $section - $minusDesktop;
}else{
var $position = $section - $minusMobile;
}
$('html, body').stop().animate({
scrollTop: $position
}, $speed);
});
// Activate Navigation
var fixSpy = function() {
var data = $body.data('bs.scrollspy');
if (data) {
offset = getNav.outerHeight();
data.options.offset = offset;
$body.data('bs.scrollspy', data);
$body.scrollspy('refresh');
}
}
// Activate Navigation on resize
var resizeTimer;
$(window).on('resize', function() {
clearTimeout(resizeTimer);
var resizeTimer = setTimeout(fixSpy, 200);
});
}
}
};
// Initialize
$(document).ready(function(){
bootsnav.initialize();
});
// Reset on resize
$(window).on("resize", function(){
bootsnav.hoverDropdown();
setTimeout(function(){
bootsnav.navbarSticky();
}, 500);
// Toggle Bars
$(".navbar-toggle").each(function(){
$(".fa", this).removeClass("fa-times");
$(".fa", this).addClass("fa-bars");
$(this).removeClass("fixed");
});
$(".navbar-collapse").removeClass("in");
$(".navbar-collapse").removeClass("on");
$(".navbar-collapse").removeClass("bounceIn");
});
}(jQuery));

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,127 @@
$(document).ready(function(){
"use strict";
/*==================================
* Author : "ThemeSine"
* Template Name : Khanas HTML Template
* Version : 1.0
==================================== */
/*=========== TABLE OF CONTENTS ===========
1. Scroll To Top
2. Smooth Scroll spy
3. Progress-bar
4. owl carousel
5. welcome animation support
======================================*/
// 1. Scroll To Top
$(window).on('scroll',function () {
if ($(this).scrollTop() > 600) {
$('.return-to-top').fadeIn();
} else {
$('.return-to-top').fadeOut();
}
});
$('.return-to-top').on('click',function(){
$('html, body').animate({
scrollTop: 0
}, 1500);
return false;
});
// 2. Smooth Scroll spy
$('.header-area').sticky({
topSpacing:0
});
//=============
$('li.smooth-menu a').bind("click", function(event) {
event.preventDefault();
var anchor = $(this);
$('html, body').stop().animate({
scrollTop: $(anchor.attr('href')).offset().top - 0
}, 1200,'easeInOutExpo');
});
$('body').scrollspy({
target:'.navbar-collapse',
offset:0
});
// 3. Progress-bar
var dataToggleTooTip = $('[data-toggle="tooltip"]');
var progressBar = $(".progress-bar");
if (progressBar.length) {
progressBar.appear(function () {
dataToggleTooTip.tooltip({
trigger: 'manual'
}).tooltip('show');
progressBar.each(function () {
var each_bar_width = $(this).attr('aria-valuenow');
$(this).width(each_bar_width + '%');
});
});
}
// 4. owl carousel
// i. client (carousel)
$('#client').owlCarousel({
items:7,
loop:true,
smartSpeed: 1000,
autoplay:true,
dots:false,
autoplayHoverPause:true,
responsive:{
0:{
items:2
},
415:{
items:2
},
600:{
items:4
},
1199:{
items:4
},
1200:{
items:7
}
}
});
$('.play').on('click',function(){
owl.trigger('play.owl.autoplay',[1000])
})
$('.stop').on('click',function(){
owl.trigger('stop.owl.autoplay')
})
// 5. welcome animation support
$(window).load(function(){
$(".header-text h2,.header-text p").removeClass("animated fadeInUp").css({'opacity':'0'});
$(".header-text a").removeClass("animated fadeInDown").css({'opacity':'0'});
});
$(window).load(function(){
$(".header-text h2,.header-text p").addClass("animated fadeInUp").css({'opacity':'0'});
$(".header-text a").addClass("animated fadeInDown").css({'opacity':'0'});
});
});

View file

@ -0,0 +1,8 @@
/*
* jQuery.appear
* http://code.google.com/p/jquery-appear/
*
* Copyright (c) 2009 Michael Hixson
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
*/
(function($){$.fn.appear=function(f,o){var s=$.extend({one:true},o);return this.each(function(){var t=$(this);t.appeared=false;if(!f){t.trigger('appear',s.data);return;}var w=$(window);var c=function(){if(!t.is(':visible')){t.appeared=false;return;}var a=w.scrollLeft();var b=w.scrollTop();var o=t.offset();var x=o.left;var y=o.top;if(y+t.height()>=b&&y<=b+w.height()&&x+t.width()>=a&&x<=a+w.width()){if(!t.appeared)t.trigger('appear',s.data);}else{t.appeared=false;}};var m=function(){t.appeared=true;if(s.one){w.unbind('scroll',c);var i=$.inArray(c,$.fn.appear.checks);if(i>=0)$.fn.appear.checks.splice(i,1);}f.apply(this,arguments);};if(s.one)t.one('appear',s.data,m);else t.bind('appear',s.data,m);w.scroll(c);$.fn.appear.checks.push(c);(c)();});};$.extend($.fn.appear,{checks:[],timeout:null,checkAll:function(){var l=$.fn.appear.checks.length;if(l>0)while(l--)($.fn.appear.checks[l])();},run:function(){if($.fn.appear.timeout)clearTimeout($.fn.appear.timeout);$.fn.appear.timeout=setTimeout($.fn.appear.checkAll,20);}});$.each(['append','prepend','after','before','attr','removeAttr','addClass','removeClass','toggleClass','remove','css','show','hide'],function(i,n){var u=$.fn[n];if(u){$.fn[n]=function(){var r=u.apply(this,arguments);$.fn.appear.run();return r;}}});})(jQuery);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,288 @@
// Sticky Plugin v1.0.4 for jQuery
// =============
// Author: Anthony Garand
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
// Improvements by Leonardo C. Daronco (daronco)
// Created: 02/14/2011
// Date: 07/20/2015
// Website: http://stickyjs.com/
// Description: Makes an element on the page stick on the screen as you scroll
// It will only set the 'top' and 'position' of your element, you
// might need to adjust the width in some cases.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var slice = Array.prototype.slice; // save ref to original slice()
var splice = Array.prototype.splice; // save ref to original slice()
var defaults = {
topSpacing: 0,
bottomSpacing: 0,
className: 'is-sticky',
wrapperClassName: 'sticky-wrapper',
center: false,
getWidthFrom: '',
widthFromWrapper: true, // works only when .getWidthFrom is empty
responsiveWidth: false,
zIndex: 'inherit'
},
$window = $(window),
$document = $(document),
sticked = [],
windowHeight = $window.height(),
scroller = function() {
var scrollTop = $window.scrollTop(),
documentHeight = $document.height(),
dwh = documentHeight - windowHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
for (var i = 0, l = sticked.length; i < l; i++) {
var s = sticked[i],
elementTop = s.stickyWrapper.offset().top,
etse = elementTop - s.topSpacing - extra;
//update height in case of dynamic content
s.stickyWrapper.css('height', s.stickyElement.outerHeight());
if (scrollTop <= etse) {
if (s.currentTop !== null) {
s.stickyElement
.css({
'width': '',
'position': '',
'top': '',
'z-index': ''
});
s.stickyElement.parent().removeClass(s.className);
s.stickyElement.trigger('sticky-end', [s]);
s.currentTop = null;
}
}
else {
var newTop = documentHeight - s.stickyElement.outerHeight()
- s.topSpacing - s.bottomSpacing - scrollTop - extra;
if (newTop < 0) {
newTop = newTop + s.topSpacing;
} else {
newTop = s.topSpacing;
}
if (s.currentTop !== newTop) {
var newWidth;
if (s.getWidthFrom) {
padding = s.stickyElement.innerWidth() - s.stickyElement.width();
newWidth = $(s.getWidthFrom).width() - padding || null;
} else if (s.widthFromWrapper) {
newWidth = s.stickyWrapper.width();
}
if (newWidth == null) {
newWidth = s.stickyElement.width();
}
s.stickyElement
.css('width', newWidth)
.css('position', 'fixed')
.css('top', newTop)
.css('z-index', s.zIndex);
s.stickyElement.parent().addClass(s.className);
if (s.currentTop === null) {
s.stickyElement.trigger('sticky-start', [s]);
} else {
// sticky is started but it have to be repositioned
s.stickyElement.trigger('sticky-update', [s]);
}
if (s.currentTop === s.topSpacing && s.currentTop > newTop || s.currentTop === null && newTop < s.topSpacing) {
// just reached bottom || just started to stick but bottom is already reached
s.stickyElement.trigger('sticky-bottom-reached', [s]);
} else if(s.currentTop !== null && newTop === s.topSpacing && s.currentTop < newTop) {
// sticky is started && sticked at topSpacing && overflowing from top just finished
s.stickyElement.trigger('sticky-bottom-unreached', [s]);
}
s.currentTop = newTop;
}
// Check if sticky has reached end of container and stop sticking
var stickyWrapperContainer = s.stickyWrapper.parent();
var unstick = (s.stickyElement.offset().top + s.stickyElement.outerHeight() >= stickyWrapperContainer.offset().top + stickyWrapperContainer.outerHeight()) && (s.stickyElement.offset().top <= s.topSpacing);
if( unstick ) {
s.stickyElement
.css('position', 'absolute')
.css('top', '')
.css('bottom', 0)
.css('z-index', '');
} else {
s.stickyElement
.css('position', 'fixed')
.css('top', newTop)
.css('bottom', '')
.css('z-index', s.zIndex);
}
}
}
},
resizer = function() {
windowHeight = $window.height();
for (var i = 0, l = sticked.length; i < l; i++) {
var s = sticked[i];
var newWidth = null;
if (s.getWidthFrom) {
if (s.responsiveWidth) {
newWidth = $(s.getWidthFrom).width();
}
} else if(s.widthFromWrapper) {
newWidth = s.stickyWrapper.width();
}
if (newWidth != null) {
s.stickyElement.css('width', newWidth);
}
}
},
methods = {
init: function(options) {
return this.each(function() {
var o = $.extend({}, defaults, options);
var stickyElement = $(this);
var stickyId = stickyElement.attr('id');
var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName;
var wrapper = $('<div></div>')
.attr('id', wrapperId)
.addClass(o.wrapperClassName);
stickyElement.wrapAll(function() {
if ($(this).parent("#" + wrapperId).length == 0) {
return wrapper;
}
});
var stickyWrapper = stickyElement.parent();
if (o.center) {
stickyWrapper.css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
}
if (stickyElement.css("float") === "right") {
stickyElement.css({"float":"none"}).parent().css({"float":"right"});
}
o.stickyElement = stickyElement;
o.stickyWrapper = stickyWrapper;
o.currentTop = null;
sticked.push(o);
methods.setWrapperHeight(this);
methods.setupChangeListeners(this);
});
},
setWrapperHeight: function(stickyElement) {
var element = $(stickyElement);
var stickyWrapper = element.parent();
if (stickyWrapper) {
stickyWrapper.css('height', element.outerHeight());
}
},
setupChangeListeners: function(stickyElement) {
if (window.MutationObserver) {
var mutationObserver = new window.MutationObserver(function(mutations) {
if (mutations[0].addedNodes.length || mutations[0].removedNodes.length) {
methods.setWrapperHeight(stickyElement);
}
});
mutationObserver.observe(stickyElement, {subtree: true, childList: true});
} else {
if (window.addEventListener) {
stickyElement.addEventListener('DOMNodeInserted', function() {
methods.setWrapperHeight(stickyElement);
}, false);
stickyElement.addEventListener('DOMNodeRemoved', function() {
methods.setWrapperHeight(stickyElement);
}, false);
} else if (window.attachEvent) {
stickyElement.attachEvent('onDOMNodeInserted', function() {
methods.setWrapperHeight(stickyElement);
});
stickyElement.attachEvent('onDOMNodeRemoved', function() {
methods.setWrapperHeight(stickyElement);
});
}
}
},
update: scroller,
unstick: function(options) {
return this.each(function() {
var that = this;
var unstickyElement = $(that);
var removeIdx = -1;
var i = sticked.length;
while (i-- > 0) {
if (sticked[i].stickyElement.get(0) === that) {
splice.call(sticked,i,1);
removeIdx = i;
}
}
if(removeIdx !== -1) {
unstickyElement.unwrap();
unstickyElement
.css({
'width': '',
'position': '',
'top': '',
'float': '',
'z-index': ''
})
;
}
});
}
};
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
if (window.addEventListener) {
window.addEventListener('scroll', scroller, false);
window.addEventListener('resize', resizer, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', scroller);
window.attachEvent('onresize', resizer);
}
$.fn.sticky = function(method) {
if (methods[method]) {
return methods[method].apply(this, slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.init.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$.fn.unstick = function(method) {
if (methods[method]) {
return methods[method].apply(this, slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.unstick.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$(function() {
setTimeout(scroller, 0);
});
}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long