topical media & game development
mobile-query-three-www-vendor-bootstrap-js-bootstrap-carousel.js / js
/* ==========================================================
* bootstrap-carousel.js v2.0.0
* http://twitter.github.com/bootstrap/javascript.html#carousel
* ==========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function( element = element
this.options = .fn.carousel.defaults, options)
this.options.slide && this.slide(this.options.slide)
}
Carousel.prototype = {
cycle: function () {
this.interval = setInterval(active = this.active.parent().children()
, activePos = children.index(element.one('slid', function () {
that.to(pos)
})
}
if (activePos == pos) {
return this.pause().cycle()
}
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
}
, pause: function () {
clearInterval(this.interval)
return this
}
, next: function () {
if (this.sliding) return
return this.slide('next')
}
, prev: function () {
if (this.sliding) return
return this.slide('prev')
}
, slide: function (type, next) {
var element.find('.active')
, active[type]()
, isCycling = this.interval
, direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last'
, that = this
this.sliding = true
isCycling && this.pause()
next.length ? element.find('.item')[fallback]()
if (!element.hasClass('slide')) {
this.active.removeClass('active')
element.trigger('slid')
} else {
next[0].offsetWidth // force reflow
next.addClass(direction)
this.element.one(next.removeClass([type, direction].join(' ')).addClass('active')
element.trigger('slid') }, 0)
})
}
isCycling && this.cycle()
return this
}
}
/* CAROUSEL PLUGIN DEFINITION
* ========================== */
this = this
, data = this.data('carousel', (data = new Carousel(this, options)))
if (typeof option == 'number') data.to(option)
else if (typeof option == 'string' || (option = options.slide)) data[option]()
else data.cycle()
})
}
.fn.carousel.Constructor = Carousel
/* CAROUSEL DATA-API
* ================= */
$(function () {
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
var target = $(this.attr('href')) && href.replace(/.*(?=#[^\s]+target.data('modal') && target.data(), target.carousel(options)
e.preventDefault()
})
})
}( window.jQuery )
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.