//").appendTo($("#alcoholFilterForm")); } } function turnSameCategoryFilterFormElementsOff(targetID, elementType, elementValue) { // Deactivate all sibling buttons $("img[id^="+elementType+"_]").each(function() { if (this.id != targetID) setFilterFormElement(this, "off", elementType, elementValue); }); } function disableSelection(target) { if (typeof target.onselectstart != "undefined") //IE route target.onselectstart = function(){return false;} else if (typeof target.style.MozUserSelect != "undefined") //Firefox route target.style.MozUserSelect = "none"; else //All other route (ie: Opera) target.onmousedown = function(){return false;} target.style.cursor = "default"; } function disableDraggingFor(element) { // this works for FireFox and WebKit in future according to http://help.dottoro.com/lhqsqbtn.php element.draggable = false; // this works for older web layout engines element.onmousedown = function(evt) { if (evt) { evt.preventDefault(); } return false; }; } $.fn.defaultText = function(value){ var element = this.eq(0); element.data('defaultText',value); element.focus(function(){ if(element.val() == value){ element.val('').removeClass('defaultText'); } }).blur(function(){ if(element.val() == '' || element.val() == value){ element.addClass('defaultText').val(value); } }); return element.blur(); } function activateCarouselFancyBox() { $("[class=carouselItemA]").each(function() { $(this).fancybox({ 'hideOnContentClick': false, 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'speedIn' : 400, 'speedOut' : 200, 'scrolling' : "no", 'overlayOpacity': "0.6", 'overlayColor' : "#000000", 'titlePosition' : "outside", 'title' : '
'+$(this).parent().find("a").attr("rel")+'
' }); }); } function updateDrinkCounter() { $.post("GetNumDrinks.php", "", function(data) { $("#drinkCounter").text(data+"+ drinks and counting!"); }); } function setupCarousel() { return $("#drinksCarousel").carouFredSel({ width: 780, // 130px * 6 items padding: [0, 110], items: { visible: 6, width: "variable" }, scroll: { items: 6, easing: "easeOutExpo", duration: 350 }, auto: false, prev: { button: "#drinksCarouselScrollLeftButton", key: "left" }, next: { button: "#drinksCarouselScrollRightButton", key: "right" }, pagination: "#drinksCarouselPageNavigation" }); } // Runs initializing script once DOM is ready. $(document).ready(function() { //===[ CarouFredSel SECTION ]================================= var carousel = setupCarousel(); //===[ Filter buttons / update carousel SECTION ]================== $(".filterButton").click(function() { if ( $(this).is(".on") ) { // If current state is on, turn it off // Deactivate target button setFilterFormElement(this, "off"); } else { // Otherwise, turn it on var splitResult = this.id.split("_"); var elementType = splitResult[0]; var elementValue = splitResult[1]; // Activate target button setFilterFormElement(this, "on", elementType, elementValue); // Deactivate all buttons of the same category turnSameCategoryFilterFormElementsOff(this.id, elementType, elementValue); } //$("#debug").text($("#alcoholFilterForm").serialize()); $.post("DrinksLookup.php", $("#alcoholFilterForm").serialize(), function(data) { if (carousel) { if ($("#carouselItem").length > 0) { $("#drinksCarousel").trigger("removeItem", "#drinksCarousel #carouselItem"); $("#drinksCarousel #carouselItem").remove(); } $(".pagination > *").remove(); carousel.destroy(); } $("#drinksCarousel").html(data); DrinkishToolTip("[class=carouselItemA]"); activateCarouselFancyBox(); var numDrinks = $("#drinksCarousel").find("[class=carouselItemA]").length; $("#drinkSelectedContainer").text("There are " + numDrinks + " drinks selected."); if (numDrinks > 0) { carousel = setupCarousel(); if (numDrinks <= 6) { $(".scrollButtonLeftWrapper").css({"display":"none"}); $(".scrollButtonRightWrapper").css({"display":"none"}); $(".pagination").css({"display":"none"}); } else { $(".scrollButtonLeftWrapper").css({"display":"inline"}).find("img").css("display","inline"); $(".scrollButtonRightWrapper").css({"display":"inline"}).find("img").css("display","inline"); $(".pagination").css({"display":"inline"}); } } else { carousel = null; $("#drinksCarousel").html("
No drinks found for the selected options.
"); $(".scrollButtonLeftWrapper").css({"display":"none"}); $(".scrollButtonRightWrapper").css({"display":"none"}); $(".pagination").css({"display":"none"}); } }); }); //===[ Add a Drink :: UGC Form Show/Hide SECTION ]========== $("#addADrinkNavButton a").fancybox({ 'hideOnContentClick': false, 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'speedIn' : 400, 'speedOut' : 200, 'scrolling' : "no", 'overlayOpacity': "0.6", 'overlayColor' : "#000000", 'titlePosition' : "outside", 'title' : '
Add a Drink
' }); //===[ Input fields default text SECTION ]================== $('#ugc_drinkName').defaultText(""); //===[ Fancy Box SECTION ]================================== activateCarouselFancyBox(); //===[ Display # drinks ]=================================== updateDrinkCounter(); //===[ Activate cool tooltips ]============================= DrinkishToolTip(); // Order of operation matters for these disable-select scripts. //$("img").each(function(index) {disableDraggingFor(this);}); //disableSelection(document.body); }); //]]>