Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: JavaScript, Created At: 10/24/2016 8:23:27 PMViews:

HTML view:
Copy Source | Copy HTML
  1. $(function(){
  2.     clearInputs();
  3.     jQuery('div.gallery').gallery({
  4.         duration: 700,
  5.         autoRotation: 10000,
  6.         event: 'mouseover',
  7.         listOfSlides: 'ul.gallery-holder > li',
  8.         switcher: 'ul.nav-bar > li',
  9.         effect: true
  10.     });
  11.     jQuery('div.slideshow').gallery({
  12.         duration: 500,
  13.         autoRotation: 5000,
  14.         listOfSlides: 'div.slideshow-holder > ul > li'
  15.     });
  16.     jQuery('div.gallery2').gallery({
  17.         duration: 500,
  18.         infinite:true,
  19.         autoRotation: 5000,
  20.         listOfSlides: 'div.gallery-holder2 > ul > li'
  21.     });
  22.     initTabs();
  23.     openBox();
  24.     jQuery('.simplebox').simplebox();
  25. });
  26. function clearInputs(){
  27.     $('input:text, input:password, textarea').each(function(){
  28.         var _el = $(this);
  29.         var _val = _el.val();
  30.         _el.attr('alt', _val);
  31.         _el.bind('focus', function(){
  32.             if (this.value == _val) {
  33.                 this.value = '';
  34.                 $(this).parent().addClass('ready');
  35.             }
  36.             $(this).parent().addClass('input-focus');
  37.         }).bind('blur', function(){
  38.             if(this.value == '') {
  39.                 this.value = _val;
  40.                 $(this).parent().removeClass('ready');
  41.             }
  42.             $(this).parent().removeClass('input-focus');
  43.         });
  44.     });
  45. }
  46. /**
     * jQuery gallery min v1.1.0
     * Copyright (c) 2011 JetCoders
     * email: yuriy.shpak@jetcoders.com
     * www: JetCoders.com
     * Licensed under the MIT License:
     * http://www.opensource.org/licenses/mit-license.php
     **/
  47. jQuery.fn.gallery=function(options){return new Gallery(this.get( 0),options);};function Gallery(context,options){this.init(context,options);};Gallery.prototype={options:{},init:function(context,options){this.options=jQuery.extend({infinite:false,duration:700,slideElement:1,autoRotation:false,effect:false,listOfSlides:'ul > li',switcher:false,disableBtn:false,nextBtn:'a.link-next, a.btn-next, .next',prevBtn:'a.link-prev, a.btn-prev, .prev',circle:true,direction:false,event:'click',IE:false,autoHeight:false,easing:'swing'},options||{});var _el=jQuery(context).find(this.options.listOfSlides);if(this.options.effect)this.list=_el;else this.list=_el.parent();this.switcher=jQuery(context).find(this.options.switcher);this.nextBtn=jQuery(context).find(this.options.nextBtn);this.prevBtn=jQuery(context).find(this.options.prevBtn);this.count=_el.index(_el.filter(':last'));if(this.options.switcher)this.active=this.switcher.index(this.switcher.filter('.active:eq(0)'));else this.active=_el.index(_el.filter('.active:eq(0)'));if(this.active< 0)this.active= 0;this.last=this.active;this.woh=_el.outerWidth(true);if(!this.options.direction)this.installDirections(this.list.parent().width());else{this.woh=_el.outerHeight(true);this.installDirections(this.list.parent().height());}if(!this.options.effect){this.rew=this.count-this.wrapHolderW+1;this.list.css({position:'relative'}).css(this.dirAnimate());this.switcher.removeClass('active').eq(this.active).addClass('active');}else{this.rew=this.count;this.list.css({opacity: 0}).removeClass('active').eq(this.active).addClass('active').css({opacity:1}).css('opacity','auto');this.switcher.removeClass('active').eq(this.active).addClass('active');if(this.options.autoHeight)this.list.parent().css({height:this.list.eq(this.active).outerHeight()});}this.flag=true;if(this.options.infinite){this.count++;this.active+=this.count;this.list.append(_el.clone());this.list.append(_el.clone());this.list.css(this.dirAnimate());}this.initEvent(this,this.nextBtn,true);this.initEvent(this,this.prevBtn,false);if(this.options.disableBtn)this.initDisableBtn();if(this.options.autoRotation)this.runTimer(this);if(this.options.switcher)this.initEventSwitcher(this,this.switcher);},dirAnimate:function(){if(!this.options.direction)return{left:-(this.woh*this.active)};else return{top:-(this.woh*this.active)};},initDisableBtn:function(){this.prevBtn.removeClass('prev-'+this.options.disableBtn);this.nextBtn.removeClass('next-'+this.options.disableBtn);if(this.active== 0||this.count+1==this.wrapHolderW)this.prevBtn.addClass('prev-'+this.options.disableBtn);if(this.active== 0&&this.count+1==1||this.count+1<=this.wrapHolderW)this.nextBtn.addClass('next-'+this.options.disableBtn);if(this.active==this.rew)this.nextBtn.addClass('next-'+this.options.disableBtn);},installDirections:function(temp){this.wrapHolderW=Math.ceil(temp/this.woh);if(((this.wrapHolderW-1)*this.woh+this.woh/2)>temp)this.wrapHolderW--;if(this.wrapHolderW== 0)this.wrapHolderW=1;},fadeElement:function(){if(jQuery.browser.msie&&this.options.IE){this.list.eq(this.last).css({opacity: 0});this.list.removeClass('active').eq(this.active).addClass('active').css({opacity:'auto'});}else{this.list.eq(this.last).animate({opacity: 0},{queue:false,easing:this.options.easing,duration:this.options.duration});this.list.removeClass('active').eq(this.active).addClass('active').animate({opacity:1},{queue:false,duration:this.options.duration,complete:function(){jQuery(this).css('opacity','auto');}});}if(this.options.autoHeight)this.list.parent().animate({height:this.list.eq(this.active).outerHeight()},{queue:false,duration:this.options.duration});if(this.options.switcher)this.switcher.removeClass('active').eq(this.active).addClass('active');this.last=this.active;},scrollElement:function($this){if(!$this.options.infinite)$this.list.animate($this.dirAnimate(),{queue:false,easing:$this.options.easing,duration:$this.options.duration});else $this.list.animate($this.dirAnimate(),$this.options.duration,$this.options.easing,function(){$this.flag=true});if($this.options.switcher)$this.switcher.removeClass('active').eq($this.active/$this.options.slideElement).addClass('active');},runTimer:function($this){if($this._t)clearTimeout($this._t);$this._t=setInterval(function(){if($this.options.infinite)$this.flag=false;$this.toPrepare($this,true);},this.options.autoRotation);},initEventSwitcher:function($this,el){el.bind($this.options.event,function(){$this.active=$this.switcher.index(jQuery(this))*$this.options.slideElement;if($this._t)clearTimeout($this._t);if($this.options.disableBtn)$this.initDisableBtn();if(!$this.options.effect)$this.scrollElement($this);else $this.fadeElement();if($this.options.autoRotation)$this.runTimer($this);return false;});},initEvent:function($this,addEventEl,dir){addEventEl.bind($this.options.event,function(){if($this.flag){if($this.options.infinite)$this.flag=false;if($this._t)clearTimeout($this._t);$this.toPrepare($this,dir);if($this.options.autoRotation)$this.runTimer($this);}return false;});},toPrepare:function($this,side){if(!$this.options.infinite){if(($this.active==$this.rew)&&$this.options.circle&&side)$this.active=-$this.options.slideElement;if(($this.active== 0)&&$this.options.circle&&!side)$this.active=$this.rew+$this.options.slideElement;for(var i= 0;i<$this.options.slideElement;i++){if(side){if($this.active+1<=$this.rew)$this.active++;}else{if($this.active-1>= 0)$this.active--;}};}else{if($this.active>=$this.count+$this.count&&side)$this.active-=$this.count;if($this.active<=$this.count-1&&!side)$this.active+=$this.count;$this.list.css($this.dirAnimate());if(side)$this.active+=$this.options.slideElement;else $this.active-=$this.options.slideElement;}if(this.options.disableBtn)this.initDisableBtn();if(!$this.options.effect)$this.scrollElement($this);else $this.fadeElement();},stop:function(){if(this._t)clearTimeout(this._t);},play:function(){if(this._t)clearTimeout(this._t);if(this.options.autoRotation)this.runTimer(this);}}
  48. function initTabs()
  49. {
  50.     var sets = document.getElementsByTagName("ul");
  51.     for (var i =  0; i < sets.length; i++)
  52.     {
  53.         if (sets[i].className.indexOf("tabset") != -1)
  54.         {
  55.             var tabs = [];
  56.             var links = sets[i].getElementsByTagName("a");
  57.             for (var j =  0; j < links.length; j++)
  58.             {
  59.                 if (links[j].className.indexOf("tab") != -1)
  60.                 {
  61.                     tabs.push(links[j]);
  62.                     links[j].tabs = tabs;
  63.                     var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));
  64.                     //reset all tabs on start
  65.                     if (c) if (links[j].className.indexOf("active") != -1) c.style.display = "block";
  66.                     else c.style.display = "none";
  67.                     links[j].onclick = function ()
  68.                     {
  69.                         var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
  70.                         if (c)
  71.                         {
  72.                             //reset all tabs before change
  73.                             for (var i =  0; i < this.tabs.length; i++)
  74.                             {
  75.                                 document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1)).style.display = "none";
  76.                                 this.tabs[i].className = this.tabs[i].className.replace("active", "");
  77.                             }
  78.                             this.className += " active";
  79.                             c.style.display = "block";
  80.                             return false;
  81.                         }
  82.                     }
  83.                 }
  84.             }
  85.         }
  86.     }
  87. }
  88. function openBox(){
  89.     $('#sidebar .left-nav > .hold-open').not('.detected').each(function(){
  90.         var hold = $(this);
  91.         var link = hold.find(' > a');
  92.         var box = hold.find(' > .box-slide ');
  93.         hold.addClass('detected');
  94.         link.click(function(){
  95.             if(!hold.hasClass('active')){
  96.                 box.slideDown(300, function(){
  97.                     hold.addClass('active');
  98.                 });
  99.             }
  100.             else{
  101.                 box.slideUp(300, function(){
  102.                     hold.removeClass('active');
  103.                 });
  104.             }
  105.             return false;
  106.         });
  107.     });
  108. }
  109. /**
     * jQuery simplebox min v1.0.0
     * Copyright (c) 2013 JetCoders
     * email: yuriy.shpak@jetcoders.com
     * www: JetCoders.com
     * Licensed under the MIT License:
     * http://www.opensource.org/licenses/mit-license.php
     **/
  110. jQuery.fn.simplebox=function(options){return new Simplebox(this,options);};function Simplebox(context,options){this.init(context,options);};Simplebox.prototype={options:{},init:function(context,options){this.options=jQuery.extend({duration:300,linkClose:'.close, a.btn-close',divFader:'fader',faderColor:'black',overlayClick:true,opacity: 0.3,onOpen:function(){},afterOpen:function(){},onClose:function(){},afterClose:function(){}},options||{});this.btn=jQuery(context);this.select=jQuery('body').find('select');this.flag=true;this.initFader();if(typeof options=='string')this.condition(options);else this.btnEvent(this,this.btn);},btnEvent:function($this,el){el.each(function(){if(!jQuery(this).attr('href'))jQuery(this).attr('link',jQuery(this).attr('title')).attr('title','')});el.unbind('click').click(function(){if(!$(this).hasClass('disabled')){if(jQuery(this).attr('href'))$this.condition(jQuery(this).attr('href'));else $this.condition(jQuery(this).attr('link'));}return false;});},calcWinWidth:function(){this.winWidth=jQuery('body').width();if(jQuery(document).width()>this.winWidth)this.winWidth=jQuery(document).width();},condition:function(obj){if(this.popup){var _this=this;_this.options.onClose();this.popup.fadeOut(this.options.duration,function(){_this.popup.css({left:'-9999px'}).show();_this.fader.unbind('click');_this.btnClose.unbind('click');_this.toPrepare(obj);});}else this.toPrepare(obj);},toPrepare:function(obj){this.popup=jQuery(obj);this.btnClose=this.popup.find(this.options.linkClose);if(jQuery.browser.msie)this.select.css({visibility:'hidden'});this.calcWinWidth();this.winHeight=jQuery(window).height();this.winScroll=jQuery(window).scrollTop();this.popupTop=this.winScroll+(this.winHeight/2)-this.popup.outerHeight(true)/2;if(this.popupTop< 0)this.popupTop= 0;if(this.popupTop+this.popup.outerHeight(true)>jQuery(document).height())this.popupTop=jQuery(document).height()-this.popup.outerHeight(true);this.popup.css({top:this.popupTop,left:this.winWidth/2-this.popup.outerWidth(true)/2}).hide();this.initAnimate(this);this.initCloseEvent(this,this.btnClose);if(this.options.overlayClick)this.initCloseEvent(this,this.fader);},initCloseEvent:function($this,el){el.click(function(){if($this.flag){$this.flag=false;$this.options.onClose();$this.popup.fadeOut($this.options.duration,function(){$this.popup.css({left:'-9999px'}).show();if(jQuery.browser.msie)$this.select.css({visibility:'visible'});$this.fader.unbind('click');$this.btnClose.unbind('click');$this.popup=false;$this.fader.fadeOut($this.options.duration,function(){$this.flag=true;$this.options.afterClose();});});}return false;});},initAnimate:function($this){$this.flag=false;$this.options.onOpen();$this.fader.css({background:$this.options.faderColor,opacity:$this.options.opacity}).fadeIn($this.options.duration,function(){$this.popup.fadeIn($this.options.duration,function(){$this.flag=true;$this.options.afterOpen();});});jQuery(window).resize(function(){if($this.popup.is(':visible')){$this.calcWinWidth();$this.popup.animate({left:$this.winWidth/2-$this.popup.outerWidth(true)/2},{queue:false,duration:$this.options.duration});}});},initFader:function(){if(jQuery('div.'+this.options.divFader).length> 0)this.fader=jQuery('div.'+this.options.divFader);else{this.fader=jQuery('<div class="'+this.options.divFader+'"></div>');jQuery('body').append(this.fader);this.fader.css({position:'fixed',zIndex:999,left: 0,top: 0,width:'100%',height:'100%',background:this.options.faderColor,opacity:this.options.opacity}).hide();}}}

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2018