(function($){ 'use strict'; /* * All Foundation related stufz */ $(function(){ $(document).foundationMediaQueryViewer(); $(document).foundationAlerts(); $(document).foundationAccordion(); $(document).tooltips(); $('input, textarea').placeholder(); $(document).foundationButtons(); $(document).foundationNavigation(); $(document).foundationCustomForms(); $(document).foundationTabs({callback:$.foundation.customForms.appendCustomMarkup}); $("#featured").orbit(); // UNCOMMENT THE LINE YOU WANT BELOW IF YOU WANT IE8 SUPPORT AND ARE USING .block-grids // $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'left'}); // $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'left'}); // $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'left'}); // $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'left'}); }); })(jQuery); $(document).ready(function(){ /* * Functionality for the Locale Switcher */ $("#locale-switcher li").click(function(){ window.location = $(this).attr("rel"); }); /** * Login box */ $(".navigation").on("click", ".loginbutton", function(e){ e.preventDefault(); $(this).toggleClass("active"); $(this).parent().find(".loginbox").toggleClass("active"); }); /* * Activating the intro slider on home */ $("#intro-slider").orbit({captions:true,bullets:true}); /** * Ajax call for checking if a band already exists * */ $("#registration_form").on("submit", function(){ // Are we ready to send the form already? var form = $(this); if($("#ready").val() === "no") { // Get vars to check le band var bandname = $("#fos_user_registration_form_bandname").val(); var city = $("#fos_user_registration_form_city").val(); var country = $("#fos_user_registration_form_country").val(); $.ajax({ type: "POST", url: "/ajax/bandname", data: { bandname: bandname, city: city, country: country}, success: function(response) { var res = $.parseJSON(response); if(res.status === "fail") { $('#modalbox').html( "

"+ res.title+ "

"+ res.msg+ "

"+res.btncontinue+" "+res.btncancel+""); $('#modalbox').reveal(); } else { $("#ready").attr('value',"yes"); form.submit(); } } }); } else { return true; } return false; }) .on("blur", "#fos_user_registration_form_website", function(){ // Make sure the website is prefixed with a protocol var site = $("#fos_user_registration_form_website").val(); if(site.indexOf('http') === -1 && site.indexOf('https') === -1){ site = "http://"+site; } $("#fos_user_registration_form_website").val(site); }); $("#edit_account").on("blur", "#fos_user_profile_form_website", function(){ // Make sure the website is prefixed with a protocol var site = $("#fos_user_profile_form_website").val(); if(site.indexOf('http') === -1 && site.indexOf('https') === -1){ site = "http://"+site; } $("#fos_user_profile_form_website").val(site); }); // The button on the modal box to overwrite the warning $("#doregister").live('click', function(){ $("#ready").attr('value',"yes"); $("#registration_form").submit(); }); // Custom close button for the modal box $("#cancel").live("click", function(){ $("#modalbox").trigger("reveal:close.reveal"); }); /** * Activate accordion for FAQ */ $("#faq-accordion").accordion({ collapsible: true, active: false, autoHeight: false, animated: "slide" }); $("#autocomplete").keydown(function(e){ if(e.keyCode === 13){ e.preventDefault(); } }).keyup(function(e){ e.preventDefault(); var current = $(".auto-complete").find("li.selected"); /* Check if we can move the selection down, and do so */ if(e.keyCode === 40){ //arrow down var next = current.next(); if(next.size() === 1){ current.removeClass("selected"); next.addClass("selected"); var ac = $(".auto-complete"); if(!ac.is(':visible')) { ac.show(); } } } /* Check if we can move the selection up, and do so */ else if(e.keyCode === 38){ // Arrow Up var prev = current.prev(); if(prev.size() === 1){ current.removeClass("selected"); prev.addClass("selected"); } } /* Hide the autocomplete on escape or blur */ else if(e.keyCode === 27) // Escape { $(".auto-complete").hide(); } /* on Enter, close the autocomplete and fill data */ else if(e.keyCode === 13) //Enter { fillHometown(current); } /* no special keys, so do a search */ else { var term = $(this).val(); $.ajax({ url: "https://secure.geonames.org/search", type: "get", dataType: 'json', data: {username:'slik',maxRows:10,featureClass:'P',name_startsWith:term,type:"json"}, success: function(msg){ var cities = msg.geonames; var results = ''; var ac = $('.auto-complete').html(results); if(!ac.is(':visible')) { ac.show(); } } }); } }); $(".auto-complete").on("click","li",function(e){ var current = $(e.target); fillHometown(current); }); $("#edit_account").submit(function(){ var auto = $("#autocomplete").val(); var city = $("#fos_user_profile_form_city").val(); var country = $("#fos_user_profile_form_country").val(); var countryCode = $("#fos_user_profile_form_countryCode").val(); if(city !== '' && country !== '' && countryCode !== '' && auto !== ''){ return true; } else{ $("#autocomplete").addClass("error"); return false; } }); $("#registration_form").submit(function(){ var auto = $("#autocomplete").val(); var city = $("#fos_user_registration_form_city").val(); var country = $("#fos_user_registration_form_country").val(); var countryCode = $("#fos_user_registration_form_countryCode").val(); if(city !== '' && country !== '' && countryCode !== '' && auto !== ''){ return true; } else{ $("#autocomplete").addClass("error"); return false; } }); /** * Load city/country on faulty submit in register and edit */ var city, country; if($('#registration_form').length) { city = $("#fos_user_registration_form_city").val(); country = $("#fos_user_registration_form_country").val(); } else if($('#edit_account').length) { city = $("#fos_user_profile_form_city").val(); country = $("#fos_user_profile_form_country").val(); } if(($('#edit_account').length || $('#registration_form').length) && city !== '' && country !== '') { $('#autocomplete').val(city+", "+country); } /** * Activate the carousel for showcasing */ $("#showcase").jcarousel({ wrap: 'circular', scroll: 3, visible: 3 }); /** * Switch stageplans to or from public */ $(".switch").on("click", function(e){ e.preventDefault(); var button = $(this); var id = button.data("id"); $.ajax({ url: window.jsRoot+"ajax/switch-stageplan", type: "post", data: {id: id}, success: function() { if(button.hasClass("on")) { button.removeClass("on").html($("#no").val()); } else { button.addClass("on").html($("#yes").val()); } } }); }); $("#contactform").on("submit", "form", function(e){ e.preventDefault(); var form = $(this).serialize(); $.ajax({ url: window.jsRoot+"ajax/contact", type: "post", data: form, success: function(){ $("#contactform").trigger("reveal:close.reveal"); $("#modalbox").html( '

Thank you

We have received your message and sent you a copy. We will try to reply as soon as possible.

Close

' ).reveal(); } }); }); $(".reveal-modal").on("submit", ".contactform", function(e){ e.preventDefault(); }); $(".tip").each(function(){ $(this).qtip({ content: $(this).data('tooltip'), style: { tip: { corner: "bottomLeft" }, name: "dark" }, position: { corner: { target: 'topMiddle', tooltip: 'bottomLeft' } }, show: { when: { event: "click" } } }); }); /* * Add click/blur behaviour to search box */ //add live filter text behaviour $( "input[type=text]#search" ).on('keyup change', function(){ findStageplans(); }); //add form changed behaviour (for auto loading new matches) $("input[type=text]#search").on('change', function() { findStageplans(); }); /* prevent enter submit*/ $('form.search').on("submit", function(e) { e.preventDefault(); return false; }); }); /* search functions */ function findStageplans(){ //each result add stageplan result var stageplan = $("#templates .result"); var contentrow = $("#templates .contentrow"); var stageplanCount = 0; var artistCount = 0; $.getJSON( window.jsRoot+'search/'+$('input[type=text]#search').val(), null, function(data) { var stageplans = []; $.each(data.artists, function(key, val) { artistCount++; var newStageplan = $(stageplan).clone(); //newStageplan.find(".props").html(val.type+', '+val.age+' jaar oud'+', '+val.gender+', '+val.color+', '+val.pedigree); // //set image var img_src = ''; if(val.promo) { img_src = '/uploads/bandpictures/'+val.promo ; newStageplan.find("img").prop("src", img_src); } var contents = newStageplan.find('.contents'); var artistHeader = contents.find('.title'); var locationHeader = contents.find('.location'); artistHeader.html(val.band); if(val.city && val.country){ locationHeader.html(val.city+', '+val.country); } $.each(val.stageplans, function(keyStagplan, stageplan){ contentrow = $(contentrow).clone(); var title = contentrow.find('.title'); var viewlink = contentrow.find('.view a'); var downloadlink = contentrow.find('.download a'); var viewslug = window.jsRoot+'stageplan/'+val.bandslug+'/'+val.bandid+'/'+stageplan.slug; var downloadslug = window.jsRoot+'search/'+stageplan.id+'/export'; title.html(stageplan.name); viewlink.prop('href', viewslug); downloadlink.prop('href', downloadslug); $(contents).append(contentrow); stageplanCount++; }); stageplans.push( newStageplan.get(0).outerHTML); }); //update pagination /*if( data['currentpage'] == Math.ceil(data['total']/data['pagelength'])){ $('div.pagination div.forward').hide(); $('div.pagination div.spacer.right').show(); }else{ $('div.pagination div.forward').show(); $('div.pagination div.spacer.right').hide(); } if( data['currentpage'] != 1){ $('div.pagination div.back').show(); $('div.pagination div.spacer.left').hide(); }else{ $('div.pagination div.back').hide(); $('div.pagination div.spacer.left').show(); }*/ /* $('div.pagination span.pagecount').html( Math.ceil(data['total']/data['pagelength'])) ; $('div.pagination span.currentpage').html( data['currentpage'] ); */ var results = $('#results-container'); $('.results h2').html('Found '+artistCount+' artist with '+stageplanCount+' stageplans'); results.empty(); //$('.count').html(data['total']); results.html(stageplans.join('')); // yellow fade /*results.before("
") results.prev() .width(results.width()) .height(results.height()) .css({ "position": "absolute", "background-color": "#ffff99", "opacity": ".7", "z-index": 10 }) .fadeOut(1000, 'easeOutQuad');*/ //$("#welcomebox").hide(); //window.scrollTo(0,0); } ); } function fillHometown(current){ var city = current.data("city"); var country = current.data("country"); var countryCode = current.data("countrycode"); $("#fos_user_profile_form_city").val(city); $("#fos_user_profile_form_country").val(country); $("#fos_user_profile_form_countryCode").val(countryCode); $("#fos_user_registration_form_city").val(city); $("#fos_user_registration_form_country").val(country); $("#fos_user_registration_form_countryCode").val(countryCode); $("#autocomplete").val(city+", "+country); $(".auto-complete").hide(); }