Browse Source

add onfullscreen & onfullscreenExit event handle

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

6
examples/index.html

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

15
src/js/editormd.js

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

Loading…
Cancel
Save