JAVASCRIPT   71
tabulous js
Guest on 8th March 2023 12:32:27 PM


  1. /*!
  2.  * strength.js
  3.  * Original author: @aaronlumsden
  4.  * Further changes, comments: @aaronlumsden
  5.  * Licensed under the MIT license
  6.  */
  7. ;(function ( $, window, document, undefined ) {
  8.  
  9.     var pluginName = "tabulous",
  10.         defaults = {
  11.             effect: 'scale'
  12.         };
  13.  
  14.        // $('<style>body { background-color: red; color: white; }</style>').appendTo('head');
  15.  
  16.     function Plugin( element, options ) {
  17.         this.element = element;
  18.         this.$elem = $(this.element);
  19.         this.options = $.extend( {}, defaults, options );
  20.         this._defaults = defaults;
  21.         this._name = pluginName;
  22.         this.init();
  23.     }
  24.  
  25.     Plugin.prototype = {
  26.  
  27.         init: function() {
  28.  
  29.             var links = this.$elem.find('a');
  30.             var firstchild = this.$elem.find('li:first-child').find('a');
  31.             var lastchild = this.$elem.find('li:last-child').after('<span class="tabulousclear"></span>');
  32.  
  33.             if (this.options.effect == 'scale') {
  34.              tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hidescale');
  35.             } else if (this.options.effect == 'slideLeft') {
  36.                  tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hideleft');
  37.             } else if (this.options.effect == 'scaleUp') {
  38.                  tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hidescaleup');
  39.             } else if (this.options.effect == 'flip') {
  40.                  tab_content = this.$elem.find('div').not(':first').not(':nth-child(1)').addClass('hideflip');
  41.             }
  42.  
  43.             var firstdiv = this.$elem.find('#tabs_container');
  44.             var firstdivheight = firstdiv.find('div:first').height();
  45.  
  46.             var alldivs = this.$elem.find('div:first').find('div');
  47.  
  48.             alldivs.css({'position': 'absolute','top':'40px'});
  49.  
  50.             firstdiv.css('height',firstdivheight+'px');
  51.  
  52.             firstchild.addClass('tabulous_active');
  53.  
  54.             links.bind('click', {myOptions: this.options}, function(e) {
  55.                 e.preventDefault();
  56.  
  57.                 var $options = e.data.myOptions;
  58.                 var effect = $options.effect;
  59.  
  60.                 var mythis = $(this);
  61.                 var thisform = mythis.parent().parent().parent();
  62.                 var thislink = mythis.attr('href');
  63.  
  64.  
  65.                 firstdiv.addClass('transition');
  66.  
  67.                 links.removeClass('tabulous_active');
  68.                 mythis.addClass('tabulous_active');
  69.                 thisdivwidth = thisform.find('div'+thislink).height();
  70.  
  71.                 if (effect == 'scale') {
  72.                     alldivs.removeClass('showscale').addClass('make_transist').addClass('hidescale');
  73.                     thisform.find('div'+thislink).addClass('make_transist').addClass('showscale');
  74.                 } else if (effect == 'slideLeft') {
  75.                     alldivs.removeClass('showleft').addClass('make_transist').addClass('hideleft');
  76.                     thisform.find('div'+thislink).addClass('make_transist').addClass('showleft');
  77.                 } else if (effect == 'scaleUp') {
  78.                     alldivs.removeClass('showscaleup').addClass('make_transist').addClass('hidescaleup');
  79.                     thisform.find('div'+thislink).addClass('make_transist').addClass('showscaleup');
  80.                 } else if (effect == 'flip') {
  81.                     alldivs.removeClass('showflip').addClass('make_transist').addClass('hideflip');
  82.                     thisform.find('div'+thislink).addClass('make_transist').addClass('showflip');
  83.                 }
  84.  
  85.  
  86.                 firstdiv.css('height',thisdivwidth+'px');
  87.  
  88.                
  89.  
  90.  
  91.             });
  92.  
  93.            
  94.  
  95.  
  96.          
  97.            
  98.         },
  99.  
  100.         yourOtherFunction: function(el, options) {
  101.             // some logic
  102.         }
  103.     };
  104.  
  105.     // A really lightweight plugin wrapper around the constructor,
  106.     // preventing against multiple instantiations
  107.     $.fn[pluginName] = function ( options ) {
  108.         return this.each(function () {
  109.             new Plugin( this, options );
  110.         });
  111.     };
  112. })( jQuery, window, document );

Raw Paste

Login or Register to edit or fork this paste. It's free.