Browse Source

add onfullscreen & onfullscreenExit event handle

mathjax-version
Pandao 11 years ago
parent
commit
bc01778e18
  1. 6
      examples/index.html
  2. 39
      examples/onfullscreen.html
  3. 9
      src/js/editormd.js

6
examples/index.html

@ -37,6 +37,12 @@
<li> <li>
<a href="./onchange.html">onchange.html</a> <a href="./onchange.html">onchange.html</a>
</li> </li>
<li>
<a href="./onfullscreen.html">onfullscreen.html</a>
</li>
<li>
<a href="./onfullscreen.html">onfullscreenExit.html</a>
</li>
<li> <li>
<a href="./mathjax.html">mathjax.html</a> <a href="./mathjax.html">mathjax.html</a>
</li> </li>

39
examples/onfullscreen.html

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Onfullscreen & onfullscreenExit - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="layout">
<header>
<h1>Onfullscreen & onfullscreenExit event</h1>
<p>Enter F12 open the develop tools</p>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
width : "90%",
height : 720,
path : '../lib/',
onfullscreen : function() {
alert("onfullscreen");
console.log("onfullscreen =>", this, this.id, this.settings);
},
onfullscreenExit : function() {
alert("onfullscreenExit");
console.log("onfullscreenExit =>", this, this.id, this.settings);
}
});
});
</script>
</body>
</html>

9
src/js/editormd.js

@ -54,6 +54,8 @@
watch : true, watch : true,
onload : function() {}, onload : function() {},
onchange : function() {}, onchange : function() {},
onfullscreen : function() {},
onfullscreenExit : function() {},
toc : true, toc : true,
tocStartLevel : 2, tocStartLevel : 2,
fontSize : "13px", fontSize : "13px",
@ -1284,14 +1286,15 @@
width : $(window).width(), width : $(window).width(),
height : $(window).height() height : $(window).height()
}).addClass(fullscreenClass); }).addClass(fullscreenClass);
this.resize();
$.proxy(this.settings.onfullscreen, this)();
} }
else else
{ {
this.fullscreenExit(); this.fullscreenExit();
} }
this.resize();
$(window).keyup(function(event) { $(window).keyup(function(event) {
if (_this.state.preview) { if (_this.state.preview) {
return ; return ;
@ -1332,6 +1335,8 @@
this.resize(); this.resize();
$.proxy(this.settings.onfullscreenExit, this)();
return this; return this;
} }
}; };

Loading…
Cancel
Save