scripts.js 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652
  1. // cookie functions http://www.quirksmode.org/js/cookies.html
  2. function createCookie(name,value,days)
  3. {
  4. if (days)
  5. {
  6. var date = new Date();
  7. date.setTime(date.getTime()+(days*24*60*60*1000));
  8. var expires = "; expires="+date.toGMTString();
  9. }
  10. else var expires = "";
  11. document.cookie = name+"="+value+expires+"; path=/";
  12. }
  13. function readCookie(name)
  14. {
  15. var nameEQ = name + "=";
  16. var ca = document.cookie.split(';');
  17. for(var i=0;i < ca.length;i++)
  18. {
  19. var c = ca[i];
  20. while (c.charAt(0)==' ') c = c.substring(1,c.length);
  21. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  22. }
  23. return null;
  24. }
  25. function eraseCookie(name)
  26. {
  27. createCookie(name,"",-1);
  28. }
  29. // /cookie functions
  30. /*! A fix for the iOS orientationchange zoom bug.
  31. Script by @scottjehl, rebound by @wilto.
  32. MIT License.
  33. */
  34. (function(w){
  35. // This fix addresses an iOS bug, so return early if the UA claims it's something else.
  36. if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){
  37. return;
  38. }
  39. var doc = w.document;
  40. if( !doc.querySelector ){ return; }
  41. var meta = doc.querySelector( "meta[name=viewport]" ),
  42. initialContent = meta && meta.getAttribute( "content" ),
  43. disabledZoom = initialContent + ",maximum-scale=1",
  44. enabledZoom = initialContent + ",maximum-scale=10",
  45. enabled = true,
  46. x, y, z, aig;
  47. if( !meta ){ return; }
  48. function restoreZoom(){
  49. meta.setAttribute( "content", enabledZoom );
  50. enabled = true;
  51. }
  52. function disableZoom(){
  53. meta.setAttribute( "content", disabledZoom );
  54. enabled = false;
  55. }
  56. function checkTilt( e ){
  57. aig = e.accelerationIncludingGravity;
  58. x = Math.abs( aig.x );
  59. y = Math.abs( aig.y );
  60. z = Math.abs( aig.z );
  61. // If portrait orientation and in one of the danger zones
  62. if( !w.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){
  63. if( enabled ){
  64. disableZoom();
  65. }
  66. }
  67. else if( !enabled ){
  68. restoreZoom();
  69. }
  70. }
  71. w.addEventListener( "orientationchange", restoreZoom, false );
  72. w.addEventListener( "devicemotion", checkTilt, false );
  73. })( this );
  74. /*
  75. jquery.sorted - super simple jQuery sorting utility
  76. Copyright (c) 2010 Jacek Galanciak
  77. Dual licensed under the MIT and GPL version 2 licenses.
  78. http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
  79. http://github.com/jquery/jquery/blob/master/GPL-LICENSE.txt
  80. Github/docs site: http://github.com/razorjack/jquery.sorted
  81. */
  82. (function($) {
  83. $.fn.sorted = function(customOptions) {
  84. var options = {
  85. reversed: false,
  86. by: function(a) { return a.text(); }
  87. };
  88. $.extend(options, customOptions);
  89. $data = $(this);
  90. arr = $data.get();
  91. arr.sort(function(a, b) {
  92. var valA = options.by($(a));
  93. var valB = options.by($(b));
  94. if (options.reversed) {
  95. return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;
  96. } else {
  97. return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;
  98. }
  99. });
  100. return $(arr);
  101. };
  102. })(jQuery);
  103. (function($) {
  104. $.fn.filterator = function(opts) {
  105. return this.each(function() {
  106. // Error handling
  107. if (!opts.target) {
  108. throw new Error("No target. I don't know what to filter");
  109. }
  110. if (!opts.container) {
  111. throw new Error("No container. I don't know where to apply the filter");
  112. }
  113. // Initialize variables
  114. var el = $(this),
  115. container = $(opts.container),
  116. target = opts.target;
  117. if (!container.data('has-filters')) {
  118. /**
  119. * We need to apply multiple filters.
  120. * To do that, instead of filter in the click/select events of the filters we'll teach the container to filter itself
  121. */
  122. container.bind('filter', function() {
  123. var $t = $(this);
  124. elements = $t.children(); // Don't cache this. Maybe the collection has changed with ajax
  125. // TODO control if the collection has changed so we can cache it
  126. var data = $t.data(),
  127. filters = {};
  128. for (key in data) {
  129. var filter = key.match(/^filter(.*?)$/);
  130. if (filter) {
  131. filters[filter[1].toLowerCase()] = data[key];
  132. }
  133. }
  134. // Hide all
  135. elements.hide();
  136. // Filter and show filtered
  137. elements.filter(function() {
  138. $(this).removeClass("filtered");
  139. $(this).removeClass("not-filtered");
  140. for (filter in filters) {
  141. if (($(this).data(filter) != filters[filter]) && !($(this).data(filter).match("#"+filters[filter]+"#"))) {
  142. $(this).addClass("filtered");
  143. return false;
  144. }
  145. }
  146. $(this).addClass("not-filtered");
  147. return true;
  148. }).show();
  149. });
  150. container.data('has-filters', true);
  151. }
  152. /*
  153. * Handle filter controls
  154. */
  155. if (el.get(0).tagName == 'SELECT') {
  156. // Select
  157. el.change(function() {
  158. var filter = $(this).val();
  159. if (filter) {
  160. container.data('filter-' + target, filter);
  161. } else {
  162. container.removeData('filter-' + target);
  163. }
  164. container.trigger('filter');
  165. });
  166. } else {
  167. // Links
  168. el.delegate('a', 'click', function(e) {
  169. e.preventDefault();
  170. var $t = $(this);
  171. // If clicked current, do nothing
  172. if ($t.hasClass('selected')) {
  173. return;
  174. }
  175. var filter = $(this).data('filter');
  176. if (filter) {
  177. container.data('filter-' + target, filter);
  178. } else {
  179. container.removeData('filter-' + target);
  180. }
  181. // In some cases (when links are included in an 'ul li' way and not together) marking siblings as unselected is not enough.
  182. // We must get the element which delegate the event and marking every 'a' descendant as unselected (yeah, it's quite ugly)
  183. $(e.delegateTarget).find("a").removeClass('selected');
  184. // Mark current as selected
  185. $t.addClass('selected');
  186. container.trigger('filter');
  187. });
  188. }
  189. });
  190. };
  191. })(jQuery);
  192. /*! Mat Marquis (@wilto). MIT License. http://wil.to/3a */
  193. (function( $, undefined ) {
  194. var inst = 0;
  195. $.fn.getPercentage = function() {
  196. var oPercent = this.attr('style').match(/margin\-left:(.*[0-9])/i) && parseInt(RegExp.$1, 10);
  197. return oPercent;
  198. };
  199. $.fn.adjRounding = function(slide) {
  200. var $el = $(this),
  201. $slides = $el.find( slide ),
  202. diff = $el.parent().width() - $($slides[0]).width();
  203. if (diff !== 0) {
  204. $($slides).css( "position", "relative" );
  205. for (var i = 0; i < $slides.length; i++) {
  206. $($slides[i]).css( "left", (diff * i) + "px" );
  207. }
  208. }
  209. return this;
  210. };
  211. $.fn.film = function(config) {
  212. if( this.data( "film-initialized" ) ) { return; }
  213. this.data( "film-initialized", true );
  214. var defaults = {
  215. slider : '.slider',
  216. slide : '.slide',
  217. prevSlide : null,
  218. nextSlide : null,
  219. slideHed : null,
  220. addPagination : false,
  221. addNav : ( config != undefined && ( config.prevSlide || config.nextSlide ) ) ? false : true,
  222. namespace : 'film',
  223. speed : 300
  224. },
  225. opt = $.extend(defaults, config),
  226. $slidewrap = this,
  227. dBody = (document.body || document.documentElement),
  228. transitionSupport = function() {
  229. dBody.setAttribute('style', 'transition:top 1s ease;-webkit-transition:top 1s ease;-moz-transition:top 1s ease;');
  230. var tSupport = !!(dBody.style.transition || dBody.style.webkitTransition || dBody.style.msTransition || dBody.style.OTransition || dBody.style.MozTransition );
  231. return tSupport;
  232. },
  233. film = {
  234. init : function() {
  235. inst++;
  236. $slidewrap.each(function(carInt) {
  237. var $wrap = $(this),
  238. $slider = $wrap.find(opt.slider),
  239. $slide = $wrap.find(opt.slide),
  240. slidenum = $slide.length,
  241. transition = "margin-left " + ( opt.speed / 1000 ) + "s ease",
  242. tmp = 'film-' + inst + '-' + carInt;
  243. if( $slide.length <= 1 ) {
  244. return; /* No sense running all this code if the carousel functionality is unnecessary. */
  245. }
  246. $wrap
  247. .css({
  248. overflow : "hidden",
  249. width : "100%"
  250. })
  251. .attr('role' , 'application');
  252. $slider
  253. .attr( 'id', ( $slider[0].id || 'film-' + inst + '-' + carInt ) )
  254. .css({
  255. "marginLeft" : "0px",
  256. "float" : "left",
  257. "width" : 100 * slidenum + "%",
  258. "-webkit-transition" : transition,
  259. "-moz-transition" : transition,
  260. "-ms-transition" : transition,
  261. "-o-transition" : transition,
  262. "transition" : transition
  263. })
  264. .bind( 'filmmove' , film.move )
  265. .bind( 'nextprev' , film.nextPrev )
  266. .bind( 'navstate' , film.navState );
  267. $slide
  268. .css({
  269. "float": "left",
  270. width: (100 / slidenum) + "%"
  271. })
  272. .each(function(i) {
  273. var $el = $(this);
  274. $el.attr({
  275. role : "tabpanel document",
  276. id : tmp + '-slide' + i
  277. });
  278. if( opt.addPagination ) {
  279. $el.attr('aria-labelledby', tmp + '-tab' + i);
  280. }
  281. });
  282. // Build and insert navigation/pagination, if specified in the options:
  283. opt.addPagination && film.addPagination();
  284. opt.addNav && film.addNav();
  285. $slider.trigger( "navstate", { current: 0 });
  286. });
  287. },
  288. addNav : function() {
  289. $slidewrap.each(function(i) {
  290. var $oEl = $(this),
  291. $slider = $oEl.find(opt.slider),
  292. currentSlider = $slider[0].id,
  293. navMarkup = [
  294. '<ul class="slidecontrols" role="navigation">',
  295. ' <li role="presentation"><a href="#' + currentSlider + '" class="' + opt.namespace + '-next">&nbsp;</a></li>',
  296. ' <li role="presentation"><a href="#' + currentSlider + '" class="' + opt.namespace + '-prev">&nbsp;</a></li>',
  297. '</ul>'
  298. ].join(''),
  299. nextprev = {
  300. nextSlide : '.' + opt.namespace + '-next',
  301. prevSlide : '.' + opt.namespace + '-prev'
  302. };
  303. opt = $.extend(opt, nextprev);
  304. $oEl.prepend(navMarkup);
  305. });
  306. },
  307. addPagination : function() {
  308. $slidewrap.each(function(i) {
  309. var $oEl = $(this),
  310. $pagination = $('<ol class="' + opt.namespace + '-tabs" role="tablist navigation" />'),
  311. $slider = $oEl.find(opt.slider),
  312. $slides = $oEl.find(opt.slide),
  313. slideNum = $slides.length,
  314. associated = 'film-' + inst + '-' + i;
  315. while( slideNum-- ) {
  316. var hed = $( $slides[ slideNum ] ).find( opt.slideHed ).text() || 'Page ' + ( slideNum + 1 ),
  317. tabMarkup = [
  318. '<li role="presentation">',
  319. '<a href="#' + associated + '-slide' + slideNum +'"',
  320. ' aria-controls="' + associated + '-slide' + slideNum +'"',
  321. ' id="' + associated + '-tab' + slideNum + '" role="tab">' + hed + '</a>',
  322. '</li>'
  323. ].join('');
  324. $pagination.prepend(tabMarkup);
  325. };
  326. $pagination
  327. .appendTo( $oEl )
  328. .find('li').keydown( function(e) {
  329. var $el = $(this),
  330. $prevTab = $el.prev().find('a'),
  331. $nextTab = $el.next().find('a');
  332. switch( e.which ) {
  333. case 37:
  334. case 38:
  335. $prevTab.length && $prevTab.trigger('click').focus();
  336. e.preventDefault();
  337. break;
  338. case 39:
  339. case 40:
  340. $nextTab.length && $nextTab.trigger('click').focus();
  341. e.preventDefault();
  342. break;
  343. }
  344. })
  345. .find('a').click( function(e) {
  346. var $el = $(this);
  347. if( $el.attr('aria-selected') == 'false' ) {
  348. var current = $el.parent().index(),
  349. move = -( 100 * ( current ) ),
  350. $slider = $oEl.find( opt.slider );
  351. $slider.trigger( 'filmmove', { moveTo: move });
  352. }
  353. e.preventDefault();
  354. });
  355. });
  356. },
  357. roundDown : function(oVal) {
  358. var val = parseInt(oVal, 10);
  359. return Math.ceil( (val - (val % 100 ) ) / 100) * 100;
  360. },
  361. navState : function(e, ui) {
  362. var $el = $(this),
  363. $slides = $el.find(opt.slide),
  364. ind = -(ui.current / 100),
  365. $activeSlide = $($slides[ind]);
  366. $el.attr('aria-activedescendant', $activeSlide[0].id);
  367. // Update state of active tabpanel:
  368. $activeSlide
  369. .addClass( opt.namespace + "-active-slide" )
  370. .attr( 'aria-hidden', false )
  371. .siblings()
  372. .removeClass( opt.namespace + "-active-slide" )
  373. .attr( 'aria-hidden', true );
  374. // Update state of next/prev navigation:
  375. if( ( !!opt.prevSlide || !!opt.nextSlide ) ) {
  376. var $target = $('[href*="#' + this.id + '"]');
  377. $target.removeClass( opt.namespace + '-disabled' );
  378. if( ind == 0 ) {
  379. $target.filter(opt.prevSlide).addClass( opt.namespace + '-disabled' );
  380. } else if( ind == $slides.length - 1 ) {
  381. $target.filter(opt.nextSlide).addClass( opt.namespace + '-disabled' );
  382. }
  383. }
  384. // Update state of pagination tabs:
  385. if( !!opt.addPagination ) {
  386. var tabId = $activeSlide.attr('aria-labelledby'),
  387. $tab = $('#' + tabId );
  388. $tab
  389. .parent()
  390. .addClass(opt.namespace + '-active-tab')
  391. .siblings()
  392. .removeClass(opt.namespace + '-active-tab')
  393. .find('a')
  394. .attr({
  395. 'aria-selected' : false,
  396. 'tabindex' : -1
  397. });
  398. $tab.attr({
  399. 'aria-selected' : true,
  400. 'tabindex' : 0
  401. });
  402. }
  403. },
  404. move : function(e, ui) {
  405. var $el = $(this);
  406. $el
  407. .trigger(opt.namespace + "-beforemove")
  408. .trigger("navstate", { current: ui.moveTo });
  409. if( transitionSupport() ) {
  410. $el
  411. .adjRounding( opt.slide ) /* Accounts for browser rounding errors. Lookin’ at you, iOS Safari. */
  412. .css('marginLeft', ui.moveTo + "%")
  413. .one("transitionend webkitTransitionEnd OTransitionEnd", function() {
  414. $(this).trigger( opt.namespace + "-aftermove" );
  415. });
  416. } else {
  417. $el
  418. .adjRounding( opt.slide )
  419. .animate({ marginLeft: ui.moveTo + "%" }, { duration : opt.speed, queue : false }, function() {
  420. $(this).trigger( opt.namespace + "-aftermove" );
  421. });
  422. }
  423. },
  424. nextPrev : function(e, ui) {
  425. var $el = $(this),
  426. left = ( $el ) ? $el.getPercentage() : 0,
  427. $slide = $el.find(opt.slide),
  428. constrain = ui.dir === 'prev' ? left != 0 : -left < ($slide.length - 1) * 100,
  429. $target = $( '[href="#' + this.id + '"]');
  430. if (!$el.is(":animated") && constrain ) {
  431. if ( ui.dir === 'prev' ) {
  432. left = ( left % 100 != 0 ) ? film.roundDown(left) : left + 100;
  433. } else {
  434. left = ( ( left % 100 ) != 0 ) ? film.roundDown(left) - 100 : left - 100;
  435. }
  436. $el.trigger('filmmove', { moveTo: left });
  437. $target
  438. .removeClass( opt.namespace + '-disabled')
  439. .removeAttr('aria-disabled');
  440. switch( left ) {
  441. case ( -($slide.length - 1) * 100 ):
  442. $target.filter(opt.nextSlide)
  443. .addClass( opt.namespace + '-disabled')
  444. .attr('aria-disabled', true);
  445. break;
  446. case 0:
  447. $target.filter(opt.prevSlide)
  448. .addClass( opt.namespace + '-disabled')
  449. .attr('aria-disabled', true);
  450. break;
  451. }
  452. } else {
  453. var reset = film.roundDown(left);
  454. $el.trigger('filmmove', { moveTo: reset });
  455. }
  456. }
  457. };
  458. film.init(this);
  459. $(opt.nextSlide + ',' + opt.prevSlide)
  460. .bind('click', function(e) {
  461. var $el = $(this),
  462. link = this.hash,
  463. dir = ( $el.is(opt.prevSlide) ) ? 'prev' : 'next',
  464. $slider = $(link);
  465. if ( $el.is('.' + opt.namespace + '-disabled') ) {
  466. return false;
  467. }
  468. $slider.trigger('nextprev', { dir: dir });
  469. e.preventDefault();
  470. })
  471. .bind('keydown', function(e) {
  472. var $el = $(this),
  473. link = this.hash;
  474. switch (e.which) {
  475. case 37:
  476. case 38:
  477. $('#' + link).trigger('nextprev', { dir: 'next' });
  478. e.preventDefault();
  479. break;
  480. case 39:
  481. case 40:
  482. $('#' + link).trigger('nextprev', { dir: 'prev' });
  483. e.preventDefault();
  484. break;
  485. }
  486. });
  487. var setup = {
  488. wrap : this,
  489. slider : opt.slider
  490. };
  491. $slidewrap.bind( "dragSnap", setup, function(e, ui){
  492. var $slider = $(this).find( opt.slider ),
  493. dir = ( ui.direction === "left" ) ? 'next' : 'prev';
  494. $slider.trigger("nextprev", { dir: dir });
  495. });
  496. $slidewrap.filter('[data-autorotate]').each(function() {
  497. var auto,
  498. $el = $(this),
  499. speed = $el.attr('data-autorotate'),
  500. slidenum = $el.find(opt.slide).length,
  501. autoAdvance = function() {
  502. var $slider = $el.find(opt.slider),
  503. active = -( $(opt.slider).getPercentage() / 100 ) + 1;
  504. switch( active ) {
  505. case slidenum:
  506. clearInterval(auto);
  507. auto = setInterval(function() {
  508. autoAdvance();
  509. $slider.trigger("nextprev", { dir: 'prev' });
  510. }, speed);
  511. break;
  512. case 1:
  513. clearInterval(auto);
  514. auto = setInterval(function() {
  515. autoAdvance();
  516. $slider.trigger("nextprev", { dir: 'next' });
  517. }, speed);
  518. break;
  519. }
  520. };
  521. auto = setInterval(autoAdvance, speed);
  522. $el
  523. .attr('aria-live', 'polite')
  524. .bind('mouseenter click touchstart', function() {
  525. clearInterval(auto);
  526. });
  527. });
  528. return this;
  529. };
  530. $.event.special.dragSnap = {
  531. setup: function(setup) {
  532. var $el = $(this),
  533. transitionSwap = function($el, tog) {
  534. var speed = 0.3,
  535. transition = ( tog ) ? "margin-left " + speed + "s ease" : 'none';
  536. $el.css({
  537. "-webkit-transition" : transition,
  538. "-moz-transition" : transition,
  539. "-ms-transition" : transition,
  540. "-o-transition" : transition,
  541. "transition" : transition
  542. });
  543. },
  544. roundDown = function(left) {
  545. left = parseInt(left, 10);
  546. return Math.ceil( (left - (left % 100 ) ) / 100) * 100;
  547. },
  548. snapBack = function(e, ui) {
  549. var $el = ui.target,
  550. currentPos = ( $el.attr('style') != undefined ) ? $el.getPercentage() : 0,
  551. left = (ui.left === false) ? roundDown(currentPos) - 100 : roundDown(currentPos),
  552. dStyle = document.body.style,
  553. transitionSupport = function() {
  554. dBody.setAttribute('style', 'transition:top 1s ease;-webkit-transition:top 1s ease;-moz-transition:top 1s ease;');
  555. var tSupport = !!(dBody.style.transition || dBody.style.webkitTransition || dBody.style.MozTransition );
  556. return tSupport;
  557. };
  558. transitionSwap($el, true);
  559. if( transitionSupport() ) {
  560. $el.css('marginLeft', left + "%");
  561. } else {
  562. $el.animate({ marginLeft: left + "%" }, opt.speed);
  563. }
  564. };
  565. $el
  566. .bind("snapback", snapBack)
  567. .bind("touchstart", function(e) {
  568. var data = e.originalEvent.touches ? e.originalEvent.touches[0] : e,
  569. start = {
  570. time: (new Date).getTime(),
  571. coords: [ data.pageX, data.pageY ],
  572. origin: $(e.target).closest( setup.wrap )
  573. },
  574. stop,
  575. $tEl = $(e.target).closest( setup.slider ),
  576. currentPos = ( $tEl.attr('style') != undefined ) ? $tEl.getPercentage() : 0;
  577. transitionSwap($tEl, false);
  578. function moveHandler(e) {
  579. var data = e.originalEvent.touches ? e.originalEvent.touches[0] : e;
  580. stop = {
  581. time: (new Date).getTime(),
  582. coords: [ data.pageX, data.pageY ]
  583. };
  584. if(!start || Math.abs(start.coords[0] - stop.coords[0]) < Math.abs(start.coords[1] - stop.coords[1]) ) {
  585. return;
  586. }
  587. $tEl.css({"margin-left": currentPos + ( ( (stop.coords[0] - start.coords[0]) / start.origin.width() ) * 100 ) + '%' });
  588. // prevent scrolling
  589. if (Math.abs(start.coords[0] - stop.coords[0]) > 10) {
  590. e.preventDefault();
  591. }
  592. };
  593. $el
  594. .bind("gesturestart", function(e) {
  595. $el
  596. .unbind("touchmove", moveHandler)
  597. .unbind("touchend", moveHandler);
  598. })
  599. .bind("touchmove", moveHandler)
  600. .one("touchend", function(e) {
  601. $el.unbind("touchmove", moveHandler);
  602. transitionSwap($tEl, true);
  603. if (start && stop ) {
  604. if (Math.abs(start.coords[0] - stop.coords[0]) > 10
  605. && Math.abs(start.coords[0] - stop.coords[0]) > Math.abs(start.coords[1] - stop.coords[1])) {
  606. e.preventDefault();
  607. } else {
  608. $el.trigger('snapback', { target: $tEl, left: true });
  609. return;
  610. }
  611. if (Math.abs(start.coords[0] - stop.coords[0]) > 1 && Math.abs(start.coords[1] - stop.coords[1]) < 75) {
  612. var left = start.coords[0] > stop.coords[0];
  613. if( -( stop.coords[0] - start.coords[0]) > ( start.origin.width() / 4 ) || ( stop.coords[0] - start.coords[0]) > ( start.origin.width() / 4 ) ) {
  614. start.origin.trigger("dragSnap", {direction: left ? "left" : "right"});
  615. } else {
  616. $el.trigger('snapback', { target: $tEl, left: left });
  617. }
  618. }
  619. }
  620. start = stop = undefined;
  621. });
  622. });
  623. }
  624. };
  625. })(jQuery);
  626. // Magnific Popup v0.8.8 by Dmitry Semenov
  627. // http://bit.ly/magnific-popup#build=inline+image+ajax+iframe+gallery+retina+fastclick
  628. (function(a){var b="Close",c="BeforeAppend",d="MarkupParse",e="Open",f="Change",g="mfp",h="."+g,i="mfp-ready",j="mfp-removing",k="mfp-prevent-close",l,m=function(){},n=!!window.jQuery,o,p=a(window),q,r,s,t,u,v=function(a,b){l.ev.on(g+a+h,b)},w=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},x=function(b,c){l.ev.triggerHandler(g+b,c),l.st.callbacks&&(b=b.charAt(0).toLowerCase()+b.slice(1),l.st.callbacks[b]&&l.st.callbacks[b].apply(l,a.isArray(c)?c:[c]))},y=function(){(l.st.focus?l.content.find(l.st.focus).eq(0):l.wrap).focus()},z=function(b){if(b!==u||!l.currTemplate.closeBtn)l.currTemplate.closeBtn=a(l.st.closeMarkup.replace("%title%",l.st.tClose)),u=b;return l.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(l=new m,l.init(),a.magnificPopup.instance=l)},B=function(b){if(a(b).hasClass(k))return;var c=l.st.closeOnContentClick,d=l.st.closeOnBgClick;if(c&&d)return!0;if(!l.content||a(b).hasClass("mfp-close")||l.preloader&&b===l.preloader[0])return!0;if(b!==l.content[0]&&!a.contains(l.content[0],b)){if(d)return!0}else if(c)return!0;return!1};m.prototype={constructor:m,init:function(){var b=navigator.appVersion;l.isIE7=b.indexOf("MSIE 7.")!==-1,l.isIE8=b.indexOf("MSIE 8.")!==-1,l.isLowIE=l.isIE7||l.isIE8,l.isAndroid=/android/gi.test(b),l.isIOS=/iphone|ipad|ipod/gi.test(b),l.probablyMobile=l.isAndroid||l.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),q=a(document.body),r=a(document),l.popupsCache={}},open:function(b){var c;if(b.isObj===!1){l.items=b.items.toArray(),l.index=0;var f=b.items,g;for(c=0;c<f.length;c++){g=f[c],g.parsed&&(g=g.el[0]);if(g===b.el[0]){l.index=c;break}}}else l.items=a.isArray(b.items)?b.items:[b.items],l.index=b.index||0;if(l.isOpen){l.updateItemHTML();return}l.types=[],t="",l.ev=b.mainEl||r,b.key?(l.popupsCache[b.key]||(l.popupsCache[b.key]={}),l.currTemplate=l.popupsCache[b.key]):l.currTemplate={},l.st=a.extend(!0,{},a.magnificPopup.defaults,b),l.fixedContentPos=l.st.fixedContentPos==="auto"?!l.probablyMobile:l.st.fixedContentPos,l.bgOverlay||(l.bgOverlay=w("bg").on("click"+h,function(){l.close()}),l.wrap=w("wrap").attr("tabindex",-1).on("click"+h,function(a){B(a.target)&&l.close()}),l.container=w("container",l.wrap)),l.contentContainer=w("content"),l.st.preloader&&(l.preloader=w("preloader",l.container,l.st.tLoading));var j=a.magnificPopup.modules;for(c=0;c<j.length;c++){var k=j[c];k=k.charAt(0).toUpperCase()+k.slice(1),l["init"+k].call(l)}x("BeforeOpen"),l.st.closeBtnInside?(v(d,function(a,b,c,d){c.close_replaceWith=z(d.type)}),t+=" mfp-close-btn-in"):l.wrap.append(z()),l.st.alignTop&&(t+=" mfp-align-top"),l.fixedContentPos?l.wrap.css({overflow:l.st.overflowY,overflowX:"hidden",overflowY:l.st.overflowY}):l.wrap.css({top:p.scrollTop(),position:"absolute"}),(l.st.fixedBgPos===!1||l.st.fixedBgPos==="auto"&&!l.fixedContentPos)&&l.bgOverlay.css({height:r.height(),position:"absolute"}),r.on("keyup"+h,function(a){a.keyCode===27&&l.close()}),p.on("resize"+h,function(){l.updateSize()}),l.st.closeOnContentClick||(t+=" mfp-auto-cursor"),t&&l.wrap.addClass(t);var m=l.wH=p.height(),n={};if(l.fixedContentPos){var o=l._getScrollbarSize();o&&(n.paddingRight=o)}l.fixedContentPos&&(l.isIE7?a("body, html").css("overflow","hidden"):n.overflow="hidden");var s=l.st.mainClass;l.isIE7&&(s+=" mfp-ie7"),s&&l._addClassToMFP(s),l.updateItemHTML(),x("BuildControls"),q.css(n),l.bgOverlay.add(l.wrap).prependTo(document.body),l._lastFocusedEl=document.activeElement,setTimeout(function(){l.content?(l._addClassToMFP(i),y()):l.bgOverlay.addClass(i),r.on("focusin"+h,function(b){if(b.target!==l.wrap[0]&&!a.contains(l.wrap[0],b.target))return y(),!1})},16),l.isOpen=!0,l.updateSize(m),x(e)},close:function(){if(!l.isOpen)return;l.isOpen=!1,l.st.removalDelay&&!l.isLowIE?(l._addClassToMFP(j),setTimeout(function(){l._close()},l.st.removalDelay)):l._close()},_close:function(){x(b);var c=j+" "+i+" ";l.bgOverlay.detach(),l.wrap.detach(),l.container.empty(),l.st.mainClass&&(c+=l.st.mainClass+" "),l._removeClassFromMFP(c);if(l.fixedContentPos){var d={paddingRight:0};l.isIE7?a("body, html").css("overflow","auto"):d.overflow="visible",q.css(d)}r.off("keyup"+h+" focusin"+h),l.ev.off(h),l.wrap.attr("class","mfp-wrap").removeAttr("style"),l.bgOverlay.attr("class","mfp-bg"),l.container.attr("class","mfp-container"),(!l.st.closeBtnInside||l.currTemplate[l.currItem.type]===!0)&&l.currTemplate.closeBtn&&l.currTemplate.closeBtn.detach(),l._lastFocusedEl&&a(l._lastFocusedEl).focus(),l.currItem=null,l.content=null,l.currTemplate=null,l.prevHeight=0},updateSize:function(a){if(l.isIOS){var b=document.documentElement.clientWidth/window.innerWidth,c=window.innerHeight*b;l.wrap.css("height",c),l.wH=c}else l.wH=a||p.height();x("Resize")},updateItemHTML:function(){var b=l.items[l.index];l.contentContainer.detach(),l.content&&l.content.detach(),b.parsed||(b=l.parseEl(l.index));var c=b.type;x("BeforeChange",[l.currItem?l.currItem.type:"",c]),l.currItem=b;if(!l.currTemplate[c]){var d=l.st[c]?l.st[c].markup:!1;x("FirstMarkupParse",d),d?l.currTemplate[c]=a(d):l.currTemplate[c]=!0}s&&s!==b.type&&l.container.removeClass("mfp-"+s+"-holder");var e=l["get"+c.charAt(0).toUpperCase()+c.slice(1)](b,l.currTemplate[c]);l.appendContent(e,c),b.preloaded=!0,x(f,b),s=b.type,l.container.prepend(l.contentContainer),x("AfterChange")},appendContent:function(a,b){l.content=a,a?l.st.closeBtnInside&&l.currTemplate[b]===!0?l.content.find(".mfp-close").length||l.content.append(z()):l.content=a:l.content="",x(c),l.container.addClass("mfp-"+b+"-holder"),l.contentContainer.append(l.content)},parseEl:function(b){var c=l.items[b],d=c.type;c.tagName?c={el:a(c)}:c={data:c,src:c.src};if(c.el){var e=l.types;for(var f=0;f<e.length;f++)if(c.el.hasClass("mfp-"+e[f])){d=e[f];break}c.src=c.el.attr("data-mfp-src"),c.src||(c.src=c.el.attr("href"))}return c.type=d||l.st.type||"inline",c.index=b,c.parsed=!0,l.items[b]=c,x("ElementParse",c),l.items[b]},addGroup:function(a,b){var c=function(c){c.mfpEl=this,l._openClick(c,a,b)};b||(b={});var d="click.magnificPopup";b.mainEl=a,b.items?(b.isObj=!0,a.off(d).on(d,c)):(b.isObj=!1,b.delegate?a.off(d).on(d,b.delegate,c):(b.items=a,a.off(d).on(d,c)))},_openClick:function(b,c,d){var e=d.midClick!==undefined?d.midClick:a.magnificPopup.defaults.midClick;if(e||b.which!==2){var f=d.disableOn!==undefined?d.disableOn:a.magnificPopup.defaults.disableOn;if(f)if(a.isFunction(f)){if(!f.call(l))return!0}else if(p.width()<f)return!0;b.type&&(b.preventDefault(),l.isOpen&&b.stopPropagation()),d.el=a(b.mfpEl),d.delegate&&(d.items=c.find(d.delegate)),l.open(d)}},updateStatus:function(a,b){if(l.preloader){o!==a&&l.container.removeClass("mfp-s-"+o),!b&&a==="loading"&&(b=l.st.tLoading);var c={status:a,text:b};x("UpdateStatus",c),a=c.status,b=c.text,l.preloader.html(b),l.preloader.find("a").click(function(a){a.stopImmediatePropagation()}),l.container.addClass("mfp-s-"+a),o=a}},_addClassToMFP:function(a){l.bgOverlay.addClass(a),l.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),l.wrap.removeClass(a)},_hasScrollBar:function(a){return document.body.clientHeight>(a||p.height())?!0:!1},_parseMarkup:function(b,c,e){var f;e.data&&(c=a.extend(e.data,c)),x(d,[b,c,e]),a.each(c,function(a,c){if(c===undefined||c===!1)return!0;f=a.split("_");if(f.length>1){var d=b.find(h+"-"+f[0]);if(d.length>0){var e=f[1];e==="replaceWith"?d[0]!==c[0]&&d.replaceWith(c):e==="img"?d.is("img")?d.attr("src",c):d.replaceWith('<img src="'+c+'" class="'+d.attr("class")+'" />'):d.attr(f[1],c)}}else b.find(h+"-"+a).html(c)})},_getScrollbarSize:function(){if(l.scrollbarSize===undefined){var a=document.createElement("div");a.id="mfp-sbm",a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),l.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return l.scrollbarSize}},a.magnificPopup={instance:null,proto:m.prototype,modules:[],open:function(a,b){return A(),a||(a={}),a.isObj=!0,a.index=b||0,this.instance.open(a)},close:function(){return a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,alignTop:!1,removalDelay:0,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">&times;</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},a.fn.magnificPopup=function(b){A();var c=a(this);if(typeof b=="string")if(b==="open"){var d,e=n?c.data("magnificPopup"):c[0].magnificPopup,f=parseInt(arguments[1],10)||0;e.items?d=e.items[f]:(d=c,e.delegate&&(d=d.find(e.delegate)),d=d.eq(f)),l._openClick({mfpEl:d},c,e)}else l.isOpen&&l[b].apply(l,Array.prototype.slice.call(arguments,1));else n?c.data("magnificPopup",b):c[0].magnificPopup=b,l.addGroup(c,b);return c};var C="inline",D,E,F,G=function(){F&&(E.after(F.addClass(D)).detach(),F=null)};a.magnificPopup.registerModule(C,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){l.types.push(C),v(b+"."+C,function(){G()})},getInline:function(b,c){G();if(b.src){var d=l.st.inline,e=a(b.src);return e.length?(e[0].parentNode!==null&&(E||(D=d.hiddenClass,E=w(D),D="mfp-"+D),F=e.after(E).detach().removeClass(D)),l.updateStatus("ready")):(l.updateStatus("error",d.tNotFound),e=a("<div>")),b.inlineElement=e,e}return l.updateStatus("ready"),l._parseMarkup(c,{},b),c}}});var H="ajax",I,J=function(){I&&q.removeClass(I)};a.magnificPopup.registerModule(H,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){l.types.push(H),I=l.st.ajax.cursor,v(b+"."+H,function(){J(),l.req&&l.req.abort()})},getAjax:function(b){I&&q.addClass(I),l.updateStatus("loading");var c=a.extend({url:b.src,success:function(c,d,e){x("ParseAjax",e),l.appendContent(a(e.responseText),H),b.finished=!0,J(),y(),setTimeout(function(){l.wrap.addClass(i)},16),l.updateStatus("ready")},error:function(){J(),b.finished=b.loadError=!0,l.updateStatus("error",l.st.ajax.tError.replace("%url%",b.src))}},l.st.ajax.settings);return l.req=a.ajax(c),""}}});var K,L=function(b){if(b.data&&b.data.title!==undefined)return b.data.title;var c=l.st.image.titleSrc;if(c){if(a.isFunction(c))return c.call(l,b);if(b.el)return b.el.attr(c)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><div class="mfp-img"></div><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var a=l.st.image,c=".image";l.types.push("image"),v(e+c,function(){l.currItem.type==="image"&&a.cursor&&q.addClass(a.cursor)}),v(b+c,function(){a.cursor&&q.removeClass(a.cursor),p.off("resize"+h)}),v("Resize"+c,l.resizeImage),l.isLowIE&&v("AfterChange",l.resizeImage)},resizeImage:function(){var a=l.currItem;if(!a.img)return;if(l.st.image.verticalFit){var b=0;l.isLowIE&&(b=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",l.wH-b)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,K&&clearInterval(K),a.isCheckingImgSize=!1,x("ImageHasSize",a),a.imgHidden&&(l.content&&l.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var b=0,c=a.img[0],d=function(e){K&&clearInterval(K),K=setInterval(function(){if(c.naturalWidth>0){l._onImageHasSize(a);return}b>200&&clearInterval(K),b++,b===3?d(10):b===40?d(50):b===100&&d(500)},e)};d(1)},getImage:function(b,c){var d=0,e=function(){b&&(b.img[0].complete?(b.img.off(".mfploader"),b===l.currItem&&(l._onImageHasSize(b),l.updateStatus("ready")),b.hasSize=!0,b.loaded=!0):(d++,d<200?setTimeout(e,100):f()))},f=function(){b&&(b.img.off(".mfploader"),b===l.currItem&&(l._onImageHasSize(b),l.updateStatus("error",g.tError.replace("%url%",b.src))),b.hasSize=!0,b.loaded=!0,b.loadError=!0)},g=l.st.image,h=c.find(".mfp-img");if(h.length){var i=new Image;i.className="mfp-img",b.img=a(i).on("load.mfploader",e).on("error.mfploader",f),i.src=b.src,h.is("img")&&(b.img=b.img.clone())}return l._parseMarkup(c,{title:L(b),img_replaceWith:b.img},b),l.resizeImage(),b.hasSize?(K&&clearInterval(K),b.loadError?(c.addClass("mfp-loading"),l.updateStatus("error",g.tError.replace("%url%",b.src))):(c.removeClass("mfp-loading"),l.updateStatus("ready")),c):(l.updateStatus("loading"),b.loading=!0,b.hasSize||(b.imgHidden=!0,c.addClass("mfp-loading"),l.findImageSize(b)),c)}}});var M="iframe",N="//about:blank",O=function(a){if(l.currTemplate[M]){var b=l.currTemplate[M].find("iframe");b.length&&(a||(b[0].src=N),l.isIE8&&b.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(M,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){l.types.push(M),v("BeforeChange",function(a,b,c){b!==c&&(b===M?O():c===M&&O(!0))}),v(b+"."+M,function(){O()})},getIframe:function(b,c){var d=b.src,e=l.st.iframe;a.each(e.patterns,function(){if(d.indexOf(this.index)>-1)return this.id&&(typeof this.id=="string"?d=d.substr(d.lastIndexOf(this.id)+this.id.length,d.length):d=this.id.call(this,d)),d=this.src.replace("%id%",d),!1});var f={};return e.srcAction&&(f[e.srcAction]=d),l._parseMarkup(c,f,b),l.updateStatus("ready"),c}}});var P=function(a){var b=l.items.length;return a>b-1?a-b:a<0?b+a:a},Q=function(a,b,c){return a.replace("%curr%",b+1).replace("%total%",c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var c=l.st.gallery,g=".mfp-gallery",h=Boolean(a.fn.mfpFastClick);l.direction=!0;if(!c||!c.enabled)return!1;t+=" mfp-gallery",v(e+g,function(){c.navigateByImgClick&&l.wrap.on("click"+g,".mfp-img",function(){if(l.items.length>1)return l.next(),!1}),r.on("keydown"+g,function(a){a.keyCode===37?l.prev():a.keyCode===39&&l.next()})}),v("UpdateStatus"+g,function(a,b){b.text&&(b.text=Q(b.text,l.currItem.index,l.items.length))}),v(d+g,function(a,b,d,e){var f=l.items.length;d.counter=f>1?Q(c.tCounter,e.index,f):""}),v("BuildControls"+g,function(){if(l.items.length>1&&c.arrows&&!l.arrowLeft){var b=c.arrowMarkup,d=l.arrowLeft=a(b.replace("%title%",c.tPrev).replace("%dir%","left")).addClass(k),e=l.arrowRight=a(b.replace("%title%",c.tNext).replace("%dir%","right")).addClass(k),f=h?"mfpFastClick":"click";d[f](function(){l.prev()}),e[f](function(){l.next()}),l.isIE7&&(w("b",d[0],!1,!0),w("a",d[0],!1,!0),w("b",e[0],!1,!0),w("a",e[0],!1,!0)),l.container.append(d.add(e))}}),v(f+g,function(){l._preloadTimeout&&clearTimeout(l._preloadTimeout),l._preloadTimeout=setTimeout(function(){l.preloadNearbyImages(),l._preloadTimeout=null},16)}),v(b+g,function(){r.off(g),l.wrap.off("click"+g),l.arrowLeft&&h&&l.arrowLeft.add(l.arrowRight).destroyMfpFastClick(),l.arrowRight=l.arrowLeft=null})},next:function(){l.direction=!0,l.index=P(l.index+1),l.updateItemHTML()},prev:function(){l.direction=!1,l.index=P(l.index-1),l.updateItemHTML()},goTo:function(a){l.direction=a>=l.index,l.index=a,l.updateItemHTML()},preloadNearbyImages:function(){var a=l.st.gallery.preload,b=Math.min(a[0],l.items.length),c=Math.min(a[1],l.items.length),d;for(d=1;d<=(l.direction?c:b);d++)l._preloadItem(l.index+d);for(d=1;d<=(l.direction?b:c);d++)l._preloadItem(l.index-d)},_preloadItem:function(b){b=P(b);if(l.items[b].preloaded)return;var c=l.items[b];c.parsed||(c=l.parseEl(b)),x("LazyLoad",c),c.type==="image"&&(c.img=a('<img class="mfp-img" />').on("load.mfploader",function(){c.hasSize=!0}).on("error.mfploader",function(){c.hasSize=!0,c.loadError=!0}).attr("src",c.src)),c.preloaded=!0}}});var R="retina";a.magnificPopup.registerModule(R,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=l.st.retina,b=a.ratio;b=isNaN(b)?b():b,b>1&&(v("ImageHasSize."+R,function(a,c){c.img.css({"max-width":c.img[0].naturalWidth/b,width:"100%"})}),v("ElementParse."+R,function(c,d){d.src=a.replaceSrc(d,b)}))}}}}),function(){var b=1e3,c="ontouchstart"in window,d=function(){p.off("touchmove"+f+" touchend"+f)},e="mfpFastClick",f="."+e;a.fn.mfpFastClick=function(e){return a(this).each(function(){var g=a(this),h;if(c){var i,j,k,l,m,n;g.on("touchstart"+f,function(a){l=!1,n=1,m=a.originalEvent?a.originalEvent.touches[0]:a.touches[0],j=m.clientX,k=m.clientY,p.on("touchmove"+f,function(a){m=a.originalEvent?a.originalEvent.touches:a.touches,n=m.length,m=m[0];if(Math.abs(m.clientX-j)>10||Math.abs(m.clientY-k)>10)l=!0,d()}).on("touchend"+f,function(a){d();if(l||n>1)return;h=!0,a.preventDefault(),clearTimeout(i),i=setTimeout(function(){h=!1},b),e()})})}g.on("click"+f,function(){h||e()})})},a.fn.destroyMfpFastClick=function(){a(this).off("touchstart"+f+" click"+f),c&&p.off("touchmove"+f+" touchend"+f)}}()})(window.jQuery||window.Zepto)
  629. /*
  630. * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
  631. *
  632. * Uses the built in easing capabilities added In jQuery 1.1
  633. * to offer multiple easing options
  634. *
  635. * TERMS OF USE - jQuery Easing
  636. *
  637. * Open source under the BSD License.
  638. *
  639. * Copyright © 2008 George McGinley Smith
  640. * All rights reserved.
  641. *
  642. * Redistribution and use in source and binary forms, with or without modification,
  643. * are permitted provided that the following conditions are met:
  644. *
  645. * Redistributions of source code must retain the above copyright notice, this list of
  646. * conditions and the following disclaimer.
  647. * Redistributions in binary form must reproduce the above copyright notice, this list
  648. * of conditions and the following disclaimer in the documentation and/or other materials
  649. * provided with the distribution.
  650. *
  651. * Neither the name of the author nor the names of contributors may be used to endorse
  652. * or promote products derived from this software without specific prior written permission.
  653. *
  654. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  655. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  656. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  657. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  658. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  659. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  660. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  661. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  662. * OF THE POSSIBILITY OF SUCH DAMAGE.
  663. *
  664. */
  665. // t: current time, b: begInnIng value, c: change In value, d: duration
  666. jQuery.easing['jswing'] = jQuery.easing['swing'];
  667. jQuery.extend( jQuery.easing,
  668. {
  669. def: 'easeOutQuad',
  670. swing: function (x, t, b, c, d) {
  671. //alert(jQuery.easing.default);
  672. return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
  673. },
  674. easeInQuad: function (x, t, b, c, d) {
  675. return c*(t/=d)*t + b;
  676. },
  677. easeOutQuad: function (x, t, b, c, d) {
  678. return -c *(t/=d)*(t-2) + b;
  679. },
  680. easeInOutQuad: function (x, t, b, c, d) {
  681. if ((t/=d/2) < 1) return c/2*t*t + b;
  682. return -c/2 * ((--t)*(t-2) - 1) + b;
  683. },
  684. easeInCubic: function (x, t, b, c, d) {
  685. return c*(t/=d)*t*t + b;
  686. },
  687. easeOutCubic: function (x, t, b, c, d) {
  688. return c*((t=t/d-1)*t*t + 1) + b;
  689. },
  690. easeInOutCubic: function (x, t, b, c, d) {
  691. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  692. return c/2*((t-=2)*t*t + 2) + b;
  693. },
  694. easeInQuart: function (x, t, b, c, d) {
  695. return c*(t/=d)*t*t*t + b;
  696. },
  697. easeOutQuart: function (x, t, b, c, d) {
  698. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  699. },
  700. easeInOutQuart: function (x, t, b, c, d) {
  701. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  702. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  703. },
  704. easeInQuint: function (x, t, b, c, d) {
  705. return c*(t/=d)*t*t*t*t + b;
  706. },
  707. easeOutQuint: function (x, t, b, c, d) {
  708. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  709. },
  710. easeInOutQuint: function (x, t, b, c, d) {
  711. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  712. return c/2*((t-=2)*t*t*t*t + 2) + b;
  713. },
  714. easeInSine: function (x, t, b, c, d) {
  715. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  716. },
  717. easeOutSine: function (x, t, b, c, d) {
  718. return c * Math.sin(t/d * (Math.PI/2)) + b;
  719. },
  720. easeInOutSine: function (x, t, b, c, d) {
  721. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  722. },
  723. easeInExpo: function (x, t, b, c, d) {
  724. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  725. },
  726. easeOutExpo: function (x, t, b, c, d) {
  727. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  728. },
  729. easeInOutExpo: function (x, t, b, c, d) {
  730. if (t==0) return b;
  731. if (t==d) return b+c;
  732. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  733. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  734. },
  735. easeInCirc: function (x, t, b, c, d) {
  736. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  737. },
  738. easeOutCirc: function (x, t, b, c, d) {
  739. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  740. },
  741. easeInOutCirc: function (x, t, b, c, d) {
  742. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  743. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  744. },
  745. easeInElastic: function (x, t, b, c, d) {
  746. var s=1.70158;var p=0;var a=c;
  747. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  748. if (a < Math.abs(c)) { a=c; var s=p/4; }
  749. else var s = p/(2*Math.PI) * Math.asin (c/a);
  750. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  751. },
  752. easeOutElastic: function (x, t, b, c, d) {
  753. var s=1.70158;var p=0;var a=c;
  754. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  755. if (a < Math.abs(c)) { a=c; var s=p/4; }
  756. else var s = p/(2*Math.PI) * Math.asin (c/a);
  757. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  758. },
  759. easeInOutElastic: function (x, t, b, c, d) {
  760. var s=1.70158;var p=0;var a=c;
  761. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  762. if (a < Math.abs(c)) { a=c; var s=p/4; }
  763. else var s = p/(2*Math.PI) * Math.asin (c/a);
  764. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  765. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  766. },
  767. easeInBack: function (x, t, b, c, d, s) {
  768. if (s == undefined) s = 1.70158;
  769. return c*(t/=d)*t*((s+1)*t - s) + b;
  770. },
  771. easeOutBack: function (x, t, b, c, d, s) {
  772. if (s == undefined) s = 1.70158;
  773. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  774. },
  775. easeInOutBack: function (x, t, b, c, d, s) {
  776. if (s == undefined) s = 1.70158;
  777. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  778. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  779. },
  780. easeInBounce: function (x, t, b, c, d) {
  781. return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  782. },
  783. easeOutBounce: function (x, t, b, c, d) {
  784. if ((t/=d) < (1/2.75)) {
  785. return c*(7.5625*t*t) + b;
  786. } else if (t < (2/2.75)) {
  787. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  788. } else if (t < (2.5/2.75)) {
  789. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  790. } else {
  791. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  792. }
  793. },
  794. easeInOutBounce: function (x, t, b, c, d) {
  795. if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  796. return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  797. }
  798. });
  799. /*
  800. *
  801. * TERMS OF USE - EASING EQUATIONS
  802. *
  803. * Open source under the BSD License.
  804. *
  805. * Copyright © 2001 Robert Penner
  806. * All rights reserved.
  807. *
  808. * Redistribution and use in source and binary forms, with or without modification,
  809. * are permitted provided that the following conditions are met:
  810. *
  811. * Redistributions of source code must retain the above copyright notice, this list of
  812. * conditions and the following disclaimer.
  813. * Redistributions in binary form must reproduce the above copyright notice, this list
  814. * of conditions and the following disclaimer in the documentation and/or other materials
  815. * provided with the distribution.
  816. *
  817. * Neither the name of the author nor the names of contributors may be used to endorse
  818. * or promote products derived from this software without specific prior written permission.
  819. *
  820. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  821. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  822. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  823. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  824. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  825. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  826. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  827. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  828. * OF THE POSSIBILITY OF SUCH DAMAGE.
  829. *
  830. */
  831. /*
  832. * jQuery Color Animations v@VERSION
  833. * http://jquery.org/
  834. *
  835. * Copyright 2011 John Resig
  836. * Dual licensed under the MIT or GPL Version 2 licenses.
  837. * http://jquery.org/license
  838. *
  839. * Date: @DATE
  840. */
  841. (function( jQuery, undefined ){
  842. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color outlineColor".split(" "),
  843. // plusequals test for += 100 -= 100
  844. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  845. // a set of RE's that can match strings and generate color tuples.
  846. stringParsers = [{
  847. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  848. parse: function( execResult ) {
  849. return [
  850. execResult[ 1 ],
  851. execResult[ 2 ],
  852. execResult[ 3 ],
  853. execResult[ 4 ]
  854. ];
  855. }
  856. }, {
  857. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  858. parse: function( execResult ) {
  859. return [
  860. 2.55 * execResult[1],
  861. 2.55 * execResult[2],
  862. 2.55 * execResult[3],
  863. execResult[ 4 ]
  864. ];
  865. }
  866. }, {
  867. re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,
  868. parse: function( execResult ) {
  869. return [
  870. parseInt( execResult[ 1 ], 16 ),
  871. parseInt( execResult[ 2 ], 16 ),
  872. parseInt( execResult[ 3 ], 16 )
  873. ];
  874. }
  875. }, {
  876. re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,
  877. parse: function( execResult ) {
  878. return [
  879. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  880. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  881. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  882. ];
  883. }
  884. }, {
  885. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  886. space: "hsla",
  887. parse: function( execResult ) {
  888. return [
  889. execResult[1],
  890. execResult[2] / 100,
  891. execResult[3] / 100,
  892. execResult[4]
  893. ];
  894. }
  895. }],
  896. // jQuery.Color( )
  897. color = jQuery.Color = function( color, green, blue, alpha ) {
  898. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  899. },
  900. spaces = {
  901. rgba: {
  902. cache: "_rgba",
  903. props: {
  904. red: {
  905. idx: 0,
  906. type: "byte",
  907. empty: true
  908. },
  909. green: {
  910. idx: 1,
  911. type: "byte",
  912. empty: true
  913. },
  914. blue: {
  915. idx: 2,
  916. type: "byte",
  917. empty: true
  918. },
  919. alpha: {
  920. idx: 3,
  921. type: "percent",
  922. def: 1
  923. }
  924. }
  925. },
  926. hsla: {
  927. cache: "_hsla",
  928. props: {
  929. hue: {
  930. idx: 0,
  931. type: "degrees",
  932. empty: true
  933. },
  934. saturation: {
  935. idx: 1,
  936. type: "percent",
  937. empty: true
  938. },
  939. lightness: {
  940. idx: 2,
  941. type: "percent",
  942. empty: true
  943. }
  944. }
  945. }
  946. },
  947. propTypes = {
  948. "byte": {
  949. floor: true,
  950. min: 0,
  951. max: 255
  952. },
  953. "percent": {
  954. min: 0,
  955. max: 1
  956. },
  957. "degrees": {
  958. mod: 360,
  959. floor: true
  960. }
  961. },
  962. rgbaspace = spaces.rgba.props,
  963. support = color.support = {},
  964. // colors = jQuery.Color.names
  965. colors,
  966. // local aliases of functions called often
  967. each = jQuery.each;
  968. spaces.hsla.props.alpha = rgbaspace.alpha;
  969. function clamp( value, prop, alwaysAllowEmpty ) {
  970. var type = propTypes[ prop.type ] || {},
  971. allowEmpty = prop.empty || alwaysAllowEmpty;
  972. if ( allowEmpty && value == null ) {
  973. return null;
  974. }
  975. if ( prop.def && value == null ) {
  976. return prop.def;
  977. }
  978. if ( type.floor ) {
  979. value = ~~value;
  980. } else {
  981. value = parseFloat( value );
  982. }
  983. if ( value == null || isNaN( value ) ) {
  984. return prop.def;
  985. }
  986. if ( type.mod ) {
  987. value = value % type.mod;
  988. // -10 -> 350
  989. return value < 0 ? type.mod + value : value;
  990. }
  991. // for now all property types without mod have min and max
  992. return type.min > value ? type.min : type.max < value ? type.max : value;
  993. }
  994. function stringParse( string ) {
  995. var inst = color(),
  996. rgba = inst._rgba = [];
  997. string = string.toLowerCase();
  998. each( stringParsers, function( i, parser ) {
  999. var match = parser.re.exec( string ),
  1000. values = match && parser.parse( match ),
  1001. parsed,
  1002. spaceName = parser.space || "rgba",
  1003. cache = spaces[ spaceName ].cache;
  1004. if ( values ) {
  1005. parsed = inst[ spaceName ]( values );
  1006. // if this was an rgba parse the assignment might happen twice
  1007. // oh well....
  1008. inst[ cache ] = parsed[ cache ];
  1009. rgba = inst._rgba = parsed._rgba;
  1010. // exit each( stringParsers ) here because we matched
  1011. return false;
  1012. }
  1013. });
  1014. // Found a stringParser that handled it
  1015. if ( rgba.length !== 0 ) {
  1016. // if this came from a parsed string, force "transparent" when alpha is 0
  1017. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  1018. if ( Math.max.apply( Math, rgba ) === 0 ) {
  1019. jQuery.extend( rgba, colors.transparent );
  1020. }
  1021. return inst;
  1022. }
  1023. // named colors / default - filter back through parse function
  1024. if ( string = colors[ string ] ) {
  1025. return string;
  1026. }
  1027. }
  1028. color.fn = color.prototype = {
  1029. constructor: color,
  1030. parse: function( red, green, blue, alpha ) {
  1031. if ( red === undefined ) {
  1032. this._rgba = [ null, null, null, null ];
  1033. return this;
  1034. }
  1035. if ( red instanceof jQuery || red.nodeType ) {
  1036. red = red instanceof jQuery ? red.css( green ) : jQuery( red ).css( green );
  1037. green = undefined;
  1038. }
  1039. var inst = this,
  1040. type = jQuery.type( red ),
  1041. rgba = this._rgba = [],
  1042. source;
  1043. // more than 1 argument specified - assume ( red, green, blue, alpha )
  1044. if ( green !== undefined ) {
  1045. red = [ red, green, blue, alpha ];
  1046. type = "array";
  1047. }
  1048. if ( type === "string" ) {
  1049. return this.parse( stringParse( red ) || colors._default );
  1050. }
  1051. if ( type === "array" ) {
  1052. each( rgbaspace, function( key, prop ) {
  1053. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  1054. });
  1055. return this;
  1056. }
  1057. if ( type === "object" ) {
  1058. if ( red instanceof color ) {
  1059. each( spaces, function( spaceName, space ) {
  1060. if ( red[ space.cache ] ) {
  1061. inst[ space.cache ] = red[ space.cache ].slice();
  1062. }
  1063. });
  1064. } else {
  1065. each( spaces, function( spaceName, space ) {
  1066. each( space.props, function( key, prop ) {
  1067. var cache = space.cache;
  1068. // if the cache doesn't exist, and we know how to convert
  1069. if ( !inst[ cache ] && space.to ) {
  1070. // if the value was null, we don't need to copy it
  1071. // if the key was alpha, we don't need to copy it either
  1072. if ( red[ key ] == null || key === "alpha") {
  1073. return;
  1074. }
  1075. inst[ cache ] = space.to( inst._rgba );
  1076. }
  1077. // this is the only case where we allow nulls for ALL properties.
  1078. // call clamp with alwaysAllowEmpty
  1079. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  1080. });
  1081. });
  1082. }
  1083. return this;
  1084. }
  1085. },
  1086. is: function( compare ) {
  1087. var is = color( compare ),
  1088. same = true,
  1089. myself = this;
  1090. each( spaces, function( _, space ) {
  1091. var isCache = is[ space.cache ],
  1092. localCache;
  1093. if (isCache) {
  1094. localCache = myself[ space.cache ] || space.to && space.to( myself._rgba ) || [];
  1095. each( space.props, function( _, prop ) {
  1096. if ( isCache[ prop.idx ] != null ) {
  1097. same = ( isCache[ prop.idx ] == localCache[ prop.idx ] );
  1098. return same;
  1099. }
  1100. });
  1101. }
  1102. return same;
  1103. });
  1104. return same;
  1105. },
  1106. _space: function() {
  1107. var used = [],
  1108. inst = this;
  1109. each( spaces, function( spaceName, space ) {
  1110. if ( inst[ space.cache ] ) {
  1111. used.push( spaceName );
  1112. }
  1113. });
  1114. return used.pop();
  1115. },
  1116. transition: function( other, distance ) {
  1117. var end = color( other ),
  1118. spaceName = end._space(),
  1119. space = spaces[ spaceName ],
  1120. start = this[ space.cache ] || space.to( this._rgba ),
  1121. result = start.slice();
  1122. end = end[ space.cache ];
  1123. each( space.props, function( key, prop ) {
  1124. var index = prop.idx,
  1125. startValue = start[ index ],
  1126. endValue = end[ index ],
  1127. type = propTypes[ prop.type ] || {};
  1128. // if null, don't override start value
  1129. if ( endValue === null ) {
  1130. return;
  1131. }
  1132. // if null - use end
  1133. if ( startValue === null ) {
  1134. result[ index ] = endValue;
  1135. } else {
  1136. if ( type.mod ) {
  1137. if ( endValue - startValue > type.mod / 2 ) {
  1138. startValue += type.mod;
  1139. } else if ( startValue - endValue > type.mod / 2 ) {
  1140. startValue -= type.mod;
  1141. }
  1142. }
  1143. result[ prop.idx ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  1144. }
  1145. });
  1146. return this[ spaceName ]( result );
  1147. },
  1148. blend: function( opaque ) {
  1149. // if we are already opaque - return ourself
  1150. if ( this._rgba[ 3 ] === 1 ) {
  1151. return this;
  1152. }
  1153. var rgb = this._rgba.slice(),
  1154. a = rgb.pop(),
  1155. blend = color( opaque )._rgba;
  1156. return color( jQuery.map( rgb, function( v, i ) {
  1157. return ( 1 - a ) * blend[ i ] + a * v;
  1158. }));
  1159. },
  1160. toRgbaString: function() {
  1161. var prefix = "rgba(",
  1162. rgba = jQuery.map( this._rgba, function( v, i ) {
  1163. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  1164. });
  1165. if ( rgba[ 3 ] === 1 ) {
  1166. rgba.pop();
  1167. prefix = "rgb(";
  1168. }
  1169. return prefix + rgba.join(",") + ")";
  1170. },
  1171. toHslaString: function() {
  1172. var prefix = "hsla(",
  1173. hsla = jQuery.map( this.hsla(), function( v, i ) {
  1174. if ( v == null ) {
  1175. v = i > 2 ? 1 : 0;
  1176. }
  1177. // catch 1 and 2
  1178. if ( i && i < 3 ) {
  1179. v = Math.round( v * 100 ) + "%";
  1180. }
  1181. return v;
  1182. });
  1183. if ( hsla[ 3 ] == 1 ) {
  1184. hsla.pop();
  1185. prefix = "hsl(";
  1186. }
  1187. return prefix + hsla.join(",") + ")";
  1188. },
  1189. toHexString: function( includeAlpha ) {
  1190. var rgba = this._rgba.slice(),
  1191. alpha = rgba.pop();
  1192. if ( includeAlpha ) {
  1193. rgba.push( ~~( alpha * 255 ) );
  1194. }
  1195. return "#" + jQuery.map( rgba, function( v, i ) {
  1196. // default to 0 when nulls exist
  1197. v = ( v || 0 ).toString( 16 );
  1198. return v.length == 1 ? "0" + v : v;
  1199. }).join("");
  1200. },
  1201. toString: function() {
  1202. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  1203. }
  1204. };
  1205. color.fn.parse.prototype = color.fn;
  1206. // hsla conversions adapted from:
  1207. // http://www.google.com/codesearch/p#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/inspector/front-end/Color.js&d=7&l=193
  1208. function hue2rgb( p, q, h ) {
  1209. h = ( h + 1 ) % 1;
  1210. if ( h * 6 < 1 ) {
  1211. return p + (q - p) * 6 * h;
  1212. }
  1213. if ( h * 2 < 1) {
  1214. return q;
  1215. }
  1216. if ( h * 3 < 2 ) {
  1217. return p + (q - p) * ((2/3) - h) * 6;
  1218. }
  1219. return p;
  1220. }
  1221. spaces.hsla.to = function ( rgba ) {
  1222. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  1223. return [ null, null, null, rgba[ 3 ] ];
  1224. }
  1225. var r = rgba[ 0 ] / 255,
  1226. g = rgba[ 1 ] / 255,
  1227. b = rgba[ 2 ] / 255,
  1228. a = rgba[ 3 ],
  1229. max = Math.max( r, g, b ),
  1230. min = Math.min( r, g, b ),
  1231. diff = max - min,
  1232. add = max + min,
  1233. l = add * 0.5,
  1234. h, s;
  1235. if ( min === max ) {
  1236. h = 0;
  1237. } else if ( r === max ) {
  1238. h = ( 60 * ( g - b ) / diff ) + 360;
  1239. } else if ( g === max ) {
  1240. h = ( 60 * ( b - r ) / diff ) + 120;
  1241. } else {
  1242. h = ( 60 * ( r - g ) / diff ) + 240;
  1243. }
  1244. if ( l === 0 || l === 1 ) {
  1245. s = l;
  1246. } else if ( l <= 0.5 ) {
  1247. s = diff / add;
  1248. } else {
  1249. s = diff / ( 2 - add );
  1250. }
  1251. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  1252. };
  1253. spaces.hsla.from = function ( hsla ) {
  1254. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  1255. return [ null, null, null, hsla[ 3 ] ];
  1256. }
  1257. var h = hsla[ 0 ] / 360,
  1258. s = hsla[ 1 ],
  1259. l = hsla[ 2 ],
  1260. a = hsla[ 3 ],
  1261. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  1262. p = 2 * l - q,
  1263. r, g, b;
  1264. return [
  1265. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  1266. Math.round( hue2rgb( p, q, h ) * 255 ),
  1267. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  1268. a
  1269. ];
  1270. };
  1271. each( spaces, function( spaceName, space ) {
  1272. var props = space.props,
  1273. cache = space.cache,
  1274. to = space.to,
  1275. from = space.from;
  1276. // makes rgba() and hsla()
  1277. color.fn[ spaceName ] = function( value ) {
  1278. // generate a cache for this space if it doesn't exist
  1279. if ( to && !this[ cache ] ) {
  1280. this[ cache ] = to( this._rgba );
  1281. }
  1282. if ( value === undefined ) {
  1283. return this[ cache ].slice();
  1284. }
  1285. var type = jQuery.type( value ),
  1286. arr = ( type === "array" || type === "object" ) ? value : arguments,
  1287. local = this[ cache ].slice(),
  1288. ret;
  1289. each( props, function( key, prop ) {
  1290. var val = arr[ type === "object" ? key : prop.idx ];
  1291. if ( val == null ) {
  1292. val = local[ prop.idx ];
  1293. }
  1294. local[ prop.idx ] = clamp( val, prop );
  1295. });
  1296. if ( from ) {
  1297. ret = color( from( local ) );
  1298. ret[ cache ] = local;
  1299. return ret;
  1300. } else {
  1301. return color( local );
  1302. }
  1303. };
  1304. // makes red() green() blue() alpha() hue() saturation() lightness()
  1305. each( props, function( key, prop ) {
  1306. // alpha is included in more than one space
  1307. if ( color.fn[ key ] ) {
  1308. return;
  1309. }
  1310. color.fn[ key ] = function( value ) {
  1311. var vtype = jQuery.type( value ),
  1312. fn = ( key === 'alpha' ? ( this._hsla ? 'hsla' : 'rgba' ) : spaceName ),
  1313. local = this[ fn ](),
  1314. cur = local[ prop.idx ],
  1315. match;
  1316. if ( vtype === "undefined" ) {
  1317. return cur;
  1318. }
  1319. if ( vtype === "function" ) {
  1320. value = value.call( this, cur );
  1321. vtype = jQuery.type( value );
  1322. }
  1323. if ( value == null && prop.empty ) {
  1324. return this;
  1325. }
  1326. if ( vtype === "string" ) {
  1327. match = rplusequals.exec( value );
  1328. if ( match ) {
  1329. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  1330. }
  1331. }
  1332. local[ prop.idx ] = value;
  1333. return this[ fn ]( local );
  1334. };
  1335. });
  1336. });
  1337. // add .fx.step functions
  1338. each( stepHooks, function( i, hook ) {
  1339. jQuery.cssHooks[ hook ] = {
  1340. set: function( elem, value ) {
  1341. var parsed;
  1342. if ( jQuery.type( value ) !== 'string' || ( parsed = stringParse( value ) ) )
  1343. {
  1344. value = color( parsed || value );
  1345. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  1346. var backgroundColor,
  1347. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  1348. do {
  1349. backgroundColor = jQuery.curCSS( curElem, "backgroundColor" );
  1350. } while (
  1351. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  1352. ( curElem = curElem.parentNode ) &&
  1353. curElem.style
  1354. );
  1355. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  1356. backgroundColor :
  1357. "_default" );
  1358. }
  1359. value = value.toRgbaString();
  1360. }
  1361. elem.style[ hook ] = value;
  1362. }
  1363. };
  1364. jQuery.fx.step[ hook ] = function( fx ) {
  1365. if ( !fx.colorInit ) {
  1366. fx.start = color( fx.elem, hook );
  1367. fx.end = color( fx.end );
  1368. fx.colorInit = true;
  1369. }
  1370. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  1371. };
  1372. });
  1373. // detect rgba support
  1374. jQuery(function() {
  1375. var div = document.createElement( "div" ),
  1376. div_style = div.style;
  1377. div_style.cssText = "background-color:rgba(1,1,1,.5)";
  1378. support.rgba = div_style.backgroundColor.indexOf( "rgba" ) > -1;
  1379. });
  1380. // Some named colors to work with
  1381. // From Interface by Stefan Petre
  1382. // http://interface.eyecon.ro/
  1383. colors = jQuery.Color.names = {
  1384. aqua: "#00ffff",
  1385. azure: "#f0ffff",
  1386. beige: "#f5f5dc",
  1387. black: "#000000",
  1388. blue: "#0000ff",
  1389. brown: "#a52a2a",
  1390. cyan: "#00ffff",
  1391. darkblue: "#00008b",
  1392. darkcyan: "#008b8b",
  1393. darkgrey: "#a9a9a9",
  1394. darkgreen: "#006400",
  1395. darkkhaki: "#bdb76b",
  1396. darkmagenta: "#8b008b",
  1397. darkolivegreen: "#556b2f",
  1398. darkorange: "#ff8c00",
  1399. darkorchid: "#9932cc",
  1400. darkred: "#8b0000",
  1401. darksalmon: "#e9967a",
  1402. darkviolet: "#9400d3",
  1403. fuchsia: "#ff00ff",
  1404. gold: "#ffd700",
  1405. green: "#008000",
  1406. indigo: "#4b0082",
  1407. khaki: "#f0e68c",
  1408. lightblue: "#add8e6",
  1409. lightcyan: "#e0ffff",
  1410. lightgreen: "#90ee90",
  1411. lightgrey: "#d3d3d3",
  1412. lightpink: "#ffb6c1",
  1413. lightyellow: "#ffffe0",
  1414. lime: "#00ff00",
  1415. magenta: "#ff00ff",
  1416. maroon: "#800000",
  1417. navy: "#000080",
  1418. olive: "#808000",
  1419. orange: "#ffa500",
  1420. pink: "#ffc0cb",
  1421. purple: "#800080",
  1422. violet: "#800080",
  1423. red: "#ff0000",
  1424. silver: "#c0c0c0",
  1425. white: "#ffffff",
  1426. yellow: "#ffff00",
  1427. transparent: [ null, null, null, 0 ],
  1428. _default: "#ffffff"
  1429. };
  1430. })( jQuery );