Commit 46559ae9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

center button functionality fixed

parent 86b49cb1
......@@ -186,7 +186,7 @@ CustomMap.prototype.createLogo = function () {
className: "minerva-center-map-button",
href: "#",
onclick: function () {
var bounds = new Bounds(new Point(0, 0), new Point(self.getWidth(), self.getHeight()));
var bounds = new Bounds(new Point(0, 0), new Point(self.getModel().getWidth(), self.getModel().getHeight()));
return self.getMapCanvas().fitBounds(bounds);
},
xss: false
......
......@@ -985,6 +985,20 @@ describe('CustomMap', function () {
});
it("center button", function () {
var options = helper.createCustomMapOptions();
var map = new CustomMap(options);
return map.init().then(function () {
ServerConnector.getSessionData().setCenter(map.getModel(), new Point(0, 0));
return $(".minerva-center-map-button", map.getElement())[0].onclick();
}).then(function () {
var center = ServerConnector.getSessionData().getCenter(map.getModel());
assert.ok(center.distanceTo(new Point(0, 0)) > helper.EPSILON);
return map.destroy();
})
});
describe("appendElementsPointingToSubmap", function () {
it("point to reaction", function () {
helper.setUrl("http://test/?id=complex_model_with_submaps");
......@@ -1025,7 +1039,11 @@ describe('CustomMap', function () {
alias.setWidth(100);
alias.setHeight(200);
var ie = new IdentifiedElement(alias);
return map.getDistance({modelId:map.getId(), coordinates: new Point(100,200), element: ie}).then(function(distance){
return map.getDistance({
modelId: map.getId(),
coordinates: new Point(100, 200),
element: ie
}).then(function (distance) {
assert.equal(0, distance);
return map.destroy();
});
......@@ -1038,7 +1056,11 @@ describe('CustomMap', function () {
alias.setWidth(100);
alias.setHeight(200);
var ie = new IdentifiedElement(alias);
return map.getDistance({modelId:map.getId(), coordinates: new Point(1,200), element: ie}).then(function(distance){
return map.getDistance({
modelId: map.getId(),
coordinates: new Point(1, 200),
element: ie
}).then(function (distance) {
assert.equal(49, distance);
return map.destroy();
});
......@@ -1051,7 +1073,11 @@ describe('CustomMap', function () {
alias.setWidth(100);
alias.setHeight(200);
var ie = new IdentifiedElement(alias);
return map.getDistance({modelId:map.getId(), coordinates: new Point(161,200), element: ie}).then(function(distance){
return map.getDistance({
modelId: map.getId(),
coordinates: new Point(161, 200),
element: ie
}).then(function (distance) {
assert.equal(11, distance);
return map.destroy();
});
......@@ -1064,7 +1090,11 @@ describe('CustomMap', function () {
alias.setWidth(100);
alias.setHeight(200);
var ie = new IdentifiedElement(alias);
return map.getDistance({modelId:map.getId(), coordinates: new Point(100,11), element: ie}).then(function(distance){
return map.getDistance({
modelId: map.getId(),
coordinates: new Point(100, 11),
element: ie
}).then(function (distance) {
assert.equal(49, distance);
return map.destroy();
});
......@@ -1077,7 +1107,11 @@ describe('CustomMap', function () {
alias.setWidth(100);
alias.setHeight(200);
var ie = new IdentifiedElement(alias);
return map.getDistance({modelId:map.getId(), coordinates: new Point(100,300), element: ie}).then(function(distance){
return map.getDistance({
modelId: map.getId(),
coordinates: new Point(100, 300),
element: ie
}).then(function (distance) {
assert.equal(40, distance);
return map.destroy();
});
......@@ -1090,7 +1124,11 @@ describe('CustomMap', function () {
alias.setWidth(100);
alias.setHeight(200);
var ie = new IdentifiedElement(alias);
return map.getDistance({modelId:map.getId(), coordinates: new Point(46,57), element: ie}).then(function(distance){
return map.getDistance({
modelId: map.getId(),
coordinates: new Point(46, 57),
element: ie
}).then(function (distance) {
assert.equal(5, distance);
return map.destroy();
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment