Advertisement
asimryu

app.js

Aug 23rd, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. $(".menu > ul > li").hover(
  2. function(){
  3. $(this).children("ul").slideDown();
  4. },
  5. function(){
  6. $(this).children("ul").slideUp();
  7. }
  8. );
  9.  
  10. var imgs = $("#slider > img");
  11. var max = imgs.length - 1;
  12. var sno = 0;
  13.  
  14. $("#slider").on("click",function(){
  15. $( imgs[sno] ).animate({
  16. left: "-100%",
  17. opacity: 1
  18. },1000,function(){
  19. $(this).css({
  20. left:"100%",
  21. opacity: 0
  22. });
  23. });
  24. sno++; //sno = sno + 1;
  25. if( sno > max ) sno = 0;
  26. $( imgs[sno] ).animate({
  27. left: "0",
  28. opacity: 1
  29. },1000);
  30. });
  31.  
  32. var timer = setInterval(function(){
  33. $("#slider").click();
  34. },2000);
  35.  
  36. var page = 1;
  37. function getlist(){
  38. $.get("list.php?page=" + page,function(data){
  39. console.log(data);
  40. $("#posts table tr:last").after(data);
  41. page++;
  42. });
  43. }
  44. getlist();
  45.  
  46. $(".btn-more").on("click",function(){
  47. getlist();
  48. });
  49.  
  50.  
  51. $(window).scroll(function() {
  52. if($(window).scrollTop() + $(window).height() == $(document).height()) {
  53. getlist();
  54. }
  55. });
  56.  
  57. $("#posts").on("click",".view-data",function(e){
  58. e.preventDefault();
  59. var id = $(this).attr("href");
  60. if( ! id ) return;
  61. $.getJSON("view.php?id=" + id, function(data){
  62. if( ! data ) return;
  63. $(".view-title").text(data.title);
  64. $(".view-writer").text(data.writer);
  65. $(".view-date").text(data.created_at);
  66. $(".view-content").text(data.content);
  67. $(".btn-del").attr("data-id",id);
  68. $("#myModal").modal("show");
  69. });
  70. });
  71.  
  72. $("#posts").on("click",".btn-del",function(){
  73. var id = $(this).attr("data-id");
  74. var del = confirm("Are you sure?");
  75. if( ! del ) return;
  76. $.post("delete.php",{"id":id},function(result){
  77. if( ! result ) return;
  78. var count = parseInt(result,10);
  79. if( count ) location.reload();
  80. else alert("Can't Delete");
  81. });
  82. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement