Skip to content

Commit

Permalink
Disabled saving files using HTML5 on Firefox to prevent a Firefox bug
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Nov 15, 2013
1 parent 1c1ffe4 commit 8ddc6f3
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 522 deletions.
4 changes: 3 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
http://jsoneditoronline.org


## not yet released, version 2.3.4
## not yet released, version 2.4.0

- Dropped support for IE8, cleaned up legacy code for old browsers.
- Disabled saving files using HTML5 on Firefox to prevent a Firefox bug
blocking cut/paste functionality in editable divs after using a.download.


## 2013-10-17, version 2.3.3
Expand Down
5 changes: 4 additions & 1 deletion app/web/fileretriever.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,11 @@ FileRetriever.prototype.saveFile = function (data, callback) {
};

// create an anchor to save files to disk (if supported by the browser)
// Note: save file using a.download is disabled in Firefox because of a
// a bug in Firefox, which breaks the cut/paste functionality of
// editable divs on the page.
var a = document.createElement('a');
if (this.options.html5 && a.download != undefined) {
if (this.options.html5 && a.download != undefined && !util.isFirefox()) {
// save file directly using a data URL
a.style.display = 'none';
a.href = 'data:application/json;charset=utf-8,' + encodeURIComponent(data);
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsoneditor",
"version": "2.3.4-SNAPSHOT",
"version": "2.4.0-SNAPSHOT",
"description": "A web-based tool to view, edit and format JSON",
"tags": [
"json",
Expand Down
4 changes: 2 additions & 2 deletions jsoneditor-min.js

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions jsoneditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Copyright (c) 2011-2013 Jos de Jong, http://jsoneditoronline.org
*
* @author Jos de Jong, <[email protected]>
* @version 2.3.4-SNAPSHOT
* @version 2.4.0-SNAPSHOT
* @date 2013-11-15
*/
(function () {
Expand Down Expand Up @@ -4597,8 +4597,8 @@ ContextMenu.prototype.show = function (anchor) {
}
});
this.eventListeners.mousewheel = util.addEventListener(
document, 'mousewheel', function () {
// hide the menu on mouse scroll
document, 'mousewheel', function (event) {
// block scrolling when context menu is visible
event.stopPropagation();
event.preventDefault();
});
Expand Down Expand Up @@ -5922,6 +5922,14 @@ util.getInternetExplorerVersion = function getInternetExplorerVersion() {
return _ieVersion;
};

/**
* Test whether the current browser is Firefox
* @returns {boolean} isFirefox
*/
util.isFirefox = function isFirefox () {
return (navigator.userAgent.indexOf("Firefox") != -1);
};

/**
* cached internet explorer version
* @type {Number}
Expand All @@ -5943,7 +5951,7 @@ util.addEventListener = function addEventListener(element, action, listener, use
if (useCapture === undefined)
useCapture = false;

if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
if (action === "mousewheel" && util.isFirefox()) {
action = "DOMMouseScroll"; // For Firefox
}

Expand All @@ -5966,7 +5974,7 @@ util.removeEventListener = function removeEventListener(element, action, listene
if (useCapture === undefined)
useCapture = false;

if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
if (action === "mousewheel" && util.isFirefox()) {
action = "DOMMouseScroll"; // For Firefox
}

Expand Down
12 changes: 10 additions & 2 deletions jsoneditor/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ util.getInternetExplorerVersion = function getInternetExplorerVersion() {
return _ieVersion;
};

/**
* Test whether the current browser is Firefox
* @returns {boolean} isFirefox
*/
util.isFirefox = function isFirefox () {
return (navigator.userAgent.indexOf("Firefox") != -1);
};

/**
* cached internet explorer version
* @type {Number}
Expand All @@ -440,7 +448,7 @@ util.addEventListener = function addEventListener(element, action, listener, use
if (useCapture === undefined)
useCapture = false;

if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
if (action === "mousewheel" && util.isFirefox()) {
action = "DOMMouseScroll"; // For Firefox
}

Expand All @@ -463,7 +471,7 @@ util.removeEventListener = function removeEventListener(element, action, listene
if (useCapture === undefined)
useCapture = false;

if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
if (action === "mousewheel" && util.isFirefox()) {
action = "DOMMouseScroll"; // For Firefox
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsoneditor",
"version": "2.3.4-SNAPSHOT",
"version": "2.4.0-SNAPSHOT",
"main": "jsoneditor.js",
"description": "A web-based tool to view, edit and format JSON",
"tags": [
Expand Down
60 changes: 0 additions & 60 deletions test/test_ace.html

This file was deleted.

Loading

0 comments on commit 8ddc6f3

Please sign in to comment.