diff --git a/demo/demo.html b/demo/demo.html
index 07ee71d..6680d67 100644
--- a/demo/demo.html
+++ b/demo/demo.html
@@ -65,6 +65,12 @@
Configuration
+
+
+
Demo
diff --git a/demo/demo.js b/demo/demo.js
index ec441da..226bdb4 100644
--- a/demo/demo.js
+++ b/demo/demo.js
@@ -5,6 +5,7 @@ app.controller('MainCtrl', function ($scope, $http, JSONFormatterConfig) {
$scope.hoverPreviewEnabled = JSONFormatterConfig.hoverPreviewEnabled;
$scope.hoverPreviewArrayCount = JSONFormatterConfig.hoverPreviewArrayCount;
$scope.hoverPreviewFieldCount = JSONFormatterConfig.hoverPreviewFieldCount;
+ $scope.openUrlsInNewWindow = JSONFormatterConfig.openUrlsInNewWindow;
$scope.$watch('hoverPreviewEnabled', function(newValue){
JSONFormatterConfig.hoverPreviewEnabled = newValue;
@@ -15,6 +16,9 @@ app.controller('MainCtrl', function ($scope, $http, JSONFormatterConfig) {
$scope.$watch('hoverPreviewFieldCount', function(newValue){
JSONFormatterConfig.hoverPreviewFieldCount = newValue;
});
+ $scope.$watch('openUrlsInNewWindow', function(newValue){
+ JSONFormatterConfig.openUrlsInNewWindow = newValue;
+ });
$scope.undef = undefined;
$scope.textarea = '{}';
diff --git a/dist/json-formatter.css b/dist/json-formatter.css
index 10bfab4..f603152 100644
--- a/dist/json-formatter.css
+++ b/dist/json-formatter.css
@@ -1,7 +1,7 @@
/*!
* jsonformatter
*
- * Version: 0.4.1 - 2015-12-03T03:38:59.933Z
+ * Version: 0.4.2 - 2015-12-24T14:10:17.232Z
* License: MIT
*/
@@ -40,13 +40,13 @@
color: red;
}
.json-formatter-row .null {
- color: #855a00;
+ color: #855A00;
}
.json-formatter-row .undefined {
color: #ca0b69;
}
.json-formatter-row .function {
- color: #ff20ed;
+ color: #FF20ED;
}
.json-formatter-row .date {
background-color: rgba(0, 0, 0, 0.05);
@@ -60,7 +60,7 @@
color: blue;
}
.json-formatter-row .key {
- color: #00008b;
+ color: #00008B;
cursor: pointer;
}
.json-formatter-row .constructor-name {
@@ -112,38 +112,38 @@
content: "[]";
}
.json-formatter-dark.json-formatter-row .string {
- color: #31f031;
+ color: #31F031;
white-space: pre;
word-wrap: break-word;
}
.json-formatter-dark.json-formatter-row .number {
- color: #66c2ff;
+ color: #66C2FF;
}
.json-formatter-dark.json-formatter-row .boolean {
- color: #ec4242;
+ color: #EC4242;
}
.json-formatter-dark.json-formatter-row .null {
- color: #eec97d;
+ color: #EEC97D;
}
.json-formatter-dark.json-formatter-row .undefined {
color: #ef8fbe;
}
.json-formatter-dark.json-formatter-row .function {
- color: #fd48cb;
+ color: #FD48CB;
}
.json-formatter-dark.json-formatter-row .date {
background-color: rgba(255, 255, 255, 0.05);
}
.json-formatter-dark.json-formatter-row .url {
text-decoration: underline;
- color: #027bff;
+ color: #027BFF;
cursor: pointer;
}
.json-formatter-dark.json-formatter-row .bracket {
- color: #9494ff;
+ color: #9494FF;
}
.json-formatter-dark.json-formatter-row .key {
- color: #23a0db;
+ color: #23A0DB;
cursor: pointer;
}
.json-formatter-dark.json-formatter-row .constructor-name {
diff --git a/dist/json-formatter.js b/dist/json-formatter.js
index 7f636a1..d43c0bf 100644
--- a/dist/json-formatter.js
+++ b/dist/json-formatter.js
@@ -1,7 +1,7 @@
/*!
* jsonformatter
*
- * Version: 0.4.1 - 2015-12-03T03:38:59.925Z
+ * Version: 0.4.2 - 2015-12-24T14:10:17.220Z
* License: MIT
*/
@@ -16,6 +16,7 @@ angular.module('jsonFormatter', ['RecursionHelper'])
var hoverPreviewEnabled = false;
var hoverPreviewArrayCount = 100;
var hoverPreviewFieldCount = 5;
+ var openUrlsInNewWindow = false;
return {
get hoverPreviewEnabled() {
@@ -38,12 +39,18 @@ angular.module('jsonFormatter', ['RecursionHelper'])
set hoverPreviewFieldCount(value) {
hoverPreviewFieldCount = parseInt(value, 10);
},
-
+ get openUrlsInNewWindow() {
+ return openUrlsInNewWindow;
+ },
+ set openUrlsInNewWindow(value) {
+ openUrlsInNewWindow = !!value;
+ },
$get: function () {
return {
hoverPreviewEnabled: hoverPreviewEnabled,
hoverPreviewArrayCount: hoverPreviewArrayCount,
- hoverPreviewFieldCount: hoverPreviewFieldCount
+ hoverPreviewFieldCount: hoverPreviewFieldCount,
+ openUrlsInNewWindow: openUrlsInNewWindow
};
}
};
@@ -166,7 +173,14 @@ angular.module('jsonFormatter', ['RecursionHelper'])
scope.openLink = function (isUrl) {
if(isUrl) {
- window.location.href = scope.json;
+ if(!!JSONFormatterConfig.openUrlsInNewWindow){
+ var win = window.open(scope.json, '_blank');
+ if(win){ //Browser allowed link to be opened
+ win.focus();
+ }
+ }else{
+ window.location.href = scope.json;
+ }
}
};
diff --git a/dist/json-formatter.min.css b/dist/json-formatter.min.css
index 9c547bf..8764d5d 100644
--- a/dist/json-formatter.min.css
+++ b/dist/json-formatter.min.css
@@ -1,6 +1,6 @@
/*!
* jsonformatter
*
- * Version: 0.4.1 - 2015-12-03T03:38:59.933Z
+ * Version: 0.4.2 - 2015-12-24T14:10:17.232Z
* License: MIT
- */.json-formatter-dark.json-formatter-row,.json-formatter-row{font-family:monospace}.json-formatter-dark.json-formatter-row .toggler.open:after,.json-formatter-row .toggler.open:after{transform:rotate(90deg)}.json-formatter-row,.json-formatter-row a,.json-formatter-row a:hover{color:#000;text-decoration:none}.json-formatter-row .json-formatter-row{margin-left:1em}.json-formatter-row .children.empty{opacity:.5;margin-left:1em}.json-formatter-row .children.empty.object:after{content:"No properties"}.json-formatter-row .children.empty.array:after{content:"[]"}.json-formatter-row .string{color:green;white-space:pre;word-wrap:break-word}.json-formatter-row .number{color:#00f}.json-formatter-row .boolean{color:red}.json-formatter-row .null{color:#855a00}.json-formatter-row .undefined{color:#ca0b69}.json-formatter-row .function{color:#ff20ed}.json-formatter-row .date{background-color:rgba(0,0,0,.05)}.json-formatter-row .url{text-decoration:underline;color:#00f;cursor:pointer}.json-formatter-row .bracket{color:#00f}.json-formatter-row .key{color:#00008b;cursor:pointer}.json-formatter-row .constructor-name{cursor:pointer}.json-formatter-row .toggler{font-size:.8em;line-height:1.2em;vertical-align:middle;opacity:.6;cursor:pointer}.json-formatter-row .toggler:after{display:inline-block;transition:transform .1s ease-in;content:"►"}.json-formatter-row>a>.thumbnail-text{opacity:0;transition:opacity .15s ease-in;font-style:italic}.json-formatter-row:hover>a>.thumbnail-text{opacity:.6}.json-formatter-dark.json-formatter-row,.json-formatter-dark.json-formatter-row a,.json-formatter-dark.json-formatter-row a:hover{color:#fff;text-decoration:none}.json-formatter-dark.json-formatter-row .json-formatter-row{margin-left:1em}.json-formatter-dark.json-formatter-row .children.empty{opacity:.5;margin-left:1em}.json-formatter-dark.json-formatter-row .children.empty.object:after{content:"No properties"}.json-formatter-dark.json-formatter-row .children.empty.array:after{content:"[]"}.json-formatter-dark.json-formatter-row .string{color:#31f031;white-space:pre;word-wrap:break-word}.json-formatter-dark.json-formatter-row .number{color:#66c2ff}.json-formatter-dark.json-formatter-row .boolean{color:#ec4242}.json-formatter-dark.json-formatter-row .null{color:#eec97d}.json-formatter-dark.json-formatter-row .undefined{color:#ef8fbe}.json-formatter-dark.json-formatter-row .function{color:#fd48cb}.json-formatter-dark.json-formatter-row .date{background-color:rgba(255,255,255,.05)}.json-formatter-dark.json-formatter-row .url{text-decoration:underline;color:#027bff;cursor:pointer}.json-formatter-dark.json-formatter-row .bracket{color:#9494ff}.json-formatter-dark.json-formatter-row .key{color:#23a0db;cursor:pointer}.json-formatter-dark.json-formatter-row .constructor-name{cursor:pointer}.json-formatter-dark.json-formatter-row .toggler{font-size:.8em;line-height:1.2em;vertical-align:middle;opacity:.6;cursor:pointer}.json-formatter-dark.json-formatter-row .toggler:after{display:inline-block;transition:transform .1s ease-in;content:"►"}.json-formatter-dark.json-formatter-row>a>.thumbnail-text{opacity:0;transition:opacity .15s ease-in;font-style:italic}.json-formatter-dark.json-formatter-row:hover>a>.thumbnail-text{opacity:.6}
\ No newline at end of file
+ */.json-formatter-dark.json-formatter-row,.json-formatter-row{font-family:monospace}.json-formatter-dark.json-formatter-row .toggler.open:after,.json-formatter-row .toggler.open:after{transform:rotate(90deg)}.json-formatter-row,.json-formatter-row a,.json-formatter-row a:hover{color:#000;text-decoration:none}.json-formatter-row .json-formatter-row{margin-left:1em}.json-formatter-row .children.empty{opacity:.5;margin-left:1em}.json-formatter-row .children.empty.object:after{content:"No properties"}.json-formatter-row .children.empty.array:after{content:"[]"}.json-formatter-row .string{color:green;white-space:pre;word-wrap:break-word}.json-formatter-row .number{color:#00f}.json-formatter-row .boolean{color:red}.json-formatter-row .null{color:#855A00}.json-formatter-row .undefined{color:#ca0b69}.json-formatter-row .function{color:#FF20ED}.json-formatter-row .date{background-color:rgba(0,0,0,.05)}.json-formatter-row .url{text-decoration:underline;color:#00f;cursor:pointer}.json-formatter-row .bracket{color:#00f}.json-formatter-row .key{color:#00008B;cursor:pointer}.json-formatter-row .constructor-name{cursor:pointer}.json-formatter-row .toggler{font-size:.8em;line-height:1.2em;vertical-align:middle;opacity:.6;cursor:pointer}.json-formatter-row .toggler:after{display:inline-block;transition:transform .1s ease-in;content:"►"}.json-formatter-row>a>.thumbnail-text{opacity:0;transition:opacity .15s ease-in;font-style:italic}.json-formatter-row:hover>a>.thumbnail-text{opacity:.6}.json-formatter-dark.json-formatter-row,.json-formatter-dark.json-formatter-row a,.json-formatter-dark.json-formatter-row a:hover{color:#fff;text-decoration:none}.json-formatter-dark.json-formatter-row .json-formatter-row{margin-left:1em}.json-formatter-dark.json-formatter-row .children.empty{opacity:.5;margin-left:1em}.json-formatter-dark.json-formatter-row .children.empty.object:after{content:"No properties"}.json-formatter-dark.json-formatter-row .children.empty.array:after{content:"[]"}.json-formatter-dark.json-formatter-row .string{color:#31F031;white-space:pre;word-wrap:break-word}.json-formatter-dark.json-formatter-row .number{color:#66C2FF}.json-formatter-dark.json-formatter-row .boolean{color:#EC4242}.json-formatter-dark.json-formatter-row .null{color:#EEC97D}.json-formatter-dark.json-formatter-row .undefined{color:#ef8fbe}.json-formatter-dark.json-formatter-row .function{color:#FD48CB}.json-formatter-dark.json-formatter-row .date{background-color:rgba(255,255,255,.05)}.json-formatter-dark.json-formatter-row .url{text-decoration:underline;color:#027BFF;cursor:pointer}.json-formatter-dark.json-formatter-row .bracket{color:#9494FF}.json-formatter-dark.json-formatter-row .key{color:#23A0DB;cursor:pointer}.json-formatter-dark.json-formatter-row .constructor-name{cursor:pointer}.json-formatter-dark.json-formatter-row .toggler{font-size:.8em;line-height:1.2em;vertical-align:middle;opacity:.6;cursor:pointer}.json-formatter-dark.json-formatter-row .toggler:after{display:inline-block;transition:transform .1s ease-in;content:"►"}.json-formatter-dark.json-formatter-row>a>.thumbnail-text{opacity:0;transition:opacity .15s ease-in;font-style:italic}.json-formatter-dark.json-formatter-row:hover>a>.thumbnail-text{opacity:.6}
\ No newline at end of file
diff --git a/dist/json-formatter.min.js b/dist/json-formatter.min.js
index 2631013..4886d11 100644
--- a/dist/json-formatter.min.js
+++ b/dist/json-formatter.min.js
@@ -1,7 +1,7 @@
/*!
* jsonformatter
*
- * Version: 0.4.1 - 2015-12-03T03:38:59.925Z
+ * Version: 0.4.2 - 2015-12-24T14:10:17.220Z
* License: MIT
*/
-"use strict";angular.module("jsonFormatter",["RecursionHelper"]).provider("JSONFormatterConfig",function(){var n=!1,e=100,t=5;return{get hoverPreviewEnabled(){return n},set hoverPreviewEnabled(e){n=!!e},get hoverPreviewArrayCount(){return e},set hoverPreviewArrayCount(n){e=parseInt(n,10)},get hoverPreviewFieldCount(){return t},set hoverPreviewFieldCount(n){t=parseInt(n,10)},$get:function(){return{hoverPreviewEnabled:n,hoverPreviewArrayCount:e,hoverPreviewFieldCount:t}}}}).directive("jsonFormatter",["RecursionHelper","JSONFormatterConfig",function(n,e){function t(n){return n.replace('"','"')}function r(n){if(void 0===n)return"";if(null===n)return"Object";if("object"==typeof n&&!n.constructor)return"Object";var e=/function (.{1,})\(/,t=e.exec(n.constructor.toString());return t&&t.length>1?t[1]:""}function o(n){return null===n?"null":typeof n}function s(n,e){var r=o(n);return"null"===r||"undefined"===r?r:("string"===r&&(e='"'+t(e)+'"'),"function"===r?n.toString().replace(/[\r\n]/g,"").replace(/\{.*\}/,"")+"{…}":e)}function i(n){var e="";return angular.isObject(n)?(e=r(n),angular.isArray(n)&&(e+="["+n.length+"]")):e=s(n,n),e}function a(n){n.isArray=function(){return angular.isArray(n.json)},n.isObject=function(){return angular.isObject(n.json)},n.getKeys=function(){return n.isObject()?Object.keys(n.json).map(function(n){return""===n?'""':n}):void 0},n.type=o(n.json),n.hasKey="undefined"!=typeof n.key,n.getConstructorName=function(){return r(n.json)},"string"===n.type&&("Invalid Date"!==new Date(n.json).toString()&&(n.isDate=!0),0===n.json.indexOf("http")&&(n.isUrl=!0)),n.isEmptyObject=function(){return n.getKeys()&&!n.getKeys().length&&n.isOpen&&!n.isArray()},n.isOpen=!!n.open,n.toggleOpen=function(){n.isOpen=!n.isOpen},n.childrenOpen=function(){return n.open>1?n.open-1:0},n.openLink=function(e){e&&(window.location.href=n.json)},n.parseValue=function(e){return s(n.json,e)},n.showThumbnail=function(){return!!e.hoverPreviewEnabled&&n.isObject()&&!n.isOpen},n.getThumbnail=function(){if(n.isArray())return n.json.length>e.hoverPreviewArrayCount?"Array["+n.json.length+"]":"["+n.json.map(i).join(", ")+"]";var t=n.getKeys(),r=t.slice(0,e.hoverPreviewFieldCount),o=r.map(function(e){return e+":"+i(n.json[e])}),s=t.length>=5?"…":"";return"{"+o.join(", ")+s+"}"}}return{templateUrl:"json-formatter.html",restrict:"E",replace:!0,scope:{json:"=",key:"=",open:"="},compile:function(e){return n.compile(e,a)}}}]),"object"==typeof module&&(module.exports="jsonFormatter"),angular.module("RecursionHelper",[]).factory("RecursionHelper",["$compile",function(n){return{compile:function(e,t){angular.isFunction(t)&&(t={post:t});var r,o=e.contents().remove();return{pre:t&&t.pre?t.pre:null,post:function(e,s){r||(r=n(o)),r(e,function(n){s.append(n)}),t&&t.post&&t.post.apply(null,arguments)}}}}}]),angular.module("jsonFormatter").run(["$templateCache",function(n){n.put("json-formatter.html",'')}]);
\ No newline at end of file
+"use strict";angular.module("jsonFormatter",["RecursionHelper"]).provider("JSONFormatterConfig",function(){var n=!1,e=100,t=5,r=!1;return{get hoverPreviewEnabled(){return n},set hoverPreviewEnabled(e){n=!!e},get hoverPreviewArrayCount(){return e},set hoverPreviewArrayCount(n){e=parseInt(n,10)},get hoverPreviewFieldCount(){return t},set hoverPreviewFieldCount(n){t=parseInt(n,10)},get openUrlsInNewWindow(){return r},set openUrlsInNewWindow(n){r=!!n},$get:function(){return{hoverPreviewEnabled:n,hoverPreviewArrayCount:e,hoverPreviewFieldCount:t,openUrlsInNewWindow:r}}}}).directive("jsonFormatter",["RecursionHelper","JSONFormatterConfig",function(n,e){function t(n){return n.replace('"','"')}function r(n){if(void 0===n)return"";if(null===n)return"Object";if("object"==typeof n&&!n.constructor)return"Object";var e=/function (.{1,})\(/,t=e.exec(n.constructor.toString());return t&&t.length>1?t[1]:""}function o(n){return null===n?"null":typeof n}function s(n,e){var r=o(n);return"null"===r||"undefined"===r?r:("string"===r&&(e='"'+t(e)+'"'),"function"===r?n.toString().replace(/[\r\n]/g,"").replace(/\{.*\}/,"")+"{…}":e)}function i(n){var e="";return angular.isObject(n)?(e=r(n),angular.isArray(n)&&(e+="["+n.length+"]")):e=s(n,n),e}function a(n){n.isArray=function(){return angular.isArray(n.json)},n.isObject=function(){return angular.isObject(n.json)},n.getKeys=function(){return n.isObject()?Object.keys(n.json).map(function(n){return""===n?'""':n}):void 0},n.type=o(n.json),n.hasKey="undefined"!=typeof n.key,n.getConstructorName=function(){return r(n.json)},"string"===n.type&&("Invalid Date"!==new Date(n.json).toString()&&(n.isDate=!0),0===n.json.indexOf("http")&&(n.isUrl=!0)),n.isEmptyObject=function(){return n.getKeys()&&!n.getKeys().length&&n.isOpen&&!n.isArray()},n.isOpen=!!n.open,n.toggleOpen=function(){n.isOpen=!n.isOpen},n.childrenOpen=function(){return n.open>1?n.open-1:0},n.openLink=function(t){if(t)if(e.openUrlsInNewWindow){var r=window.open(n.json,"_blank");r&&r.focus()}else window.location.href=n.json},n.parseValue=function(e){return s(n.json,e)},n.showThumbnail=function(){return!!e.hoverPreviewEnabled&&n.isObject()&&!n.isOpen},n.getThumbnail=function(){if(n.isArray())return n.json.length>e.hoverPreviewArrayCount?"Array["+n.json.length+"]":"["+n.json.map(i).join(", ")+"]";var t=n.getKeys(),r=t.slice(0,e.hoverPreviewFieldCount),o=r.map(function(e){return e+":"+i(n.json[e])}),s=t.length>=5?"…":"";return"{"+o.join(", ")+s+"}"}}return{templateUrl:"json-formatter.html",restrict:"E",replace:!0,scope:{json:"=",key:"=",open:"="},compile:function(e){return n.compile(e,a)}}}]),"object"==typeof module&&(module.exports="jsonFormatter"),angular.module("RecursionHelper",[]).factory("RecursionHelper",["$compile",function(n){return{compile:function(e,t){angular.isFunction(t)&&(t={post:t});var r,o=e.contents().remove();return{pre:t&&t.pre?t.pre:null,post:function(e,s){r||(r=n(o)),r(e,function(n){s.append(n)}),t&&t.post&&t.post.apply(null,arguments)}}}}}]),angular.module("jsonFormatter").run(["$templateCache",function(n){n.put("json-formatter.html",'')}]);
\ No newline at end of file
diff --git a/src/json-formatter.js b/src/json-formatter.js
index 36ab383..2acbf8d 100644
--- a/src/json-formatter.js
+++ b/src/json-formatter.js
@@ -8,6 +8,7 @@ angular.module('jsonFormatter', ['RecursionHelper'])
var hoverPreviewEnabled = false;
var hoverPreviewArrayCount = 100;
var hoverPreviewFieldCount = 5;
+ var openUrlsInNewWindow = false;
return {
get hoverPreviewEnabled() {
@@ -30,12 +31,18 @@ angular.module('jsonFormatter', ['RecursionHelper'])
set hoverPreviewFieldCount(value) {
hoverPreviewFieldCount = parseInt(value, 10);
},
-
+ get openUrlsInNewWindow() {
+ return openUrlsInNewWindow;
+ },
+ set openUrlsInNewWindow(value) {
+ openUrlsInNewWindow = !!value;
+ },
$get: function () {
return {
hoverPreviewEnabled: hoverPreviewEnabled,
hoverPreviewArrayCount: hoverPreviewArrayCount,
- hoverPreviewFieldCount: hoverPreviewFieldCount
+ hoverPreviewFieldCount: hoverPreviewFieldCount,
+ openUrlsInNewWindow: openUrlsInNewWindow
};
}
};
@@ -158,7 +165,14 @@ angular.module('jsonFormatter', ['RecursionHelper'])
scope.openLink = function (isUrl) {
if(isUrl) {
- window.location.href = scope.json;
+ if(!!JSONFormatterConfig.openUrlsInNewWindow){
+ var win = window.open(scope.json, '_blank');
+ if(win){ //Browser allowed link to be opened
+ win.focus();
+ }
+ }else{
+ window.location.href = scope.json;
+ }
}
};