Advertisement
fahmihilmansyah

struktur organisasi

Aug 15th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 5.68 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <title></title>
  7.     <link rel="stylesheet" href="">
  8.     <style type="text/css">
  9.         /*Now the CSS*/
  10. * {margin: 0; padding: 0;}
  11.  
  12. .tree ul {
  13.     padding-top: 20px; position: relative;
  14.    
  15.     transition: all 0.5s;
  16.     -webkit-transition: all 0.5s;
  17.     -moz-transition: all 0.5s;
  18. }
  19.  
  20. .tree li {
  21.     float: left; text-align: center;
  22.     list-style-type: none;
  23.     position: relative;
  24.     padding: 20px 5px 0 5px;
  25.    
  26.     transition: all 0.5s;
  27.     -webkit-transition: all 0.5s;
  28.     -moz-transition: all 0.5s;
  29. }
  30.  
  31. /*We will use ::before and ::after to draw the connectors*/
  32.  
  33. .tree li::before, .tree li::after{
  34.     content: '';
  35.     position: absolute; top: 0; right: 50%;
  36.     border-top: 1px solid #ccc;
  37.     width: 50%; height: 20px;
  38. }
  39. .tree li::after{
  40.     right: auto; left: 50%;
  41.     border-left: 1px solid #ccc;
  42. }
  43.  
  44. /*We need to remove left-right connectors from elements without
  45. any siblings*/
  46. .tree li:only-child::after, .tree li:only-child::before {
  47.     display: none;
  48. }
  49.  
  50. /*Remove space from the top of single children*/
  51. .tree li:only-child{ padding-top: 0;}
  52.  
  53. /*Remove left connector from first child and
  54. right connector from last child*/
  55. .tree li:first-child::before, .tree li:last-child::after{
  56.     border: 0 none;
  57. }
  58. /*Adding back the vertical connector to the last nodes*/
  59. .tree li:last-child::before{
  60.     border-right: 1px solid #ccc;
  61.     border-radius: 0 5px 0 0;
  62.     -webkit-border-radius: 0 5px 0 0;
  63.     -moz-border-radius: 0 5px 0 0;
  64. }
  65. .tree li:first-child::after{
  66.     border-radius: 5px 0 0 0;
  67.     -webkit-border-radius: 5px 0 0 0;
  68.     -moz-border-radius: 5px 0 0 0;
  69. }
  70.  
  71. /*Time to add downward connectors from parents*/
  72. .tree ul ul::before{
  73.     content: '';
  74.     position: absolute; top: 0; left: 50%;
  75.     border-left: 1px solid #ccc;
  76.     width: 0; height: 20px;
  77. }
  78.  
  79. .tree li a{
  80.     border: 1px solid #ccc;
  81.     padding: 5px 10px;
  82.     text-decoration: none;
  83.     color: #666;
  84.     font-family: arial, verdana, tahoma;
  85.     font-size: 11px;
  86.     display: inline-block;
  87.    
  88.     border-radius: 5px;
  89.     -webkit-border-radius: 5px;
  90.     -moz-border-radius: 5px;
  91.    
  92.     transition: all 0.5s;
  93.     -webkit-transition: all 0.5s;
  94.     -moz-transition: all 0.5s;
  95. }
  96.  
  97. /*Time for some hover effects*/
  98. /*We will apply the hover effect the the lineage of the element also*/
  99. .tree li a:hover, .tree li a:hover+ul li a {
  100.     background: #c8e4f8; color: #000; border: 1px solid #94a0b4;
  101. }
  102. /*Connector styles on hover*/
  103. .tree li a:hover+ul li::after,
  104. .tree li a:hover+ul li::before,
  105. .tree li a:hover+ul::before,
  106. .tree li a:hover+ul ul::before{
  107.     border-color:  #94a0b4;
  108. }
  109.  
  110. /*Thats all. I hope you enjoyed it.
  111. Thanks :)*/
  112.     </style>
  113.     <script
  114.  src="https://code.jquery.com/jquery-3.2.1.min.js"
  115.  integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  116.  crossorigin="anonymous"></script>
  117.   <script type="text/javascript">
  118.     $(document).ready(function(){
  119.         var idgen = 1;
  120.         /* untuk id defaultnya generate*/
  121.         jQuery(document).on('click','.child',function(){
  122.             var namaParent = $(this).data('nameparent') ;
  123.             var parent = $(this).data('parent') ;
  124.             var row = $(this).data('row') ;
  125.             var id = $(this).data('id') ;
  126.             $("#nameParent").html(namaParent);
  127.             $("#parentinp").val(parent);
  128.             $("#idinp").val(idgen++);
  129.             $("#idsblm").val(id);
  130.             $("#rowinp").val(row);
  131.         });
  132.         jQuery(document).on('click','#tambahChild',function(){
  133.             var parent = parseInt($("#parentinp").val());
  134.             var idinp = parseInt($("#idinp").val());
  135.             var rowinp = parseInt($("#rowinp").val());
  136.             tambahChild(parent,idinp,rowinp);
  137.         });
  138.         jQuery(document).on('click','#removeChild',function(){
  139.             var idsblm = parseInt($("#idsblm").val());
  140.             var rowinp = parseInt($("#rowinp").val());
  141.             $(".uldefault").find('li:not(:first)').remove();
  142.             /*if(idsblm != 0){
  143.                 $('.parent-'+idsblm).remove();
  144.             }else{
  145.                 alert("Maaf Tidak Bisa Di Hapus");
  146.             }*/
  147.         });
  148.         function tambahChild(p,i,r){
  149.             /*p = parent, i = id, r = row*/
  150.                 /*<!-- untuk jika row tidak ketemu make tambah UL baru  -->*/
  151.             r = r+1;
  152.             if($("ul#row-" + r+".parentul-"+p).length == 0){
  153.                 // alert("masuk if"+p);
  154.                 $(".parent-"+p).append('<ul id="row-'+(r)+'" class="parentul-'+p+'">'+
  155.                     '<li class="parent-'+(i)+'">'+
  156.                         '<a href="#" data-parent="'+i+'" data-id="'+i+'" data-row="'+r+'" data-nameparent="Parent 1" class="child posisi'+r+""+i+'">Parent '+p+' idskr '+i+' idsblm '+p+'</a>'+
  157.                     '</li>'+
  158.                 '</ul>');
  159.             }else{
  160.                 // alert("R = "+r+" "+$("#row-" + r+""+p).length+" parent "+$(".parent-"+p).length);
  161.                 $("ul#row-"+r+".parentul-"+p).append('<li class="parent-'+(i)+'">'+
  162.                         '<a href="#" data-parent="'+i+'" data-id="'+i+'" data-row="'+r+'" data-nameparent="Parent 1" class="child posisi'+r+""+i+'">Parent '+p+' idskr '+i+' idsblm '+p+'</a>'+
  163.                     '</li>');
  164.             }
  165.         }
  166.     });
  167.   </script>
  168. </head>
  169. <body>
  170.     <!--
  171. We will create a family tree using just CSS(3)
  172. The markup will be simple nested lists
  173. -->
  174. <div class="pengaturan">
  175.     Atasan : <span id="nameParent"></span> <br>
  176.     parent <input type="text" value="" id="parentinp" placeholder="parent"> <br>
  177.     id <input type="text" value="" id="idinp" placeholder="id user yang ingin dibuat"> <br>
  178.     id sebelum <input type="text" value="" id="idsblm" placeholder="id user bersangkutan"> <br>
  179.     row <input type="text" value="" id="rowinp" placeholder="row saat ini"> <br>
  180.     <button id="tambahChild">Tambah</button>
  181.     <button id="removeChild">Hapus</button>
  182. </div>
  183. <div class="tree">
  184.     <ul id="row-0" class="parentul-0 uldefault">
  185.         <li class="parent-0">
  186.             <a href="#" data-parent="0" data-id="0" data-row="0" data-nameparent="Parent" class="child">Parent</a>
  187.  
  188.            
  189.         </li>
  190.     </ul>
  191. </div>
  192. </body>
  193. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement