Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 118.59 KB | None | 0 0
  1. /**
  2. * jQuery iLightBox - Revolutionary Lightbox Plugin
  3. * http://www.ilightbox.net/
  4. *
  5. * @version: 2.2.0 - September 23, 2014
  6. *
  7. * @author: Hemn Chawroka
  8. * http://www.iprodev.com/
  9. *
  10. */
  11. (function($, window, undefined) {
  12.  
  13. var extensions = {
  14. flash: ['swf'],
  15. image: ['bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff', 'tif', 'jfif', 'jpe'],
  16. iframe: ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'jsp', 'php', 'pl', 'php3', 'php4', 'php5', 'phtml', 'rb', 'rhtml', 'shtml', 'txt'],
  17. video: ['avi', 'mov', 'mpg', 'mpeg', 'movie', 'mp4', 'webm', 'ogv', 'ogg', '3gp', 'm4v']
  18. },
  19.  
  20. // Global DOM elements
  21. $win = $(window),
  22. $doc = $(document),
  23.  
  24. // Support indicators
  25. browser,
  26. transform,
  27. gpuAcceleration,
  28. fullScreenApi = '',
  29. supportTouch = !!('ontouchstart' in window) && (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),
  30.  
  31. // Events
  32. clickEvent = supportTouch ? "itap.iLightBox" : "click.iLightBox",
  33. touchStartEvent = supportTouch ? "touchstart.iLightBox" : "mousedown.iLightBox",
  34. touchStopEvent = supportTouch ? "touchend.iLightBox" : "mouseup.iLightBox",
  35. touchMoveEvent = supportTouch ? "touchmove.iLightBox" : "mousemove.iLightBox",
  36.  
  37. // Math shorthands
  38. abs = Math.abs,
  39. sqrt = Math.sqrt,
  40. round = Math.round,
  41. max = Math.max,
  42. min = Math.min,
  43. floor = Math.floor,
  44. random = Math.random,
  45.  
  46. pluginspages = {
  47. quicktime: 'http://www.apple.com/quicktime/download',
  48. flash: 'http://www.adobe.com/go/getflash'
  49. },
  50.  
  51. iLightBox = function(el, options, items, instant) {
  52. var iL = this;
  53.  
  54. iL.options = options,
  55. iL.selector = el.selector || el,
  56. iL.context = el.context,
  57. iL.instant = instant;
  58.  
  59. if (items.length < 1) iL.attachItems();
  60. else iL.items = items;
  61.  
  62. iL.vars = {
  63. total: iL.items.length,
  64. start: 0,
  65. current: null,
  66. next: null,
  67. prev: null,
  68. BODY: $('body'),
  69. loadRequests: 0,
  70. overlay: $('<div class="ilightbox-overlay"></div>'),
  71. loader: $('<div class="ilightbox-loader"><div></div></div>'),
  72. toolbar: $('<div class="ilightbox-toolbar"></div>'),
  73. innerToolbar: $('<div class="ilightbox-inner-toolbar"></div>'),
  74. title: $('<div class="ilightbox-title"></div>'),
  75. closeButton: $('<a class="ilightbox-close" title="' + iL.options.text.close + '"></a>'),
  76. fullScreenButton: $('<a class="ilightbox-fullscreen" title="' + iL.options.text.enterFullscreen + '"></a>'),
  77. innerPlayButton: $('<a class="ilightbox-play" title="' + iL.options.text.slideShow + '"></a>'),
  78. innerNextButton: $('<a class="ilightbox-next-button" title="' + iL.options.text.next + '"></a>'),
  79. innerPrevButton: $('<a class="ilightbox-prev-button" title="' + iL.options.text.previous + '"></a>'),
  80. holder: $('<div class="ilightbox-holder' + (supportTouch ? ' supportTouch' : '') + '" ondragstart="return false;"><div class="ilightbox-container"></div></div>'),
  81. nextPhoto: $('<div class="ilightbox-holder' + (supportTouch ? ' supportTouch' : '') + ' ilightbox-next" ondragstart="return false;"><div class="ilightbox-container"></div></div>'),
  82. prevPhoto: $('<div class="ilightbox-holder' + (supportTouch ? ' supportTouch' : '') + ' ilightbox-prev" ondragstart="return false;"><div class="ilightbox-container"></div></div>'),
  83. nextButton: $('<a class="ilightbox-button ilightbox-next-button" ondragstart="return false;" title="' + iL.options.text.next + '"><span></span></a>'),
  84. prevButton: $('<a class="ilightbox-button ilightbox-prev-button" ondragstart="return false;" title="' + iL.options.text.previous + '"><span></span></a>'),
  85. thumbnails: $('<div class="ilightbox-thumbnails" ondragstart="return false;"><div class="ilightbox-thumbnails-container"><a class="ilightbox-thumbnails-dragger"></a><div class="ilightbox-thumbnails-grid"></div></div></div>'),
  86. thumbs: false,
  87. nextLock: false,
  88. prevLock: false,
  89. hashLock: false,
  90. isMobile: false,
  91. mobileMaxWidth: 980,
  92. isInFullScreen: false,
  93. isSwipe: false,
  94. mouseID: 0,
  95. cycleID: 0,
  96. isPaused: 0
  97. };
  98.  
  99. // Hideable elements with mousemove event
  100. iL.vars.hideableElements = iL.vars.nextButton.add(iL.vars.prevButton);
  101.  
  102. iL.normalizeItems();
  103.  
  104. //Check necessary plugins
  105. iL.availPlugins();
  106.  
  107. //Set startFrom
  108. iL.options.startFrom = (iL.options.startFrom > 0 && iL.options.startFrom >= iL.vars.total) ? iL.vars.total - 1 : iL.options.startFrom;
  109.  
  110. //If randomStart
  111. iL.options.startFrom = (iL.options.randomStart) ? floor(random() * iL.vars.total) : iL.options.startFrom;
  112. iL.vars.start = iL.options.startFrom;
  113.  
  114. if (instant) iL.instantCall();
  115. else iL.patchItemsEvents();
  116.  
  117. if (iL.options.linkId) {
  118. iL.hashChangeHandler();
  119. $win.iLightBoxHashChange(function() {
  120. iL.hashChangeHandler();
  121. });
  122. }
  123.  
  124. if (supportTouch) {
  125. var RegExp = /(click|mouseenter|mouseleave|mouseover|mouseout)/ig,
  126. replace = "itap";
  127. iL.options.caption.show = iL.options.caption.show.replace(RegExp, replace),
  128. iL.options.caption.hide = iL.options.caption.hide.replace(RegExp, replace),
  129. iL.options.social.show = iL.options.social.show.replace(RegExp, replace),
  130. iL.options.social.hide = iL.options.social.hide.replace(RegExp, replace);
  131. }
  132.  
  133. if (iL.options.controls.arrows) {
  134. $.extend(iL.options.styles, {
  135. nextOffsetX: 0,
  136. prevOffsetX: 0,
  137. nextOpacity: 0,
  138. prevOpacity: 0
  139. });
  140. }
  141. };
  142.  
  143. //iLightBox helpers
  144. iLightBox.prototype = {
  145. showLoader: function() {
  146. var iL = this;
  147. iL.vars.loadRequests += 1;
  148. if (iL.options.path.toLowerCase() == "horizontal") iL.vars.loader.stop().animate({
  149. top: '-30px'
  150. }, iL.options.show.speed, 'easeOutCirc');
  151. else iL.vars.loader.stop().animate({
  152. left: '-30px'
  153. }, iL.options.show.speed, 'easeOutCirc');
  154. },
  155.  
  156. hideLoader: function() {
  157. var iL = this;
  158. iL.vars.loadRequests -= 1;
  159. iL.vars.loadRequests = (iL.vars.loadRequests < 0) ? 0 : iL.vars.loadRequests;
  160. if (iL.options.path.toLowerCase() == "horizontal") {
  161. if (iL.vars.loadRequests <= 0) iL.vars.loader.stop().animate({
  162. top: '-192px'
  163. }, iL.options.show.speed, 'easeInCirc');
  164. } else {
  165. if (iL.vars.loadRequests <= 0) iL.vars.loader.stop().animate({
  166. left: '-192px'
  167. }, iL.options.show.speed, 'easeInCirc');
  168. }
  169. },
  170.  
  171. createUI: function() {
  172. var iL = this;
  173.  
  174. iL.ui = {
  175. currentElement: iL.vars.holder,
  176. nextElement: iL.vars.nextPhoto,
  177. prevElement: iL.vars.prevPhoto,
  178. currentItem: iL.vars.current,
  179. nextItem: iL.vars.next,
  180. prevItem: iL.vars.prev,
  181. hide: function() {
  182. iL.closeAction();
  183. },
  184. refresh: function() {
  185. (arguments.length > 0) ? iL.repositionPhoto(true): iL.repositionPhoto();
  186. },
  187. fullscreen: function() {
  188. iL.fullScreenAction();
  189. }
  190. };
  191. },
  192.  
  193. attachItems: function() {
  194. var iL = this,
  195. itemsObject = new Array(),
  196. items = new Array();
  197.  
  198. $(iL.selector, iL.context).each(function() {
  199. var t = $(this),
  200. URL = t.attr(iL.options.attr) || null,
  201. options = t.data("options") && eval("({" + t.data("options") + "})") || {},
  202. caption = t.data('caption'),
  203. title = t.data('title'),
  204. type = t.data('type') || getTypeByExtension(URL);
  205.  
  206. items.push({
  207. URL: URL,
  208. caption: caption,
  209. title: title,
  210. type: type,
  211. options: options
  212. });
  213.  
  214. if (!iL.instant) itemsObject.push(t);
  215. });
  216.  
  217. iL.items = items,
  218. iL.itemsObject = itemsObject;
  219. },
  220.  
  221. normalizeItems: function() {
  222. var iL = this,
  223. newItems = new Array();
  224.  
  225. $.each(iL.items, function(key, val) {
  226.  
  227. if (typeof val == "string") val = {
  228. url: val
  229. };
  230.  
  231. var URL = val.url || val.URL || null,
  232. options = val.options || {},
  233. caption = val.caption || null,
  234. title = val.title || null,
  235. type = (val.type) ? val.type.toLowerCase() : getTypeByExtension(URL),
  236. ext = (typeof URL != 'object') ? getExtension(URL) : '';
  237.  
  238. options.thumbnail = options.thumbnail || ((type == "image") ? URL : null),
  239. options.videoType = options.videoType || null,
  240. options.skin = options.skin || iL.options.skin,
  241. options.width = options.width || null,
  242. options.height = options.height || null,
  243. options.mousewheel = (typeof options.mousewheel != 'undefined') ? options.mousewheel : true,
  244. options.swipe = (typeof options.swipe != 'undefined') ? options.swipe : true,
  245. options.social = (typeof options.social != 'undefined') ? options.social : iL.options.social.buttons && $.extend({}, {}, iL.options.social.buttons);
  246.  
  247. if (type == "video") {
  248. options.html5video = (typeof options.html5video != 'undefined') ? options.html5video : {};
  249.  
  250. options.html5video.webm = options.html5video.webm || options.html5video.WEBM || null;
  251. options.html5video.controls = (typeof options.html5video.controls != 'undefined') ? options.html5video.controls : "controls";
  252. options.html5video.preload = options.html5video.preload || "metadata";
  253. options.html5video.autoplay = (typeof options.html5video.autoplay != 'undefined') ? options.html5video.autoplay : false;
  254. }
  255.  
  256. if (!options.width || !options.height) {
  257. if (type == "video") options.width = 1280, options.height = 720;
  258. else if (type == "iframe") options.width = '100%', options.height = '90%';
  259. else if (type == "flash") options.width = 1280, options.height = 720;
  260. }
  261.  
  262. delete val.url;
  263. val.index = key;
  264. val.URL = URL;
  265. val.caption = caption;
  266. val.title = title;
  267. val.type = type;
  268. val.options = options;
  269. val.ext = ext;
  270.  
  271. newItems.push(val);
  272. });
  273.  
  274. iL.items = newItems;
  275. },
  276.  
  277. instantCall: function() {
  278. var iL = this,
  279. key = iL.vars.start;
  280.  
  281. iL.vars.current = key;
  282. iL.vars.next = (iL.items[key + 1]) ? key + 1 : null;
  283. iL.vars.prev = (iL.items[key - 1]) ? key - 1 : null;
  284.  
  285. iL.addContents();
  286. iL.patchEvents();
  287. },
  288.  
  289. addContents: function() {
  290. var iL = this,
  291. vars = iL.vars,
  292. opts = iL.options,
  293. viewport = getViewport(),
  294. path = opts.path.toLowerCase(),
  295. recognizingItems = vars.total > 0 && iL.items.filter(function(e, i, arr) {
  296. return ['image', 'flash', 'video'].indexOf(e.type) === -1 && typeof e.recognized === 'undefined' && (opts.smartRecognition || e.options.smartRecognition);
  297. }),
  298. needRecognition = recognizingItems.length > 0;
  299.  
  300. if (opts.mobileOptimizer && !opts.innerToolbar)
  301. vars.isMobile = viewport.width <= vars.mobileMaxWidth;
  302.  
  303. vars.overlay.addClass(opts.skin).hide().css('opacity', opts.overlay.opacity);
  304.  
  305. if (opts.linkId)
  306. vars.overlay[0].setAttribute('linkid', opts.linkId);
  307.  
  308. //Add Toolbar Buttons
  309. if (opts.controls.toolbar) {
  310. vars.toolbar.addClass(opts.skin).append(vars.closeButton);
  311. if (opts.controls.fullscreen)
  312. vars.toolbar.append(vars.fullScreenButton);
  313. if (opts.controls.slideshow)
  314. vars.toolbar.append(vars.innerPlayButton);
  315. if (vars.total > 1)
  316. vars.toolbar.append(vars.innerPrevButton).append(vars.innerNextButton);
  317. }
  318.  
  319. //Append elements to body
  320. vars.BODY.addClass('ilightbox-noscroll').append(vars.overlay).append(vars.loader).append(vars.holder).append(vars.nextPhoto).append(vars.prevPhoto);
  321.  
  322. if (!opts.innerToolbar)
  323. vars.BODY.append(vars.toolbar);
  324. if (opts.controls.arrows)
  325. vars.BODY.append(vars.nextButton).append(vars.prevButton);
  326.  
  327. if (opts.controls.thumbnail && vars.total > 1) {
  328. vars.BODY.append(vars.thumbnails);
  329. vars.thumbnails.addClass(opts.skin).addClass('ilightbox-' + path);
  330. $('div.ilightbox-thumbnails-grid', vars.thumbnails).empty();
  331. vars.thumbs = true;
  332. }
  333.  
  334. //Configure loader and arrows
  335. var loaderCss = (opts.path.toLowerCase() == "horizontal") ? {
  336. left: parseInt((viewport.width / 2) - (vars.loader.outerWidth() / 2))
  337. } : {
  338. top: parseInt((viewport.height / 2) - (vars.loader.outerHeight() / 2))
  339. };
  340. vars.loader.addClass(opts.skin).css(loaderCss);
  341. vars.nextButton.add(vars.prevButton).addClass(opts.skin);
  342. if (path == "horizontal")
  343. vars.loader.add(vars.nextButton).add(vars.prevButton).addClass('horizontal');
  344.  
  345. // Configure arrow buttons
  346. vars.BODY[vars.isMobile ? 'addClass' : 'removeClass']('isMobile');
  347.  
  348. if (!opts.infinite) {
  349. vars.prevButton.add(vars.prevButton).add(vars.innerPrevButton).add(vars.innerNextButton).removeClass('disabled');
  350.  
  351. if (vars.current == 0)
  352. vars.prevButton.add(vars.innerPrevButton).addClass('disabled');
  353. if (vars.current >= vars.total - 1)
  354. vars.nextButton.add(vars.innerNextButton).addClass('disabled');
  355. }
  356.  
  357. if (opts.show.effect) {
  358. vars.overlay.stop().fadeIn(opts.show.speed);
  359. vars.toolbar.stop().fadeIn(opts.show.speed);
  360. } else {
  361. vars.overlay.show();
  362. vars.toolbar.show();
  363. }
  364.  
  365. var length = recognizingItems.length;
  366. if (needRecognition) {
  367. iL.showLoader();
  368.  
  369. $.each(recognizingItems, function(key, val) {
  370. var resultFnc = function(result) {
  371. var key = -1,
  372. filter = iL.items.filter(function(e, i, arr) {
  373. if (e.URL == result.url)
  374. key = i;
  375.  
  376. return e.URL == result.url;
  377. }),
  378. self = iL.items[key];
  379.  
  380. if (result)
  381. $.extend(true, self, {
  382. URL: result.source,
  383. type: result.type,
  384. recognized: true,
  385. options: {
  386. html5video: result.html5video,
  387. width: (result.type == "image") ? 0 : (result.width || self.width),
  388. height: (result.type == "image") ? 0 : (result.height || self.height),
  389. thumbnail: self.options.thumbnail || result.thumbnail
  390. }
  391. });
  392.  
  393. length--;
  394.  
  395. if (length == 0) {
  396. iL.hideLoader();
  397.  
  398. vars.dontGenerateThumbs = false;
  399. iL.generateThumbnails();
  400.  
  401. if (opts.show.effect)
  402. setTimeout(function() {
  403. iL.generateBoxes();
  404. }, opts.show.speed);
  405. else
  406. iL.generateBoxes();
  407. }
  408. };
  409.  
  410. iL.ogpRecognition(this, resultFnc);
  411. });
  412. }
  413. else {
  414. if (opts.show.effect)
  415. setTimeout(function() {
  416. iL.generateBoxes();
  417. }, opts.show.speed);
  418. else
  419. iL.generateBoxes();
  420. }
  421.  
  422. iL.createUI();
  423.  
  424. window.iLightBox = {
  425. close: function() {
  426. iL.closeAction();
  427. },
  428. fullscreen: function() {
  429. iL.fullScreenAction();
  430. },
  431. moveNext: function() {
  432. iL.moveTo('next');
  433. },
  434. movePrev: function() {
  435. iL.moveTo('prev');
  436. },
  437. goTo: function(index) {
  438. iL.goTo(index);
  439. },
  440. refresh: function() {
  441. iL.refresh();
  442. },
  443. reposition: function() {
  444. (arguments.length > 0) ? iL.repositionPhoto(true): iL.repositionPhoto();
  445. },
  446. setOption: function(options) {
  447. iL.setOption(options);
  448. },
  449. destroy: function() {
  450. iL.closeAction();
  451. iL.dispatchItemsEvents();
  452. }
  453. };
  454.  
  455. if (opts.linkId) {
  456. vars.hashLock = true;
  457. window.location.hash = opts.linkId + '/' + vars.current;
  458. setTimeout(function() {
  459. vars.hashLock = false;
  460. }, 55);
  461. }
  462.  
  463. if (!opts.slideshow.startPaused) {
  464. iL.resume();
  465. vars.innerPlayButton.removeClass('ilightbox-play').addClass('ilightbox-pause');
  466. }
  467.  
  468. //Trigger the onOpen callback
  469. if (typeof iL.options.callback.onOpen == 'function') iL.options.callback.onOpen.call(iL);
  470. },
  471.  
  472. loadContent: function(obj, opt, speed) {
  473. var iL = this,
  474. holder, item;
  475.  
  476. iL.createUI();
  477.  
  478. obj.speed = speed || iL.options.effects.loadedFadeSpeed;
  479.  
  480. if (opt == 'current') {
  481. if (!obj.options.mousewheel) iL.vars.lockWheel = true;
  482. else iL.vars.lockWheel = false;
  483.  
  484. if (!obj.options.swipe) iL.vars.lockSwipe = true;
  485. else iL.vars.lockSwipe = false;
  486. }
  487.  
  488. switch (opt) {
  489. case 'current':
  490. holder = iL.vars.holder, item = iL.vars.current;
  491. break;
  492. case 'next':
  493. holder = iL.vars.nextPhoto, item = iL.vars.next;
  494. break;
  495. case 'prev':
  496. holder = iL.vars.prevPhoto, item = iL.vars.prev;
  497. break;
  498. }
  499.  
  500. holder.removeAttr('style class').addClass('ilightbox-holder' + (supportTouch ? ' supportTouch' : '')).addClass(obj.options.skin);
  501. $('div.ilightbox-inner-toolbar', holder).remove();
  502.  
  503. if (obj.title || iL.options.innerToolbar) {
  504. var innerToolbar = iL.vars.innerToolbar.clone();
  505. if (obj.title && iL.options.show.title) {
  506. var title = iL.vars.title.clone();
  507. title.empty().html(obj.title);
  508. innerToolbar.append(title);
  509. }
  510. if (iL.options.innerToolbar) {
  511. innerToolbar.append((iL.vars.total > 1) ? iL.vars.toolbar.clone() : iL.vars.toolbar);
  512. }
  513. holder.prepend(innerToolbar);
  514. }
  515.  
  516. iL.loadSwitcher(obj, holder, item, opt);
  517. },
  518.  
  519. loadSwitcher: function(obj, holder, item, opt) {
  520. var iL = this,
  521. opts = iL.options,
  522. api = {
  523. element: holder,
  524. position: item
  525. };
  526.  
  527. switch (obj.type) {
  528. case 'image':
  529. //Trigger the onBeforeLoad callback
  530. if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
  531. if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
  532.  
  533. iL.loadImage(obj.URL, function(img) {
  534. //Trigger the onAfterLoad callback
  535. if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
  536. if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
  537.  
  538. var width = (img) ? img.width : 400,
  539. height = (img) ? img.height : 200;
  540.  
  541. holder.data({
  542. naturalWidth: width,
  543. naturalHeight: height
  544. });
  545. $('div.ilightbox-container', holder).empty().append((img) ? '<img src="' + obj.URL + '" class="ilightbox-image" />' : '<span class="ilightbox-alert">' + opts.errors.loadImage + '</span>');
  546.  
  547. //Trigger the onRender callback
  548. if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
  549. if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
  550.  
  551. iL.configureHolder(obj, opt, holder);
  552. });
  553.  
  554. break;
  555.  
  556. case 'video':
  557. holder.data({
  558. naturalWidth: obj.options.width,
  559. naturalHeight: obj.options.height
  560. });
  561.  
  562. iL.addContent(holder, obj);
  563.  
  564. //Trigger the onRender callback
  565. if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
  566. if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
  567.  
  568. iL.configureHolder(obj, opt, holder);
  569.  
  570. break;
  571.  
  572. case 'iframe':
  573. iL.showLoader();
  574. holder.data({
  575. naturalWidth: obj.options.width,
  576. naturalHeight: obj.options.height
  577. });
  578. var el = iL.addContent(holder, obj);
  579.  
  580. //Trigger the onRender callback
  581. if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
  582. if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
  583.  
  584. //Trigger the onBeforeLoad callback
  585. if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
  586. if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
  587.  
  588. el.bind('load', function() {
  589. //Trigger the onAfterLoad callback
  590. if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
  591. if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
  592.  
  593. iL.hideLoader();
  594. iL.configureHolder(obj, opt, holder);
  595. el.unbind('load');
  596. });
  597.  
  598. break;
  599.  
  600. case 'inline':
  601. var el = $(obj.URL),
  602. content = iL.addContent(holder, obj),
  603. images = findImageInElement(holder);
  604.  
  605. holder.data({
  606. naturalWidth: (iL.items[item].options.width || el.outerWidth()),
  607. naturalHeight: (iL.items[item].options.height || el.outerHeight())
  608. });
  609. content.children().eq(0).show();
  610.  
  611. //Trigger the onRender callback
  612. if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
  613. if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
  614.  
  615. //Trigger the onBeforeLoad callback
  616. if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
  617. if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
  618.  
  619. iL.loadImage(images, function() {
  620. //Trigger the onAfterLoad callback
  621. if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
  622. if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
  623.  
  624. iL.configureHolder(obj, opt, holder);
  625. });
  626.  
  627. break;
  628.  
  629. case 'flash':
  630. var el = iL.addContent(holder, obj);
  631.  
  632. holder.data({
  633. naturalWidth: (iL.items[item].options.width || el.outerWidth()),
  634. naturalHeight: (iL.items[item].options.height || el.outerHeight())
  635. });
  636.  
  637. //Trigger the onRender callback
  638. if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
  639. if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
  640.  
  641. iL.configureHolder(obj, opt, holder);
  642.  
  643. break;
  644.  
  645. case 'ajax':
  646. var ajax = obj.options.ajax || {};
  647. //Trigger the onBeforeLoad callback
  648. if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
  649. if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
  650.  
  651. iL.showLoader();
  652. $.ajax({
  653. url: obj.URL || opts.ajaxSetup.url,
  654. data: ajax.data || null,
  655. dataType: ajax.dataType || "html",
  656. type: ajax.type || opts.ajaxSetup.type,
  657. cache: ajax.cache || opts.ajaxSetup.cache,
  658. crossDomain: ajax.crossDomain || opts.ajaxSetup.crossDomain,
  659. global: ajax.global || opts.ajaxSetup.global,
  660. ifModified: ajax.ifModified || opts.ajaxSetup.ifModified,
  661. username: ajax.username || opts.ajaxSetup.username,
  662. password: ajax.password || opts.ajaxSetup.password,
  663. beforeSend: ajax.beforeSend || opts.ajaxSetup.beforeSend,
  664. complete: ajax.complete || opts.ajaxSetup.complete,
  665. success: function(data, textStatus, jqXHR) {
  666. iL.hideLoader();
  667.  
  668. var el = $(data),
  669. container = $('div.ilightbox-container', holder),
  670. elWidth = iL.items[item].options.width || parseInt(el[0].getAttribute('width')),
  671. elHeight = iL.items[item].options.height || parseInt(el[0].getAttribute('height')),
  672. css = (el[0].getAttribute('width') && el[0].getAttribute('height')) ? {
  673. 'overflow': 'hidden'
  674. } : {};
  675.  
  676. container.empty().append($('<div class="ilightbox-wrapper"></div>').css(css).html(el));
  677. holder.show().data({
  678. naturalWidth: (elWidth || container.outerWidth()),
  679. naturalHeight: (elHeight || container.outerHeight())
  680. }).hide();
  681.  
  682. //Trigger the onRender callback
  683. if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
  684. if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
  685.  
  686. var images = findImageInElement(holder);
  687. iL.loadImage(images, function() {
  688. //Trigger the onAfterLoad callback
  689. if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
  690. if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
  691.  
  692. iL.configureHolder(obj, opt, holder);
  693. });
  694.  
  695. opts.ajaxSetup.success(data, textStatus, jqXHR);
  696. if (typeof ajax.success == 'function') ajax.success(data, textStatus, jqXHR);
  697. },
  698. error: function(jqXHR, textStatus, errorThrown) {
  699. //Trigger the onAfterLoad callback
  700. if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
  701. if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
  702.  
  703. iL.hideLoader();
  704. $('div.ilightbox-container', holder).empty().append('<span class="ilightbox-alert">' + opts.errors.loadContents + '</span>');
  705. iL.configureHolder(obj, opt, holder);
  706.  
  707. opts.ajaxSetup.error(jqXHR, textStatus, errorThrown);
  708. if (typeof ajax.error == 'function') ajax.error(jqXHR, textStatus, errorThrown);
  709. }
  710. });
  711.  
  712. break;
  713.  
  714. case 'html':
  715. var object = obj.URL,
  716. el
  717. container = $('div.ilightbox-container', holder);
  718.  
  719. if (object[0].nodeName) el = object.clone();
  720. else {
  721. var dom = $(object);
  722. if (dom.selector) el = $('<div>' + dom + '</div>');
  723. else el = dom;
  724. }
  725.  
  726. var elWidth = iL.items[item].options.width || parseInt(el.attr('width')),
  727. elHeight = iL.items[item].options.height || parseInt(el.attr('height'));
  728.  
  729. iL.addContent(holder, obj);
  730.  
  731. el.appendTo(document.documentElement).hide();
  732.  
  733. //Trigger the onRender callback
  734. if (typeof opts.callback.onRender == 'function') opts.callback.onRender.call(iL, iL.ui, item);
  735. if (typeof obj.options.onRender == 'function') obj.options.onRender.call(iL, api);
  736.  
  737. var images = findImageInElement(holder);
  738.  
  739. //Trigger the onBeforeLoad callback
  740. if (typeof opts.callback.onBeforeLoad == 'function') opts.callback.onBeforeLoad.call(iL, iL.ui, item);
  741. if (typeof obj.options.onBeforeLoad == 'function') obj.options.onBeforeLoad.call(iL, api);
  742.  
  743. iL.loadImage(images, function() {
  744. //Trigger the onAfterLoad callback
  745. if (typeof opts.callback.onAfterLoad == 'function') opts.callback.onAfterLoad.call(iL, iL.ui, item);
  746. if (typeof obj.options.onAfterLoad == 'function') obj.options.onAfterLoad.call(iL, api);
  747.  
  748. holder.show().data({
  749. naturalWidth: (elWidth || container.outerWidth()),
  750. naturalHeight: (elHeight || container.outerHeight())
  751. }).hide();
  752. el.remove();
  753.  
  754. iL.configureHolder(obj, opt, holder);
  755. });
  756.  
  757. break;
  758. }
  759. },
  760.  
  761. configureHolder: function(obj, opt, holder) {
  762. var iL = this,
  763. vars = iL.vars,
  764. opts = iL.options;
  765.  
  766. if (opt != "current")(opt == "next") ? holder.addClass('ilightbox-next') : holder.addClass('ilightbox-prev');
  767.  
  768. if (opt == "current")
  769. var item = vars.current;
  770. else if (opt == "next")
  771. var opacity = opts.styles.nextOpacity,
  772. item = vars.next;
  773. else
  774. var opacity = opts.styles.prevOpacity,
  775. item = vars.prev;
  776.  
  777. var api = {
  778. element: holder,
  779. position: item
  780. };
  781.  
  782. iL.items[item].options.width = iL.items[item].options.width || 0,
  783. iL.items[item].options.height = iL.items[item].options.height || 0;
  784.  
  785. if (opt == "current") {
  786. if (opts.show.effect) holder.css(transform, gpuAcceleration).fadeIn(obj.speed, function() {
  787. holder.css(transform, '');
  788. if (obj.caption) {
  789. iL.setCaption(obj, holder);
  790. var caption = $('div.ilightbox-caption', holder),
  791. percent = parseInt((caption.outerHeight() / holder.outerHeight()) * 100);
  792. if (opts.caption.start & percent <= 50) caption.fadeIn(opts.effects.fadeSpeed);
  793. }
  794.  
  795. var social = obj.options.social;
  796. if (social) {
  797. iL.setSocial(social, obj.URL, holder);
  798. if (opts.social.start) $('div.ilightbox-social', holder).fadeIn(opts.effects.fadeSpeed);
  799. }
  800.  
  801. //Generate thumbnails
  802. iL.generateThumbnails();
  803.  
  804. //Trigger the onShow callback
  805. if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
  806. if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
  807. });
  808. else {
  809. holder.show();
  810.  
  811. //Generate thumbnails
  812. iL.generateThumbnails();
  813.  
  814. //Trigger the onShow callback
  815. if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
  816. if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
  817. }
  818. } else {
  819. if (opts.show.effect) holder.fadeTo(obj.speed, opacity, function() {
  820. if (opt == "next") vars.nextLock = false;
  821. else vars.prevLock = false;
  822.  
  823. //Generate thumbnails
  824. iL.generateThumbnails();
  825.  
  826. //Trigger the onShow callback
  827. if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
  828. if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
  829. });
  830. else {
  831. holder.css({
  832. opacity: opacity
  833. }).show();
  834. if (opt == "next") vars.nextLock = false;
  835. else vars.prevLock = false;
  836.  
  837. //Generate thumbnails
  838. iL.generateThumbnails();
  839.  
  840. //Trigger the onShow callback
  841. if (typeof opts.callback.onShow == 'function') opts.callback.onShow.call(iL, iL.ui, item);
  842. if (typeof obj.options.onShow == 'function') obj.options.onShow.call(iL, api);
  843. }
  844. }
  845.  
  846. setTimeout(function() {
  847. iL.repositionPhoto();
  848. }, 0);
  849. },
  850.  
  851. generateBoxes: function() {
  852. var iL = this,
  853. vars = iL.vars,
  854. opts = iL.options;
  855.  
  856. if (opts.infinite && vars.total >= 3) {
  857. if (vars.current == vars.total - 1) vars.next = 0;
  858. if (vars.current == 0) vars.prev = vars.total - 1;
  859. } else opts.infinite = false;
  860.  
  861. iL.loadContent(iL.items[vars.current], 'current', opts.show.speed);
  862.  
  863. if (iL.items[vars.next]) iL.loadContent(iL.items[vars.next], 'next', opts.show.speed);
  864. if (iL.items[vars.prev]) iL.loadContent(iL.items[vars.prev], 'prev', opts.show.speed);
  865. },
  866.  
  867. generateThumbnails: function() {
  868. var iL = this,
  869. vars = iL.vars,
  870. opts = iL.options,
  871. timeOut = null;
  872.  
  873. if (vars.thumbs && !iL.vars.dontGenerateThumbs) {
  874. var thumbnails = vars.thumbnails,
  875. container = $('div.ilightbox-thumbnails-container', thumbnails),
  876. grid = $('div.ilightbox-thumbnails-grid', container),
  877. i = 0;
  878.  
  879. grid.removeAttr('style').empty();
  880.  
  881. $.each(iL.items, function(key, val) {
  882. var isActive = (vars.current == key) ? 'ilightbox-active' : '',
  883. opacity = (vars.current == key) ? opts.thumbnails.activeOpacity : opts.thumbnails.normalOpacity,
  884. thumb = val.options.thumbnail,
  885. thumbnail = $('<div class="ilightbox-thumbnail"></div>'),
  886. icon = $('<div class="ilightbox-thumbnail-icon"></div>');
  887.  
  888. thumbnail.css({
  889. opacity: 0
  890. }).addClass(isActive);
  891.  
  892. if ((val.type == "video" || val.type == "flash") && typeof val.options.icon == 'undefined') {
  893. icon.addClass('ilightbox-thumbnail-video');
  894. thumbnail.append(icon);
  895. } else if (val.options.icon) {
  896. icon.addClass('ilightbox-thumbnail-' + val.options.icon);
  897. thumbnail.append(icon);
  898. }
  899.  
  900. if (thumb) iL.loadImage(thumb, function(img) {
  901. i++;
  902. if (img) thumbnail.data({
  903. naturalWidth: img.width,
  904. naturalHeight: img.height
  905. }).append('<img src="' + thumb + '" border="0" />');
  906. else thumbnail.data({
  907. naturalWidth: opts.thumbnails.maxWidth,
  908. naturalHeight: opts.thumbnails.maxHeight
  909. });
  910.  
  911. clearTimeout(timeOut);
  912. timeOut = setTimeout(function() {
  913. iL.positionThumbnails(thumbnails, container, grid);
  914. }, 20);
  915. setTimeout(function() {
  916. thumbnail.fadeTo(opts.effects.loadedFadeSpeed, opacity);
  917. }, i * 20);
  918. });
  919.  
  920. grid.append(thumbnail);
  921. });
  922. iL.vars.dontGenerateThumbs = true;
  923. }
  924. },
  925.  
  926. positionThumbnails: function(thumbnails, container, grid) {
  927. var iL = this,
  928. vars = iL.vars,
  929. opts = iL.options,
  930. viewport = getViewport(),
  931. path = opts.path.toLowerCase();
  932.  
  933. if (!thumbnails) thumbnails = vars.thumbnails;
  934. if (!container) container = $('div.ilightbox-thumbnails-container', thumbnails);
  935. if (!grid) grid = $('div.ilightbox-thumbnails-grid', container);
  936.  
  937. var thumbs = $('.ilightbox-thumbnail', grid),
  938. widthAvail = (path == 'horizontal') ? viewport.width - opts.styles.pageOffsetX : thumbs.eq(0).outerWidth() - opts.styles.pageOffsetX,
  939. heightAvail = (path == 'horizontal') ? thumbs.eq(0).outerHeight() - opts.styles.pageOffsetY : viewport.height - opts.styles.pageOffsetY,
  940. gridWidth = (path == 'horizontal') ? 0 : widthAvail,
  941. gridHeight = (path == 'horizontal') ? heightAvail : 0,
  942. active = $('.ilightbox-active', grid),
  943. gridCss = {},
  944. css = {};
  945.  
  946. if (arguments.length < 3) {
  947. thumbs.css({
  948. opacity: opts.thumbnails.normalOpacity
  949. });
  950. active.css({
  951. opacity: opts.thumbnails.activeOpacity
  952. });
  953. }
  954.  
  955. thumbs.each(function(i) {
  956. var t = $(this),
  957. data = t.data(),
  958. width = (path == 'horizontal') ? 0 : opts.thumbnails.maxWidth;
  959. height = (path == 'horizontal') ? opts.thumbnails.maxHeight : 0;
  960. dims = iL.getNewDimenstions(width, height, data.naturalWidth, data.naturalHeight, true);
  961.  
  962. t.css({
  963. width: dims.width,
  964. height: dims.height
  965. });
  966. if (path == 'horizontal') t.css({
  967. 'float': 'left'
  968. });
  969.  
  970. (path == 'horizontal') ? (
  971. gridWidth += t.outerWidth()
  972. ) : (
  973. gridHeight += t.outerHeight()
  974. );
  975. });
  976.  
  977. gridCss = {
  978. width: gridWidth,
  979. height: gridHeight
  980. };
  981.  
  982. grid.css(gridCss);
  983.  
  984. gridCss = {};
  985.  
  986. var gridOffset = grid.offset(),
  987. activeOffset = (active.length) ? active.offset() : {
  988. top: parseInt(heightAvail / 2),
  989. left: parseInt(widthAvail / 2)
  990. };
  991.  
  992. gridOffset.top = (gridOffset.top - $doc.scrollTop()),
  993. gridOffset.left = (gridOffset.left - $doc.scrollLeft()),
  994. activeOffset.top = (activeOffset.top - gridOffset.top - $doc.scrollTop()),
  995. activeOffset.left = (activeOffset.left - gridOffset.left - $doc.scrollLeft());
  996.  
  997. (path == 'horizontal') ? (
  998. gridCss.top = 0,
  999. gridCss.left = parseInt((widthAvail / 2) - activeOffset.left - (active.outerWidth() / 2))
  1000. ) : (
  1001. gridCss.top = parseInt(((heightAvail / 2) - activeOffset.top - (active.outerHeight() / 2))),
  1002. gridCss.left = 0
  1003. );
  1004.  
  1005. if (arguments.length < 3) grid.stop().animate(gridCss, opts.effects.repositionSpeed, 'easeOutCirc');
  1006. else grid.css(gridCss);
  1007. },
  1008.  
  1009. loadImage: function(image, callback) {
  1010. if (!$.isArray(image)) image = [image];
  1011.  
  1012. var iL = this,
  1013. length = image.length;
  1014.  
  1015. if (length > 0) {
  1016. iL.showLoader();
  1017. $.each(image, function(index, value) {
  1018. var img = new Image();
  1019. img.onload = function() {
  1020. length -= 1;
  1021. if (length == 0) {
  1022. iL.hideLoader();
  1023. callback(img);
  1024. }
  1025. };
  1026. img.onerror = img.onabort = function() {
  1027. length -= 1;
  1028. if (length == 0) {
  1029. iL.hideLoader();
  1030. callback(false);
  1031. }
  1032. };
  1033. img.src = image[index];
  1034. });
  1035. } else callback(false);
  1036. },
  1037.  
  1038. patchItemsEvents: function() {
  1039. var iL = this,
  1040. vars = iL.vars,
  1041. clickEvent = supportTouch ? "itap.iL" : "click.iL",
  1042. vEvent = supportTouch ? "click.iL" : "itap.iL";
  1043.  
  1044. if (iL.context && iL.selector) {
  1045. var $items = $(iL.selector, iL.context);
  1046.  
  1047. $(iL.context).on(clickEvent, iL.selector, function() {
  1048. var $this = $(this),
  1049. key = $items.index($this);
  1050.  
  1051. vars.current = key;
  1052. vars.next = iL.items[key + 1] ? key + 1 : null;
  1053. vars.prev = iL.items[key - 1] ? key - 1 : null;
  1054.  
  1055. iL.addContents();
  1056. iL.patchEvents();
  1057.  
  1058. return false;
  1059. }).on(vEvent, iL.selector, function() {
  1060. return false;
  1061. });
  1062. } else
  1063. $.each(iL.itemsObject, function(key, val) {
  1064. val.on(clickEvent, function() {
  1065. vars.current = key;
  1066. vars.next = iL.items[key + 1] ? key + 1 : null;
  1067. vars.prev = iL.items[key - 1] ? key - 1 : null;
  1068.  
  1069. iL.addContents();
  1070. iL.patchEvents();
  1071.  
  1072. return false;
  1073. }).on(vEvent, function() {
  1074. return false;
  1075. });
  1076. });
  1077. },
  1078.  
  1079. dispatchItemsEvents: function() {
  1080. var iL = this,
  1081. vars = iL.vars,
  1082. opts = iL.options;
  1083.  
  1084. if (iL.context && iL.selector)
  1085. $(iL.context).off('.iL', iL.selector);
  1086. else
  1087. $.each(iL.itemsObject, function(key, val) {
  1088. val.off('.iL');
  1089. });
  1090. },
  1091.  
  1092. refresh: function() {
  1093. var iL = this;
  1094.  
  1095. iL.dispatchItemsEvents();
  1096. iL.attachItems();
  1097. iL.normalizeItems();
  1098. iL.patchItemsEvents();
  1099. },
  1100.  
  1101. patchEvents: function() {
  1102. var iL = this,
  1103. vars = iL.vars,
  1104. opts = iL.options,
  1105. path = opts.path.toLowerCase(),
  1106. holders = $('.ilightbox-holder'),
  1107. fullscreenEvent = fullScreenApi.fullScreenEventName + '.iLightBox',
  1108. durationThreshold = 1000,
  1109. horizontalDistanceThreshold =
  1110. verticalDistanceThreshold = 100,
  1111. buttonsArray = [vars.nextButton[0], vars.prevButton[0], vars.nextButton[0].firstChild, vars.prevButton[0].firstChild];
  1112.  
  1113. $win.bind('resize.iLightBox', function() {
  1114. var viewport = getViewport();
  1115.  
  1116. if (opts.mobileOptimizer && !opts.innerToolbar) vars.isMobile = viewport.width <= vars.mobileMaxWidth;
  1117. vars.BODY[vars.isMobile ? 'addClass' : 'removeClass']('isMobile');
  1118.  
  1119. iL.repositionPhoto(null);
  1120. if (supportTouch) {
  1121. clearTimeout(vars.setTime);
  1122. vars.setTime = setTimeout(function() {
  1123. var scrollTop = getScrollXY().y;
  1124. window.scrollTo(0, scrollTop - 30);
  1125. window.scrollTo(0, scrollTop + 30);
  1126. window.scrollTo(0, scrollTop);
  1127. }, 2000);
  1128. }
  1129. if (vars.thumbs) iL.positionThumbnails();
  1130. }).bind('keydown.iLightBox', function(event) {
  1131. if (opts.controls.keyboard) {
  1132. switch (event.keyCode) {
  1133. case 13:
  1134. if (event.shiftKey && opts.keyboard.shift_enter) iL.fullScreenAction();
  1135. break;
  1136. case 27:
  1137. if (opts.keyboard.esc) iL.closeAction();
  1138. break;
  1139. case 37:
  1140. if (opts.keyboard.left && !vars.lockKey) iL.moveTo('prev');
  1141. break;
  1142. case 38:
  1143. if (opts.keyboard.up && !vars.lockKey) iL.moveTo('prev');
  1144. break;
  1145. case 39:
  1146. if (opts.keyboard.right && !vars.lockKey) iL.moveTo('next');
  1147. break;
  1148. case 40:
  1149. if (opts.keyboard.down && !vars.lockKey) iL.moveTo('next');
  1150. break;
  1151. }
  1152. }
  1153. });
  1154.  
  1155. if (fullScreenApi.supportsFullScreen) $win.bind(fullscreenEvent, function() {
  1156. iL.doFullscreen();
  1157. });
  1158.  
  1159. var holderEventsArr = [opts.caption.show + '.iLightBox', opts.caption.hide + '.iLightBox', opts.social.show + '.iLightBox', opts.social.hide + '.iLightBox'].filter(function(e, i, arr) {
  1160. return arr.lastIndexOf(e) === i;
  1161. }),
  1162. holderEvents = "";
  1163.  
  1164. $.each(holderEventsArr, function(key, val) {
  1165. if (key != 0) holderEvents += ' ';
  1166. holderEvents += val;
  1167. });
  1168.  
  1169. $doc.on(clickEvent, '.ilightbox-overlay', function() {
  1170. if (opts.overlay.blur) iL.closeAction();
  1171. }).on(clickEvent, '.ilightbox-next, .ilightbox-next-button', function() {
  1172. iL.moveTo('next');
  1173. }).on(clickEvent, '.ilightbox-prev, .ilightbox-prev-button', function() {
  1174. iL.moveTo('prev');
  1175. }).on(clickEvent, '.ilightbox-thumbnail', function() {
  1176. var t = $(this),
  1177. thumbs = $('.ilightbox-thumbnail', vars.thumbnails),
  1178. index = thumbs.index(t);
  1179.  
  1180. if (index != vars.current) iL.goTo(index);
  1181. }).on(holderEvents, '.ilightbox-holder:not(.ilightbox-next, .ilightbox-prev)', function(e) {
  1182. var caption = $('div.ilightbox-caption', vars.holder),
  1183. social = $('div.ilightbox-social', vars.holder),
  1184. fadeSpeed = opts.effects.fadeSpeed;
  1185.  
  1186. if (vars.nextLock || vars.prevLock) {
  1187. if (e.type == opts.caption.show && !caption.is(':visible')) caption.fadeIn(fadeSpeed);
  1188. else if (e.type == opts.caption.hide && caption.is(':visible')) caption.fadeOut(fadeSpeed);
  1189.  
  1190. if (e.type == opts.social.show && !social.is(':visible')) social.fadeIn(fadeSpeed);
  1191. else if (e.type == opts.social.hide && social.is(':visible')) social.fadeOut(fadeSpeed);
  1192. } else {
  1193. if (e.type == opts.caption.show && !caption.is(':visible')) caption.stop().fadeIn(fadeSpeed);
  1194. else if (e.type == opts.caption.hide && caption.is(':visible')) caption.stop().fadeOut(fadeSpeed);
  1195.  
  1196. if (e.type == opts.social.show && !social.is(':visible')) social.stop().fadeIn(fadeSpeed);
  1197. else if (e.type == opts.social.hide && social.is(':visible')) social.stop().fadeOut(fadeSpeed);
  1198. }
  1199. }).on('mouseenter.iLightBox mouseleave.iLightBox', '.ilightbox-wrapper', function(e) {
  1200. if (e.type == 'mouseenter') vars.lockWheel = true;
  1201. else vars.lockWheel = false;
  1202. }).on(clickEvent, '.ilightbox-toolbar a.ilightbox-close, .ilightbox-toolbar a.ilightbox-fullscreen, .ilightbox-toolbar a.ilightbox-play, .ilightbox-toolbar a.ilightbox-pause', function() {
  1203. var t = $(this);
  1204.  
  1205. if (t.hasClass('ilightbox-fullscreen')) iL.fullScreenAction();
  1206. else if (t.hasClass('ilightbox-play')) {
  1207. iL.resume();
  1208. t.addClass('ilightbox-pause').removeClass('ilightbox-play');
  1209. } else if (t.hasClass('ilightbox-pause')) {
  1210. iL.pause();
  1211. t.addClass('ilightbox-play').removeClass('ilightbox-pause');
  1212. } else iL.closeAction();
  1213. }).on(touchMoveEvent, '.ilightbox-overlay, .ilightbox-thumbnails-container', function(e) {
  1214. // prevent scrolling
  1215. e.preventDefault();
  1216. });
  1217.  
  1218. function mouseMoveHandler(e) {
  1219. if (!vars.isMobile) {
  1220. if (!vars.mouseID) {
  1221. vars.hideableElements.show();
  1222. }
  1223.  
  1224. vars.mouseID = clearTimeout(vars.mouseID);
  1225.  
  1226. if (buttonsArray.indexOf(e.target) === -1)
  1227. vars.mouseID = setTimeout(function() {
  1228. vars.hideableElements.hide();
  1229. vars.mouseID = clearTimeout(vars.mouseID);
  1230. }, 3000);
  1231. }
  1232. }
  1233.  
  1234. if (opts.controls.arrows && !supportTouch) $doc.on('mousemove.iLightBox', mouseMoveHandler);
  1235.  
  1236. if (opts.controls.slideshow && opts.slideshow.pauseOnHover) $doc.on('mouseenter.iLightBox mouseleave.iLightBox', '.ilightbox-holder:not(.ilightbox-next, .ilightbox-prev)', function(e) {
  1237. if (e.type == 'mouseenter' && vars.cycleID) iL.pause();
  1238. else if (e.type == 'mouseleave' && vars.isPaused) iL.resume();
  1239. });
  1240.  
  1241. var switchers = $('.ilightbox-overlay, .ilightbox-holder, .ilightbox-thumbnails');
  1242.  
  1243. if (opts.controls.mousewheel) switchers.on('mousewheel.iLightBox', function(event, delta) {
  1244. if (!vars.lockWheel) {
  1245. event.preventDefault();
  1246. if (delta < 0) iL.moveTo('next');
  1247. else if (delta > 0) iL.moveTo('prev');
  1248. }
  1249. });
  1250.  
  1251. if (opts.controls.swipe) holders.on(touchStartEvent, function(event) {
  1252. if (vars.nextLock || vars.prevLock || vars.total == 1 || vars.lockSwipe) return;
  1253.  
  1254. vars.BODY.addClass('ilightbox-closedhand');
  1255.  
  1256. var data = event.originalEvent.touches ? event.originalEvent.touches[0] : event,
  1257. scrollTop = $doc.scrollTop(),
  1258. scrollLeft = $doc.scrollLeft(),
  1259. offsets = [
  1260. holders.eq(0).offset(),
  1261. holders.eq(1).offset(),
  1262. holders.eq(2).offset()
  1263. ],
  1264. offSet = [{
  1265. top: offsets[0].top - scrollTop,
  1266. left: offsets[0].left - scrollLeft
  1267. }, {
  1268. top: offsets[1].top - scrollTop,
  1269. left: offsets[1].left - scrollLeft
  1270. }, {
  1271. top: offsets[2].top - scrollTop,
  1272. left: offsets[2].left - scrollLeft
  1273. }],
  1274. start = {
  1275. time: (new Date()).getTime(),
  1276. coords: [data.pageX - scrollLeft, data.pageY - scrollTop]
  1277. },
  1278. stop;
  1279.  
  1280. function moveEachHandler(i) {
  1281. var t = $(this),
  1282. offset = offSet[i],
  1283. scroll = [(start.coords[0] - stop.coords[0]), (start.coords[1] - stop.coords[1])];
  1284.  
  1285. t[0].style[path == "horizontal" ? 'left' : 'top'] = (path == "horizontal" ? offset.left - scroll[0] : offset.top - scroll[1]) + 'px';
  1286. }
  1287.  
  1288. function moveHandler(event) {
  1289.  
  1290. if (!start) return;
  1291.  
  1292. var data = event.originalEvent.touches ? event.originalEvent.touches[0] : event;
  1293.  
  1294. stop = {
  1295. time: (new Date()).getTime(),
  1296. coords: [data.pageX - scrollLeft, data.pageY - scrollTop]
  1297. };
  1298.  
  1299. holders.each(moveEachHandler);
  1300.  
  1301. // prevent scrolling
  1302. event.preventDefault();
  1303. }
  1304.  
  1305. function repositionHolders() {
  1306. holders.each(function() {
  1307. var t = $(this),
  1308. offset = t.data('offset') || {
  1309. top: t.offset().top - scrollTop,
  1310. left: t.offset().left - scrollLeft
  1311. },
  1312. top = offset.top,
  1313. left = offset.left;
  1314.  
  1315. t.css(transform, gpuAcceleration).stop().animate({
  1316. top: top,
  1317. left: left
  1318. }, 500, 'easeOutCirc', function() {
  1319. t.css(transform, '');
  1320. });
  1321. });
  1322. }
  1323.  
  1324. holders.bind(touchMoveEvent, moveHandler);
  1325. $doc.one(touchStopEvent, function(event) {
  1326. holders.unbind(touchMoveEvent, moveHandler);
  1327.  
  1328. vars.BODY.removeClass('ilightbox-closedhand');
  1329.  
  1330. if (start && stop) {
  1331. if (path == "horizontal" && stop.time - start.time < durationThreshold && abs(start.coords[0] - stop.coords[0]) > horizontalDistanceThreshold && abs(start.coords[1] - stop.coords[1]) < verticalDistanceThreshold) {
  1332. if (start.coords[0] > stop.coords[0]) {
  1333. if (vars.current == vars.total - 1 && !opts.infinite) repositionHolders();
  1334. else {
  1335. vars.isSwipe = true;
  1336. iL.moveTo('next');
  1337. }
  1338. } else {
  1339. if (vars.current == 0 && !opts.infinite) repositionHolders();
  1340. else {
  1341. vars.isSwipe = true;
  1342. iL.moveTo('prev');
  1343. }
  1344. }
  1345. } else if (path == "vertical" && stop.time - start.time < durationThreshold && abs(start.coords[1] - stop.coords[1]) > horizontalDistanceThreshold && abs(start.coords[0] - stop.coords[0]) < verticalDistanceThreshold) {
  1346. if (start.coords[1] > stop.coords[1]) {
  1347. if (vars.current == vars.total - 1 && !opts.infinite) repositionHolders();
  1348. else {
  1349. vars.isSwipe = true;
  1350. iL.moveTo('next');
  1351. }
  1352. } else {
  1353. if (vars.current == 0 && !opts.infinite) repositionHolders();
  1354. else {
  1355. vars.isSwipe = true;
  1356. iL.moveTo('prev');
  1357. }
  1358. }
  1359. } else repositionHolders();
  1360. }
  1361. start = stop = undefined;
  1362. });
  1363. });
  1364.  
  1365. },
  1366.  
  1367. goTo: function(index) {
  1368. var iL = this,
  1369. vars = iL.vars,
  1370. opts = iL.options,
  1371. diff = (index - vars.current);
  1372.  
  1373. if (opts.infinite) {
  1374. if (index == vars.total - 1 && vars.current == 0) diff = -1;
  1375. if (vars.current == vars.total - 1 && index == 0) diff = 1;
  1376. }
  1377.  
  1378. if (diff == 1) iL.moveTo('next');
  1379. else if (diff == -1) iL.moveTo('prev');
  1380. else {
  1381.  
  1382. if (vars.nextLock || vars.prevLock) return false;
  1383.  
  1384. //Trigger the onBeforeChange callback
  1385. if (typeof opts.callback.onBeforeChange == 'function') opts.callback.onBeforeChange.call(iL, iL.ui);
  1386.  
  1387. if (opts.linkId) {
  1388. vars.hashLock = true;
  1389. window.location.hash = opts.linkId + '/' + index;
  1390. }
  1391.  
  1392. if (iL.items[index]) {
  1393. if (!iL.items[index].options.mousewheel) vars.lockWheel = true;
  1394. else iL.vars.lockWheel = false;
  1395.  
  1396. if (!iL.items[index].options.swipe) vars.lockSwipe = true;
  1397. else vars.lockSwipe = false;
  1398. }
  1399.  
  1400. $.each([vars.holder, vars.nextPhoto, vars.prevPhoto], function(key, val) {
  1401. val.css(transform, gpuAcceleration).fadeOut(opts.effects.loadedFadeSpeed);
  1402. });
  1403.  
  1404. vars.current = index;
  1405. vars.next = index + 1;
  1406. vars.prev = index - 1;
  1407.  
  1408. iL.createUI();
  1409.  
  1410. setTimeout(function() {
  1411. iL.generateBoxes();
  1412. }, opts.effects.loadedFadeSpeed + 50);
  1413.  
  1414. $('.ilightbox-thumbnail', vars.thumbnails).removeClass('ilightbox-active').eq(index).addClass('ilightbox-active');
  1415. iL.positionThumbnails();
  1416.  
  1417. if (opts.linkId) setTimeout(function() {
  1418. vars.hashLock = false;
  1419. }, 55);
  1420.  
  1421. // Configure arrow buttons
  1422. if (!opts.infinite) {
  1423. vars.nextButton.add(vars.prevButton).add(vars.innerPrevButton).add(vars.innerNextButton).removeClass('disabled');
  1424.  
  1425. if (vars.current == 0) {
  1426. vars.prevButton.add(vars.innerPrevButton).addClass('disabled');
  1427. }
  1428. if (vars.current >= vars.total - 1) {
  1429. vars.nextButton.add(vars.innerNextButton).addClass('disabled');
  1430. }
  1431. }
  1432.  
  1433. // Reset next cycle timeout
  1434. iL.resetCycle();
  1435.  
  1436. //Trigger the onAfterChange callback
  1437. if (typeof opts.callback.onAfterChange == 'function') opts.callback.onAfterChange.call(iL, iL.ui);
  1438. }
  1439. },
  1440.  
  1441. moveTo: function(side) {
  1442. var iL = this,
  1443. vars = iL.vars,
  1444. opts = iL.options,
  1445. path = opts.path.toLowerCase(),
  1446. viewport = getViewport(),
  1447. switchSpeed = opts.effects.switchSpeed;
  1448.  
  1449. if (vars.nextLock || vars.prevLock) return false;
  1450. else {
  1451.  
  1452. var item = (side == "next") ? vars.next : vars.prev;
  1453.  
  1454. if (opts.linkId) {
  1455. vars.hashLock = true;
  1456. window.location.hash = opts.linkId + '/' + item;
  1457. }
  1458.  
  1459. if (side == "next") {
  1460. if (!iL.items[item]) return false;
  1461. var firstHolder = vars.nextPhoto,
  1462. secondHolder = vars.holder,
  1463. lastHolder = vars.prevPhoto,
  1464. firstClass = 'ilightbox-prev',
  1465. secondClass = 'ilightbox-next';
  1466. } else if (side == "prev") {
  1467. if (!iL.items[item]) return false;
  1468. var firstHolder = vars.prevPhoto,
  1469. secondHolder = vars.holder,
  1470. lastHolder = vars.nextPhoto,
  1471. firstClass = 'ilightbox-next',
  1472. secondClass = 'ilightbox-prev';
  1473. }
  1474.  
  1475. //Trigger the onBeforeChange callback
  1476. if (typeof opts.callback.onBeforeChange == 'function')
  1477. opts.callback.onBeforeChange.call(iL, iL.ui);
  1478.  
  1479. (side == "next") ? vars.nextLock = true: vars.prevLock = true;
  1480.  
  1481. var captionFirst = $('div.ilightbox-caption', secondHolder),
  1482. socialFirst = $('div.ilightbox-social', secondHolder);
  1483.  
  1484. if (captionFirst.length)
  1485. captionFirst.stop().fadeOut(switchSpeed, function() {
  1486. $(this).remove();
  1487. });
  1488. if (socialFirst.length)
  1489. socialFirst.stop().fadeOut(switchSpeed, function() {
  1490. $(this).remove();
  1491. });
  1492.  
  1493. if (iL.items[item].caption) {
  1494. iL.setCaption(iL.items[item], firstHolder);
  1495. var caption = $('div.ilightbox-caption', firstHolder),
  1496. percent = parseInt((caption.outerHeight() / firstHolder.outerHeight()) * 100);
  1497. if (opts.caption.start && percent <= 50) caption.fadeIn(switchSpeed);
  1498. }
  1499.  
  1500. var social = iL.items[item].options.social;
  1501. if (social) {
  1502. iL.setSocial(social, iL.items[item].URL, firstHolder);
  1503. if (opts.social.start) $('div.ilightbox-social', firstHolder).fadeIn(opts.effects.fadeSpeed);
  1504. }
  1505.  
  1506. $.each([firstHolder, secondHolder, lastHolder], function(key, val) {
  1507. val.removeClass('ilightbox-next ilightbox-prev');
  1508. });
  1509.  
  1510. var firstOffset = firstHolder.data('offset'),
  1511. winW = (viewport.width - (opts.styles.pageOffsetX)),
  1512. winH = (viewport.height - (opts.styles.pageOffsetY)),
  1513. width = firstOffset.newDims.width,
  1514. height = firstOffset.newDims.height,
  1515. thumbsOffset = firstOffset.thumbsOffset,
  1516. diff = firstOffset.diff,
  1517. top = parseInt((winH / 2) - (height / 2) - diff.H - (thumbsOffset.H / 2)),
  1518. left = parseInt((winW / 2) - (width / 2) - diff.W - (thumbsOffset.W / 2));
  1519.  
  1520. firstHolder.css(transform, gpuAcceleration).animate({
  1521. top: top,
  1522. left: left,
  1523. opacity: 1
  1524. }, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc', function() {
  1525. firstHolder.css(transform, '');
  1526. });
  1527.  
  1528. $('div.ilightbox-container', firstHolder).animate({
  1529. width: width,
  1530. height: height
  1531. }, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc');
  1532.  
  1533. var secondOffset = secondHolder.data('offset'),
  1534. object = secondOffset.object;
  1535.  
  1536. diff = secondOffset.diff;
  1537.  
  1538. width = secondOffset.newDims.width,
  1539. height = secondOffset.newDims.height;
  1540.  
  1541. width = parseInt(width * opts.styles[side == 'next' ? 'prevScale' : 'nextScale']),
  1542. height = parseInt(height * opts.styles[side == 'next' ? 'prevScale' : 'nextScale']),
  1543. top = (path == 'horizontal') ? parseInt((winH / 2) - object.offsetY - (height / 2) - diff.H - (thumbsOffset.H / 2)) : parseInt(winH - object.offsetX - diff.H - (thumbsOffset.H / 2));
  1544.  
  1545. if (side == 'prev')
  1546. left = (path == 'horizontal') ? parseInt(winW - object.offsetX - diff.W - (thumbsOffset.W / 2)) : parseInt((winW / 2) - (width / 2) - diff.W - object.offsetY - (thumbsOffset.W / 2));
  1547. else {
  1548. top = (path == 'horizontal') ? top : parseInt(object.offsetX - diff.H - height - (thumbsOffset.H / 2)),
  1549. left = (path == 'horizontal') ? parseInt(object.offsetX - diff.W - width - (thumbsOffset.W / 2)) : parseInt((winW / 2) - object.offsetY - (width / 2) - diff.W - (thumbsOffset.W / 2));
  1550. }
  1551.  
  1552. $('div.ilightbox-container', secondHolder).animate({
  1553. width: width,
  1554. height: height
  1555. }, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc');
  1556.  
  1557. secondHolder.addClass(firstClass).css(transform, gpuAcceleration).animate({
  1558. top: top,
  1559. left: left,
  1560. opacity: opts.styles.prevOpacity
  1561. }, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc', function() {
  1562. secondHolder.css(transform, '');
  1563.  
  1564. $('.ilightbox-thumbnail', vars.thumbnails).removeClass('ilightbox-active').eq(item).addClass('ilightbox-active');
  1565. iL.positionThumbnails();
  1566.  
  1567. if (iL.items[item]) {
  1568. if (!iL.items[item].options.mousewheel) vars.lockWheel = true;
  1569. else vars.lockWheel = false;
  1570.  
  1571. if (!iL.items[item].options.swipe) vars.lockSwipe = true;
  1572. else vars.lockSwipe = false;
  1573. }
  1574.  
  1575. vars.isSwipe = false;
  1576.  
  1577. if (side == "next") {
  1578. vars.nextPhoto = lastHolder,
  1579. vars.prevPhoto = secondHolder,
  1580. vars.holder = firstHolder;
  1581.  
  1582. vars.nextPhoto.hide();
  1583.  
  1584. vars.next = vars.next + 1,
  1585. vars.prev = vars.current,
  1586. vars.current = vars.current + 1;
  1587.  
  1588. if (opts.infinite) {
  1589. if (vars.current > vars.total - 1) vars.current = 0;
  1590. if (vars.current == vars.total - 1) vars.next = 0;
  1591. if (vars.current == 0) vars.prev = vars.total - 1;
  1592. }
  1593.  
  1594. iL.createUI();
  1595.  
  1596. if (!iL.items[vars.next])
  1597. vars.nextLock = false;
  1598. else
  1599. iL.loadContent(iL.items[vars.next], 'next');
  1600. } else {
  1601. vars.prevPhoto = lastHolder;
  1602. vars.nextPhoto = secondHolder;
  1603. vars.holder = firstHolder;
  1604.  
  1605. vars.prevPhoto.hide();
  1606.  
  1607. vars.next = vars.current;
  1608. vars.current = vars.prev;
  1609. vars.prev = vars.current - 1;
  1610.  
  1611. if (opts.infinite) {
  1612. if (vars.current == vars.total - 1) vars.next = 0;
  1613. if (vars.current == 0) vars.prev = vars.total - 1;
  1614. }
  1615.  
  1616. iL.createUI();
  1617.  
  1618. if (!iL.items[vars.prev])
  1619. vars.prevLock = false;
  1620. else
  1621. iL.loadContent(iL.items[vars.prev], 'prev');
  1622. }
  1623.  
  1624. if (opts.linkId) setTimeout(function() {
  1625. vars.hashLock = false;
  1626. }, 55);
  1627.  
  1628. // Configure arrow buttons
  1629. if (!opts.infinite) {
  1630. vars.nextButton.add(vars.prevButton).add(vars.innerPrevButton).add(vars.innerNextButton).removeClass('disabled');
  1631.  
  1632. if (vars.current == 0)
  1633. vars.prevButton.add(vars.innerPrevButton).addClass('disabled');
  1634. if (vars.current >= vars.total - 1)
  1635. vars.nextButton.add(vars.innerNextButton).addClass('disabled');
  1636. }
  1637.  
  1638. iL.repositionPhoto();
  1639.  
  1640. // Reset next cycle timeout
  1641. iL.resetCycle();
  1642.  
  1643. //Trigger the onAfterChange callback
  1644. if (typeof opts.callback.onAfterChange == 'function')
  1645. opts.callback.onAfterChange.call(iL, iL.ui);
  1646. });
  1647.  
  1648. top = (path == 'horizontal') ? getPixel(lastHolder, 'top') : ((side == "next") ? parseInt(-(winH / 2) - lastHolder.outerHeight()) : parseInt(top * 2)),
  1649. left = (path == 'horizontal') ? ((side == "next") ? parseInt(-(winW / 2) - lastHolder.outerWidth()) : parseInt(left * 2)) : getPixel(lastHolder, 'left');
  1650.  
  1651. lastHolder.css(transform, gpuAcceleration).animate({
  1652. top: top,
  1653. left: left,
  1654. opacity: opts.styles.nextOpacity
  1655. }, switchSpeed, (vars.isSwipe) ? 'easeOutCirc' : 'easeInOutCirc', function() {
  1656. lastHolder.css(transform, '');
  1657. }).addClass(secondClass);
  1658. }
  1659. },
  1660.  
  1661. setCaption: function(obj, target) {
  1662. var iL = this,
  1663. caption = $('<div class="ilightbox-caption"></div>');
  1664.  
  1665. if (obj.caption) {
  1666. caption.html(obj.caption);
  1667. $('div.ilightbox-container', target).append(caption);
  1668. }
  1669. },
  1670.  
  1671. normalizeSocial: function(obj, url) {
  1672. var iL = this,
  1673. vars = iL.vars,
  1674. opts = iL.options,
  1675. baseURL = window.location.href;
  1676.  
  1677. $.each(obj, function(key, value) {
  1678. if (!value)
  1679. return true;
  1680.  
  1681. var item = key.toLowerCase(),
  1682. source, text;
  1683.  
  1684. switch (item) {
  1685. case 'facebook':
  1686. source = "http://www.facebook.com/share.php?v=4&src=bm&u={URL}",
  1687. text = "Share on Facebook";
  1688. break;
  1689. case 'twitter':
  1690. source = "http://twitter.com/home?status={URL}",
  1691. text = "Share on Twitter";
  1692. break;
  1693. case 'googleplus':
  1694. source = "https://plus.google.com/share?url={URL}",
  1695. text = "Share on Google+";
  1696. break;
  1697. case 'delicious':
  1698. source = "http://delicious.com/post?url={URL}",
  1699. text = "Share on Delicious";
  1700. break;
  1701. case 'digg':
  1702. source = "http://digg.com/submit?phase=2&url={URL}",
  1703. text = "Share on Digg";
  1704. break;
  1705. case 'reddit':
  1706. source = "http://reddit.com/submit?url={URL}",
  1707. text = "Share on reddit";
  1708. break;
  1709. }
  1710.  
  1711. obj[key] = {
  1712. URL: value.URL && absolutizeURI(baseURL, value.URL) || opts.linkId && window.location.href || typeof url !== 'string' && baseURL || url && absolutizeURI(baseURL, url) || baseURL,
  1713. source: value.source || source || value.URL && absolutizeURI(baseURL, value.URL) || url && absolutizeURI(baseURL, url),
  1714. text: value.text || text || "Share on " + key,
  1715. width: (typeof(value.width) != 'undefined' && !isNaN(value.width)) ? parseInt(value.width) : 640,
  1716. height: value.height || 360
  1717. };
  1718.  
  1719. });
  1720.  
  1721. return obj;
  1722. },
  1723.  
  1724. setSocial: function(obj, url, target) {
  1725. var iL = this,
  1726. socialBar = $('<div class="ilightbox-social"></div>'),
  1727. buttons = '<ul>';
  1728.  
  1729. obj = iL.normalizeSocial(obj, url);
  1730.  
  1731. $.each(obj, function(key, value) {
  1732. var item = key.toLowerCase(),
  1733. source = value.source.replace(/\{URL\}/g, encodeURIComponent(value.URL).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+'));
  1734. buttons += '<li class="' + key + '"><a href="' + source + '" onclick="javascript:window.open(this.href' + ((value.width <= 0 || value.height <= 0) ? '' : ', \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=' + value.height + ',width=' + value.width + ',left=40,top=40\'') + ');return false;" title="' + value.text + '" target="_blank"></a></li>';
  1735. });
  1736.  
  1737. buttons += '</ul>';
  1738.  
  1739. socialBar.html(buttons);
  1740. $('div.ilightbox-container', target).append(socialBar);
  1741. },
  1742.  
  1743. fullScreenAction: function() {
  1744. var iL = this,
  1745. vars = iL.vars;
  1746.  
  1747. if (fullScreenApi.supportsFullScreen) {
  1748. if (fullScreenApi.isFullScreen()) fullScreenApi.cancelFullScreen(document.documentElement);
  1749. else fullScreenApi.requestFullScreen(document.documentElement);
  1750. } else {
  1751. iL.doFullscreen();
  1752. }
  1753. },
  1754.  
  1755. doFullscreen: function() {
  1756. var iL = this,
  1757. vars = iL.vars,
  1758. viewport = getViewport(),
  1759. opts = iL.options;
  1760.  
  1761. if (opts.fullAlone) {
  1762. var currentHolder = vars.holder,
  1763. current = iL.items[vars.current],
  1764. windowWidth = viewport.width,
  1765. windowHeight = viewport.height,
  1766. elements = [currentHolder, vars.nextPhoto, vars.prevPhoto, vars.nextButton, vars.prevButton, vars.overlay, vars.toolbar, vars.thumbnails, vars.loader],
  1767. hideElements = [vars.nextPhoto, vars.prevPhoto, vars.nextButton, vars.prevButton, vars.loader, vars.thumbnails];
  1768.  
  1769. if (!vars.isInFullScreen) {
  1770. vars.isInFullScreen = vars.lockKey = vars.lockWheel = vars.lockSwipe = true;
  1771. vars.overlay.css({
  1772. opacity: 1
  1773. });
  1774.  
  1775. $.each(hideElements, function(i, element) {
  1776. element.hide();
  1777. });
  1778.  
  1779. vars.fullScreenButton.attr('title', opts.text.exitFullscreen);
  1780.  
  1781. if (opts.fullStretchTypes.indexOf(current.type) != -1) currentHolder.data({
  1782. naturalWidthOld: currentHolder.data('naturalWidth'),
  1783. naturalHeightOld: currentHolder.data('naturalHeight'),
  1784. naturalWidth: windowWidth,
  1785. naturalHeight: windowHeight
  1786. });
  1787. else {
  1788. var viewport = current.options.fullViewPort || opts.fullViewPort || '',
  1789. newWidth = windowWidth,
  1790. newHeight = windowHeight,
  1791. width = currentHolder.data('naturalWidth'),
  1792. height = currentHolder.data('naturalHeight');
  1793.  
  1794. if (viewport.toLowerCase() == 'fill') {
  1795. newHeight = (newWidth / width) * height;
  1796.  
  1797. if (newHeight < windowHeight) {
  1798. newWidth = (windowHeight / height) * width,
  1799. newHeight = windowHeight;
  1800. }
  1801. } else if (viewport.toLowerCase() == 'fit') {
  1802. var dims = iL.getNewDimenstions(newWidth, newHeight, width, height, true);
  1803.  
  1804. newWidth = dims.width,
  1805. newHeight = dims.height;
  1806. } else if (viewport.toLowerCase() == 'stretch') {
  1807. newWidth = newWidth,
  1808. newHeight = newHeight;
  1809. } else {
  1810. var scale = (width > newWidth || height > newHeight) ? true : false,
  1811. dims = iL.getNewDimenstions(newWidth, newHeight, width, height, scale);
  1812. newWidth = dims.width,
  1813. newHeight = dims.height;
  1814. }
  1815.  
  1816. currentHolder.data({
  1817. naturalWidthOld: currentHolder.data('naturalWidth'),
  1818. naturalHeightOld: currentHolder.data('naturalHeight'),
  1819. naturalWidth: newWidth,
  1820. naturalHeight: newHeight
  1821. });
  1822. }
  1823.  
  1824. $.each(elements, function(key, val) {
  1825. val.addClass('ilightbox-fullscreen');
  1826. });
  1827.  
  1828. //Trigger the onEnterFullScreen callback
  1829. if (typeof opts.callback.onEnterFullScreen == 'function') opts.callback.onEnterFullScreen.call(iL, iL.ui);
  1830. } else {
  1831. vars.isInFullScreen = vars.lockKey = vars.lockWheel = vars.lockSwipe = false;
  1832. vars.overlay.css({
  1833. opacity: iL.options.overlay.opacity
  1834. });
  1835.  
  1836. $.each(hideElements, function(i, element) {
  1837. element.show();
  1838. });
  1839.  
  1840. vars.fullScreenButton.attr('title', opts.text.enterFullscreen);
  1841.  
  1842. currentHolder.data({
  1843. naturalWidth: currentHolder.data('naturalWidthOld'),
  1844. naturalHeight: currentHolder.data('naturalHeightOld'),
  1845. naturalWidthOld: null,
  1846. naturalHeightOld: null
  1847. });
  1848.  
  1849. $.each(elements, function(key, val) {
  1850. val.removeClass('ilightbox-fullscreen');
  1851. });
  1852.  
  1853. //Trigger the onExitFullScreen callback
  1854. if (typeof opts.callback.onExitFullScreen == 'function') opts.callback.onExitFullScreen.call(iL, iL.ui);
  1855. }
  1856. } else {
  1857. if (!vars.isInFullScreen) vars.isInFullScreen = true;
  1858. else vars.isInFullScreen = false;
  1859. }
  1860. iL.repositionPhoto(true);
  1861. },
  1862.  
  1863. closeAction: function() {
  1864. var iL = this,
  1865. vars = iL.vars,
  1866. opts = iL.options;
  1867.  
  1868. $win.unbind('.iLightBox');
  1869. $doc.off('.iLightBox');
  1870.  
  1871. if (vars.isInFullScreen) fullScreenApi.cancelFullScreen(document.documentElement);
  1872.  
  1873. $('.ilightbox-overlay, .ilightbox-holder, .ilightbox-thumbnails').off('.iLightBox');
  1874.  
  1875. if (opts.hide.effect) vars.overlay.stop().fadeOut(opts.hide.speed, function() {
  1876. vars.overlay.remove();
  1877. vars.BODY.removeClass('ilightbox-noscroll').off('.iLightBox');
  1878. });
  1879. else {
  1880. vars.overlay.remove();
  1881. vars.BODY.removeClass('ilightbox-noscroll').off('.iLightBox');
  1882. }
  1883.  
  1884. var fadeOuts = [vars.toolbar, vars.holder, vars.nextPhoto, vars.prevPhoto, vars.nextButton, vars.prevButton, vars.loader, vars.thumbnails];
  1885.  
  1886. $.each(fadeOuts, function(i, element) {
  1887. element.removeAttr('style').remove();
  1888. });
  1889.  
  1890. vars.dontGenerateThumbs = vars.isInFullScreen = false;
  1891.  
  1892. window.iLightBox = null;
  1893.  
  1894. if (opts.linkId) {
  1895. vars.hashLock = true;
  1896. removeHash();
  1897. setTimeout(function() {
  1898. vars.hashLock = false;
  1899. }, 55);
  1900. }
  1901.  
  1902. //Trigger the onHide callback
  1903. if (typeof opts.callback.onHide == 'function') opts.callback.onHide.call(iL, iL.ui);
  1904. },
  1905.  
  1906. repositionPhoto: function() {
  1907. var iL = this,
  1908. vars = iL.vars,
  1909. opts = iL.options,
  1910. path = opts.path.toLowerCase(),
  1911. viewport = getViewport(),
  1912. winWidth = viewport.width,
  1913. winHeight = viewport.height;
  1914.  
  1915. var thumbsOffsetW = (vars.isInFullScreen && opts.fullAlone || vars.isMobile) ? 0 : ((path == 'horizontal') ? 0 : vars.thumbnails.outerWidth()),
  1916. thumbsOffsetH = vars.isMobile ? vars.toolbar.outerHeight() : ((vars.isInFullScreen && opts.fullAlone) ? 0 : ((path == 'horizontal') ? vars.thumbnails.outerHeight() : 0)),
  1917. width = (vars.isInFullScreen && opts.fullAlone) ? winWidth : (winWidth - (opts.styles.pageOffsetX)),
  1918. height = (vars.isInFullScreen && opts.fullAlone) ? winHeight : (winHeight - (opts.styles.pageOffsetY)),
  1919. offsetW = (path == 'horizontal') ? parseInt((iL.items[vars.next] || iL.items[vars.prev]) ? ((opts.styles.nextOffsetX + opts.styles.prevOffsetX)) * 2 : (((width / 10) <= 30) ? 30 : (width / 10))) : parseInt(((width / 10) <= 30) ? 30 : (width / 10)) + thumbsOffsetW,
  1920. offsetH = (path == 'horizontal') ? parseInt(((height / 10) <= 30) ? 30 : (height / 10)) + thumbsOffsetH : parseInt((iL.items[vars.next] || iL.items[vars.prev]) ? ((opts.styles.nextOffsetX + opts.styles.prevOffsetX)) * 2 : (((height / 10) <= 30) ? 30 : (height / 10)));
  1921.  
  1922. var elObject = {
  1923. type: 'current',
  1924. width: width,
  1925. height: height,
  1926. item: iL.items[vars.current],
  1927. offsetW: offsetW,
  1928. offsetH: offsetH,
  1929. thumbsOffsetW: thumbsOffsetW,
  1930. thumbsOffsetH: thumbsOffsetH,
  1931. animate: arguments.length,
  1932. holder: vars.holder
  1933. };
  1934.  
  1935. iL.repositionEl(elObject);
  1936.  
  1937. if (iL.items[vars.next]) {
  1938. elObject = $.extend(elObject, {
  1939. type: 'next',
  1940. item: iL.items[vars.next],
  1941. offsetX: opts.styles.nextOffsetX,
  1942. offsetY: opts.styles.nextOffsetY,
  1943. holder: vars.nextPhoto
  1944. });
  1945.  
  1946. iL.repositionEl(elObject);
  1947. }
  1948.  
  1949. if (iL.items[vars.prev]) {
  1950. elObject = $.extend(elObject, {
  1951. type: 'prev',
  1952. item: iL.items[vars.prev],
  1953. offsetX: opts.styles.prevOffsetX,
  1954. offsetY: opts.styles.prevOffsetY,
  1955. holder: vars.prevPhoto
  1956. });
  1957.  
  1958. iL.repositionEl(elObject);
  1959. }
  1960.  
  1961. var loaderCss = (path == "horizontal") ? {
  1962. left: parseInt((width / 2) - (vars.loader.outerWidth() / 2))
  1963. } : {
  1964. top: parseInt((height / 2) - (vars.loader.outerHeight() / 2))
  1965. };
  1966. vars.loader.css(loaderCss);
  1967. },
  1968.  
  1969. repositionEl: function(obj) {
  1970. var iL = this,
  1971. vars = iL.vars,
  1972. opts = iL.options,
  1973. path = opts.path.toLowerCase(),
  1974. widthAvail = (obj.type == 'current') ? ((vars.isInFullScreen && opts.fullAlone) ? obj.width : (obj.width - obj.offsetW)) : (obj.width - obj.offsetW),
  1975. heightAvail = (obj.type == 'current') ? ((vars.isInFullScreen && opts.fullAlone) ? obj.height : (obj.height - obj.offsetH)) : (obj.height - obj.offsetH),
  1976. itemParent = obj.item,
  1977. item = obj.item.options,
  1978. holder = obj.holder,
  1979. offsetX = obj.offsetX || 0,
  1980. offsetY = obj.offsetY || 0,
  1981. thumbsOffsetW = obj.thumbsOffsetW,
  1982. thumbsOffsetH = obj.thumbsOffsetH;
  1983.  
  1984. if (obj.type == 'current') {
  1985. if (typeof item.width == 'number' && item.width) widthAvail = ((vars.isInFullScreen && opts.fullAlone) && (opts.fullStretchTypes.indexOf(itemParent.type) != -1 || item.fullViewPort || opts.fullViewPort)) ? widthAvail : ((item.width > widthAvail) ? widthAvail : item.width);
  1986. if (typeof item.height == 'number' && item.height) heightAvail = ((vars.isInFullScreen && opts.fullAlone) && (opts.fullStretchTypes.indexOf(itemParent.type) != -1 || item.fullViewPort || opts.fullViewPort)) ? heightAvail : ((item.height > heightAvail) ? heightAvail : item.height);
  1987. } else {
  1988. if (typeof item.width == 'number' && item.width) widthAvail = (item.width > widthAvail) ? widthAvail : item.width;
  1989. if (typeof item.height == 'number' && item.height) heightAvail = (item.height > heightAvail) ? heightAvail : item.height;
  1990. }
  1991.  
  1992. heightAvail = parseInt(heightAvail - $('.ilightbox-inner-toolbar', holder).outerHeight());
  1993.  
  1994. var width = (typeof item.width == 'string' && item.width.indexOf('%') != -1) ? percentToValue(parseInt(item.width.replace('%', '')), obj.width) : holder.data('naturalWidth'),
  1995. height = (typeof item.height == 'string' && item.height.indexOf('%') != -1) ? percentToValue(parseInt(item.height.replace('%', '')), obj.height) : holder.data('naturalHeight');
  1996.  
  1997. var dims = ((typeof item.width == 'string' && item.width.indexOf('%') != -1 || typeof item.height == 'string' && item.height.indexOf('%') != -1) ? {
  1998. width: width,
  1999. height: height
  2000. } : iL.getNewDimenstions(widthAvail, heightAvail, width, height)),
  2001. newDims = $.extend({}, dims, {});
  2002.  
  2003. if (obj.type == 'prev' || obj.type == 'next')
  2004. width = parseInt(dims.width * ((obj.type == 'next') ? opts.styles.nextScale : opts.styles.prevScale)),
  2005. height = parseInt(dims.height * ((obj.type == 'next') ? opts.styles.nextScale : opts.styles.prevScale));
  2006. else
  2007. width = dims.width,
  2008. height = dims.height;
  2009.  
  2010. var widthDiff = parseInt((getPixel(holder, 'padding-left') + getPixel(holder, 'padding-right') + getPixel(holder, 'border-left-width') + getPixel(holder, 'border-right-width')) / 2),
  2011. heightDiff = parseInt((getPixel(holder, 'padding-top') + getPixel(holder, 'padding-bottom') + getPixel(holder, 'border-top-width') + getPixel(holder, 'border-bottom-width') + $('.ilightbox-inner-toolbar', holder).outerHeight()) / 2);
  2012.  
  2013. switch (obj.type) {
  2014. case 'current':
  2015. var top = parseInt((obj.height / 2) - (height / 2) - heightDiff - (thumbsOffsetH / 2)),
  2016. left = parseInt((obj.width / 2) - (width / 2) - widthDiff - (thumbsOffsetW / 2));
  2017. break;
  2018.  
  2019. case 'next':
  2020. var top = (path == 'horizontal') ? parseInt((obj.height / 2) - offsetY - (height / 2) - heightDiff - (thumbsOffsetH / 2)) : parseInt(obj.height - offsetX - heightDiff - (thumbsOffsetH / 2)),
  2021. left = (path == 'horizontal') ? parseInt(obj.width - offsetX - widthDiff - (thumbsOffsetW / 2)) : parseInt((obj.width / 2) - (width / 2) - widthDiff - offsetY - (thumbsOffsetW / 2));
  2022. break;
  2023.  
  2024. case 'prev':
  2025. var top = (path == 'horizontal') ? parseInt((obj.height / 2) - offsetY - (height / 2) - heightDiff - (thumbsOffsetH / 2)) : parseInt(offsetX - heightDiff - height - (thumbsOffsetH / 2)),
  2026. left = (path == 'horizontal') ? parseInt(offsetX - widthDiff - width - (thumbsOffsetW / 2)) : parseInt((obj.width / 2) - offsetY - (width / 2) - widthDiff - (thumbsOffsetW / 2));
  2027. break;
  2028. }
  2029.  
  2030. holder.data('offset', {
  2031. top: top,
  2032. left: left,
  2033. newDims: newDims,
  2034. diff: {
  2035. W: widthDiff,
  2036. H: heightDiff
  2037. },
  2038. thumbsOffset: {
  2039. W: thumbsOffsetW,
  2040. H: thumbsOffsetH
  2041. },
  2042. object: obj
  2043. });
  2044.  
  2045. if (obj.animate > 0 && opts.effects.reposition) {
  2046. holder.css(transform, gpuAcceleration).stop().animate({
  2047. top: top,
  2048. left: left
  2049. }, opts.effects.repositionSpeed, 'easeOutCirc', function() {
  2050. holder.css(transform, '');
  2051. });
  2052. $('div.ilightbox-container', holder).stop().animate({
  2053. width: width,
  2054. height: height
  2055. }, opts.effects.repositionSpeed, 'easeOutCirc');
  2056. $('div.ilightbox-inner-toolbar', holder).stop().animate({
  2057. width: width
  2058. }, opts.effects.repositionSpeed, 'easeOutCirc', function() {
  2059. $(this).css('overflow', 'visible');
  2060. });
  2061. } else {
  2062. holder.css({
  2063. top: top,
  2064. left: left
  2065. });
  2066. $('div.ilightbox-container', holder).css({
  2067. width: width,
  2068. height: height
  2069. });
  2070. $('div.ilightbox-inner-toolbar', holder).css({
  2071. width: width
  2072. });
  2073. }
  2074. },
  2075.  
  2076. resume: function(priority) {
  2077. var iL = this,
  2078. vars = iL.vars,
  2079. opts = iL.options;
  2080.  
  2081. if (!opts.slideshow.pauseTime || opts.controls.slideshow && vars.total <= 1 || priority < vars.isPaused) {
  2082. return;
  2083. }
  2084.  
  2085. vars.isPaused = 0;
  2086.  
  2087. if (vars.cycleID) {
  2088. vars.cycleID = clearTimeout(vars.cycleID);
  2089. }
  2090.  
  2091. vars.cycleID = setTimeout(function() {
  2092. if (vars.current == vars.total - 1) iL.goTo(0);
  2093. else iL.moveTo('next');
  2094. }, opts.slideshow.pauseTime);
  2095. },
  2096.  
  2097. pause: function(priority) {
  2098. var iL = this,
  2099. vars = iL.vars,
  2100. opts = iL.options;
  2101.  
  2102. if (priority < vars.isPaused) {
  2103. return;
  2104. }
  2105.  
  2106. vars.isPaused = priority || 100;
  2107.  
  2108. if (vars.cycleID) {
  2109. vars.cycleID = clearTimeout(vars.cycleID);
  2110. }
  2111. },
  2112.  
  2113. resetCycle: function() {
  2114. var iL = this,
  2115. vars = iL.vars,
  2116. opts = iL.options;
  2117.  
  2118. if (opts.controls.slideshow && vars.cycleID && !vars.isPaused) {
  2119. iL.resume();
  2120. }
  2121. },
  2122.  
  2123. getNewDimenstions: function(width, height, width_old, height_old, thumb) {
  2124. var iL = this;
  2125.  
  2126. if (!width) factor = height / height_old;
  2127. else if (!height) factor = width / width_old;
  2128. else factor = min(width / width_old, height / height_old);
  2129.  
  2130. if (!thumb) {
  2131. if (factor > iL.options.maxScale) factor = iL.options.maxScale;
  2132. else if (factor < iL.options.minScale) factor = iL.options.minScale;
  2133. }
  2134.  
  2135. var final_width = (iL.options.keepAspectRatio) ? round(width_old * factor) : width,
  2136. final_height = (iL.options.keepAspectRatio) ? round(height_old * factor) : height;
  2137.  
  2138. return {
  2139. width: final_width,
  2140. height: final_height,
  2141. ratio: factor
  2142. };
  2143. },
  2144.  
  2145. setOption: function(options) {
  2146. var iL = this;
  2147.  
  2148. iL.options = $.extend(true, iL.options, options || {});
  2149. iL.refresh();
  2150. },
  2151.  
  2152. availPlugins: function() {
  2153. var iL = this,
  2154. testEl = document.createElement("video");
  2155.  
  2156. iL.plugins = {
  2157. flash: (parseInt(PluginDetect.getVersion("Shockwave")) >= 0 || parseInt(PluginDetect.getVersion("Flash")) >= 0) ? true : false,
  2158. quicktime: (parseInt(PluginDetect.getVersion("QuickTime")) >= 0) ? true : false,
  2159. html5H264: !!(testEl.canPlayType && testEl.canPlayType('video/mp4').replace(/no/, '')),
  2160. html5WebM: !!(testEl.canPlayType && testEl.canPlayType('video/webm').replace(/no/, '')),
  2161. html5Vorbis: !!(testEl.canPlayType && testEl.canPlayType('video/ogg').replace(/no/, '')),
  2162. html5QuickTime: !!(testEl.canPlayType && testEl.canPlayType('video/quicktime').replace(/no/, ''))
  2163. };
  2164. },
  2165.  
  2166. addContent: function(element, obj) {
  2167. var iL = this,
  2168. el;
  2169.  
  2170. switch (obj.type) {
  2171. case 'video':
  2172. var HTML5 = false,
  2173. videoType = obj.videoType,
  2174. html5video = obj.options.html5video;
  2175.  
  2176. if (((videoType == 'video/mp4' || obj.ext == 'mp4' || obj.ext == 'm4v') || html5video.h264) && iL.plugins.html5H264)
  2177. obj.ext = 'mp4',
  2178. obj.URL = html5video.h264 || obj.URL;
  2179. else if (html5video.webm && iL.plugins.html5WebM)
  2180. obj.ext = 'webm',
  2181. obj.URL = html5video.webm || obj.URL;
  2182. else if (html5video.ogg && iL.plugins.html5Vorbis)
  2183. obj.ext = 'ogv',
  2184. obj.URL = html5video.ogg || obj.URL;
  2185.  
  2186. if (iL.plugins.html5H264 && (videoType == 'video/mp4' || obj.ext == 'mp4' || obj.ext == 'm4v')) HTML5 = true, videoType = "video/mp4";
  2187. else if (iL.plugins.html5WebM && (videoType == 'video/webm' || obj.ext == 'webm')) HTML5 = true, videoType = "video/webm";
  2188. else if (iL.plugins.html5Vorbis && (videoType == 'video/ogg' || obj.ext == 'ogv')) HTML5 = true, videoType = "video/ogg";
  2189. else if (iL.plugins.html5QuickTime && (videoType == 'video/quicktime' || obj.ext == 'mov' || obj.ext == 'qt')) HTML5 = true, videoType = "video/quicktime";
  2190.  
  2191. if (HTML5) {
  2192. el = $('<video />', {
  2193. "width": "100%",
  2194. "height": "100%",
  2195. "preload": html5video.preload,
  2196. "autoplay": html5video.autoplay,
  2197. "poster": html5video.poster,
  2198. "controls": html5video.controls
  2199. }).append($('<source />', {
  2200. "src": obj.URL,
  2201. "type": videoType
  2202. }));
  2203. } else {
  2204. if (!iL.plugins.quicktime) el = $('<span />', {
  2205. "class": "ilightbox-alert",
  2206. html: iL.options.errors.missingPlugin.replace('{pluginspage}', pluginspages.quicktime).replace('{type}', 'QuickTime')
  2207. });
  2208. else {
  2209.  
  2210. el = $('<object />', {
  2211. "type": "video/quicktime",
  2212. "pluginspage": pluginspages.quicktime
  2213. }).attr({
  2214. "data": obj.URL,
  2215. "width": "100%",
  2216. "height": "100%"
  2217. }).append($('<param />', {
  2218. "name": "src",
  2219. "value": obj.URL
  2220. })).append($('<param />', {
  2221. "name": "autoplay",
  2222. "value": "false"
  2223. })).append($('<param />', {
  2224. "name": "loop",
  2225. "value": "false"
  2226. })).append($('<param />', {
  2227. "name": "scale",
  2228. "value": "tofit"
  2229. }));
  2230.  
  2231. if (browser.msie) el = QT_GenerateOBJECTText(obj.URL, '100%', '100%', '', 'SCALE', 'tofit', 'AUTOPLAY', 'false', 'LOOP', 'false');
  2232. }
  2233. }
  2234.  
  2235. break;
  2236.  
  2237. case 'flash':
  2238. if (!iL.plugins.flash) el = $('<span />', {
  2239. "class": "ilightbox-alert",
  2240. html: iL.options.errors.missingPlugin.replace('{pluginspage}', pluginspages.flash).replace('{type}', 'Adobe Flash player')
  2241. });
  2242. else {
  2243. var flashvars = "",
  2244. i = 0;
  2245.  
  2246. if (obj.options.flashvars) $.each(obj.options.flashvars, function(k, v) {
  2247. if (i != 0) flashvars += "&";
  2248. flashvars += k + "=" + encodeURIComponent(v);
  2249. i++;
  2250. });
  2251. else flashvars = null;
  2252.  
  2253. el = $('<embed />').attr({
  2254. "type": "application/x-shockwave-flash",
  2255. "src": obj.URL,
  2256. "width": (typeof obj.options.width == 'number' && obj.options.width && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.width : "100%",
  2257. "height": (typeof obj.options.height == 'number' && obj.options.height && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.height : "100%",
  2258. "quality": "high",
  2259. "bgcolor": "#000000",
  2260. "play": "true",
  2261. "loop": "true",
  2262. "menu": "true",
  2263. "wmode": "transparent",
  2264. "scale": "showall",
  2265. "allowScriptAccess": "always",
  2266. "allowFullScreen": "true",
  2267. "flashvars": flashvars,
  2268. "fullscreen": "yes"
  2269. });
  2270. }
  2271.  
  2272. break;
  2273.  
  2274. case 'iframe':
  2275. el = $('<iframe />').attr({
  2276. "width": (typeof obj.options.width == 'number' && obj.options.width && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.width : "100%",
  2277. "height": (typeof obj.options.height == 'number' && obj.options.height && iL.options.minScale == '1' && iL.options.maxScale == '1') ? obj.options.height : "100%",
  2278. src: obj.URL,
  2279. frameborder: 0,
  2280. 'hspace': 0,
  2281. 'vspace': 0,
  2282. 'scrolling': supportTouch ? 'auto' : 'scroll',
  2283. 'webkitAllowFullScreen': '',
  2284. 'mozallowfullscreen': '',
  2285. 'allowFullScreen': ''
  2286. });
  2287.  
  2288. break;
  2289.  
  2290. case 'inline':
  2291. el = $('<div class="ilightbox-wrapper"></div>').html($(obj.URL).clone(true));
  2292.  
  2293. break;
  2294.  
  2295. case 'html':
  2296. var object = obj.URL,
  2297. el;
  2298.  
  2299. if (object[0].nodeName) {
  2300. el = $('<div class="ilightbox-wrapper"></div>').html(object);
  2301. } else {
  2302. var dom = $(obj.URL),
  2303. html = (dom.selector) ? $('<div>' + dom + '</div>') : dom;
  2304. el = $('<div class="ilightbox-wrapper"></div>').html(html);
  2305. }
  2306.  
  2307. break;
  2308. }
  2309.  
  2310. $('div.ilightbox-container', element).empty().html(el);
  2311.  
  2312. // For fixing Chrome about just playing the video for first time
  2313. if (el[0].tagName.toLowerCase() === 'video' && browser.webkit) setTimeout(function() {
  2314. var src = el[0].currentSrc + '?' + floor(random() * 30000);
  2315. el[0].currentSrc = src;
  2316. el[0].src = src;
  2317. });
  2318.  
  2319. return el;
  2320. },
  2321.  
  2322. ogpRecognition: function(obj, callback) {
  2323. var iL = this,
  2324. url = obj.URL;
  2325.  
  2326. iL.showLoader();
  2327. doAjax(url, function(data) {
  2328. iL.hideLoader();
  2329.  
  2330. if (data) {
  2331. var object = new Object();
  2332.  
  2333. object.length = false,
  2334. object.url = data.url;
  2335.  
  2336. if (data.status == 200) {
  2337. var result = data.results,
  2338. type = result.type,
  2339. source = result.source;
  2340.  
  2341. object.source = source.src,
  2342. object.width = source.width && parseInt(source.width) || 0,
  2343. object.height = source.height && parseInt(source.height) || 0,
  2344. object.type = type,
  2345. object.thumbnail = source.thumbnail || result.images[0],
  2346. object.html5video = result.html5video || {},
  2347. object.length = true;
  2348.  
  2349. if (source.type == 'application/x-shockwave-flash') object.type = "flash";
  2350. else if (source.type.indexOf("video/") != -1) object.type = "video";
  2351. else if (source.type.indexOf("/html") != -1) object.type = "iframe";
  2352. else if (source.type.indexOf("image/") != -1) object.type = "image";
  2353.  
  2354. } else if (typeof data.response != 'undefined')
  2355. throw data.response;
  2356.  
  2357. callback.call(this, object.length ? object : false);
  2358. }
  2359. });
  2360. },
  2361.  
  2362. hashChangeHandler: function(url) {
  2363. var iL = this,
  2364. vars = iL.vars,
  2365. opts = iL.options,
  2366. URL = url || window.location.href,
  2367. hash = parseURI(URL).hash,
  2368. split = hash.split('/'),
  2369. index = split[1];
  2370.  
  2371. if (vars.hashLock || ('#' + opts.linkId != split[0] && hash.length > 1)) return;
  2372.  
  2373. if (index) {
  2374. var target = split[1] || 0;
  2375. if (iL.items[target]) {
  2376. var overlay = $('.ilightbox-overlay');
  2377. if (overlay.length && overlay.attr('linkid') == opts.linkId) {
  2378. iL.goTo(target);
  2379. } else {
  2380. iL.itemsObject[target].trigger(supportTouch ? 'itap' : 'click');
  2381. }
  2382. } else {
  2383. var overlay = $('.ilightbox-overlay');
  2384. if (overlay.length) iL.closeAction();
  2385. }
  2386. } else {
  2387. var overlay = $('.ilightbox-overlay');
  2388. if (overlay.length) iL.closeAction();
  2389. }
  2390. }
  2391. };
  2392.  
  2393. /**
  2394. * Parse style to pixels.
  2395. *
  2396. * @param {Object} $element jQuery object with element.
  2397. * @param {Property} property CSS property to get the pixels from.
  2398. *
  2399. * @return {Int}
  2400. */
  2401. function getPixel($element, property) {
  2402. return parseInt($element.css(property), 10) || 0;
  2403. }
  2404.  
  2405. /**
  2406. * Make sure that number is within the limits.
  2407. *
  2408. * @param {Number} number
  2409. * @param {Number} min
  2410. * @param {Number} max
  2411. *
  2412. * @return {Number}
  2413. */
  2414. function within(number, min, max) {
  2415. return number < min ? min : number > max ? max : number;
  2416. }
  2417.  
  2418. /**
  2419. * Get viewport/window size (width and height).
  2420. *
  2421. * @return {Object}
  2422. */
  2423. function getViewport() {
  2424. var e = window,
  2425. a = 'inner';
  2426. if (!('innerWidth' in window)) {
  2427. a = 'client';
  2428. e = document.documentElement || document.body;
  2429. }
  2430. return {
  2431. width: e[a + 'Width'],
  2432. height: e[a + 'Height']
  2433. }
  2434. }
  2435.  
  2436. /**
  2437. * Remove hash tag from the URL
  2438. *
  2439. * @return {Void}
  2440. */
  2441. function removeHash() {
  2442. var scroll = getScrollXY();
  2443.  
  2444. window.location.hash = "";
  2445.  
  2446. // Restore the scroll offset, should be flicker free
  2447. window.scrollTo(scroll.x, scroll.y);
  2448. }
  2449.  
  2450. /**
  2451. * Do the ajax requests with callback.
  2452. *
  2453. * @param {String} url
  2454. * @param {Function} callback
  2455. *
  2456. * @return {Void}
  2457. */
  2458. function doAjax(url, callback) {
  2459. var url = "http://ilightbox.net/getSource/jsonp.php?url=" + encodeURIComponent(url).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A');
  2460. $.ajax({
  2461. url: url,
  2462. dataType: 'jsonp'
  2463. });
  2464.  
  2465. iLCallback = function(data) {
  2466. callback.call(this, data);
  2467. };
  2468. }
  2469.  
  2470. /**
  2471. * Find image from DOM elements
  2472. *
  2473. * @param {Element} element
  2474. *
  2475. * @return {Void}
  2476. */
  2477. function findImageInElement(element) {
  2478. var elements = $('*', element),
  2479. imagesArr = new Array();
  2480.  
  2481. elements.each(function() {
  2482. var url = "",
  2483. element = this;
  2484.  
  2485. if ($(element).css("background-image") != "none") {
  2486. url = $(element).css("background-image");
  2487. } else if (typeof($(element).attr("src")) != "undefined" && element.nodeName.toLowerCase() == "img") {
  2488. url = $(element).attr("src");
  2489. }
  2490.  
  2491. if (url.indexOf("gradient") == -1) {
  2492. url = url.replace(/url\(\"/g, "");
  2493. url = url.replace(/url\(/g, "");
  2494. url = url.replace(/\"\)/g, "");
  2495. url = url.replace(/\)/g, "");
  2496.  
  2497. var urls = url.split(",");
  2498.  
  2499. for (var i = 0; i < urls.length; i++) {
  2500. if (urls[i].length > 0 && $.inArray(urls[i], imagesArr) == -1) {
  2501. var extra = "";
  2502. if (browser.msie && browser.version < 9) {
  2503. extra = "?" + floor(random() * 3000);
  2504. }
  2505. imagesArr.push(urls[i] + extra);
  2506. }
  2507. }
  2508. }
  2509. });
  2510.  
  2511. return imagesArr;
  2512. }
  2513.  
  2514. /**
  2515. * Get file extension.
  2516. *
  2517. * @param {String} URL
  2518. *
  2519. * @return {String}
  2520. */
  2521. function getExtension(URL) {
  2522. var ext = URL.split('.').pop().toLowerCase(),
  2523. extra = ext.indexOf('?') !== -1 ? ext.split('?').pop() : '';
  2524.  
  2525. return ext.replace(extra, '');
  2526. }
  2527.  
  2528. /**
  2529. * Get type via extension.
  2530. *
  2531. * @param {String} URL
  2532. *
  2533. * @return {String}
  2534. */
  2535. function getTypeByExtension(URL) {
  2536. var type,
  2537. ext = getExtension(URL);
  2538.  
  2539. if (extensions.image.indexOf(ext) !== -1) type = 'image';
  2540. else if (extensions.flash.indexOf(ext) !== -1) type = 'flash';
  2541. else if (extensions.video.indexOf(ext) !== -1) type = 'video';
  2542. else type = 'iframe';
  2543.  
  2544. return type;
  2545. }
  2546.  
  2547. /**
  2548. * Return value from percent of a number.
  2549. *
  2550. * @param {Number} percent
  2551. * @param {Number} total
  2552. *
  2553. * @return {Number}
  2554. */
  2555. function percentToValue(percent, total) {
  2556. return parseInt((total / 100) * percent);
  2557. }
  2558.  
  2559. /**
  2560. * A JavaScript equivalent of PHP’s parse_url.
  2561. *
  2562. * @param {String} url The URL to parse.
  2563. *
  2564. * @return {Mixed}
  2565. */
  2566. function parseURI(url) {
  2567. var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
  2568. // authority = '//' + user + ':' + pass '@' + hostname + ':' port
  2569. return (m ? {
  2570. href: m[0] || '',
  2571. protocol: m[1] || '',
  2572. authority: m[2] || '',
  2573. host: m[3] || '',
  2574. hostname: m[4] || '',
  2575. port: m[5] || '',
  2576. pathname: m[6] || '',
  2577. search: m[7] || '',
  2578. hash: m[8] || ''
  2579. } : null);
  2580. }
  2581.  
  2582. /**
  2583. * Gets the absolute URI.
  2584. *
  2585. * @param {String} href The relative URL.
  2586. * @param {String} base The base URL.
  2587. *
  2588. * @return {String} The absolute URL.
  2589. */
  2590. function absolutizeURI(base, href) { // RFC 3986
  2591. var iL = this;
  2592.  
  2593. function removeDotSegments(input) {
  2594. var output = [];
  2595. input.replace(/^(\.\.?(\/|$))+/, '')
  2596. .replace(/\/(\.(\/|$))+/g, '/')
  2597. .replace(/\/\.\.$/, '/../')
  2598. .replace(/\/?[^\/]*/g, function(p) {
  2599. if (p === '/..') {
  2600. output.pop();
  2601. } else {
  2602. output.push(p);
  2603. }
  2604. });
  2605. return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
  2606. }
  2607.  
  2608. href = parseURI(href || '');
  2609. base = parseURI(base || '');
  2610.  
  2611. return !href || !base ? null : (href.protocol || base.protocol) +
  2612. (href.protocol || href.authority ? href.authority : base.authority) +
  2613. removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : (href.pathname ? ((base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname) : base.pathname)) +
  2614. (href.protocol || href.authority || href.pathname ? href.search : (href.search || base.search)) +
  2615. href.hash;
  2616. }
  2617.  
  2618. /**
  2619. * A JavaScript equivalent of PHP’s version_compare.
  2620. *
  2621. * @param {String} v1
  2622. * @param {String} v2
  2623. * @param {String} operator
  2624. *
  2625. * @return {Boolean}
  2626. */
  2627. function version_compare(v1, v2, operator) {
  2628. this.php_js = this.php_js || {};
  2629. this.php_js.ENV = this.php_js.ENV || {};
  2630. var i = 0,
  2631. x = 0,
  2632. compare = 0,
  2633. vm = {
  2634. 'dev': -6,
  2635. 'alpha': -5,
  2636. 'a': -5,
  2637. 'beta': -4,
  2638. 'b': -4,
  2639. 'RC': -3,
  2640. 'rc': -3,
  2641. '#': -2,
  2642. 'p': 1,
  2643. 'pl': 1
  2644. },
  2645. prepVersion = function(v) {
  2646. v = ('' + v).replace(/[_\-+]/g, '.');
  2647. v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.');
  2648. return (!v.length ? [-8] : v.split('.'));
  2649. },
  2650. numVersion = function(v) {
  2651. return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10));
  2652. };
  2653. v1 = prepVersion(v1);
  2654. v2 = prepVersion(v2);
  2655. x = max(v1.length, v2.length);
  2656. for (i = 0; i < x; i++) {
  2657. if (v1[i] == v2[i]) {
  2658. continue;
  2659. }
  2660. v1[i] = numVersion(v1[i]);
  2661. v2[i] = numVersion(v2[i]);
  2662. if (v1[i] < v2[i]) {
  2663. compare = -1;
  2664. break;
  2665. } else if (v1[i] > v2[i]) {
  2666. compare = 1;
  2667. break;
  2668. }
  2669. }
  2670. if (!operator) {
  2671. return compare;
  2672. }
  2673.  
  2674. switch (operator) {
  2675. case '>':
  2676. case 'gt':
  2677. return (compare > 0);
  2678. case '>=':
  2679. case 'ge':
  2680. return (compare >= 0);
  2681. case '<=':
  2682. case 'le':
  2683. return (compare <= 0);
  2684. case '==':
  2685. case '=':
  2686. case 'eq':
  2687. return (compare === 0);
  2688. case '<>':
  2689. case '!=':
  2690. case 'ne':
  2691. return (compare !== 0);
  2692. case '':
  2693. case '<':
  2694. case 'lt':
  2695. return (compare < 0);
  2696. default:
  2697. return null;
  2698. }
  2699. }
  2700.  
  2701.  
  2702. // Begin the iLightBox plugin
  2703. $.fn.iLightBox = function() {
  2704.  
  2705. var args = arguments,
  2706. opt = ($.isPlainObject(args[0])) ? args[0] : args[1],
  2707. items = ($.isArray(args[0]) || typeof args[0] == 'string') ? args[0] : args[1];
  2708.  
  2709. if (!opt) opt = {};
  2710.  
  2711. // Default options. Play carefully.
  2712. var options = $.extend(true, {
  2713. attr: 'href',
  2714. path: 'vertical',
  2715. skin: 'dark',
  2716. linkId: false,
  2717. infinite: false,
  2718. startFrom: 0,
  2719. randomStart: false,
  2720. keepAspectRatio: true,
  2721. maxScale: 1,
  2722. minScale: .2,
  2723. innerToolbar: false,
  2724. smartRecognition: false,
  2725. mobileOptimizer: true,
  2726. fullAlone: true,
  2727. fullViewPort: null,
  2728. fullStretchTypes: 'flash, video',
  2729. overlay: {
  2730. blur: true,
  2731. opacity: .85
  2732. },
  2733. controls: {
  2734. arrows: false,
  2735. slideshow: false,
  2736. toolbar: true,
  2737. fullscreen: true,
  2738. thumbnail: true,
  2739. keyboard: true,
  2740. mousewheel: true,
  2741. swipe: true
  2742. },
  2743. keyboard: {
  2744. left: true, // previous
  2745. right: true, // next
  2746. up: true, // previous
  2747. down: true, // next
  2748. esc: true, // close
  2749. shift_enter: true // fullscreen
  2750. },
  2751. show: {
  2752. effect: true,
  2753. speed: 300,
  2754. title: true
  2755. },
  2756. hide: {
  2757. effect: true,
  2758. speed: 300
  2759. },
  2760. caption: {
  2761. start: true,
  2762. show: 'mouseenter',
  2763. hide: 'mouseleave'
  2764. },
  2765. social: {
  2766. start: true,
  2767. show: 'mouseenter',
  2768. hide: 'mouseleave',
  2769. buttons: false
  2770. },
  2771. styles: {
  2772. pageOffsetX: 0,
  2773. pageOffsetY: 0,
  2774. nextOffsetX: 45,
  2775. nextOffsetY: 0,
  2776. nextOpacity: 1,
  2777. nextScale: 1,
  2778. prevOffsetX: 45,
  2779. prevOffsetY: 0,
  2780. prevOpacity: 1,
  2781. prevScale: 1
  2782. },
  2783. thumbnails: {
  2784. maxWidth: 120,
  2785. maxHeight: 80,
  2786. normalOpacity: 1,
  2787. activeOpacity: .6
  2788. },
  2789. effects: {
  2790. reposition: true,
  2791. repositionSpeed: 200,
  2792. switchSpeed: 500,
  2793. loadedFadeSpeed: 180,
  2794. fadeSpeed: 200
  2795. },
  2796. slideshow: {
  2797. pauseTime: 5000,
  2798. pauseOnHover: false,
  2799. startPaused: true
  2800. },
  2801. text: {
  2802. close: "Press Esc to close",
  2803. enterFullscreen: "Enter Fullscreen (Shift+Enter)",
  2804. exitFullscreen: "Exit Fullscreen (Shift+Enter)",
  2805. slideShow: "Slideshow",
  2806. next: "Next",
  2807. previous: "Previous"
  2808. },
  2809. errors: {
  2810. loadImage: "An error occurred when trying to load photo.",
  2811. loadContents: "An error occurred when trying to load contents.",
  2812. missingPlugin: "The content your are attempting to view requires the <a href='{pluginspage}' target='_blank'>{type} plugin<\/a>."
  2813. },
  2814. ajaxSetup: {
  2815. url: '',
  2816. beforeSend: function(jqXHR, settings) {},
  2817. cache: false,
  2818. complete: function(jqXHR, textStatus) {},
  2819. crossDomain: false,
  2820. error: function(jqXHR, textStatus, errorThrown) {},
  2821. success: function(data, textStatus, jqXHR) {},
  2822. global: true,
  2823. ifModified: false,
  2824. username: null,
  2825. password: null,
  2826. type: 'GET'
  2827. },
  2828. callback: {}
  2829. }, opt);
  2830.  
  2831. var instant = ($.isArray(items) || typeof items == 'string') ? true : false;
  2832.  
  2833. items = $.isArray(items) ? items : new Array();
  2834.  
  2835. if (typeof args[0] == 'string') items[0] = args[0];
  2836.  
  2837. if (version_compare($.fn.jquery, '1.8', '>=')) {
  2838. var iLB = new iLightBox($(this), options, items, instant);
  2839. return {
  2840. close: function() {
  2841. iLB.closeAction();
  2842. },
  2843. fullscreen: function() {
  2844. iLB.fullScreenAction();
  2845. },
  2846. moveNext: function() {
  2847. iLB.moveTo('next');
  2848. },
  2849. movePrev: function() {
  2850. iLB.moveTo('prev');
  2851. },
  2852. goTo: function(index) {
  2853. iLB.goTo(index);
  2854. },
  2855. refresh: function() {
  2856. iLB.refresh();
  2857. },
  2858. reposition: function() {
  2859. (arguments.length > 0) ? iLB.repositionPhoto(true): iLB.repositionPhoto();
  2860. },
  2861. setOption: function(options) {
  2862. iLB.setOption(options);
  2863. },
  2864. destroy: function() {
  2865. iLB.closeAction();
  2866. iLB.dispatchItemsEvents();
  2867. }
  2868. };
  2869. } else {
  2870. throw "The jQuery version that was loaded is too old. iLightBox requires jQuery 1.8+";
  2871. }
  2872.  
  2873. };
  2874.  
  2875.  
  2876. $.iLightBox = function() {
  2877. return $.fn.iLightBox(arguments[0], arguments[1]);
  2878. };
  2879.  
  2880.  
  2881. $.extend($.easing, {
  2882. easeInCirc: function(x, t, b, c, d) {
  2883. return -c * (sqrt(1 - (t /= d) * t) - 1) + b;
  2884. },
  2885. easeOutCirc: function(x, t, b, c, d) {
  2886. return c * sqrt(1 - (t = t / d - 1) * t) + b;
  2887. },
  2888. easeInOutCirc: function(x, t, b, c, d) {
  2889. if ((t /= d / 2) < 1) return -c / 2 * (sqrt(1 - t * t) - 1) + b;
  2890. return c / 2 * (sqrt(1 - (t -= 2) * t) + 1) + b;
  2891. }
  2892. });
  2893.  
  2894. function getScrollXY() {
  2895. var scrOfX = 0,
  2896. scrOfY = 0;
  2897. if (typeof(window.pageYOffset) == 'number') {
  2898. //Netscape compliant
  2899. scrOfY = window.pageYOffset;
  2900. scrOfX = window.pageXOffset;
  2901. } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
  2902. //DOM compliant
  2903. scrOfY = document.body.scrollTop;
  2904. scrOfX = document.body.scrollLeft;
  2905. } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
  2906. //IE6 standards compliant mode
  2907. scrOfY = document.documentElement.scrollTop;
  2908. scrOfX = document.documentElement.scrollLeft;
  2909. }
  2910. return {
  2911. x: scrOfX,
  2912. y: scrOfY
  2913. };
  2914. }
  2915.  
  2916. (function() {
  2917. // add new event shortcuts
  2918. $.each(("touchstart touchmove touchend " +
  2919. "tap taphold " +
  2920. "swipe swipeleft swiperight " +
  2921. "scrollstart scrollstop").split(" "), function(i, name) {
  2922.  
  2923. $.fn[name] = function(fn) {
  2924. return fn ? this.bind(name, fn) : this.trigger(name);
  2925. };
  2926.  
  2927. // jQuery < 1.8
  2928. if ($.attrFn) {
  2929. $.attrFn[name] = true;
  2930. }
  2931. });
  2932.  
  2933. var tapSettings = {
  2934. startEvent: 'touchstart.iTap',
  2935. endEvent: 'touchend.iTap'
  2936. };
  2937.  
  2938. // tap Event:
  2939. $.event.special.itap = {
  2940. setup: function() {
  2941.  
  2942. var self = this,
  2943. $self = $(this),
  2944. start, stop;
  2945.  
  2946. $self.bind(tapSettings.startEvent, function(event) {
  2947. start = getScrollXY();
  2948.  
  2949. $self.one(tapSettings.endEvent, function(event) {
  2950. stop = getScrollXY();
  2951.  
  2952. var orgEvent = event || window.event;
  2953. event = $.event.fix(orgEvent);
  2954. event.type = "itap";
  2955.  
  2956. if ((start && stop) && (start.x == stop.x && start.y == stop.y))($.event.dispatch || $.event.handle).call(self, event);
  2957.  
  2958. start = stop = undefined;
  2959. });
  2960. });
  2961. },
  2962.  
  2963. teardown: function() {
  2964. $(this).unbind(tapSettings.startEvent);
  2965. }
  2966. };
  2967. }());
  2968.  
  2969.  
  2970. //Fullscreen API
  2971. (function() {
  2972. fullScreenApi = {
  2973. supportsFullScreen: false,
  2974. isFullScreen: function() {
  2975. return false;
  2976. },
  2977. requestFullScreen: function() {},
  2978. cancelFullScreen: function() {},
  2979. fullScreenEventName: '',
  2980. prefix: ''
  2981. },
  2982. browserPrefixes = 'webkit moz o ms khtml'.split(' ');
  2983.  
  2984. // check for native support
  2985. if (typeof document.cancelFullScreen != 'undefined') {
  2986. fullScreenApi.supportsFullScreen = true;
  2987. } else {
  2988. // check for fullscreen support by vendor prefix
  2989. for (var i = 0, il = browserPrefixes.length; i < il; i++) {
  2990. fullScreenApi.prefix = browserPrefixes[i];
  2991.  
  2992. if (typeof document[fullScreenApi.prefix + 'CancelFullScreen'] != 'undefined') {
  2993. fullScreenApi.supportsFullScreen = true;
  2994.  
  2995. break;
  2996. }
  2997. }
  2998. }
  2999.  
  3000. // update methods to do something useful
  3001. if (fullScreenApi.supportsFullScreen) {
  3002. fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
  3003.  
  3004. fullScreenApi.isFullScreen = function() {
  3005. switch (this.prefix) {
  3006. case '':
  3007. return document.fullScreen;
  3008. case 'webkit':
  3009. return document.webkitIsFullScreen;
  3010. default:
  3011. return document[this.prefix + 'FullScreen'];
  3012. }
  3013. }
  3014. fullScreenApi.requestFullScreen = function(el) {
  3015. return (this.prefix === '') ? el.requestFullScreen() : el[this.prefix + 'RequestFullScreen']();
  3016. }
  3017. fullScreenApi.cancelFullScreen = function(el) {
  3018. return (this.prefix === '') ? document.cancelFullScreen() : document[this.prefix + 'CancelFullScreen']();
  3019. }
  3020. }
  3021. }());
  3022.  
  3023. // Browser detect
  3024. (function() {
  3025. function uaMatch(ua) {
  3026. ua = ua.toLowerCase();
  3027.  
  3028. var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
  3029. /(webkit)[ \/]([\w.]+)/.exec(ua) ||
  3030. /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
  3031. /(msie) ([\w.]+)/.exec(ua) ||
  3032. ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
  3033.  
  3034. return {
  3035. browser: match[1] || "",
  3036. version: match[2] || "0"
  3037. };
  3038. }
  3039.  
  3040. var matched = uaMatch(navigator.userAgent);
  3041. browser = {};
  3042.  
  3043. if (matched.browser) {
  3044. browser[matched.browser] = true;
  3045. browser.version = matched.version;
  3046. }
  3047.  
  3048. // Chrome is Webkit, but Webkit is also Safari.
  3049. if (browser.chrome) {
  3050. browser.webkit = true;
  3051. } else if (browser.webkit) {
  3052. browser.safari = true;
  3053. }
  3054. }());
  3055.  
  3056. // Feature detects
  3057. (function() {
  3058. var prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
  3059. var el = document.createElement('div');
  3060.  
  3061. function testProp(prop) {
  3062. for (var p = 0, pl = prefixes.length; p < pl; p++) {
  3063. var prefixedProp = prefixes[p] ? prefixes[p] + prop.charAt(0).toUpperCase() + prop.slice(1) : prop;
  3064. if (el.style[prefixedProp] !== undefined) {
  3065. return prefixedProp;
  3066. }
  3067. }
  3068. }
  3069.  
  3070. // Global support indicators
  3071. transform = testProp('transform') || '';
  3072. gpuAcceleration = testProp('perspective') ? 'translateZ(0) ' : '';
  3073. }());
  3074.  
  3075.  
  3076. /*
  3077. PluginDetect v0.7.9
  3078. www.pinlady.net/PluginDetect/license/
  3079. [ getVersion onWindowLoaded BetterIE ]
  3080. [ Flash QuickTime Shockwave ]
  3081. */
  3082. var PluginDetect={version:"0.7.9",name:"PluginDetect",handler:function(c,b,a){return function(){c(b,a)}},openTag:"<",isDefined:function(b){return typeof b!="undefined"},isArray:function(b){return(/array/i).test(Object.prototype.toString.call(b))},isFunc:function(b){return typeof b=="function"},isString:function(b){return typeof b=="string"},isNum:function(b){return typeof b=="number"},isStrNum:function(b){return(typeof b=="string"&&(/\d/).test(b))},getNumRegx:/[\d][\d\.\_,-]*/,splitNumRegx:/[\.\_,-]/g,getNum:function(b,c){var d=this,a=d.isStrNum(b)?(d.isDefined(c)?new RegExp(c):d.getNumRegx).exec(b):null;return a?a[0]:null},compareNums:function(h,f,d){var e=this,c,b,a,g=parseInt;if(e.isStrNum(h)&&e.isStrNum(f)){if(e.isDefined(d)&&d.compareNums){return d.compareNums(h,f)}c=h.split(e.splitNumRegx);b=f.split(e.splitNumRegx);for(a=0;a<min(c.length,b.length);a++){if(g(c[a],10)>g(b[a],10)){return 1}if(g(c[a],10)<g(b[a],10)){return -1}}}return 0},formatNum:function(b,c){var d=this,a,e;if(!d.isStrNum(b)){return null}if(!d.isNum(c)){c=4}c--;e=b.replace(/\s/g,"").split(d.splitNumRegx).concat(["0","0","0","0"]);for(a=0;a<4;a++){if(/^(0+)(.+)$/.test(e[a])){e[a]=RegExp.$2}if(a>c||!(/\d/).test(e[a])){e[a]="0"}}return e.slice(0,4).join(",")},$$hasMimeType:function(a){return function(c){if(!a.isIE&&c){var f,e,b,d=a.isArray(c)?c:(a.isString(c)?[c]:[]);for(b=0;b<d.length;b++){if(a.isString(d[b])&&/[^\s]/.test(d[b])){f=navigator.mimeTypes[d[b]];e=f?f.enabledPlugin:0;if(e&&(e.name||e.description)){return f}}}}return null}},findNavPlugin:function(l,e,c){var j=this,h=new RegExp(l,"i"),d=(!j.isDefined(e)||e)?/\d/:0,k=c?new RegExp(c,"i"):0,a=navigator.plugins,g="",f,b,m;for(f=0;f<a.length;f++){m=a[f].description||g;b=a[f].name||g;if((h.test(m)&&(!d||d.test(RegExp.leftContext+RegExp.rightContext)))||(h.test(b)&&(!d||d.test(RegExp.leftContext+RegExp.rightContext)))){if(!k||!(k.test(m)||k.test(b))){return a[f]}}}return null},getMimeEnabledPlugin:function(k,m,c){var e=this,f,b=new RegExp(m,"i"),h="",g=c?new RegExp(c,"i"):0,a,l,d,j=e.isString(k)?[k]:k;for(d=0;d<j.length;d++){if((f=e.hasMimeType(j[d]))&&(f=f.enabledPlugin)){l=f.description||h;a=f.name||h;if(b.test(l)||b.test(a)){if(!g||!(g.test(l)||g.test(a))){return f}}}}return 0},getPluginFileVersion:function(f,b){var h=this,e,d,g,a,c=-1;if(h.OS>2||!f||!f.version||!(e=h.getNum(f.version))){return b}if(!b){return e}e=h.formatNum(e);b=h.formatNum(b);d=b.split(h.splitNumRegx);g=e.split(h.splitNumRegx);for(a=0;a<d.length;a++){if(c>-1&&a>c&&d[a]!="0"){return b}if(g[a]!=d[a]){if(c==-1){c=a}if(d[a]!="0"){return b}}}return e},AXO:window.ActiveXObject,getAXO:function(a){var f=null,d,b=this,c={};try{f=new b.AXO(a)}catch(d){}return f},convertFuncs:function(f){var a,g,d,b=/^[\$][\$]/,c=this;for(a in f){if(b.test(a)){try{g=a.slice(2);if(g.length>0&&!f[g]){f[g]=f[a](f);delete f[a]}}catch(d){}}}},initObj:function(e,b,d){var a,c;if(e){if(e[b[0]]==1||d){for(a=0;a<b.length;a=a+2){e[b[a]]=b[a+1]}}for(a in e){c=e[a];if(c&&c[b[0]]==1){this.initObj(c,b)}}}},initScript:function(){var d=this,a=navigator,h,i=document,l=a.userAgent||"",j=a.vendor||"",b=a.platform||"",k=a.product||"";d.initObj(d,["$",d]);for(h in d.Plugins){if(d.Plugins[h]){d.initObj(d.Plugins[h],["$",d,"$$",d.Plugins[h]],1)}}d.convertFuncs(d);d.OS=100;if(b){var g=["Win",1,"Mac",2,"Linux",3,"FreeBSD",4,"iPhone",21.1,"iPod",21.2,"iPad",21.3,"Win.*CE",22.1,"Win.*Mobile",22.2,"Pocket\\s*PC",22.3,"",100];for(h=g.length-2;h>=0;h=h-2){if(g[h]&&new RegExp(g[h],"i").test(b)){d.OS=g[h+1];break}}};d.head=i.getElementsByTagName("head")[0]||i.getElementsByTagName("body")[0]||i.body||null;d.isIE=new Function("return/*@cc_on!@*/!1")();d.verIE=d.isIE&&(/MSIE\s*(\d+\.?\d*)/i).test(l)?parseFloat(RegExp.$1,10):null;d.verIEfull=null;d.docModeIE=null;if(d.isIE){var f,n,c=document.createElement("div");try{c.style.behavior="url(#default#clientcaps)";d.verIEfull=(c.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid")).replace(/,/g,".")}catch(f){}n=parseFloat(d.verIEfull||"0",10);d.docModeIE=i.documentMode||((/back/i).test(i.compatMode||"")?5:n)||d.verIE;d.verIE=n||d.docModeIE};d.ActiveXEnabled=false;if(d.isIE){var h,m=["Msxml2.XMLHTTP","Msxml2.DOMDocument","Microsoft.XMLDOM","ShockwaveFlash.ShockwaveFlash","TDCCtl.TDCCtl","Shell.UIHelper","Scripting.Dictionary","wmplayer.ocx"];for(h=0;h<m.length;h++){if(d.getAXO(m[h])){d.ActiveXEnabled=true;break}}};d.isGecko=(/Gecko/i).test(k)&&(/Gecko\s*\/\s*\d/i).test(l);d.verGecko=d.isGecko?d.formatNum((/rv\s*\:\s*([\.\,\d]+)/i).test(l)?RegExp.$1:"0.9"):null;d.isChrome=(/Chrome\s*\/\s*(\d[\d\.]*)/i).test(l);d.verChrome=d.isChrome?d.formatNum(RegExp.$1):null;d.isSafari=((/Apple/i).test(j)||(!j&&!d.isChrome))&&(/Safari\s*\/\s*(\d[\d\.]*)/i).test(l);d.verSafari=d.isSafari&&(/Version\s*\/\s*(\d[\d\.]*)/i).test(l)?d.formatNum(RegExp.$1):null;d.isOpera=(/Opera\s*[\/]?\s*(\d+\.?\d*)/i).test(l);d.verOpera=d.isOpera&&((/Version\s*\/\s*(\d+\.?\d*)/i).test(l)||1)?parseFloat(RegExp.$1,10):null;d.addWinEvent("load",d.handler(d.runWLfuncs,d))},init:function(d){var c=this,b,d,a={status:-3,plugin:0};if(!c.isString(d)){return a}if(d.length==1){c.getVersionDelimiter=d;return a}d=d.toLowerCase().replace(/\s/g,"");b=c.Plugins[d];if(!b||!b.getVersion){return a}a.plugin=b;if(!c.isDefined(b.installed)){b.installed=null;b.version=null;b.version0=null;b.getVersionDone=null;b.pluginName=d}c.garbage=false;if(c.isIE&&!c.ActiveXEnabled&&d!=="java"){a.status=-2;return a}a.status=1;return a},fPush:function(b,a){var c=this;if(c.isArray(a)&&(c.isFunc(b)||(c.isArray(b)&&b.length>0&&c.isFunc(b[0])))){a.push(b)}},callArray:function(b){var c=this,a;if(c.isArray(b)){for(a=0;a<b.length;a++){if(b[a]===null){return}c.call(b[a]);b[a]=null}}},call:function(c){var b=this,a=b.isArray(c)?c.length:-1;if(a>0&&b.isFunc(c[0])){c[0](b,a>1?c[1]:0,a>2?c[2]:0,a>3?c[3]:0)}else{if(b.isFunc(c)){c(b)}}},getVersionDelimiter:",",$$getVersion:function(a){return function(g,d,c){var e=a.init(g),f,b,h={};if(e.status<0){return null};f=e.plugin;if(f.getVersionDone!=1){f.getVersion(null,d,c);if(f.getVersionDone===null){f.getVersionDone=1}}a.cleanup();b=(f.version||f.version0);b=b?b.replace(a.splitNumRegx,a.getVersionDelimiter):b;return b}},cleanup:function(){var a=this;if(a.garbage&&a.isDefined(window.CollectGarbage)){window.CollectGarbage()}},isActiveXObject:function(d,b){var f=this,a=false,g,c='<object width="1" height="1" style="display:none" '+d.getCodeBaseVersion(b)+">"+d.HTML+f.openTag+"/object>";if(!f.head){return a}f.head.insertBefore(document.createElement("object"),f.head.firstChild);f.head.firstChild.outerHTML=c;try{f.head.firstChild.classid=d.classID}catch(g){}try{if(f.head.firstChild.object){a=true}}catch(g){}try{if(a&&f.head.firstChild.readyState<4){f.garbage=true}}catch(g){}f.head.removeChild(f.head.firstChild);return a},codebaseSearch:function(f,b){var c=this;if(!c.ActiveXEnabled||!f){return null}if(f.BIfuncs&&f.BIfuncs.length&&f.BIfuncs[f.BIfuncs.length-1]!==null){c.callArray(f.BIfuncs)}var d,o=f.SEARCH,k={};if(c.isStrNum(b)){if(o.match&&o.min&&c.compareNums(b,o.min)<=0){return true}if(o.match&&o.max&&c.compareNums(b,o.max)>=0){return false}d=c.isActiveXObject(f,b);if(d&&(!o.min||c.compareNums(b,o.min)>0)){o.min=b}if(!d&&(!o.max||c.compareNums(b,o.max)<0)){o.max=b}return d};var e=[0,0,0,0],l=[].concat(o.digits),a=o.min?1:0,j,i,h,g,m,n=function(p,r){var q=[].concat(e);q[p]=r;return c.isActiveXObject(f,q.join(","))};if(o.max){g=o.max.split(c.splitNumRegx);for(j=0;j<g.length;j++){g[j]=parseInt(g[j],10)}if(g[0]<l[0]){l[0]=g[0]}}if(o.min){m=o.min.split(c.splitNumRegx);for(j=0;j<m.length;j++){m[j]=parseInt(m[j],10)}if(m[0]>e[0]){e[0]=m[0]}}if(m&&g){for(j=1;j<m.length;j++){if(m[j-1]!=g[j-1]){break}if(g[j]<l[j]){l[j]=g[j]}if(m[j]>e[j]){e[j]=m[j]}}}if(o.max){for(j=1;j<l.length;j++){if(g[j]>0&&l[j]==0&&l[j-1]<o.digits[j-1]){l[j-1]+=1;break}}};for(j=0;j<l.length;j++){h={};for(i=0;i<20;i++){if(l[j]-e[j]<1){break}d=round((l[j]+e[j])/2);if(h["a"+d]){break}h["a"+d]=1;if(n(j,d)){e[j]=d;a=1}else{l[j]=d}}l[j]=e[j];if(!a&&n(j,e[j])){a=1};if(!a){break}};return a?e.join(","):null},addWinEvent:function(d,c){var e=this,a=window,b;if(e.isFunc(c)){if(a.addEventListener){a.addEventListener(d,c,false)}else{if(a.attachEvent){a.attachEvent("on"+d,c)}else{b=a["on"+d];a["on"+d]=e.winHandler(c,b)}}}},winHandler:function(d,c){return function(){d();if(typeof c=="function"){c()}}},WLfuncs0:[],WLfuncs:[],runWLfuncs:function(a){var b={};a.winLoaded=true;a.callArray(a.WLfuncs0);a.callArray(a.WLfuncs);if(a.onDoneEmptyDiv){a.onDoneEmptyDiv()}},winLoaded:false,$$onWindowLoaded:function(a){return function(b){if(a.winLoaded){a.call(b)}else{a.fPush(b,a.WLfuncs)}}},div:null,divID:"plugindetect",divWidth:50,pluginSize:1,emptyDiv:function(){var d=this,b,h,c,a,f,g;if(d.div&&d.div.childNodes){for(b=d.div.childNodes.length-1;b>=0;b--){c=d.div.childNodes[b];if(c&&c.childNodes){for(h=c.childNodes.length-1;h>=0;h--){g=c.childNodes[h];try{c.removeChild(g)}catch(f){}}}if(c){try{d.div.removeChild(c)}catch(f){}}}}if(!d.div){a=document.getElementById(d.divID);if(a){d.div=a}}if(d.div&&d.div.parentNode){try{d.div.parentNode.removeChild(d.div)}catch(f){}d.div=null}},DONEfuncs:[],onDoneEmptyDiv:function(){var c=this,a,b;if(!c.winLoaded){return}if(c.WLfuncs&&c.WLfuncs.length&&c.WLfuncs[c.WLfuncs.length-1]!==null){return}for(a in c){b=c[a];if(b&&b.funcs){if(b.OTF==3){return}if(b.funcs.length&&b.funcs[b.funcs.length-1]!==null){return}}}for(a=0;a<c.DONEfuncs.length;a++){c.callArray(c.DONEfuncs)}c.emptyDiv()},getWidth:function(c){if(c){var a=c.scrollWidth||c.offsetWidth,b=this;if(b.isNum(a)){return a}}return -1},getTagStatus:function(m,g,a,b){var c=this,f,k=m.span,l=c.getWidth(k),h=a.span,j=c.getWidth(h),d=g.span,i=c.getWidth(d);if(!k||!h||!d||!c.getDOMobj(m)){return -2}if(j<i||l<0||j<0||i<0||i<=c.pluginSize||c.pluginSize<1){return 0}if(l>=i){return -1}try{if(l==c.pluginSize&&(!c.isIE||c.getDOMobj(m).readyState==4)){if(!m.winLoaded&&c.winLoaded){return 1}if(m.winLoaded&&c.isNum(b)){if(!c.isNum(m.count)){m.count=b}if(b-m.count>=10){return 1}}}}catch(f){}return 0},getDOMobj:function(g,a){var f,d=this,c=g?g.span:0,b=c&&c.firstChild?1:0;try{if(b&&a){d.div.focus()}}catch(f){}return b?c.firstChild:null},setStyle:function(b,g){var f=b.style,a,d,c=this;if(f&&g){for(a=0;a<g.length;a=a+2){try{f[g[a]]=g[a+1]}catch(d){}}}},insertDivInBody:function(i,g){var f,c=this,h="pd33993399",b=null,d=g?window.top.document:window.document,a=d.getElementsByTagName("body")[0]||d.body;if(!a){try{d.write('<div id="'+h+'">.'+c.openTag+"/div>");b=d.getElementById(h)}catch(f){}}a=d.getElementsByTagName("body")[0]||d.body;if(a){a.insertBefore(i,a.firstChild);if(b){a.removeChild(b)}}},insertHTML:function(f,b,g,a,k){var l,m=document,j=this,p,o=m.createElement("span"),n,i;var c=["outlineStyle","none","borderStyle","none","padding","0px","margin","0px","visibility","visible"];var h="outline-style:none;border-style:none;padding:0px;margin:0px;visibility:visible;";if(!j.isDefined(a)){a=""}if(j.isString(f)&&(/[^\s]/).test(f)){f=f.toLowerCase().replace(/\s/g,"");p=j.openTag+f+' width="'+j.pluginSize+'" height="'+j.pluginSize+'" ';p+='style="'+h+'display:inline;" ';for(n=0;n<b.length;n=n+2){if(/[^\s]/.test(b[n+1])){p+=b[n]+'="'+b[n+1]+'" '}}p+=">";for(n=0;n<g.length;n=n+2){if(/[^\s]/.test(g[n+1])){p+=j.openTag+'param name="'+g[n]+'" value="'+g[n+1]+'" />'}}p+=a+j.openTag+"/"+f+">"}else{p=a}if(!j.div){i=m.getElementById(j.divID);if(i){j.div=i}else{j.div=m.createElement("div");j.div.id=j.divID}j.setStyle(j.div,c.concat(["width",j.divWidth+"px","height",(j.pluginSize+3)+"px","fontSize",(j.pluginSize+3)+"px","lineHeight",(j.pluginSize+3)+"px","verticalAlign","baseline","display","block"]));if(!i){j.setStyle(j.div,["position","absolute","right","0px","top","0px"]);j.insertDivInBody(j.div)}}if(j.div&&j.div.parentNode){j.setStyle(o,c.concat(["fontSize",(j.pluginSize+3)+"px","lineHeight",(j.pluginSize+3)+"px","verticalAlign","baseline","display","inline"]));try{o.innerHTML=p}catch(l){};try{j.div.appendChild(o)}catch(l){};return{span:o,winLoaded:j.winLoaded,tagName:f,outerHTML:p}}return{span:null,winLoaded:j.winLoaded,tagName:"",outerHTML:p}},Plugins:{quicktime:{mimeType:["video/quicktime","application/x-quicktimeplayer","image/x-macpaint","image/x-quicktime"],progID:"QuickTimeCheckObject.QuickTimeCheck.1",progID0:"QuickTime.QuickTime",classID:"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B",minIEver:7,HTML:'<param name="src" value="" /><param name="controller" value="false" />',getCodeBaseVersion:function(a){return'codebase="#version='+a+'"'},SEARCH:{min:0,max:0,match:0,digits:[16,128,128,0]},getVersion:function(c){var f=this,d=f.$,a=null,e=null,b;if(!d.isIE){if(d.hasMimeType(f.mimeType)){e=d.OS!=3?d.findNavPlugin("QuickTime.*Plug-?in",0):null;if(e&&e.name){a=d.getNum(e.name)}}}else{if(d.isStrNum(c)){b=c.split(d.splitNumRegx);if(b.length>3&&parseInt(b[3],10)>0){b[3]="9999"}c=b.join(",")}if(d.isStrNum(c)&&d.verIE>=f.minIEver&&f.canUseIsMin()>0){f.installed=f.isMin(c);f.getVersionDone=0;return}f.getVersionDone=1;if(!a&&d.verIE>=f.minIEver){a=f.CDBASE2VER(d.codebaseSearch(f))}if(!a){e=d.getAXO(f.progID);if(e&&e.QuickTimeVersion){a=e.QuickTimeVersion.toString(16);a=parseInt(a.charAt(0),16)+"."+parseInt(a.charAt(1),16)+"."+parseInt(a.charAt(2),16)}}}f.installed=a?1:(e?0:-1);f.version=d.formatNum(a,3)},cdbaseUpper:["7,60,0,0","0,0,0,0"],cdbaseLower:["7,50,0,0",null],cdbase2ver:[function(c,b){var a=b.split(c.$.splitNumRegx);return[a[0],a[1].charAt(0),a[1].charAt(1),a[2]].join(",")},null],CDBASE2VER:function(f){var e=this,c=e.$,b,a=e.cdbaseUpper,d=e.cdbaseLower;if(f){f=c.formatNum(f);for(b=0;b<a.length;b++){if(a[b]&&c.compareNums(f,a[b])<0&&d[b]&&c.compareNums(f,d[b])>=0&&e.cdbase2ver[b]){return e.cdbase2ver[b](e,f)}}}return f},canUseIsMin:function(){var f=this,d=f.$,b,c=f.canUseIsMin,a=f.cdbaseUpper,e=f.cdbaseLower;if(!c.value){c.value=-1;for(b=0;b<a.length;b++){if(a[b]&&d.codebaseSearch(f,a[b])){c.value=1;break}if(e[b]&&d.codebaseSearch(f,e[b])){c.value=-1;break}}}f.SEARCH.match=c.value==1?1:0;return c.value},isMin:function(c){var b=this,a=b.$;return a.codebaseSearch(b,c)?0.7:-1}},flash:{mimeType:"application/x-shockwave-flash",progID:"ShockwaveFlash.ShockwaveFlash",classID:"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000",getVersion:function(){var b=function(i){if(!i){return null}var e=/[\d][\d\,\.\s]*[rRdD]{0,1}[\d\,]*/.exec(i);return e?e[0].replace(/[rRdD\.]/g,",").replace(/\s/g,""):null};var j=this,g=j.$,k,h,l=null,c=null,a=null,f,m,d;if(!g.isIE){m=g.hasMimeType(j.mimeType);if(m){f=g.getDOMobj(g.insertHTML("object",["type",j.mimeType],[],"",j));try{l=g.getNum(f.GetVariable("$version"))}catch(k){}}if(!l){d=m?m.enabledPlugin:null;if(d&&d.description){l=b(d.description)}if(l){l=g.getPluginFileVersion(d,l)}}}else{for(h=15;h>2;h--){c=g.getAXO(j.progID+"."+h);if(c){a=h.toString();break}}if(!c){c=g.getAXO(j.progID)}if(a=="6"){try{c.AllowScriptAccess="always"}catch(k){return"6,0,21,0"}}try{l=b(c.GetVariable("$version"))}catch(k){}if(!l&&a){l=a}}j.installed=l?1:-1;j.version=g.formatNum(l);return true}},shockwave:{mimeType:"application/x-director",progID:"SWCtl.SWCtl",classID:"clsid:166B1BCA-3F9C-11CF-8075-444553540000",getVersion:function(){var a=null,b=null,g,f,d=this,c=d.$;if(!c.isIE){f=c.findNavPlugin("Shockwave\\s*for\\s*Director");if(f&&f.description&&c.hasMimeType(d.mimeType)){a=c.getNum(f.description)}if(a){a=c.getPluginFileVersion(f,a)}}else{try{b=c.getAXO(d.progID).ShockwaveVersion("")}catch(g){}if(c.isString(b)&&b.length>0){a=c.getNum(b)}else{if(c.getAXO(d.progID+".8")){a="8"}else{if(c.getAXO(d.progID+".7")){a="7"}else{if(c.getAXO(d.progID+".1")){a="6"}}}}}d.installed=a?1:-1;d.version=c.formatNum(a)}},zz:0}};PluginDetect.initScript();
  3083.  
  3084. var gArgCountErr='The "%%" function requires an even number of arguments.\nArguments should be in the form "atttributeName", "attributeValue", ...',gTagAttrs=null,gQTGeneratorVersion=1;function AC_QuickTimeVersion(){return gQTGeneratorVersion}function _QTComplain(a,b){b=b.replace("%%",a);alert(b)}function _QTAddAttribute(a,b,c){var d;d=gTagAttrs[a+b];null==d&&(d=gTagAttrs[b]);return null!=d?(0==b.indexOf(a)&&null==c&&(c=b.substring(a.length)),null==c&&(c=b),c+'="'+d+'" '):""}function _QTAddObjectAttr(a,b){if(0==a.indexOf("emb#"))return"";0==a.indexOf("obj#")&&null==b&&(b=a.substring(4));return _QTAddAttribute("obj#",a,b)}function _QTAddEmbedAttr(a,b){if(0==a.indexOf("obj#"))return"";0==a.indexOf("emb#")&&null==b&&(b=a.substring(4));return _QTAddAttribute("emb#",a,b)}function _QTAddObjectParam(a,b){var c,d="",e=b?" />":">";-1==a.indexOf("emb#")&&(c=gTagAttrs["obj#"+a],null==c&&(c=gTagAttrs[a]),0==a.indexOf("obj#")&&(a=a.substring(4)),null!=c&&(d=' <param name="'+a+'" value="'+c+'"'+e+"\n"));return d}function _QTDeleteTagAttrs(){for(var a=0;a<arguments.length;a++){var b=arguments[a];delete gTagAttrs[b];delete gTagAttrs["emb#"+b];delete gTagAttrs["obj#"+b]}}function _QTGenerate(a,b,c){if(4>c.length||0!=c.length%2)return _QTComplain(a,gArgCountErr),"";gTagAttrs=[];gTagAttrs.src=c[0];gTagAttrs.width=c[1];gTagAttrs.height=c[2];gTagAttrs.classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";gTagAttrs.pluginspage="http://www.apple.com/quicktime/download/";a=c[3];if(null==a||""==a)a="6,0,2,0";gTagAttrs.codebase="http://www.apple.com/qtactivex/qtplugin.cab#version="+a;for(var d,e=4;e<c.length;e+=2)d=c[e].toLowerCase(),a=c[e+1],"name"==d||"id"==d?gTagAttrs.name=a:gTagAttrs[d]=a;c="<object "+_QTAddObjectAttr("classid")+_QTAddObjectAttr("width")+_QTAddObjectAttr("height")+_QTAddObjectAttr("codebase")+_QTAddObjectAttr("name","id")+_QTAddObjectAttr("tabindex")+_QTAddObjectAttr("hspace")+_QTAddObjectAttr("vspace")+_QTAddObjectAttr("border")+_QTAddObjectAttr("align")+_QTAddObjectAttr("class")+_QTAddObjectAttr("title")+_QTAddObjectAttr("accesskey")+_QTAddObjectAttr("noexternaldata")+">\n"+_QTAddObjectParam("src",b);e=" <embed "+_QTAddEmbedAttr("src")+_QTAddEmbedAttr("width")+_QTAddEmbedAttr("height")+_QTAddEmbedAttr("pluginspage")+_QTAddEmbedAttr("name")+_QTAddEmbedAttr("align")+_QTAddEmbedAttr("tabindex");_QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex","hspace","vspace","border","align","noexternaldata","class","title","accesskey");for(d in gTagAttrs)a=gTagAttrs[d],null!=a&&(e+=_QTAddEmbedAttr(d),c+=_QTAddObjectParam(d,b));return c+e+"> </embed>\n</object>"}function QT_GenerateOBJECTText(){return _QTGenerate("QT_GenerateOBJECTText",!1,arguments)};
  3085.  
  3086.  
  3087. /*
  3088. jQuery hashchange event v1.3
  3089. https://github.com/cowboy/jquery-hashchange
  3090. Copyright (c) 2010 "Cowboy" Ben Alman
  3091. Dual licensed under the MIT and GPL licenses.
  3092. */
  3093. (function(){function e(a){a=a||location.href;return"#"+a.replace(/^[^#]*#?(.*)$/,"$1")}var k=document,b,f=$.event.special,p=k.documentMode,m="oniLightBoxHashChange"in window&&(void 0===p||7<p);$.fn.iLightBoxHashChange=function(a){return a?this.bind("iLightBoxHashChange",a):this.trigger("iLightBoxHashChange")};$.fn.iLightBoxHashChange.delay=50;f.iLightBoxHashChange=$.extend(f.iLightBoxHashChange,{setup:function(){if(m)return!1;$(b.start)},teardown:function(){if(m)return!1;$(b.stop)}});b=function(){function a(){var c=
  3094. e(),d=f(l);c!==l?(n(l=c,d),$(window).trigger("iLightBoxHashChange")):d!==l&&(location.href=location.href.replace(/#.*/,"")+d);g=setTimeout(a,$.fn.iLightBoxHashChange.delay)}var h={},g,l=e(),b=function(c){return c},n=b,f=b;h.start=function(){g||a()};h.stop=function(){g&&clearTimeout(g);g=void 0};browser.msie&&!m&&function(){var c,d;h.start=function(){c||(d=(d=$.fn.iLightBoxHashChange.src)&&d+e(),c=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){d||n(e());a()}).attr("src",d||
  3095. "javascript:0").insertAfter("body")[0].contentWindow,k.onpropertychange=function(){try{"title"===event.propertyName&&(c.document.title=k.title)}catch(a){}})};h.stop=b;f=function(){return e(c.location.href)};n=function(a,d){var b=c.document,e=$.fn.iLightBoxHashChange.domain;a!==d&&(b.title=k.title,b.open(),e&&b.write('<script>document.domain="'+e+'"\x3c/script>'),b.close(),c.location.hash=a)}}();return h}()})();
  3096.  
  3097. if (!Array.prototype.filter) {
  3098. Array.prototype.filter = function(fun /*, thisp */ ) {
  3099. "use strict";
  3100.  
  3101. if (this == null)
  3102. throw new TypeError();
  3103.  
  3104. var t = Object(this);
  3105. var len = t.length >>> 0;
  3106. if (typeof fun != "function")
  3107. throw new TypeError();
  3108.  
  3109. var res = [];
  3110. var thisp = arguments[1];
  3111. for (var i = 0; i < len; i++) {
  3112. if (i in t) {
  3113. var val = t[i]; // in case fun mutates this
  3114. if (fun.call(thisp, val, i, t))
  3115. res.push(val);
  3116. }
  3117. }
  3118.  
  3119. return res;
  3120. };
  3121. }
  3122.  
  3123. if (!Array.prototype.indexOf) {
  3124. Array.prototype.indexOf = function(searchElement, fromIndex) {
  3125. var k;
  3126.  
  3127. if (this == null) {
  3128. throw new TypeError('"this" is null or not defined');
  3129. }
  3130.  
  3131. var O = Object(this);
  3132.  
  3133. var len = O.length >>> 0;
  3134.  
  3135. if (len === 0) {
  3136. return -1;
  3137. }
  3138.  
  3139. var n = +fromIndex || 0;
  3140.  
  3141. if (abs(n) === Infinity) {
  3142. n = 0;
  3143. }
  3144.  
  3145. if (n >= len) {
  3146. return -1;
  3147. }
  3148.  
  3149. k = max(n >= 0 ? n : len - abs(n), 0);
  3150.  
  3151. while (k < len) {
  3152. var kValue;
  3153. if (k in O && O[k] === searchElement) {
  3154. return k;
  3155. }
  3156. k++;
  3157. }
  3158. return -1;
  3159. };
  3160. }
  3161.  
  3162. if (!Array.prototype.lastIndexOf) {
  3163. Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/ ) {
  3164. "use strict";
  3165.  
  3166. if (this == null)
  3167. throw new TypeError();
  3168.  
  3169. var t = Object(this);
  3170. var len = t.length >>> 0;
  3171. if (len === 0)
  3172. return -1;
  3173.  
  3174. var n = len;
  3175. if (arguments.length > 1) {
  3176. n = Number(arguments[1]);
  3177. if (n != n)
  3178. n = 0;
  3179. else if (n != 0 && n != (1 / 0) && n != -(1 / 0))
  3180. n = (n > 0 || -1) * floor(abs(n));
  3181. }
  3182.  
  3183. var k = n >= 0 ? min(n, len - 1) : len - abs(n);
  3184.  
  3185. for (; k >= 0; k--) {
  3186. if (k in t && t[k] === searchElement)
  3187. return k;
  3188. }
  3189. return -1;
  3190. };
  3191. }
  3192. })(jQuery, this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement