Fix: Bug in the onReturn directive which refreshed the page.

This commit is contained in:
Amritanshu 2014-05-24 18:51:22 +05:30
parent 1f8b6f0c63
commit 29653b524a

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