mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
removed notes in preparation for new build
This commit is contained in:
parent
e21026d892
commit
95cd02ac40
@ -1,246 +1,49 @@
|
|||||||
|
// (c) 2011 Christopher Thatcher
|
||||||
// (c) 2010 OpenSeadragon, (c) 2010 CodePlex Foundation
|
// (c) 2010 OpenSeadragon, (c) 2010 CodePlex Foundation
|
||||||
//Start Thatcher - general changes include adding ; where best practice
|
// @NEWBSD@
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - .add was only used once
|
|
||||||
//Array.prototype.add = function(array, item) {
|
|
||||||
// array[array.length] = item;
|
|
||||||
//};
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - .clear is never used in this code base
|
|
||||||
//Array.prototype.clear = function(array) {
|
|
||||||
// array.length = 0;
|
|
||||||
//};
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - .clone is only used once
|
|
||||||
//Array.prototype.clone = function(array) {
|
|
||||||
// return array.length === 1 ? [array[0]] : Array.apply(null, array);
|
|
||||||
//};
|
|
||||||
//SArray = Array();
|
|
||||||
//Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - This is silly, Function is defined
|
|
||||||
//if (!window.Function) {
|
|
||||||
// window.Function = {};
|
|
||||||
//}
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - moved into Seadragon namespace
|
|
||||||
//Function.prototype.delegate = function(object, method) {
|
|
||||||
// return function() {
|
|
||||||
// if (arguments === undefined)
|
|
||||||
// arguments = [];
|
|
||||||
// return method.apply(object, arguments);
|
|
||||||
// };
|
|
||||||
//}
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - This is also silly and has terrible side effects
|
|
||||||
//function String() {
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - moved into Seadragon namespace
|
|
||||||
/*
|
|
||||||
String.format = function(format, args) {
|
|
||||||
return String._toFormattedString(false, arguments);
|
|
||||||
}
|
|
||||||
String._toFormattedString = function(useLocale, args) {
|
|
||||||
var result = '';
|
|
||||||
var format = args[0];
|
|
||||||
|
|
||||||
for (var i = 0; ; ) {
|
|
||||||
var open = format.indexOf('{', i);
|
|
||||||
var close = format.indexOf('}', i);
|
|
||||||
if ((open < 0) && (close < 0)) {
|
|
||||||
result += format.slice(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((close > 0) && ((close < open) || (open < 0))) {
|
|
||||||
if (format.charAt(close + 1) !== '}') {
|
|
||||||
throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
|
|
||||||
}
|
|
||||||
result += format.slice(i, close + 1);
|
|
||||||
i = close + 2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
result += format.slice(i, open);
|
|
||||||
i = open + 1;
|
|
||||||
|
|
||||||
if (format.charAt(i) === '{') {
|
|
||||||
result += '{';
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (close < 0) throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
|
|
||||||
|
|
||||||
|
|
||||||
var brace = format.substring(i, close);
|
|
||||||
var colonIndex = brace.indexOf(':');
|
|
||||||
var argNumber = parseInt((colonIndex < 0) ? brace : brace.substring(0, colonIndex), 10) + 1;
|
|
||||||
if (isNaN(argNumber)) throw Error.argument('format', Sys.Res.stringFormatInvalid);
|
|
||||||
var argFormat = (colonIndex < 0) ? '' : brace.substring(colonIndex + 1);
|
|
||||||
|
|
||||||
var arg = args[argNumber];
|
|
||||||
if (typeof (arg) === "undefined" || arg === null) {
|
|
||||||
arg = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg.toFormattedString) {
|
|
||||||
result += arg.toFormattedString(argFormat);
|
|
||||||
}
|
|
||||||
else if (useLocale && arg.localeFormat) {
|
|
||||||
result += arg.localeFormat(argFormat);
|
|
||||||
}
|
|
||||||
else if (arg.format) {
|
|
||||||
result += arg.format(argFormat);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
result += arg.toString();
|
|
||||||
|
|
||||||
i = close + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - Observer is only used twice and always uses the following
|
|
||||||
// - call "this._observer._getContext(this, true).events;"
|
|
||||||
// - To start I'm just making 'events' a member variable that
|
|
||||||
// - is an instance of EventHandlerList
|
|
||||||
/*
|
|
||||||
function Observer() { }
|
|
||||||
Observer.prototype = {
|
|
||||||
_getContext: function(obj, create) {
|
|
||||||
var ctx = obj._observerContext;
|
|
||||||
if (ctx) return ctx();
|
|
||||||
if (create) {
|
|
||||||
return (obj._observerContext = this._createContext())();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
_createContext: function() {
|
|
||||||
var ctx = {
|
|
||||||
events: new EventHandlerList()
|
|
||||||
};
|
|
||||||
return function() {
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - Adding singular global namespace declaration and closure
|
|
||||||
Seadragon = function(){};
|
Seadragon = function(){};
|
||||||
(function($){
|
(function($){
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
var EventHandlerList = function EventHandlerList() {
|
var EventHandlerList = function EventHandlerList() {
|
||||||
this._list = {};
|
this._list = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
EventHandlerList.prototype = {
|
EventHandlerList.prototype = {
|
||||||
//Start Thatcher - unneccessary indirection, just use addHandler
|
|
||||||
//_addHandler: function(id, handler) {
|
|
||||||
//Start Thatcher
|
|
||||||
//SArray.add(this._getEvent(id, true), handler);
|
|
||||||
// var events = this._getEvent(id, true);
|
|
||||||
// events[events.length] = handler;
|
|
||||||
//End Thatcher
|
|
||||||
//},
|
|
||||||
//End Thatcher
|
|
||||||
addHandler: function(id, handler) {
|
|
||||||
//Start Thatcher - unneccessary indirection
|
|
||||||
//this._addHandler(id, handler);
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - removing indirection
|
addHandler: function(id, handler) {
|
||||||
//var events = this._getEvent(id, true);
|
|
||||||
var events = this._list[ id ];
|
var events = this._list[ id ];
|
||||||
if( !events ){
|
if( !events ){
|
||||||
this._list[ id ] = events = [];
|
this._list[ id ] = events = [];
|
||||||
}
|
}
|
||||||
//End Thatcher
|
|
||||||
events[events.length] = handler;
|
events[events.length] = handler;
|
||||||
},
|
},
|
||||||
//Start Thatcher - unneccessary indirection, just use _removeHandler
|
|
||||||
//_removeHandler: function(id, handler) {
|
|
||||||
// var evt = this._getEvent(id);
|
|
||||||
// if (!evt) return;
|
|
||||||
//Start Thatcher - SArray.remove is not defined anywhere in this code base
|
|
||||||
// - and is not a natural function of the Array.prototype!
|
|
||||||
//SArray.remove(evt, handler);
|
|
||||||
//End Thatcher
|
|
||||||
//},
|
|
||||||
//EndThatcher
|
|
||||||
//Start Thatcher - _removeHandlers is not used in the entire codebase
|
|
||||||
//_removeHandlers: function(id) {
|
|
||||||
// if (!id) {
|
|
||||||
// this._list = {};
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// var evt = this._getEvent(id);
|
|
||||||
// if (!evt) return;
|
|
||||||
// evt.length = 0;
|
|
||||||
// }
|
|
||||||
//},
|
|
||||||
//End Thatcher
|
|
||||||
removeHandler: function(id, handler) {
|
removeHandler: function(id, handler) {
|
||||||
//Start Thatcher - unneccessary indirection. Also, because events were
|
//Start Thatcher - unneccessary indirection. Also, because events were
|
||||||
// - not actually being removed, we need to add the code
|
// - not actually being removed, we need to add the code
|
||||||
// - to do the removal ourselves. TODO
|
// - to do the removal ourselves. TODO
|
||||||
//this._removeHandler(id, handler);
|
|
||||||
var evt = this._list[ id ];
|
var evt = this._list[ id ];
|
||||||
if (!evt) return;
|
if (!evt) return;
|
||||||
//End Thatcher
|
//End Thatcher
|
||||||
},
|
},
|
||||||
getHandler: function(id) {
|
getHandler: function(id) {
|
||||||
//Start Thatcher - remove indirection
|
var evt = this._list[ id ];
|
||||||
//var evt = this._getEvent(id);
|
|
||||||
var evt = this._list[ id ] || [];
|
|
||||||
//End Thatcher
|
|
||||||
if (!evt || !evt.length) return null;
|
if (!evt || !evt.length) return null;
|
||||||
//Start Thatcher - .clone only used once in entire codebase so just do it
|
|
||||||
//evt = SArray.clone(evt);
|
|
||||||
evt = evt.length === 1 ?
|
evt = evt.length === 1 ?
|
||||||
[evt[0]] :
|
[evt[0]] :
|
||||||
Array.apply( null, evt );
|
Array.apply( null, evt );
|
||||||
//End Thatcher
|
|
||||||
return function(source, args) {
|
return function(source, args) {
|
||||||
for (var i = 0, l = evt.length; i < l; i++) {
|
for (var i = 0, l = evt.length; i < l; i++) {
|
||||||
evt[i](source, args);
|
evt[i](source, args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//Start Thatcher - removing indirection
|
|
||||||
//,
|
|
||||||
//_getEvent: function(id, create) {
|
|
||||||
// var e = this._list[id];
|
|
||||||
// if (!e) {
|
|
||||||
// if (!create) return null;
|
|
||||||
// this._list[id] = e = [];
|
|
||||||
// }
|
|
||||||
// return e;
|
|
||||||
//}
|
|
||||||
//End Thatcher
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Start Thatcher - Created a global declaration with closure
|
|
||||||
//var Seadragon = new function() {
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - Moved this function into closure namespace, more importantly
|
|
||||||
// - avoids polluting built in Function
|
|
||||||
function delegate(object, method) {
|
function delegate(object, method) {
|
||||||
return function() {
|
return function() {
|
||||||
if (arguments === undefined)
|
if (arguments === undefined)
|
||||||
@ -248,19 +51,11 @@ function delegate(object, method) {
|
|||||||
return method.apply(object, arguments);
|
return method.apply(object, arguments);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
//Start Thatcher - Moved this function into closure namespace, more importantly
|
|
||||||
// - avoids polluting built in String. Also removed indirection.
|
|
||||||
//var format = function(format, args) {
|
|
||||||
// return $._toFormattedString(false, arguments);
|
|
||||||
//};
|
|
||||||
//$._toFormattedString = function(useLocale, args) {
|
|
||||||
function format(){
|
function format(){
|
||||||
//Start Thatcher - removeing indirection
|
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
useLocale = false;
|
useLocale = false;
|
||||||
//End Thatcher
|
|
||||||
var result = '';
|
var result = '';
|
||||||
var format = args[0];
|
var format = args[0];
|
||||||
|
|
||||||
@ -273,10 +68,7 @@ function format(){
|
|||||||
}
|
}
|
||||||
if ((close > 0) && ((close < open) || (open < 0))) {
|
if ((close > 0) && ((close < open) || (open < 0))) {
|
||||||
if (format.charAt(close + 1) !== '}') {
|
if (format.charAt(close + 1) !== '}') {
|
||||||
//Start Thatcher - There is no Sys object or Error.argument
|
|
||||||
//throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
|
|
||||||
throw Error('SeadragonError: Formatted String Brace Mismatch. \n' + format );
|
throw Error('SeadragonError: Formatted String Brace Mismatch. \n' + format );
|
||||||
//End Thatcher
|
|
||||||
}
|
}
|
||||||
result += format.slice(i, close + 1);
|
result += format.slice(i, close + 1);
|
||||||
i = close + 2;
|
i = close + 2;
|
||||||
@ -292,23 +84,18 @@ function format(){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start Thatcher - No Sys object or Error.argument
|
|
||||||
//if (close < 0) throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
|
|
||||||
if (close < 0) {
|
if (close < 0) {
|
||||||
throw Error('SeadragonError: Formatted String Brace Mismatch. \n' + format );
|
throw Error('SeadragonError: Formatted String Brace Mismatch. \n' + format );
|
||||||
}
|
}
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
|
|
||||||
var brace = format.substring(i, close);
|
var brace = format.substring(i, close);
|
||||||
var colonIndex = brace.indexOf(':');
|
var colonIndex = brace.indexOf(':');
|
||||||
var argNumber = parseInt((colonIndex < 0) ? brace : brace.substring(0, colonIndex), 10) + 1;
|
var argNumber = parseInt((colonIndex < 0) ? brace : brace.substring(0, colonIndex), 10) + 1;
|
||||||
//Start Thatcher - No Sys object or Error,argument
|
|
||||||
//if (isNaN(argNumber)) throw Error.argument('format', Sys.Res.stringFormatInvalid);
|
|
||||||
if( isNaN( argNumber ) ){
|
if( isNaN( argNumber ) ){
|
||||||
throw Error('SeadragonError: Invalid Format String\n' + format );
|
throw Error('SeadragonError: Invalid Format String\n' + format );
|
||||||
}
|
}
|
||||||
//End Thatcher
|
|
||||||
var argFormat = (colonIndex < 0) ? '' : brace.substring(colonIndex + 1);
|
var argFormat = (colonIndex < 0) ? '' : brace.substring(colonIndex + 1);
|
||||||
|
|
||||||
var arg = args[argNumber];
|
var arg = args[argNumber];
|
||||||
@ -333,13 +120,8 @@ function format(){
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
|
|
||||||
//Start Thatcher - Notes for refactoring Utils
|
|
||||||
// * Use .prototype pattern
|
|
||||||
// * Provide closure
|
|
||||||
//End Thatcher
|
|
||||||
$.Utils = function() {
|
$.Utils = function() {
|
||||||
|
|
||||||
|
|
||||||
@ -1344,7 +1126,7 @@ $.NavControl.prototype = {
|
|||||||
var onFullPageHandler = delegate(this, this._onFullPage);
|
var onFullPageHandler = delegate(this, this._onFullPage);
|
||||||
|
|
||||||
var navImages = this._viewer.config.navImages;
|
var navImages = this._viewer.config.navImages;
|
||||||
//Start Thatcher - reformatted for readability
|
|
||||||
var zoomIn = new $.Button({
|
var zoomIn = new $.Button({
|
||||||
config: this._viewer.config,
|
config: this._viewer.config,
|
||||||
tooltip: $.Strings.getString("Tooltips.ZoomIn"),
|
tooltip: $.Strings.getString("Tooltips.ZoomIn"),
|
||||||
@ -1397,16 +1179,12 @@ $.NavControl.prototype = {
|
|||||||
config: this._viewer.config,
|
config: this._viewer.config,
|
||||||
buttons: [zoomIn, zoomOut, goHome, fullPage]
|
buttons: [zoomIn, zoomOut, goHome, fullPage]
|
||||||
});
|
});
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
this.elmt = this._group.get_element();
|
this.elmt = this._group.get_element();
|
||||||
this.elmt[SIGNAL] = true; // hack to get our controls to fade
|
this.elmt[SIGNAL] = true; // hack to get our controls to fade
|
||||||
this._viewer.add_open(delegate(this, this._lightUp));
|
this._viewer.add_open(delegate(this, this._lightUp));
|
||||||
},
|
},
|
||||||
//Start Thatcher - never called internally
|
|
||||||
//dispose: function() {
|
|
||||||
//},
|
|
||||||
//End Thatcher
|
|
||||||
get_events: function() {
|
get_events: function() {
|
||||||
return this._events;
|
return this._events;
|
||||||
},
|
},
|
||||||
@ -1556,10 +1334,7 @@ $.Viewer = function(element, xmlPath, prefixUrl, controls, overlays, overlayCont
|
|||||||
$.Viewer.prototype = {
|
$.Viewer.prototype = {
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
|
||||||
//Start Thatcher - Observer pattern is over abstracted
|
|
||||||
//this._observer = new Observer();
|
|
||||||
this._events = new EventHandlerList();
|
this._events = new EventHandlerList();
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
this._container = $.Utils.makeNeutralElement("div");
|
this._container = $.Utils.makeNeutralElement("div");
|
||||||
this._canvas = $.Utils.makeNeutralElement("div");
|
this._canvas = $.Utils.makeNeutralElement("div");
|
||||||
@ -1642,10 +1417,7 @@ $.Viewer.prototype = {
|
|||||||
this.openDzi(this._xmlPath);
|
this.openDzi(this._xmlPath);
|
||||||
},
|
},
|
||||||
get_events: function get_events() {
|
get_events: function get_events() {
|
||||||
//Start Thatcher - Removing Observer pattern
|
|
||||||
//return this._observer._getContext(this, true).events;
|
|
||||||
return this._events;
|
return this._events;
|
||||||
//End Thatcher
|
|
||||||
},
|
},
|
||||||
_raiseEvent: function (eventName, eventArgs) {
|
_raiseEvent: function (eventName, eventArgs) {
|
||||||
var handler = this.get_events().getHandler(eventName);
|
var handler = this.get_events().getHandler(eventName);
|
||||||
@ -2937,10 +2709,7 @@ $.Button = function(properties, events) {
|
|||||||
$.Button.prototype = {
|
$.Button.prototype = {
|
||||||
initialize: function(events) {
|
initialize: function(events) {
|
||||||
|
|
||||||
//Start Thatcher - Observer pattern is over abstracted
|
|
||||||
//this._observer = new Observer();
|
|
||||||
this._events = new EventHandlerList();
|
this._events = new EventHandlerList();
|
||||||
//End Thatcher
|
|
||||||
|
|
||||||
if (events.onPress != undefined)
|
if (events.onPress != undefined)
|
||||||
this.add_onPress(events.onPress);
|
this.add_onPress(events.onPress);
|
||||||
@ -2999,10 +2768,6 @@ $.Button.prototype = {
|
|||||||
this._tracker.setTracking(true);
|
this._tracker.setTracking(true);
|
||||||
this._outTo($.ButtonState.REST);
|
this._outTo($.ButtonState.REST);
|
||||||
},
|
},
|
||||||
//Start Thatcher - never called internally
|
|
||||||
//dispose: function() {
|
|
||||||
//},
|
|
||||||
//End Thatcher
|
|
||||||
_scheduleFade: function() {
|
_scheduleFade: function() {
|
||||||
window.setTimeout(delegate(this, this._updateFade), 20);
|
window.setTimeout(delegate(this, this._updateFade), 20);
|
||||||
},
|
},
|
||||||
@ -3096,10 +2861,7 @@ $.Button.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
get_events: function get_events() {
|
get_events: function get_events() {
|
||||||
//Start Thatcher - Removing Observer pattern
|
|
||||||
//return this._observer._getContext(this, true).events;
|
|
||||||
return this._events;
|
return this._events;
|
||||||
//End Thatcher
|
|
||||||
},
|
},
|
||||||
_raiseEvent: function(eventName, eventArgs) {
|
_raiseEvent: function(eventName, eventArgs) {
|
||||||
var handler = this.get_events().getHandler(eventName);
|
var handler = this.get_events().getHandler(eventName);
|
||||||
@ -3215,10 +2977,7 @@ $.ButtonGroup.prototype = {
|
|||||||
|
|
||||||
tracker.setTracking(true);
|
tracker.setTracking(true);
|
||||||
},
|
},
|
||||||
//Start Thatcher - never called internally
|
|
||||||
//dispose: function() {
|
|
||||||
//},
|
|
||||||
//End Thatcher
|
|
||||||
get_buttons: function() {
|
get_buttons: function() {
|
||||||
return this._buttons;
|
return this._buttons;
|
||||||
},
|
},
|
||||||
@ -3477,10 +3236,6 @@ $.Tile = function(level, x, y, bounds, exists, url) {
|
|||||||
}
|
}
|
||||||
$.Tile.prototype = {
|
$.Tile.prototype = {
|
||||||
|
|
||||||
//Start Thatcher - never called internally
|
|
||||||
//dispose: function() {
|
|
||||||
//},
|
|
||||||
//End Thatcher
|
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return this.level + "/" + this.x + "_" + this.y;
|
return this.level + "/" + this.x + "_" + this.y;
|
||||||
},
|
},
|
||||||
@ -3680,10 +3435,7 @@ $.Drawer = function(source, viewport, elmt) {
|
|||||||
this._init();
|
this._init();
|
||||||
}
|
}
|
||||||
$.Drawer.prototype = {
|
$.Drawer.prototype = {
|
||||||
//Start Thatcher - never called internally
|
|
||||||
//dispose: function() {
|
|
||||||
//},
|
|
||||||
//End Thatcher
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._canvas.style.width = "100%";
|
this._canvas.style.width = "100%";
|
||||||
this._canvas.style.height = "100%";
|
this._canvas.style.height = "100%";
|
||||||
@ -4481,6 +4233,4 @@ $.Viewport.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start Thatcher - Adding global closure ending
|
|
||||||
}( Seadragon ));
|
}( Seadragon ));
|
||||||
//End Thatcher
|
|
||||||
|
Loading…
Reference in New Issue
Block a user