From cdc469d8fca0332f618b50735fa65cea65c83927 Mon Sep 17 00:00:00 2001 From: Jasper Staab Date: Fri, 24 Jan 2020 07:49:02 -0800 Subject: [PATCH] Load OpenSeadragon if not defined --- openseadragon-scalebar.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openseadragon-scalebar.js b/openseadragon-scalebar.js index f192db6..e387b0e 100644 --- a/openseadragon-scalebar.js +++ b/openseadragon-scalebar.js @@ -14,8 +14,14 @@ * * @author Antoine Vandecreme */ -(function($) { - +(function() { + var $ = window.OpenSeadragon; + if (!$) { + $ = require('openseadragon'); + if (!$) { + throw new Error('OpenSeadragon is missing.'); + } + } if (!$.version || $.version.major < 2) { throw new Error('This version of OpenSeadragonScalebar requires ' + 'OpenSeadragon version 2.0.0+'); @@ -559,4 +565,4 @@ function isDefined(variable) { return typeof (variable) !== "undefined"; } -}(OpenSeadragon)); +}());