Fixed #80 and #70 (again)

This commit is contained in:
josdejong 2013-12-07 15:30:11 +01:00
parent e3bd8379f1
commit e302507c7a
17 changed files with 9729 additions and 55 deletions

View File

@ -3,6 +3,11 @@
http://jsoneditoronline.org
## (not yet released), version 2.3.5
- Fixed a positioning issue of the action menu again.
## 2013-11-19, version 2.3.4
- Dropped support for IE8, cleaned up legacy code for old browsers.

2
jsoneditor-min.css vendored

File diff suppressed because one or more lines are too long

8
jsoneditor-min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -226,7 +226,7 @@
/* ContextMenu - main menu */
.jsoneditor-contextmenu {
position: fixed;
position: absolute;
z-index: 99999;
}

View File

@ -27,8 +27,8 @@
* Copyright (c) 2011-2013 Jos de Jong, http://jsoneditoronline.org
*
* @author Jos de Jong, <wjosdejong@gmail.com>
* @version 2.3.4
* @date 2013-11-19
* @version 2.3.5-SNAPSHOT
* @date 2013-12-07
*/
(function () {
@ -4560,14 +4560,16 @@ ContextMenu.prototype.show = function (anchor) {
this.hide();
// calculate whether the menu fits below the anchor
var windowHeight = window.innerHeight;
var anchorHeight = anchor.offsetHeight;
var menuHeight = this.maxHeight;
var windowHeight = window.innerHeight,
windowScroll = (window.pageYOffset || document.scrollTop),
windowBottom = windowHeight + windowScroll,
anchorHeight = anchor.offsetHeight,
menuHeight = this.maxHeight;
// position the menu
var left = util.getAbsoluteLeft(anchor);
var top = util.getAbsoluteTop(anchor);
if (top + anchorHeight + menuHeight < windowHeight) {
if (top + anchorHeight + menuHeight < windowBottom) {
// display the menu below the anchor
this.dom.menu.style.left = left + 'px';
this.dom.menu.style.top = (top + anchorHeight) + 'px';
@ -5624,33 +5626,19 @@ util.isUrl = function isUrl (text) {
* in the browser page.
*/
util.getAbsoluteLeft = function getAbsoluteLeft(elem) {
var left = elem.offsetLeft;
var body = document.body;
var e = elem.offsetParent;
while (e != null && elem != body) {
left += e.offsetLeft;
left -= e.scrollLeft;
e = e.offsetParent;
}
return left;
var rect = elem.getBoundingClientRect();
return rect.left + window.pageXOffset || document.scrollLeft || 0;
};
/**
* Retrieve the absolute top value of a DOM element
* @param {Element} elem A dom element, for example a div
* @return {Number} top The absolute top position of this element
* @return {Number} top The absolute top position of this element
* in the browser page.
*/
util.getAbsoluteTop = function getAbsoluteTop(elem) {
var top = elem.offsetTop;
var body = document.body;
var e = elem.offsetParent;
while (e != null && e != body) {
top += e.offsetTop;
top -= e.scrollTop;
e = e.offsetParent;
}
return top;
var rect = elem.getBoundingClientRect();
return rect.top + window.pageYOffset || document.scrollTop || 0;
};
/**

View File

@ -2,7 +2,7 @@
/* ContextMenu - main menu */
.jsoneditor-contextmenu {
position: fixed;
position: absolute;
z-index: 99999;
}

View File

@ -180,14 +180,16 @@ ContextMenu.prototype.show = function (anchor) {
this.hide();
// calculate whether the menu fits below the anchor
var windowHeight = window.innerHeight;
var anchorHeight = anchor.offsetHeight;
var menuHeight = this.maxHeight;
var windowHeight = window.innerHeight,
windowScroll = (window.pageYOffset || document.scrollTop),
windowBottom = windowHeight + windowScroll,
anchorHeight = anchor.offsetHeight,
menuHeight = this.maxHeight;
// position the menu
var left = util.getAbsoluteLeft(anchor);
var top = util.getAbsoluteTop(anchor);
if (top + anchorHeight + menuHeight < windowHeight) {
if (top + anchorHeight + menuHeight < windowBottom) {
// display the menu below the anchor
this.dom.menu.style.left = left + 'px';
this.dom.menu.style.top = (top + anchorHeight) + 'px';

View File

@ -121,33 +121,19 @@ util.isUrl = function isUrl (text) {
* in the browser page.
*/
util.getAbsoluteLeft = function getAbsoluteLeft(elem) {
var left = elem.offsetLeft;
var body = document.body;
var e = elem.offsetParent;
while (e != null && elem != body) {
left += e.offsetLeft;
left -= e.scrollLeft;
e = e.offsetParent;
}
return left;
var rect = elem.getBoundingClientRect();
return rect.left + window.pageXOffset || document.scrollLeft || 0;
};
/**
* Retrieve the absolute top value of a DOM element
* @param {Element} elem A dom element, for example a div
* @return {Number} top The absolute top position of this element
* @return {Number} top The absolute top position of this element
* in the browser page.
*/
util.getAbsoluteTop = function getAbsoluteTop(elem) {
var top = elem.offsetTop;
var body = document.body;
var e = elem.offsetParent;
while (e != null && e != body) {
top += e.offsetTop;
top -= e.scrollTop;
e = e.offsetParent;
}
return top;
var rect = elem.getBoundingClientRect();
return rect.top + window.pageYOffset || document.scrollTop || 0;
};
/**

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

6167
test/bootstrap/css/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load Diff

9
test/bootstrap/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

113
test/bootstrap/index.html Normal file
View File

@ -0,0 +1,113 @@
<!DOCTYPE html>
<html>
<head>
<title>Test Bootstrap modal</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" type="text/css" href="../../jsoneditor-min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="../../jsoneditor-min.js"></script>
<style>
body {
width: 500px;
margin: 20px;
padding: 20px;
}
</style>
</head>
<body>
<div style="height: 100px;"></div>
<h1>Test Bootstrap Modal</h1>
<a class="btn" data-toggle="modal" href="#myModal1">Launch Modal 1</a>
<div class="modal hide" id="myModal1"><!-- note the use of "hide" class -->
<div class="modal-header">
<button class="close" data-dismiss="modal">&times;</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body...</p>
<div id="jsoneditor1"></div>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a><!-- note the use of "data-dismiss" -->
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
<a class="btn" data-toggle="modal" href="#myModal2">Launch Modal 2</a>
<div class="modal hide" id="myModal2"><!-- note the use of "hide" class -->
<div class="modal-header">
<button class="close" data-dismiss="modal">&times;</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body...</p>
<div id="jsoneditor2" style="height: 300px;"></div>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a><!-- note the use of "data-dismiss" -->
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
<p></p>
<div id="jsoneditor3"></div>
<p></p>
<div id="jsoneditor4" style="height: 300px;"></div>
<p></p>
<div style="width:500px; height:300px; overflow: auto; background: lightgray;">
<div style="width: 700px; height:200px;"></div>
<div id="jsoneditor5" style="width: 300px; height: 300px; background: white; margin: 0 200px;"></div>
<div style="height:200px;"></div>
</div>
<div style="height: 400px;"></div>
<script>
function createEditor (container) {
var options = {};
var json = {
'array': [1, 2, 3],
'boolean': true,
'null': null,
'number': 123,
'object': {'a': 'b', 'c': 'd'},
'string': 'Hello World'
};
var editor = new jsoneditor.JSONEditor(container, options, json);
}
setTimeout(function () {
createEditor(document.getElementById('jsoneditor1'));
createEditor(document.getElementById('jsoneditor2'));
createEditor(document.getElementById('jsoneditor3'));
createEditor(document.getElementById('jsoneditor4'));
createEditor(document.getElementById('jsoneditor5'));
document.getElementById('jsoneditor5').parentNode.scrollLeft = 100;
document.getElementById('jsoneditor5').parentNode.scrollTop = 100;
document.scrollTop = 100;
}, 0);
</script>
</body>
</html>

2280
test/bootstrap/js/bootstrap.js vendored Normal file

File diff suppressed because it is too large Load Diff

6
test/bootstrap/js/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long