Created
July 2, 2014 14:46
-
-
Save nhindman/0d2070ded8b910710fc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function zeroFill( number, width ){width -= number.toString().length;if ( width > 0 ){return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;}return number; } | |
| $(document).ready(function(){ | |
| // $('body').click(function(){ | |
| // alert("hello!") | |
| // }) | |
| var sites = [] | |
| $('#splash-container').on('click', 'a.twitter_linkout', function(e){ | |
| e.preventDefault(); | |
| var targetElement = e.target; | |
| console.log('targetElement:', targetElement) | |
| console.log("twitter link click fired") | |
| var $div = $("#twitter-info-modal"); | |
| if($div.length < 1){ | |
| //if it does not exist on the page. | |
| $(".simple-modal-flow-control").append('<div id="twitter-info-modal" class="simple-modal"><div class="loader loading"><div class="nu-loader med"></div></div></div>'); | |
| $("#twitter-info-modal").fireSimpleModal(); | |
| } else { | |
| //if it does not exist. | |
| $("#twitter-info-modal").html('<div class="loader loading"><div class="nu-loader med"></div></div>').fireSimpleModal(); | |
| } | |
| //now get the data. | |
| // var twitter_username = document.getElementsByClassName('twitter_linkout').innerHTML(); | |
| // console.log('TWITTER USERNAME:', twitter_username) | |
| $.ajax({ | |
| type: 'GET', | |
| url: 'http://whispering-lake-3875.herokuapp.com/lookup?username=bjamin32', | |
| async: false, | |
| jsonpCallback: 'jsonpCallback', | |
| contentType: "application/json", | |
| dataType: 'jsonp', | |
| success: function(json) { | |
| console.log(json); | |
| sites.push(json) | |
| console.log(sites) | |
| $('#twitter-info-modal').empty().html(rows); | |
| var rows = ''; | |
| var counter = 0; | |
| var twitter_modal_header = $('<div class="twitter_modal_header"></div>') | |
| $('#twitter-info-modal').append(twitter_modal_header); | |
| for (var i=0; i < json.length; i++) { | |
| console.log("each fired", json[i]) | |
| // rows += '<div class="card"><div class="twitter_title"><a href="'+json[i].url+'">'+json[i].title+'</a></div>'; | |
| // rows += '<div class="twitter_image">'+json[i].image+'</div>'; | |
| // rows += '<div class="twitter_description">'+json[i].description+'</div>'; | |
| var image_counter = counter++; //<----gives each div a unique class for unique background image | |
| $('#twitter-info-modal').append('<div class="twitter_card"><div class="twitter_modal_title"><a href="'+json[i].url+'" target="_blank">'+json[i].title+'</a></div><a href="'+json[i].url+'" target="_blank"><div class="twitter_modal_image twitter_modal_image-'+image_counter+'"></div></a><div class="twitter_modal_description">'+json[i].description+'</div></div>'); | |
| $('.twitter_modal_image-'+image_counter).css('background-image','url("'+json[i].image+'")'); | |
| }; | |
| // $("#twitter-info-modal").empty().html(rows); | |
| }, | |
| error: function(e) { | |
| console.log(e.message); | |
| } | |
| }); | |
| return false; | |
| }); | |
| var isMobile = (/iPhone|iPod|iPad|Android|BlackBerry/).test(navigator.userAgent) | |
| if ( isMobile == true ){ | |
| $('body').addClass('isMobile') | |
| } | |
| $('body').removeClass('loading'); | |
| winHeight = $(window).height(); | |
| if( $('.autoWindowHeight').length > 0 ){ | |
| autoWindowSizes(); | |
| } else { | |
| if( constants.thisTheme != 'st-poster-v2' && constants.thisTheme != 'st-flyer-v2'){ | |
| dynamaHead() | |
| } | |
| } | |
| //headerVideoInit(); | |
| $(document).on({ | |
| mouseenter:function(){ | |
| if($(this).find(".when").length){ | |
| $(this).find(".company").hide(); | |
| $(this).find(".when").show();//('fast'); | |
| } | |
| }, | |
| mouseleave:function(){ | |
| var $obj = $(this); | |
| if($(this).find(".when").length){ | |
| $(this).find(".when").hide();//('slow',function(){ | |
| $obj.find(".company").show();//;;('fast'); | |
| // }); | |
| } | |
| } | |
| },'#event-attendees li'); | |
| resizeSplashContainer(); | |
| $navWrap = $("#main-canvas").find(".navWrap:first"); | |
| if(typeof $navWrap!=='undefined' && $navWrap.position()!==null){ | |
| navPos = $navWrap.position().top; | |
| } | |
| if(typeof navPos!=='undefined' && navPos!==false){ | |
| $(window).scroll(function(){ | |
| if($(this).scrollTop()>navPos){ | |
| $navWrap.addClass('fixed'); | |
| navHeight = 0; | |
| } else{ | |
| $navWrap.removeClass('fixed'); | |
| navHeight = $navWrap.outerHeight(); | |
| } | |
| }); | |
| } | |
| $("html").click(function(e){ | |
| if(openModal){ | |
| if(!$("#simple-modal-wrap").hasClass('persistent')){ | |
| var $target = $(e.target); | |
| if(!$target.hasClass('simple-modal') && $target.parents(".simple-modal").length < 1){ | |
| closeSimpleModal(); | |
| openModal = false; | |
| } | |
| } | |
| } | |
| }).keyup(function(e){ | |
| if(e.which==27){ | |
| if(openModal){ | |
| if(!$("#simple-modal-wrap").hasClass('persistent')){ | |
| closeSimpleModal(); | |
| openModal = false; | |
| } | |
| } | |
| } | |
| }); | |
| /* End Video Stuff */ | |
| $('#ticketForm').on('click', '.more-info', function(){ | |
| $desc = $(this).siblings('.description'); | |
| if( $desc.hasClass('hide') ){ | |
| $desc.removeClass('hide') | |
| } else { | |
| $desc.addClass('hide') | |
| } | |
| }); | |
| $(document).on('click','#sectionNav a',function(event){ | |
| event.preventDefault(); | |
| var section = $.trim($(this).attr('href').replace('#','')); | |
| var $chunk = $("#section-"+section); | |
| if($chunk.length){ | |
| $('html, body').stop().animate({ | |
| scrollTop: $chunk.offset().top-20 | |
| }, 1000,'easeInOutExpo'); | |
| } | |
| }); | |
| if( constants.inlineRsvp == 1 && constants.thisTheme.indexOf('st-reset') == '-1' && constants.thisTheme.indexOf('st-') != '-1' ){ | |
| $('.element-rsvp').addClass('inlineForm') | |
| } | |
| $("#main-canvas").on('click',".element-rsvp",function(){ | |
| var $t = $(this); | |
| if(!$("body").hasClass('finetune')&&!$("body").hasClass('rsvp-closed')){ | |
| if( $t.find(".rsvp-form.private").length < 1){//don't click if dealing with semi-private event. | |
| if( $('#main-canvas').hasClass('link') && typeof $('#rsvp-button').attr('href')!=='undefined' ) { | |
| window.open( $('#rsvp-button').attr('href') ); | |
| } else if($t.find("#rsvp-modal").length < 1) {//dont fire if inline rsvp form. | |
| showRsvpForm(); | |
| return false; | |
| //$("#rsvp-button").click(); | |
| //return false; | |
| } | |
| } | |
| } | |
| }); | |
| $("#main-canvas").on('click',"#rsvp-button",function(event){ | |
| var $this = $(this); | |
| _gaq.push(['_trackEvent', 'Splash', $this.attr("track"), 'id:'+constants.event_id]); | |
| if( !$this.hasClass('disabled') && !$this.hasClass('editable') && !$("body").hasClass('rsvp-closed')){ | |
| //$("#rsvp-button").hide(); | |
| if( $('#main-canvas').hasClass('link') && $('#rsvp-button').attr('href') ) { | |
| window.open( $('#rsvp-button').attr('href') ); // open if rsvp_method is external link | |
| } else { | |
| event.stopPropagation(); | |
| showRsvpForm(); | |
| } | |
| } | |
| }); | |
| $(document).on('click', 'a.add-cal', function(e){ | |
| _gaq.push(['_trackEvent', 'Splash', 'CalendarOpen', 'id:'+constants.event_id]); | |
| e.preventDefault(); | |
| $(this).parents("div:first").find('.the-cals').removeClass('hide'); | |
| $('#add-cal-wrap').addClass('addingToCal') | |
| }); | |
| $("div.private h3").click(function(){ | |
| $("input[name='access_code']").focus(); | |
| }); | |
| var mapOpenTimeout; | |
| $("#rsvp-form-inner").on('click',"#add-message",function(event){ | |
| _gaq.push(['_trackEvent', 'Splash', 'RSVPAddMessage', 'id:'+constants.event_id]); | |
| event.preventDefault(); | |
| $(this).hide(); | |
| var $rsvpMessage = $('#rsvp-message'); | |
| //$rsvpMessage.removeClass('hide').slideDown('fast',function(){$rsvpMessage.focus().width()}); | |
| $rsvpMessage.removeClass('hide').focus().width(); | |
| }); | |
| $("#rsvp-form-inner").on('keyup',".form-field",function(e){ | |
| if ( e.which == 13 ){ | |
| var $this = $(this); | |
| if(!$this.hasClass('textarea')){ //textareas can press enter. | |
| if($this.parent().hasClass('radio')){ //radio button + enter = select it. | |
| $this.click(); | |
| if($this.hasClass('attending-toggle')){ | |
| $("#rsvp-submit").click(); | |
| return false; | |
| } | |
| } | |
| var $n = $this.next('.form-field'); | |
| if($n.length > 0){ | |
| $n.focus(); | |
| } else{ | |
| var input_index = $this.index()*1; | |
| var next = input_index; | |
| var $next_input = $("#rsvp-form-inner").find(".form-field:eq("+next+")"); | |
| //console.log("here."); | |
| if($next_input.length>0){ | |
| $next_input.focus(); | |
| } else{ | |
| //console.log("here."); | |
| next = input_index+1; | |
| $next_input = $("#rsvp-form-inner").find(".form-field:eq("+next+")"); | |
| if($next_input.length > 0){ | |
| $next_input.focus(); | |
| } //else { | |
| // $("#rsvp-submit").click(); | |
| //} | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| $('#rsvp-form-inner').on('change','.date-select',function(){ | |
| var $this = $(this); | |
| var $parent = $this.parents(".date-holder"); | |
| if($this.hasClass('month')){ | |
| if($.inArray($this.val(),['02','04','06','09','11']) > -1 ){ | |
| //$parent.find(".day").find("option:gt(28)").remove(); | |
| $parent.find(".day:first").find(".option[value='29'],.option[value='30'],.option[value='31']").hide(); | |
| if($this.val()=='02'){ | |
| var year = $parent.find(".year").val(); | |
| if(year!=''){ | |
| var isLeap = new Date(year, 1, 29).getMonth(); | |
| if(isLeap==1){ | |
| $parent.find(".day:first").find(".option[value='29']").show(); | |
| // var other_opts = '<option value="29">29</option>'; | |
| // $parent.find(".day").append(other_opts); | |
| } | |
| } | |
| } else{ | |
| // var other_opts = '<option value="29">29</option><option value="30">30</option>'; | |
| // $parent.find(".day").append(other_opts); | |
| $parent.find(".day:first").find(".option").show().end().find(".option[value='31']").hide(); | |
| } | |
| // $parent.find(".day").find("option:gt(30)").remove(); | |
| } else{ | |
| $parent.find(".day:first").find(".option").show();//:gt(28):lt(31)").show(); | |
| // $parent.find(".day").find("option:gt(28)").remove(); | |
| // var other_opts = '<option value="29">29</option><option value="30">30</option><option value="31">31</option>'; | |
| //$parent.find(".day").append(other_opts); | |
| } | |
| } else if ($this.hasClass('year')){ | |
| var year = $this.val(); | |
| var month = $parent.find(".month"); | |
| if(month.val()=='02'){ | |
| var isLeap = new Date(year, 1, 29).getMonth(); | |
| if(isLeap==1){ | |
| $parent.find(".day:first").find(".option[value='29']").show(); | |
| // var other_opts = '<option value="29">29</option>'; | |
| // $parent.find(".day").append(other_opts); | |
| } else{ | |
| $parent.find(".day:first").find(".option[value='29']").hide();//[value='29']").show(); | |
| } | |
| } | |
| } | |
| var p = { year: $parent.find(".year").val(), | |
| month: $parent.find(".month").val(), | |
| day: $parent.find(".day").val() | |
| }; | |
| //console.log("P ",p); | |
| $this.parents(".date-holder").find("input.custom").val(p.year+'-'+p.month+'-'+p.day); | |
| // if($(this).val()=='') | |
| }); | |
| $("#sendANote,#contactOrgFtr").click(function(event){ | |
| event.preventDefault(); | |
| $("#contact-event-organizer").fireSimpleModal(); | |
| return false; | |
| }); | |
| $("#rsvp-modal").on('change','#attendee_count',function(){ | |
| var c = parseInt($(this).val()); | |
| $('.guest_names').hide(); | |
| for ( var i=1; i<c; i++ ){ | |
| $('.guest_name_'+i).show(); | |
| } | |
| }); | |
| $("#rsvp-modal").on({ | |
| click:function(){ | |
| //console.log('yep'); | |
| var $this=$(this) | |
| if($this.prop("checked")){ | |
| $this.parents(".options").find("input.other-input-field").fadeIn(300,function(){ | |
| $(this).focus(); | |
| }) | |
| } else{ | |
| $this.parents(".options").find("input.other-input-field").val('').hide(); | |
| } | |
| } | |
| },'input[value="include_other_opt"]'); | |
| $("#rsvp-modal").on({ | |
| click:function(){ | |
| if( $(this).val() != 'include_other_opt' ){ | |
| $(this).parents(".options").find("input.other-input-field").val('').hide(); | |
| } | |
| } | |
| }, '.radio input') | |
| $(document).on({ | |
| change:function(){ | |
| //console.log('yep'); | |
| console.log('clickingg') | |
| var $this=$(this) | |
| if( $this.val() == 1 ){ | |
| $this.parents(".options").find("input.other-input-field").fadeIn(300,function(){ | |
| $(this).focus(); | |
| }) | |
| } else{ | |
| $this.parents(".options").find("input.other-input-field").val('').hide(); | |
| } | |
| } | |
| },'input[field="include_other_opt"], input[use-val="include_other_opt"]'); | |
| $(document).on('change','select, input.dropdown',function(){ | |
| var $t = $(this); | |
| console.log('change dropdown') | |
| var $input = $t.parents(".select-holder:first").find("input.other-input-field"); | |
| if($input.length > 0){ | |
| if($t.val()=='include_other_opt'){ | |
| $input.fadeIn().focus(); | |
| } else{ | |
| $input.hide().val(''); | |
| } | |
| } | |
| }); | |
| $(document).on('click',".plus-one-wrap label",function(){ | |
| if( $(this).find('#rsvp-plus-1').val() == 1){ | |
| $('#guest-name').show(); | |
| } else { | |
| $('#guest-name').hide(); | |
| $('#guest-name').val(''); | |
| } | |
| }); | |
| $(document).on('click', '.attending-wrap', function(){ | |
| console.log('click bo') | |
| if( ! $('.cantMakeIt').find('input').is(':checked') ){ | |
| $('#rsvp-form-inner').find('.attending-wrap').removeClass('selected') | |
| $(this).addClass('selected') | |
| } | |
| }) | |
| $(document).on('change', 'input[type="file"]', function(){ | |
| var filename = $(this).val().replace(/C:\\fakepath\\/i, '') | |
| $(this).attr('data-content', 'Uploaded: ' + filename).addClass('uploaded') | |
| }) | |
| $(document).on('click',"#rsvp-submit",function(){ | |
| var $obj = $(this); | |
| var errors = []; | |
| var $form = $("#rsvp-form-inner"); | |
| var params = { | |
| event_id: constants.event_id, first_name: $("#rsvp-first-name").val(), | |
| last_name: $("#rsvp-last-name").val(), email: $.trim($("#rsvp-email").val()), custom: {} | |
| } | |
| if($("#rsvp-company").length){ | |
| params.company = $("#rsvp-company").val() | |
| } | |
| if($("#rsvp-linkedin_url").length){ | |
| params.linkedin_url = $("#rsvp-linkedin_url").val() | |
| } | |
| if($("#rsvp-message").is(":visible")){ | |
| params.message = $("#rsvp-message").val(); | |
| } | |
| if($("#rsvp-plus-1").length){ | |
| params.plus_one = ($("#rsvp-plus-1").prop("checked"))?'yes':'no'; | |
| var $g = $('#guest-name'); | |
| params.guest_names = ($g.val()!=$g.attr('placeholder'))?[$g.val()]:[]; | |
| } | |
| var $b = $("#attendee_count"); | |
| if($b.length == 1 ){ | |
| params.attendee_count = $('#attendee_count').val(); | |
| params.guest_names = []; | |
| $('.guest_names:visible').each(function(){ | |
| var value = $.trim($(this).val()); | |
| if ( value != '' ){ | |
| params.guest_names.push(value); | |
| $(this).removeClass('error-border'); | |
| } | |
| else { | |
| $(this).addClass('error-border'); | |
| errors.push('Guest Name required.'); | |
| } | |
| }); | |
| if(isNaN(params.attendee_count)){//if its empty, mark as 1. | |
| params.attendee_count = 1; | |
| } | |
| } | |
| var $custom_fields = $form.find("input.custom,select.custom,textarea.custom"); | |
| if($custom_fields.length > 0){ | |
| $custom_fields.each(function(){ | |
| var $input = $(this); | |
| console.log( $input, ' inputtt') | |
| if ( $input.attr('type') == 'checkbox' || $input.hasClass('checkbox') ){ | |
| var $thisParent = $input.parent() | |
| var isNuCheckbox = false | |
| if( $thisParent.hasClass('nu-checkbox') && $thisParent.hasClass('checked') ){ | |
| isNuCheckbox = true | |
| } | |
| //console.log( $input, ' input' , $thisParent , ' parent', isNuCheckbox, ' test') | |
| if ( $input.hasClass('multi') ){ | |
| if ( $input.is(':checked') || isNuCheckbox ){ | |
| if ( typeof params.custom[$input.attr("num")] == 'undefined' ) | |
| params.custom[$input.attr("num")] = []; | |
| if ($input.val() == 'include_other_opt' || $input.attr('use-val') == 'include_other_opt') { | |
| var $opts = $input.parents('.options:first'); | |
| var $other = $opts.find('.other-input-field'); | |
| if ($other.length && $other.length > 0 ) { | |
| if( $input.is(':checked') || isNuCheckbox == true ) { | |
| params.custom[$input.attr("num")].push('Other: '+$other.val()); | |
| } | |
| } | |
| } else { | |
| if( isNuCheckbox == true ) { | |
| params.custom[$input.attr("num")].push($input.attr('use-val')); | |
| } else if( $input.is(':checked') ){ | |
| params.custom[$input.attr("num")].push($input.val()); | |
| } | |
| } | |
| } | |
| //params.custom[$input.attr("num")] = ''; | |
| } | |
| else{ | |
| console.log(isNuCheckbox, ' is checked? ', $input.is(':checked')) | |
| if ( $input.is(':checked') || isNuCheckbox == true ){ | |
| params.custom[$input.attr("num")] = $input.val(); | |
| }else{ | |
| params.custom[$input.attr("num")] = ''; | |
| } | |
| } | |
| } else if ( $input.attr('type') == 'radio' ){ | |
| if ( $input.is(':checked') ){ | |
| params.custom[$input.attr("num")] = $input.val(); | |
| if (params.custom[$input.attr("num")] == 'include_other_opt') { | |
| var $opts = $input.parents('.options:first'); | |
| var $other = $opts.find('.other-input-field'); | |
| if ($other.length && $other.length > 0 ) { | |
| params.custom[$input.attr("num")] = 'Other: '+$other.val(); | |
| } | |
| } | |
| }else{ | |
| //params.custom[$input.attr("num")] = ''; | |
| } | |
| } else if ( $input[0]['nodeName']=='SELECT' || $input.hasClass('dropdown') ){//.attr('type') == 'select' ){ | |
| console.log('DROPDOWN') | |
| params.custom[$input.attr("num")] = ($input.val()!=$input.attr('placeholder'))?$input.val():''; | |
| console.log(params.custom[$input.attr("num")], ' test' ) | |
| if (params.custom[$input.attr("num")] == 'include_other_opt'){ | |
| var $opts = $input.parents(".select-holder:first"); | |
| var $other = $opts.find('.other-input-field'); | |
| if ($other.length && $other.length > 0 ) { | |
| params.custom[$input.attr("num")] = 'Other: '+$other.val(); | |
| } | |
| console.log(params.custom[$input.attr("num")], ' testommg' ) | |
| } else{ | |
| //console.log("NOPE"); | |
| } | |
| } else{ | |
| params.custom[$input.attr("num")] = ($input.val()!=$input.attr('placeholder'))?$input.val():''; | |
| } | |
| }); | |
| } | |
| $form.find("input.required,select.required,textarea.required").each(function(){ | |
| var $input = $(this); | |
| if( $input.attr('type') == 'checkbox' || $input.hasClass('checkbox') ) { | |
| if ( $input.hasClass('multi') ){ | |
| if ( $('input[name="'+$input.attr('name')+'"]:checked').length == 0 && $input.parents('.multiCheck-holder:first').find('.nu-checkbox.checked').length == 0 ){ | |
| $input.parent().parent().addClass('error-border'); | |
| errors.push('Please select at least one.'); | |
| }else { | |
| $input.parent().parent().removeClass('error-border'); | |
| } | |
| }else{ | |
| if ( !$input.is(':checked') && ! $input.parents('.checkbox:first').hasClass('checked') ){ | |
| $input.parent().addClass('error-border'); | |
| errors.push('Checkbox required'); | |
| } else{ | |
| $input.parent().removeClass('error-border'); | |
| } | |
| } | |
| /* } else if( $input.hasClass('date-field') ) { | |
| var $parent = $input.parents('.date-holder:first') | |
| var $day = $parent.find('.date-select.day') | |
| var $month = $parent.find('.date-select.month') | |
| var $year = $parent.find('.date-select.year') | |
| if( $day.hasClass('nativeSelect') || $month.hasClass('nativeSelect') || $year.hasClass('nativeSelect') ){ | |
| // IF NATIVE SELECT | |
| if( $input.val() == '' ){ | |
| $input.parents('.date-holder:first').addClass('error-border') | |
| } else { | |
| $input.parents('.date-holder:first').removeClass('error-border') | |
| } | |
| } else { | |
| // IF NU DROPDOWN | |
| var isError = false | |
| if( $day.val() == ''){ | |
| isError = true | |
| } | |
| if( $month.val() == ''){ | |
| isError = true | |
| } | |
| if( $year.val() == '' ){ | |
| isError = true | |
| } | |
| } | |
| */ | |
| } else if( $input.hasClass('dropdown') ){ | |
| if( $input.val() == '' ){ | |
| $input.parents('.nu-dropdown:first').addClass('error-border') | |
| errors.push('Dropdown required'); | |
| } else { | |
| $input.parents('.nu-dropdown:first').removeClass('error-border') | |
| } | |
| }else if( $input.attr('type') == 'radio' && $('input[name="'+$input.attr('name')+'"]:checked').length == 0 ){ | |
| $input.parent().parent().addClass('error-border'); | |
| errors.push($input.attr("radio-placeholder")+' is required.'); | |
| } | |
| else if (($.trim($input.val()) == '' || $input.val()==$input.attr("placeholder")) && !($input.attr('id')=='guest-name'&&!$('#rsvp-plus-1').is(':checked')) ){ | |
| if ( $input.hasClass('textarea') ) $input.parent().addClass('error-border'); | |
| $input.addClass('error-border'); | |
| if ( $input.attr('placeholder') ){ | |
| errors.push($input.attr("placeholder")+' is required.'); | |
| } else{ | |
| errors.push('Fill out all required fields.'); | |
| } | |
| } | |
| else{ | |
| $input.removeClass('error-border'); | |
| $input.parent().removeClass('error-border'); | |
| $input.parent().parent().removeClass('error-border'); | |
| } | |
| }); | |
| $form.find(".date-holder").each(function(){ | |
| var $date_block = $(this); | |
| var $input = $date_block.find("input.custom"); | |
| var $parent = $input.parents('.date-holder:first') | |
| var $day = $parent.find('.date-select.day') | |
| var $month = $parent.find('.date-select.month') | |
| var $year = $parent.find('.date-select.year') | |
| if( $day.hasClass('nativeSelect') || $month.hasClass('nativeSelect') || $year.hasClass('nativeSelect') ){ | |
| // IF NATIVE SELECT | |
| if( $input.val() == '' ){ | |
| $input.parents('.date-holder:first').addClass('error-border') | |
| } else { | |
| $input.parents('.date-holder:first').removeClass('error-border') | |
| } | |
| } else { | |
| var date_val = $input.val(); | |
| if($day.val() =='' && $month.val()=='' && $year.val() == ''){ | |
| if($input.hasClass('required')){ //only stop them if they are required to fill out date. | |
| $date_block.addClass('error-border'); | |
| errors.push('A valid date is required.'); | |
| } | |
| } else if($day.val()=='' || $month.val()=='' || $year.val() == ''){ | |
| //regardles of whether it's required. if at least one field is empty, but not all, let them know. | |
| $date_block.addClass('error-border'); | |
| errors.push('A valid date is required.'); | |
| } else { | |
| // if(date_val.match(/^(19|20)\d\d-(0\d|1[012])-(0\d|1\d|2\d|3[01])$/)){ | |
| // alert('good date'); | |
| // errors.push('A valid date is required.'); | |
| // $date_block.removeClass('error-border'); | |
| // } else{ | |
| // alert('bad date'); | |
| $input.val( $year.val() + '-' + $month.val() + '-' + $day.val() ) | |
| console.log( $input.val(), ' is no') | |
| $date_block.removeClass('error-border'); | |
| } | |
| } | |
| if (typeof allDateFields21plus != 'undefined' && allDateFields21plus == true) { | |
| var dateString = $input.val(); | |
| if (dateString.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/)) { | |
| var parts = dateString.split('-'); | |
| var maxDate = new Date(); | |
| maxDate.setFullYear((maxDate.getFullYear() - 21)); | |
| var maxTime = maxDate.getTime(); | |
| var enteredDate = new Date(parts[0],(parts[1] - 1),parts[2]); | |
| var enteredTime = enteredDate.getTime(); | |
| if (enteredTime <= maxTime) { | |
| $input.val(dateString); | |
| } else { | |
| $input.val(''); | |
| $date_block.addClass('error-border'); | |
| errors.push('This is a 21 + event. No admittance without valid ID. All ID will be checked!<br> No one under 21 will be allowed in! No exceptions.'); | |
| } | |
| } else { | |
| $input.val(''); | |
| $date_block.addClass('error-border'); | |
| errors.push('This is a 21 + event. No admittance without valid ID. All ID will be checked!<br> No one under 21 will be allowed in! No exceptions.'); | |
| } | |
| } | |
| params.custom[$input.attr("num")] = $input.val() ; | |
| /* | |
| var day = $date_block.find(".day").val(); | |
| var month = $date_block.find(".month").val(); | |
| var year = $date_block.find(".year").val(); | |
| var date_val = $input.val(); | |
| if(day=='' && month=='' && year == ''){ | |
| if($input.hasClass('required')){ //only stop them if they are required to fill out date. | |
| $date_block.addClass('error-border'); | |
| errors.push('A valid date is required.'); | |
| } | |
| } else if(day=='' || month=='' || year == ''){ | |
| //regardles of whether it's required. if at least one field is empty, but not all, let them know. | |
| $date_block.addClass('error-border'); | |
| errors.push('A valid date is required.'); | |
| } else { | |
| // if(date_val.match(/^(19|20)\d\d-(0\d|1[012])-(0\d|1\d|2\d|3[01])$/)){ | |
| // alert('good date'); | |
| // errors.push('A valid date is required.'); | |
| // $date_block.removeClass('error-border'); | |
| // } else{ | |
| // alert('bad date'); | |
| $date_block.removeClass('error-border'); | |
| } | |
| */ | |
| }); | |
| if(!isValidEmail($("#rsvp-email").val())){ | |
| $("#rsvp-email").addClass('error-border'); | |
| errors.push('A valid email address is required.'); | |
| } | |
| params.attending = 1; | |
| var $attending_toggle = $form.find("input.attending-toggle");//:checked"); | |
| if($attending_toggle.length > 0){ | |
| //make sure that eiter attending/not attending is checked (if applicable) | |
| var attending_val = $form.find("input.attending-toggle:checked").val(); | |
| if(typeof attending_val==='undefined'){ | |
| //fix for attending_val returning undefined. having difficulty pinpointing why this is happening, | |
| //but believe it has something to do with radio inputs that are not visible on the page, thus the :checked selector not grabbing the right value. | |
| attending_val = $form.find("input.attending-toggle[checked='checked']").val(); | |
| } | |
| if(attending_val!='1' && attending_val!='0'){ | |
| _gaq.push(['_trackEvent', 'Splash', 'RSVPSubmitError', 'id:'+constants.event_id]); | |
| $("span.required-fields").html('*Please select if you\'re attending or not.').fadeIn();//errors.join('<br />')).fadeIn(); | |
| $form.find("input.attending-toggle:first").focus(); | |
| return false; | |
| //$form.find(".attending-toggle:first").focus(); | |
| } else{ | |
| params.attending = attending_val; | |
| } | |
| } | |
| if(errors.length > 0){ | |
| //console.log(errors); | |
| _gaq.push(['_trackEvent', 'Splash', 'RSVPSubmitError', 'id:'+constants.event_id]); | |
| $("span.required-fields").html('*Please fill out all required fields').fadeIn();//errors.join('<br />')).fadeIn(); | |
| return false; | |
| } | |
| else{ | |
| _gaq.push(['_trackEvent', 'Splash', 'RSVPSubmit', 'id:'+constants.event_id]); | |
| $("span.required-fields").hide(); | |
| $obj.hide(); | |
| if($obj.hasClass('in-progress')){ | |
| return false; | |
| } | |
| $obj.addClass('in-progress'); | |
| $("#rsvp-spinner").show().find('.nu-loader').addClass('loading'); | |
| $('#rsvp-form-inner .btnWrap').addClass('noBorder') | |
| // check for a real form for the file upload | |
| var $realForm = $('#rsvp-real-form.realForm'); | |
| if ( $realForm.length == 1 ){ | |
| $('#rsvp-form-inner').find(".nu-checkbox:not('.checked')").each( function(){ | |
| console.log($(this),' this ', $(this).find('input[type="hidden"]').val() ) | |
| $(this).find('input[type="hidden"]').remove() | |
| }) | |
| $('#rsvp-form-inner').find(".nu-checkbox.checked").each( function(){ | |
| //console.log($(this),' this ', $(this).find('input[type="hidden"]').val() ) | |
| if ( $(this).find('input[type="hidden"]').attr('use-val') == 'include_other_opt' ){ | |
| $(this).find('input[type="hidden"]').remove() | |
| } | |
| }) | |
| $realForm[0].submit(); | |
| return; | |
| } | |
| // this functionality needs to be duplicated in rsvp-form.ctp for realForm compat | |
| $.post(constants.formBase+"/rsvp"+location.search, params, function(response){ | |
| //console.log(response, 'resp') | |
| var jq = $.parseJSON(response); | |
| if(typeof jq.error!=='undefined' && jq.error == 1){ | |
| constants.hide_registration_prompt=true; | |
| $("#contactTheOrganizer").show(); | |
| var $social = ''; | |
| /* if (typeof jq.msg != 'undefined') { | |
| //$('#rsvp-modal').find('.rsvp-form').append(jq.msg); | |
| $('#afterRsvpMessage').after(jq.msg); | |
| } */ | |
| if(typeof jq.msgHead != 'undefined'){ | |
| $('#rsvp-form-top .rsvp-text').text(jq.msgHead) | |
| //console.log('head') | |
| } | |
| if(typeof jq.msgBody != 'undefined'){ | |
| $('#afterRsvpMessage .afterRsvpMessageInner .content').html('<p>'+jq.msgBody+'</p>') | |
| $('#afterRsvpMessage').show() | |
| } | |
| } else { | |
| var $social = $("div.countdown").find("ul.social").clone(); | |
| $('#rsvp-button').addClass('disabled'); | |
| } | |
| var $fh = $obj.parents('.form-holder:first'); | |
| //$fh.find('h5:first span').remove(); | |
| //var formTitle = $fh.find('h5:first').html(); | |
| $fh.remove(); | |
| //$fh.addClass('rsvp-confirm').html(jq.msg).append($social).hide().fadeIn('fast'); | |
| //galleryThumbFlow(true); | |
| // for wired theme | |
| $('span.fist-thumb.thumb').show(); | |
| // pop a modal with the message.. some social links.. and the 'create-your-own' auto-reg | |
| if ( constants.hide_registration_prompt !== true && (typeof jq.error == 'undefined' || jq.error!=1) ){ | |
| var $myShareBox = ( constants.hide_social_links ) ? '' : createMyShareBox(window.location); | |
| var $social = $("div.countdown").find("ul.social").clone(); | |
| var $arm = $('#afterRsvpMessage'); | |
| $arm.show() | |
| .find('.first_name').val(params.first_name) | |
| .end().find('.last_name').val(params.last_name) | |
| .end().find('.email').val(params.email) | |
| .end().find('.afterRsvpMessageInner .content').html('') | |
| .append(jq.msg) | |
| .append($social); | |
| if ( $myShareBox != '' && (typeof jq.error==='undefined'||jq.error!='1') ){ | |
| $arm.find('.afterRsvpMessageInner .content').append('<span class="shareWithFriends">Share with Friends:</span>').append($myShareBox).append( $('#add-cal-wrap') ); | |
| } | |
| } | |
| if(typeof jq.hideInlineForm!=='undefined'){ | |
| $("#section-rsvp").find("i.close-form").hide(); | |
| closeSimpleModal(); | |
| } | |
| $('#rsvp-modal').addClass('afterRsvp') | |
| console.log( jq.msgHead.length , ' len') | |
| var thisMsg = jq.msgHead | |
| if( thisMsg.length != 0 ) { | |
| $('#rsvp-form-top').find('.rsvp-text').text( thisMsg ) | |
| //thisMsg.remove() | |
| $('#afterRsvpMessage').find('.content > h5').remove() | |
| $('#afterRsvpMessage').find('.content > h3').remove() | |
| } | |
| if (typeof customAfterRSVP == 'function') { | |
| setTimeout(function(){ | |
| customAfterRSVP(params); | |
| },0); | |
| } | |
| }); | |
| } | |
| }); | |
| liveTimes = { days: constants.days, hours : constants.hours, | |
| minutes : constants.minutes, seconds: constants.seconds }; | |
| startCounter(); | |
| galleryInit(); | |
| $(document).on('click','#afterRsvpMessage .close',function(){ | |
| //$('#afterRsvpMessage').hide(); | |
| closeSimpleModal(); | |
| }); | |
| $(document).on('click','.fb-wrap .close',function(){ | |
| $(this).parents('div.fb-wrap:first').hide(); | |
| }); | |
| $(document).on('click','.add-fb-comments',function(e){ | |
| e.preventDefault(); | |
| var $li = $(this).parents('div.photo:first'); | |
| var $myFBWrap = $li.find('div.fb-wrap'); | |
| if ( $li.hasClass('commentsOpen') ){ | |
| $li.removeClass('shareOpen commentsOpen shareBoxOpen') | |
| .css({height:'',marginTop:'auto'}); | |
| }else{ | |
| $myFBWrap.show(); | |
| $li.addClass('shareOpen commentsOpen').removeClass('shareBoxOpen').find('.shareBox').remove(); | |
| setTimeout(function(){$('div.photos').scrollTop($('div.photos').height());},30); | |
| } | |
| if (!$myFBWrap.hasClass('jfiedj') ){ | |
| $myFBWrap.addClass('jfiedj'); | |
| $myFBWrap.html('<h3>Comment on this photo <span class="right">To mention someone in your comment, put an @ symbol before their name</span></h3><div class="fb-comments" data-href="'+$(this).attr('href')+'" data-num-posts="30" data-width="'+$myFBWrap.width()+'" data-colorscheme="dark"></div><span class="close">✖</span>').show(); | |
| FB.XFBML.parse(document.getElementById('fb-wrap-'+$(this).attr('im'))) | |
| } | |
| return false; | |
| }); | |
| $("#view-attendees").click(function(){ | |
| var legacy = false; | |
| if($(this).parents(".guest-list").find("#attendee-list").length > 0){ | |
| legacy = true; | |
| } | |
| if(!legacy && $("#attendees-modal").hasClass('loaded')){ | |
| $("#attendees-modal").fireSimpleModal(); | |
| return false; | |
| } else{ | |
| if(legacy){ | |
| //Legacy check. | |
| if($("#attendee-list").is(":visible")){ | |
| $("#attendee-list").slideUp(); | |
| } else{ | |
| $("#attendee-list").slideDown(); | |
| } | |
| } else{ | |
| $("#attendees-modal").fireSimpleModal(); | |
| } | |
| $("#sort-spinner").show(); | |
| $.ajax(constants.formBase+"/splash/viewAttendees/",{ | |
| data: { event_id: constants.event_id, sort: '' }, | |
| type: 'post', | |
| success: function(response){ | |
| $("#sort-spinner").hide(); | |
| $("#event-attendees").html(response); | |
| var updated_guest_count = $("#event-attendees").find(".updated-guest-count:first").html() * 1; | |
| $("#guest-count").html(updated_guest_count+' Attending'); | |
| $("#attendees-modal").addClass('loaded');//.html(response); | |
| // var updated_guest_count = $("#attendees-modal").find(".updated-guest-count:first").html() * 1; | |
| // $("#guest-count").html(updated_guest_count+' Attending'); | |
| }, | |
| error: function(){ | |
| alert('There was a problem processing your request. Please try again.'); | |
| } | |
| }); | |
| return false; | |
| } | |
| }); | |
| var closingSimple = false | |
| var closeSimpleWithDelay = function(){ | |
| $('body').removeClass('showSimple') | |
| clearTimeout( closingSimple ) | |
| closingSimple = setTimeout( function(){ | |
| closeSimpleModal() | |
| }, 300 ) | |
| } | |
| $('#simple-modal-wrap').on('click', function( event ){ | |
| //if( $('body').hasClass('isMobile') ){ | |
| if( $('#rsvp-modal').css('display') != 'none' && $(event.target).hasClass('simple-modal-flow-control') ){ | |
| event.preventDefault() | |
| var $thisModal = $(this).find('#rsvp-modal') | |
| console.log('testtt ', $thisModal.css('display') ) | |
| if( $thisModal.css('display') != 'none' ){ | |
| closeSimpleWithDelay() | |
| } | |
| return false | |
| } | |
| //} | |
| }) | |
| $('#rsvp-modal').on('click', '.close-form', function(event){ | |
| event.preventDefault() | |
| closeSimpleWithDelay() | |
| return false | |
| }) | |
| $("#attendees-modal,#attendee-block").on('click','.attendee-sort a',function(event){ | |
| event.preventDefault(); | |
| var $this = $(this); | |
| var sort = $this.attr("sort"); | |
| var $guest_list = $("#event-attendees"); | |
| _gaq.push(['_trackEvent', 'Splash', 'ViewAttendeeSort'+sort, 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| $this.parents(".attendee-sort").find("a.active").removeClass('active'); | |
| $this.addClass('active'); | |
| $("#sort-spinner").show(); | |
| $.ajax(constants.formBase+"/splash/viewAttendees/",{ | |
| data: { event_id: constants.event_id, sort: sort }, | |
| type: 'post', | |
| success: function(response){ | |
| $("#sort-spinner").hide(); | |
| $guest_list.html(response); | |
| var updated_guest_count = $guest_list.find(".updated-guest-count:first").html() * 1; | |
| $("#guest-count").html(updated_guest_count+' Attending'); | |
| }, | |
| error: function(){ | |
| alert('There was a problem processing your request. Please try again.'); | |
| } | |
| }); | |
| }); | |
| $(document).on('click',".toggle-shell",function(){ | |
| var $bar = $(this).find('span.inner'); | |
| if ( $(this).attr('status') == 'off' ){ | |
| $(this).attr("status",'on').find('span.inner').animate({marginLeft:0},{duration:200}); | |
| $(this).parents(".toggle-shell-contain").find("input.toggle-hidden-val").val(1).blur(); | |
| } else{ | |
| $(this).attr("status",'off').find('span.inner').animate({marginLeft:-82},{duration:200}); | |
| $(this).parents(".toggle-shell-contain").find("input.toggle-hidden-val").val(0).blur(); | |
| } | |
| }); | |
| ///////////////////////////////////////////////////////////////// | |
| // Ticket Form Validation | |
| $(document).on('submit','form.validateTicketForm',function(){ | |
| var $this = $(this); | |
| var form = getValuesObjFromForm($this); | |
| // make sure at least one ticket type has a > 0 quantity | |
| var isGood = false; | |
| if ( typeof form.tickets != 'undefined' ){ | |
| for ( id in form.tickets ){ | |
| if ( typeof form.tickets[id].quantity != 'undefined' && form.tickets[id].quantity != '' && parseInt(form.tickets[id].quantity) > 0 ){ | |
| isGood = true; | |
| } | |
| } | |
| } | |
| if (isGood != true) { | |
| $this.parents('.form-holder').find('.required-fields').html('Please select a valid number of tickets.').show(); | |
| } else if (typeof form.discount_code != 'undefined' && form.discount_code != ''){ | |
| $.ajax({url:constants.formBase+'/checkCode',type:'post',data:{code:form.discount_code},dataType:'json'}) | |
| .done(function(response){ | |
| if (typeof response != 'undefined' && typeof response.status != 'undefined' && response.status == 'success') { | |
| $this[0].submit(); // this is so we don't keep looping this onsubmit! | |
| } else { | |
| $this.parents('.form-holder').find('.required-fields').html('Invalid Code').show(); | |
| } | |
| }) | |
| .error(function(){ | |
| $this.parents('.form-holder').find('.required-fields').html('Invalid Code').show(); | |
| }); | |
| return false; | |
| } else if (isGood == true) { | |
| return true; | |
| } | |
| return false; | |
| }); | |
| // End Ticket Form Validation | |
| ///////////////////////////////////////////////////////////////// | |
| $(".subscribe-signup").click(function(event){ | |
| event.preventDefault(); | |
| var params = {}; | |
| var $t = $(this); | |
| var $p = $(this).parents(".subscribe-signup-area:first"); | |
| if($p.hasClass('saving')){//no double clicks. | |
| return false; | |
| } | |
| $p.addClass('saving').find("input.subscribe-input").each(function(){ | |
| if($(this).val()!=''){ | |
| params[$(this).prop("name")] = $(this).val(); | |
| } | |
| }); | |
| params.event_id = constants.event_id; | |
| $.ajax({ | |
| url: constants.formBase+"/extSubscribe/"+constants.slug, | |
| type: 'POST', | |
| data: params, | |
| success:function(response){ | |
| $p.removeClass('saving').hide().parents(".layoutGrp:first").addClass('subscribed'); | |
| $(".wakefield-success").fadeIn(300); | |
| }, | |
| error:function(){ | |
| $p.removeClass('saving'); | |
| // alert('There was an error ') | |
| } | |
| }); | |
| }); | |
| if($("input.subscribe-email").length > 0){ | |
| $("input.subscribe-email").keyup(function(e){ | |
| if(e.keyCode==13){//submit on enter. | |
| $(this).parents(".subscribe-signup-area:first").find(".subscribe-signup").click(); | |
| } | |
| }); | |
| $("input.subscribe-email").attr("placeholder",'Enter email address.'); | |
| } | |
| $("#contact-event-organizer").on('click',"#send-contact-org-note",function(event){ | |
| event.preventDefault(); | |
| _gaq.push(['_trackEvent', 'Splash', 'SendANoteSubmit', 'id:'+constants.event_id]); | |
| var params = { | |
| name: $("#contact-org-name").val(), | |
| note: $.trim($("#contact-org-note").val()), | |
| email: $("#contact-org-email").val(), | |
| company: $("#contact-org-company").val(), | |
| eventid: constants.event_id | |
| }; | |
| if ( !isValidEmail(params.email) ){ | |
| $("#contact-org-required").text('Please enter a valid email address.'); | |
| $("#contact-org-email").focus(); | |
| } else if ( params.note == '' ){ | |
| $("#contact-org-required").text('Please fill out a message to send.'); | |
| $("#contact-org-note").focus(); | |
| } else { | |
| var $this = $(this); | |
| $this.text('Sending...'); | |
| $.ajax(constants.formBase+"/splash/sendANote/",{ | |
| type:'POST', | |
| data: params, | |
| dataType: 'json', | |
| success: function(response){ | |
| if(typeof response.success!=='undefined'){ | |
| $this.text('Sent!'); | |
| setTimeout(function(){ | |
| $this.text('Send Note'); | |
| closeSimpleModal(); | |
| //setTimeout(function(){ | |
| // },2000); | |
| },3000); | |
| $("#contact-org-required").text(''); | |
| } else if(typeof response.error!=='undefined'){ | |
| $("#contact-org-required").html(response.error); | |
| $this.text('Send Note'); | |
| } else{ | |
| alert('There was an error sending your message. Please try again.'); | |
| $this.text('Send Note'); | |
| } | |
| }, | |
| error: function(response){ | |
| alert('There was an error sending your message. Please try again.'); | |
| $this.text('Send Note'); | |
| } | |
| }); | |
| } | |
| }); | |
| if(typeof constants.viewer!=='undefined'){ | |
| $("#rsvp-first-name").val(constants.viewer.first_name); | |
| $("#rsvp-last-name").val(constants.viewer.last_name); | |
| $("#rsvp-email").val(constants.viewer.email); | |
| } | |
| if(typeof constants.rsvp_form_field_values!=='undefined'){ | |
| for (var key in constants.rsvp_form_field_values) { | |
| var value = constants.rsvp_form_field_values[key]; | |
| if (key == 'first_name') { | |
| $("#rsvp-first-name").val(value); | |
| } else if (key == 'last_name') { | |
| $("#rsvp-last-name").val(value); | |
| } else if (key == 'email') { | |
| $("#rsvp-email").val(value); | |
| // custom fields | |
| } else { | |
| var num = key.replace('custom_field_',''); | |
| var $input = $('#rsvp-form-inner').find('input[num="'+num+'"]:first'); | |
| if ($input.length == 1) { | |
| var type = $input.attr('type') || false; | |
| if (type == 'text' || type == 'hidden') { | |
| $input.val(value); | |
| } else if (type == 'radio' || type == 'checkbox') { | |
| var set = false; | |
| $('#rsvp-form-inner').find('input[num="'+num+'"]').each(function(){ | |
| var $this = $(this); | |
| if ($this.attr('type') == type && $this.val() == value) { | |
| $this.attr('checked','checked'); | |
| set = true; | |
| } else { | |
| $this.removeAttr('checked'); | |
| } | |
| }); | |
| // other | |
| if (set == false) { | |
| var $input = $('#rsvp-form-inner').find('input[num="'+num+'"].other-input-field'); | |
| if ($input.length == 1) { | |
| $('#rsvp-form-inner').find('input[num="'+num+'",value="include_other_opt"]').attr('checked','checked'); | |
| $input.val(value); | |
| } | |
| } | |
| } | |
| } else { | |
| var $input = $('#rsvp-form-inner').find('textarea[num="'+num+'"]:first,'); | |
| if ($input.length == 1) { | |
| $input.val(value); | |
| } else { | |
| var $input = $('#rsvp-form-inner').find('select[num="'+num+'"]:first,'); | |
| if ($input.length == 1) { | |
| $input.val(value); | |
| } else { | |
| var $input = $('<input id="custom-'+num+'" class="custom optional" num="'+num+'" name="custom_field_'+num+'" type="hidden" />'); | |
| $input.val(value); | |
| $('#rsvp-form-inner').append($input); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| $(document).on('click','.closeSimpleModal,a.close-modal-link,a.close-modal',function(event){ | |
| event.preventDefault(); | |
| closeSimpleModal(); | |
| }); | |
| if($("#checkin-password-prompt").length > 0){ | |
| $("#checkin-password-prompt").fireSimpleModal({ persistent: true }); | |
| $("#checkin-page-code").keyup(function(e){ | |
| if(e.keyCode==13){ | |
| $("#checkin-password-save").click(); | |
| } | |
| }); | |
| $("#checkin-password-save").click(function(){ | |
| var $this = $(this); | |
| if($this.hasClass('in-progress')){ | |
| return false; | |
| } | |
| $this.addClass('in-progress').text('Checking...'); | |
| $.ajax(constants.formBase+"/splash/checkinPassword/"+constants.event_id, | |
| { | |
| type: 'POST', | |
| data: { code: $("#checkin-page-code").val() }, | |
| dataType:'json', | |
| success: function(response){ | |
| if(typeof response.success!=='undefined'){ | |
| $("#checkin-password-response").hide(); | |
| document.location.reload(); | |
| } else{ | |
| $this.removeClass('in-progress').text('Submit'); | |
| $("#checkin-password-response").hide().text('Invalid password').fadeIn(); | |
| } | |
| }, | |
| error:function(){ | |
| alert('There was an error submitting your data. Please try again (#102)'); | |
| $this.removeClass('in-progress').text('Submit'); | |
| } | |
| }); | |
| }); | |
| } | |
| // NEW -- GOOD -- DONT DELETE ME -- <3 Clay | |
| if( $('body').hasClass('private') ) { | |
| var newFooterTop = $(window).height() - $('#footer').height() - $('#footer').css('padding-top').replace('px', '') - $('#footer').css('padding-bottom').replace('px', ''); | |
| $('#footer').css('top', newFooterTop+'px'); | |
| $(window).resize(function(){ | |
| var newFooterTop = $(window).height() - $('#footer').height() - $('#footer').css('padding-top').replace('px', '') - $('#footer').css('padding-bottom').replace('px', ''); | |
| $('#footer').css('top', newFooterTop+'px'); | |
| }); | |
| //moved into privacy check | |
| $("input.age-input").keydown(function(event){ | |
| var allowed = [46,8,9,188,37]; //allow backspace,delete,tab,period,left,right,comma | |
| if($.inArray(event.keyCode,allowed)<0 ){ | |
| if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )){ | |
| // Not a number or allowed keystroke so stop them! | |
| event.preventDefault(); | |
| } | |
| } | |
| }).keyup(function(event){ | |
| if(event.keyCode == 13){ | |
| if($(this).prop("id")=='age-yy'){ | |
| $("#access-code-form").submit(); | |
| } | |
| else{ | |
| event.preventDefault(); | |
| $(this).next().focus(); | |
| return; | |
| } | |
| } | |
| var allowed = [46,8,9,188,37]; //allow backspace,delete,tab,period,left,right,comma | |
| var $this= $(this); | |
| if($this.val().length == $this.prop("maxlength")){ | |
| if($.inArray(event.keyCode,allowed)<0 ){ | |
| $(this).next().focus(); | |
| } | |
| } | |
| }); | |
| $("#access-code-form").submit(function(){ | |
| var $code_input = $("#access-code-input"); | |
| if($("#age-mm").length > 0){ | |
| var match = false; | |
| $("input.age-input").each(function(){ | |
| if($(this).val().length!=$(this).prop("maxlength")){ | |
| $("#access-code-error").html('Please enter a valid date of birth.').fadeIn('fast'); | |
| $(this).focus(); | |
| match=true; | |
| return false; | |
| } | |
| }); | |
| if(match){ | |
| return false; | |
| } | |
| } | |
| if($code_input.length && $code_input.val() == ''){ | |
| if($code_input.hasClass('email_access')){ | |
| $("#access-code-error").html('<br>Please enter your email address to continue.').fadeIn('fast'); | |
| } else { | |
| $("#access-code-error").html('<br>Please enter the access code to continue.').fadeIn('fast'); | |
| } | |
| $("#access-code-input").focus(); | |
| return false; | |
| } | |
| }); | |
| } | |
| $("#splash-container").find(".element").each(function(){ | |
| var $t = $(this); | |
| if($t.prop("id")){ | |
| $t.parents(".layoutGrp:first").addClass($t.prop("id")); | |
| } | |
| }); | |
| $("a.nav-jump").click(function(event){ | |
| if(!$("body").hasClass('finetune')){ | |
| var $t = $(this); | |
| if($t.prop("target")!='_blank' && $t.prop("target")!='_self'){//if linking out, use _self. | |
| jumpToNavBlock($t,event); | |
| return false; | |
| } | |
| } | |
| }); | |
| $('table.ticketTypeTable').on('click','span.showDetails',function(){ | |
| $(this).parents('tbody').find('tr.prefs').toggle(); | |
| }); | |
| if($('#main-canvas').find('.ticker').length > 0){ | |
| $('.ticker .ticker-item').hide() | |
| fadeTickerItems() | |
| } | |
| if( $('body').hasClass('hasVidBG') && ! $('body').hasClass('finetune') ){ | |
| var tag = document.createElement('script'); | |
| tag.src = "/js/vidBG.js"; | |
| tag.id = "ytAPIsrc"; | |
| //console.log('inserting vidbg js') | |
| var firstScriptTag = document.getElementsByTagName('script')[0]; | |
| firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | |
| } | |
| if(typeof navPos!=='undefined' && navPos!==false && !$("body").hasClass('finetune')){ | |
| $("#main-canvas").find(".nav-item").click(function(){ | |
| $(this).find("a.nav-jump").click(); | |
| return false; | |
| }); | |
| } | |
| if(constants.autosize['title']||constants.autosize['subtitle']||constants.autosize['rsvp']){ | |
| setTimeout(function(){ | |
| autoSizeContent(null); | |
| setTimeout(function(){ | |
| autoSizeContent(null,true); | |
| },100); | |
| },10); | |
| } | |
| $("#main-canvas").find(".layoutGrp").find(".carousel").each(function(){ | |
| $(this).activateCarousel(); | |
| }); | |
| $("#main-canvas").find("input.event-hub-search").each(function(){ | |
| var $search = $(this); | |
| var $block = $search.parents("div.event-hub:first"); | |
| if($block.length < 1){ | |
| $block = $("#main-canvas").find("div.event-hub:first"); | |
| } | |
| $search.keyup(function(e){ | |
| if (e.which == 13) { | |
| $search.parents("div.hubSearch:first").find(".search-btn").click();//search. | |
| return; | |
| } | |
| }); | |
| }); | |
| $("#main-canvas").on('click','.hubSearch .search-btn',function(){ | |
| var $search = $("#main-canvas").find("input.event-hub-search:first"); | |
| var term = $search.val(); | |
| var $block = $("#main-canvas").find("div.event-hub:first"); | |
| $search.parents("div.layoutGrp:first").find(".quick-links").removeClass("active");//remove any active links at this point. | |
| searchEventHub($block,term); | |
| }); | |
| $("#main-canvas").on('click',".quick-links",function(){ | |
| var $t = $(this), | |
| $block = $t.parents("div.event-hub:first"); | |
| if($block.length < 1){ | |
| $block = $("#main-canvas").find("div.event-hub:first"); | |
| } | |
| if($t.hasClass('active')){ //clear search results. | |
| $t.removeClass('active'); | |
| var term = '';//show all. | |
| } else { | |
| $t.addClass('active').siblings().removeClass('active'); | |
| var term = (''+$t.find(".term:first").text()).trim(); | |
| } | |
| //clear out. | |
| $("#main-canvas").find("input.event-hub-search").val(''); | |
| searchEventHub($block,term); | |
| }); | |
| $("#rsvp-modal").on('click','.shareBox .icon',function(e){ | |
| var type = $(this).parents(".method:first").attr("method"); | |
| _gaq.push(['_trackEvent', 'Splash', 'shareBox-'+type, 'id:'+constants.event_id]); | |
| }); | |
| $("#rsvp-modal").on('keyup','.shareBox .method[method=email] input',function(e){ | |
| if ( e.which == 13 ){ $(this).siblings('a:first').click(); } | |
| }) | |
| $("#rsvp-modal").on('click','.shareBox .method[method=email] a',function(e){ | |
| e.preventDefault(); | |
| var $this = $(this); | |
| var $parent = $this.parents(".method"); | |
| if($this.hasClass('in-progress')){ return false; } | |
| var $shareBox = $this.parents('.shareBox:first'); | |
| var $emailS = $this.siblings('input:first'); | |
| var email = $.trim($emailS.val()); | |
| var url = $this.attr('share-url'); | |
| if ( isValidEmail(email) ){ | |
| _gaq.push(['_trackEvent', 'Splash', 'EmailShareSend', 'id:'+constants.event_id]); | |
| $emailS.attr('disabled','disabled'); | |
| $this.addClass('in-progress').text('Sending...'); | |
| $.ajax(constants.formBase+'/emailShare',{type:'POST',data:{email:email,url:url},dataType:'json', | |
| success: function(response){ | |
| _gaq.push(['_trackEvent', 'Splash', 'EmailShareSuccess', 'id:'+constants.event_id]); | |
| $shareBox.find('img.loading').remove(); | |
| $emailS.val('').removeAttr('disabled'); | |
| $this.removeClass('in-progress').text('Message sent!');//show(); | |
| setTimeout(function(){ | |
| $this.text('Send message'); | |
| $parent.find(".icon:first").click(); | |
| },2500); | |
| }, | |
| error: function(){ | |
| _gaq.push(['_trackEvent', 'Splash', 'EmailShareSuccess', 'id:'+constants.event_id]); | |
| $shareBox.find('img.loading').remove(); | |
| $this.show(); | |
| $emailS.removeAttr('disabled'); | |
| },timeout: 10000 | |
| }); | |
| } | |
| else{ | |
| _gaq.push(['_trackEvent', 'Splash', 'EmailShareValidFail', 'id:'+constants.event_id]); | |
| alert('Please enter a valid Email Address.'); | |
| $emailS.select(); | |
| } | |
| }); | |
| $("#rsvp-modal").on('click','.shareBox .method[method=link] a',function(e){ | |
| _gaq.push(['_trackEvent', 'Splash', 'shareBox-LinkOpen', 'id:'+constants.event_id]); | |
| }); | |
| $("#rsvp-modal").on('click','.shareBox .closeShareBox',function(e){ | |
| var $this = $(this); | |
| _gaq.push(['_trackEvent', 'Splash', 'closeShareBox', 'id:'+constants.event_id]); | |
| var $shareBox = $this.parents('.shareBox:first'); | |
| $shareBox.animate({width:'0px'},350,'linear',function(){$shareBox.remove();}); | |
| }); | |
| $("#rsvp-modal").on('click','.shareBox .method .icon',function(e){ | |
| var $m = $(this).parent(); | |
| var $p = $m.parent(); | |
| var clear = ($p.hasClass($m.attr('n'))||$m.hasClass('jammed')); | |
| $p.find('.method').each(function(){ $p.removeClass($(this).attr('n')); }); | |
| if ( clear === false ){ | |
| $p.addClass($m.attr('n')); | |
| _gaq.push(['_trackEvent', 'Splash', 'shareBox-'+$m.attr('method'), 'id:'+constants.event_id]); | |
| } | |
| else if (!$m.hasClass('jammed')){ | |
| _gaq.push(['_trackEvent', 'Splash', 'shareBox-clear', 'id:'+constants.event_id]); | |
| } | |
| }); | |
| $(document).on('click', '#rsvp-modal .nu-checkbox > a', function(e){ | |
| // FOR NU CHECKBOXES IN THE RSVP FORM, OPEN ANY LINKS WITHIN ON CLICK OF LINK | |
| e.preventDefault(); | |
| window.open($(this).attr('href'), '_blank'); | |
| return false; | |
| }); | |
| customThemeReady() | |
| if (!!navigator.userAgent.match(/Trident\/7\./)){ | |
| $('body').addClass('isIE') | |
| console.log('is totally IE') | |
| var thisVer = $.browser.version.substring(0, 2).replace('.','') | |
| $('body').addClass('v'+thisVer) | |
| } else { | |
| $('body').removeClass('isIE') | |
| console.log('is not IE') | |
| } | |
| updateModalColors() | |
| //check for open rsvp form on load. | |
| if(typeof constants.openRsvp!=='undefined' && constants.openRsvp=='1'){ | |
| showRsvpForm(); | |
| } | |
| }); // end of document ready | |
| $('#rsvp-modal').find('.nu-checkbox').find('a').on('click', function(e){ | |
| // FOR NU CHECKBOXES IN THE RSVP FORM, OPEN ANY LINKS WITHIN ON CLICK OF LINK | |
| e.preventDefault(); | |
| window.open($(this).attr('href'), '_blank'); | |
| return false; | |
| }) | |
| var hubsearch; | |
| RegExp.escape = function(text) { return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); } | |
| function searchEventHub($block,term){ | |
| var block_id = $block.prop("id").replace('sfid-','')*1; | |
| if(isNaN(block_id)){ return; } | |
| if(typeof eventHubIds[block_id]==='undefined'){ | |
| return false; | |
| } | |
| var $all = $block.find("div.children").find("div.event-hub-item"); | |
| if(term!=null){ | |
| search = term.toLowerCase().trim(); | |
| } else { | |
| $block.find(".quick-links.active").removeClass("active"); | |
| var search = (''+$block.find("input.event-hub-search").val()).toLowerCase(); | |
| } | |
| $block.addClass('loading').removeClass('no-results results'); | |
| $all.hide(); | |
| if(search==''){ | |
| $block.removeClass('loading'); | |
| return; | |
| } | |
| if(search=='boskoff'){//skeleton key. | |
| search = ' '; | |
| } | |
| var matchingIds = []; | |
| var priorityIds = []; | |
| var re = new RegExp('('+RegExp.escape(search)+')'); | |
| for (var i in eventHubIds[block_id]) { | |
| if ((''+eventHubData[block_id][eventHubIds[block_id][i]].search).match(re)) { | |
| matchingIds.push(eventHubIds[block_id][i]); | |
| } | |
| } | |
| // if (priorityIds.length == 0 && comingSoonIds && comingSoonIds.length > 0) { | |
| // for (var i in comingSoonIds) { | |
| // if ((''+eventHubData[comingSoonIds[i]].search).toLowerCase().match(re)) { | |
| // priorityIds.push(comingSoonIds[i]); | |
| // } | |
| // } | |
| // } | |
| // // put the priority event ids at the beginning of the matching list | |
| // if (priorityIds.length > 0) { | |
| // priorityIds.reverse(); | |
| // for (var i in priorityIds) { | |
| // matchingIds.unshift(priorityIds[i]); | |
| // } | |
| // } | |
| if (matchingIds.length > 0) { | |
| //window.location.hash = ('s-'+$.trim(search)).toUpperCase(); | |
| //$evc.html(''); | |
| //$evlm.addClass('hide'); | |
| //$elrc.html(matchingIds.length); | |
| // setTimeout(function(){ | |
| // for (var z in matchingIds) { | |
| // insertEventListing(matchingIds[z],z); | |
| // if (z == 0){ | |
| // var headers = $('#onPageEventListingHeaders').clone(); | |
| // headers.attr('id','').css('display','table-row'); | |
| // $evc.append(headers) | |
| // } | |
| // } | |
| // $elbi.removeClass('loading').addClass('results').removeClass('no-results'); | |
| // $evc.css('height','auto'); | |
| // },0); | |
| console.log("matches",matchingIds); | |
| $block.removeClass('loading').addClass('results'); | |
| for(var x in matchingIds){ | |
| $("#sfid-"+matchingIds[x]).show(); | |
| } | |
| } else { | |
| // $evc.html('').css('height','auto'); | |
| // $elrc.html('0'); | |
| //$elbi.removeClass('loading').addClass('no-results').removeClass('results'); | |
| $block.removeClass('loading').addClass('no-results').removeClass('results'); | |
| } | |
| if (typeof customAfterHubSearch == 'function') { | |
| setTimeout(function(){ | |
| customAfterHubSearch(); | |
| },0); | |
| } | |
| } | |
| var $navWrap; | |
| var navPos=false; | |
| var navHeight = 0; | |
| function fadeTickerItems(){ | |
| var tickers = $('#main-canvas').find('.ticker') | |
| var animSpeed = 3000; | |
| var fadeSpeed = 1000; | |
| var fadeThisTicker = function(thisTicker){ | |
| var $t = $(thisTicker) | |
| if( ! $t.hasClass('active') ){ | |
| $t.addClass('active') | |
| //console.log('this ticker: '+i) | |
| var thisIndex = 0; | |
| var endIndex = $t.find('.ticker-item').length; | |
| //console.log('this lenght: '+endIndex) | |
| $t.find('.ticker-item:first').fadeIn(fadeSpeed) | |
| var loopThisFade = function($this){ | |
| if( ! $this.hasClass('editingTicker') ){ | |
| setTimeout(function(){ | |
| if( ! $this.hasClass('editingTicker') ){ | |
| $this.find('.ticker-item:eq('+thisIndex+')').delay(fadeSpeed).fadeOut(fadeSpeed, function(){ | |
| thisIndex++ | |
| if(thisIndex == endIndex){ | |
| thisIndex = 0; | |
| } | |
| $this.find('.ticker-item:eq('+thisIndex+')').fadeIn(fadeSpeed, function(){ | |
| loopThisFade($this) | |
| }) | |
| }) | |
| } | |
| }, animSpeed) | |
| } else { | |
| $this.find('.ticker-item').show().css('opacity', '1') | |
| loopThisFade = null | |
| } | |
| } | |
| loopThisFade($t) | |
| } | |
| } | |
| var scrollThisTicker = function(thisTicker){ | |
| var $t = $(thisTicker) | |
| if( ! $t.hasClass('active') ){ | |
| $t.addClass('active') | |
| var thisIndex = 0; | |
| var endIndex = $t.find('.ticker-item').length | |
| var scrollWidth = 0; | |
| $t.find('.ticker-item').each(function(){ | |
| scrollWidth = scrollWidth + $(this).outerWidth() | |
| }) | |
| if( scrollWidth < 5000 ){ | |
| scrollWidth = scrollWidth * 1.05 | |
| } else { | |
| scrollWidth = scrollWidth * 1.1 | |
| } | |
| var pxSpeed = 20 | |
| if( $t.parents('.layoutGrp:first').hasClass('slowScroll') ){ | |
| pxSpeed = 20 | |
| } else if( $t.parents('.layoutGrp:first').hasClass('medScroll') ) { | |
| pxSpeed = 40 | |
| } else if( $t.parents('.layoutGrp:first').hasClass('fastScroll') ) { | |
| pxSpeed = 50 | |
| } | |
| var thisSpeed = ( scrollWidth / pxSpeed ) * 1000 | |
| if( $t.find('.scrollWrap').length == 0 ){ | |
| $t.find('.children').wrapAll('<div class="scrollWrap"></div>') | |
| } | |
| $t.find('.children:last').clone().appendTo($t.find('.scrollWrap') ) | |
| if( $t.find('.children').length < 3 ){ | |
| $t.find('.children:last').clone().appendTo($t.find('.scrollWrap')) | |
| } | |
| $t.find('.scrollWrap').css({'width': ( scrollWidth*3.25 ) +'px'}) | |
| //$t.css({ 'left':'100%', 'position':'relative' }).animate({ 'left':"-100%" }, thisSpeed, 'linear', moveScroll); | |
| $t.find('.children').css({'width':'auto', 'position':'relative'}) | |
| $t.find('.children:first').animate({ 'margin-left':"-"+ scrollWidth +"px" }, thisSpeed, 'linear', flipClones); | |
| function moveScroll(){ | |
| $t.find('.children:first').animate({ 'margin-left':"-"+ scrollWidth +"px" }, thisSpeed, 'linear', flipClones); | |
| } | |
| function flipClones(){ | |
| if( ! $t.hasClass('editingTicker') ){ | |
| $t.find('.scrollWrap .children:first').insertAfter($t.find('.scrollWrap .children:last')) | |
| $t.find('.children').css({'margin-left':'0px'}) | |
| moveScroll() | |
| } | |
| } | |
| } | |
| } | |
| for(var i=0; i<tickers.length; i++){ | |
| if( ! $(tickers[i]).hasClass('editingTicker') && ! $(tickers[i]).hasClass('active') ){ | |
| $item = $(tickers[i]).find('.ticker-item') | |
| if( $item.hasClass('tickerFade') ){ | |
| fadeThisTicker(tickers[i]) | |
| } else if( $item.hasClass('tickerScroll') ) { | |
| $(tickers[i]).addClass('scrollBlock') | |
| scrollThisTicker(tickers[i]) | |
| } | |
| } | |
| } | |
| } | |
| function getValuesObjFromForm($form){ | |
| var formArray = $form.serializeArray(); | |
| var form = {}; | |
| for ( i in formArray ){ | |
| var keyVal = formNameValueToObj(formArray[i].name,formArray[i].value); | |
| if ( typeof form[keyVal.key] != 'undefined' ){ | |
| form[keyVal.key] = $.extend(form[keyVal.key],keyVal.value); | |
| } | |
| else { | |
| form[keyVal.key] = keyVal.value; | |
| } | |
| } | |
| return form; | |
| } | |
| // this function makes an assoc array (object) from name="someName[index][someIndex]" .. // handy | |
| function formNameValueToObj(name,value){ | |
| var ret = { key: '', value: false }; | |
| var tmp = name.split(/\[/); | |
| if ( tmp.length == 1 ){ | |
| ret.key = name.replace(/\]/,''); | |
| ret.value = value; | |
| }else{ | |
| ret.key = tmp.shift().replace(/\]/,''); | |
| var keyVal = formNameValueToObj(tmp.join('['),value); | |
| ret.value = {}; | |
| ret.value[keyVal.key] = keyVal.value; | |
| } | |
| return ret; | |
| } | |
| function resetScroll(){ | |
| $('.ticker.scrollBlock .children').append( $('.tickerScroll:first') ) | |
| moveBG() | |
| } | |
| function moveBG(){ | |
| var left = $('.tickerScroll').offset().left; | |
| $('.tickerScroll').css({ 'left':left+"px" }); | |
| $('.tickerScroll').animate({ 'left':"-1000px" }, 8000, 'linear', resetScroll); | |
| } | |
| var cIn = false; | |
| var cFadeLock = false; | |
| //var $ctrl = $('div.v-ctrl'); | |
| // function fadeCtrl(){ | |
| // if ( !cIn && !cFadeLock && !$('#sound').hasClass('big') ) { | |
| // $ctrl.fadeOut(); | |
| // } | |
| // } | |
| var videoPlayer = {pause:function(){}}; | |
| var duration; var minutes; var seconds; var currentTime; var c_minutes; var c_seconds; | |
| var headerVideoInited = false; | |
| $.fn.textfill = function(options) { | |
| var fontSize = options.maxFontPixels; | |
| var minFontSize = 3; | |
| if(typeof options.minFontPixels !== 'undefined'){ | |
| minFontSize = options.minFontPixels; | |
| } | |
| var ourText = $('span:visible:first', this); | |
| var maxHeight = $(this).height(); | |
| var maxWidth = $(this).width(); | |
| var textHeight; | |
| var textWidth; | |
| do { | |
| ourText.css('font-size', fontSize+'px'); | |
| textHeight = ourText.height(); | |
| textWidth = ourText.width(); | |
| fontSize = fontSize - 1; | |
| } while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize >= minFontSize); | |
| if(options.comeBackUp && fontSize <= minFontSize && (textHeight > maxHeight || textWidth > maxWidth)){ | |
| maxHeight = maxHeight * 2;//textHeight; //set maxHeight up to current height | |
| $(this).css('height',maxHeight+'px'); | |
| do{ | |
| fontSize = fontSize + 1; | |
| ourText.css('font-size', fontSize+'px'); | |
| textHeight = ourText.height(); | |
| textWidth = ourText.width(); | |
| } | |
| while ((textHeight <= maxHeight) && fontSize < options.maxFontPixels ); | |
| ourText.css('font-size',(fontSize-1)+'px'); | |
| } | |
| return this; | |
| } | |
| $("#save-splash-theme").click(function(){ | |
| var params = { event_id: constants.event_id, theme: $("#splash-theme-selector").find("a.active").parents("li").attr("codename") } | |
| $(this).text('Saving...'); | |
| $.post("/events/saveSplashTheme", params, function(response){ | |
| window.location = constants.formBase; | |
| }); | |
| }); | |
| /******************************* | |
| * Photo Gallery functionality * | |
| *******************************/ | |
| var galleryOpen = false; | |
| var currentPhotoId = 0; | |
| var gBlankHtml; | |
| function galleryInit(){ | |
| if ( $("#gallery-thumbs div.photo-thumb").length > 0 ){ | |
| var $gBlank = $('#gallery').find('div.photo:first'); | |
| $gBlank.detach(); | |
| gBlankHtml = '<div photo-id=":id:" n=":i:" class="photo :type:">'+$gBlank.html()+'</div>'; | |
| for ( i in galleryImages ){ | |
| galleryI[galleryImages[i]['id']] = parseInt(i) + 1; | |
| } | |
| //checks for clicking off gallery photos (easy close) | |
| $(document).on({ | |
| mouseenter: function(){ | |
| $(this).addClass('activeLI'); | |
| }, | |
| mouseleave: function(){ | |
| $(this).removeClass('activeLI'); | |
| } | |
| }, "div.photos div.photo" | |
| ); | |
| $("div.photos").click(function(){ | |
| if($("div.activeLI").length < 1){ | |
| hideTheGallery(); | |
| } | |
| }); | |
| if ( typeof adminSort == 'undefined' ){ | |
| $(document).on('click',"div.photo-thumb",function(){ | |
| //if($(this).hasClass('sort')){ | |
| // return false; //dont fire if in sort mode. | |
| //} | |
| if($("#finetune-block").length){ | |
| return false; //dont sort in finetune mode. | |
| } | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryOpenThumb', 'id:'+constants.event_id+' pid:'+$(this).find('img.th').attr('photo-id')]); | |
| if($(this).hasClass('quote-link')){ | |
| //window.open($(this).find("table.quote-table").attr("link-to"),'_blank'); | |
| showTheGallery($(this).find('img.th').attr('photo-id')); | |
| } | |
| else{ | |
| showTheGallery($(this).find('img.th').attr('photo-id')); | |
| } | |
| }); | |
| } | |
| setTimeout(function(){ | |
| galleryThumbFlow(); | |
| },1000); | |
| $("#gallery .mask-below, #gallery .actions .close").click(function(){ | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryClose', 'id:'+constants.event_id]); | |
| hideTheGallery(); | |
| }); | |
| currentPhotoId = $("#gallery div.photos div.photo:first").attr('photo-id'); | |
| $("#gallery .actions .next,#gallNext").click(function(){ | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryNext', 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| galleryNext(); | |
| }); | |
| $("#gallery .photo-count .first").click(function(){ | |
| var photoId = galleryI[0]; | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryFirst', 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| showTheGallery(photoId); | |
| }); | |
| $("#gallery .photo-count .last").click(function(){ | |
| var photoId = galleryI[galleryI.length-1]; | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryLast', 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| showTheGallery(photoId); | |
| }); | |
| $("#gallery .actions .prev,#gallPrev").click(function(){ | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryPrev', 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| galleryPrevious(); | |
| }); | |
| $("#gallery .actions .playPause").click(function(){ | |
| if ( $(this).find('.play').hasClass('hide') ){ | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryStop', 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| // show play, hide pause, stop slideshow | |
| $(this).find('.play').removeClass('hide'); | |
| $(this).find('.pause').addClass('hide'); | |
| stopGallerySlideshow(); | |
| }else{ | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryPlay', 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| // hide play, show pause, start slideshow | |
| $(this).find('.play').addClass('hide'); | |
| $(this).find('.pause').removeClass('hide'); | |
| startGallerySlideshow(); | |
| } | |
| }); | |
| $(document).on('click','.pinterestShare',function(){ | |
| var n = $(this).attr('n'); | |
| _gaq.push(['_trackEvent', 'Splash', 'PhotoPinterest', 'id:'+constants.event_id+' n:'+n]); | |
| href="http://pinterest.com/pin/create/button/?media="; | |
| var imgSrc = $(this).parents('li:first').find('img.ph').attr('src'); | |
| if ( imgSrc[0] == '/'){ | |
| href+=encodeURIComponent('http://'+gallVars['domain']+imgSrc); | |
| }else{ | |
| href+=encodeURIComponent(imgSrc); | |
| } | |
| href+="&url="; | |
| href+= $(this).parent().attr('share-url'); | |
| href+="&alt=alt&title="; | |
| href+=gallVars['urlencodedtitle']; | |
| href+="&is_video=false" | |
| window.open(href,'Pinterest','width=590,height=360'); | |
| return false; | |
| }); | |
| $(document).keyup(function(e){ | |
| if ( galleryOpen ){ | |
| var keyCode = e.which; | |
| if ( keyCode == 37 || keyCode == 38 ) { // left arrow or up arrow | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryKeyPrevious', 'id:'+constants.event_id+' k:'+keyCode]); | |
| galleryPrevious(); | |
| }else if ( keyCode == 39 || keyCode == 40 ) { // right arrow or down arrow | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryKeyNext', 'id:'+constants.event_id+' k:'+keyCode]); | |
| galleryNext(); | |
| }else if ( keyCode == 27 ) { // escape | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryKeyEsc', 'id:'+constants.event_id+' k:'+keyCode]); | |
| hideTheGallery(); | |
| } | |
| } | |
| }); | |
| var $_GET = getQueryParams(document.location.search); | |
| if ( window.location.hash && window.location.hash.match(/^#p[0-9]+/) ){ | |
| var index = parseInt(window.location.hash.replace(/^#p/,'')); | |
| _gaq.push(['_trackEvent', 'MobileSplash', 'GalleryAutoOpenHash', 'id:'+constants.event_id+' p:'+index]); | |
| if ( index <= galleryImages.length ){ | |
| setTimeout('showTheGallery(1,'+index+')',1000); | |
| }else{ // //console.log('choke'); | |
| } | |
| } | |
| else if ( $_GET.p && !isNaN(parseInt($_GET.p)) && isFinite($_GET.p) ){ | |
| var index = parseInt($_GET.p); | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryAutoOpenShared', 'id:'+constants.event_id+' g:'+index]); | |
| if ( index <= galleryImages.length ){ | |
| setTimeout('showTheGallery(1,'+index+')',1000); | |
| }else{ //console.log('choke'); | |
| } | |
| } | |
| else if ( $_GET.i && !isNaN(parseInt($_GET.i)) && isFinite($_GET.i) ){ | |
| var photoid = parseInt($_GET.i); | |
| var index = false; | |
| if ( galleryI[photoid] ){ | |
| index = galleryI[photoid]; | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryAutoOpenShared', 'id:'+constants.event_id+' g:'+index]); | |
| setTimeout('showTheGallery(1,'+index+')',1000); | |
| }else{ //console.log('choke'); | |
| } | |
| } | |
| if ( $_GET.d && !isNaN(parseInt($_GET.d)) && isFinite($_GET.d) ) {photoLoadDelay = $_GET.d*1000;lzD=photoLoadDelay; } | |
| if ( $_GET.party ) { partyMode = true; setTimeout(function(){ checkForNewPhotos();}, 5000); } | |
| //if ( constants.domain == 'rockyourpalate.splashthat.com' ) { partyMode = true; setTimeout(function(){ checkForNewPhotos();}, 5000); } | |
| if ( typeof $_GET.expired != 'undefined' ) { | |
| $('#rsvp-button').click(); | |
| $('.rsvp-form .required-fields').css({'font-family':'Helvetica','font-size':'12px'}).html('Your order expired').show(); | |
| } | |
| $("#splash-container").on('click','.stickyMedia',function(e){ | |
| var $s = $('#stickyMedia'); | |
| $s.empty().show();//.append('<span class="close">✖</span>'); | |
| $s.css({ bottom:'auto', left: $(this).offset().left, top: ($(this).offset().top - $(window).scrollTop()), width: $(this).width(), height: $(this).height(), border: '2px dotted #333333', background: '#ffffff'}); | |
| var targetWidth = $(this).attr('w'); | |
| var targetHeight = $(this).attr('h'); | |
| var content = false; | |
| if ( $(this).attr('content') != undefined ){ | |
| content = $(this).attr('content'); | |
| }else if ( $(this).attr('video-url') != undefined ){ | |
| var vUrl = $(this).attr('video-url'); | |
| for ( x in videoUrlElements ){ | |
| if ( vUrl.match(RegExp(videoUrlElements[x]['reg'])) ){ | |
| content = videoUrlElements[x]['element'].replace(/:video-url:/g,vUrl); | |
| $c = $(content); | |
| if ( $c.attr('content') != undefined ){ | |
| content = $c.attr('content'); | |
| targetHeight = $c.attr('h'); | |
| targetWidth = $c.attr('w'); | |
| } | |
| break; | |
| } | |
| } | |
| } | |
| if ( content !== false ){ | |
| $s.animate({top:($(window).height()-targetHeight),left:(($(window).width()/2)-(targetWidth/2)),width:targetWidth,height:targetHeight},{duration: 1000, complete: function(){ | |
| $s.append(content+'<span class="close">✖</span>'); | |
| $s.css({bottom:0,top:'auto',border:0}); | |
| }}); | |
| stickyOn = true; | |
| } | |
| return false; // to stop the bubble up | |
| }); | |
| $("#splash-container").on('click','#stickyMedia .close',function(){ | |
| $('#stickyMedia').empty().hide(); | |
| stickyOn = false; | |
| }); | |
| } | |
| } | |
| $(document).on('click','.facebookShare',function(){ | |
| var n = $(this).attr('n'); | |
| if ( typeof n != 'undefined' ) | |
| _gaq.push(['_trackEvent', 'Splash', 'PhotoFacebook', 'id:'+constants.event_id+' n:'+n]); | |
| var href=$("#fb-link").prop("href"); | |
| ///gallVars['facebookShareUrl']; | |
| var $p = $(this).parent(); | |
| href+="&link="+$p.attr('share-url'); | |
| if(typeof $p.attr("share-desc")!=='undefined'){ | |
| href+="&desc="+$p.attr("share-desc"); | |
| } | |
| if(typeof $p.attr("picture")!=='undefined'){ | |
| href+="&picture="+$p.attr("picture"); | |
| } | |
| //href+="&name="+gallVars['urlencodedtitle']; | |
| window.open(href,'Facebook','width=400,height=250'); | |
| return false; | |
| }); | |
| $(document).on('click','.twitterShare',function(){ | |
| var n = $(this).attr('n'); | |
| if ( typeof n != 'undefined' ) | |
| _gaq.push(['_trackEvent', 'Splash', 'PhotoTwitter', 'id:'+constants.event_id+' n:'+n]); | |
| var href=$("#twitter-link").prop("href");//gallVars['twitterShareUrl']; | |
| //href+="&url="+$(this).parent().attr('share-url'); | |
| window.open(href,'Twitter','width=400,height=400'); | |
| return false; | |
| }); | |
| $(document).on('click','.urlShare',function(e){ | |
| e.preventDefault(); | |
| var $this = $(this); | |
| if ( $this.find('input').length == 0 ){ | |
| var $p = $('<input type="text" />'); | |
| $p.css({ width: '171px',fontFamily: 'Arial,sans-serif', fontSize: '12px',position: 'absolute', right: '108px', top: '52px', background: '#eeeeee', display: 'inline-block'}); | |
| $p.attr('disabled',true); | |
| $p.val($this.attr('href')); | |
| $this.append($p); | |
| $p.select(); | |
| }else { | |
| $this.find('input').remove(); | |
| } | |
| return false; | |
| }); | |
| $(document).on('click','a.backToTop',function(event){ | |
| event.preventDefault(); | |
| $("html, body").animate({ scrollTop: 0 }, 300); | |
| return false; | |
| }); | |
| var stickyOn = false; | |
| window.onbeforeunload = function (evt) { | |
| if ( stickyOn ){ | |
| var message = 'Looks like you might be listening to some tunes here.'; | |
| if (typeof evt == undefined) { | |
| evt = window.event; | |
| } | |
| if (evt) { | |
| evt.returnValue = message; | |
| } | |
| return message; | |
| } | |
| } | |
| function getQueryParams(qs) { | |
| qs = qs.split("+").join(" "); | |
| var params = {}, | |
| tokens, | |
| re = /[?&]?([^=&]+)=?([^&]*)?/g; | |
| while (tokens = re.exec(qs)) { | |
| params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); | |
| } | |
| return params; | |
| } | |
| function hideTheGallery(){ | |
| $("body").css('overflow','auto'); | |
| galleryOpen = false; | |
| $("#gallery").fadeOut(400,function(){$(this).find('div.photos').empty();}); | |
| window.location.hash = ''; | |
| stopGallerySlideshow(); | |
| } | |
| var gallerySliding = false; | |
| function startGallerySlideshow(){ | |
| gallerySliding = true; | |
| slideGallery(); | |
| } | |
| function slideGallery(){ | |
| if ( gallerySliding ){ | |
| galleryNext(); | |
| _gaq.push(['_trackEvent', 'Splash', 'GalleryPlaySlide', 'id:'+constants.event_id+' pid:'+currentPhotoId]); | |
| setTimeout(function(){ | |
| slideGallery(); | |
| },5000); | |
| } | |
| } | |
| function stopGallerySlideshow(){ | |
| gallerySliding = false; | |
| } | |
| var galleryI = {}; | |
| var $gallery; | |
| function showTheGallery(photoId,n,action){ | |
| if ( typeof collapseStickyOnGaleryOpen != undefined ) $('#stickyMedia').addClass('closed'); | |
| videoPlayer.pause(); | |
| $("body").css('overflow','hidden'); | |
| $gallery = $("#gallery"); | |
| $gallery.find('div.photos').empty(); | |
| $gallery.fadeIn(); | |
| galleryOpen = true; | |
| var $ul = $gallery.find('div.photos'); | |
| if ( photoId ){ | |
| // insert in the photo lis | |
| if ( typeof n == 'undefined' ) | |
| var n = galleryI[photoId]; | |
| var $main = newPhotoLi(n); | |
| $main.addClass('active loaded') | |
| .find('.caption,.credit,.share').removeClass('hide').end(); | |
| $ul.append($main); | |
| positionPhotoLi(n,0); | |
| loadPhoto(n,0,$main); | |
| var np1 = n+1; | |
| if ( np1 == ( galleryImages.length + 1 )&& galleryImages.length != 1 ) np1 = 1; | |
| var $nPOne = newPhotoLi(np1); | |
| if ( $nPOne !== false ){ | |
| $ul.append($nPOne); | |
| loadPhoto(np1,1,$nPOne); | |
| positionPhotoLi(np1,1,$nPOne); | |
| } | |
| if ( galleryImages.length !=2 ){ | |
| var nm1 = n-1; | |
| if ( nm1 == 0&& galleryImages.length != 1 ) nm1 = galleryImages.length; | |
| var $nMOne = newPhotoLi(nm1); | |
| if ( $nMOne !== false ){ | |
| $ul.append($nMOne); | |
| loadPhoto(nm1,-1,$nMOne); | |
| positionPhotoLi(nm1,-1,$nMOne); | |
| } | |
| } | |
| $("#gallery .photo-count span.current").text(n); | |
| } | |
| } | |
| function galleryNext(){ | |
| var p0 = parseInt($gallery.find('div.photo[p=0]').attr('n')); | |
| var p1 = parseInt($gallery.find('div.photo[p=1]').attr('n')); | |
| if ( isNaN(p1) || isNaN(p0) ) return false; | |
| // remove n-1 | |
| $('#gallery').find('div.photos div.photo[p=-1]').remove(); | |
| // move n into -1 | |
| positionPhotoLi(p0,-1); | |
| // move n+1 into 0 | |
| positionPhotoLi(p1,0); | |
| // create and append new +1 | |
| var newnp2 = p0 + 2; | |
| if ( newnp2 == ( galleryImages.length + 1 ) ) newnp2 = 1; | |
| else if ( newnp2 == ( galleryImages.length + 2 ) ) newnp2 = 2; | |
| if ( galleryImages.length != 2 ){ | |
| var $nP = newPhotoLi(newnp2); | |
| $gallery.find('div.photos').append($nP); | |
| positionPhotoLi(newnp2,1,$nP); | |
| loadPhoto(newnp2,1,$nP); | |
| } | |
| } | |
| function galleryPrevious(){ | |
| var p0 = parseInt($gallery.find('div.photo[p=0]').attr('n')); | |
| var pm1 = parseInt($gallery.find('div.photo[p=-1]').attr('n')); | |
| if ( isNaN(pm1) || isNaN(p0) ) return false; | |
| //console.log(p0); | |
| //console.log(pm1); | |
| //console.log(currentNP); | |
| // remove +1 | |
| $('#gallery').find('div.photos div.photo[p=1]').remove(); | |
| // move n into +1 | |
| positionPhotoLi(p0,1); | |
| // move n-1 into 0 | |
| positionPhotoLi(pm1,0); | |
| // create and append new -1 | |
| var newnm2 = p0 - 2; | |
| if ( newnm2 == 0 ) newnm2 = galleryImages.length; | |
| else if ( newnm2 == -1 ) newnm2 = galleryImages.length - 1; | |
| //console.log(newnm2); | |
| if ( galleryImages.length != 2 ){ | |
| var $nM = newPhotoLi(newnm2); | |
| $gallery.find('div.photos').append($nM); | |
| positionPhotoLi(newnm2,-1,$nM); | |
| loadPhoto(newnm2,-1,$nM); | |
| } | |
| } | |
| function newPhotoLi(n){ | |
| var newHtml = gBlankHtml.replace(/:i:/g,n); | |
| if ( galleryImages[n-1] ) { | |
| for ( x in galleryImages[n-1] ){ | |
| if ( x == 'credit' ){ | |
| var credit = galleryImages[n-1][x]; | |
| if ( galleryImages[n-1].otype == 'twitter' ){ | |
| credit = '@'+credit+'<br>via Twitter'; | |
| } | |
| else if ( galleryImages[n-1].otype == 'instagram' ){ | |
| credit = '@'+credit+'<br>via Instagram'; | |
| } | |
| else if ( galleryImages[n-1].otype == 'facebook' ){ | |
| credit = '@'+credit+'<br>via Facebook'; | |
| } | |
| if ( credit != '' ) credit = 'By '+credit; | |
| newHtml = newHtml.replace(RegExp(':'+x+':','g'),credit); | |
| } | |
| else { | |
| newHtml = newHtml.replace(RegExp(':'+x+':','g'),galleryImages[n-1][x]); | |
| } | |
| } | |
| for ( x in gallVars ){ | |
| newHtml = newHtml.replace(RegExp(':'+x+':','g'),gallVars[x]); | |
| } | |
| var $n = $(newHtml); | |
| if ( galleryImages[n-1]['video-url'] != '' ){ | |
| for ( x in videoUrlElements ){ | |
| if ( galleryImages[n-1]['video-url'].match(RegExp(videoUrlElements[x]['reg'])) ){ | |
| var ele = videoUrlElements[x]['element'].replace(/:video-url:/g,galleryImages[n-1]['video-url']); | |
| $n.find('img.ph').after(ele); | |
| break; | |
| } | |
| } | |
| } | |
| //console.log($n.html()); | |
| if ( typeof FB != 'undefined' ) FB.XFBML.parse($n.find('span.comment')[0]); | |
| return $n; | |
| }else{ | |
| return false; | |
| //var $n = $(newHtml); | |
| //console.log('choke'); | |
| //showTheGallery(1,n); | |
| } | |
| } | |
| galleryNP = { n:0, np1:0, nm1:0, np2:0, nm2:0 }; | |
| function positionPhotoLi(n,p,$li){ | |
| //console.log('positioning '+n+','+p); | |
| if ( typeof($li) == 'undefined' ) $li = $('#gallery').find('div.photos div.photo[n='+n+']'); | |
| if ( typeof(p) == 'undefined' && $li ) p = $li.attr('p'); | |
| if ( galleryImages[n-1] ){ | |
| if ( $li.length > 0 ){ | |
| $li.attr('p',p); | |
| if ( p == 0 ){ | |
| galleryNP.n = n; | |
| $li.css({right:'auto',left:'auto',zIndex:2,overflow:'visible'}); | |
| $li.siblings('div.photo').removeClass('active').find("span.share,span.credit,span.caption,.fb-wrap").addClass('hide'); | |
| $li.addClass('active').find("span.share,span.credit,span.caption").removeClass('hide'); | |
| if ( $li.hasClass('sized') || $li.hasClass('loaded') ){ | |
| $("#gallery").find("div.secondary").html('<img src="'+galleryImages[n-1]['src']+'" />'); | |
| $("#gallery").find("div.mask.primary").animate({opacity: 0},{duration: 0, complete:function(){ | |
| $('#gallery').find('div.secondary').removeClass('secondary').addClass('primary'); | |
| $(this).addClass('secondary').removeClass('primary'); | |
| $(this).css('opacity',1); | |
| }}); | |
| }else{ setTimeout('positionPhotoLi('+n+')',500); } | |
| $("#gallery .photo-count span.current").text(n); | |
| }else if ( p == 1 ){ | |
| galleryNP.np1 = n; | |
| var newLeft = $(window).width() - 100; | |
| $li.css({right:'auto',zIndex:1,overflow:'hidden'}); | |
| $li.animate({ left: newLeft },{ duration: 0, complete: function(){ | |
| }}); | |
| }else if ( p == -1 ){ | |
| galleryNP.nm1 = n; | |
| var newRight = $(window).width() - 100; | |
| $li.css({left:'auto',zIndex:1,overflow:'hidden'}); | |
| $li.animate({ right: newRight },{ duration: 0, complete: function(){ | |
| }}); | |
| }else if ( p == 2 ){ | |
| galleryNP.np2 = n; | |
| $li.css('left',$(window).width() + 200); | |
| }else if ( p == -2 ){ | |
| galleryNP.nm2 = n; | |
| $li.css('left',$(window).width() + 200); | |
| } | |
| }//else{//console.log('nope');} | |
| }else{ | |
| $li.css('left',$(window).width() + 200); | |
| $li.attr('p',p); | |
| } | |
| setImageOrientation($li); | |
| } | |
| var photoLoadDelay = 0; | |
| var loadedPhotos = []; | |
| function loadPhoto(n,p,$li){ | |
| if ( typeof($li) == 'undefined' ) $li = $('#gallery').find('div.photos div.photo[n='+n+']'); | |
| if ( galleryImages[n-1] && $.inArray(n,loadedPhotos) == -1 ){ | |
| loadedPhotos.push(n); | |
| if ( !$li.hasClass('quote') ){ | |
| if ( galleryImages[n-1]['src'] != '' ){ | |
| var loader = new ImageLoader(galleryImages[n-1]['src']); | |
| //console.log(galleryImages[n-1]['src']+' '+$li.attr('p')+' -'); | |
| loader.loadEvent = function(url, image){ | |
| setTimeout(function(){ | |
| var $l = $('#gallery').find('div.photos div.photo[n='+n+']'); | |
| $l.addClass('sized').find('img.ph').attr('src',url).removeClass('hide'); | |
| setTimeout('positionPhotoLi(0)',90); | |
| setImageOrientation($l); | |
| },photoLoadDelay); | |
| }; | |
| loader.load(); | |
| }else{ | |
| $('#gallery').find('div.photos div.photo[n='+n+']').addClass('sized').find('img.ph').attr('src','').addClass('hide'); | |
| } | |
| } | |
| }else if ( galleryImages[n-1] && !$li.hasClass('quote') ){ | |
| if ( $li.length > 0 ){ | |
| if ( galleryImages[n-1] != '' ){ | |
| $li.find('img.ph').attr('src',galleryImages[n-1]['src']).removeClass('hide'); | |
| }else{ | |
| $li.find('img.ph').attr('src',galleryImages[n-1]['src']).addClass('hide'); | |
| } | |
| $li.addClass('sized'); | |
| setTimeout('positionPhotoLi('+n+')',0); | |
| setImageOrientation($li); | |
| } | |
| } | |
| } | |
| function setImageOrientation($li){ | |
| setTimeout(function(){ | |
| var $image = $li.find('img.ph'); | |
| //console.log('w:'+$image.width()+' h:'+$image.height()); | |
| var diff = $image.height() - $image.width(); | |
| //$li.width($image.width()).height($image.height()); | |
| if ( $image.length == 1 ){ | |
| var licss = {'max-width':'none','max-height':'none'}; | |
| var imagecss = {'height':'auto','width':'auto','max-width':'none','max-height':'none'}; | |
| var windowHeight = $(window).height(); | |
| if ( !$li.hasClass('quote') ){ | |
| licss.height='auto'; | |
| } | |
| if ( diff > 0 ){ | |
| //$li.addClass('portrait'); | |
| licss.maxHeight = '90%'; | |
| imagecss.maxHeight = '100%'; | |
| } | |
| else if ( diff < 0 ){ | |
| //$li.addClass('landscape'); | |
| licss.maxWidth = '90%'; | |
| imagecss.maxWidth = '100%'; | |
| } | |
| else{ | |
| //$li.addClass('square'); | |
| licss.maxWidth = '90%'; | |
| imagecss.maxWidth = '100%'; | |
| } | |
| $li.css(licss); | |
| $image.css(imagecss); | |
| setTimeout(function(){ | |
| if ( $li.height() < $li.find('.innerWrapping').height() ){ | |
| $li.css('height','90%'); | |
| } | |
| },5); | |
| } | |
| },5); | |
| } | |
| /** Thumbnail loading stuff **/ | |
| var cleared = false; | |
| function galleryThumbFlow(force_cliff){ | |
| galleryOuterWidthReflow(); | |
| return; | |
| } | |
| var scrollTop,docHeight,winHeight,winBottom,doneLoadingThumbs=false; | |
| var $gallery = $("#gallery-container"); | |
| var $thumbQuoteTable = $('<table class="quote-table">'+ | |
| '<tr valign="middle">'+ | |
| '<td valign="middle">'+ | |
| '<h2 class="quote-body"></h2>'+ | |
| '<h4 class="quote-credit"></h4>'+ | |
| '</td>'+ | |
| '</tr>'+ | |
| '</table>'); | |
| $(document).on('click','#loadMoreThumbs',function(){ | |
| checkViewportForThumbsToLoad(); | |
| //$('html,body').animate({ scrollTop: $(this).parent().offset().top+$(this).parent().height()- $(window).height() },{ duration:500, queue:false}); | |
| }); | |
| var scrlT,sectionAdder=false; | |
| $(document).scroll(function(){ | |
| clearTimeout(scrlT); | |
| docHeight = $(document).height(); | |
| scrollTop = $(document).scrollTop(); | |
| winBottom = Math.ceil(scrollTop + winHeight); | |
| scrlT=setTimeout(function(){ | |
| checkViewportForThumbsToLoad(); | |
| var $ll = $("#live-link"); | |
| if(!sectionAdder && $ll.length > 0 && typeof constants.finetune!=='undefined' && constants.finetune){ | |
| $ll.addClass('active'); | |
| sectionAdder=true; | |
| } | |
| if (!(typeof mustClickToLoadMore != 'undefined' && mustClickToLoadMore)) { | |
| checkViewportForThumbsToLoad(); | |
| } | |
| if($gallery.length){ | |
| if ( ( winHeight + scrollTop ) > $('#gallery-container').offset().top ){ | |
| $('#live-link').addClass('active'); | |
| }else $('#live-link').removeClass('active'); | |
| } | |
| },50); | |
| if(typeof constants!=='undefined'){ | |
| if( constants.thisTheme == 'st-flyer-v2' || constants.thisTheme == 'st-poster-v2' ){ | |
| customThemeScroll( ) | |
| } | |
| } | |
| checkViewportForBottoms(); | |
| }); | |
| function resizeAdventureFooter(){ | |
| //console.log('custom adventure ') | |
| var thisWidth; | |
| if( $('body').hasClass('finetune') ){ | |
| thisWidth = ( $('#splash-container').outerWidth() - $('.event-bg-url').outerWidth() ) + 'px' | |
| } else { | |
| thisWidth = $('.adventure-content').outerWidth() + 'px' | |
| $('#footer').css('width', thisWidth) | |
| } | |
| $('#footer').css('width', thisWidth) | |
| } | |
| var canvasTimer; | |
| function resizeAdventureCanvas(){ | |
| // clearTimeout( canvasTimer ); | |
| // canvasTimer = setTimeout(function(){ | |
| var thisMin = $('.adventure-content').css('min-height').replace('px','') | |
| var newMin = thisMin - $('#footer').outerHeight() | |
| if( $('.adventure-content').outerHeight() > $(window).outerHeight() ){ | |
| $('.adventure-content').css('min-height', $('.event-bg-url').outerHeight() + 50 + 'px' ) | |
| } else { | |
| $('.adventure-content').css('min-height', newMin + 'px') | |
| } | |
| resizeAdventureFooter() | |
| //}, 100) | |
| } | |
| function resizeFlyer(){ | |
| if ($('body').hasClass('finetune')) { | |
| $('#main-canvas').css('margin-bottom', $('.st-details-wrap').height()+40); | |
| } else { | |
| $('#footer').css('padding-bottom', $('.st-details-wrap').height()+40 ); | |
| } | |
| $('.st-content-wrap').css('padding-bottom', $('.st-details-wrap').outerHeight() * .9 + 'px') | |
| } | |
| function scrollFlyer(){ | |
| if($(window).scrollTop() + $(window).height() > $(document).height() - $('#footer').outerHeight() ) { | |
| $('body').addClass('scrolledToBottom') | |
| $('.st-details-wrap').css('bottom', $('#footer').outerHeight() + 'px') | |
| } else { | |
| $('body').removeClass('scrolledToBottom') | |
| $('.st-details-wrap').css('bottom', '') | |
| } | |
| } | |
| function scrollPoster(){ | |
| if($(window).scrollTop() + $(window).height() > $(document).height() - $('#footer').outerHeight() ) { | |
| $('body').addClass('scrolledToBottom') | |
| $('.st-details-wrap').css('bottom', $('#footer').outerHeight() + 'px') | |
| } else { | |
| $('body').removeClass('scrolledToBottom') | |
| $('.st-details-wrap').css('bottom', '') | |
| } | |
| } | |
| function flyerReady(){ | |
| //console.log('flyer ready') | |
| $('.st-content-wrap').css('padding-bottom', $('.st-details-wrap').outerHeight() * .9 + 'px') | |
| $('#footer').css('padding-bottom', '') | |
| } | |
| function adventureReady(){ | |
| $('.adventure-content').attr('initMinHeight', $('.adventure-content').css('min-height') ) | |
| // save initial min height of container | |
| $('.toolBtn').on('click', function(){ | |
| setTimeout(function(){ | |
| if( constants.thisTheme == 'st-adventure-v2'){ | |
| resizeAdventureFooter() | |
| } | |
| }, 10) | |
| }) | |
| var resizeAdvTimer; | |
| $('.adventureStuffWrap, .event-bg-url').on('keyup', function(){ | |
| console.log('typing') | |
| if( constants.thisTheme == 'st-adventure-v2' ){ | |
| clearTimeout(resizeAdvTimer); | |
| resizeAdvTimer = setTimeout(function(){ | |
| if( constants.thisTheme == 'st-adventure-v2' ){ | |
| autoWindowSizes() | |
| } | |
| },100); | |
| } | |
| }) | |
| resizeAdventureFooter() | |
| } | |
| function adjustSlantyCanvas(){ | |
| if( typeof( $slantCanvas ) === 'undefined' || $slantCanvas.length == 0 ){ | |
| return false; | |
| } | |
| console.log( typeof( $slantCanvas ) ) | |
| $canvasHeight = $('#main-canvas').height() - $slantCanvas.offset().top | |
| $('.slantCanvasContain').css('height', $canvasHeight + 'px') | |
| console.log('adjusting slanty') | |
| } | |
| function updateClassicSidebar(){ | |
| //return false; | |
| $sidebar = $('.details-wrap:first').find('.classicSidebar') | |
| var $mc = $('.content-wrap.link-canvas-bg') | |
| var color = $mc.css('background-color') + ' !important' | |
| if( $('#main-canvas').hasClass('darkBG') ){ | |
| $sidebar.addClass('dark') | |
| $sidebar.css('background-color', color).find('.details-cap').css('background-color', color) | |
| } else { | |
| $sidebar.removeClass('dark') | |
| $sidebar.css('background-color', '').find('.details-cap').css('background-color', '') | |
| } | |
| } | |
| function slantyReady(){ | |
| adjustSlantyCanvas() | |
| updateHoverColors() | |
| } | |
| function resizeSlanty(){ | |
| adjustSlantyCanvas() | |
| } | |
| function customThemeReady(){ | |
| if( constants.thisTheme == 'st-adventure-v2' ){ | |
| adventureReady() | |
| } else if ( constants.thisTheme == 'st-flyer-v2' ){ | |
| flyerReady() | |
| } else if ( constants.thisTheme == 'st-slanty-v2'){ | |
| slantyReady() | |
| } | |
| //console.log('custom theme ready') | |
| } | |
| function customThemeScroll(){ | |
| if ( constants.thisTheme == 'st-flyer-v2' ){ | |
| scrollFlyer() | |
| } else if ( constants.thisTheme == 'st-poster-v2' ){ | |
| scrollPoster() | |
| } | |
| } | |
| function customThemeResize(){ | |
| if( constants.thisTheme == 'st-adventure-v2' ){ | |
| resizeAdventureCanvas() | |
| } else if ( constants.thisTheme == 'st-flyer-v2' ){ | |
| resizeFlyer() | |
| } else if ( constants.thisTheme == 'st-slanty-v2' ){ | |
| resizeSlanty() | |
| } | |
| } | |
| $(window).resize(function(){ | |
| winHeight = $(window).height(); | |
| scrollTop = $(document).scrollTop(); | |
| setImageOrientation($('div.photo.active')); | |
| //$('#gallery').find('ul.photos li').each(function(){ positionPhotoLi($(this).attr('n'),$(this).attr('p')); }); | |
| //$('#stickyMedia').css('left',($(window).width()/2)-($('#stickyMedia').width()/2)); | |
| galleryOuterWidthReflow(); | |
| resizeSplashContainer(); | |
| clearTimeout(clearing); | |
| clearing = setTimeout(function(){ | |
| autoSizeContent(); | |
| },250); | |
| // if( constants.thisTheme == 'st-adventure-v2' || constants.thisTheme == 'st-flyer-v2'){ | |
| customThemeResize( ) | |
| //} | |
| if( $('.autoWindowHeight').length > 0 ){ | |
| autoWindowSizes(); | |
| } else { | |
| if( constants.thisTheme != 'st-poster-v2' && constants.thisTheme != 'st-flyer-v2'){ | |
| dynamaHead() | |
| } | |
| } | |
| }); | |
| function updateHoversOTF(){ // updates while choosing color on the fly | |
| if ( constants.thisTheme == 'st-slanty-v2'){ | |
| var $mc = $('#splash-container').find('.content-wrap.link-canvas-bg'), | |
| color = $mc.css('background-color') | |
| var shade = parseColorLightDark(color) | |
| if( shade == 'dark' ){ | |
| $('#main-canvas').removeClass('lightBG').addClass('darkBG') | |
| } else { | |
| $('#main-canvas').removeClass('darkBG').addClass('lightBG') | |
| } | |
| updateClassicSidebar() | |
| } | |
| } | |
| function updateHoverColors(){ | |
| var $mc = $("#main-canvas") | |
| var color = $mc.css('background-color') | |
| if( typeof constants.canvasColor !== 'undefined' && constants.canvasColor != ''){ | |
| color = constants.canvasColor | |
| } | |
| var shade = parseColorLightDark(color) | |
| if(shade == 'dark'){ | |
| $mc.addClass('darkBG').removeClass('lightBG') | |
| } else { | |
| $mc.addClass('lightBG').removeClass('darkBG') | |
| } | |
| if ( constants.thisTheme == 'st-slanty-v2'){ | |
| updateClassicSidebar() | |
| } | |
| } | |
| function parseColorLightDark(color){ | |
| var values = parseColorShade(color), | |
| bgAvg = ( parseInt(values['red']) + parseInt(values['green']) + parseInt(values['blue']) ) / 3; | |
| if(bgAvg < 146 && values['alpha'] > .475){ | |
| return 'dark'; | |
| } else { | |
| return 'light'; | |
| } | |
| } | |
| function parseColorShade(color){ | |
| var values = { red:null, green:null, blue:null, alpha:null }; | |
| if( color.indexOf('#') === 0 ){ | |
| color = color.substr(1) | |
| if( color.length == 3 ) | |
| values = { | |
| red: parseInt( color[0]+color[0], 16 ), | |
| green: parseInt( color[1]+color[1], 16 ), | |
| blue: parseInt( color[2]+color[2], 16 ), | |
| alpha: 1 | |
| } | |
| else | |
| values = { | |
| red: parseInt( color.substr(0,2), 16 ), | |
| green: parseInt( color.substr(2,2), 16 ), | |
| blue: parseInt( color.substr(4,2), 16 ), | |
| alpha: 1 | |
| } | |
| /* rgb */ | |
| }else if( color.indexOf('rgb(') === 0 ){ | |
| var pars = color.indexOf(','); | |
| values = { | |
| red: parseInt(color.substr(4,pars)), | |
| green: parseInt(color.substr(pars+1,color.indexOf(',',pars))), | |
| blue: parseInt(color.substr(color.indexOf(',',pars+1)+1,color.indexOf(')'))), | |
| alpha: 1 | |
| } | |
| /* colora */ | |
| }else if( color.indexOf('rgba(') === 0 ){ | |
| var pars = color.indexOf(','), | |
| repars = color.indexOf(',',pars+1); | |
| values = { | |
| red: parseInt(color.substr(5,pars)), | |
| green: parseInt(color.substr(pars+1,repars)), | |
| blue: parseInt(color.substr(color.indexOf(',',pars+1)+1,color.indexOf(',',repars))), | |
| alpha: parseFloat(color.substr(color.indexOf(',',repars+1)+1,color.indexOf(')'))) | |
| } | |
| /* verbous */ | |
| } else { | |
| values = { | |
| red: 0, | |
| green: 0, | |
| blue: 0, | |
| alpha: 1 | |
| } | |
| } | |
| return values | |
| } | |
| function checkViewportForThumbsToLoad(checkAll){ | |
| if ( doneLoadingThumbs === false ){ | |
| if ( checkAll ) | |
| $nextUnloadedThumb = $('#gallery-thumbs img.unloaded:first'); | |
| else | |
| $nextUnloadedThumb = $('#gallery-thumbs img.unloaded'); | |
| if ( $nextUnloadedThumb.length > 0 ){ | |
| $nextUnloadedThumb.each(function(){ | |
| if ( !$(this).hasClass('loading-thumb') ){ | |
| //console.log('sT:'+scrollTop+' wH:'+winHeight+' dH:'+docHeight+' nO:'+$nextUnloadedThumb.offset().top); | |
| if ( winBottom >= $(this).offset().top ){ | |
| loadMoreThumbs(); | |
| return false; | |
| } | |
| } | |
| }); | |
| }else if ( typeof unloadedGalleryThumbnails !== 'undefined' && unloadedGalleryThumbnails && unloadedGalleryThumbnails.length > 0 && winBottom >= $('#galleryThumbBottom').offset().top ) { | |
| newToLoad = thumbsToLoad; | |
| if ( newToLoad > unloadedGalleryThumbnails.length ) newToLoad = unloadedGalleryThumbnails.length; | |
| //var newT = unloadedGalleryThumbnails.slice(0,thumbsToLoad); | |
| $galleryThumbs = $('#gallery-thumbs'); | |
| $blank = $galleryThumbs.find('div.photo-thumb:first').clone(); | |
| $blank.removeClass('photo-thumb clear video double triple') | |
| .find('.quote-table,.via').remove() | |
| .end().find('img.th').remove() | |
| .end().find('span.play').remove(); | |
| var playSpan = {open:'<span class="play', audio:' audio stickyMedia', id: '" photo-id="', close: '"></span>'}; | |
| for ( var x=0; x<newToLoad; x++ ){ | |
| var $newBlank = $blank.clone(); | |
| var n = unloadedGalleryThumbnails.shift(); | |
| //console.log('newThumb: '+x+' hasPlay:'+n['has-play']); | |
| $newBlank.addClass(n['outer-class']); | |
| /*if ( n['outer-class'].match(/double/) ){ | |
| newToLoad += 7; | |
| if ( newToLoad > unloadedGalleryThumbnails.length ) newToLoad = unloadedGalleryThumbnails.length; | |
| } | |
| if ( n['outer-class'].match(/triple/) ){ | |
| newToLoad += 9; | |
| if ( newToLoad > unloadedGalleryThumbnails.length ) newToLoad = unloadedGalleryThumbnails.length; | |
| }*/ | |
| var $img = $newBlank.find('img.th'); | |
| if ( $img.length == 0 ){ | |
| $img = $('<img />'); | |
| $newBlank.find('.inner:first').append($img); | |
| $img.addClass('th').attr('loading-src','/images/eventfeed/loading-4.png'); | |
| } | |
| $img.attr('data-src',n['src']) | |
| .attr('src',$img.attr('loading-src')).addClass('unloaded') | |
| .attr('photo-id',n['photo-id']) | |
| .attr('thumbnail-position',n['thumbnail_position']); | |
| if ( n['src'] == '' ) $img.css('display','none').removeClass('unloaded'); | |
| if ( n['has-play'] ){ | |
| var playButtonSpan = playSpan.open; | |
| if ( n['has-play'] == 'audio' ) playButtonSpan += playSpan.audio + '" video-url="'+n['video-url']; | |
| playButtonSpan += playSpan.id+n['photo-id']+playSpan.close; | |
| //console.log(playButtonSpan); | |
| $newBlank.find('span.view').after(playButtonSpan); | |
| } | |
| $newBlank.find('.body').html(n['caption']); | |
| $newBlank.find('.author').html(n['credit']); | |
| $newBlank.find('.created').html(n['created']); | |
| if ( n['type'] == 'quote' || ( ( n['type'] == 'twitter' || n['type'] == 'facebook' ) && n['src'] == '' ) ){ | |
| //$newBlank.find('.thumbDetails').remove(); | |
| //$newBlank.find('img.th').before($thumbQuoteTable.clone()); | |
| //$newBlank.find('.quote-body').html('"'+n['caption']+'"'); | |
| //$newBlank.find('.quote-credit').html('-'+n['credit']); | |
| $newBlank.find('.quote .inner span:first').html(n['caption']); | |
| $newBlank.find('.meta .username .inner span:first').html(n['credit']); | |
| if (typeof n['remote_screen_name'] != 'undefined') { | |
| $newBlank.find('.meta .username .inner span:last').html('@'+n['remote_screen_name']); | |
| } else { | |
| $newBlank.find('.meta .username .inner span:last').html(''); | |
| } | |
| if (typeof n['meta_data'] != 'undefined' && n['meta_data']['remote_profile_img'] != 'undefined') { | |
| $newBlank.find('.meta .thepoint img:first').attr('src',n['meta_data']['remote_profile_img']); | |
| } else { | |
| $newBlank.find('.meta .thepoint img:first').hide(); | |
| } | |
| } | |
| if ( n['otype'] == 'twitter' ){ | |
| $newBlank.find('.inner:first').append('<img src="/images/eventfeed/share-twitter.png" alt="via Twitter" title="via Twitter" class="via">'); | |
| } else if ( n['otype'] == 'instagram' ){ | |
| $newBlank.find('.inner:first').append('<img src="/images/eventfeed/share-instagram.png" alt="via Instagram" title="via Instagram" class="via">'); | |
| } else if ( n['otype'] == 'facebook' ){ | |
| $newBlank.find('.inner:first').append('<img src="/images/eventfeed/share-fbook.png" alt="via Facebook" title="via Facebook" class="via">'); | |
| } | |
| $galleryThumbs.append($newBlank); | |
| if ( unloadedGalleryThumbnails && unloadedGalleryThumbnails.length == 0 ){ | |
| doneLoadingThumbs = true; | |
| $('#loadMoreThumbs').hide(); | |
| } | |
| } | |
| $('#gallery-thumbs').masonry('reload'); | |
| loadMoreThumbs(); | |
| }else if ( $nextUnloadedThumb.length == 0 && typeof unloadedGalleryThumbnails !== 'undefined' && unloadedGalleryThumbnails && unloadedGalleryThumbnails.length == 0 ){ | |
| doneLoadingThumbs = true; | |
| $('#loadMoreThumbs').hide(); | |
| } | |
| } | |
| } | |
| // position the image in the thumbnail viewport to represent their crop | |
| function positionThumbnail($img){ | |
| setTimeout(function(){ | |
| //console.log($img); | |
| var fullPosition = $img.attr('thumbnail-position'); | |
| if ( fullPosition ){ | |
| var xyw = fullPosition.split(/;/); | |
| if($img.attr("display-width")){ | |
| var displayWidth = $img.attr('display-width'); | |
| } | |
| else{ | |
| var $parent = $img.parents("div.photo-thumb"); | |
| if($parent.hasClass('triple')){ | |
| $img.attr("display-width",constants.thumbSizes.triple.w); | |
| } | |
| else if($parent.hasClass('double')){ | |
| $img.attr("display-width",constants.thumbSizes.double.w); | |
| } | |
| else{ | |
| $img.attr("display-width",constants.thumbSizes.single.w); | |
| } | |
| $img.attr("display-width",$parent.width()); | |
| var displayWidth=$img.attr("display-width"); | |
| } | |
| var displayTop=0,displayLeft=0; | |
| if ( xyw.length == 3 ){ | |
| displayWidth = Math.ceil(displayWidth/xyw[2]); | |
| displayTop = Math.ceil(xyw[1]*displayWidth); | |
| displayLeft = Math.ceil(xyw[0]*displayWidth); | |
| } | |
| $img.css({ | |
| "min-width": 'none', | |
| "max-width": 'none', | |
| "margin-top": '-'+displayTop+'px', | |
| "margin-left": '-'+displayLeft+'px', | |
| "width": displayWidth+'px', | |
| "height": 'auto' | |
| }); | |
| } else { | |
| var diff = $img.height() - $img.parent().height(); | |
| if ( diff < 0 ){ | |
| $img.css({ | |
| "min-width": 'none', | |
| "max-width": 'none', | |
| "width": 'auto', | |
| "height": '100%' | |
| }); | |
| }else if ( diff > 0 ) { | |
| $img.css({ | |
| "height": 'auto' | |
| }); | |
| } | |
| } | |
| },200); | |
| } | |
| var thumbsToLoad = 6*5; | |
| //var extraThumbsToLoad = 0; | |
| function loadMoreThumbs(){ | |
| $thumbs = $('#gallery-thumbs img.unloaded'); | |
| if ( $thumbs.length > 0 ){ | |
| var i = 0; | |
| $thumbs.each(function(){ | |
| i++; | |
| var $img = $(this); | |
| $img.removeClass('unloaded').addClass('loading-thumb'); | |
| var loader = new ImageLoader($img.attr('data-src')); | |
| loader.loadEvent = function(url, image){ | |
| //action to perform when the image is loaded | |
| setTimeout(function(){ | |
| $img.attr('src',url); | |
| $img.removeClass('loading-thumb') | |
| .parents(".inner:first").addClass('loaded').find(".lazy.message").hide(); | |
| positionThumbnail($img); | |
| },photoLoadDelay); | |
| } | |
| loader.load(); | |
| }); | |
| } | |
| galleryThumbFlow(); | |
| } | |
| $(document).on('click','.photo-thumb .thumbShare',function(e){ | |
| _gaq.push(['_trackEvent', 'Splash', 'shareBox-open', 'id:'+constants.event_id]); | |
| $('div.main').find('.shareBox').each(function(){ $(this).animate({width:0},100,'linear',function(){$(this).remove();}) }); | |
| var $thumbDiv = $(this).parents('.photo-thumb:first'); | |
| var photoId = $thumbDiv.find('img.th').attr('photo-id'); | |
| var url = 'http://'+gallVars.domain+'/?i='+photoId; | |
| var $myShareBox = createMyShareBox(url); | |
| var right = $(window).width() - ($thumbDiv.offset().left+$thumbDiv.width()+2) ; | |
| var top = $thumbDiv.offset().top + $thumbDiv.height() - 114; | |
| $myShareBox.css({top: top, left: 'auto', right: right+'px',width: '0px'}); | |
| $('#gallery-thumbs').after($myShareBox); | |
| $myShareBox.animate({width:'400px'},350,'linear',function(){ | |
| var myLeftOffset = $myShareBox.offset().left; | |
| if ( myLeftOffset < 0 ){ | |
| $myShareBox.animate({right: (right+myLeftOffset)},200); | |
| } | |
| }); | |
| return false; // to stop the gallery from opening... | |
| }); | |
| function createMyShareBox(url){ | |
| var blankHtml = $('#shareBoxMarkup').html(); | |
| blankHtml = blankHtml.replace(/:url:/g,url); | |
| return $(blankHtml); | |
| } | |
| $(document).on('click','#gallery div.photos div.photo .shareThisPhoto',function(e){ | |
| var $this = $(this) | |
| var $li = $this.parents('div.photo:first'); | |
| if ( !$li.hasClass('shareBoxOpen') ){ | |
| $li.addClass('shareOpen shareBoxOpen').removeClass('commentsOpen'); | |
| $li.find('.fb-wrap').hide(); | |
| $li.css({ | |
| //height:$(window).height()-20 | |
| //,marginTop:($(document).scrollTop()-$li.offset().top)+10 | |
| }); | |
| // add and parse the fb comment block | |
| var $myShareBox = createMyShareBox($li.find('.urlShare').attr('href')); | |
| var newLeft = ($li.width()/2)-200; | |
| $myShareBox.css({top: $this.parent().height(), right: 'auto', left: newLeft,height: '0px'}); | |
| $this.parents('.photo-util').find('.util-actions-wrap').prepend($myShareBox); | |
| $myShareBox.animate({height:'116px'},1,'linear',function(){ | |
| setTimeout(function(){$('div.photos').scrollTop($('div.photos').height());},0); | |
| }); | |
| $this.hide(); | |
| }else{ | |
| $li.removeClass('shareOpen shareBoxOpen commentsOpen') | |
| .css({height:'',marginTop:'auto'}); | |
| $li.find('.shareBox').remove(); | |
| } | |
| }); | |
| //var partyDelays = { check: 30000, scrollJump: 30 }; // live | |
| var partyDelays = { check: 3000, scrollJump: 900 }; // testing | |
| var newPhotosSince; | |
| var partyMode = false; | |
| var keepScrolling = false; | |
| var keepScrollingRepeat = false; | |
| function checkForNewPhotos(){ | |
| //console.log('dude'); | |
| $.ajax(constants.formBase+'/party/new',{type:'POST',data:{since:newPhotosSince},dataType:'json', | |
| success: function(response){ | |
| if ( typeof response.newSince != 'undefined' ){ | |
| newPhotosSince = response.newSince; | |
| } | |
| thumbsToLoad = 2; | |
| if ( typeof response.newThumbs != 'undefined' && response.newThumbs.length > 0 ){ | |
| //console.log(response.EventPhoto); | |
| unloadedGalleryThumbnails = unloadedGalleryThumbnails.concat(response.newThumbs); | |
| doneLoadingThumbs = false; | |
| keepScrolling = true; | |
| checkViewportForThumbsToLoad(); | |
| } | |
| if ( typeof response.scrollToTopWhenAtBottom != 'undefined' ){ | |
| keepScrollingRepeat = response.scrollToTopWhenAtBottom; | |
| keepScrolling = true; | |
| keepScrollingDown(); | |
| } | |
| if ( typeof response.partyDelayCheck != 'undefined' ){ | |
| partyDelays.check = parseInt(response.partyDelayCheck); | |
| } | |
| if ( typeof response.partyDelayScrollJump != 'undefined' ){ | |
| partyDelays.scrollJump = parseInt(response.partyDelayScrollJump); | |
| } | |
| // do we stop the party? | |
| if ( typeof response.stopParty != 'undefined' ){ partyMode = false; keepScrolling = false; } | |
| // or keep it rolllllingg | |
| if ( partyMode == true ){ | |
| setTimeout(function(){ checkForNewPhotos(); }, partyDelays.check); // call again in 1 min | |
| } | |
| }, | |
| timeout: 5000 | |
| }); | |
| } | |
| var nwineiunvriwunewervwe; | |
| function keepScrollingDown(){ | |
| clearTimeout(nwineiunvriwunewervwe); | |
| nwineiunvriwunewervwe = setTimeout(function(){ | |
| if ( keepScrolling ){ | |
| var current = $(document).scrollTop(); | |
| $('html, body').stop().animate({ | |
| scrollTop: current+partyDelays.scrollJump | |
| }, 1000,'linear',function(){ | |
| if ( current == $(document).scrollTop() ){ | |
| if ( keepScrollingRepeat ){ | |
| keepScrolling = false; | |
| setTimeout(function(){ | |
| var $screen = $('<div style="position:fixed;width:100%;height:100%;background:#000000;display:none;top:0;left:0;z-index:23;"></div>'); | |
| $('#main-canvas').append($screen); | |
| $screen.fadeIn(1000,function(){ | |
| $(document).scrollTop(0); | |
| $screen.fadeOut(1000,function(){ | |
| keepScrolling = true; | |
| keepScrollingDown(); | |
| $screen.remove(); | |
| }); | |
| }); | |
| },1000); | |
| }else keepScrolling = false; | |
| }else{ | |
| keepScrollingDown(); | |
| } | |
| }); | |
| } | |
| },0); | |
| } | |
| /*********************************** | |
| * End Photo Gallery functionality * | |
| ***********************************/ | |
| var liveTimes; | |
| var countdownInterval; | |
| function startCounter(){ | |
| // //console.log("startCounter"); | |
| countdownInterval = setInterval('updateLiveTimes()',1000); | |
| } | |
| // this decrements the live time seconds and then if <0 the other ones! | |
| function updateLiveTimes(){ | |
| //console.log("updateLiveTimes"); | |
| liveTimes.seconds--; | |
| if ( liveTimes.seconds < 0 ){ | |
| liveTimes.seconds = 59; | |
| liveTimes.minutes--; | |
| if ( liveTimes.minutes < 0 ){ | |
| liveTimes.minutes = 59; | |
| liveTimes.hours--; | |
| if ( liveTimes.hours < 0 ){ | |
| liveTimes.hours = 23; | |
| liveTimes.days--; | |
| if ( liveTimes.days < 0 ){ | |
| // IT'S THE EVENT! | |
| // change the clock into something else? | |
| countdownInterval = window.clearInterval(countdownInterval); | |
| // //console.log("GO TIME"); | |
| _gaq.push(['_trackEvent', 'Splash', 'GoTimeReached', 'id:'+constants.event_id]); | |
| return; | |
| } | |
| } | |
| } | |
| } | |
| updateCounter(); | |
| } | |
| function updateCounter(){ | |
| var params = { days: liveTimes.days.toString(), hours : liveTimes.hours.toString(), | |
| minutes : liveTimes.minutes.toString(), seconds: liveTimes.seconds.toString() }; | |
| //console.log('the values: days'+params.days+', hours '+params.hours+', minutes '+params.minutes); | |
| //POPULATE DAYS | |
| if(params.days.length == 1){ | |
| $("#counter-days").find("li").eq(0).hide().find("span").html('0'); | |
| $("#counter-days").find("li").eq(1).find("span").html('0'); | |
| $("#counter-days").find("li").eq(2).find("span").html(params.days); | |
| } | |
| else if(params.days.length == 2){ | |
| $("#counter-days").find("li").eq(0).hide().find("span").html('0'); | |
| $("#counter-days").find("li").eq(1).find("span").text(params.days.substring(0,1)); | |
| $("#counter-days").find("li").eq(2).find("span").text(params.days.substring(1,2)); | |
| } | |
| else{ | |
| $("#counter-days").find("li").eq(0).find("span").html(params.days.substring(0,1)); | |
| $("#counter-days").find("li").eq(1).find("span").html(params.days.substring(1,2)); | |
| $("#counter-days").find("li").eq(2).find("span").html(params.days.substring(2,3)); | |
| } | |
| //POPULATE HOURS | |
| if(params.hours.length > 1){ | |
| $("#counter-hours").find("li").eq(0).find("span").html(params.hours.substring(0,1)); | |
| $("#counter-hours").find("li").eq(1).find("span").html(params.hours.substring(1,2)); | |
| } | |
| else{ | |
| $("#counter-hours").find("li").eq(0).find("span").html('0'); | |
| $("#counter-hours").find("li").eq(1).find("span").html(params.hours.substring(0,1)).end() | |
| } | |
| //POPULATE MINUTES | |
| if(params.minutes.length > 1){ | |
| $("#counter-minutes").find("li").eq(0).find("span").html(params.minutes.substring(0,1)); | |
| $("#counter-minutes").find("li").eq(1).find("span").html(params.minutes.substring(1,2)); | |
| } | |
| else{ | |
| $("#counter-minutes").find("li").eq(0).find("span").html('0'); | |
| $("#counter-minutes").find("li").eq(1).find("span").html(params.minutes.substring(0,1)).end() | |
| } | |
| if(params.seconds.length > 1){ | |
| $("#counter-seconds").find("li").eq(0).find("span").html(params.seconds.substring(0,1)); | |
| $("#counter-seconds").find("li").eq(1).find("span").html(params.seconds.substring(1,2)); | |
| } | |
| else{ | |
| $("#counter-seconds").find("li").eq(0).find("span").html('0'); | |
| $("#counter-seconds").find("li").eq(1).find("span").html(params.seconds); | |
| } | |
| } | |
| var map_visible = false; | |
| var countdown_visible = false; | |
| var map_animating = false; | |
| var countdown_animating = false; | |
| var map_hover = false; | |
| var countdown_hover = false; | |
| function openUp(){ | |
| var $map = $('div.map:first'); | |
| var openHeight = 218; | |
| if(map_hover && $map.height() != openHeight && !map_animating ){ | |
| hidePiece('countddown'); | |
| map_animating = true; | |
| $map.animate( { 'height': openHeight }, 400, function(){ | |
| _gaq.push(['_trackEvent', 'Splash', 'SMapOpen', 'id:'+constants.event_id]); | |
| map_animating = false; | |
| }); | |
| } | |
| } | |
| function openUpCountDown(){ | |
| var $countdown = $('div.countdown:first'); | |
| var openHeight = 192; | |
| if(countdown_hover && $countdown.height() != openHeight && !countdown_animating ){ | |
| hidePiece('map'); | |
| countdown_animating = true; | |
| $countdown.animate( { 'height': openHeight }, 400, function(){ | |
| _gaq.push(['_trackEvent', 'Splash', 'SCountdownOpen', 'id:'+constants.event_id]); | |
| countdown_animating = false; | |
| }); | |
| } | |
| } | |
| function randomXToY(minVal,maxVal,floatVal) | |
| { | |
| var randVal = minVal+(Math.random()*(maxVal-minVal)); | |
| return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal); | |
| } | |
| function hidePiece(type){ | |
| if(type == 'map'){ | |
| if(!map_visible && !map_hover){ | |
| $("div.map").animate( { 'height': 0 }, 400, function(){}); | |
| } | |
| } | |
| else{ | |
| if(!countdown_visible && !countdown_hover){ | |
| $("div.countdown").animate( { 'height': 0 }, 400, function(){}); | |
| } | |
| } | |
| } | |
| function isValidEmail(val){ | |
| var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; | |
| return reg.test($.trim(val)); | |
| } | |
| var $get_params = getQueryParams(window.location.search); | |
| if(typeof $get_params.fb !=='undefined'){ | |
| setTimeout(function(){ | |
| $("#fb-link").click(); | |
| },2000); | |
| } | |
| else if(typeof $get_params.tw !== 'undefined'){ | |
| setTimeout(function(){ | |
| $("#twitter-link").click(); | |
| },2000); | |
| } | |
| if(typeof $get_params.closefb !== 'undefined'){ | |
| window.close(); | |
| } | |
| $("#ext-rsvp-link").click(function(){ | |
| _gaq.push(['_trackEvent', 'Splash', 'GetLinks', 'id:'+constants.event_id]); | |
| }); | |
| //resize title on the fly. | |
| $.fn.resizeText = function(args){ | |
| // clearTimeout(clearing); | |
| // clearing = setTimeout(function(){ | |
| if(args==null){ | |
| args = { min: 18, max: 140 }; | |
| } | |
| var $t = $(this); | |
| // $t.html($t.html().replace(/<br\s*[\/]?>/gi,' ')).css('font-size',maxFontSize); | |
| $t.css("font-size",args.max+'px'); | |
| var tempTarget = $t.clone().html(" ").insertAfter($t); | |
| var fontSize = parseInt($t.css("font-size")); | |
| while ($t.height() > tempTarget.height() && fontSize>=args.min) { | |
| fontSize--; | |
| $t.css("font-size", fontSize+'px'); | |
| } | |
| $t.css("line-height",fontSize+'px'); | |
| // finetuneDeActivateEditable($(this)); | |
| // finetuneActivateEditable($('#element-title').find("h1 span"),'data[EventSetting][theme_styles][title][text]',{ /*singleField:true,*/ noPane: true, noRTE: true }); | |
| tempTarget.remove(); | |
| //},200); | |
| } | |
| var galleryOuterWidthReflowTimer; | |
| var forceSmallerGalleryWidth = false; | |
| function galleryOuterWidthReflow() { | |
| clearTimeout(galleryOuterWidthReflowTimer); | |
| galleryOuterWidthReflowTimer = setTimeout(function(){ | |
| var $g = $('#gallery-container'); | |
| if ($g.hasClass('noAutoWidthChange')) { | |
| w = $g.width(); | |
| } | |
| var $gt = $('#gallery-thumbs'); | |
| var cols = 5; | |
| if ($g.hasClass('column4')) { | |
| cols = 4; | |
| } else if ($g.hasClass('column3')) { | |
| cols = 3; | |
| } else if ($g.hasClass('column2')) { | |
| cols = 2; | |
| } else if ($g.hasClass('column1')) { | |
| cols = 1; | |
| } | |
| var win = $(window).width(); | |
| if (win<481) { | |
| cols = 1; | |
| } | |
| var w = $gt.width(); | |
| var displayRatio = 3/4; | |
| var margin = 4; // half of the gutter | |
| var columnWidth = Math.floor(w/cols); | |
| var rowHeight = Math.floor(columnWidth*displayRatio); | |
| var singleWidth = columnWidth-margin*2; | |
| var singleHeight = rowHeight-margin*2; | |
| var doubleWidth = (singleWidth*2+margin*2); | |
| var doubleHeight = (singleHeight*2+margin*2); | |
| var tripleWidth = (singleWidth*3+margin*4); | |
| var tripleHeight = (singleHeight*3+margin*4); | |
| var $thumbs = $gt.find(".photo-thumb"); | |
| $thumbs.each(function(){ | |
| var $this = $(this); | |
| var width = singleWidth; | |
| var height = singleHeight; | |
| if ($this.hasClass('triple')) { | |
| if (cols >= 3) { | |
| width = tripleWidth; | |
| height = tripleHeight; | |
| } else if (cols == 2) { | |
| width = doubleWidth; | |
| height = doubleHeight | |
| } | |
| } else if ($this.hasClass('double')) { | |
| if (cols >= 2) { | |
| width = doubleWidth; | |
| height = doubleHeight; | |
| } | |
| } | |
| var css = { | |
| 'width':width+'px', | |
| 'height':height+'px' | |
| }; | |
| $this.css(css); | |
| $this.find('>.inner:first').css(css); | |
| }); | |
| // lock this parent's height | |
| var $p = $gt.parent(); | |
| $p.css('height',$p.height()+'px'); | |
| if ($gt.hasClass('masonry')) { | |
| $gt.masonry('destroy'); | |
| } | |
| if(typeof galleryMasonryVars!=='undefined' && $thumbs.length > 0){ | |
| galleryMasonryVars.columnWidth = columnWidth; | |
| $gt.masonry(galleryMasonryVars); | |
| } | |
| setTimeout(function(){ | |
| $p.css('height','auto'); | |
| },1000); | |
| },100); | |
| } | |
| function autoSizeContent(type,fv){ | |
| //return; // this has been causing all sorts of title size issues | |
| // if(type!=null){ | |
| // if(typeof constants.autosize[type]!=='undefined' && constants.autosize[type]){ | |
| // if(type=='rsvp'){ | |
| // $("#element-"+type).parents(".layoutGrp:first").resizeText({ min: 18, max: 36 }); | |
| // } else{ | |
| // $("#element-"+type).parents(".layoutGrp:first").resizeText(); | |
| // } | |
| // } | |
| // } else{ | |
| // if(constants.autosize['title']){ | |
| // $("#element-title").parents(".layoutGrp:first").resizeText(); | |
| // } | |
| // if(constants.autosize['subtitle']){ | |
| // $("#element-subtitle").parents(".layoutGrp:first").resizeText(); | |
| // } | |
| // if(constants.autosize['rsvp']){ | |
| // $("#element-rsvp").parents(".layoutGrp:first").resizeText({ min: 18, max: 36 }); | |
| // } | |
| // } | |
| if(fv!=null){ | |
| $("#element-title").parents(".layoutGrp:first").removeClass("no-op"); | |
| $("#element-subtitle").parents(".layoutGrp:first").removeClass("no-op"); | |
| $("#element-rsvp").parents(".layoutGrp:first").removeClass("no-op"); | |
| } | |
| } | |
| /********* Image loading Object Stuff *******************/ | |
| // Cross-browser implementation of element.addEventListener() | |
| function addListener(element, type, expression, bubbling) | |
| { | |
| bubbling = bubbling || false; | |
| if(window.addEventListener) { // Standard | |
| element.addEventListener(type, expression, bubbling); | |
| return true; | |
| } else if(window.attachEvent) { // IE | |
| element.attachEvent('on' + type, expression); | |
| return true; | |
| } else return false; | |
| } | |
| var ImageLoader = function(url){ | |
| this.url = url; | |
| this.image = null; | |
| this.loadEvent = null; | |
| }; | |
| ImageLoader.prototype = { | |
| load:function(){ | |
| this.image = document.createElement('img'); | |
| var url = this.url; | |
| if (url != '') { | |
| var image = this.image; | |
| var loadEvent = this.loadEvent; | |
| addListener(this.image, 'load', function(e){ | |
| if(loadEvent != null){ | |
| //console.log(url); | |
| loadEvent(url, image); | |
| } | |
| }, false); | |
| this.image.src = this.url; | |
| } | |
| }, | |
| getImage:function(){ | |
| return this.image; | |
| } | |
| }; | |
| /********* End Image loading Object Stuff *******************/ | |
| /********** Lazy Image Loading **************/ | |
| var lzD=0; // delay to test some shit... | |
| var lazyLoader=function(){this.q=[];this.r=false;}; | |
| lazyLoader.prototype={ | |
| load: function(image,_c){ | |
| if (image && image != '') { | |
| this.q.push(image); | |
| if(this.r==false)this.go(_c); | |
| } | |
| }, | |
| go: function(_c){ | |
| if (this.q.length>0){ | |
| this.r=true; | |
| var image=this.q.shift(); | |
| var me = this; | |
| var went = false; | |
| this.loadImage(image,function(){ | |
| if ( !went ) { me.go(); went = true; } | |
| if(typeof _c!='undefined')_c(); | |
| }); | |
| setTimeout(function(){ if ( !went ) { me.go(); went = true; } },200); | |
| }else this.r=false; | |
| }, | |
| loadImage: function(i,_c){ | |
| var iL=new ImageLoader(i.getAttribute('lazy-src')); | |
| iL.loadEvent=function(u){ | |
| i.setAttribute('src',u); | |
| i.removeAttribute('lazy-src'); | |
| $(i).parents(".inner:first").addClass('loaded').find(".lazy.message").hide(); | |
| if(typeof _c!='undefined')setTimeout(_c,lzD); | |
| positionThumbnail($(i)); | |
| }; | |
| iL.load(); | |
| } | |
| } | |
| var myLazyLoader=new lazyLoader(); | |
| function lazyLoad(i,c){myLazyLoader.load(i,c)} | |
| function manualLazy(ele,src,_c){ | |
| var loader = new ImageLoader(src); | |
| //console.log(galleryImages[n-1]['src']+' '+$li.attr('p')+' -'); | |
| loader.loadEvent = function(url, image){ | |
| setTimeout(function(){ | |
| ele.setAttribute('src',url); | |
| if ( typeof _c != 'undefined' ) _c(); | |
| },0); | |
| }; | |
| loader.load(); | |
| } | |
| function getAge(dateString) { //http://stackoverflow.com/questions/4060004/calculate-age-in-javascript | |
| var today = new Date(); | |
| var birthDate = new Date(dateString); | |
| var age = today.getFullYear() - birthDate.getFullYear(); | |
| var m = today.getMonth() - birthDate.getMonth(); | |
| if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { | |
| age--; | |
| } | |
| return age; | |
| } | |
| function resizeSplashContainer(){ | |
| var $div = $("#footer"); | |
| if($div.is(":visible")){ | |
| $("#splash-container").css('min-height',$(window).height()-$div.outerHeight(true)); | |
| if( $('#splash-container').outerHeight() < $(window).outerHeight() ){ | |
| $('body').addClass('fixFooter') | |
| } else { | |
| $('body').removeClass('fixFooter') | |
| } | |
| console.log('test') | |
| // $("#main-canvas").css('min-height',$(window).height()-$div.outerHeight(true)); | |
| } else{ | |
| // $("#main-canvas").css('min-height',$(window).height()-$div.outerHeight(true)); | |
| } | |
| } | |
| var $awhs=false; | |
| function autoWindowSizes(){ | |
| //console.log('winding sziing') | |
| var h = winHeight; | |
| //var $p = $('#planning-tools'); | |
| //if ($p.length == 1 && $p.is(':visible')) { | |
| // h -= $p.outerHeight(); | |
| //} | |
| if ( typeof($awhs) != 'undefined' || $awhs==false ){ | |
| $awhs = $('.autoWindowHeight:first'); | |
| } | |
| if ($awhs.length>0){ | |
| $awhs.each(function(){ | |
| var $t=$(this); | |
| var $m=$t.find('> .autoHeightMaint:first'); | |
| if ($m.length>0){ | |
| var mh=$m.outerHeight(); | |
| if (mh>h){ | |
| $('#splash-container').find('.autoWindowHeight').css('min-height',mh+'px').addClass('maintReached'); | |
| }else{ | |
| $('#splash-container').find('.autoWindowHeight').css('min-height',h+'px').removeClass('maintReached'); | |
| } | |
| //console.log(h, 'this min 2 ', mh, $t) | |
| }else{ | |
| $('#splash-container').find('.autoWindowHeight').css('min-height',h+'px'); | |
| //console.log(h, 'this min height') | |
| } | |
| }); | |
| } | |
| if( constants.thisTheme == 'st-adventure-v2' ){ | |
| resizeAdventureCanvas() | |
| } | |
| //console.log('sizing window ', $awhs) | |
| } | |
| var $hbiv=false; | |
| function checkViewportForBottoms(){ | |
| if($hbiv===false){$hbiv=$('.hasBottomInViewport');} | |
| if($hbiv.length>0){ | |
| $hbiv.each(function(){ | |
| var $t=$(this); var h=$t.height(); var t=$t.offset().top; | |
| if(h+t>winBottom){$t.removeClass('bottomIn');}else{$t.addClass('bottomIn');} | |
| });} | |
| } | |
| /********************** | |
| * Upload Photo Modal */ // {{{ | |
| function uploadGalleryPhotos() { | |
| var $galleryModal = $('#galleryUploadModal'); | |
| $galleryModal.html('Loading...').fireSimpleModal(); | |
| $.ajax({url:constants.upload_form_action+'m'}) | |
| .done(function(response){ | |
| $galleryModal.html(response); | |
| initializePhotoUploader(); | |
| }); | |
| } | |
| function updateModalColors(){ | |
| if( ! $('#splash-container').hasClass('isCustomPage') ){ | |
| var $btn = $('#main-canvas').find('.element-rsvp') | |
| var btnBgColor = $btn.css('background-color') | |
| var highlightColor | |
| if( ! btnBgColor ){ | |
| btnBgColor = '#000' | |
| } | |
| var shade = parseColorLightDark( btnBgColor ) | |
| highlightColor = 'rgba(255,255,255,.5)' | |
| if( btnBgColor == 'rgb(255, 255, 255)' ){ | |
| highlightColor = 'rgba(0,0,0,.1)' | |
| } | |
| var btnTxtColor = $btn.css('color') | |
| if( ! btnTxtColor ){ | |
| btnTxtColor = '#FFF' | |
| } | |
| var nuGradient = "linear-gradient(to right, "+btnBgColor+", "+highlightColor+", "+btnBgColor+", "+highlightColor+")" | |
| $('#rsvp-modal').find('.bgGradient').css({'background-image': nuGradient, 'background-color':btnBgColor}) | |
| $('#rsvp-submit').css({ 'background-color':btnBgColor, 'color':btnTxtColor }) | |
| $('#add-cal-wrap').find('a.add-cal').css({ 'background-color':btnBgColor, 'color':btnTxtColor }) | |
| $('#add-cal-wrap').find('.the-cals').css({ 'background-color':btnBgColor, 'color':btnTxtColor }) | |
| $('#add-cal-wrap').find('a').css('color', btnTxtColor) | |
| } | |
| } | |
| function showRsvpForm(){ | |
| $("#rsvp-modal").fireSimpleModal(); | |
| $('#rsvp-form-inner').addClass('active'); | |
| updateModalColors() | |
| setTimeout(function(){ | |
| $('#rsvp-first-name').focus(); | |
| }, 400); | |
| return false; | |
| } | |
| function jumpToNavBlock($t,event){ | |
| var jumpTo = $t.attr("href"); | |
| if(typeof jumpTo==='undefined'){ return false; } | |
| if(jumpTo.match(/#to/)){ | |
| jumpTo = jumpTo.replace('http://','');//remove "http://" from jumpTo path. | |
| if (event && event.preventDefault) event.preventDefault(); | |
| var $s = $(jumpTo); | |
| if(jumpTo=='#tobutton'||jumpTo=='#button'||jumpTo=='#rsvp'){ | |
| $s = $("#element-rsvp"); | |
| if($s.length < 1 || !$s.parents(".element-rsvp:first").is(":visible") ){ | |
| $('html, body').animate({ | |
| scrollTop: 0 | |
| }, 400); | |
| } | |
| return false; | |
| } else if(jumpTo == '#top'||jumpTo == '#totop'||jumpTo == '#event'){ | |
| $('html, body').animate({ | |
| scrollTop: 0 | |
| }, 400); | |
| return false; | |
| } | |
| if($s.length > 0){ | |
| if($t.parents(".tt-content").length > 0){//tabbed nav. | |
| //tabbed nav, not page nav. | |
| var $p = $s.parents(".sf:first"); | |
| var bt = 'full-list'; | |
| //console.log("ssss",$s.parents(".layoutGrp:first")); | |
| $t.parents(".tt-content").find("div[block-type='"+bt+"']").each(function(){ | |
| $(this).parents(".layoutGrp:first").hide(); | |
| }); | |
| var $b = $s.parents(".layoutGrp:first"); | |
| //console.log("B ! ",$b); | |
| $b.show(); | |
| $t.parents(".nav-item:first").addClass('active').siblings().removeClass('active'); | |
| } else{ | |
| $t.parents(".nav-item:first").addClass('active').siblings().removeClass('active'); | |
| $('html, body').animate({ | |
| scrollTop: $s.offset().top - 60 - navHeight | |
| }, 400); | |
| } | |
| return false; | |
| } else { | |
| //CHECKS FOR TT. HARDCODED LINKS | |
| if(jumpTo == '#to301527'){ //"IDEAS" | |
| var $s = $("#main-canvas").find(".sf[block-type='content']:first"); | |
| } else if(jumpTo == '#to301542'){//PARTICIPANTS | |
| var $s = $("#main-canvas").find(".sf[block-type='list']:first"); | |
| } else if(jumpTo == '#to306859'){//PHOTOS | |
| var $s = $("#main-canvas").find(".element-gallery:last"); | |
| if($s.length < 1 || !$s.is(":visible")){ | |
| var $s = $("#main-canvas").find(".sf[block-type='images']:first"); | |
| } | |
| } | |
| if(typeof $s !== 'undefined' && $s.length > 0){ | |
| $('html, body').animate({ | |
| scrollTop: $s.offset().top - 60 - navHeight | |
| }, 400); | |
| } | |
| } | |
| } | |
| } | |
| var autoTimeout; | |
| function dynamaHead(){ | |
| if( $('.stretchBox').length == 0){ | |
| return false; | |
| } | |
| clearTimeout(autoTimeout) | |
| autoTimeout = setTimeout(function(){ | |
| console.log('runing timeout') | |
| var $thisBG = $('.event-bg-url') | |
| var innerHeight = $('.stretchBox').outerHeight() + 60 | |
| if( constants.thisTheme == 'st-pitch-v2'){ | |
| innerHeight = $('.stretchBox').outerHeight() + 100 | |
| } | |
| var thisMin = parseInt( $thisBG.css('min-height') ) | |
| if( innerHeight > thisMin ){ | |
| $thisBG.css('height', innerHeight + 'px' ) | |
| $('.stretchBox').css('top', '0px') | |
| if( constants.thisTheme == 'st-pitch-v2'){ | |
| $('.stretchBox').css('top', '-30px') | |
| } | |
| } else { | |
| $thisBG.css('height', thisMin + 'px' ) | |
| $('.stretchBox').css('top', '') | |
| } | |
| }, 700 ) | |
| } | |
| var openModal = false; | |
| var clearing; | |
| /* End Upload Photo Modal * // }}} | |
| **************************/ | |
| $.fn.slideToCurrent = function(){ | |
| var $carousel = $(this), | |
| $parent = $carousel.parents(".layoutGrp:first"), | |
| $slides = $carousel.find(".slides"), | |
| $left = $parent.find(".scrollLeftContain"), | |
| $right = $parent.find(".scrollRightContain"); | |
| var $current = $carousel.find(".img-gal-item.current:first"); | |
| var left = $current.position().left; | |
| $slides.css('left','-'+left+'px'); | |
| var current_index = $current.index(); | |
| $parent.find('.progress .current').html((current_index+1)); | |
| var $currentImg = $current.find("img:first"); | |
| if($currentImg.hasClass('unloaded')){ | |
| lazyLoad($currentImg[0],function(){$currentImg.removeClass('unloaded')}); | |
| } | |
| if($current.prev().length > 0){ | |
| $left.show(); | |
| } else { | |
| $left.hide(); | |
| } | |
| if($current.next().length > 0){ | |
| $right.show(); | |
| } else { | |
| $right.hide(); | |
| } | |
| } | |
| $.fn.activateCarousel = function(params){ | |
| // | |
| var $carousel = $(this), | |
| $parent = $carousel.parents(".layoutGrp:first"), | |
| $left = $parent.find(".scrollLeftContain"), | |
| $right = $parent.find(".scrollRightContain"), | |
| $slides = $carousel.find(".slides"), | |
| imgCount = $carousel.find(".img-gal-item").length; | |
| if(imgCount == '1'){//if only one, hide the controls. | |
| $left.hide(); | |
| $right.hide(); | |
| } | |
| $parent.find(".progress").find(".total").text(imgCount); | |
| // do this soon.. but after we're done here | |
| setTimeout(function(){ | |
| var width = $slides.parent().width(); | |
| var $imgs = $slides.find('.img-gal-item') | |
| $imgs.css('width',width+'px'); | |
| if ($imgs.length > 0) { | |
| $slides.css('width',(width*($imgs.length+1))+'px'); | |
| } | |
| },0); | |
| function loadNext() { | |
| var $next = $carousel.find("img.unloaded:first"); | |
| if ($next.length == 1) { | |
| lazyLoad($next[0],function(){$next.removeClass('unloaded')}); | |
| } | |
| } | |
| $left.unbind('click').click(function(){ | |
| var $currentImg = $carousel.find(".img-gal-item.current:first"); | |
| var $prev = $currentImg.prev(); | |
| $currentImg.removeClass('current'); | |
| $prev.addClass('current'); | |
| //$right.show(); | |
| // if($prev.prev().length > 0){ | |
| // $left.show(); | |
| // } else { | |
| // $left.hide(); | |
| // } | |
| $carousel.slideToCurrent(); | |
| }); | |
| $right.unbind('click').click(function(){ | |
| var $currentImg = $carousel.find(".img-gal-item.current:first"); | |
| var $next = $currentImg.next(); | |
| $next.addClass('current'); | |
| $currentImg.removeClass('current'); | |
| // $left.show(); | |
| // if($next.next().length > 0){ | |
| // $right.show(); | |
| // } else { | |
| // $right.hide(); | |
| // } | |
| $carousel.slideToCurrent(); | |
| loadNext(); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment