1!function ($) { 2 "use strict"; 3 var JCarousel = function (element, options) { 4 this.$element = $(element) 5 this.options = options 6 this.options.jslide && this.slide(this.options.jslide) 7 this.options.pause == 'hover' && this.$element.on('mouseenter', $.proxy(this.pause, this)).on('mouseleave', $.proxy(this.cycle, this)) 8 this.transition = (function () { 9 var transitionEnd = (function () { 10 var el = document.createElement('bootstrap'), 11 transEndEventNames = { 12 'WebkitTransition' : 'webkitTransitionEnd', 13 'MozTransition' : 'transitionend', 14 'OTransition' : 'oTransitionEnd otransitionend', 15 'transition' : 'transitionend' 16 }, 17 name 18 for (name in transEndEventNames) { 19 if (el.style[name] !== undefined) { 20 return transEndEventNames[name] 21 } 22 } 23 }()) 24 return transitionEnd && { 25 end : transitionEnd 26 } 27 })() 28 } 29 30 JCarousel.prototype = { 31 cycle : function (e) { 32 if (!e) 33 this.paused = false 34 this.options.interval && !this.paused && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) 35 return this 36 }, 37 to : function (pos) { 38 var $active = this.$element.find('.item.active'), 39 children = $active.parent().children(), 40 activePos = children.index($active), 41 that = this 42 if (pos > (children.length - 1) || pos < 0) return 43 if (this.sliding) { 44 return this.$element.one('jslid', function () { 45 that.to(pos) 46 }) 47 } 48 if (activePos == pos) { 49 return this.pause().cycle() 50 } 51 return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos])) 52 }, 53 pause : function (e) { 54 if (!e) this.paused = true 55 if (this.$element.find('.next, .prev').length && this.transition.end) {} 56 clearInterval(this.interval) 57 this.interval = null 58 return this 59 }, 60 next : function () { 61 if (this.sliding) return 62 return this.slide('next') 63 }, 64 prev : function () { 65 if (this.sliding) return 66 return this.slide('prev') 67 }, 68 slide : function (type, next) { 69 var $active = this.$element.find('.item.active'), 70 $next = next || $active[type](), 71 isCycling = this.interval, 72 direction = type == 'next' ? 'left' : 'right', 73 fallback = type == 'next' ? 'first' : 'last', 74 that = this 75 76 this.sliding = true 77 isCycling && this.pause() 78 $next = $next.length ? $next : this.$element.find('.item')[fallback]() 79 if ($next.hasClass('active')) return 80 var e = $.Event('jslide', { 81 relatedTarget : $next[0] 82 }) 83 if (this.transition && this.$element.hasClass('slide')) { 84 this.$element.trigger(e) 85 if (e.isDefaultPrevented()) return 86 $next.addClass(type) 87 $next[0].offsetWidth 88 $active.addClass(direction) 89 $next.addClass(direction) 90 this.$element.one(this.transition.end, function () { 91 $next.removeClass([type, direction].join(' ')).addClass('active') 92 $active.removeClass(['active', direction].join(' ')) 93 that.sliding = false 94 setTimeout(function () { 95 that.$element.trigger('jslid') 96 }, 0) 97 }) 98 } else { 99 this.$element.trigger(e) 100 if (e.isDefaultPrevented()) return 101 if (this.options.pager){ $(this.options.pager).removeClass('sel').eq( $next.index() ).addClass('sel'); } 102 var that = this, end = 0, endFn = function () { 103 $active.removeClass('active') 104 $next.addClass('active') 105 $active.attr('style', null) 106 $next.attr('style', null) 107 that.sliding = false 108 that.$element.trigger('jslid') 109 }, 110 chk4end = function () { 111 end++; 112 if (end == 2) { 113 endFn(); 114 } 115 }, 116 nextCss = { 117 display : 'block', 118 width : '100%', 119 position : 'absolute', 120 top : 0, 121 left : '100%' 122 }, 123 nextOpt = { 124 left : '0' 125 }, 126 actiOpt = { 127 left : '-100%' 128 }, 129 commOpt = { 130 duration : 800, 131 complete : chk4end 132 }; 133 if (this.$element.hasClass('slide')) { 134 if (type == 'prev') { 135 nextCss.left = '-100%'; 136 actiOpt.left = '100%'; 137 } else if (type == 'next') {} 138 139 } else { 140 nextCss.left = 0; 141 nextCss.opacity = 0; 142 nextOpt = { 143 opacity : 1 144 } 145 actiOpt = { 146 opacity : 0 147 } 148 } 149 $next.css(nextCss).animate(nextOpt, commOpt); 150 $active.animate(actiOpt, commOpt); 151 } 152 isCycling && this.cycle() 153 return this 154 } 155 } 156
157 $.fn.jcarousel = function (option) { 158 return this.each(function () { 159 var $this = $(this), 160 data = $this.data('jcarousel'), 161 options = $.extend({}, $.fn.jcarousel.defaults, typeof option == 'object' && option), 162 action = typeof option == 'string' ? option : options.jslide 163 if (!data) $this.data('jcarousel', (data = new JCarousel(this, options))) 164 if (typeof action == 'number') data.to(action) 165 else if (action) data[action]() 166 else if (options.interval) data.cycle() 167 }) 168 } 169 170 $.fn.jcarousel.defaults = { 171 interval : 5000, 172 pause : 'hover' 173 } 174 175 $.fn.jcarousel.Constructor = JCarousel 176 177 $(function () { 178 $('body').on('click.jcarousel.data-api', '[data-jslide]', function (e) { 179 var $this = $(this), href, 180 $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')), 181 options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) 182 $target.jcarousel(options) 183 e.preventDefault() 184 }); 185 $('[data-start-jcarousel]').each(function(){ 186 var $this = $(this); 187 //console.log('start'); 188 $this.jcarousel(); 189 $this.bind('jslide', function(e){ 190 var index = $(this).find(e.relatedTarget).index(); 191 $('[data-jslide]').each(function(){ 192 var $nav = $(this), $navData = $nav.data(), href, $target = $($nav.attr('data-target') || (href = $nav.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')); 193 if ( !$target.is($this) ) return; 194 if (typeof $navData.jslide == 'number' && $navData.jslide==index){ 195 $nav.addClass('sel'); 196 } else { 197 $nav.removeClass('sel'); 198 } 199 }); 200 }); 201 }); 202 }) 203}(window.jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.