var env_path = ''; var strat_zoom = 0; var strat_notes = 1; $(function() { // environment path /* if($('#env_path').length != 0) { env_path = "\/"; env_path += $("#env_path").val(); if(env_path != '/randomnade') env_path = ''; } */ //hud maps hover $('.recent-maps a').hover(function(){ $(this).find(".map-name-tip").show(); }) $('.recent-maps a').mouseleave(function(){ $(this).find(".map-name-tip").hide(); }) // strategy and map hover states $(".strategy-box").hover(function(){ $(this).find(".strategy-options").show(); }); $(".strategy-box").mouseleave(function(){ $(this).find(".strategy-options").hide(); }); $(".strategy-box").click(function(){ window.location.href = $(this).find(".strategy-options .view-link").attr("href"); }); // follow list hover states and user list hover states $(".followers-list-wrap .followers-list li, .user-list-wrapper .user-list li").hover(function(){ $(this).find(".btn_viewprofile").show(); }); $(".followers-list-wrap .followers-list li, .user-list-wrapper .user-list li").mouseleave(function(){ $(this).find(".btn_viewprofile").hide(); }); //view game list hover states $(".games-list li").hover(function(){ $(this).find(".btn_viewgame").show(); $(this).addClass("hovering"); }); $(".games-list li").mouseleave(function(){ $(this).find(".btn_viewgame").hide(); $(this).removeClass("hovering"); }); // fade out flash messages if($('#flashMessage').length != 0) { $('#flashMessage').delay(2000).fadeOut(); } /* quick search forms default vals */ $('.quick-search-form input[type="input"]').focus(function(){ if($(this).val() == 'Search') $(this).val(""); }); $('.quick-search-form input[type="input"]').blur(function(){ if($(this).val() == "") $(this).val('Search'); }); /* comments form */ $("#StrategyViewForm").submit(function(event) { event.preventDefault(); //local server version $.ajax({data:$("#submit_btn").closest("form").serialize(), type:"post", url: env_path + "\/strategies\/postcomment\/"}); //live server version $.ajax({data:$("#submit_btn").closest("form").serialize(), type:"post", url:"\/strategies\/postcomment\/"}); var user = $("#StrategyCommentUser").val(); var comment = $("#StrategyCommentComment").val();; var comment_html = '
'; if(comment != '') { if($('.no-comments').length != 0) $('.no-comments').remove(); $(".comments-list ul").append(comment_html); $(".hidden-comment").fadeIn(); } $("#StrategyCommentComment").val(""); }) $(".share-delete").click(function(event) { event.preventDefault(); $.post(env_path + "\/strategies\/postsharedelete\/", { data: $(this).attr('data-id')} );//{data: { id: $(this).attr('data-id') } } } ); $(this).html("Deleted"); $(this).css("background-color","#f14f4f"); }) $("#StrategyShareViewForm").submit(function(event) { event.preventDefault(); //local server version $.ajax({data:$("#submit_share_btn").closest("form").serialize(), type:"post", url: env_path + "\/strategies\/postshare\/"}); }) $('.feed-like').live('click', function(event) { event.preventDefault(); $.ajax({ type: "post", url: env_path + "\/users\/like_activity\/" + event.target.id }); if(!$(this).hasClass("like_activity")){ var like_count = parseInt($(this).html()); like_count = like_count + 1; $(this).html(like_count); $(this).addClass("like_activity"); $(this).parent().find(".i-like-notification").html("You like") } }); // handle strategy zoom var test = 1; var top; var left; window.addEventListener('SVGLoad', function() { // all SVG loaded and rendered if($("#svg-wrapper-small object").length != 0) $("#svg-wrapper-big").height($("#svg-wrapper-small object").attr("height")); else $("#svg-wrapper-big").height($("#svg-wrapper-small").height()); $("#svg-wrapper-big").scrollLeft(99999).scrollTop(99999); // grab max scroll width / height left = $("#svg-wrapper-big").scrollLeft(); top = $("#svg-wrapper-big").scrollLeft(); $("#svg-wrapper-big").hide(); }, false); $(".zoom-strategy").click(function(){ if(!strat_zoom) { $("#svg-wrapper-small").hide(); $("#svg-wrapper-big").show(); $(".zoom-pan-instructions").show(); $("#svg-wrapper-big").scrollview(); //set scroll width / height to center $("#svg-wrapper-big").scrollLeft(left/2).scrollTop(top/2); $(".zoom-strategy").addClass("zoom-strategy-on"); strat_zoom = 1; } else { $("#svg-wrapper-small").show(); $("#svg-wrapper-big").hide(); $(".zoom-pan-instructions").hide(); $(".zoom-strategy").removeClass("zoom-strategy-on"); strat_zoom = 0; } }); $(".strategy-notes-header").click(function(){ if(strat_notes) { $('.strategy-notes-content').hide(); $(this).addClass("strategy-notes-header-closed"); strat_notes = 0; } else { $('.strategy-notes-content').show(); $(this).removeClass("strategy-notes-header-closed"); strat_notes = 1; } }) if($(".public-strats-modal").length != 0) { $(".public-strats-modal").modal({ opacity:70, overlayCss: {backgroundColor:"#124F72"}, overlayClose: true, persist: true, closeClass: "close-modal" }) } $(".close-welcome").click(function(){ $.modal.close(); }) if($(".pub-strat-modal").length != 0) { $(".pub-strat-modal").modal({ opacity:70, overlayCss: {backgroundColor:"#124F72"}, overlayClose: true, persist: true, closeClass: "close-modal" }) } // add map modal $(".add-map").click(function(){ $(".basic-modal").modal({ opacity:70, overlayCss: {backgroundColor:"#124F72"}, overlayClose: true, persist: true, closeClass: "close-modal" }) return false; }) // login modal $(".login-link, .not-logged-in").click(function(){ $(".login-modal").modal({ opacity:70, overlayCss: {backgroundColor:"#124F72"}, overlayClose: true, persist: true, closeClass: "close-modal" }) return false; }) if($('.login-failed').length != 0){ $(".login-modal").modal({ opacity:70, overlayCss: {backgroundColor:"#124F72"}, overlayClose: true, persist: true, closeClass: "close-modal" }) } if($('.password-reset').length != 0){ $(".login-modal").modal({ opacity:70, overlayCss: {backgroundColor:"#124F72"}, overlayClose: true, persist: true, closeClass: "close-modal" }) $(".login-wrap, .forgot-desc").hide(); $(".forgotpass-wrap, .reset-pass-desc").show(); } $(".forgot-pass a").click(function(){ $(".login-wrap").hide(); $(".forgotpass-wrap").show(); }) $(".backtosignup").click(function(){ $(".login-wrap").show(); $(".forgotpass-wrap").hide(); }) //show/hide related strat view links $(".related-strategy").mouseover(function(){ $(this).find(".view-strat-link").show(); }) $(".related-strategy").mouseout(function(){ $(this).find(".view-strat-link").hide(); }) //show/hide build strat button on map list on game pages $(".map-row").mouseover(function(){ $(this).find(".map-row-options").show(); }) $(".map-row").mouseout(function(){ $(this).find(".map-row-options").hide(); }) $(window).load(function () { //vertical center buttons on map page if($(".map-row").length != 0){ var map_height = $(".map-row-image").height(); $(".map-row").css("height",map_height); $(".map-row-info").css("top",map_height/2-15); if($(".map-row").height() < 100){ $(".map-row").css("min-height","100px"); $(".map-row-options").css("top","20px"); } else{ $(".map-row-options").css("top",map_height/2-25); } } }); //tactical notes toggle $(".tactical-notes .min-max").click(function(){ if($(this).hasClass("min-max-toggle")){ $(".tactical-notes-content").show(); $(this).removeClass("min-max-toggle"); $(this).parent().find("h1").css("margin-bottom","10px"); } else{ $(".tactical-notes-content").hide(); $(this).addClass("min-max-toggle"); $(this).parent().find("h1").css("margin-bottom","0px") } return false; }) if($("#workarea").length != 0){ $("#workarea").scrollLeft($("#workarea").scrollLeft()+27); } //build strategy modal $(".build-strategy-btn").click(function(){ $(".build-strategy-modal").modal({ opacity:70, overlayCss: {backgroundColor:"#124F72"}, overlayClose: true, persist: true, closeClass: "close-modal" }) }) // $(".game-block a").hover(function(){ $(this).parent().find("a").css("opacity", ".5"); $(this).css("opacity", "1"); }) $(".game-block").mouseout(function(){ $(this).find("a").css("opacity", "1"); }) //sign up page if($(".signup-form-wrap").length != 0){ $("#InviteEmail").val("Your email address"); } $("#InviteEmail").focus(function(){ if( $("#InviteEmail").val() == "Your email address"){ $("#InviteEmail").val(""); } }) $("#InviteEmail").blur(function(){ if( $("#InviteEmail").val() == ""){ $("#InviteEmail").val("Your email address"); } }) $(".sign-me-up-already").click(function(){ $(window).scrollTop(0); $("#InviteEmail").addClass("highlight-field"); }) // top search $(".quick-search").focus(function(){ if( $(".quick-search").val() == "Find your favorite game"){ $(".quick-search").val(""); } }) $(".quick-search").blur(function(){ if( $(".quick-search").val() == ""){ $(".quick-search").val("Find your favorite game"); } }) });