$(document).ready(function () { //-------START group content box tabs functionality-----------// if (typeof (groupContentBoxes) != "undefined") { if (groupContentBoxes) { $.each(groupContentBoxes, function (index, value) { $("#group-" + value + " .groupContextNewsTab").bind("click", { tabId: "1", itemId: value }, groupTab); $("#group-" + value + " .groupContextVideosTab").bind("click", { tabId: "2", itemId: value }, groupTab); $("#group-" + value + " .groupContextPhotosTab").bind("click", { tabId: "3", itemId: value }, groupTab); }); } } //-------END group content box tabs functionality-----------// //-------Start Subscriber functionality-----------// //set attributes initFormValues(); //hide all error classes hideErrorDivs(); //bind the click event $('#footer-searchBox-sbt').unbind("click").bind('click', function (e) { e.preventDefault(); if (!checkNewsSelection()) { $('#newsSelectionMessage').toggleClass('custom-validation-error'); $('#newsSelectionMessage').show(); } else if ($('#footer-searchBox-sbt').closest("form").valid()) { $('#newsSelectionMessage').hide(); callController(); } return false; }); //clear the errors when click outside the Subscriber form $('body').bind('mouseup', hideErrorDivs); //-------End Subscriber functionality-----------// $("#findClubForm").submit(function (event) { clubSearchFormValidate(event, $(this).find(".input-text").val()); }); $("#findClubForm button").unbind("click").click(function (event) { clubSearchFormValidate(event, $(this).parents('form:first').find(".input-text").val()); }); //------- START: Content Editor functionality-----------// // if the selected dropdown position box is "Highlight Box" then the next dropdown position box selection should be unavailable var highlightBox = "Highlights"; // Hightlight boxes fodler name var unvailableBox = "{A9447BD8-A1FE-475A-BD8B-0DBD7625F35A}"; //Item id for unavailable box $(".contentEditorBoxDropdown").change(function () { var id = $(this).attr('id'); //Homepage_Position_1 var thisDropdown = "#" + id; //#Homepage_Position_1 var position = id.substring(id.length - 1); // 1 var nextDropdown = id.substring(0, id.length - 1) + (parseInt(position) + 1); //Homepage_Position_2 nextDropdown = "#" + nextDropdown; //#Homepage_Position_2 // don;t allow "Unavailabe Box" selection in position 1" if (position == "1") { if ($(this).val() == unvailableBox) { alert('Box position one cannot be "Unavailable Box".'); $(this).val(""); } else { altertNextDropdown(thisDropdown, nextDropdown); } } // don;t allow "Highlight Box" selection in position 6 & 3" else if (position == "3" || position == "6") { var displayName = $('option:selected', $(this)).text(); if (isHighlightBox(displayName)) { alert('Box position three and six cannot be "News Highlight Box".'); $(this).val(""); } } else { altertNextDropdown(thisDropdown, nextDropdown); } }); // make next dropdown box selection unavailable function altertNextDropdown(thisDropdown, nextDropdown) { var displayName = $(thisDropdown + " :selected").text(); if (isHighlightBox(displayName)) { $(nextDropdown).val(unvailableBox); $(nextDropdown).attr('disabled', true); } else { $(nextDropdown).attr('disabled', false); if ($(nextDropdown).val() == unvailableBox) { $(nextDropdown).val(""); } } } function isHighlightBox(displayName) { var firstTenChars = displayName.substring(0, 10); return (firstTenChars == highlightBox); } // enable all the dropdowns to post the dropdown selected value $('form').submit(function () { $(".contentEditorBoxDropdown").each(function () { $(this).removeAttr('disabled'); }); }); //disable all dropdowns with unavailable box selection $(".contentEditorBoxDropdown").each(function () { $(this).attr('disabled', ($(this).val() == unvailableBox)); }); //------- END: Content Editor functionality-----------// }); //-------START group content box tabs functionality-----------// function groupTab(event) { event.preventDefault(); var itemId = event.data.itemId; var tabId = event.data.tabId; $.get("/Box/GetGroupContentItems/" + tabId + "?itemId=" + itemId, function (data) { $("#group-" + itemId + " .blockInner .news-list").remove(); $("#group-" + itemId + " .blockInner").prepend(data); if ($('.news-list li').length < 4) { $('#cp-paginator').hide(); } else { $('#cp-paginator').show(); } initLatestNewsPagination(); }); } //-------END group content box tabs functionality-----------// //-------Start Subscriber functionality-----------// //set default valuers function initFormValues() { $('#errorMessage').attr("placeholder", "Enter your email"); } // send json to MVC controller function callController() { var check11 = $("label[for='footer-checkBox-1']").hasClass("checked"); var check21 = $("label[for='footer-checkBox-2']").hasClass("checked"); var check31 = $("label[for='footer-checkBox-3']").hasClass("checked"); $.ajax({ type: "POST", url: "/getinvolved/footersignup", data: { email: $('#Email').val(), check1: $('#footer-checkBox-1').val(), check2: $('#footer-checkBox-2').val(), check3: $('#footer-checkBox-3').val(), check1checked: check11, check2checked: check21, check3checked: check31, __RequestVerificationToken: $("#footer-form input[name='__RequestVerificationToken']").val() }, success: function (data) { if (data != "True") { alert('Failed' + data); } else { showSuccesfully(); } }, error: function (data) { alert('Failed' + data); }, beforeSend: function () { $("#footerLoadingDiv").show(); }, complete: function () { $("#footerLoadingDiv").hide(); } }); //showSuccesfully(); } function showSuccesfully() { $('#subscribeSuccessfullyMessage').toggleClass("subscribe-message"); $('#subscribeSuccessfullyMessage').show(); $('#Email').val(""); $('input:checked').each(function () { $(this).removeClass('checked'); }); } //get data from the current form function getData() { var stringArray = new Array(); var i = 0; $('input:checked').each(function () { stringArray[i] = new String($(this).val()); i++; }); stringArray[stringArray.length] = $('#footer-emailBox').val(); return stringArray; } //check if any news checkboxes were selected function checkNewsSelection() { var selected = $('input:checked').length; if (selected >= 1) { return true; } return false; } //validate email function isValidEmail(email) { if (email != '' && email.search) { if (email.search( /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/ ) != -1) return true; else return false; } return false; } //hide error span's on DOM load function hideErrorDivs() { $('.error').hide(); } //-------End Subscriber functionality-----------// //-------START PostCode Validation-----------// function IsValidPostcode(postcode) { var validFormat = /^[a-z]{1,2}[0-9]{1,2}/i; if (postcode.length > 3) { validFormat = /(((^[BEGLMNS][1-9]\d?)|(^W[2-9])|(^(A[BL]|B[ABDHLNRST]|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]|F[KY]|G[LUY]|H[ADGPRSUX]|I[GMPV]|JE|K[ATWY]|L[ADELNSU]|M[EKL]|N[EGNPRW]|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKL-PRSTWY]|T[ADFNQRSW]|UB|W[ADFNRSV]|YO|ZE)\d\d?)|(^W1[A-HJKSTUW0-9])|(((^WC[1-2])|(^EC[1-4])|(^SW1))[ABEHMNPRVWXY]))(\s*)?([0-9][ABD-HJLNP-UW-Z]{2}))$|(^GIR\s?0AA$)/i; } var isValid = validFormat.test(postcode); return isValid; } function clubSearchFormValidate(event, postcode) { var isValid = IsValidPostcode(postcode); if (!isValid) { $(event.target).parents('form:first').find(".error").show(); event.preventDefault(); } else { $(event.target).parent().find(".error").hide(); } } //-------END PostCode Validation-----------// function displayMatchSummary(obj, matchId, divId, tdLoad) { if (obj.getAttribute('class') == "opened") return; //data already loaded ?? divId = "#" + divId; if ($(divId).html().length > 0) return; //show progress if (tdLoad != '') { tdLoad = "#" + tdLoad; $(tdLoad).html("
"); } var url = (Json.Encode(Url.Action("MatchReport"))); url = url + '/' + matchId; $.ajax( { type: 'POST', dataType: 'html', url: url, success: function(result) { $(divId).html(result); }, error: function() { alert("Failed to load match summary data, please try later"); }, complete: function() { //end progress if (tdLoad != '') { $(tdLoad).html(""); } } }); }