2012-07-02 21:09:51 +00:00
|
|
|
panelApp.controller('OptionsCtrl', function OptionsCtrl($scope, appContext, chromeExtension) {
|
|
|
|
|
|
|
|
$scope.debugger = {
|
|
|
|
scopes: false,
|
|
|
|
bindings: false,
|
|
|
|
app: false
|
|
|
|
};
|
|
|
|
|
2012-07-25 21:37:54 +00:00
|
|
|
//TODO: improve look of highlighting; for instance, if an element is bound and a scope,
|
|
|
|
// you will only see the most recently applied outline
|
|
|
|
|
|
|
|
// TODO: refactor; remove chromeExtension calls in favor of adding methods to appContext
|
2012-07-02 21:09:51 +00:00
|
|
|
$scope.$watch('debugger.scopes', function (newVal, oldVal) {
|
|
|
|
if (newVal) {
|
|
|
|
chromeExtension.eval(function () {
|
|
|
|
var addCssRule = function (selector, rule) {
|
|
|
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
|
|
|
styleSheet.insertRule(selector + '{' + rule + '}', styleSheet.cssRules.length);
|
|
|
|
};
|
|
|
|
addCssRule('.ng-scope', 'border: 1px solid red');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
chromeExtension.eval(function () {
|
|
|
|
removeCssRule = function (selector, rule) {
|
|
|
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
|
|
|
|
|
|
|
var i;
|
|
|
|
for (i = styleSheet.cssRules.length - 1; i >= 0; i -= 1) {
|
|
|
|
if (styleSheet.cssRules[i].cssText === selector + ' { ' + rule + '; }') {
|
|
|
|
styleSheet.deleteRule(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
removeCssRule('.ng-scope', 'border: 1px solid red');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.$watch('debugger.bindings', function (newVal, oldVal) {
|
|
|
|
if (newVal) {
|
|
|
|
chromeExtension.eval(function () {
|
|
|
|
var addCssRule = function (selector, rule) {
|
|
|
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
|
|
|
styleSheet.insertRule(selector + '{' + rule + '}', styleSheet.cssRules.length);
|
|
|
|
};
|
|
|
|
addCssRule('.ng-binding', 'border: 1px solid blue');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
chromeExtension.eval(function () {
|
|
|
|
removeCssRule = function (selector, rule) {
|
|
|
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
|
|
|
|
|
|
|
var i;
|
|
|
|
for (i = styleSheet.cssRules.length - 1; i >= 0; i -= 1) {
|
|
|
|
if (styleSheet.cssRules[i].cssText === selector + ' { ' + rule + '; }') {
|
|
|
|
styleSheet.deleteRule(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
removeCssRule('.ng-binding', 'border: 1px solid blue');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.$watch('debugger.app', function (newVal, oldVal) {
|
|
|
|
if (newVal) {
|
|
|
|
chromeExtension.eval(function () {
|
|
|
|
var addCssRule = function (selector, rule) {
|
|
|
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
|
|
|
styleSheet.insertRule(selector + '{' + rule + '}', styleSheet.cssRules.length);
|
|
|
|
};
|
2012-07-25 21:37:54 +00:00
|
|
|
// TODO: rules for ng-app (is it added as a class?)
|
2012-07-02 21:09:51 +00:00
|
|
|
addCssRule('[ng-app]', 'border: 1px solid green');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
chromeExtension.eval(function () {
|
|
|
|
removeCssRule = function (selector, rule) {
|
|
|
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
|
|
|
|
|
|
|
var i;
|
|
|
|
for (i = styleSheet.cssRules.length - 1; i >= 0; i -= 1) {
|
|
|
|
if (styleSheet.cssRules[i].cssText === selector + ' { ' + rule + '; }') {
|
|
|
|
styleSheet.deleteRule(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
removeCssRule('[ng-app]', 'border: 1px solid green');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-07-10 19:10:12 +00:00
|
|
|
|
|
|
|
chromeExtension.eval(function () {
|
|
|
|
return window.angular.version.full +
|
|
|
|
' ' +
|
|
|
|
window.angular.version.codeName;
|
|
|
|
}, function (version) {
|
|
|
|
$scope.version = version;
|
|
|
|
});
|
2012-07-25 21:37:54 +00:00
|
|
|
|
|
|
|
appContext.getAngularSrc(function (status) {
|
|
|
|
$scope.status = status;
|
|
|
|
});
|
|
|
|
|
2012-07-02 21:09:51 +00:00
|
|
|
});
|