/* Plugin Name: TS Thinkbox Plugin URI: http://www.templatesquare.com/plugin Description: TS Thinkbox is a wordpress plugin for displaying stylish testimonial etc. Version: 1.0 Author: templatesquare Author URI: http://www.templatesquare.com License: GPL */ /* Copyright 2010 TEMPLATESQUARE (email : support@templatesquare.com) This file is part of TS Thinkbox TS Thinkbox is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // JavaScript Documentvar jQuery(document).ready(function () { //define the needed variable var dur = 500; var currel = 0; var conresizable = 1; // Don't execute code if it's IE6 or below cause it doesn't support it. if (jQuery.browser.msie && jQuery.browser.version < 7) return; // retrieve all elements dimension var heightcontents = new Array(); var quotecontent = jQuery(".ts-thinkbox-slider-quotecontent"); quotecontent.each(function(idx,el){ heightcontents[idx] = el.offsetHeight; }); //use jQuery cycle to make the effect jQuery('.ts-thinkbox-slider-fade').cycle({ timeout :0, speed : dur, startingSlide : 0, fx : 'fade', containerResize : conresizable }); jQuery('.ts-thinkbox-slider-scrollVert').cycle({ timeout :0, speed : dur, startingSlide : 0, fx : 'scrollVert', containerResize : conresizable }); jQuery('.ts-thinkbox-slider-scrollHorz').cycle({ timeout :0, speed : dur, startingSlide : 0, fx : 'scrollHorz', containerResize : conresizable }); jQuery('.ts-thinkbox-slider-zoom').cycle({ timeout :0, speed : dur, startingSlide : 0, fx : 'zoom', containerResize : conresizable }); jQuery('.ts-thinkbox-slider-scrollUp').cycle({ timeout :0, speed : dur, startingSlide : 0, fx : 'scrollUp', containerResize : conresizable }); jQuery('.ts-thinkbox-slider-scrollDown').cycle({ timeout :0, speed : dur, startingSlide : 0, fx : 'scrollDown', containerResize : conresizable }); jQuery('.ts-thinkbox-slider-shuffle').cycle({ timeout :0, speed : dur, startingSlide : 0, fx : 'shuffle', containerResize : conresizable }); //define the quotecontainer height with first current element jQuery("#ts-thinkbox-slider-quotecontainer").css({'height' : heightcontents[currel]+'px'}); //when the thumbslide is clicked jQuery(".ts-thinkbox-slider-thumbslide").click(function(){ var idx = parseInt(jQuery(this).attr("title")); jQuery("#ts-thinkbox-slider-quotecontainer").cycle(idx); jQuery("#ts-thinkbox-slider-quotecontainer").animate({ 'height' : heightcontents[idx]+'px' },dur,'linear'); return false; }); jQuery(".ts-thinkbox-slider-thumbcont").walkingPointer({speed : dur}); }); // function to make the pointer moving (function($j) { jQuery.fn.walkingPointer = function(o) { o = jQuery.extend({ fx: "linear", speed: 500, click: function(){} }, o || {}); return this.each(function() { var me = jQuery(this), noop = function(){}, $pointer = jQuery('.ts-thinkbox-slider-pointer'), $thumbslide = jQuery(".ts-thinkbox-slider-thumbslide", this), curr = jQuery(".tscurrentpointer", this)[0] || jQuery($thumbslide[0]).addClass("tscurrentpointer")[0]; var unusedLeft = $thumbslide[0].offsetLeft; var stcPointer = 7; jQuery(this).click(noop); $thumbslide.click(function(e) { move(this); $thumbslide.removeClass("tscurrentpointer"); jQuery(this).addClass("tscurrentpointer"); curr = jQuery(this); return o.click.apply(this, [e, this]); }); setCurr(curr); function setCurr(el) { var halfwidth = el.offsetWidth/2; halfwidth = parseInt(halfwidth); var bgPos = el.offsetLeft + halfwidth - unusedLeft - stcPointer; $pointer.css({ 'background-position': bgPos+"px 0px"}); curr = el; }; function move(el) { var halfwidth = el.offsetWidth/2; halfwidth = parseInt(halfwidth); var bgPos = el.offsetLeft + halfwidth - unusedLeft - stcPointer; var bgposobj = {'background-position-x' : bgPos+'px'}; if(jQuery.browser.mozilla){ bgposobj = {'background-position' : bgPos+'px 0px'}; } $pointer.each(function() { jQuery(this).dequeue(); } ).animate(bgposobj, o.speed, o.fx); }; }); }; })(jQuery);