$(function () { $('.final-tiles-gallery').finalTilesGallery({ margin: 5, gridSize: 20, layout: 'final', minTileWidth: 400, autoLoadURL: "/gallery_images.php", onLoading: function () { loading = setTimeout(function () { $(".ftg-page-loader").fadeIn(); }, 100); }, onUpdate: function () { clearTimeout(loading); $(".ftg-page-loader").fadeOut(); } }); }); $( "#show_past_gallery" ).on( "click", function() { $( ".main_content_pane" ).addClass('hidden'); $( "#past_gallery" ).removeClass('hidden'); }); $( "#close_gallery_button" ).on( "click", function() { $( "#past_gallery" ).addClass('hidden'); $( ".main_content_pane" ).removeClass('hidden'); }); $( "#open_search" ).on( "click", function() { $( "#open_search" ).addClass('hidden'); $( "#close_search" ).removeClass('hidden'); $( "#search_module" ).removeClass('hidden'); }); $( "#close_search" ).on( "click", function() { $( "#search_module" ).addClass('hidden'); $( "#close_search" ).addClass('hidden'); $( "#open_search" ).removeClass('hidden'); }); $(function() { $( "#site_search" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "/cmd.php", dataType: "json", data: { query: request.term, cmd: 'search', type: 'main' }, success: function( data ) { response( data.message ); } }); }, minLength: 3, select: function( e, ui ) { e.preventDefault(); if( ui.item.url != 'none' ) { $( "#site_search" ).val(''); window.location.replace(ui.item.url); } }, open: function() { $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); }, close: function() { $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); } }); }); $( "#login_button" ).on( "click", function() { $data = $("#login_form").serialize(); $username = $("#login_username_or_email").val(); $.ajax({ type: "POST", url: "/cmd.php", maxSelection: 3, maxEntryLength: 30, expandOnFocus: true, data: { cmd: "login", data: $data } }) .done(function( result ) { var data = jQuery.parseJSON( result ); if( data.status == "failure" ) { window.location.replace("/login/?bad_login="+$username ); } else { window.location.replace("/"); } }); return false; }); $("#login_password").keypress(function(event) { if (event.which == 13) { event.preventDefault(); $( "#login_button" ).trigger( "click" ); } }); $('.no-action').click(function(){ return false; }); $( "#resend_welcome" ).on( "click", function() { $message_type = $(this).attr('message_type'); $.ajax({ type: "POST", url: "/cmd.php", maxSelection: 3, maxEntryLength: 30, expandOnFocus: true, data: { cmd: "resend_welcome", type: $message_type } }) .done(function( result ) { var data = jQuery.parseJSON( result ); if( data.status == "failure" ) { alert('We were unable to send your message at this time. Please try again later.'); } else { if( data.message == "confirmed" ) { $( "#"+$message_type+"unconfirmed_div" ).addClass('hidden'); $( "#"+$message_type+"confirmed_div" ).removeClass('hidden'); } else if( data.message == "sent" ) { $( "#"+$message_type+"unconfirmed_div" ).addClass('hidden'); $( "#"+$message_type+"resent_div" ).removeClass('hidden'); } } }); return false; }); $( ".refresh_user" ).on( "click", function() { $message_type = $(this).attr('message_type'); $.ajax({ type: "POST", url: "/cmd.php", maxSelection: 3, maxEntryLength: 30, expandOnFocus: true, data: { cmd: "refresh_user", type: $message_type } }) .done(function( result ) { var data = jQuery.parseJSON( result ); if( data.status == "failure" ) { alert('We were unable to refresh user status. Please try again later.'); } else { if( data.message == true ) { $( "#"+$message_type+"_unconfirmed_div" ).addClass('hidden'); $( "#"+$message_type+"_confirmed_div" ).removeClass('hidden'); } else { $( "#"+$message_type+"_unconfirmed_div" ).html('Looks like there is a delay is updating. Please check back a little bit later.'); } } }); return false; });