1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| <!DOCTYPE html> <html> <head> <title>Directory Tree</title> <meta charset="UTF-8">
<style> body { font-family: "微软雅黑", "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, sans-serif; }
#file-tree ul { list-style: none; padding-left: 20px; }
#file-tree .file, #file-tree .branch, #file-tree .icon, #file-tree .name { height: 20px; line-height: 20px; display: inline-block; vertical-align: middle; }
#file-tree .file { display: inline-block; font-size: 0; border: 1px solid transparent; }
#file-tree .file.active { border-radius: 2px; border: 1px solid rgb(68, 211, 255); }
#file-tree .is-directory { margin-left: -15px; }
#file-tree .is-directory .branch { width: 15px;
}
#file-tree .is-file .branch { width: 0;
}
#file-tree .is-directory .branch { cursor: pointer; }
#file-tree .is-directory.expand .branch { background: url(arrow.png) no-repeat -65px 3px; }
#file-tree .is-directory.collapse .branch { background: url(arrow.png) no-repeat -32px 3px; }
#file-tree .icon { width: 20px; }
#file-tree .is-directory .icon { background: url(folder.png) no-repeat; }
#file-tree .is-file .icon { background: url(file.png) no-repeat; }
#file-tree .name { cursor: default; font-size: 14px; padding: 0 3px; }
#file-tree .file.active .name { background: rgb(68, 211, 255); } </style> </head> <body> <div id="file-tree"> <ul> <li> <div class="file is-directory"> <span class="branch"></span> <span class="icon"></span> <span class="name">根目录</span> </div>
<ul> <li> <div class="file is-directory"> <span class="branch"></span> <span class="icon"></span> <span class="name">学科</span> </div>
<ul> <li> <div class="file is-file"> <span class="branch"></span> <span class="icon"></span> <span class="name">百科目录</span> </div> </li> <li> <div class="file is-file"> <span class="branch"></span> <span class="icon"></span> <span class="name">操作指南</span> </div> </li> <li> <div class="file is-file"> <span class="branch"></span> <span class="icon"></span> <span class="name">README.md</span> </div> </li> </ul> </li> <li> <div class="file is-file"> <span class="branch"></span> <span class="icon"></span> <span class="name">README.md</span> </div> </li> <li> <div class="file is-file"> <span class="branch"></span> <span class="icon"></span> <span class="name">操作指南</span> </div> </li> </ul> </li> </ul> </div>
<script src="../jquery.min.js"></script> <script src="../jquery-ui.min.js"></script> <script> $(document).ready(function() { $('.is-directory').addClass('expand');
$('#file-tree').on('click', '.is-directory .branch', function() { var $directory = $(this).parent(); $directory.toggleClass('expand').toggleClass('collapse'); $directory.siblings('ul').slideToggle('fast'); });
$('#file-tree').on('mousedown', '.name', function(e) { $('.name').parent().removeClass('active'); $(this).parent().addClass('active'); });
$('.is-file').draggable({ helper : 'clone', cursor: 'move', revert: 'invalid' }); }); </script> </body> </html>
|