Guest User

Untitled

a guest
Aug 13th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.78 KB | None | 0 0
  1. var source;
  2. var target;
  3. var action;
  4. var search;
  5. var row;
  6. var col;
  7. //Hold
  8. $.fn.hold = function (time, func) {
  9. return this.each(function () {
  10. setTimeout(func, time);
  11. });
  12. }
  13. //Hash Link
  14. function hash() {
  15. $("#list .list-link, .slider-ui li, .slider-contact li").each(function () {
  16. $(this).attr("link", $(this).attr("title"));
  17. $(this).removeAttr("title");
  18. });
  19. }
  20. //Deep Link
  21. function deep() {
  22. if (location.hash.indexOf("/") > 0) {
  23. row = location.hash.split("/")[0].substring(1);
  24. col = location.hash.split("/")[1].substring(0);
  25. }
  26. if (location.hash.indexOf("/") < 1) {
  27. row = location.hash.substring(1);
  28. col = "";
  29. }
  30. }
  31. //Toggle
  32. function toggle() {
  33. $("#header").slideToggle(200);
  34. $("#search-holder").slideToggle(200);
  35. }
  36. //Unload
  37. function unload() {
  38. $(".menu li").removeClass("link-active");
  39. $(this).hold(200, function () {
  40. toggle();
  41. $(this).hold(400, function () {
  42. $("#content").hide(400);
  43. $(this).hold(400, function () {
  44. location.href = target;
  45. });
  46. });
  47. });
  48. }
  49. function search_enable() {
  50. $("#search").css("color", "#666666");
  51. $("#cse-search-box .action").removeClass("disabled");
  52. $("#cse-search-box .submit").removeAttr("disabled");
  53. }
  54. function search_toggle() {
  55. $("#search").css("color", "#AAAAAA");
  56. $("#cse-search-box .action").addClass("disabled");
  57. $("#cse-search-box .submit").attr("disabled", "disabled");
  58. }
  59. function search_active() {
  60. $("#search").css("color", "#666666");
  61. $("#cse-search-box .submit").removeAttr("disabled");
  62. }
  63. function search_filter() {
  64. $("#cse-search-box .action").addClass("disabled");
  65. $("#cse-search-box .submit").attr("disabled", "disabled");
  66. }
  67. function project_show() {
  68. $(".project .top").stop().animate({paddingBottom: 0}, 400);
  69. $(".project .bottom").stop().animate({paddingTop: 0}, 400);
  70. $(".project .left").stop().animate({paddingRight: 0}, 400);
  71. $(".project .right").stop().animate({paddingLeft: 0}, 400, function () {
  72. $(".holder").addClass("open");
  73. });
  74. }
  75. function project_hide() {
  76. $(".holder").removeClass("open");
  77. $(".project .top").stop().animate({paddingBottom: 80}, 400);
  78. $(".project .bottom").stop().animate({paddingTop: 80}, 400);
  79. $(".project .left").stop().animate({paddingRight: 180}, 400);
  80. $(".project .right").stop().animate({paddingLeft: 180}, 400);
  81. }
  82. $(document).ready(function () {
  83. //Source
  84. source = $("#content").attr("class");
  85. //Target
  86. $("a:not(.action):not(.list-link):not(.expire):not(.tag)").click(function () {
  87. target = $(this).attr("href");
  88. if ($(this).closest("li").is(":not(.slide-active)") || $(this).is(".trigger")) {
  89. $(this).closest("li").trigger("click");
  90. return false;
  91. }
  92. if ($(this).filter(":not(.custom)").closest("li").is(".slide-active")) {
  93. unload();
  94. return false;
  95. }
  96. if ($(this).is(".contact-profile")) {
  97. $("#login_form").submit();
  98. return false;
  99. }
  100. unload();
  101. return false;
  102. });
  103. //Action
  104. $(".action:not(.disabled)").click(function () {
  105. action = $(this).closest("form").attr("id");
  106. $("#" + action).submit();
  107. });
  108. $("form").submit(function () {
  109. $(this).find(".action").addClass("disabled");
  110. });
  111. //UI
  112. $("#list .list-link").click(function () {
  113. $(".list-link").removeClass("list-active");
  114. $(this).addClass("list-active");
  115. $(this).parent(".list-wrapper").find(".list-content").slideDown(200, function () {
  116. $(".list-wrapper").filter(":not(:has(.list-active))").find(".list-content").slideUp(200);
  117. });
  118. $(".list-link:not(.list-active) .list-head").stop().animate({left: 0}, 200);
  119. $(".list-active").find(".list-head").stop().animate({left: 352 - $(this).find(".list-head").width()}, 200);
  120. return false;
  121. });
  122. $("#list .list-link").hover(function () {
  123. $(this).filter(":not(.list-active)").find(".list-head").stop().animate({left: 4}, 100);
  124. }, function () {
  125. $(this).filter(":not(.list-active)").find(".list-head").stop().animate({left: 0}, 100);
  126. });
  127. $(".menu li:not(.link-active)").hover(function () {
  128. $(this).find("img").stop().animate({marginLeft: 4}, 100);
  129. }, function () {
  130. $(this).find("img").stop().animate({marginLeft: 0}, 100);
  131. });
  132. $(".trigger img").each(function () {
  133. $(this).appendTo($(this).closest("li").find(".tag"));
  134. });
  135. //Slider
  136. $(".slider-ui li").click(function () {
  137. $(this).closest(".list-wrapper").find("li").removeClass("slide-active");
  138. $(this).addClass("slide-active");
  139. $(this).find(".lock").stop().css("left", 252);
  140. $(this).find(".block").delay(200).fadeIn(400);
  141. $(this).find("h3").delay(200).show().animate({width: 244}, 200, function () {
  142. $(this).closest("li").find("span").animate({opacity: 1, left: 0}, 200);
  143. });
  144. $(this).find(".trigger").hide();
  145. $(this).closest(".list-wrapper").find("li:not(.slide-active)").each(function () {
  146. $(this).find(".block").fadeOut(400);
  147. $(this).find("span").animate({opacity: 0, left: 244}, 200, function () {
  148. $(this).removeAttr("style");
  149. $(this).closest("li").find("h3").animate({width: 0}, 200, function () {
  150. $(this).hide();
  151. $(this).closest("li").find(".lock").stop().animate({left: 0}, 200, function () {
  152. $(this).closest("li").find(".trigger").show();
  153. });
  154. });
  155. });
  156. });
  157. if ($(this).is(".slide-1")) {
  158. $(this).closest(".list-wrapper").find(".slide-2").animate({left: 260}, 200);
  159. $(this).closest(".list-wrapper").find(".slide-3").animate({left: 310}, 200);
  160. }
  161. if ($(this).is(".slide-2")) {
  162. $(this).closest(".list-wrapper").find(".slide-2").animate({left: 50}, 200);
  163. $(this).closest(".list-wrapper").find(".slide-3").animate({left: 310}, 200);
  164. }
  165. if ($(this).is(".slide-3")) {
  166. $(this).closest(".list-wrapper").find(".slide-2").animate({left: 50}, 200);
  167. $(this).closest(".list-wrapper").find(".slide-3").animate({left: 100}, 200);
  168. }
  169. location.hash = "#" + $(this).closest(".list-wrapper").find(".list-active").attr("link") + "/" + $(this).attr("link");
  170. });
  171. $(".slider-contact li").click(function () {
  172. $(this).closest(".list-wrapper").find("li").removeClass("slide-active");
  173. $(this).addClass("slide-active");
  174. $(this).filter(".slide-1").closest(".list-wrapper").find(".slide-2").animate({left: 310}, 200);
  175. $(this).filter(".slide-2").closest(".list-wrapper").find(".slide-2").animate({left: 50}, 200);
  176. });
  177. //Authentication
  178. $("#login_form").submit(function () {
  179. if ($("#content").is(".contact")) {
  180. source = "profile";
  181. $(".contact-profile").removeClass("text-link").text("Authenticating...");
  182. }
  183. $("#login_form .field").removeClass("fail");
  184. $.post(source + "/authenticate", {username: $("#username").val(), password: $("#password").val(), rand: Math.random()}, function (data) {
  185. if (data == "1") {
  186. if ($("#content").is(".service, .profile")) {
  187. location.reload();
  188. }
  189. }
  190. else {
  191. $("#login_form .field").addClass("fail");
  192. $("#login_form .action").removeClass("disabled");
  193. }
  194. if ($("#content").is(".contact")) {
  195. $(".contact-profile").text("Redirecting...");
  196. unload();
  197. }
  198. });
  199. return false;
  200. });
  201. //Contact Form
  202. $("#contact_form").submit(function () {
  203. $("#contact_form .field").removeClass("fail");
  204. var get = $(this).serialize();
  205. $.ajax({type: "post", url: source + "/process", data: get, success: function (data) {
  206. $("#notice").ajaxComplete(function (event, request, settings) {
  207. if (data == "1") {
  208. $("#notice").show();
  209. $("#fields").hide();
  210. result = '<div id="success"><p>The message has been sent.</p><p>Please allow up to 24 hours for a reply.</p></div>';
  211. }
  212. else {
  213. result = data;
  214. $("#contact_form .field").removeClass("fail");
  215. $("#contact_form .action").removeClass("disabled");
  216. }
  217. $(this).html(result);
  218. if ($("#fail:contains(1)").length == 1) {
  219. $("#name").addClass("fail");
  220. }
  221. if ($("#fail:contains(2)").length == 1) {
  222. $("#addr").addClass("fail");
  223. }
  224. if ($("#fail:contains(3)").length == 1) {
  225. $("#text").addClass("fail");
  226. }
  227. });
  228. }
  229. });
  230. return false;
  231. });
  232. $("#list .list-link").click(function () {
  233. if ($(this).closest("#list").find(".slide-active").length == 0) {
  234. $(this).parent(".list-wrapper").find('li[link="' + col + '"]').trigger("click");
  235. }
  236. if ($(this).parent(".list-wrapper").find(".slide-active").length == 0) {
  237. $(this).parent(".list-wrapper").find(".slide-1").trigger("click");
  238. }
  239. if ($(this).parent(".list-wrapper").find(".slide-active").length == 1) {
  240. $(this).parent(".list-wrapper").find(".slide-active").trigger("click");
  241. }
  242. });
  243. //UI
  244. if ($("#content").is(".core, .code")) {
  245. hash();
  246. deep();
  247. }
  248. //Project
  249. if ($("#content").is(".project")) {
  250. $(".holder").toggle(function () {
  251. project_hide();
  252. }, function () {
  253. project_show();
  254. });
  255. }
  256. //Contact
  257. $(".slider-contact li").click(function () {
  258. location.hash = "#" + $(this).attr("link");
  259. });
  260. //Navigation
  261. $(".menu a").click(function () {
  262. unload();
  263. $(this).parent("li").addClass("link-active");
  264. });
  265. //Search
  266. search = $("#cse-search-box .val").val();
  267. if ($("#search").val() == "") {
  268. $("#search").val(search);
  269. }
  270. if ($("#search").val() != search) {
  271. search_enable();
  272. }
  273. $("#search").focus(function () {
  274. if ($(this).val() == search) {
  275. $(this).val("");
  276. search_active();
  277. }
  278. if ($(this).val() != "") {
  279. search_enable();
  280. }
  281. });
  282. $("#search").blur(function () {
  283. if ($(this).val() == "") {
  284. $(this).val(search);
  285. search_toggle();
  286. }
  287. if ($(this).val() == search) {
  288. search_toggle();
  289. }
  290. });
  291. $("#search").bind("keydown keyup click", function () {
  292. if ($(this).val() != search) {
  293. search_enable();
  294. }
  295. if ($(this).val() == "") {
  296. search_filter();
  297. }
  298. if ($(this).val() == search) {
  299. $(this).blur();
  300. }
  301. });
  302. $("#search").bind("paste", function () {
  303. $(this).hold(0, function () {
  304. if ($(this).val() != search) {
  305. search_enable();
  306. }
  307. if ($("#search").val() == search) {
  308. $("#search").blur();
  309. }
  310. });
  311. });
  312. //$Ready
  313. });
  314. $(window).load(function () {
  315. //Active
  316. $("#link-" + source).removeClass("link").addClass("link-active");
  317. $("#link-" + source + " a").removeAttr("href").unbind("click");
  318. $(".menu-link img").attr({alt: ""});
  319. //Contact
  320. if ($("#content").is(".contact")) {
  321. hash();
  322. if (location.hash == "") {
  323. $(".slider-contact .slide-1").trigger("click");
  324. }
  325. if (location.hash != "") {
  326. $(this).hold(200, function () {
  327. $('.slider-contact li[link="' + location.hash.substring(1) + '"]').trigger("click");
  328. });
  329. }
  330. }
  331. //Start
  332. $("#content").show(400);
  333. $(this).hold(800, function () {
  334. toggle();
  335. //UI
  336. if ($("#content").is(".core, .code")) {
  337. if (location.hash == "") {
  338. $(this).hold(200, function () {
  339. $("#list-wrapper-1 .list-link").trigger("click");
  340. });
  341. }
  342. if (location.hash != "") {
  343. $(this).hold(200, function () {
  344. $('.list-link[link="' + row + '"]').trigger("click");
  345. });
  346. }
  347. }
  348. //Project
  349. if ($("#content").is(".project")) {
  350. $(this).hold(400, function () {
  351. project_show();
  352. });
  353. }
  354. });
  355. $(".slider-ui li").hover(function () {
  356. $(this).filter(":not(.slide-active)").find(".lock").stop().animate({left: 42}, 200);
  357. }, function () {
  358. $(this).filter(":not(.slide-active)").find(".lock").stop().animate({left: 0}, 200);
  359. });
  360. //$Load
  361. });
Add Comment
Please, Sign In to add comment