Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var source;
- var target;
- var action;
- var search;
- var row;
- var col;
- //Hold
- $.fn.hold = function (time, func) {
- return this.each(function () {
- setTimeout(func, time);
- });
- }
- //Hash Link
- function hash() {
- $("#list .list-link, .slider-ui li, .slider-contact li").each(function () {
- $(this).attr("link", $(this).attr("title"));
- $(this).removeAttr("title");
- });
- }
- //Deep Link
- function deep() {
- if (location.hash.indexOf("/") > 0) {
- row = location.hash.split("/")[0].substring(1);
- col = location.hash.split("/")[1].substring(0);
- }
- if (location.hash.indexOf("/") < 1) {
- row = location.hash.substring(1);
- col = "";
- }
- }
- //Toggle
- function toggle() {
- $("#header").slideToggle(200);
- $("#search-holder").slideToggle(200);
- }
- //Unload
- function unload() {
- $(".menu li").removeClass("link-active");
- $(this).hold(200, function () {
- toggle();
- $(this).hold(400, function () {
- $("#content").hide(400);
- $(this).hold(400, function () {
- location.href = target;
- });
- });
- });
- }
- function search_enable() {
- $("#search").css("color", "#666666");
- $("#cse-search-box .action").removeClass("disabled");
- $("#cse-search-box .submit").removeAttr("disabled");
- }
- function search_toggle() {
- $("#search").css("color", "#AAAAAA");
- $("#cse-search-box .action").addClass("disabled");
- $("#cse-search-box .submit").attr("disabled", "disabled");
- }
- function search_active() {
- $("#search").css("color", "#666666");
- $("#cse-search-box .submit").removeAttr("disabled");
- }
- function search_filter() {
- $("#cse-search-box .action").addClass("disabled");
- $("#cse-search-box .submit").attr("disabled", "disabled");
- }
- function project_show() {
- $(".project .top").stop().animate({paddingBottom: 0}, 400);
- $(".project .bottom").stop().animate({paddingTop: 0}, 400);
- $(".project .left").stop().animate({paddingRight: 0}, 400);
- $(".project .right").stop().animate({paddingLeft: 0}, 400, function () {
- $(".holder").addClass("open");
- });
- }
- function project_hide() {
- $(".holder").removeClass("open");
- $(".project .top").stop().animate({paddingBottom: 80}, 400);
- $(".project .bottom").stop().animate({paddingTop: 80}, 400);
- $(".project .left").stop().animate({paddingRight: 180}, 400);
- $(".project .right").stop().animate({paddingLeft: 180}, 400);
- }
- $(document).ready(function () {
- //Source
- source = $("#content").attr("class");
- //Target
- $("a:not(.action):not(.list-link):not(.expire):not(.tag)").click(function () {
- target = $(this).attr("href");
- if ($(this).closest("li").is(":not(.slide-active)") || $(this).is(".trigger")) {
- $(this).closest("li").trigger("click");
- return false;
- }
- if ($(this).filter(":not(.custom)").closest("li").is(".slide-active")) {
- unload();
- return false;
- }
- if ($(this).is(".contact-profile")) {
- $("#login_form").submit();
- return false;
- }
- unload();
- return false;
- });
- //Action
- $(".action:not(.disabled)").click(function () {
- action = $(this).closest("form").attr("id");
- $("#" + action).submit();
- });
- $("form").submit(function () {
- $(this).find(".action").addClass("disabled");
- });
- //UI
- $("#list .list-link").click(function () {
- $(".list-link").removeClass("list-active");
- $(this).addClass("list-active");
- $(this).parent(".list-wrapper").find(".list-content").slideDown(200, function () {
- $(".list-wrapper").filter(":not(:has(.list-active))").find(".list-content").slideUp(200);
- });
- $(".list-link:not(.list-active) .list-head").stop().animate({left: 0}, 200);
- $(".list-active").find(".list-head").stop().animate({left: 352 - $(this).find(".list-head").width()}, 200);
- return false;
- });
- $("#list .list-link").hover(function () {
- $(this).filter(":not(.list-active)").find(".list-head").stop().animate({left: 4}, 100);
- }, function () {
- $(this).filter(":not(.list-active)").find(".list-head").stop().animate({left: 0}, 100);
- });
- $(".menu li:not(.link-active)").hover(function () {
- $(this).find("img").stop().animate({marginLeft: 4}, 100);
- }, function () {
- $(this).find("img").stop().animate({marginLeft: 0}, 100);
- });
- $(".trigger img").each(function () {
- $(this).appendTo($(this).closest("li").find(".tag"));
- });
- //Slider
- $(".slider-ui li").click(function () {
- $(this).closest(".list-wrapper").find("li").removeClass("slide-active");
- $(this).addClass("slide-active");
- $(this).find(".lock").stop().css("left", 252);
- $(this).find(".block").delay(200).fadeIn(400);
- $(this).find("h3").delay(200).show().animate({width: 244}, 200, function () {
- $(this).closest("li").find("span").animate({opacity: 1, left: 0}, 200);
- });
- $(this).find(".trigger").hide();
- $(this).closest(".list-wrapper").find("li:not(.slide-active)").each(function () {
- $(this).find(".block").fadeOut(400);
- $(this).find("span").animate({opacity: 0, left: 244}, 200, function () {
- $(this).removeAttr("style");
- $(this).closest("li").find("h3").animate({width: 0}, 200, function () {
- $(this).hide();
- $(this).closest("li").find(".lock").stop().animate({left: 0}, 200, function () {
- $(this).closest("li").find(".trigger").show();
- });
- });
- });
- });
- if ($(this).is(".slide-1")) {
- $(this).closest(".list-wrapper").find(".slide-2").animate({left: 260}, 200);
- $(this).closest(".list-wrapper").find(".slide-3").animate({left: 310}, 200);
- }
- if ($(this).is(".slide-2")) {
- $(this).closest(".list-wrapper").find(".slide-2").animate({left: 50}, 200);
- $(this).closest(".list-wrapper").find(".slide-3").animate({left: 310}, 200);
- }
- if ($(this).is(".slide-3")) {
- $(this).closest(".list-wrapper").find(".slide-2").animate({left: 50}, 200);
- $(this).closest(".list-wrapper").find(".slide-3").animate({left: 100}, 200);
- }
- location.hash = "#" + $(this).closest(".list-wrapper").find(".list-active").attr("link") + "/" + $(this).attr("link");
- });
- $(".slider-contact li").click(function () {
- $(this).closest(".list-wrapper").find("li").removeClass("slide-active");
- $(this).addClass("slide-active");
- $(this).filter(".slide-1").closest(".list-wrapper").find(".slide-2").animate({left: 310}, 200);
- $(this).filter(".slide-2").closest(".list-wrapper").find(".slide-2").animate({left: 50}, 200);
- });
- //Authentication
- $("#login_form").submit(function () {
- if ($("#content").is(".contact")) {
- source = "profile";
- $(".contact-profile").removeClass("text-link").text("Authenticating...");
- }
- $("#login_form .field").removeClass("fail");
- $.post(source + "/authenticate", {username: $("#username").val(), password: $("#password").val(), rand: Math.random()}, function (data) {
- if (data == "1") {
- if ($("#content").is(".service, .profile")) {
- location.reload();
- }
- }
- else {
- $("#login_form .field").addClass("fail");
- $("#login_form .action").removeClass("disabled");
- }
- if ($("#content").is(".contact")) {
- $(".contact-profile").text("Redirecting...");
- unload();
- }
- });
- return false;
- });
- //Contact Form
- $("#contact_form").submit(function () {
- $("#contact_form .field").removeClass("fail");
- var get = $(this).serialize();
- $.ajax({type: "post", url: source + "/process", data: get, success: function (data) {
- $("#notice").ajaxComplete(function (event, request, settings) {
- if (data == "1") {
- $("#notice").show();
- $("#fields").hide();
- result = '<div id="success"><p>The message has been sent.</p><p>Please allow up to 24 hours for a reply.</p></div>';
- }
- else {
- result = data;
- $("#contact_form .field").removeClass("fail");
- $("#contact_form .action").removeClass("disabled");
- }
- $(this).html(result);
- if ($("#fail:contains(1)").length == 1) {
- $("#name").addClass("fail");
- }
- if ($("#fail:contains(2)").length == 1) {
- $("#addr").addClass("fail");
- }
- if ($("#fail:contains(3)").length == 1) {
- $("#text").addClass("fail");
- }
- });
- }
- });
- return false;
- });
- $("#list .list-link").click(function () {
- if ($(this).closest("#list").find(".slide-active").length == 0) {
- $(this).parent(".list-wrapper").find('li[link="' + col + '"]').trigger("click");
- }
- if ($(this).parent(".list-wrapper").find(".slide-active").length == 0) {
- $(this).parent(".list-wrapper").find(".slide-1").trigger("click");
- }
- if ($(this).parent(".list-wrapper").find(".slide-active").length == 1) {
- $(this).parent(".list-wrapper").find(".slide-active").trigger("click");
- }
- });
- //UI
- if ($("#content").is(".core, .code")) {
- hash();
- deep();
- }
- //Project
- if ($("#content").is(".project")) {
- $(".holder").toggle(function () {
- project_hide();
- }, function () {
- project_show();
- });
- }
- //Contact
- $(".slider-contact li").click(function () {
- location.hash = "#" + $(this).attr("link");
- });
- //Navigation
- $(".menu a").click(function () {
- unload();
- $(this).parent("li").addClass("link-active");
- });
- //Search
- search = $("#cse-search-box .val").val();
- if ($("#search").val() == "") {
- $("#search").val(search);
- }
- if ($("#search").val() != search) {
- search_enable();
- }
- $("#search").focus(function () {
- if ($(this).val() == search) {
- $(this).val("");
- search_active();
- }
- if ($(this).val() != "") {
- search_enable();
- }
- });
- $("#search").blur(function () {
- if ($(this).val() == "") {
- $(this).val(search);
- search_toggle();
- }
- if ($(this).val() == search) {
- search_toggle();
- }
- });
- $("#search").bind("keydown keyup click", function () {
- if ($(this).val() != search) {
- search_enable();
- }
- if ($(this).val() == "") {
- search_filter();
- }
- if ($(this).val() == search) {
- $(this).blur();
- }
- });
- $("#search").bind("paste", function () {
- $(this).hold(0, function () {
- if ($(this).val() != search) {
- search_enable();
- }
- if ($("#search").val() == search) {
- $("#search").blur();
- }
- });
- });
- //$Ready
- });
- $(window).load(function () {
- //Active
- $("#link-" + source).removeClass("link").addClass("link-active");
- $("#link-" + source + " a").removeAttr("href").unbind("click");
- $(".menu-link img").attr({alt: ""});
- //Contact
- if ($("#content").is(".contact")) {
- hash();
- if (location.hash == "") {
- $(".slider-contact .slide-1").trigger("click");
- }
- if (location.hash != "") {
- $(this).hold(200, function () {
- $('.slider-contact li[link="' + location.hash.substring(1) + '"]').trigger("click");
- });
- }
- }
- //Start
- $("#content").show(400);
- $(this).hold(800, function () {
- toggle();
- //UI
- if ($("#content").is(".core, .code")) {
- if (location.hash == "") {
- $(this).hold(200, function () {
- $("#list-wrapper-1 .list-link").trigger("click");
- });
- }
- if (location.hash != "") {
- $(this).hold(200, function () {
- $('.list-link[link="' + row + '"]').trigger("click");
- });
- }
- }
- //Project
- if ($("#content").is(".project")) {
- $(this).hold(400, function () {
- project_show();
- });
- }
- });
- $(".slider-ui li").hover(function () {
- $(this).filter(":not(.slide-active)").find(".lock").stop().animate({left: 42}, 200);
- }, function () {
- $(this).filter(":not(.slide-active)").find(".lock").stop().animate({left: 0}, 200);
- });
- //$Load
- });
Add Comment
Please, Sign In to add comment