mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-15 07:46:06 +10:00
Merge pull request #2233 from jsor/jcarousel
[author] Add jcarousel 0.3.0
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
$.jCarousel.plugin('jcarouselAutoscroll', {
|
||||
_options: {
|
||||
target: '+=1',
|
||||
interval: 3000,
|
||||
autostart: true
|
||||
},
|
||||
_timer: null,
|
||||
_init: function () {
|
||||
this.onDestroy = $.proxy(function() {
|
||||
this._destroy();
|
||||
this.carousel()
|
||||
.one('jcarousel:createend', $.proxy(this._create, this));
|
||||
}, this);
|
||||
|
||||
this.onAnimateEnd = $.proxy(this.start, this);
|
||||
},
|
||||
_create: function() {
|
||||
this.carousel()
|
||||
.one('jcarousel:destroy', this.onDestroy);
|
||||
|
||||
if (this.options('autostart')) {
|
||||
this.start();
|
||||
}
|
||||
},
|
||||
_destroy: function() {
|
||||
this.stop();
|
||||
this.carousel()
|
||||
.off('jcarousel:destroy', this.onDestroy);
|
||||
},
|
||||
start: function() {
|
||||
this.stop();
|
||||
|
||||
this.carousel()
|
||||
.one('jcarousel:animateend', this.onAnimateEnd);
|
||||
|
||||
this._timer = setTimeout($.proxy(function() {
|
||||
this.carousel().jcarousel('scroll', this.options('target'));
|
||||
}, this), this.options('interval'));
|
||||
|
||||
return this;
|
||||
},
|
||||
stop: function() {
|
||||
if (this._timer) {
|
||||
this._timer = clearTimeout(this._timer);
|
||||
}
|
||||
|
||||
this.carousel()
|
||||
.off('jcarousel:animateend', this.onAnimateEnd);
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,4 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function(t){"use strict";t.jCarousel.plugin("jcarouselAutoscroll",{_options:{target:"+=1",interval:3e3,autostart:!0},_timer:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onAnimateEnd=t.proxy(this.start,this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy),this.options("autostart")&&this.start()},_destroy:function(){this.stop(),this.carousel().off("jcarousel:destroy",this.onDestroy)},start:function(){return this.stop(),this.carousel().one("jcarousel:animateend",this.onAnimateEnd),this._timer=setTimeout(t.proxy(function(){this.carousel().jcarousel("scroll",this.options("target"))},this),this.options("interval")),this},stop:function(){return this._timer&&(this._timer=clearTimeout(this._timer)),this.carousel().off("jcarousel:animateend",this.onAnimateEnd),this}})})(jQuery);
|
||||
@@ -0,0 +1,76 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
$.jCarousel.plugin('jcarouselControl', {
|
||||
_options: {
|
||||
target: '+=1',
|
||||
event: 'click',
|
||||
method: 'scroll'
|
||||
},
|
||||
_active: null,
|
||||
_init: function() {
|
||||
this.onDestroy = $.proxy(function() {
|
||||
this._destroy();
|
||||
this.carousel()
|
||||
.one('jcarousel:createend', $.proxy(this._create, this));
|
||||
}, this);
|
||||
this.onReload = $.proxy(this._reload, this);
|
||||
this.onEvent = $.proxy(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var method = this.options('method');
|
||||
|
||||
if ($.isFunction(method)) {
|
||||
method.call(this);
|
||||
} else {
|
||||
this.carousel()
|
||||
.jcarousel(this.options('method'), this.options('target'));
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
_create: function() {
|
||||
this.carousel()
|
||||
.one('jcarousel:destroy', this.onDestroy)
|
||||
.on('jcarousel:reloadend jcarousel:scrollend', this.onReload);
|
||||
|
||||
this._element
|
||||
.on(this.options('event') + '.jcarouselcontrol', this.onEvent);
|
||||
|
||||
this._reload();
|
||||
},
|
||||
_destroy: function() {
|
||||
this._element
|
||||
.off('.jcarouselcontrol', this.onEvent);
|
||||
|
||||
this.carousel()
|
||||
.off('jcarousel:destroy', this.onDestroy)
|
||||
.off('jcarousel:reloadend jcarousel:scrollend', this.onReload);
|
||||
},
|
||||
_reload: function() {
|
||||
var parsed = $.jCarousel.parseTarget(this.options('target')),
|
||||
carousel = this.carousel(),
|
||||
active;
|
||||
|
||||
if (parsed.relative) {
|
||||
active = carousel
|
||||
.jcarousel(parsed.target > 0 ? 'hasNext' : 'hasPrev');
|
||||
} else {
|
||||
var target = typeof parsed.target !== 'object' ?
|
||||
carousel.jcarousel('items').eq(parsed.target) :
|
||||
parsed.target;
|
||||
|
||||
active = carousel.jcarousel('target').index(target) >= 0;
|
||||
}
|
||||
|
||||
if (this._active !== active) {
|
||||
this._trigger(active ? 'active' : 'inactive');
|
||||
this._active = active;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,4 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function(t){"use strict";t.jCarousel.plugin("jcarouselControl",{_options:{target:"+=1",event:"click",method:"scroll"},_active:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onEvent=t.proxy(function(i){i.preventDefault();var s=this.options("method");t.isFunction(s)?s.call(this):this.carousel().jcarousel(this.options("method"),this.options("target"))},this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend jcarousel:scrollend",this.onReload),this._element.on(this.options("event")+".jcarouselcontrol",this.onEvent),this._reload()},_destroy:function(){this._element.off(".jcarouselcontrol",this.onEvent),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend jcarousel:scrollend",this.onReload)},_reload:function(){var i,s=t.jCarousel.parseTarget(this.options("target")),e=this.carousel();if(s.relative)i=e.jcarousel(s.target>0?"hasNext":"hasPrev");else{var r="object"!=typeof s.target?e.jcarousel("items").eq(s.target):s.target;i=e.jcarousel("target").index(r)>=0}return this._active!==i&&(this._trigger(i?"active":"inactive"),this._active=i),this}})})(jQuery);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,185 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
$.jCarousel.plugin('jcarouselPagination', {
|
||||
_options: {
|
||||
perPage: null,
|
||||
item: function(page) {
|
||||
return '<a href="#' + page + '">' + page + '</a>';
|
||||
},
|
||||
event: 'click',
|
||||
method: 'scroll'
|
||||
},
|
||||
_pages: {},
|
||||
_items: {},
|
||||
_currentPage: null,
|
||||
_init: function() {
|
||||
this.onDestroy = $.proxy(function() {
|
||||
this._destroy();
|
||||
this.carousel()
|
||||
.one('jcarousel:createend', $.proxy(this._create, this));
|
||||
}, this);
|
||||
this.onReload = $.proxy(this._reload, this);
|
||||
this.onScroll = $.proxy(this._update, this);
|
||||
},
|
||||
_create: function() {
|
||||
this.carousel()
|
||||
.one('jcarousel:destroy', this.onDestroy)
|
||||
.on('jcarousel:reloadend', this.onReload)
|
||||
.on('jcarousel:scrollend', this.onScroll);
|
||||
|
||||
this._reload();
|
||||
},
|
||||
_destroy: function() {
|
||||
this._clear();
|
||||
|
||||
this.carousel()
|
||||
.off('jcarousel:destroy', this.onDestroy)
|
||||
.off('jcarousel:reloadend', this.onReload)
|
||||
.off('jcarousel:scrollend', this.onScroll);
|
||||
},
|
||||
_reload: function() {
|
||||
var perPage = this.options('perPage');
|
||||
|
||||
this._pages = {};
|
||||
this._items = {};
|
||||
|
||||
// Calculate pages
|
||||
if ($.isFunction(perPage)) {
|
||||
perPage = perPage.call(this);
|
||||
}
|
||||
|
||||
if (perPage == null) {
|
||||
this._pages = this._calculatePages();
|
||||
} else {
|
||||
var pp = parseInt(perPage, 10) || 0,
|
||||
items = this.carousel().jcarousel('items'),
|
||||
page = 1,
|
||||
i = 0,
|
||||
curr;
|
||||
|
||||
while (true) {
|
||||
curr = items.eq(i++);
|
||||
|
||||
if (curr.length === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!this._pages[page]) {
|
||||
this._pages[page] = curr;
|
||||
} else {
|
||||
this._pages[page] = this._pages[page].add(curr);
|
||||
}
|
||||
|
||||
if (i % pp === 0) {
|
||||
page++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._clear();
|
||||
|
||||
var self = this,
|
||||
carousel = this.carousel().data('jcarousel'),
|
||||
element = this._element,
|
||||
item = this.options('item');
|
||||
|
||||
$.each(this._pages, function(page, carouselItems) {
|
||||
var currItem = self._items[page] = $(item.call(self, page, carouselItems));
|
||||
|
||||
currItem.on(self.options('event') + '.jcarouselpagination', $.proxy(function() {
|
||||
var target = carouselItems.eq(0);
|
||||
|
||||
// If circular wrapping enabled, ensure correct scrolling direction
|
||||
if (carousel.circular) {
|
||||
var currentIndex = carousel.index(carousel.target()),
|
||||
newIndex = carousel.index(target);
|
||||
|
||||
if (parseFloat(page) > parseFloat(self._currentPage)) {
|
||||
if (newIndex < currentIndex) {
|
||||
target = '+=' + (carousel.items().length - currentIndex + newIndex);
|
||||
}
|
||||
} else {
|
||||
if (newIndex > currentIndex) {
|
||||
target = '-=' + (currentIndex + (carousel.items().length - newIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
carousel[this.options('method')](target);
|
||||
}, self));
|
||||
|
||||
element.append(currItem);
|
||||
});
|
||||
|
||||
this._update();
|
||||
},
|
||||
_update: function() {
|
||||
var target = this.carousel().jcarousel('target'),
|
||||
currentPage;
|
||||
|
||||
$.each(this._pages, function(page, carouselItems) {
|
||||
carouselItems.each(function() {
|
||||
if (target.is(this)) {
|
||||
currentPage = page;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (currentPage) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (this._currentPage !== currentPage) {
|
||||
this._trigger('inactive', this._items[this._currentPage]);
|
||||
this._trigger('active', this._items[currentPage]);
|
||||
}
|
||||
|
||||
this._currentPage = currentPage;
|
||||
},
|
||||
items: function() {
|
||||
return this._items;
|
||||
},
|
||||
_clear: function() {
|
||||
this._element.empty();
|
||||
this._currentPage = null;
|
||||
},
|
||||
_calculatePages: function() {
|
||||
var carousel = this.carousel().data('jcarousel'),
|
||||
items = carousel.items(),
|
||||
clip = carousel.clipping(),
|
||||
wh = 0,
|
||||
idx = 0,
|
||||
page = 1,
|
||||
pages = {},
|
||||
curr;
|
||||
|
||||
while (true) {
|
||||
curr = items.eq(idx++);
|
||||
|
||||
if (curr.length === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pages[page]) {
|
||||
pages[page] = curr;
|
||||
} else {
|
||||
pages[page] = pages[page].add(curr);
|
||||
}
|
||||
|
||||
wh += carousel.dimension(curr);
|
||||
|
||||
if (wh >= clip) {
|
||||
page++;
|
||||
wh = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return pages;
|
||||
}
|
||||
});
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,4 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function(t){"use strict";t.jCarousel.plugin("jcarouselPagination",{_options:{perPage:null,item:function(t){return'<a href="#'+t+'">'+t+"</a>"},event:"click",method:"scroll"},_pages:{},_items:{},_currentPage:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onScroll=t.proxy(this._update,this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend",this.onReload).on("jcarousel:scrollend",this.onScroll),this._reload()},_destroy:function(){this._clear(),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend",this.onReload).off("jcarousel:scrollend",this.onScroll)},_reload:function(){var i=this.options("perPage");if(this._pages={},this._items={},t.isFunction(i)&&(i=i.call(this)),null==i)this._pages=this._calculatePages();else for(var s,e=parseInt(i,10)||0,r=this.carousel().jcarousel("items"),n=1,o=0;;){if(s=r.eq(o++),0===s.length)break;this._pages[n]=this._pages[n]?this._pages[n].add(s):s,0===o%e&&n++}this._clear();var l=this,a=this.carousel().data("jcarousel"),h=this._element,c=this.options("item");t.each(this._pages,function(i,s){var e=l._items[i]=t(c.call(l,i,s));e.on(l.options("event")+".jcarouselpagination",t.proxy(function(){var t=s.eq(0);if(a.circular){var e=a.index(a.target()),r=a.index(t);parseFloat(i)>parseFloat(l._currentPage)?e>r&&(t="+="+(a.items().length-e+r)):r>e&&(t="-="+(e+(a.items().length-r)))}a[this.options("method")](t)},l)),h.append(e)}),this._update()},_update:function(){var i,s=this.carousel().jcarousel("target");t.each(this._pages,function(t,e){return e.each(function(){return s.is(this)?(i=t,!1):void 0}),i?!1:void 0}),this._currentPage!==i&&(this._trigger("inactive",this._items[this._currentPage]),this._trigger("active",this._items[i])),this._currentPage=i},items:function(){return this._items},_clear:function(){this._element.empty(),this._currentPage=null},_calculatePages:function(){for(var t,i=this.carousel().data("jcarousel"),s=i.items(),e=i.clipping(),r=0,n=0,o=1,l={};;){if(t=s.eq(n++),0===t.length)break;l[o]=l[o]?l[o].add(t):t,r+=i.dimension(t),r>=e&&(o++,r=0)}return l}})})(jQuery);
|
||||
@@ -0,0 +1,63 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
$.jcarousel.fn.scrollIntoView = function(target, animate, callback) {
|
||||
var parsed = $.jCarousel.parseTarget(target),
|
||||
first = this.index(this._fullyvisible.first()),
|
||||
last = this.index(this._fullyvisible.last()),
|
||||
index;
|
||||
|
||||
if (parsed.relative) {
|
||||
index = parsed.target < 0 ? Math.max(0, first + parsed.target) : last + parsed.target;
|
||||
} else {
|
||||
index = typeof parsed.target !== 'object' ? parsed.target : this.index(parsed.target);
|
||||
}
|
||||
|
||||
if (index < first) {
|
||||
return this.scroll(index, animate, callback);
|
||||
}
|
||||
|
||||
if (index >= first && index <= last) {
|
||||
if ($.isFunction(callback)) {
|
||||
callback.call(this, false);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
var items = this.items(),
|
||||
clip = this.clipping(),
|
||||
lrb = this.vertical ? 'bottom' : (this.rtl ? 'left' : 'right'),
|
||||
wh = 0,
|
||||
curr;
|
||||
|
||||
while (true) {
|
||||
curr = items.eq(index);
|
||||
|
||||
if (curr.length === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
wh += this.dimension(curr);
|
||||
|
||||
if (wh >= clip) {
|
||||
var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
|
||||
if ((wh - margin) !== clip) {
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (index <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
index--;
|
||||
}
|
||||
|
||||
return this.scroll(index, animate, callback);
|
||||
};
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,4 @@
|
||||
/*! jCarousel - v0.3.0 - 2013-11-22
|
||||
* http://sorgalla.com/jcarousel
|
||||
* Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
|
||||
(function(t){"use strict";t.jcarousel.fn.scrollIntoView=function(i,s,e){var r,n=t.jCarousel.parseTarget(i),l=this.index(this._fullyvisible.first()),o=this.index(this._fullyvisible.last());if(r=n.relative?0>n.target?Math.max(0,l+n.target):o+n.target:"object"!=typeof n.target?n.target:this.index(n.target),l>r)return this.scroll(r,s,e);if(r>=l&&o>=r)return t.isFunction(e)&&e.call(this,!1),this;for(var a,h=this.items(),u=this.clipping(),c=this.vertical?"bottom":this.rtl?"left":"right",f=0;;){if(a=h.eq(r),0===a.length)break;if(f+=this.dimension(a),f>=u){var d=parseFloat(a.css("margin-"+c))||0;f-d!==u&&r++;break}if(0>=r)break;r--}return this.scroll(r,s,e)}})(jQuery);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "jcarousel",
|
||||
"filename": "jquery.jcarousel.min.js",
|
||||
"version": "0.3.0",
|
||||
"description": "jCarousel is a jQuery plugin for controlling a list of items in horizontal or vertical order. It provides a full-featured and flexible toolset for navigating any HTML based content in a carousel-like fashion.",
|
||||
"homepage": "http://sorgalla.com/jcarousel/",
|
||||
"keywords": [
|
||||
"carousel",
|
||||
"slideshow",
|
||||
"animation"
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Jan Sorgalla",
|
||||
"web": "http://sorgalla.com"
|
||||
}
|
||||
],
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/jsor/jcarousel.git"
|
||||
}
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/jsor/jcarousel/master/LICENSE"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user