Last active
January 3, 2016 05:29
-
-
Save Yhzhtk/8416380 to your computer and use it in GitHub Desktop.
使用bootstrap、jquery、tree、resize bar等。http://jsfiddle.net/gaby/Bek9L/186/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<title>Yicha Doc - 易查项目接口文档</title> | |
<script type='text/javascript' src='http://code.jquery.com/jquery-2.0.1.js'></script> | |
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> | |
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css"> | |
<script type='text/javascript' src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script> | |
<style type='text/css'> | |
.rightdiv{ | |
float:right; | |
position: absolute; | |
left:300px; | |
right: 0; | |
padding: 0 0 0 10px; | |
border: 1px solid #C0C0C0; | |
} | |
.leftdiv{ | |
background-color:#F5F5F5; | |
position: absolute; | |
float:left; | |
width:300px; | |
height:100%; | |
overflow: hidden; | |
border: 1px solid #C0C0C0; | |
} | |
.drag{ | |
background-color: #C2C2C2; | |
height:100%; | |
float: right; | |
width: 5px; | |
cursor:w-resize; | |
} | |
#ghostbar{ | |
width:5px; | |
background-color:#000; | |
opacity:0.5; | |
position:absolute; | |
cursor: w-resize; | |
z-index:999 | |
} | |
.tree { | |
min-height:20px; | |
padding:1px; | |
margin-bottom:20px; | |
border:1px solid #999; | |
-webkit-border-radius:4px; | |
-moz-border-radius:4px; | |
border-radius:4px; | |
-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05); | |
-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05); | |
box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05); | |
} | |
.tree li { | |
list-style-type:none; | |
margin:0; | |
padding:10px 5px 0 5px; | |
position:relative | |
} | |
.tree li::before, .tree li::after { | |
content:''; | |
left:-20px; | |
position:absolute; | |
right:auto | |
} | |
.tree li::before { | |
border-left:1px solid #999; | |
bottom:50px; | |
height:100%; | |
top:0; | |
width:1px | |
} | |
.tree li::after { | |
border-top:1px solid #999; | |
height:20px; | |
top:25px; | |
width:25px | |
} | |
.tree li span { | |
-moz-border-radius:5px; | |
-webkit-border-radius:5px; | |
border:1px solid #999; | |
border-radius:5px; | |
display:inline-block; | |
padding:1px 5px; | |
text-decoration:none; | |
font-size: 12px | |
} | |
.tree li.parent_li>span { | |
cursor:pointer | |
} | |
.tree>ul>li::before, .tree>ul>li::after { | |
border:0 | |
} | |
.tree li:last-child::before { | |
height:30px | |
} | |
.tree li.parent_li>span:hover, .tree li.parent_li>span:hover+ul li span { | |
background:#eee; | |
border:1px solid #94a0b4; | |
color:#000 | |
} | |
</style> | |
</head> | |
<body> | |
<div class="leftdiv"> | |
<div class="drag"></div> | |
<div class="tree"><ul><li><span><i class="icon-minus-sign"></i>易查接口文档</span><ul><li><span><i class="icon-minus-sign"></i>image</span><ul><li><span><a href="/image/back.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><a href="/image/front.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><i class="icon-minus-sign"></i>news</span><ul><li><span><a href="/image/news/back.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><a href="/image/news/front.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li></ul></li></ul></li><li><span><i class="icon-minus-sign"></i>radio</span><ul><li><span><a href="/radio/back.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><a href="/radio/front.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><i class="icon-minus-sign"></i>news</span><ul><li><span><a href="/radio/news/back.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><a href="/radio/news/front.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><i class="icon-minus-sign"></i>news</span><ul><li><span><a href="/radio/news/news/back.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li><li><span><a href="/radio/news/news/front.htm"><i class="icon-leaf"></i>RadioBack 文档</a></span></li></ul></li></ul></li></ul></li></ul></li></ul></div> | |
</div> | |
<div class="rightdiv"> | |
<iframe class="docframe" name="docframe" frameborder="0" scolling="auto" width="100%" height="100" onload="this.height=window.document.body.scrollHeight - 10;"></iframe> | |
</div> | |
<script type='text/javascript'>//<![CDATA[ | |
$("a").each(function(){ | |
var url = $(this).attr("href"); | |
$(this).attr("onclick", "window.frames['docframe'].location='" + url + "?' + new Date().getTime(); return false;"); | |
}) | |
$(window).load(function(){ | |
$(function () { | |
$('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch'); | |
$('.tree li.parent_li > span').on('click', function (e) { | |
var children = $(this).parent('li.parent_li').find(' > ul > li'); | |
if (children.is(":visible")) { | |
children.hide('fast'); | |
$(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign'); | |
} else { | |
children.show('fast'); | |
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign'); | |
} | |
e.stopPropagation(); | |
}); | |
}); | |
});//]]> | |
// 拖动条 | |
$(window).load(function(){ | |
$(document).ready(function resize(){ | |
var $left = $('.leftdiv'), | |
$right = $('.rightdiv'), | |
$drag = $('.drag'), | |
$frame = $('.docframe'); | |
var dw = $drag.width(); | |
$drag.css('height', window.document.body.scrollHeight); | |
var dragging = false; | |
$drag.mousedown(function(e){ | |
e.preventDefault(); | |
dragging = true; | |
var main = $right; | |
var ghostbar = $('<div>', | |
{id:'ghostbar', | |
css: { | |
height: main.outerHeight(), | |
top: main.offset().top, | |
left: main.offset().left | |
} | |
}).appendTo('body'); | |
$(document).mousemove(function(e){ | |
ghostbar.css("left", e.pageX); | |
}); | |
$frame.contents().mousemove(function(e){ | |
ghostbar.css("left", e.pageX + $right.offset().left + dw * 2); | |
}); | |
}); | |
$(document).mouseup(function(e){ | |
if (dragging) | |
{ | |
$left.css("width", e.pageX + dw); | |
$right.css("left", e.pageX + dw); | |
$('#ghostbar').remove(); | |
$(document).unbind('mousemove'); | |
$frame.contents().unbind('mousemove'); | |
dragging = false; | |
} | |
}); | |
$frame.contents().mouseup(function(e){ | |
if (dragging) | |
{ | |
$left.css("width", e.pageX + $right.offset().left + dw); | |
$right.css("left", e.pageX + $right.offset().left + dw); | |
$('#ghostbar').remove(); | |
$(document).unbind('mousemove'); | |
$frame.contents().unbind('mousemove'); | |
dragging = false; | |
} | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment