1// JavaScript Document 2 3//jQuery(document).ready(function () { 4 (function ($, f) { 5 // If there's no jQuery, Unslider can't work, so kill the operation. 6 if (!$) return f; 7 8 var Unslider = function () { 9 // Set up our elements 10 this.el = f; 11 this.items = f; 12 13 // Dimensions 14 this.sizes = []; 15 this.max = [0, 0]; 16 17 // Current inded 18 this.current = 0; 19 20 // Start/stop timer 21 this.interval = f; 22 23 // Set some options 24 this.opts = { 25 speed: 500, 26 delay: 3000, // f for no autoplay 27 complete: f, // when a slide's finished 28 keys: !f, // keyboard shortcuts - disable if it breaks things 29 dots: f, // display â¢â¢â¢â¢o⢠pagination 30 fluid: f // is it a percentage width?, 31 }; 32 33 // Create a deep clone for methods where context changes 34 var _ = this; 35 36 this.init = function (el, opts) { 37 this.el = el; 38 this.ul = el.children('ul'); 39 this.max = [el.outerWidth(), el.outerHeight()]; 40 this.items = this.ul.children('li').each(this.calculate); 41 42 // Check whether we're passing any options in to Unslider 43 this.opts = $.extend(this.opts, opts); 44 45 // Set up the Unslider 46 this.setup(); 47 48 return this; 49 }; 50 51 // Get the width for an element 52 // Pass a jQuery element as the context with .call(), and the index as a parameter: Unslider.calculate.call($('li:first'), 0) 53 this.calculate = function (index) { 54 var me = $(this), 55 width = me.outerWidth(), height = me.outerHeight(); 56 57 // Add it to the sizes list 58 _.sizes[index] = [width, height]; 59 60 // Set the max values 61 if (width > _.max[0]) _.max[0] = width; 62 if (height > _.max[1]) _.max[1] = height; 63 }; 64 65 // Work out what methods need calling 66 this.setup = function () { 67 // Set the main element 68 this.el.css({ 69 overflow: 'hidden', 70 width: _.max[0], 71 height: this.items.first().outerHeight() 72 }); 73 74 // Set the relative widths 75 this.ul.css({ width: (this.items.length * 100) + '%', position: 'absolute' }); 76 this.items.css('width', (100 / this.items.length) + '%'); 77 78 if (this.opts.delay !== f) { 79 this.start(); 80 this.el.hover(this.stop, this.start); 81 } 82 83 // Custom keyboard support 84 this.opts.keys && $(document).keydown(this.keys); 85 86 // Dot pagination 87 this.opts.dots && this.dots(); 88 89 // Little patch for fluid-width sliders. Screw those guys. 90 if (this.opts.fluid) { 91 var resize = function () { 92 _.el.css('width', Math.min(Math.round((_.el.outerWidth() / _.el.parent().outerWidth()) * 100), 100) + '%'); 93 }; 94 95 resize(); 96 $(window).resize(resize); 97 } 98 99 if (this.opts.arrows) { 100 this.el.parent().append('<p class="arrows"><span class="prev">â</span><span class="next">â</span></p>') 101 .find('.arrows span').click(function () { 102 $.isFunction(_[this.className]) && _[this.className](); 103 }); 104 }; 105 106 // Swipe support 107 //06242014 108 //if ($.event.swipe) { 109 // this.el.on('swipeleft', _.prev).on('swiperight', _.next); 110 //} 111 this.el.on('swipeleft', _.next).on('swiperight', _.prev); 112 }; 113 114 // Move Unslider to a slide index 115 this.move = function (index, cb) { 116 // If it's out of bounds, go to the first slide 117 if (!this.items.eq(index).length) index = 0; 118 if (index < 0) index = (this.items.length - 1); 119 //var perv_Index = parseInt(_.el.find('.dots li.active').html()) - 1; 120 var perv_Index = parseInt(_.el.find('.dots li.active').attr("data-sli
120deIndex")) - 1; 121 if ($("#ss_wistia_video_play_" + perv_Index) != undefined) { 122 if ($("#ss_wistia_video_play_" + perv_Index).val() == '1') { 123 this.stop(); 124 $("#ss_wistia_video_play_" + perv_Index).val('0'); 125 return false; 126 } 127 } 128 129 var target = this.items.eq(index); 130 var obj = { height: target.outerHeight() }; 131 var speed = cb ? 5 : this.opts.speed; 132 133 if (!this.ul.is(':animated')) { 134 // Handle those pesky dots 135 _.el.find('.dot:eq(' + index + ')').addClass('active').siblings().removeClass('active'); 136 137 this.el.animate(obj, speed) && this.ul.animate($.extend({ left: '-' + index + '00%' }, obj), speed, function (data) { 138 _.current = index; 139 $.isFunction(_.opts.complete) && !cb && _.opts.complete(_.el); 140 }); 141 } 142 }; 143 144 // Autoplay functionality 145 this.start = function () { 146 _.interval = setInterval(function () { 147 _.move(_.current + 1); 148 }, _.opts.delay); 149 }; 150 151 // Stop autoplay 152 this.stop = function () { 153 _.interval = clearInterval(_.interval); 154 return _; 155 }; 156 157 // Keypresses 158 this.keys = function (e) { 159 var key = e.which; 160 var map = { 161 // Prev/next 162 37: _.prev, 163 39: _.next, 164 165 // Esc 166 27: _.stop 167 }; 168 169 if ($.isFunction(map[key])) { 170 map[key](); 171 } 172 }; 173 174 // Arrow navigation 175 this.next = function () { return _.stop().move(_.current + 1) }; 176 this.prev = function () { return _.stop().move(_.current - 1) }; 177 178 this.dots = function () { 179 // Create the HTML 180 var html = '<ol class="dots">'; 181 $.each(this.items, function (index) { 182 //html += '<li class="dot' + (index < 1 ? ' active' : '') + '">' + (index + 1) + '</li>'; 183 if ($(this).hasClass('has-video')){ 184 //html += '<li class="dot videodot' + (index < 1 ? ' active' : '') + '">' + (index + 1) + '</li>'; 185 html += '<li class="dot videodot' + (index < 1 ? ' active' : '') + '" data-slideIndex="' + (index + 1) + '"></li>'; 186 } else { 187 //html += '<li class="dot' + (index < 1 ? ' active' : '') + '">' + (index + 1) + '</li>'; 188 html += '<li class="dot' + (index < 1 ? ' active' : '') + '" data-slideIndex="' + (index + 1) + '"></li>'; 189 } 190 }); 191 192 html += '</ol>'; 193 194 // Add it to the Unslider 195 this.el.addClass('has-dots').append(html).find('.dot').click(function () { 196 _.move($(this).index()); 197 }); 198 }; 199 }; 200 201 // Create a jQuery plugin 202 $.fn.unslider = function (o) { 203 var len = this.length; 204 205 // Enable multiple-slider support 206 return this.each(function (index) { 207 // Cache a copy of $(this), so it 208 var me = $(this); 209 var instance = (new Unslider).init(me, o); 210 211 // Invoke an Unslider instance 212 me.data('unslider' + (len > 1 ? '-' + (index + 1) : ''), instance); 213 }); 214 }; 215 })(window.jQuery, false); 216//});
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.