From ea346a785dc1b3f7c156f6fc33da634e1f1a627b Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Tue, 12 Aug 2014 21:56:44 +0200 Subject: Adding jquery, flot and openlayers to be included with the GEM. --- misc/openlayers/lib/OpenLayers/Handler.js | 325 ++++++++++++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 misc/openlayers/lib/OpenLayers/Handler.js (limited to 'misc/openlayers/lib/OpenLayers/Handler.js') diff --git a/misc/openlayers/lib/OpenLayers/Handler.js b/misc/openlayers/lib/OpenLayers/Handler.js new file mode 100644 index 0000000..0fef88e --- /dev/null +++ b/misc/openlayers/lib/OpenLayers/Handler.js @@ -0,0 +1,325 @@ +/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for + * full list of contributors). Published under the 2-clause BSD license. + * See license.txt in the OpenLayers distribution or repository for the + * full text of the license. */ + +/** + * @requires OpenLayers/BaseTypes/Class.js + * @requires OpenLayers/Events.js + */ + +/** + * Class: OpenLayers.Handler + * Base class to construct a higher-level handler for event sequences. All + * handlers have activate and deactivate methods. In addition, they have + * methods named like browser events. When a handler is activated, any + * additional methods named like a browser event is registered as a + * listener for the corresponding event. When a handler is deactivated, + * those same methods are unregistered as event listeners. + * + * Handlers also typically have a callbacks object with keys named like + * the abstracted events or event sequences that they are in charge of + * handling. The controls that wrap handlers define the methods that + * correspond to these abstract events - so instead of listening for + * individual browser events, they only listen for the abstract events + * defined by the handler. + * + * Handlers are created by controls, which ultimately have the responsibility + * of making changes to the the state of the application. Handlers + * themselves may make temporary changes, but in general are expected to + * return the application in the same state that they found it. + */ +OpenLayers.Handler = OpenLayers.Class({ + + /** + * Property: id + * {String} + */ + id: null, + + /** + * APIProperty: control + * {}. The control that initialized this handler. The + * control is assumed to have a valid map property - that map is used + * in the handler's own setMap method. + */ + control: null, + + /** + * Property: map + * {} + */ + map: null, + + /** + * APIProperty: keyMask + * {Integer} Use bitwise operators and one or more of the OpenLayers.Handler + * constants to construct a keyMask. The keyMask is used by + * . If the keyMask matches the combination of keys + * down on an event, checkModifiers returns true. + * + * Example: + * (code) + * // handler only responds if the Shift key is down + * handler.keyMask = OpenLayers.Handler.MOD_SHIFT; + * + * // handler only responds if Ctrl-Shift is down + * handler.keyMask = OpenLayers.Handler.MOD_SHIFT | + * OpenLayers.Handler.MOD_CTRL; + * (end) + */ + keyMask: null, + + /** + * Property: active + * {Boolean} + */ + active: false, + + /** + * Property: evt + * {Event} This property references the last event handled by the handler. + * Note that this property is not part of the stable API. Use of the + * evt property should be restricted to controls in the library + * or other applications that are willing to update with changes to + * the OpenLayers code. + */ + evt: null, + + /** + * Property: touch + * {Boolean} Indicates the support of touch events. When touch events are + * started touch will be true and all mouse related listeners will do + * nothing. + */ + touch: false, + + /** + * Constructor: OpenLayers.Handler + * Construct a handler. + * + * Parameters: + * control - {} The control that initialized this + * handler. The control is assumed to have a valid map property; that + * map is used in the handler's own setMap method. If a map property + * is present in the options argument it will be used instead. + * callbacks - {Object} An object whose properties correspond to abstracted + * events or sequences of browser events. The values for these + * properties are functions defined by the control that get called by + * the handler. + * options - {Object} An optional object whose properties will be set on + * the handler. + */ + initialize: function(control, callbacks, options) { + OpenLayers.Util.extend(this, options); + this.control = control; + this.callbacks = callbacks; + + var map = this.map || control.map; + if (map) { + this.setMap(map); + } + + this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); + }, + + /** + * Method: setMap + */ + setMap: function (map) { + this.map = map; + }, + + /** + * Method: checkModifiers + * Check the keyMask on the handler. If no is set, this always + * returns true. If a is set and it matches the combination + * of keys down on an event, this returns true. + * + * Returns: + * {Boolean} The keyMask matches the keys down on an event. + */ + checkModifiers: function (evt) { + if(this.keyMask == null) { + return true; + } + /* calculate the keyboard modifier mask for this event */ + var keyModifiers = + (evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) | + (evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) | + (evt.altKey ? OpenLayers.Handler.MOD_ALT : 0) | + (evt.metaKey ? OpenLayers.Handler.MOD_META : 0); + + /* if it differs from the handler object's key mask, + bail out of the event handler */ + return (keyModifiers == this.keyMask); + }, + + /** + * APIMethod: activate + * Turn on the handler. Returns false if the handler was already active. + * + * Returns: + * {Boolean} The handler was activated. + */ + activate: function() { + if(this.active) { + return false; + } + // register for event handlers defined on this class. + var events = OpenLayers.Events.prototype.BROWSER_EVENTS; + for (var i=0, len=events.length; i will be + * true and all mouse related listeners will do nothing. + */ + startTouch: function() { + if (!this.touch) { + this.touch = true; + var events = [ + "mousedown", "mouseup", "mousemove", "click", "dblclick", + "mouseout" + ]; + for (var i=0, len=events.length; i, returns false if any key is down. + */ +OpenLayers.Handler.MOD_NONE = 0; + +/** + * Constant: OpenLayers.Handler.MOD_SHIFT + * If set as the , returns false if Shift is down. + */ +OpenLayers.Handler.MOD_SHIFT = 1; + +/** + * Constant: OpenLayers.Handler.MOD_CTRL + * If set as the , returns false if Ctrl is down. + */ +OpenLayers.Handler.MOD_CTRL = 2; + +/** + * Constant: OpenLayers.Handler.MOD_ALT + * If set as the , returns false if Alt is down. + */ +OpenLayers.Handler.MOD_ALT = 4; + +/** + * Constant: OpenLayers.Handler.MOD_META + * If set as the , returns false if Cmd is down. + */ +OpenLayers.Handler.MOD_META = 8; + + -- cgit v1.2.3