mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
9f6f164d9f
The results of running this command:: find . -name \*.js -print0 | xargs -0 perl -p -i -e "s|[ \t]+$||" (Split from #136)
79 lines
2.5 KiB
JavaScript
79 lines
2.5 KiB
JavaScript
(function() {
|
|
|
|
// ----------
|
|
window.Util = {
|
|
// ----------
|
|
simulateViewerClick: function(viewer, widthFactor, heightFactor) {
|
|
if (widthFactor === undefined) {
|
|
widthFactor = 0.5;
|
|
}
|
|
|
|
//TODO Redefine to be the middle by default
|
|
if (heightFactor === undefined) {
|
|
heightFactor = 0.5;
|
|
}
|
|
|
|
widthFactor = Math.min(1, Math.max(0, widthFactor));
|
|
//TODO Fix this. The max height should be 1/AR
|
|
heightFactor = Math.min(1, Math.max(0, heightFactor));
|
|
|
|
var $canvas = $(viewer.element).find('.openseadragon-canvas').not('.navigator .openseadragon-canvas');
|
|
var offset = $canvas.offset();
|
|
var event = {
|
|
clientX: offset.left + Math.floor($canvas.width() * widthFactor),
|
|
clientY: offset.top + Math.floor($canvas.height() * heightFactor)
|
|
};
|
|
|
|
$canvas
|
|
.simulate('mouseover', event)
|
|
.simulate('mousedown', event)
|
|
.simulate('mouseup', event);
|
|
},
|
|
|
|
resetDom: function () {
|
|
if ($('#exampleNavigator').is(':ui-dialog')) {
|
|
$('#exampleNavigator').dialog('destroy');
|
|
}
|
|
$("#exampleNavigator").remove();
|
|
$(".navigator").remove();
|
|
$("#example").empty();
|
|
$("#tallexample").empty();
|
|
$("#wideexample").empty();
|
|
$("#example").parent().append('<div id="exampleNavigator"></div>');
|
|
},
|
|
|
|
equalsWithVariance: function (value1, value2, variance) {
|
|
return Math.abs(value1 - value2) <= variance;
|
|
},
|
|
|
|
assessNumericValue: function (value1, value2, variance, message) {
|
|
ok(Util.equalsWithVariance(value1, value2, variance), message + " Expected:" + value1 + " Found: " + value2 + " Variance: " + variance);
|
|
},
|
|
|
|
timeWatcher: function(time) {
|
|
time = time || 2000;
|
|
var finished = false;
|
|
|
|
setTimeout(function() {
|
|
if (!finished) {
|
|
finished = true;
|
|
ok(false, 'finishes in ' + time + 'ms');
|
|
start();
|
|
}
|
|
}, time);
|
|
|
|
return {
|
|
done: function() {
|
|
if (!finished) {
|
|
finished = true;
|
|
start();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
};
|
|
|
|
})();
|
|
|