Advertisement
fahmihilmansyah

struktur organisasi fix 1

Aug 15th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.44 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. $('.pengaturan').hide();
  121. $('.tree').hide();
  122. /* untuk id defaultnya generate*/
  123. jQuery(document).on('click','.child',function(){
  124. var namaParent = $(this).data('nameparent') ;
  125. var parent = $(this).data('parent') ;
  126. var row = $(this).data('row') ;
  127. var id = $(this).data('id') ;
  128. $("#nameParent").html(namaParent);
  129. $("#parentinp").val(parent);
  130. $("#idinp").val(idgen++);
  131. $("#idsblm").val(id);
  132. $("#rowinp").val(row);
  133. });
  134. jQuery(document).on('click','#buatstruktur',function(){
  135. var namamanager = ($("#namamanager").val());
  136. $(".adefault").data("nameparent",namamanager);
  137. $(".adefault").html(namamanager);
  138. $('.tree').show();
  139. $(".pertamatampil").remove();
  140. $(".pengaturan").show();
  141. });
  142. jQuery(document).on('click','#tambahChild',function(){
  143. var namabawahan = ($("#namabawahan").val());
  144. var parent = parseInt($("#parentinp").val());
  145. var idinp = parseInt($("#idinp").val());
  146. var rowinp = parseInt($("#rowinp").val());
  147. tambahChild(parent,idinp,rowinp,namabawahan);
  148. });
  149. jQuery(document).on('click','#removeChild',function(){
  150. var idsblm = parseInt($("#idsblm").val());
  151. var rowinp = parseInt($("#rowinp").val());
  152. $(".uldefault").find('li:not(:first)').remove();
  153. /*if(idsblm != 0){
  154. $('.parent-'+idsblm).remove();
  155. }else{
  156. alert("Maaf Tidak Bisa Di Hapus");
  157. }*/
  158. });
  159. function tambahChild(p,i,r,namabawahan){
  160. /*p = parent, i = id, r = row*/
  161. /*<!-- untuk jika row tidak ketemu make tambah UL baru -->*/
  162. r = r+1;
  163. if($("ul#row-" + r+".parentul-"+p).length == 0){
  164. // alert("masuk if"+p);
  165. $(".parent-"+p).append('<ul id="row-'+(r)+'" class="parentul-'+p+'">'+
  166. '<li class="parent-'+(i)+'">'+
  167. '<a href="#" data-parent="'+i+'" data-id="'+i+'" data-row="'+r+'" data-nameparent="'+namabawahan+'" class="child posisi'+r+""+i+'">'+namabawahan+'</a>'+
  168. '</li>'+
  169. '</ul>');
  170. }else{
  171. // alert("R = "+r+" "+$("#row-" + r+""+p).length+" parent "+$(".parent-"+p).length);
  172. $("ul#row-"+r+".parentul-"+p).append('<li class="parent-'+(i)+'">'+
  173. '<a href="#" data-parent="'+i+'" data-id="'+i+'" data-row="'+r+'" data-nameparent="'+namabawahan+'" class="child posisi'+r+""+i+'">'+namabawahan+'</a>'+
  174. '</li>');
  175. }
  176. }
  177. });
  178. </script>
  179. </head>
  180. <body>
  181. <!--
  182. We will create a family tree using just CSS(3)
  183. The markup will be simple nested lists
  184. -->
  185. <div class="pengaturan">
  186. Atasan : <a href="#" id="nameParent"></a> <br>
  187. Nama Bawahan : <input type="text" value="" id="namabawahan" placeholder="Nama Bawahan"> <br>
  188. parent <input type="text" value="" id="parentinp" placeholder="parent"> <br>
  189. id <input type="text" value="" id="idinp" placeholder="id user yang ingin dibuat"> <br>
  190. id sebelum <input type="text" value="" id="idsblm" placeholder="id user bersangkutan"> <br>
  191. row <input type="text" value="" id="rowinp" placeholder="row saat ini"> <br>
  192. <button id="tambahChild">Tambah</button>
  193. <button id="removeChild">Hapus</button>
  194. </div><br>
  195. <div class="pertamatampil">
  196. <span>Berfungsi ketika pertama kali load input terlebih dahulu nama manager:</span><br>
  197. Nama Manager : <input type="text" id="namamanager" value="" placeholder="Nama Manager"><br>
  198. <button id="buatstruktur">Buat Struktur</button>
  199. </div>
  200. <div class="tree">
  201. <ul id="row-0" class="parentul-0 uldefault">
  202. <li class="parent-0">
  203. <a href="#" data-parent="0" data-id="0" data-row="0" data-nameparent="Parent" class="child adefault">Parent</a>
  204. </li>
  205. </ul>
  206. </div>
  207. </body>
  208. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement