diff options
Diffstat (limited to 'testapi/3rd_party/static/testapi-ui/assets/lib/angular-json-tree/angular-json-tree.min.js')
-rw-r--r-- | testapi/3rd_party/static/testapi-ui/assets/lib/angular-json-tree/angular-json-tree.min.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/testapi/3rd_party/static/testapi-ui/assets/lib/angular-json-tree/angular-json-tree.min.js b/testapi/3rd_party/static/testapi-ui/assets/lib/angular-json-tree/angular-json-tree.min.js new file mode 100644 index 0000000..59389b0 --- /dev/null +++ b/testapi/3rd_party/static/testapi-ui/assets/lib/angular-json-tree/angular-json-tree.min.js @@ -0,0 +1,67 @@ +/*global angular */ ! function () { + "use strict"; + var e = { + is: function (e, a) { + return Object.prototype.toString.call(e).slice(8, -1) === a + }, + whatClass: function (e) { + return Object.prototype.toString.call(e).slice(8, -1) + }, + forKeys: function (e, a) { + for (var n in e) + if (e.hasOwnProperty(n) && "function" != typeof e[n] && a(n, e[n])) break + } + }; + angular.module("angular-json-tree", ["ajs.RecursiveDirectiveHelper"]).directive("jsonTree", [function () { + return { + restrict: "E", + scope: { + object: "=", + startExpanded: "&?", + rootName: "&?" + }, + template: '<json-node key="rootName() || \'\'" value="object" start-expanded="startExpanded()"></json-node>' + } + }]).directive("jsonNode", ["ajsRecursiveDirectiveHelper", function (a) { + return { + restrict: "E", + scope: { + key: "=", + value: "=", + startExpanded: "&?" + }, + compile: function (e) { + return a.compile(e, this) + }, + template: ' <span style="padding-left:0px" class= "key col-md-2" ng-class="{\'hidden\' : key==\'\' && key!=\'0\'}" ng-click="toggleExpanded()">{{key}}</span> <span class="leaf-value col-md-10" ng-if="!isExpandable">{{value}}</span> <span class="branch-preview" ng-if="isExpandable" ng-show="!isExpanded" ng-click="toggleExpanded()">{{preview}}</span> <ul class="branch-value" ng-if="isExpandable" > <li ng-repeat="(subkey,subval) in value"> <json-node key="subkey" class="col-md-12" value="subval"></json-node> </li> </ul>', + pre: function (a, n, s) { + if (n.addClass(e.whatClass(a.value).toLowerCase()), e.is(a.value, "Object") || e.is(a.value, "Array")) { + a.isExpandable = !0, n.addClass("expandable"); + var t = e.is(a.value, "Array"); + a.preview = t ? "[ " : "{ ", e.forKeys(a.value, function (e, n) { + t ? a.preview += n + ", " : a.preview += e + ": " + n + ", " + }), a.preview = a.preview.substring(0, a.preview.length - (a.preview.length > 2 ? 2 : 0)) + (t ? " ]" : " }"), a.startExpanded && a.startExpanded() && (a.shouldRender = !0, n.addClass("expanded")), a.isExpanded = a.startExpanded ? a.startExpanded() : !1, a.toggleExpanded = function () { + a.isExpanded = !a.isExpanded, a.isExpanded ? n.addClass("expanded") : n.removeClass("expanded"), a.shouldRender = !0 + } + } else a.isExpandable = !1, n.addClass("not-expandable") + } + } + }]), angular.module("ajs.RecursiveDirectiveHelper", []).factory("ajsRecursiveDirectiveHelper", ["$compile", function (e) { + return { + compile: function (a, n) { + angular.isFunction(n) && (n = { + post: n + }); + var s, t = a.contents().remove(); + return { + pre: n && n.pre ? n.pre : null, + post: function (a, r) { + s || (s = e(t)), s(a, function (e) { + r.append(e) + }), n && n.post && n.post.apply(null, arguments) + } + } + } + } + }]) +}();
\ No newline at end of file |