|
");
window.frames["iframe_toc"+sid].document.write(decodeHtml($("pre#stepCodePre"+sid).html()));
window.frames["iframe_toc"+sid].document.close();
$(window.frames["iframe_toc"+sid]).load(function(){
$("#iframe_toc"+sid).height($("#iframe_toc"+sid).contents().find("body").height()+(showittryitheight));
});
$("#iframe_toc"+sid).height($("#iframe_toc"+sid).contents().find("body").height()+(showittryitheight));
}
$("input.tocName").hover(function(){
$(this).select();
});
function refresh(){
var sid = tocstepids.shift();
if(null!=sid)
refreshIframe(sid);
else
go2ArchorFlag = true;
}
var t = setInterval(refresh,300);
// $("div.steptoc iframe").height($(showittryitheight+50));
});
效果 |
说明 |
示例代码 |
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
div.well{
margin:10px;
}
</style>
<a class="btn btn-info" role="button" data-toggle="collapse" href="#dota" aria-expanded="false" aria-controls="collapseExample">
DotA
</a>
<button class="btn btn-info" type="button" data-toggle="collapse" data-target="#lol" aria-expanded="false" aria-controls="collapseExample">
LOL
</button>
<div class="collapse" id="dota">
<div class="well">
《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。
</div>
</div>
<div class="collapse" id="lol">
<div class="well">
《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。
</div>
</div>
<div style="height:100px"></div>
|
基本折叠
|
示例代码
|
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
DOTA
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
LOL
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
风暴英雄
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
《风暴英雄》 是由暴雪娱乐公司开发的一款运行在Windows和Mac OS上的在线多人竞技PC游戏。
</div>
</div>
</div>
</div>
|
面板折叠
|
示例代码
|
示例
1
:
基本折叠
示例
2
:
面板折叠
");
window.frames["iframe_show3017"].document.write(decodeHtml($("textarea#stepcodeTextarea3017").val()));
window.frames["iframe_show3017"].document.close();
$(window.frames["iframe_show3017"]).load(function(){
$("#iframe_show3017").height($("#iframe_show3017").contents().find("body").height()+showittryitheight);
});
$("#iframe_show3017").height($("#iframe_show3017").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
div.well{
margin:10px;
}
</style>
<a class="btn btn-info" role="button" data-toggle="collapse" href="#dota" aria-expanded="false" aria-controls="collapseExample">
DotA
</a>
<button class="btn btn-info" type="button" data-toggle="collapse" data-target="#lol" aria-expanded="false" aria-controls="collapseExample">
LOL
</button>
<div class="collapse" id="dota">
<div class="well">
《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。
</div>
</div>
<div class="collapse" id="lol">
<div class="well">
《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。
</div>
</div>
<div style="height:100px"></div>
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
div.well{
margin:10px;
}
</style>
<a class="btn btn-info" role="button" data-toggle="collapse" href="#dota" aria-expanded="false" aria-controls="collapseExample">
DotA
</a>
<button class="btn btn-info" type="button" data-toggle="collapse" data-target="#lol" aria-expanded="false" aria-controls="collapseExample">
LOL
</button>
<div class="collapse" id="dota">
<div class="well">
《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。
</div>
</div>
<div class="collapse" id="lol">
<div class="well">
《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。
</div>
</div>
<div style="height:100px"></div>
");
window.frames["iframe3017"].document.write(decodeHtml(code3017));
window.frames["iframe3017"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3017"]).load(function(){
$("#iframe3017").height($("#iframe3017").contents().find("body").height()+showittryitheight);
});
$("#iframe3017").height($("#iframe3017").contents().find("body").height()+showittryitheight);
alreadyWriteCode3017 = code3017;
$("#rendering3017").hide();
$("#rendered3017").show();
}
var tRereshRetry2DemoPanel3017 = setInterval(rereshRetry2DemoPanel3017,1000);
var binded3017 = false;
$("textarea#stepcodeTextarea3017").keyup(function(){
if(!binded3017){
$(window).bind('beforeunload',function(){
binded3017 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code3017 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code3017!=newCode){
// window.frames["iframe3017"].document.write("
");
// window.frames["iframe3017"].document.write(decodeHtml($("textarea#stepcodeTextarea3017").val()));
// window.frames["iframe3017"].document.close();
// $(window.frames["iframe3017"]).load(function(){
// $("#iframe3017").height($("#iframe3017").contents().find("body").height()+showittryitheight);
// });
// code3017 = newCode;
// }
});
$(".tryButton3017").click(function(){
$("#tryDiv3017").show();
$("#stepcodeTextarea3017").focus();
$("#stepcodeTextarea3017").height(200);
$("#iframe3017").height(0);
window.frames["iframe3017"].document.write("
");
window.frames["iframe3017"].document.write(decodeHtml($("textarea#stepcodeTextarea3017").val()));
window.frames["iframe3017"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3017"]).load(function(){
$("#iframe3017").height($("#iframe3017").contents().find("body").height()+showittryitheight);
});
$("#iframe3017").height($("#iframe3017").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor3017.focus();
editor3017.setSize(null, "250");
$("#rendering3017").hide();
$("#rendered3017").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor3017 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3017"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor3017.on("change",function(doc){
if(!binded3017){
$(window).bind('beforeunload',function(){
binded3017 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code3017 = newCode;
$("textarea#stepcodeTextarea3017").val(newCode);
if(alreadyWriteCode3017!=code3017){
lastModifedTime3017 = new Date().getTime();
$("#rendering3017").show();
$("#rendered3017").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor3017 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor3017.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv3017").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show3018"].document.write(decodeHtml($("textarea#stepcodeTextarea3018").val()));
window.frames["iframe_show3018"].document.close();
$(window.frames["iframe_show3018"]).load(function(){
$("#iframe_show3018").height($("#iframe_show3018").contents().find("body").height()+showittryitheight);
});
$("#iframe_show3018").height($("#iframe_show3018").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
DOTA
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
LOL
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
风暴英雄
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
《风暴英雄》 是由暴雪娱乐公司开发的一款运行在Windows和Mac OS上的在线多人竞技PC游戏。
</div>
</div>
</div>
</div>
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
DOTA
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
LOL
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
风暴英雄
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
《风暴英雄》 是由暴雪娱乐公司开发的一款运行在Windows和Mac OS上的在线多人竞技PC游戏。
</div>
</div>
</div>
</div>
");
window.frames["iframe3018"].document.write(decodeHtml(code3018));
window.frames["iframe3018"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3018"]).load(function(){
$("#iframe3018").height($("#iframe3018").contents().find("body").height()+showittryitheight);
});
$("#iframe3018").height($("#iframe3018").contents().find("body").height()+showittryitheight);
alreadyWriteCode3018 = code3018;
$("#rendering3018").hide();
$("#rendered3018").show();
}
var tRereshRetry2DemoPanel3018 = setInterval(rereshRetry2DemoPanel3018,1000);
var binded3018 = false;
$("textarea#stepcodeTextarea3018").keyup(function(){
if(!binded3018){
$(window).bind('beforeunload',function(){
binded3018 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code3018 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code3018!=newCode){
// window.frames["iframe3018"].document.write("
");
// window.frames["iframe3018"].document.write(decodeHtml($("textarea#stepcodeTextarea3018").val()));
// window.frames["iframe3018"].document.close();
// $(window.frames["iframe3018"]).load(function(){
// $("#iframe3018").height($("#iframe3018").contents().find("body").height()+showittryitheight);
// });
// code3018 = newCode;
// }
});
$(".tryButton3018").click(function(){
$("#tryDiv3018").show();
$("#stepcodeTextarea3018").focus();
$("#stepcodeTextarea3018").height(200);
$("#iframe3018").height(0);
window.frames["iframe3018"].document.write("
");
window.frames["iframe3018"].document.write(decodeHtml($("textarea#stepcodeTextarea3018").val()));
window.frames["iframe3018"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3018"]).load(function(){
$("#iframe3018").height($("#iframe3018").contents().find("body").height()+showittryitheight);
});
$("#iframe3018").height($("#iframe3018").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor3018.focus();
editor3018.setSize(null, "250");
$("#rendering3018").hide();
$("#rendered3018").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor3018 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3018"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor3018.on("change",function(doc){
if(!binded3018){
$(window).bind('beforeunload',function(){
binded3018 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code3018 = newCode;
$("textarea#stepcodeTextarea3018").val(newCode);
if(alreadyWriteCode3018!=code3018){
lastModifedTime3018 = new Date().getTime();
$("#rendering3018").show();
$("#rendered3018").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor3018 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor3018.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv3018").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|