-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.js
More file actions
42 lines (41 loc) · 1.44 KB
/
Copy pathdebug.js
File metadata and controls
42 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function() {
'use strict';
var app = angular.module('platypus.debug', [
'platypus.jsonviewer'
]);
app.directive('debug', function(){
var listenKeypress = function(){
angular.element(document.body).on('keypress', function(e){
if (e.charCode === 68 && e.shiftKey &&
['INPUT', 'SELECT', 'TEXTAREA'].indexOf(e.target.tagName) < 0 &&
angular.element(e.target).attr('contenteditable') !== 'true') {
angular.element(document.body).toggleClass('showDebug');
angular.element(document).triggerHandler('debugToggle');
}
});
};
if(document.readyState === "complete") {
listenKeypress();
} else {
angular.element(window).on('load', listenKeypress);
}
return {
restrict: 'E',
template: '<div json-viewer="debugData"></div>',
scope: {
data: '='
},
link: function(scope) {
scope.debugData = null;
angular.element(document).bind('debugToggle', function() {
if (scope.debugData === null){
scope.debugData = scope.data;
} else {
scope.debugData = null;
}
scope.$apply();
});
}
};
});
})();