diff --git a/brewman/static/scripts/angular_directive.js b/brewman/static/scripts/angular_directive.js index 1662f615..8cfff70b 100644 --- a/brewman/static/scripts/angular_directive.js +++ b/brewman/static/scripts/angular_directive.js @@ -130,22 +130,30 @@ overlord_directive.directive('keypress', [function () { }); })(k); } - element.on('$destroy', function() { - $interval.cancel(timeoutId); - }); + element.on('$destroy', function () { + $interval.cancel(timeoutId); + }); }; }]); -overlord_directive.directive('onReturn', function () { - return function (scope, elm, attrs) { - elm.bind("keypress", function (event) { - if (event.which === 13) { - scope.$apply(attrs.onReturn); - } - }); +overlord_directive.directive('onReturn', ['$parse', function ($parse) { + return { + compile: function ($element, attr) { + var fn = $parse(attr["onReturn"]); + return function (scope, element, attr) { + element.on("keypress", function (event) { + if (event.which === 13) { + scope.$apply(function () { + fn(scope, {$event: event}); + }); + } + }); + }; + } }; -}); +}]); + overlord_directive.directive('tanSse', ['$parse', function ($parse) { return{ @@ -211,8 +219,12 @@ overlord_directive.directive('chartDiscreteBar', ['$parse', function ($parse) { link: function (scope, element, attrs) { nv.addGraph(function () { var chart = nv.models.discreteBarChart() - .x(function (d) {return d.label;}) - .y(function (d) {return d.value;}) + .x(function (d) { + return d.label; + }) + .y(function (d) { + return d.value; + }) .staggerLabels(true) .tooltips(false) .showValues(true); @@ -291,8 +303,12 @@ overlord_directive.directive('chartPie', ['$parse', function ($parse) { nv.addGraph(function () { chart = nv.models.pieChart() - .x(function (d) {return d.label;}) - .y(function (d) {return d.value;}) + .x(function (d) { + return d.label; + }) + .y(function (d) { + return d.value; + }) .showLabels(true); // var data = $parse(attrs.chartPie)(scope); d3.select('#' + attrs.id + ' svg') @@ -324,8 +340,12 @@ overlord_directive.directive('chartLinePlusBar', ['$parse', function ($parse) { } nv.addGraph(function () { chart = nv.models.linePlusBarChart() - .x(function (d) {return d.label;}) - .y(function (d) {return d.value;}); + .x(function (d) { + return d.label; + }) + .y(function (d) { + return d.value; + }); chart.xAxis.axisLabel('Date').tickFormat(function (d) { return d3.time.format('%b %d')(new Date(d)); });