Fix double-tap to open study (#20)
This commit is contained in:
1 parent
6f23c7163a
commit
c0fe9fff50
8 files changed
+65
-149
No files matched your search
@@ -0,0 +1,33 @@
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery', 'hammerjs'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
factory(require('jquery'), require('hammerjs'));
|
||||
} else {
|
||||
factory(jQuery, Hammer);
|
||||
}
|
||||
}(function($, Hammer) {
|
||||
function hammerify(el, options) {
|
||||
var $el = $(el);
|
||||
if(!$el.data("hammer")) {
|
||||
$el.data("hammer", new Hammer($el[0], options));
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.hammer = function(options) {
|
||||
return this.each(function() {
|
||||
hammerify(this, options);
|
||||
});
|
||||
};
|
||||
|
||||
// extend the emit method to also trigger jQuery events
|
||||
Hammer.Manager.prototype.emit = (function(originalEmit) {
|
||||
return function(type, data) {
|
||||
originalEmit.call(this, type, data);
|
||||
$(this.element).trigger({
|
||||
type: type,
|
||||
gesture: data
|
||||
});
|
||||
};
|
||||
})(Hammer.Manager.prototype.emit);
|
||||
}));
|
||||
@@ -1,77 +0,0 @@
|
||||
(function($, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// This object manages a collection of measurements
|
||||
function MeasurementManager() {
|
||||
// Define some basic validator functions (everything is always valid)
|
||||
this.singleMeasurementValidator = function() {
|
||||
return {isValid: true};
|
||||
};
|
||||
|
||||
this.measurementSetValidator = function() {
|
||||
return {isValid: true};
|
||||
};
|
||||
|
||||
var that = this;
|
||||
that.measurements = [];
|
||||
|
||||
// adds an element as both a source and a target
|
||||
this.add = function(measurement, validateSingle, validateSet) {
|
||||
var index = that.measurements.push(measurement);
|
||||
|
||||
if (validateSingle === true) {
|
||||
measurementValid = singleMeasurementValidator(measurement);
|
||||
}
|
||||
|
||||
if (validateSet === true) {
|
||||
measurementSetValid = measurementSetValidator(measurement);
|
||||
}
|
||||
|
||||
// fire event
|
||||
var eventDetail = {
|
||||
index: index,
|
||||
measurement: measurement,
|
||||
measurementValid: measurementValid,
|
||||
measurementSetValid: measurementSetValid
|
||||
};
|
||||
|
||||
$(that).trigger('CornerstoneMeasurementAdded', eventDetail);
|
||||
};
|
||||
|
||||
this.remove = function(index) {
|
||||
var measurement = that.measurements[index];
|
||||
that.measurements.splice(index, 1);
|
||||
// fire event
|
||||
var eventDetail = {
|
||||
index: index,
|
||||
measurement: measurement
|
||||
};
|
||||
$(that).trigger('CornerstoneMeasurementRemoved', eventDetail);
|
||||
};
|
||||
|
||||
// Add set/get measurementValidator to run on each single measurement
|
||||
// (e.g. length > 10 mm, location must be 30 mm from lymph node)
|
||||
this.setSingleMeasurementValidator = function(validator) {
|
||||
this.singleMeasurementValidator = validator;
|
||||
};
|
||||
|
||||
this.getSingleMeasurementValidator = function(validator) {
|
||||
return singleMeasurementValidator;
|
||||
};
|
||||
|
||||
// Add set/get groupValidator to run on all of the measurements together
|
||||
// (e.g. the number of measurments must be <= 2)
|
||||
this.setMeasurementSetValidator = function(validator) {
|
||||
this.measurementSetValidator = validator;
|
||||
};
|
||||
|
||||
this.getMeasurementSetValidator = function(validator) {
|
||||
return measurementSetValidator;
|
||||
};
|
||||
}
|
||||
|
||||
// module/private exports
|
||||
cornerstoneTools.MeasurementManager = new MeasurementManager();
|
||||
|
||||
})($, cornerstoneTools);
|
||||
@@ -1,57 +0,0 @@
|
||||
// Example usage for something like RECIST
|
||||
var tumourLengthMeasurementManager = cornerstoneTools.MeasurementManager;
|
||||
function singleValidator(measurement) {
|
||||
var result = {
|
||||
isValid: true
|
||||
};
|
||||
if (measurement.distance < 10) {
|
||||
result.isValid = false;
|
||||
result.details = 'Measurement distance must be less than 10 mm';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function setValidator(measurements) {
|
||||
var result = {
|
||||
isValid: true
|
||||
};
|
||||
if (measurements.length > 2) {
|
||||
result.isValid = false;
|
||||
result.details = 'The number of measurements per image must be less than 2';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Or a remote call
|
||||
function remoteSetValidator(measurements) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
var result = {
|
||||
isValid: true,
|
||||
promise: deferred.promise()
|
||||
};
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
var response = JSON.parse(xhr.response);
|
||||
if (response.isValid) {
|
||||
deferred.resolve(xhr.responseText);
|
||||
} else {
|
||||
deferred.reject(xhr.responseText);
|
||||
}
|
||||
} else {
|
||||
// The request didn't succeed
|
||||
deferred.reject(xhr.responseText);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.open("POST", "/urlToValidateRECIST", true);
|
||||
xhr.send(measurements);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
tumourLengthMeasurementManager.setSingleMeasurementValidator(singleValidator);
|
||||
tumourLengthMeasurementManager.setMeasurementSetValidator(setValidator);
|
||||
Reference in new issue
Block a user