1/*--------------------------------------------------------------- 2# SP Tab - Next generation tab module for joomla 3# --------------------------------------------------------------- 4# Author - JoomShaper http://www.joomshaper.com 5# Copyright (C) 2010 - 2014 JoomShaper.com. All Rights Reserved. 6# license - PHP files are licensed under GNU/GPL V2 7# license - CSS - JS - IMAGE files are Copyrighted material 8# Websites: http://www.joomshaper.com 9-----------------------------------------------------------------*/ 10 11// Utility 12if ( typeof Object.create !== 'function' ) { 13 Object.create = function( obj ) { 14 function F() {}; 15 F.prototype = obj; 16 return new F(); 17 }; 18} 19 20!(function($){ 21 22 var spTab = { 23 init: function( options, elem ) { 24 var self = this 25 26 self.elem = elem 27 self.$elem = $( elem ) 28 self.options = $.extend( {}, $.fn.sptab.options, options ) 29 30 self.build() 31 self.display() 32 }, 33 34 build: function() { 35 var self = this 36 37 self.$elem.children().wrapAll('<div class="items_mask" />') 38 var items = self.$elem.find('.items_mask').children() 39 var handlers = self.$elem.find('.title') 40 var button_code = '<div class="tabs_buttons"><div class="tabs_mask"><ul class="tabs_container"></ul></div></div>' 41 42 //generate handlers 43 var tabs_buttons = ( self.options.btnPos == 'top' ) ? self.$elem.prepend( button_code ) : self.$elem.append( button_code ) 44 45 var title = ''; 46 handlers.each(function(index){ 47 this.cls = (index === 0 ) ? 'tab first-tab active' : 'tab' 48 title += '<li class="' + this.cls + '">' 49 title += $(this).html() 50 title += '</li>' 51 }); 52 53 $(tabs_buttons).find('.tabs_container').append( title ) 54 $(items).find('.title').remove() 55 56 }, 57 58 display: function() { 59 var self = this 60 var mask = self.$elem.find('.items_mask') 61 var items = self.$elem.find('.items_mask').children() 62 var handlers = self.$elem.find('.tabs_container').children() 63 var isSliding = false 64 65 items.removeAttr('style').css({ 66 'display': 'none' 67 }).first().css({ 68 'display': 'block' 69 }) 70 71 $(handlers).each( function(index) { 72 73 $(this).on(self.options.activator, function(event) { 74 75 if ( $(this).hasClass('active') ) return 76 77 if ( isSliding == true ) return 78 79 isSliding = true 80 81 this.prevIndex = handlers.filter('.active').index() 82 this.curIndex = $(this).index() 83 84 if( this.curIndex > this.prevIndex ) 85 { 86 this.directtion = 'left' 87 } 88 else 89 { 90 this.directtion = 'right' 91 } 92 93 this.current = $(items)[ this.curIndex ] 94 this.previous = $(items)[ this.prevIndex ] 95 96 handlers.removeClass('active'); 97 $(this.previous).removeClass('active'); 98 $(this.current).addClass('active'); 99 $(this).addClass('active'); 100 101 //Animation fade 102 if( self.options.animation == 'fade' ) 103 { 104 $(mask).animate({ 105 height: $(this.current).outerHeight() 106 }, self.options.duration) 107 108 $( this.previous ).css('display', 'none') 109 $( this.current ).fadeIn( self.options.duration, self.options.transition, function(){ 110 $(mask).removeAttr('style') 111 isSliding = false 112 }) 113 } 114 else if( self.options.animation == 'scroll:horizontal' ) 115 { 116 $(mask).animate({ 117 height: $(this.current).outerHeight() 118 }, self.options.duration) 119 120 $( this.previous ).css({ 121 'display': 'block', 122 'position': 'absolute', 123 'overflow': 'hidden', 124 'top': 0, 125 'left': 0, 126 'width': $(mask).outerWidth(), 127 'height': $( this.previous ).outerHeight() 128 }).animate({ 129 'left': (this.directtion == 'left') ? -$(mask).outerWidth() : $(mask).outerWidth() 130 }, self.options.duration, self.options.transition, function(){ 131 $(this).removeAttr('style').css('display', 'none') 132 isSliding = false 133 }) 134 135 $( this.current ).css({ 136 'display': 'block', 137 'position': 'absolute', 138 'overflow': 'hidden', 139 'top': 0, 140 'left': ( this.directtion == 'left' ) ? $(mask).outerWidth() : -$(mask).outerWidth(), 141 'width': $(mask).outerWidth(), 142 'height': $( this.current ).outerHeight() 143 }).animate({ 144 'left': 0 145 }, self.options.duration, self.options.transition, function(){ 146 $(this).removeAttr('style').css('display', 'block') 147 $(mask).removeAttr('style')
148 isSliding = false 149 }) 150 151 } 152 else if( self.options.animation == 'scroll:vertical' ) 153 { 154 $(mask).css( 'height', $( this.current ).outerHeight() ) 155 156 $( this.previous ).css({ 157 'display': 'block', 158 'position': 'absolute', 159 'overflow': 'hidden', 160 'top': 0, 161 'left': 0, 162 'width': $(mask).outerWidth(), 163 'height': $( this.previous ).outerHeight() 164 }).animate({ 165 'top': ( this.directtion == 'left' ) ? -$( this.previous ).outerHeight() : $( this.previous ).outerHeight() 166 }, self.options.duration, self.options.transition, function(){ 167 $(this).removeAttr('style').css('display', 'none') 168 isSliding = false 169 }); 170 171 $( this.current ).css({ 172 'display': 'block', 173 'position': 'absolute', 174 'overflow': 'hidden', 175 'top': ( this.directtion == 'left' ) ? $( this.current ).outerHeight() : -$( this.current ).outerHeight(), 176 'left': 0, 177 'width': $(mask).outerWidth(), 178 'height': $( this.current ).outerHeight() 179 }).animate({ 180 'top': 0 181 }, self.options.duration, self.options.transition, function(){ 182 $(this).removeAttr('style').css('display', 'block') 183 $(mask).removeAttr('style') 184 isSliding = false 185 }); 186 187 } 188 else 189 { 190 $( this.previous ).css('display', 'none') 191 $( this.current ).css('display', 'block') 192 isSliding = false 193 } 194 195 196 }) 197 }) 198 } 199 } 200 201 $.fn.sptab = function( options ) { 202 return this.each(function() { 203 var sptab = Object.create( spTab ) 204 sptab.init( options, this ) 205 206 }) 207 } 208 209 $.fn.sptab.options = { 210 animation: 'scroll:horizontal', 211 duration: 400, 212 transition: 'linear', 213 btnPos: 'top', 214 activator: 'click' 215 } 216 217})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.