JAVASCRIPT   19

bootstrap tab

Guest on 3rd May 2022 02:37:09 AM

  1. ========================================================
  2.  * bootstrap-tab.js v2.2.2
  3.  * http://twitter.github.com/bootstrap/javascript.html#tabs
  4.  * ========================================================
  5.  * Copyright  Twitter, Inc.
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  * http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  * ======================================================== */
  19.  
  20.  
  21. !function ($) {
  22.  
  23.   "use strict"; // jshint ;_;
  24.  
  25.  
  26.  /* TAB CLASS DEFINITION
  27.   * ==================== */
  28.  
  29.   var Tab = function (element) {
  30.     this.element = $(element)
  31.   }
  32.  
  33.   Tab.prototype = {
  34.  
  35.     constructor: Tab
  36.  
  37.   , show: function () {
  38.       var $this = this.element
  39.         , $ul = $this.closest('ul:not(.dropdown-menu)')
  40.         , selector = $this.attr('data-target')
  41.         , previous
  42.         , $target
  43.         , e
  44.  
  45.       if (!selector) {
  46.         selector = $this.attr('href')
  47.         selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  48.       }
  49.  
  50.       if ( $this.parent('li').hasClass('active') ) return
  51.  
  52.       previous = $ul.find('.active:last a')[0]
  53.  
  54.       e = $.Event('show', {
  55.         relatedTarget: previous
  56.       })
  57.  
  58.       $this.trigger(e)

Raw Paste


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