/data/sites/web/unidosporsectorespt/htdocs/public/www/js
Edit: /data/sites/web/unidosporsectorespt/htdocs/public/www/js/jquery.panzoom.js (36915B)
/**
* @license jquery.panzoom.js v2.0.5
* Updated: Thu Jul 03 2014
* Add pan and zoom functionality to any element
* Copyright (c) 2014 timmy willison
* Released under the MIT license
* https://github.com/timmywil/jquery.panzoom/blob/master/MIT-License.txt
*/
(function(global, factory) {
// AMD
if (typeof define === 'function' && define.amd) {
define([ 'jquery' ], function(jQuery) {
return factory(global, jQuery);
});
// CommonJS/Browserify
} else if (typeof exports === 'object') {
factory(global, require('jquery'));
// Global
} else {
factory(global, global.jQuery);
}
}(typeof window !== 'undefined' ? window : this, function(window, $) {
'use strict';
// Common properties to lift for touch or pointer events
var list = 'over out down up move enter leave cancel'.split(' ');
var hook = $.extend({}, $.event.mouseHooks);
var events = {};
// Support pointer events in IE11+ if available
if ( window.PointerEvent ) {
$.each(list, function( i, name ) {
// Add event name to events property and add fixHook
$.event.fixHooks[
(events[name] = 'pointer' + name)
] = hook;
});
} else {
var mouseProps = hook.props;
// Add touch properties for the touch hook
hook.props = mouseProps.concat(['touches', 'changedTouches', 'targetTouches', 'altKey', 'ctrlKey', 'metaKey', 'shiftKey']);
/**
* Support: Android
* Android sets pageX/Y to 0 for any touch event
* Attach first touch's pageX/pageY and clientX/clientY if not set correctly
*/
hook.filter = function( event, originalEvent ) {
var touch;
var i = mouseProps.length;
if ( !originalEvent.pageX && originalEvent.touches && (touch = originalEvent.touches[0]) ) {
// Copy over all mouse properties
while(i--) {
event[mouseProps[i]] = touch[mouseProps[i]];
}
}
return event;
};
$.each(list, function( i, name ) {
// No equivalent touch events for over and out
if (i < 2) {
events[ name ] = 'mouse' + name;
} else {
var touch = 'touch' +
(name === 'down' ? 'start' : name === 'up' ? 'end' : name);
// Add fixHook
$.event.fixHooks[ touch ] = hook;
// Add event names to events property
events[ name ] = touch + ' mouse' + name;
}
});
}
$.pointertouch = events;
var document = window.document;
var datakey = '__pz__';
var slice = Array.prototype.slice;
var pointerEvents = !!window.PointerEvent;
var supportsInputEvent = (function() {
var input = document.createElement('input');
input.setAttribute('oninput', 'return');
return typeof input.oninput === 'function';
})();
// Regex
var rupper = /([A-Z])/g;
var rsvg = /^https:[\w\.\/]+svg$/;
var rinline = /^inline/;
var floating = '(\\-?[\\d\\.e]+)';
var commaSpace = '\\,?\\s*';
var rmatrix = new RegExp(
'^matrix\\(' +
floating + commaSpace +
floating + commaSpace +
floating + commaSpace +
floating + commaSpace +
floating + commaSpace +
floating + '\\)$'
);
/**
* Utility for determing transform matrix equality
* Checks backwards to test translation first
* @param {Array} first
* @param {Array} second
*/
function matrixEquals(first, second) {
var i = first.length;
while(--i) {
if (+first[i] !== +second[i]) {
return false;
}
}
return true;
}
/**
* Creates the options object for reset functions
* @param {Boolean|Object} opts See reset methods
* @returns {Object} Returns the newly-created options object
*/
function createResetOptions(opts) {
var options = { range: true, animate: true };
if (typeof opts === 'boolean') {
options.animate = opts;
} else {
$.extend(options, opts);
}
return options;
}
/**
* Represent a transformation matrix with a 3x3 matrix for calculations
* Matrix functions adapted from Louis Remi's jQuery.transform (https://github.com/louisremi/jquery.transform.js)
* @param {Array|Number} a An array of six values representing a 2d transformation matrix
*/
function Matrix(a, b, c, d, e, f, g, h, i) {
if ($.type(a) === 'array') {
this.elements = [
+a[0], +a[2], +a[4],
+a[1], +a[3], +a[5],
0, 0, 1
];
} else {
this.elements = [
a, b, c,
d, e, f,
g || 0, h || 0, i || 1
];
}
}
Matrix.prototype = {
/**
* Multiply a 3x3 matrix by a similar matrix or a vector
* @param {Matrix|Vector} matrix
* @return {Matrix|Vector} Returns a vector if multiplying by a vector
*/
x: function(matrix) {
var isVector = matrix instanceof Vector;
var a = this.elements,
b = matrix.elements;
if (isVector && b.length === 3) {
// b is actually a vector
return new Vector(
a[0] * b[0] + a[1] * b[1] + a[2] * b[2],
a[3] * b[0] + a[4] * b[1] + a[5] * b[2],
a[6] * b[0] + a[7] * b[1] + a[8] * b[2]
);
} else if (b.length === a.length) {
// b is a 3x3 matrix
return new Matrix(
a[0] * b[0] + a[1] * b[3] + a[2] * b[6],
a[0] * b[1] + a[1] * b[4] + a[2] * b[7],
a[0] * b[2] + a[1] * b[5] + a[2] * b[8],
a[3] * b[0] + a[4] * b[3] + a[5] * b[6],
a[3] * b[1] + a[4] * b[4] + a[5] * b[7],
a[3] * b[2] + a[4] * b[5] + a[5] * b[8],
a[6] * b[0] + a[7] * b[3] + a[8] * b[6],
a[6] * b[1] + a[7] * b[4] + a[8] * b[7],
a[6] * b[2] + a[7] * b[5] + a[8] * b[8]
);
}
return false; // fail
},
/**
* Generates an inverse of the current matrix
* @returns {Matrix}
*/
inverse: function() {
var d = 1 / this.determinant(),
a = this.elements;
return new Matrix(
d * ( a[8] * a[4] - a[7] * a[5]),
d * (-(a[8] * a[1] - a[7] * a[2])),
d * ( a[5] * a[1] - a[4] * a[2]),
d * (-(a[8] * a[3] - a[6] * a[5])),
d * ( a[8] * a[0] - a[6] * a[2]),
d * (-(a[5] * a[0] - a[3] * a[2])),
d * ( a[7] * a[3] - a[6] * a[4]),
d * (-(a[7] * a[0] - a[6] * a[1])),
d * ( a[4] * a[0] - a[3] * a[1])
);
},
/**
* Calculates the determinant of the current matrix
* @returns {Number}
*/
determinant: function() {
var a = this.elements;
return a[0] * (a[8] * a[4] - a[7] * a[5]) - a[3] * (a[8] * a[1] - a[7] * a[2]) + a[6] * (a[5] * a[1] - a[4] * a[2]);
}
};
/**
* Create a vector containing three values
*/
function Vector(x, y, z) {
this.elements = [ x, y, z ];
}
/**
* Get the element at zero-indexed index i
* @param {Number} i
*/
Vector.prototype.e = Matrix.prototype.e = function(i) {
return this.elements[ i ];
};
/**
* Create a Panzoom object for a given element
* @constructor
* @param {Element} elem - Element to use pan and zoom
* @param {Object} [options] - An object literal containing options to override default options
* (See Panzoom.defaults for ones not listed below)
* @param {jQuery} [options.$zoomIn] - zoom in buttons/links collection (you can also bind these yourself
* e.g. $button.on('click', function(e) { e.preventDefault(); $elem.panzoom('zoomIn'); });)
* @param {jQuery} [options.$zoomOut] - zoom out buttons/links collection on which to bind zoomOut
* @param {jQuery} [options.$zoomRange] - zoom in/out with this range control
* @param {jQuery} [options.$reset] - Reset buttons/links collection on which to bind the reset method
* @param {Function} [options.on[Start|Change|Zoom|Pan|End|Reset] - Optional callbacks for panzoom events
*/
function Panzoom(elem, options) {
// Allow instantiation without `new` keyword
if (!(this instanceof Panzoom)) {
return new Panzoom(elem, options);
}
// Sanity checks
if (elem.nodeType !== 1) {
$.error('Panzoom called on non-Element node');
}
if (!$.contains(document, elem)) {
$.error('Panzoom element must be attached to the document');
}
// Don't remake
var d = $.data(elem, datakey);
if (d) {
return d;
}
// Extend default with given object literal
// Each instance gets its own options
this.options = options = $.extend({}, Panzoom.defaults, options);
this.elem = elem;
var $elem = this.$elem = $(elem);
this.$set = options.$set && options.$set.length ? options.$set : $elem;
this.$doc = $(elem.ownerDocument || document);
this.$parent = $elem.parent();
// This is SVG if the namespace is SVG
// However, while