/** This is a JavaScript library that will allow you to easily add some basic DHTML drop-down datepicker functionality to your Notes forms. This script is not as full-featured as others you may find on the Internet, but it's free, it's easy to understand, and it's easy to change. You'll also want to include a stylesheet that makes the datepicker elements look nice. An example one can be found in the database that this script was originally released with, at: http://www.nsftools.com/tips/NotesTips.htm#datepicker I've tested this lightly with Internet Explorer 6 and Mozilla Firefox. I have no idea how compatible it is with other browsers. version 1.5 December 4, 2005 Julian Robichaux -- http://www.nsftools.com HISTORY -- version 1.0 (Sept. 4, 2004): Initial release. -- version 1.1 (Sept. 5, 2004): Added capability to define the date format to be used, either globally (using the defaultDateSeparator and defaultDateFormat variables) or when the displayDatePicker function is called. -- version 1.2 (Sept. 7, 2004): Fixed problem where datepicker x-y coordinates weren't right inside of a table. Fixed problem where datepicker wouldn't display over selection lists on a page. Added a call to the datePickerClosed function (if one exists) after the datepicker is closed, to allow the developer to add their own custom validation after a date has been chosen. For this to work, you must have a function called datePickerClosed somewhere on the page, that accepts a field object as a parameter. See the example in the comments of the updateDateField function for more details. -- version 1.3 (Sept. 9, 2004) Fixed problem where adding the
and ';}else{if(ie6){$('select').css('visibility','hidden');}msgbox+='
';}msgbox+='
X
';msgbox+='
';$.prompt.jqib=$(msgbox).appendTo($body);$.prompt.jqi=$.prompt.jqib.children('#'+$.prompt.options.prefix);$.prompt.jqif=$.prompt.jqib.children('#'+$.prompt.options.prefix+'fade');if(message.constructor==String){message={state0:{html:message,buttons:$.prompt.options.buttons,focus:$.prompt.options.focus,submit:$.prompt.options.submit}};}var states="";$.each(message,function(statename,stateobj){stateobj=$.extend({},$.prompt.defaults.state,stateobj);message[statename]=stateobj;var arrow="";if(stateobj.position.arrow!==null)arrow='
';states+='';});$.prompt.states=message;$.prompt.jqi.find('#'+$.prompt.options.prefix+'states').html(states).children('.'+$.prompt.options.prefix+'_state:first').css('display','block');$.prompt.jqi.find('.'+$.prompt.options.prefix+'buttons:empty').css('display','none');$.each(message,function(statename,stateobj){var $state=$.prompt.jqi.find('#'+$.prompt.options.prefix+'_state_'+statename);if($.prompt.currentStateName==="")$.prompt.currentStateName=statename;$state.children('.'+$.prompt.options.prefix+'buttons').children('button').click(function(){var msg=$state.children('.'+$.prompt.options.prefix+'message');var clicked=stateobj.buttons[$(this).text()];if(clicked==undefined){for(var i in stateobj.buttons)if(stateobj.buttons[i].title==$(this).text())clicked=stateobj.buttons[i].value;}if(typeof clicked=='object')clicked=clicked.value;var forminputs={};$.each($.prompt.jqi.find('#'+$.prompt.options.prefix+'states :input').serializeArray(),function(i,obj){if(forminputs[obj.name]===undefined){forminputs[obj.name]=obj.value;}else if(typeof forminputs[obj.name]==Array||typeof forminputs[obj.name]=='object'){forminputs[obj.name].push(obj.value);}else{forminputs[obj.name]=[forminputs[obj.name],obj.value];}});var close=stateobj.submit(clicked,msg,forminputs);if(close===undefined||close){removePrompt(true,clicked,msg,forminputs);}});$state.find('.'+$.prompt.options.prefix+'buttons button:eq('+stateobj.focus+')').addClass($.prompt.options.prefix+'defaultbutton');});var fadeClicked=function(){if($.prompt.options.persistent){var offset=($.prompt.options.top.toString().indexOf('%')>=0?($window.height()*(parseInt($.prompt.options.top,10)/100)):parseInt($.prompt.options.top,10)),top=parseInt($.prompt.jqi.css('top').replace('px',''),10)-offset;$('html,body').animate({scrollTop:top},'fast',function(){var i=0;$.prompt.jqib.addClass($.prompt.options.prefix+'warning');var intervalid=setInterval(function(){$.prompt.jqib.toggleClass($.prompt.options.prefix+'warning');if(i++>1){clearInterval(intervalid);$.prompt.jqib.removeClass($.prompt.options.prefix+'warning');}},100);});}else{removePrompt();}};var keyPressEventHandler=function(e){var key=(window.event)?event.keyCode:e.keyCode;if(key==27){fadeClicked();}if(key==9){var $inputels=$(':input:enabled:visible',$.prompt.jqib);var fwd=!e.shiftKey&&e.target==$inputels[$inputels.length-1];var back=e.shiftKey&&e.target==$inputels[0];if(fwd||back){setTimeout(function(){if(!$inputels)return;var el=$inputels[back===true?$inputels.length-1:0];if(el)el.focus();},10);return false;}}};var removePrompt=function(callCallback,clicked,msg,formvals){$.prompt.jqi.remove();$window.unbind('resize',$.prompt.position);$.prompt.jqif.fadeOut($.prompt.options.overlayspeed,function(){$.prompt.jqif.unbind('click',fadeClicked);$.prompt.jqif.remove();if(callCallback){$.prompt.options.callback(clicked,msg,formvals);}$.prompt.jqib.unbind('keypress',keyPressEventHandler);$.prompt.jqib.remove();if(ie6&&!$.prompt.options.useiframe){$('select').css('visibility','visible');}});};$.prompt.position();$.prompt.style();$.prompt.jqif.click(fadeClicked);$window.resize($.prompt.position);$.prompt.jqib.bind("keydown keypress",keyPressEventHandler);$.prompt.jqi.find('.'+$.prompt.options.prefix+'close').click(removePrompt);$.prompt.jqif.fadeIn($.prompt.options.overlayspeed);$.prompt.jqi[$.prompt.options.show]($.prompt.options.promptspeed,$.prompt.options.loaded);$.prompt.jqi.find('#'+$.prompt.options.prefix+'states .'+$.prompt.options.prefix+'_state:first .'+$.prompt.options.prefix+'defaultbutton').focus();if($.prompt.options.timeout>0)setTimeout($.prompt.close,$.prompt.options.timeout);return $.prompt.jqib;};$.prompt.defaults={prefix:'jqi',classes:'',buttons:{Ok:true},loaded:function(){},submit:function(){return true;},callback:function(){},opacity:0.6,zIndex:999,overlayspeed:'slow',promptspeed:'fast',show:'fadeIn',focus:0,useiframe:false,top:'15%',persistent:true,timeout:0,state:{html:'',buttons:{Ok:true},focus:0,position:{container:null,x:null,y:null,arrow:null},submit:function(){return true;}}};$.prompt.currentPrefix=$.prompt.defaults.prefix;$.prompt.currentStateName="";$.prompt.setDefaults=function(o){$.prompt.defaults=$.extend({},$.prompt.defaults,o);};$.prompt.setStateDefaults=function(o){$.prompt.defaults.state=$.extend({},$.prompt.defaults.state,o);};$.prompt.position=function(){var $window=$(window),bodyHeight=$(document.body).outerHeight(true),windowHeight=$(window).height(),documentHeight=$(document).height(),height=bodyHeight>windowHeight?bodyHeight:windowHeight,top=parseInt($window.scrollTop(),10)+($.prompt.options.top.toString().indexOf('%')>=0?(windowHeight*(parseInt($.prompt.options.top,10)/100)):parseInt($.prompt.options.top,10));height=height>documentHeight?height:documentHeight;$.prompt.jqib.css({position:"absolute",height:height,width:"100%",top:0,left:0,right:0,bottom:0});$.prompt.jqif.css({position:"absolute",height:height,width:"100%",top:0,left:0,right:0,bottom:0});if($.prompt.states[$.prompt.currentStateName].position.container!==null){var pos=$.prompt.states[$.prompt.currentStateName].position,offset=$(pos.container).offset();$.prompt.jqi.css({position:"absolute"});$.prompt.jqi.animate({top:offset.top+pos.y,left:offset.left+pos.x,marginLeft:0,width:(pos.width!==undefined)?pos.width:null});top=(offset.top+pos.y)-($.prompt.options.top.toString().indexOf('%')>=0?(windowHeight*(parseInt($.prompt.options.top,10)/100)):parseInt($.prompt.options.top,10));$('html,body').animate({scrollTop:top},'slow','swing',function(){});}else{$.prompt.jqi.css({position:"absolute",top:top,left:$window.width()/2,marginLeft:(($.prompt.jqi.outerWidth()/2)*-1)});}};$.prompt.style=function(){$.prompt.jqif.css({zIndex:$.prompt.options.zIndex,display:"none",opacity:$.prompt.options.opacity});$.prompt.jqi.css({zIndex:$.prompt.options.zIndex+1,display:"none"});$.prompt.jqib.css({zIndex:$.prompt.options.zIndex});};$.prompt.getStateContent=function(state){return $('#'+$.prompt.currentPrefix+'_state_'+state);};$.prompt.getCurrentState=function(){return $('.'+$.prompt.currentPrefix+'_state:visible');};$.prompt.getCurrentStateName=function(){var stateid=$.prompt.getCurrentState().attr('id');return stateid.replace($.prompt.currentPrefix+'_state_','');};$.prompt.goToState=function(state,callback){$.prompt.currentStateName=state;$('.'+$.prompt.currentPrefix+'_state').slideUp('slow').find('.'+$.prompt.currentPrefix+'arrow').fadeToggle();$('#'+$.prompt.currentPrefix+'_state_'+state).slideDown('slow',function(){$(this).find('.'+$.prompt.currentPrefix+'defaultbutton').focus().find('.'+$.prompt.currentPrefix+'arrow').fadeToggle('slow');if(typeof callback=='function')callback();});$.prompt.position();};$.prompt.nextState=function(callback){var $next=$('#'+$.prompt.currentPrefix+'_state_'+$.prompt.currentStateName).next();$.prompt.goToState($next.attr('id').replace($.prompt.currentPrefix+'_state_',''));};$.prompt.prevState=function(callback){var $prev=$('#'+$.prompt.currentPrefix+'_state_'+$.prompt.currentStateName).prev();$.prompt.goToState($prev.attr('id').replace($.prompt.currentPrefix+'_state_',''));};$.prompt.close=function(){$('#'+$.prompt.currentPrefix+'box').fadeOut('fast',function(){$(this).remove();});};$.fn.extend({prompt:function(options){if(options==undefined)options={};if(options.withDataAndEvents==undefined)options.withDataAndEvents=false;$.prompt($(this).clone(options.withDataAndEvents).html(),options);},promptDropIn:function(speed,callback){var $t=$(this);if($t.css("display")=="none"){var eltop=$t.css('top');$t.css({top:$(window).scrollTop(),display:'block'}).animate({top:eltop},speed,'swing',callback);}}});})(jQuery); $(function(){$("ul.dropdown li").hover(function(){$(this).addClass("hover");$('ul:first',this).css('visibility', 'visible');}, function(){$(this).removeClass("hover");$('ul:first',this).css('visibility', 'hidden');});$("ul.dropdown li ul li:has(ul)").find("a:first").append(" » ");}); $(function(){var config = { sensitivity: 3, // number = sensitivity threshold (must be 1 or higher) interval: 200, // number = milliseconds for onMouseOver polling interval over: doOpen, // function = onMouseOver callback (REQUIRED) timeout: 200, // number = milliseconds delay before onMouseOut out: doClose // function = onMouseOut callback (REQUIRED) };function doOpen() {$(this).addClass("hover");$('ul:first',this).css('visibility', 'visible');}function doClose() {$(this).removeClass("hover");$('ul:first',this).css('visibility', 'hidden');}$("ul.dropdown li").hoverIntent(config);$("ul.dropdown li ul li:has(ul)").find("a:first").append(" » ");}); /* ------------------------------------------------------------------------ Class: prettyGallery Use: Gallery plugin for jQuery Author: Stephane Caron (http://www.no-margin-for-errors.com) Version: 1.1.1 ------------------------------------------------------------------------- */ jQuery.fn.prettyGallery = function(settings) { settings = jQuery.extend({ itemsPerPage : 2, animationSpeed : 'normal', /* fast/normal/slow */ navigation : 'top', /* top/bottom/both */ of_label: ' of ', /* The content in the page "1 of 2" */ previous_title_label: 'Previous page', /* The title of the previous link */ next_title_label: 'Next page', /* The title of the next link */ previous_label: 'Previous', /* The content of the previous link */ next_label: 'Next' /* The content of the next link */ }, settings); return this.each(function(){ // Global variables needed in multiple functions. var currentPage = 1, itemWidth = 0, itemMargin = 0, itemHeight = 0, galleryWidth = 0, pageCount = 0, animated = false, $gallery = $(this); var prettyGalleryPrevious = function(caller) { // Make sure not to double animate, and not animate of the button is disabled if(animated || $(caller).hasClass('disabled')) return; animated = true; $gallery.find('li:lt('+(currentPage * settings.itemsPerPage)+')').each(function(i){ $(this).animate({'left': parseFloat($(this).css('left')) + (galleryWidth + itemMargin) }, settings.animationSpeed, function(){ animated = false; }); }); $gallery.find('li:gt('+ ((currentPage * settings.itemsPerPage) - 1) +')').each(function(i){ $(this).animate({'left': parseFloat($(this).css('left')) + (galleryWidth + itemMargin) }, settings.animationSpeed); }); currentPage--; _displayPaging(); }; var prettyGalleryNext = function(caller) { // Make sure not to double animate, and not animate of the button is disabled if(animated || $(caller).hasClass('disabled')) return; animated = true; $gallery.find('li:lt('+(currentPage * settings.itemsPerPage)+')').each(function(i){ $(this).animate({'left': parseFloat($(this).css('left')) - (galleryWidth + itemMargin) }, settings.animationSpeed, function(){ animated = false; }); }); $gallery.find('li:gt('+ ((currentPage * settings.itemsPerPage) - 1) +')').each(function(i){ $(this).animate({'left': parseFloat($(this).css('left')) - (galleryWidth + itemMargin) }, settings.animationSpeed); }); currentPage++; _displayPaging(); }; var _formatGallery = function() { itemWidth = $gallery.find('li:first').css('position','absolute').width(); itemMargin += ($gallery.find('li:first').css('margin-right') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('margin-right')); itemMargin += ($gallery.find('li:first').css('margin-left') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('margin-left')); itemMargin += ($gallery.find('li:first').css('padding-right') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('padding-right')); itemMargin += ($gallery.find('li:first').css('padding-left') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('padding-left')); var itemSpacingTopBottom = 0; itemSpacingTopBottom += ($gallery.find('li:first').css('margin-top') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('margin-top')); itemSpacingTopBottom += ($gallery.find('li:first').css('margin-bottom') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('margin-bottom')); itemSpacingTopBottom += ($gallery.find('li:first').css('padding-top') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('padding-top')); itemSpacingTopBottom += ($gallery.find('li:first').css('padding-bottom') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('padding-bottom')); var itemHeight = $gallery.find('li:first').height() + itemSpacingTopBottom; var marginRight = ($gallery.find('li:first').css('margin-right') == 'auto') ? 0 : parseFloat($gallery.find('li:first').css('margin-right')); galleryWidth = (itemWidth + itemMargin) * settings.itemsPerPage - marginRight; // We don't want the margin of the last item, that's why we remove it. $gallery.css({ 'width': galleryWidth, 'height': itemHeight, 'overflow': 'hidden', 'position': 'relative', 'clear': 'left' }); $gallery.find('li').each(function(i){ $(this).css({ 'position':'absolute', 'top':0, 'left':i * (itemWidth + itemMargin) }); }); $gallery.wrap('
'); }; var _displayPaging = function() { $cg = $gallery.parents('div.prettyGalleryContainer:first'); // The containing gallery $cg.find('ul.pg_paging span.current').text(currentPage); $cg.find('ul.pg_paging span.total').text(pageCount); // Make sur all the links are enabled $cg.find('ul.pg_paging li a').removeClass('disabled'); // Display the proper nav if(currentPage == 1){ // Hide the previous button $cg.find('ul.pg_paging li.pg_previous a').addClass('disabled'); } else if(currentPage == pageCount) { // Hide the next button $cg.find('ul.pg_paging li.pg_next a').addClass('disabled'); }; }; var _applyNav = function() { var template = ''; template +=''; switch(settings.navigation){ case 'top': $gallery.before(template); break; case 'bottom': $gallery.after(template); break; case 'both': $gallery.before(template); $gallery.after(template); break; }; // Adjust the nav to the gallery width var $theNav = $gallery.parent('div.prettyGalleryContainer:first').find('ul.pg_paging'); galleryBorderWidth = parseFloat($theNav.css('border-left-width')) + parseFloat($theNav.css('border-right-width')); $theNav.width(galleryWidth - galleryBorderWidth); $theNav.each(function(){ $(this).find('li:eq(1)').width(galleryWidth - galleryBorderWidth - parseFloat($(this).parent().find('ul.prettyNavigation li:first').width()) - parseFloat($(this).parent().find('ul.prettyNavigation li:last').width())); }); // Apply the functions to the buttons $theNav.find('li.pg_previous a').click(function(){ prettyGalleryPrevious(this); return false; }); $theNav.find('li.pg_next a').click(function(){ prettyGalleryNext(this); return false; }); }; // Check if we need the gallery if($(this).find('li').size() > settings.itemsPerPage) { // Set the number of pages pageCount = Math.ceil($(this).find('li').size() / settings.itemsPerPage); // Format the gallery properly _formatGallery(); // Build and display the nav _applyNav(); // Display the proper paging _displayPaging(this); currentPage = 1; }; }); }; /* Suite of routines supporting AJAX calls from web pages By: gary conley Date: 08/13/2007 */ function createXMLHTTP() { if (typeof XMLHttpRequest != "undefined") return new XMLHttpRequest(); else if (typeof window.ActiveXObject != "undefined") return new ActiveXObject("Msxml2.XMLHttp"); else throw ("createXMLHTTP method failed - browser does not support this method"); } /* Use this call when you want to process a GET operation. Parameters should be passed in the URL (eg: ?java=ABC&mynextparam=nextparam&) */ function httpRequestGet(url) { var httpObj = createXMLHTTP(); httpObj.open("GET", url, false); httpObj.setRequestHeader("Content-Type", "text/xml"); httpObj.send(null); if (httpObj.status == 200) { return httpObj.responseText; } else { throw httpObj.responseText; } } /* Use this call when you want to process a POST operation. Parameters should be passed in the DATA variable. It gets passed seperatly. The values in the DATA variable should be name/value pairs seperated by an ampersand (&). eg: java=ABC&mynextparam=nextparam */ function httpRequestPost(url, data) { var httpObj = createXMLHTTP(); httpObj.open("POST", url, false); httpObj.setRequestHeader("Content-Type", "text/xml"); httpObj.send(data); if (httpObj.status == 200) { return httpObj.responseText; } else { throw httpObj.responseText; } } /* Use this method when you want to pass the data associated with an HTML form. This method operates like the the httpRequestPost method above with the added convenience that it will automatically parse the data entered into a form into name/value pairs and pass it in the DATA variable. */ function httpRequestFormPOST (url, form) { var data = getFormFieldsAsNameValue(form); var httpObj = createXMLHTTP(); httpObj.open("POST", url, false); httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); httpObj.send(data); if (httpObj.status == 200) { return httpObj.responseText; } else { throw httpObj.responseText; } } /* Use this method to convert form data to name/value pairs. */ function getFormFieldsAsNameValue(form) { var formElements = form.elements; var data = ""; for (i=0; i < form.elements.length; i ++) { if (formElements[i].tagName == "INPUT" && formElements[i].name != "__VIEWSTATE") { if (formElements[i].type== "hidden") data += formElements[i].name + "=" + escape(formElements[i].value) + "&"; else if (formElements[i].type == "text") data += formElements[i].name + "=" + escape(formElements[i].value) + "&"; else if ((formElements[i].type == "radio" || formElements[i].type == "checkbox") && formElements[i].checked) data += formElements[i].name + "=" + formElements[i].value + "&"; } else if (formElements[i].tagName == "SELECT" && formElements[i].options.length != 0) data += formElements[i].name + "=" + formElements[i].options[formElements[i].selectedIndex].value + "&"; else if (formElements[i].tagName == "TEXTAREA") data += formElements[i].name + "=" + escape(formElements[i].value) + "&"; } data = data.substring(0, data.length-1); return data; } /** * hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+ * * * @param f onMouseOver function || An object with configuration options * @param g onMouseOut function || Nothing (use configuration options object) * @author Brian Cherne brian(at)cherne(dot)net */ (function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY)) 1 || e.shiftKey || e.altKey || e.metaKey)) { e.preventDefault(); launch(this); } }); } return true; } return false; } // Don't do anything if ColorBox already exists. if ($.colorbox) { return; } // Append the HTML when the DOM loads $(appendHTML); // **************** // PUBLIC FUNCTIONS // Usage format: $.fn.colorbox.close(); // Usage from within an iframe: parent.$.fn.colorbox.close(); // **************** publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) { var $this = this; options = options || {}; appendHTML(); if (addBindings()) { if (!$this[0]) { if ($this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit. return $this; } // if no selector was given (ie. $.colorbox()), create a temporary element to work with $this = $(''); options.open = true; // assume an immediate open } if (callback) { options.onComplete = callback; } $this.each(function () { $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options)); }).addClass(boxElement); if (($.isFunction(options.open) && options.open.call($this)) || options.open) { launch($this[0]); } } return $this; }; publicMethod.position = function (speed, loadedCallback) { var top = 0, left = 0, offset = $box.offset(), scrollTop = $window.scrollTop(), scrollLeft = $window.scrollLeft(); $window.unbind('resize.' + prefix); // remove the modal so that it doesn't influence the document width/height $box.css({top: -9e4, left: -9e4}); if (settings.fixed && !isIE6) { offset.top -= scrollTop; offset.left -= scrollLeft; $box.css({position: 'fixed'}); } else { top = scrollTop; left = scrollLeft; $box.css({position: 'absolute'}); } // keeps the top and left positions within the browser's viewport. if (settings.right !== false) { left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0); } else if (settings.left !== false) { left += setSize(settings.left, 'x'); } else { left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2); } if (settings.bottom !== false) { top += Math.max($window.height() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0); } else if (settings.top !== false) { top += setSize(settings.top, 'y'); } else { top += Math.round(Math.max($window.height() - settings.h - loadedHeight - interfaceHeight, 0) / 2); } $box.css({top: offset.top, left: offset.left}); // setting the speed to 0 to reduce the delay between same-sized content. speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0; // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly, // but it has to be shrank down around the size of div#colorbox when it's done. If not, // it can invoke an obscure IE bug when using iframes. $wrap[0].style.width = $wrap[0].style.height = "9999px"; function modalDimensions(that) { $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width; $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height; } $box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left}, { duration: speed, complete: function () { modalDimensions(this); active = false; // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation. $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px"; $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px"; if (settings.reposition) { setTimeout(function () { // small delay before binding onresize due to an IE8 bug. $window.bind('resize.' + prefix, publicMethod.position); }, 1); } if (loadedCallback) { loadedCallback(); } }, step: function () { modalDimensions(this); } }); }; publicMethod.resize = function (options) { if (open) { options = options || {}; if (options.width) { settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth; } if (options.innerWidth) { settings.w = setSize(options.innerWidth, 'x'); } $loaded.css({width: settings.w}); if (options.height) { settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight; } if (options.innerHeight) { settings.h = setSize(options.innerHeight, 'y'); } if (!options.innerHeight && !options.height) { $loaded.css({height: "auto"}); settings.h = $loaded.height(); } $loaded.css({height: settings.h}); publicMethod.position(settings.transition === "none" ? 0 : settings.speed); } }; publicMethod.prep = function (object) { if (!open) { return; } var callback, speed = settings.transition === "none" ? 0 : settings.speed; $loaded.remove(); $loaded = $tag(div, 'LoadedContent').append(object); function getWidth() { settings.w = settings.w || $loaded.width(); settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w; return settings.w; } function getHeight() { settings.h = settings.h || $loaded.height(); settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h; return settings.h; } $loaded.hide() .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations. .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'}) .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height. .prependTo($content); $loadingBay.hide(); // floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width. //$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'}); $(photo).css({'float': 'none'}); // Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay. if (isIE6) { $('select').not($box.find('select')).filter(function () { return this.style.visibility !== 'hidden'; }).css({'visibility': 'hidden'}).one(event_cleanup, function () { this.style.visibility = 'inherit'; }); } callback = function () { var preload, i, total = $related.length, iframe, frameBorder = 'frameBorder', allowTransparency = 'allowTransparency', complete, src, img; if (!open) { return; } function removeFilter() { if (isIE) { $box[0].style.removeAttribute('filter'); } } complete = function () { clearTimeout(loadingTimer); $loadingOverlay.hide(); trigger(event_complete, settings.onComplete); }; if (isIE) { //This fadeIn helps the bicubic resampling to kick-in. if (photo) { $loaded.fadeIn(100); } } $title.html(settings.title).add($loaded).show(); if (total > 1) { // handle grouping if (typeof settings.current === "string") { $current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show(); } $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next); $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous); if (settings.slideshow) { $slideshow.show(); } // Preloads images within a rel group if (settings.preloading) { preload = [ getIndex(-1), getIndex(1) ]; while (i = $related[preload.pop()]) { src = $.data(i, colorbox).href || i.href; if ($.isFunction(src)) { src = src.call(i); } if (isImage(src)) { img = new Image(); img.src = src; } } } } else { $groupControls.hide(); } if (settings.iframe) { iframe = $tag('iframe')[0]; if (frameBorder in iframe) { iframe[frameBorder] = 0; } if (allowTransparency in iframe) { iframe[allowTransparency] = "true"; } // give the iframe a unique name to prevent caching iframe.name = prefix + (+new Date()); if (settings.fastIframe) { complete(); } else { $(iframe).one('load', complete); } iframe.src = settings.href; if (!settings.scrolling) { iframe.scrolling = "no"; } $(iframe).addClass(prefix + 'Iframe').appendTo($loaded).one(event_purge, function () { iframe.src = "//about:blank"; }); } else { complete(); } if (settings.transition === 'fade') { $box.fadeTo(speed, 1, removeFilter); } else { removeFilter(); } }; if (settings.transition === 'fade') { $box.fadeTo(speed, 0, function () { publicMethod.position(0, callback); }); } else { publicMethod.position(speed, callback); } }; publicMethod.load = function (launched) { var href, setResize, prep = publicMethod.prep; active = true; photo = false; element = $related[index]; if (!launched) { makeSettings(); } trigger(event_purge); trigger(event_load, settings.onLoad); settings.h = settings.height ? setSize(settings.height, 'y') - loadedHeight - interfaceHeight : settings.innerHeight && setSize(settings.innerHeight, 'y'); settings.w = settings.width ? setSize(settings.width, 'x') - loadedWidth - interfaceWidth : settings.innerWidth && setSize(settings.innerWidth, 'x'); // Sets the minimum dimensions for use in image scaling settings.mw = settings.w; settings.mh = settings.h; // Re-evaluate the minimum width and height based on maxWidth and maxHeight values. // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead. if (settings.maxWidth) { settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth; settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw; } if (settings.maxHeight) { settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight; settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh; } href = settings.href; loadingTimer = setTimeout(function () { $loadingOverlay.show(); }, 100); if (settings.inline) { // Inserts an empty placeholder where inline content is being pulled from. // An event is bound to put inline content back when ColorBox closes or loads new content. $tag(div).hide().insertBefore($(href)[0]).one(event_purge, function () { $(this).replaceWith($loaded.children()); }); prep($(href)); } else if (settings.iframe) { // IFrame element won't be added to the DOM until it is ready to be displayed, // to avoid problems with DOM-ready JS that might be trying to run in that iframe. prep(" "); } else if (settings.html) { prep(settings.html); } else if (isImage(href)) { $(photo = new Image()) .addClass(prefix + 'Photo') .error(function () { settings.title = false; prep($tag(div, 'Error').text('This image could not be loaded')); }) .load(function () { var percent; photo.onload = null; //stops animated gifs from firing the onload repeatedly. if (settings.scalePhotos) { setResize = function () { photo.height -= photo.height * percent; photo.width -= photo.width * percent; }; if (settings.mw && photo.width > settings.mw) { percent = (photo.width - settings.mw) / photo.width; setResize(); } if (settings.mh && photo.height > settings.mh) { percent = (photo.height - settings.mh) / photo.height; setResize(); } } if (settings.h) { photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px'; } if ($related[1] && (settings.loop || $related[index + 1])) { photo.style.cursor = 'pointer'; photo.onclick = function () { publicMethod.next(); }; } if (isIE) { photo.style.msInterpolationMode = 'bicubic'; } setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise. prep(photo); }, 1); }); setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise. photo.src = href; }, 1); } else if (href) { $loadingBay.load(href, settings.data, function (data, status, xhr) { prep(status === 'error' ? $tag(div, 'Error').text('Request unsuccessful: ' + xhr.statusText) : $(this).contents()); }); } }; // Navigates to the next page/image in a set. publicMethod.next = function () { if (!active && $related[1] && (settings.loop || $related[index + 1])) { index = getIndex(1); publicMethod.load(); } }; publicMethod.prev = function () { if (!active && $related[1] && (settings.loop || index)) { index = getIndex(-1); publicMethod.load(); } }; // Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close(); publicMethod.close = function () { if (open && !closing) { closing = true; open = false; trigger(event_cleanup, settings.onCleanup); $window.unbind('.' + prefix + ' .' + event_ie6); $overlay.fadeTo(200, 0); $box.stop().fadeTo(300, 0, function () { $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide(); trigger(event_purge); $loaded.remove(); setTimeout(function () { closing = false; trigger(event_closed, settings.onClosed); }, 1); }); } }; // Removes changes ColorBox made to the document, but does not remove the plugin // from jQuery. publicMethod.remove = function () { $([]).add($box).add($overlay).remove(); $box = null; $('.' + boxElement) .removeData(colorbox) .removeClass(boxElement) .die(); }; // A method for fetching the current element ColorBox is referencing. // returns a jQuery object. publicMethod.element = function () { return $(element); }; publicMethod.settings = defaults; }(jQuery, document, this)); /*! * jCarousel - Riding carousels with jQuery * http://sorgalla.com/jcarousel/ * * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * Built on top of the jQuery library * http://jquery.com * * Inspired by the "Carousel Component" by Bill Scott * http://billwscott.com/carousel/ */ /*global window, jQuery */ (function($) { // Default configuration properties. var defaults = { vertical: false, rtl: false, start: 1, offset: 1, size: null, scroll: 3, visible: null, animation: 'normal', easing: 'swing', auto: 0, wrap: null, initCallback: null, setupCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, animationStepCallback: null, buttonNextHTML: '
', buttonPrevHTML: '
', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null, itemFallbackDimension: null }, windowLoaded = false; $(window).bind('load.jcarousel', function() { windowLoaded = true; }); /** * The jCarousel object. * * @constructor * @class jcarousel * @param e {HTMLElement} The element to create the carousel for. * @param o {Object} A set of key/value pairs to set as configuration properties. * @cat Plugins/jCarousel */ $.jcarousel = function(e, o) { this.options = $.extend({}, defaults, o || {}); this.locked = false; this.autoStopped = false; this.container = null; this.clip = null; this.list = null; this.buttonNext = null; this.buttonPrev = null; this.buttonNextState = null; this.buttonPrevState = null; // Only set if not explicitly passed as option if (!o || o.rtl === undefined) { this.options.rtl = ($(e).attr('dir') || $('html').attr('dir') || '').toLowerCase() == 'rtl'; } this.wh = !this.options.vertical ? 'width' : 'height'; this.lt = !this.options.vertical ? (this.options.rtl ? 'right' : 'left') : 'top'; // Extract skin class var skin = '', split = e.className.split(' '); for (var i = 0; i < split.length; i++) { if (split[i].indexOf('jcarousel-skin') != -1) { $(e).removeClass(split[i]); skin = split[i]; break; } } if (e.nodeName.toUpperCase() == 'UL' || e.nodeName.toUpperCase() == 'OL') { this.list = $(e); this.clip = this.list.parents('.jcarousel-clip'); this.container = this.list.parents('.jcarousel-container'); } else { this.container = $(e); this.list = this.container.find('ul,ol').eq(0); this.clip = this.container.find('.jcarousel-clip'); } if (this.clip.size() === 0) { this.clip = this.list.wrap('
').parent(); } if (this.container.size() === 0) { this.container = this.clip.wrap('
').parent(); } if (skin !== '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1) { this.container.wrap('
'); } this.buttonPrev = $('.jcarousel-prev', this.container); if (this.buttonPrev.size() === 0 && this.options.buttonPrevHTML !== null) { this.buttonPrev = $(this.options.buttonPrevHTML).appendTo(this.container); } this.buttonPrev.addClass(this.className('jcarousel-prev')); this.buttonNext = $('.jcarousel-next', this.container); if (this.buttonNext.size() === 0 && this.options.buttonNextHTML !== null) { this.buttonNext = $(this.options.buttonNextHTML).appendTo(this.container); } this.buttonNext.addClass(this.className('jcarousel-next')); this.clip.addClass(this.className('jcarousel-clip')).css({ position: 'relative' }); this.list.addClass(this.className('jcarousel-list')).css({ overflow: 'hidden', position: 'relative', top: 0, margin: 0, padding: 0 }).css((this.options.rtl ? 'right' : 'left'), 0); this.container.addClass(this.className('jcarousel-container')).css({ position: 'relative' }); if (!this.options.vertical && this.options.rtl) { this.container.addClass('jcarousel-direction-rtl').attr('dir', 'rtl'); } var di = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null; var li = this.list.children('li'); var self = this; if (li.size() > 0) { var wh = 0, j = this.options.offset; li.each(function() { self.format(this, j++); wh += self.dimension(this, di); }); this.list.css(this.wh, (wh + 100) + 'px'); // Only set if not explicitly passed as option if (!o || o.size === undefined) { this.options.size = li.size(); } } // For whatever reason, .show() does not work in Safari... this.container.css('display', 'block'); this.buttonNext.css('display', 'block'); this.buttonPrev.css('display', 'block'); this.funcNext = function() { self.next(); }; this.funcPrev = function() { self.prev(); }; this.funcResize = function() { if (self.resizeTimer) { clearTimeout(self.resizeTimer); } self.resizeTimer = setTimeout(function() { self.reload(); }, 100); }; if (this.options.initCallback !== null) { this.options.initCallback(this, 'init'); } // if (!windowLoaded && $.browser.safari) { // this.buttons(false, false); // $(window).bind('load.jcarousel', function() { self.setup(); }); // } else { this.setup(); // } }; // Create shortcut for internal use var $jc = $.jcarousel; $jc.fn = $jc.prototype = { jcarousel: '0.2.8' }; $jc.fn.extend = $jc.extend = $.extend; $jc.fn.extend({ /** * Setups the carousel. * * @method setup * @return undefined */ setup: function() { this.first = null; this.last = null; this.prevFirst = null; this.prevLast = null; this.animating = false; this.timer = null; this.resizeTimer = null; this.tail = null; this.inTail = false; if (this.locked) { return; } this.list.css(this.lt, this.pos(this.options.offset) + 'px'); var p = this.pos(this.options.start, true); this.prevFirst = this.prevLast = null; this.animate(p, false); $(window).unbind('resize.jcarousel', this.funcResize).bind('resize.jcarousel', this.funcResize); if (this.options.setupCallback !== null) { this.options.setupCallback(this); } }, /** * Clears the list and resets the carousel. * * @method reset * @return undefined */ reset: function() { this.list.empty(); this.list.css(this.lt, '0px'); this.list.css(this.wh, '10px'); if (this.options.initCallback !== null) { this.options.initCallback(this, 'reset'); } this.setup(); }, /** * Reloads the carousel and adjusts positions. * * @method reload * @return undefined */ reload: function() { if (this.tail !== null && this.inTail) { this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail); } this.tail = null; this.inTail = false; if (this.options.reloadCallback !== null) { this.options.reloadCallback(this); } if (this.options.visible !== null) { var self = this; var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0; this.list.children('li').each(function(i) { wh += self.dimension(this, di); if (i + 1 < self.first) { lt = wh; } }); this.list.css(this.wh, wh + 'px'); this.list.css(this.lt, -lt + 'px'); } this.scroll(this.first, false); }, /** * Locks the carousel. * * @method lock * @return undefined */ lock: function() { this.locked = true; this.buttons(); }, /** * Unlocks the carousel. * * @method unlock * @return undefined */ unlock: function() { this.locked = false; this.buttons(); }, /** * Sets the size of the carousel. * * @method size * @return undefined * @param s {Number} The size of the carousel. */ size: function(s) { if (s !== undefined) { this.options.size = s; if (!this.locked) { this.buttons(); } } return this.options.size; }, /** * Checks whether a list element exists for the given index (or index range). * * @method get * @return bool * @param i {Number} The index of the (first) element. * @param i2 {Number} The index of the last element. */ has: function(i, i2) { if (i2 === undefined || !i2) { i2 = i; } if (this.options.size !== null && i2 > this.options.size) { i2 = this.options.size; } for (var j = i; j <= i2; j++) { var e = this.get(j); if (!e.length || e.hasClass('jcarousel-item-placeholder')) { return false; } } return true; }, /** * Returns a jQuery object with list element for the given index. * * @method get * @return jQuery * @param i {Number} The index of the element. */ get: function(i) { return $('>.jcarousel-item-' + i, this.list); }, /** * Adds an element for the given index to the list. * If the element already exists, it updates the inner html. * Returns the created element as jQuery object. * * @method add * @return jQuery * @param i {Number} The index of the element. * @param s {String} The innerHTML of the element. */ add: function(i, s) { var e = this.get(i), old = 0, n = $(s); if (e.length === 0) { var c, j = $jc.intval(i); e = this.create(i); while (true) { c = this.get(--j); if (j <= 0 || c.length) { if (j <= 0) { this.list.prepend(e); } else { c.after(e); } break; } } } else { old = this.dimension(e); } if (n.get(0).nodeName.toUpperCase() == 'LI') { e.replaceWith(n); e = n; } else { e.empty().append(s); } this.format(e.removeClass(this.className('jcarousel-item-placeholder')), i); var di = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null; var wh = this.dimension(e, di) - old; if (i > 0 && i < this.first) { this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px'); } this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px'); return e; }, /** * Removes an element for the given index from the list. * * @method remove * @return undefined * @param i {Number} The index of the element. */ remove: function(i) { var e = this.get(i); // Check if item exists and is not currently visible if (!e.length || (i >= this.first && i <= this.last)) { return; } var d = this.dimension(e); if (i < this.first) { this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px'); } e.remove(); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px'); }, /** * Moves the carousel forwards. * * @method next * @return undefined */ next: function() { if (this.tail !== null && !this.inTail) { this.scrollTail(false); } else { this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size !== null && this.last == this.options.size) ? 1 : this.first + this.options.scroll); } }, /** * Moves the carousel backwards. * * @method prev * @return undefined */ prev: function() { if (this.tail !== null && this.inTail) { this.scrollTail(true); } else { this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size !== null && this.first == 1) ? this.options.size : this.first - this.options.scroll); } }, /** * Scrolls the tail of the carousel. * * @method scrollTail * @return undefined * @param b {Boolean} Whether scroll the tail back or forward. */ scrollTail: function(b) { if (this.locked || this.animating || !this.tail) { return; } this.pauseAuto(); var pos = $jc.intval(this.list.css(this.lt)); pos = !b ? pos - this.tail : pos + this.tail; this.inTail = !b; // Save for callbacks this.prevFirst = this.first; this.prevLast = this.last; this.animate(pos); }, /** * Scrolls the carousel to a certain position. * * @method scroll * @return undefined * @param i {Number} The index of the element to scoll to. * @param a {Boolean} Flag indicating whether to perform animation. */ scroll: function(i, a) { if (this.locked || this.animating) { return; } this.pauseAuto(); this.animate(this.pos(i), a); }, /** * Prepares the carousel and return the position for a certian index. * * @method pos * @return {Number} * @param i {Number} The index of the element to scoll to. * @param fv {Boolean} Whether to force last item to be visible. */ pos: function(i, fv) { var pos = $jc.intval(this.list.css(this.lt)); if (this.locked || this.animating) { return pos; } if (this.options.wrap != 'circular') { i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i); } var back = this.first > i; // Create placeholders, new list width/height // and new list position var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first; var c = back ? this.get(f) : this.get(this.last); var j = back ? f : f - 1; var e = null, l = 0, p = false, d = 0, g; while (back ? --j >= i : ++j < i) { e = this.get(j); p = !e.length; if (e.length === 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c[back ? 'before' : 'after' ](e); if (this.first !== null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) { e = this.add(j, g.clone(true)); } } } c = e; d = this.dimension(e); if (p) { l += d; } if (this.first !== null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size === null || j <= this.options.size)))) { pos = back ? pos + d : pos - d; } } // Calculate visible items var clipping = this.clipping(), cache = [], visible = 0, v = 0; c = this.get(i - 1); j = i; while (++visible) { e = this.get(j); p = !e.length; if (e.length === 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); // This should only happen on a next scroll if (c.length === 0) { this.list.prepend(e); } else { c[back ? 'before' : 'after' ](e); } if (this.first !== null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) { e = this.add(j, g.clone(true)); } } } c = e; d = this.dimension(e); if (d === 0) { throw new Error('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...'); } if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size) { cache.push(e); } else if (p) { l += d; } v += d; if (v >= clipping) { break; } j++; } // Remove out-of-range placeholders for (var x = 0; x < cache.length; x++) { cache[x].remove(); } // Resize list if (l > 0) { this.list.css(this.wh, this.dimension(this.list) + l + 'px'); if (back) { pos -= l; this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px'); } } // Calculate first and last item var last = i + visible - 1; if (this.options.wrap != 'circular' && this.options.size && last > this.options.size) { last = this.options.size; } if (j > last) { visible = 0; j = last; v = 0; while (++visible) { e = this.get(j--); if (!e.length) { break; } v += this.dimension(e); if (v >= clipping) { break; } } } var first = last - visible + 1; if (this.options.wrap != 'circular' && first < 1) { first = 1; } if (this.inTail && back) { pos += this.tail; this.inTail = false; } this.tail = null; if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) { var m = $jc.intval(this.get(last).css(!this.options.vertical ? 'marginRight' : 'marginBottom')); if ((v - m) > clipping) { this.tail = v - clipping - m; } } if (fv && i === this.options.size && this.tail) { pos -= this.tail; this.inTail = true; } // Adjust position while (i-- > first) { pos += this.dimension(this.get(i)); } // Save visible item range this.prevFirst = this.first; this.prevLast = this.last; this.first = first; this.last = last; return pos; }, /** * Animates the carousel to a certain position. * * @method animate * @return undefined * @param p {Number} Position to scroll to. * @param a {Boolean} Flag indicating whether to perform animation. */ animate: function(p, a) { if (this.locked || this.animating) { return; } this.animating = true; var self = this; var scrolled = function() { self.animating = false; if (p === 0) { self.list.css(self.lt, 0); } if (!self.autoStopped && (self.options.wrap == 'circular' || self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size === null || self.last < self.options.size || (self.last == self.options.size && self.tail !== null && !self.inTail))) { self.startAuto(); } self.buttons(); self.notify('onAfterAnimation'); // This function removes items which are appended automatically for circulation. // This prevents the list from growing infinitely. if (self.options.wrap == 'circular' && self.options.size !== null) { for (var i = self.prevFirst; i <= self.prevLast; i++) { if (i !== null && !(i >= self.first && i <= self.last) && (i < 1 || i > self.options.size)) { self.remove(i); } } } }; this.notify('onBeforeAnimation'); // Animate if (!this.options.animation || a === false) { this.list.css(this.lt, p + 'px'); scrolled(); } else { var o = !this.options.vertical ? (this.options.rtl ? {'right': p} : {'left': p}) : {'top': p}; // Define animation settings. var settings = { duration: this.options.animation, easing: this.options.easing, complete: scrolled }; // If we have a step callback, specify it as well. if ($.isFunction(this.options.animationStepCallback)) { settings.step = this.options.animationStepCallback; } // Start the animation. this.list.animate(o, settings); } }, /** * Starts autoscrolling. * * @method auto * @return undefined * @param s {Number} Seconds to periodically autoscroll the content. */ startAuto: function(s) { if (s !== undefined) { this.options.auto = s; } if (this.options.auto === 0) { return this.stopAuto(); } if (this.timer !== null) { return; } this.autoStopped = false; var self = this; this.timer = window.setTimeout(function() { self.next(); }, this.options.auto * 1000); }, /** * Stops autoscrolling. * * @method stopAuto * @return undefined */ stopAuto: function() { this.pauseAuto(); this.autoStopped = true; }, /** * Pauses autoscrolling. * * @method pauseAuto * @return undefined */ pauseAuto: function() { if (this.timer === null) { return; } window.clearTimeout(this.timer); this.timer = null; }, /** * Sets the states of the prev/next buttons. * * @method buttons * @return undefined */ buttons: function(n, p) { if (n == null) { n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size === null || this.last < this.options.size); if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size !== null && this.last >= this.options.size) { n = this.tail !== null && !this.inTail; } } if (p == null) { p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1); if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size !== null && this.first == 1) { p = this.tail !== null && this.inTail; } } var self = this; if (this.buttonNext.size() > 0) { this.buttonNext.unbind(this.options.buttonNextEvent + '.jcarousel', this.funcNext); if (n) { this.buttonNext.bind(this.options.buttonNextEvent + '.jcarousel', this.funcNext); } this.buttonNext[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true); if (this.options.buttonNextCallback !== null && this.buttonNext.data('jcarouselstate') != n) { this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); }).data('jcarouselstate', n); } } else { if (this.options.buttonNextCallback !== null && this.buttonNextState != n) { this.options.buttonNextCallback(self, null, n); } } if (this.buttonPrev.size() > 0) { this.buttonPrev.unbind(this.options.buttonPrevEvent + '.jcarousel', this.funcPrev); if (p) { this.buttonPrev.bind(this.options.buttonPrevEvent + '.jcarousel', this.funcPrev); } this.buttonPrev[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true); if (this.options.buttonPrevCallback !== null && this.buttonPrev.data('jcarouselstate') != p) { this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); }).data('jcarouselstate', p); } } else { if (this.options.buttonPrevCallback !== null && this.buttonPrevState != p) { this.options.buttonPrevCallback(self, null, p); } } this.buttonNextState = n; this.buttonPrevState = p; }, /** * Notify callback of a specified event. * * @method notify * @return undefined * @param evt {String} The event name */ notify: function(evt) { var state = this.prevFirst === null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev'); // Load items this.callback('itemLoadCallback', evt, state); if (this.prevFirst !== this.first) { this.callback('itemFirstInCallback', evt, state, this.first); this.callback('itemFirstOutCallback', evt, state, this.prevFirst); } if (this.prevLast !== this.last) { this.callback('itemLastInCallback', evt, state, this.last); this.callback('itemLastOutCallback', evt, state, this.prevLast); } this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast); this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last); }, callback: function(cb, evt, state, i1, i2, i3, i4) { if (this.options[cb] == null || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation')) { return; } var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb]; if (!$.isFunction(callback)) { return; } var self = this; if (i1 === undefined) { callback(self, state, evt); } else if (i2 === undefined) { this.get(i1).each(function() { callback(self, this, i1, state, evt); }); } else { var call = function(i) { self.get(i).each(function() { callback(self, this, i, state, evt); }); }; for (var i = i1; i <= i2; i++) { if (i !== null && !(i >= i3 && i <= i4)) { call(i); } } } }, create: function(i) { return this.format('
  • ', i); }, format: function(e, i) { e = $(e); var split = e.get(0).className.split(' '); for (var j = 0; j < split.length; j++) { if (split[j].indexOf('jcarousel-') != -1) { e.removeClass(split[j]); } } e.addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i)).css({ 'float': (this.options.rtl ? 'right' : 'left'), 'list-style': 'none' }).attr('jcarouselindex', i); return e; }, className: function(c) { return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical'); }, dimension: function(e, d) { var el = $(e); if (d == null) { return !this.options.vertical ? (el.outerWidth(true) || $jc.intval(this.options.itemFallbackDimension)) : (el.outerHeight(true) || $jc.intval(this.options.itemFallbackDimension)); } else { var w = !this.options.vertical ? d - $jc.intval(el.css('marginLeft')) - $jc.intval(el.css('marginRight')) : d - $jc.intval(el.css('marginTop')) - $jc.intval(el.css('marginBottom')); $(el).css(this.wh, w + 'px'); return this.dimension(el); } }, clipping: function() { return !this.options.vertical ? this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) : this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth')); }, index: function(i, s) { if (s == null) { s = this.options.size; } return Math.round((((i-1) / s) - Math.floor((i-1) / s)) * s) + 1; } }); $jc.extend({ /** * Gets/Sets the global default configuration properties. * * @method defaults * @return {Object} * @param d {Object} A set of key/value pairs to set as configuration properties. */ defaults: function(d) { return $.extend(defaults, d || {}); }, intval: function(v) { v = parseInt(v, 10); return isNaN(v) ? 0 : v; }, windowLoaded: function() { windowLoaded = true; } }); /** * Creates a carousel for all matched elements. * * @example $("#mycarousel").jcarousel(); * @before
    • First item
    • Second item
    * @result * *
    *
    *
    *
      *
    • First item
    • *
    • Second item
    • *
    *
    *
    *
    *
    *
    * * @method jcarousel * @return jQuery * @param o {Hash|String} A set of key/value pairs to set as configuration properties or a method name to call on a formerly created instance. */ $.fn.jcarousel = function(o) { if (typeof o == 'string') { var instance = $(this).data('jcarousel'), args = Array.prototype.slice.call(arguments, 1); return instance[o].apply(instance, args); } else { return this.each(function() { var instance = $(this).data('jcarousel'); if (instance) { if (o) { $.extend(instance.options, o); } instance.reload(); } else { $(this).data('jcarousel', new $jc(this, o)); } }); } }; })(jQuery);