Guest User

Untitled

a guest
May 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. $(function() {
  2. $("div.blocks:last").hide();
  3.  
  4. $("#tabs li").hover(function() {
  5. $(this).addClass("over");
  6. }, function() {
  7. $(this).removeClass("over");
  8. });
  9.  
  10. $("#tabs li").click(function() {
  11. $("div.blocks").hide();
  12. $("#" + $(this).attr("title")).show();
  13. });
  14.  
  15. $("a.new_sec").click(function() {
  16. $('<div></div>').addClass("new_sections").appendTo("#sections form");
  17.  
  18. var sectionIndex = $(".new_sections").index($(".new_sections:last"));
  19.  
  20. $("<fieldset><legend>New Section</legend></fieldset>").appendTo(".new_sections:eq(" + sectionIndex + ")");
  21.  
  22. var fieldsetIndex = $("fieldset").index($(".new_sections:eq(" + sectionIndex + ") fieldset"));
  23.  
  24. $('<div class="article"><p><span class="s_title">Section Title</span>: <input type="text" name="title" class="text" /></p><p>Main Article Title: <input type="text" name="a_title[]" class="text" /></p><p>Article Text: <textarea name="a_text[]" class="textarea"></textarea></p><p>Article Image: <input type="file" name="a_image[]" class="text" /></p><p>Link: <input type="text" name="a_link[]" class="text" /></p></div>').css({border:"0", backgroundColor:"#DDD"}).appendTo("fieldset:eq(" + fieldsetIndex + ")");
  25.  
  26. $('<a href="/" class="new_art">Add Additional Article it this Section</a> | <a href="/" class="rem_sec">Remove This Section</a>').appendTo("fieldset:eq(" + fieldsetIndex + ")");
  27.  
  28. $("fieldset:eq(" + fieldsetIndex + ") a.new_art").click(function() {
  29. $('<div class="article"><p>Article Title: <input type="text" name="a_title[]" class="text" /></p><p>Article Text: <textarea name="a_text[]" class="textarea"></textarea></p><p>Article Image: <input type="file" name="a_image[]" class="text" /></p><p>Link: <input type="text" name="a_link[]" class="text" /></p><p><a href="#" class="rem_art">Remove This Article</a></p></div>').css({border:"0", backgroundColor:($("fieldset:eq(" + fieldsetIndex + ") div.article:last").css("backgroundColor") == "rgb(221, 221, 221)" || $("fieldset:eq(" + fieldsetIndex + ") div.article:last").css("backgroundColor") == "#ddd" ? "#FFF" : "#DDD")}).insertAfter("fieldset:eq(" + fieldsetIndex + ") div.article:last");
  30.  
  31. $("fieldset a.rem_art").click(function() {
  32. $(this).parent().parent().remove();
  33. return false;
  34. });
  35.  
  36. return false;
  37. });
  38.  
  39. $("fieldset a.rem_sec").click(function() {
  40. $(this).parent().remove();
  41. return false;
  42. });
  43.  
  44. return false;
  45. });
  46. });
Add Comment
Please, Sign In to add comment