comparison client/digitallibrary/jquery/jquery.digilib.js @ 652:01557c5e0682 jquery

added guessing of scalerBaseUrl
author robcast
date Thu, 20 Jan 2011 20:15:45 +0100
parents 694bdb86cbad
children b21c1a539af3
comparison
equal deleted inserted replaced
651:694bdb86cbad 652:01557c5e0682
143 img : "sep.png" 143 img : "sep.png"
144 } 144 }
145 }; 145 };
146 146
147 var defaults = { 147 var defaults = {
148 // the root digilib element, for easy retrieval
149 'digilibRoot' : null,
150 // version of this script 148 // version of this script
151 'version' : 'jquery.digilib.js 0.9', 149 'version' : 'jquery.digilib.js 0.9',
152 // logo url 150 // logo url
153 'logoUrl' : '../img/digilib-logo-text1.png', 151 'logoUrl' : '../img/digilib-logo-text1.png',
154 // homepage url (behind logo) 152 // homepage url (behind logo)
155 'homeUrl' : 'http://digilib.berlios.de', 153 'homeUrl' : 'http://digilib.berlios.de',
156 // base URL to Scaler servlet 154 // base URL to Scaler servlet
157 'scalerBaseUrl' : 'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler', 155 'scalerBaseUrl' : null,
158 // list of Scaler parameters 156 // list of Scaler parameters
159 'scalerParamNames' : ['fn','pn','dw','dh','ww','wh','wx','wy','ws','mo', 157 'scalerParamNames' : ['fn','pn','dw','dh','ww','wh','wx','wy','ws','mo',
160 'rot','cont','brgt','rgbm','rgba','ddpi','ddpix','ddpiy'], 158 'rot','cont','brgt','rgbm','rgba','ddpi','ddpix','ddpiy'],
161 // Scaler parameter defaults 159 // Scaler parameter defaults
162 'pn' : 1, 160 'pn' : 1,
185 'interactionMode' : 'fullscreen', 183 'interactionMode' : 'fullscreen',
186 // buttons 184 // buttons
187 'buttons' : buttons, 185 'buttons' : buttons,
188 // path to button images (must end with a slash) 186 // path to button images (must end with a slash)
189 'buttonsImagePath' : '../greyskin/', 187 'buttonsImagePath' : '../greyskin/',
190 // buttons groups 188 // button groups
191 //'buttonsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"], 189 //'buttonsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"],
192 'buttonsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","mark","delmark","back","fwd","page","bird","SEP","help","reset","options"], 190 'buttonsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","mark","delmark","back","fwd","page","bird","SEP","help","reset","options"],
193 'buttonsSpecial' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"], 191 'buttonsSpecial' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"],
194 'buttonsCustom' : [], 192 'buttonsCustom' : [],
195 // is birdView shown? 193 // is birdView shown?
213 var settings = $.extend({}, defaults, options); 211 var settings = $.extend({}, defaults, options);
214 var isFullscreen = settings.interactionMode === 'fullscreen'; 212 var isFullscreen = settings.interactionMode === 'fullscreen';
215 var queryParams = {}; 213 var queryParams = {};
216 if (isFullscreen) { 214 if (isFullscreen) {
217 queryParams = parseQueryParams(); 215 queryParams = parseQueryParams();
216 // check scalerBaseUrl
217 if (settings.scalerBaseUrl == null) {
218 // try the host this came from
219 var h = window.location.host;
220 if (window.location.host) {
221 var url = window.location.href;
222 // assume the page lives in [webapp]/jquery/
223 var pos = url.indexOf('jquery/');
224 if (pos > 0) {
225 settings.scalerBaseUrl = url.substring(0, pos) + 'servlet/Scaler';
226 }
227 }
228 }
218 } 229 }
219 return this.each(function() { 230 return this.each(function() {
220 var $elem = $(this); 231 var $elem = $(this);
221 var data = $elem.data('digilib'); 232 var data = $elem.data('digilib');
222 var elemSettings; 233 var elemSettings;
395 return paramString; 406 return paramString;
396 }; 407 };
397 408
398 // returns URL and query string for Scaler 409 // returns URL and query string for Scaler
399 var getScalerUrl = function (data) { 410 var getScalerUrl = function (data) {
411 if (settings.scalerBaseUrl == null) {
412 alert("ERROR: URL of digilib Scaler servlet missing!");
413 }
400 var settings = data.settings; 414 var settings = data.settings;
401 var keys = settings.scalerParamNames; 415 var keys = settings.scalerParamNames;
402 var queryString = getParamString(settings, keys, defaults); 416 var queryString = getParamString(settings, keys, defaults);
403 var url = settings.scalerBaseUrl + '?' + queryString; 417 var url = settings.scalerBaseUrl + '?' + queryString;
404 return url; 418 return url;