Last active
January 4, 2016 08:49
-
-
Save tlimpanont/8597956 to your computer and use it in GitHub Desktop.
TEIViewer Development Source code preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(OpenLayers, NA, jQuery) { | |
/** | |
* TEIMap draws NA.TranscriptionHotspotLayer and NA.TranscriptionScanLayer on the map surface. The map settings (resolution, view bounds, max zoomlevel) depend on the scan graphic width and height. | |
* @constructor | |
* @augments OpenLayers.Map | |
*/ | |
NA.TEIMap = OpenLayers.Class(OpenLayers.Map, { | |
/** | |
* @constructs NA.TEIMap | |
* @param {Object} surface Surface object contains information about graphic and the related zones. | |
*/ | |
initialize: function(map_id) { | |
var self = this; | |
var navigation_option = { | |
dragPanOptions: { | |
enableKinetic: true, | |
interval: 0 | |
}, | |
documentDrag: true, | |
clickOptions: { | |
tap: true | |
} | |
}; | |
/** | |
* optimize for touch devices when we add TouchNavigation to the map control | |
*/ | |
var navigation_control = (Utilities.Browser.isTouch()) ? new OpenLayers.Control.TouchNavigation(navigation_option) | |
: new OpenLayers.Control.Navigation(navigation_option); | |
OpenLayers.Map.prototype.initialize.apply(this, [{ | |
div: map_id, | |
controls: [navigation_control] | |
}]); | |
this.$map = jQuery("#"+map_id); | |
this.$el = this.$map; | |
this.$viewport = this.$map.find(".olMapViewport"); | |
this.$container = this.$viewport.find("div:first"); | |
/** | |
* remove GPU hardware support. olTileImage class has to be removed from the dom, when we want to desiable transformation calculation. | |
* Chrome does not display the scanlayer when back-visibility is turned on | |
*/ | |
this.events.register("move", this, function(e) { | |
if(Utilities.BrowserDetect.browser == "Chrome") | |
jQuery("img").removeClass("olTileImage"); | |
}); | |
this.events.register("addlayer", this, function(e) { | |
if(Utilities.BrowserDetect.browser == "Chrome") | |
jQuery("img").removeClass("olTileImage"); | |
}); | |
} | |
}); | |
})(OpenLayers, NA, jQuery); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(OpenLayers, NA, jQuery) { | |
/** | |
* @class | |
* @classdesc Responsible for loading xml and convert it to JSON. It is a global dataprovider for all the TEIViewer related classes | |
*/ | |
NA.TEIXmlReader = function() { | |
this.xml = null; | |
this.json = null; | |
this.facsimiles = null; | |
this.source = null; | |
/** | |
* Call when reader has successfully loaded the xml | |
* @param {OpenLayers.Request.XMLHttpRequest} request | |
*/ | |
this.xml_loaded = function(responseXML) { | |
this.xml = responseXML; | |
this.$xml = $(this.xml); | |
this.json = Utilities.xmlToJSON(responseXML); | |
this.facsimiles = jQuery.makeArray(this.json.TEI.facsimile); | |
this.facsimile = this.json.TEI.facsimile; | |
NA.TEIXmlReader.prototype.instance = this; | |
} | |
}; | |
/** | |
* NA.TEIXmlReader singleton. After the XML is completely loaded, this singleton is available everywhere in the application. | |
* @public | |
* @static | |
*/ | |
NA.TEIXmlReader.prototype.instance = null; | |
/** | |
* OpenLayers.Request.GET does not work in IE10, can't get responseXML object, this property is ignored by the unit-test | |
* @extends OpenLayers.Request | |
*/ | |
NA.TEIXmlReader.prototype.parent = OpenLayers.Request; | |
/** | |
* @borrows NA.TEIXmlReader.prototype.GET as jQuery.ajax | |
*/ | |
NA.TEIXmlReader.prototype.GET = function(config) { | |
/** | |
* fallback use cross browser XMLHTTPRequest implementation of jQuery, HTTPRequest of OpenLayers doesn't work in IE browsers | |
*/ | |
jQuery.ajax(config); | |
} | |
})(OpenLayers, NA, jQuery); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment