/* --------------------------------------------- */ /* Author: http://codecanyon.net/user/CodingJack */ /* --------------------------------------------- */ ;(function($) { //////////////////////////////////////////////////////// // BEGIN ADVANCED SETTINGS ///////////////////////////// //////////////////////////////////////////////////////// // These can be overriden with the main jackBox() call, see "Global Settings" in the help documentation var boxBuffer = 10, // Accounts for the thumb panel's border thumbnailMargin = 2, // Accounts for the large prev/next buttons you'll find on the left and right sides of the screen // This number makes sure the content always fits between these buttons thumbPanelBuffer = 160, // The width and height of the social iframe that's loaded in socialFrameWidth = 200, socialFrameHeight = 21, // The url to the swf module swfPlayer = "jackbox/modules/jackbox_swf.html", // The url to the fallback thumbnail defaultThumb = "jackbox/img/default_thumb.jpg", // The url to the video player module videoPlayer = "jackbox/modules/jackbox_video.html", // The url to the audio player module audioPlayer = "jackbox/modules/jackbox_audio.html", // The url to the social buttons module socialButtons = "jackbox/modules/jackbox_social.php", // The Vimeo video iframe to be used (edit with caution) vimeoMarkup = "//player.vimeo.com/video{url}?title=0&byline=0&portrait=0&autoplay={autoplay}&color=FFFFFF&wmode=transparent", // The Youtube video iframe to be used (edit with caution) youTubeMarkup = "//www.youtube.com/embed/{url}?autoplay={autoplay}&autohide=1&vq=hd1080&iv_load_policy=3&showinfo=0&showsearch=0&wmode=transparent", // The markup or "header" that will be placed above the item's content topMarkup = '
' + /* ******************************************** */ /* delete this line below for no social buttons */ /* ******************************************** */ '
' + // fullscreen and close buttons '
' + '' + '' + '
' + '
', // The markup or "footer" that will be placed below the item's content bottomMarkup = '
' + // prev/next buttons '
' + '' + '' + '
' + // title text plus current number '
' + '/' + '' + '
' + // info and thumb toggle buttons '
' + '' + '' + '
' + '
', //////////////////////////////////////////////////////// // END SETTINGS //////////////////////////////////////// //////////////////////////////////////////////////////// resizeThrottle, bottomContent, hasFullscreen, holderPadLeft, holderPadTop, thumbTipText, thumbBufTall, currentWidth, holderHeight, isFullscreen, ajaxSelector, ajaxRequest, thumbTipBuf, paddingTall, paddingWide, totalThumbs, description, panelBuffer, thumbMinus, thumbStrip, thumbPanel, stripWidth, thumbRight, topContent, descHolder, descHeight, showThumbs, hideThumbs, panelRight, fullNormal, scrollPos, panelLeft, titleText, thumbLeft, container, preloader, numThumbs, oldHeight, unescaped, swipeable, clickNext, firstLoad, isYoutube, defHover, oldWidth, thumbTip, thumbVis, showHide, closeBtn, descText, controls, elements, keyboard, useTips, scaleUp, divider, descVis, thumbOn, wrapper, current, goRight, legged, preBuf, goLeft, upsize, fader, touch, boxed, title, total, cover, words, $this, items, info, docs, doc, url, wid, win, leg, base, isIE, cats, high, hash, list, isIE8, pushW, pushH, timer, toCall, thumbs, bodies, holder, lights, oWidth, isLocal, runTime, scaling, content, oHeight, isImage, winWide, winTall, bufferW, bufferH, theType, parents, browser, thmWidth, dataDesc, isActive, preAdded, scroller, useSocial, useThumbs, isLoading, fromThumb, hasThumbs, holOrigTop, firstCheck, currentCat, deepLinking, lightSocial, socialFrame, thumbHolder, eventsAdded, preThumbBuf, holOrigLeft, instantiated, arrowClicked, arrowsActive, thumbsChecked, autoplayVideo, jackBoxIsReady, showDescription, usePinterest, thumbsHidden, thumbHeight, videoHeight, useFacebook, thumbWidth, videoWidth, flashVideo, showScroll, useTwitter, useGoogle, cssSkin, isOn = 1, catOn = -1, numCats = 0, firstRun = true, initialLoad = true, methods = { init: function($this) { if(typeof Jacked === "undefined" || instantiated) return; cssSkin = jackboxOptions.skin; defHover = jackboxOptions.hover; scaling = jackboxOptions["full-scale"] === "yes"; clickNext = jackboxOptions["click-next"] === "yes"; useTips = jackboxOptions["use-tooltips"] === "yes"; useThumbs = jackboxOptions["use-thumbs"] === "yes"; flashVideo = jackboxOptions["flash-video"] === "yes"; useGoogle = jackboxOptions["social-google"] === "yes"; deepLinking = jackboxOptions["deep-linking"] === "yes"; useTwitter = jackboxOptions["social-twitter"] === "yes"; showScroll = jackboxOptions["show-scrollbar"] === "yes"; thumbsHidden = jackboxOptions["thumbs-hidden"] === "yes"; keyboard = jackboxOptions["keyboard-shortcuts"] === "yes"; useFacebook = jackboxOptions["social-facebook"] === "yes"; autoplayVideo = jackboxOptions["autoplay-video"] === "yes"; usePinterest = jackboxOptions["social-pinterest"] === "yes"; showDescription = jackboxOptions["show-description"] === "yes"; thumbWidth = parseInt(jackboxOptions["thumb-width"], 10); videoWidth = parseInt(jackboxOptions["video-width"], 10); videoHeight = parseInt(jackboxOptions["video-height"], 10); thumbHeight = parseInt(jackboxOptions["thumb-height"], 10); base = jackboxOptions.domain; swfPlayer = base + swfPlayer; videoPlayer = base + videoPlayer; audioPlayer = base + audioPlayer; defaultThumb = base + defaultThumb; socialButtons = base + socialButtons; base = base.split('plugins/wp-jackbox/').join(''); doc = document; docs = $(doc); instantiated = true; thmWidth = thumbWidth + thumbnailMargin; useSocial = useFacebook || useGoogle || useTwitter || usePinterest; isLocal = doc.URL.search("file:///") !== -1; Jacked.setEngines({ios: true, safari: true, opera: true, firefox: true}); lights = $this; isIE8 = Jacked.getIE(); touch = Jacked.getMobile(); browser = Jacked.getBrowser(); isIE = browser === "ie"; if(touch) showScroll = false; if(defHover === "none") defHover = null; if(typeof $.address !== "undefined" && deepLinking) { init(); $.address.update(); } else { deepLinking = false; init(); } }, frameReady: function() { if(isActive) loaded(); }, addItem: function($this, settings) { if(jackboxAjax) jackboxCheckGallery(); $this.each(function() { apiCall.apply(this, settings); }); }, removeItem: function($this) { $this.each(function() { apiCall.apply(this, [false, true]); }); } }, loaded = (function() { var obj = {}; return function(event) { if(event) event.stopPropagation(); if(isImage) { oWidth = this.width || content.width(); oHeight = this.height || content.height(); setSize(); } obj.width = wid; obj.height = high; content.css(obj); tweenContent(true); win.on("resize.jackbox", resized); firstLoad = true; }; })(), tweenContent = (function() { var tw = {}, tw2 = {}, props = {}; return function(callback) { var newW; if(callback) { if(wid < 260) pushW += 260 - wid; newW = Math.max(wid, 260); if(newW === oldWidth && high === oldHeight) { showContent(); return; } tw.callback = showContent; tw.duration = oldWidth ? Math.abs(newW - oldWidth) > 50 || Math.abs(high - oldHeight) > 50 ? 600 : 300 : 600; } else { newW = wid; props.width = newW; tw.duration = 300; delete tw.callback; if(topContent) Jacked.tween(topContent[0], props, tw); if(bottomContent) Jacked.tween(bottomContent[0], props, tw); props.height = high; Jacked.stopTween(content[0], true); Jacked.tween(content[0], props, tw); } tw2.marginLeft = -(((pushW >> 1) + 0.5) | 0); tw2.marginTop = -(((pushH >> 1) + 0.5) | 0); tw2.height = high; tw2.width = newW; if(!oldWidth) tw2.opacity = 1; Jacked.tween(holder[0], tw2, tw); oldWidth = newW; oldHeight = high; }; })(), showContent = (function() { var dur = {}, style = {opacity: 1, visibility: "visible"}; return function() { showElements(); preloader.removeClass("jackbox-spin-preloader"); var maxed = Math.max(wid, 260); dur.duration = 600; if(isImage && !isIE8) { Jacked.fadeIn(content[0], dur); } else { if(!isYoutube) { content.show(); } else { content.css('visibility', 'visible'); } if(theType === "audio" || theType === "local") { content[0].contentWindow.cjInit(); } } dur.duration = 300; if(!isIE8) { if(topContent) { topContent.css("width", maxed); Jacked.fadeIn(topContent[0], dur); } if(bottomContent) { bottomContent.css("width", maxed); Jacked.fadeIn(bottomContent[0], dur); } } else { if(topContent) topContent.css("width", maxed).show(); if(bottomContent) bottomContent.css("width", maxed).show(); } if(info && descText) { info.show(); descHolder.html(descText).show(); descHeight = -descHolder.outerHeight(); description.css("height", -descHeight < high ? -descHeight : high); if(!showDescription) { descVis = false; descHolder.css("margin-top", descHeight); } else { descVis = true; info.addClass("jb-info-inactive"); descHolder.css("margin-top", 0); description.css("visibility", "visible"); } } else if(info) { info.hide(); descHolder.hide(); } isLoading = false; if(!eventsAdded && legged) { panelLeft.css(style); panelRight.css(style); } if(!thumbsChecked && useThumbs && legged) loadThumbs(); if(!eventsAdded) addEvents(); if(!touch) { if(isImage && clickNext) content.css("cursor", "pointer").on("click.jackbox", nextItem); } else { content[0].removeEventListener("touchstart", returnFalse, false); content[0].removeEventListener("touchmove", returnFalse, false); content[0].removeEventListener("touchend", returnFalse, false); removeTouches(); } if(legged) turnOn(); }; })(), showElements = (function() { var obj = { type: "text/html", frameborder: 0, mozallowfullscreen: "mozallowfullscreen", webkitallowfullscreen: "webkitallowfullscreen", allowfullscreen: "allowfullscreen", scrolling: "no" }; return function() { if(!elements) createElements(); if(!legged) { if(controls) controls.hide(); if(showHide) showHide.hide(); } if(title) { if(titleText === "false") titleText = false; var hasContent = words && titleText, amper = hasContent ? " - " : ""; if(current && legged) { current.text((isOn + 1)).show(); total.html(leg + amper).show(); if(divider) divider.show(); } else { if(total) total.hide(); if(current) current.hide(); if(divider) divider.hide(); } if(hasContent) { words.html(unescaped); var a = words.find("a"); if(a.length) { a.on("click.jackbox", stopProp); words.data("links", a); } } } if(!lightSocial || isLocal) return; var domain = doc.URL.split("#")[0], len = domain.length - 1, oDomain = domain, ur = domain, poster; if(domain.search("/") !== -1) { if(domain.charAt(len) !== "/") { ur = deepLinking ? domain + '#/' + hash + "/" + (isOn + 1) : domain; domain = domain.substring(0, domain.lastIndexOf("/")); } else { domain = domain.substring(0, len); ur = deepLinking ? domain + '/#/' + hash + "/" + (isOn + 1) : domain; } } if(isImage) { poster = $this.attr("href") || $this.attr("data-jbhref"); } else { var alt = $this.children("img"); poster = alt.length ? alt.attr("src") : "false"; } if(poster.search("http") === -1) poster = poster.charAt(0) !== "/" ? domain + "/" + poster : domain + poster; if(jackboxAjax && domain.search("/") !== -1) { if(oDomain.charAt(oDomain.length - 1) === '/') { oDomain = oDomain.substring(0, len); console.log(oDomain); } if(poster && poster !== 'false') { ur = poster.split(base); if(ur.length > 1) { ur = ur[1]; var dot = ur.lastIndexOf('.'); ur = oDomain + '/#/' + ur.substr(0, dot) + '/' + ur.substr(dot + 1, ur.length); } else { ur = oDomain; } } else { ur = oDomain; } } var titlText = titleText ? titleText.replace(/(<([^>]+)>)/ig, "") : doc.title; titlText = titlText.split('.').join(''); obj.width = socialFrameWidth; obj.height = socialFrameHeight; obj.src = socialButtons + "?url=" + encodeURIComponent(ur) + "&poster=" + encodeURIComponent(poster) + "&title=" + escape(titlText) + "&skin=" + cssSkin + "&fb=" + (useFacebook ? 'yes' : 'no') + "&tw=" + (useTwitter ? 'yes' : 'no') + "&gp=" + (useGoogle ? 'yes' : 'no') + "&pi=" + (usePinterest ? 'yes' : 'no') socialFrame = $("