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);
}
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));
});