~patrick-hetu/+junk/ptittrain_site

« back to all changes in this revision

Viewing changes to apps/ptittrain/static/bootstrap/docs/assets/js/bootstrap-carousel.js

  • Committer: Patrick Hetu
  • Date: 2012-08-05 23:21:32 UTC
  • Revision ID: patrick.hetu@gmail.com-20120805232132-fryckvbj84wzg3tk
remove unnessesary files and fix static+version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ==========================================================
2
 
 * bootstrap-carousel.js v2.0.2
3
 
 * http://twitter.github.com/bootstrap/javascript.html#carousel
4
 
 * ==========================================================
5
 
 * Copyright 2012 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"
24
 
 
25
 
 /* CAROUSEL CLASS DEFINITION
26
 
  * ========================= */
27
 
 
28
 
  var Carousel = function (element, options) {
29
 
    this.$element = $(element)
30
 
    this.options = $.extend({}, $.fn.carousel.defaults, options)
31
 
    this.options.slide && this.slide(this.options.slide)
32
 
    this.options.pause == 'hover' && this.$element
33
 
      .on('mouseenter', $.proxy(this.pause, this))
34
 
      .on('mouseleave', $.proxy(this.cycle, this))
35
 
  }
36
 
 
37
 
  Carousel.prototype = {
38
 
 
39
 
    cycle: function () {
40
 
      this.interval = setInterval($.proxy(this.next, this), this.options.interval)
41
 
      return this
42
 
    }
43
 
 
44
 
  , to: function (pos) {
45
 
      var $active = this.$element.find('.active')
46
 
        , children = $active.parent().children()
47
 
        , activePos = children.index($active)
48
 
        , that = this
49
 
 
50
 
      if (pos > (children.length - 1) || pos < 0) return
51
 
 
52
 
      if (this.sliding) {
53
 
        return this.$element.one('slid', function () {
54
 
          that.to(pos)
55
 
        })
56
 
      }
57
 
 
58
 
      if (activePos == pos) {
59
 
        return this.pause().cycle()
60
 
      }
61
 
 
62
 
      return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
63
 
    }
64
 
 
65
 
  , pause: function () {
66
 
      clearInterval(this.interval)
67
 
      this.interval = null
68
 
      return this
69
 
    }
70
 
 
71
 
  , next: function () {
72
 
      if (this.sliding) return
73
 
      return this.slide('next')
74
 
    }
75
 
 
76
 
  , prev: function () {
77
 
      if (this.sliding) return
78
 
      return this.slide('prev')
79
 
    }
80
 
 
81
 
  , slide: function (type, next) {
82
 
      var $active = this.$element.find('.active')
83
 
        , $next = next || $active[type]()
84
 
        , isCycling = this.interval
85
 
        , direction = type == 'next' ? 'left' : 'right'
86
 
        , fallback  = type == 'next' ? 'first' : 'last'
87
 
        , that = this
88
 
 
89
 
      this.sliding = true
90
 
 
91
 
      isCycling && this.pause()
92
 
 
93
 
      $next = $next.length ? $next : this.$element.find('.item')[fallback]()
94
 
 
95
 
      if ($next.hasClass('active')) return
96
 
 
97
 
      if (!$.support.transition && this.$element.hasClass('slide')) {
98
 
        this.$element.trigger('slide')
99
 
        $active.removeClass('active')
100
 
        $next.addClass('active')
101
 
        this.sliding = false
102
 
        this.$element.trigger('slid')
103
 
      } else {
104
 
        $next.addClass(type)
105
 
        $next[0].offsetWidth // force reflow
106
 
        $active.addClass(direction)
107
 
        $next.addClass(direction)
108
 
        this.$element.trigger('slide')
109
 
        this.$element.one($.support.transition.end, function () {
110
 
          $next.removeClass([type, direction].join(' ')).addClass('active')
111
 
          $active.removeClass(['active', direction].join(' '))
112
 
          that.sliding = false
113
 
          setTimeout(function () { that.$element.trigger('slid') }, 0)
114
 
        })
115
 
      }
116
 
 
117
 
      isCycling && this.cycle()
118
 
 
119
 
      return this
120
 
    }
121
 
 
122
 
  }
123
 
 
124
 
 
125
 
 /* CAROUSEL PLUGIN DEFINITION
126
 
  * ========================== */
127
 
 
128
 
  $.fn.carousel = function ( option ) {
129
 
    return this.each(function () {
130
 
      var $this = $(this)
131
 
        , data = $this.data('carousel')
132
 
        , options = typeof option == 'object' && option
133
 
      if (!data) $this.data('carousel', (data = new Carousel(this, options)))
134
 
      if (typeof option == 'number') data.to(option)
135
 
      else if (typeof option == 'string' || (option = options.slide)) data[option]()
136
 
      else data.cycle()
137
 
    })
138
 
  }
139
 
 
140
 
  $.fn.carousel.defaults = {
141
 
    interval: 5000
142
 
  , pause: 'hover'
143
 
  }
144
 
 
145
 
  $.fn.carousel.Constructor = Carousel
146
 
 
147
 
 
148
 
 /* CAROUSEL DATA-API
149
 
  * ================= */
150
 
 
151
 
  $(function () {
152
 
    $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
153
 
      var $this = $(this), href
154
 
        , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
155
 
        , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
156
 
      $target.carousel(options)
157
 
      e.preventDefault()
158
 
    })
159
 
  })
160
 
 
161
 
}( window.jQuery );
 
 
b'\\ No newline at end of file'