initial commit

This commit is contained in:
2026-03-22 03:21:45 +02:00
commit 897fea9f4e
15431 changed files with 2548840 additions and 0 deletions

25
node_modules/region/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,25 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules

21
node_modules/region/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Radu Brehar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

10
node_modules/region/Makefile generated vendored Normal file
View File

@@ -0,0 +1,10 @@
REPORTER = spec
test:
./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --require should
test-w:
./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --require should --watch
test-debug:
./node_modules/.bin/mocha --debug-brk --recursive --reporter $(REPORTER) --require should --watch
.PHONY: test test-w

139
node_modules/region/README.md generated vendored Normal file
View File

@@ -0,0 +1,139 @@
region
======
A helper to work with rectangular regions in the DOM
## Install
```sh
$ npm install region --save
```
## Usage
```js
var Region = require('region')
var region = Region({
top: 10,
left: 10,
width: 50,
height: 60
})
region.getRight() == 60
region.getBottom() == 70
```
## API
### Instantiation
You can create a new Region by calling the function returned by ```require('region')```. You can call it as a constructor if you want.
```js
var Region = require('region')
new Region({
top: 10,
left: 10
//either width,height
//or right, bottom
width: 10,
height: 10
})
```
or
```js
var Region = require('region')
var r = Region({
top: 10,
left: 10,
right: 20,
bottom: 20
})
```
You can instantiate a ```Region``` from a DOM node, using Region.fromDOM (NOTE: uses dom.offsetWidth/Height/Left/Top for getting coordinates)
```js
var r = Region.fromDOM(document.body)
```
### Getters
* get - returns an object with {top, left, bottom, right}
* getWidth
* getHeight
* getLeft
* getTop
* getRight
* getBottom
* getPosition - returns an object with {left, top}
* getSize - returns an object with {width, height}
### containsPoint(x,y) or containsPoint({x,y}) : Boolean
```js
var r = Region({
top: 10,
left: 10,
width: 10,
height: 10
})
r.containsPoint(15, 10) == true
r.containsPoint({x: 10, y: 10}) == true
```
### equals(r): Boolean
Returns true if this region equals the region (or the object) given as the first param
var r = Region({top: 10, left: 10, bottom: 20, right: 20 })
r.equals({top: 10, left: 10, bottom: 20, right: 20 }) == true
### equalsPosition({top, left}): Boolean
Returns true if this region has top, left equal to the given coordinates
### equalsSize({width, height}): Boolean
Returns true if this region has the same size as the given region or object
```js
var coords = { top: 10, left: 10, width: 100, height: 100 }
var r = Region(coords)
r.equalsSize(coords) == true
r.equalsSize(r.clone()) == true
```
### getIntersection(Region): Region/false
Returns the region resulted by intersecting this region with the given region. If no intersection, returns false
### clone: Region
Returns a new region instance with the same coordinates
```js
var r = new Region({left: 10, right: 10, width: 10, height: 20})
r.clone().equals(r)
```
## Tests
```sh
$ make
```
Watch mode
```sh
$ make test-w
```
## License
```
MIT
```

177
node_modules/region/align/alignToNormalized.js generated vendored Normal file
View File

@@ -0,0 +1,177 @@
'use strict'
var Region = require('region')
/**
*
* This method is trying to align the sourceRegion to the targetRegion, given the alignment positions
* and the offsets. It only modifies the sourceRegion
*
* This is all well and easy, but if there is a constrainTo region, the algorithm has to take it into account.
* In this case, it works as follows.
*
* * start with the first alignment position. Aligns the region, adds the offset and then check for the constraint.
* * if the constraint condition is ok, return the position.
* * otherwise, remember the intersection area, if the regions are intersecting.
* * then go to the next specified align position, and so on, computing the maximum intersection area.
*
* If no alignment fits the constrainRegion, the sourceRegion will be resized to match it,
* using the position with the maximum intersection area.
*
* Since we have computed the index of the position with the max intersection area, take that position,
* and align the sourceRegion accordingly. Then resize the sourceRegion to the intersection, and reposition
* it again, since resizing it might have destroyed the alignment.
*
* Return the position.
*
* @param {Region} sourceRegion
* @param {Region} targetRegion
* @param {String[]} positions
* @param {Object} config
* @param {Array} config.offset
* @param {Region} config.constrain
* @param {Boolean/Object} config.sync
*
* @return {String/Undefined} the chosen position for the alignment, or undefined if no position found
*/
function ALIGN_TO_NORMALIZED(sourceRegion, targetRegion, positions, config){
targetRegion = Region.from(targetRegion)
config = config || {}
var constrainTo = config.constrain,
syncOption = config.sync,
offsets = config.offset || [],
syncWidth = false,
syncHeight = false,
sourceClone = sourceRegion.clone()
/*
* Prepare the method arguments: positions, offsets, constrain and sync options
*/
if (!Array.isArray(positions)){
positions = positions? [positions]: []
}
if (!Array.isArray(offsets)){
offsets = offsets? [offsets]: []
}
if (constrainTo){
constrainTo = constrainTo === true?
Region.getDocRegion():
constrainTo.getRegion()
}
if (syncOption){
if (syncOption.size){
syncWidth = true
syncHeight = true
} else {
syncWidth = syncOption === true?
true:
syncOption.width || false
syncHeight = syncOption === true?
true:
syncOption.height || false
}
}
if (syncWidth){
sourceClone.setWidth(targetRegion.getWidth())
}
if (syncHeight){
sourceClone.setHeight(targetRegion.getHeight())
}
var offset,
i = 0,
len = positions.length,
pos,
intersection,
itArea,
maxArea = -1,
maxAreaIndex = -1
for (; i < len; i++){
pos = positions[i]
offset = offsets[i]
sourceClone.alignToRegion(targetRegion, pos)
if (offset){
if (!Array.isArray(offset)){
offset = offsets[i] = [offset.x || offset.left, offset.y || offset.top]
}
sourceClone.shift({
left: offset[0],
top : offset[1]
})
}
//the source region is already aligned in the correct position
if (constrainTo){
//if we have a constrain region, test for the constrain
intersection = sourceClone.getIntersection(constrainTo)
if ( intersection && intersection.equals(sourceClone) ) {
//constrain respected, so return (the aligned position)
sourceRegion.set(sourceClone)
return pos
} else {
//the constrain was not respected, so continue trying
if (intersection && ((itArea = intersection.getArea()) > maxArea)){
maxArea = itArea
maxAreaIndex = i
}
}
} else {
sourceRegion.set(sourceClone)
return pos
}
}
//no alignment respected the constraints
if (~maxAreaIndex){
pos = positions[maxAreaIndex]
offset = offsets[maxAreaIndex]
sourceClone.alignToRegion(targetRegion, pos)
if (offset){
sourceClone.shift({
left: offset[0],
top : offset[1]
})
}
//we are sure an intersection exists, because of the way the maxAreaIndex was computed
intersection = sourceClone.getIntersection(constrainTo)
sourceClone.setRegion(intersection)
sourceClone.alignToRegion(targetRegion, pos)
if (offset){
sourceClone.shift({
left: offset[0],
top : offset[1]
})
}
sourceRegion.set(sourceClone)
return pos
}
}
module.exports = ALIGN_TO_NORMALIZED

74
node_modules/region/align/computeAlignRegion.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
'use strict'
var ALIGN_TO_NORMALIZED = require('./alignToNormalized')
/**
* @localdoc Given source and target regions, and the given alignments required, returns a region that is the resulting allignment.
* Does not modify the sourceRegion.
*
* Example
*
* var sourceRegion = zippy.getInstance({
* alias : 'z.region',
* top : 10,
* left : 10,
* bottom : 40,
* right : 100
* })
*
* var targetRegion = zippy.getInstance({
* alias : 'z.region',
* top : 10,
* left : 10,
* bottom : 40,
* right : 100
* })
* //has top-left at (10,10)
* //and bottom-right at (40, 100)
*
* var alignRegion = alignable.COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, 'tl-br')
*
* //alignRegion will be a clone of sourceRegion, but will have the
* //top-left corner aligned with bottom-right of targetRegion
*
* alignRegion.get() // => { top: 40, left: 100, bottom: 70, right: 190 }
*
* @param {Region} sourceRegion The source region to align to targetRegion
* @param {Region} targetRegion The target region to which to align the sourceRegion
* @param {String/String[]} positions A string ( delimited by "-" characters ) or an array of strings with the position to try, in the order of their priority.
* See Region#getPoint for a list of available positions. They can be combined in any way.
* @param {Object} config A config object with other configuration for the alignment
* @param {Object/Object[]} config.offset Optional offsets. Either an object or an array with a different offset for each position
* @param {Element/Region/Boolean} config.constrain The constrain to region or element. If the boolean true, Region.getDocRegion() will be used
* @param {Object/Boolean} config.sync A boolean object that indicates whether to sync sourceRegion and targetRegion sizes (width/height or both). Can be
*
* * true - in order to sync both width and height
* * { width: true } - to only sync width
* * { height: true } - to only sync height
* * { size: true } - to sync both width and height
*
* @return {Object} an object with the following keys:
*
* * position - the position where the alignment was made. One of the given positions
* * region - the region where the alignment is in place
* * positionChanged - boolean value indicating if the position of the returned region is different from the position of sourceRegion
* * widthChanged - boolean value indicating if the width of the returned region is different from the width of sourceRegion
* * heightChanged - boolean value indicating if the height of the returned region is different from the height of sourceRegion
*/
function COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, positions, config){
sourceRegion = Region.from(sourceRegion)
var sourceClone = sourceRegion.clone()
var position = ALIGN_TO_NORMALIZED(sourceClone, targetRegion, positions, config)
return {
position : position,
region : sourceClone,
widthChanged : sourceClone.getWidth() != sourceRegion.getWidth(),
heightChanged : sourceClone.getHeight() != sourceRegion.getHeight(),
positionChanged : sourceClone.equalsPosition(sourceRegion)
}
}
module.exports = COMPUTE_ALIGN_REGION

181
node_modules/region/align/index.js generated vendored Normal file
View File

@@ -0,0 +1,181 @@
'use strict';
module.exports = function(Region){
require('./Region.static')
require('./Region.proto')
var COMPUTE_ALIGN_REGION = require('./computeAlignRegion')
/**
* region-align module exposes methods for aligning {@link Element} and {@link Region} instances
*
* The #alignTo method aligns this to the target element/region using the specified positions. See #alignTo for a graphical example.
*
*
* var div = Element.select('div.first')
*
* div.alignTo(Element.select('body') , 'br-br')
*
* //aligns the div to be in the bottom-right corner of the body
*
* Other useful methods
*
* * {@link #alignRegions} - aligns a given source region to a target region
* * {@link #COMPUTE_ALIGN_REGION} - given a source region and a target region, and alignment positions, returns a clone of the source region, but aligned to satisfy the given alignments
*/
/**
* Aligns sourceRegion to targetRegion. It modifies the sourceRegion in order to perform the correct alignment.
* See #COMPUTE_ALIGN_REGION for details and examples.
*
* This method calls #COMPUTE_ALIGN_REGION passing to it all its arguments. The #COMPUTE_ALIGN_REGION method returns a region that is properly aligned.
* If this returned region position/size differs from sourceRegion, then the sourceRegion is modified to be an exact copy of the aligned region.
*
* @inheritdoc #COMPUTE_ALIGN_REGION
* @return {String} the position used for alignment
*/
Region.alignRegions = function(sourceRegion, targetRegion, positions, config){
var result = COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, positions, config)
var alignedRegion = result.region
if ( !alignedRegion.equals(sourceRegion) ) {
sourceRegion.setRegion(alignedRegion)
}
return result.position
}
/**
*
* The #alignTo method aligns this to the given target region, using the specified alignment position(s).
* You can also specify a constrain for the alignment.
*
* Example
*
* BIG
* ________________________
* | _______ |
* | | | |
* | | A | |
* | | | _____ |
* | |_______| | | |
* | | B | |
* | | | |
* |_______________|_____|_|
*
* Assume the *BIG* outside rectangle is our constrain region, and you want to align the *A* rectangle
* to the *B* rectangle. Ideally, you'll want their tops to be aligned, and *A* to be placed at the right side of *B*
*
*
* //so we would align them using
*
* A.alignTo(B, 'tl-tr', { constrain: BIG })
*
* But this would result in
*
* BIG
* ________________________
* | |
* | |
* | |
* | _____ _|_____
* | | | . |
* | | B | . A |
* | | | . |
* |_______________|_____|_._____|
*
*
* Which is not what we want. So we specify an array of options to try
*
* A.alignTo(B, ['tl-tr', 'tr-tl'], { constrain: BIG })
*
* So by this we mean: try to align A(top,left) with B(top,right) and stick to the BIG constrain. If this is not possible,
* try the next option: align A(top,right) with B(top,left)
*
* So this is what we end up with
*
* BIG
* ________________________
* | |
* | |
* | |
* | _______ _____ |
* | | | | |
* | | A | B | |
* | | | | |
* |_______|_______|_____|_|
*
*
* Which is a lot better!
*
* @param {Element/Region} target The target to which to align this alignable.
*
* @param {String[]/String} positions The positions for the alignment.
*
* Example:
*
* 'br-tl'
* ['br-tl','br-tr','cx-tc']
*
* This method will try to align using the first position. But if there is a constrain region, that position might not satisfy the constrain.
* If this is the case, the next positions will be tried. If one of them satifies the constrain, it will be used for aligning and it will be returned from this method.
*
* If no position matches the contrain, the one with the largest intersection of the source region with the constrain will be used, and this alignable will be resized to fit the constrain region.
*
* @param {Object} config A config object with other configuration for this method
*
* @param {Array[]/Object[]/Object} config.offset The offset to use for aligning. If more that one offset is specified, then offset at a given index is used with the position at the same index.
*
* An offset can have the following form:
*
* [left_offset, top_offset]
* {left: left_offset, top: top_offset}
* {x: left_offset, y: top_offset}
*
* You can pass one offset or an array of offsets. In case you pass just one offset,
* it cannot have the array form, so you cannot call
*
* this.alignTo(target, positions, [10, 20])
*
* If you do, it will not be considered. Instead, please use
*
* this.alignTo(target, positions, {x: 10, y: 20})
*
* Or
*
* this.alignTo(target, positions, [[10, 20]] )
*
* @param {Boolean/Element/Region} config.constrain If boolean, target will be constrained to the document region, otherwise,
* getRegion will be called on this argument to determine the region we need to constrain to.
*
* @param {Boolean/Object} config.sync Either boolean or an object with {width, height}. If it is boolean,
* both width and height will be synced. If directions are specified, will only sync the direction which is specified as true
*
* @return {String}
*
*/
Region.prototype.alignTo = function(target, positions, config){
config = config || {}
var sourceRegion = this
var targetRegion = Region.from(target)
var result = COMPUTE_ALIGN_REGION(sourceRegion, targetRegion, positions, config)
var resultRegion = result.region
if (!resultRegion.equalsSize(sourceRegion)){
this.setSize(resultRegion.getSize())
}
if (!resultRegion.equalsPosition(sourceRegion)){
this.setPosition(resultRegion.getPosition(), { absolute: !!config.absolute })
}
return result.position
}
}

9
node_modules/region/dist.config.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
module.exports = {
entry: './index',
output: {
path : __dirname + "/dist",
libraryTarget: 'umd',
library : 'Region',
filename : 'region.js'
}
}

9
node_modules/region/dist.min.config.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
module.exports = {
entry: './index',
output: {
path : __dirname + "/dist",
libraryTarget: 'umd',
library : 'Region',
filename : 'region.min.js'
}
}

1809
node_modules/region/dist/region.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/region/dist/region.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/region/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./src')

View File

@@ -0,0 +1,26 @@
'use strict';
function ToObject(val) {
if (val == null) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
module.exports = Object.assign || function (target, source) {
var from;
var keys;
var to = ToObject(target);
for (var s = 1; s < arguments.length; s++) {
from = arguments[s];
keys = Object.keys(Object(from));
for (var i = 0; i < keys.length; i++) {
to[keys[i]] = from[keys[i]];
}
}
return to;
};

21
node_modules/region/node_modules/object-assign/license generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,38 @@
{
"name": "object-assign",
"version": "2.1.1",
"description": "ES6 Object.assign() ponyfill",
"license": "MIT",
"repository": "sindresorhus/object-assign",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"object",
"assign",
"extend",
"properties",
"es6",
"ecmascript",
"harmony",
"ponyfill",
"prollyfill",
"polyfill",
"shim",
"browser"
],
"devDependencies": {
"mocha": "*"
}
}

View File

@@ -0,0 +1,51 @@
# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign)
> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill
> Ponyfill: A polyfill that doesn't overwrite the native method
## Install
```sh
$ npm install --save object-assign
```
## Usage
```js
var objectAssign = require('object-assign');
objectAssign({foo: 0}, {bar: 1});
//=> {foo: 0, bar: 1}
// multiple sources
objectAssign({foo: 0}, {bar: 1}, {baz: 2});
//=> {foo: 0, bar: 1, baz: 2}
// overwrites equal keys
objectAssign({foo: 0}, {foo: 1}, {foo: 2});
//=> {foo: 2}
// ignores null and undefined sources
objectAssign({foo: 0}, null, {bar: 1}, undefined);
//=> {foo: 0, bar: 1}
```
## API
### objectAssign(target, source, [source, ...])
Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones.
## Resources
- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign)
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

45
node_modules/region/package.json generated vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"name": "region",
"version": "2.1.2",
"description": "A helper to work with rectangular regions in the DOM",
"main": "index.js",
"scripts": {
"test": "make test",
"test-w": "make test-w",
"test-debug": "mocha --debug-brk",
"dist": "./node_modules/.bin/webpack --progress --colors --config dist.config.js",
"dist.min": "./node_modules/.bin/webpack --progress --colors --optimize-minimize --optimize-occurence-order --optimize-dedupe --config dist.min.config.js",
"build": "npm run dist && npm run dist.min"
},
"devDependencies": {
"mocha": "~1.21.0",
"should": "~4.0.4",
"webpack": "^1.4.13",
"webpack-dev-server": "^1.6.5"
},
"repository": {
"type": "git",
"url": "git://github.com/radubrehar/region.git"
},
"keywords": [
"region",
"dom",
"rectangle",
"size",
"area",
"intersection",
"element",
"html",
"coordinates"
],
"author": "Radu Brehar",
"license": "MIT",
"bugs": {
"url": "https://github.com/radubrehar/region/issues"
},
"dependencies": {
"hasown": "~1.x.x",
"newify": "^1.1.9",
"object-assign": "^2.0.0"
}
}

9
node_modules/region/region.sublime-project generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
]
}

2324
node_modules/region/region.sublime-workspace generated vendored Normal file

File diff suppressed because it is too large Load Diff

1051
node_modules/region/src/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

13
node_modules/region/src/inherits.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
module.exports = function(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value : ctor,
enumerable : false,
writable : true,
configurable: true
}
})
}

214
node_modules/region/src/statics.js generated vendored Normal file
View File

@@ -0,0 +1,214 @@
'use strict';
var hasOwn = require('hasown')
var VALIDATE = require('./validate')
module.exports = function(REGION){
var MAX = Math.max
var MIN = Math.min
var statics = {
init: function(){
var exportAsNonStatic = {
getIntersection : true,
getIntersectionArea : true,
getIntersectionHeight: true,
getIntersectionWidth : true,
getUnion : true
}
var thisProto = REGION.prototype
var newName
var exportHasOwn = hasOwn(exportAsNonStatic)
var methodName
for (methodName in exportAsNonStatic) if (exportHasOwn(methodName)) {
newName = exportAsNonStatic[methodName]
if (typeof newName != 'string'){
newName = methodName
}
;(function(proto, methodName, protoMethodName){
proto[methodName] = function(region){
//<debug>
if (!REGION[protoMethodName]){
console.warn('cannot find method ', protoMethodName,' on ', REGION)
}
//</debug>
return REGION[protoMethodName](this, region)
}
})(thisProto, newName, methodName);
}
},
validate: VALIDATE,
/**
* Returns the region corresponding to the documentElement
* @return {Region} The region corresponding to the documentElement. This region is the maximum region visible on the screen.
*/
getDocRegion: function(){
return REGION.fromDOM(document.documentElement)
},
from: function(reg){
if (reg.__IS_REGION){
return reg
}
if (typeof document != 'undefined'){
if (typeof HTMLElement != 'undefined' && reg instanceof HTMLElement){
return REGION.fromDOM(reg)
}
if (reg.type && typeof reg.pageX !== 'undefined' && typeof reg.pageY !== 'undefined'){
return REGION.fromEvent(reg)
}
}
return REGION(reg)
},
fromEvent: function(event){
return REGION.fromPoint({
x: event.pageX,
y: event.pageY
})
},
fromDOM: function(dom){
var rect = dom.getBoundingClientRect()
// var docElem = document.documentElement
// var win = window
// var top = rect.top + win.pageYOffset - docElem.clientTop
// var left = rect.left + win.pageXOffset - docElem.clientLeft
return new REGION({
top : rect.top,
left : rect.left,
bottom: rect.bottom,
right : rect.right
})
},
/**
* @static
* Returns a region that is the intersection of the given two regions
* @param {Region} first The first region
* @param {Region} second The second region
* @return {Region/Boolean} The intersection region or false if no intersection found
*/
getIntersection: function(first, second){
var area = this.getIntersectionArea(first, second)
if (area){
return new REGION(area)
}
return false
},
getIntersectionWidth: function(first, second){
var minRight = MIN(first.right, second.right)
var maxLeft = MAX(first.left, second.left)
if (maxLeft < minRight){
return minRight - maxLeft
}
return 0
},
getIntersectionHeight: function(first, second){
var maxTop = MAX(first.top, second.top)
var minBottom = MIN(first.bottom,second.bottom)
if (maxTop < minBottom){
return minBottom - maxTop
}
return 0
},
getIntersectionArea: function(first, second){
var maxTop = MAX(first.top, second.top)
var minRight = MIN(first.right, second.right)
var minBottom = MIN(first.bottom,second.bottom)
var maxLeft = MAX(first.left, second.left)
if (
maxTop < minBottom &&
maxLeft < minRight
){
return {
top : maxTop,
right : minRight,
bottom : minBottom,
left : maxLeft,
width : minRight - maxLeft,
height : minBottom - maxTop
}
}
return false
},
/**
* @static
* Returns a region that is the union of the given two regions
* @param {Region} first The first region
* @param {Region} second The second region
* @return {Region} The union region. The smallest region that contains both given regions.
*/
getUnion: function(first, second){
var top = MIN(first.top, second.top)
var right = MAX(first.right, second.right)
var bottom = MAX(first.bottom,second.bottom)
var left = MIN(first.left, second.left)
return new REGION(top, right, bottom, left)
},
/**
* @static
* Returns a region. If the reg argument is a region, returns it, otherwise return a new region built from the reg object.
*
* @param {Region} reg A region or an object with either top, left, bottom, right or
* with top, left, width, height
* @return {Region} A region
*/
getRegion: function(reg){
return REGION.from(reg)
},
/**
* Creates a region that corresponds to a point.
*
* @param {Object} xy The point
* @param {Number} xy.x
* @param {Number} xy.y
*
* @return {Region} The new region, with top==xy.y, bottom = xy.y and left==xy.x, right==xy.x
*/
fromPoint: function(xy){
return new REGION({
top : xy.y,
bottom : xy.y,
left : xy.x,
right : xy.x
})
}
}
Object.keys(statics).forEach(function(key){
REGION[key] = statics[key]
})
REGION.init()
}

27
node_modules/region/src/validate.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
'use strict';
/**
* @static
* Returns true if the given region is valid, false otherwise.
* @param {Region} region The region to check
* @return {Boolean} True, if the region is valid, false otherwise.
* A region is valid if
* * left <= right &&
* * top <= bottom
*/
module.exports = function validate(region){
var isValid = true
if (region.right < region.left){
isValid = false
region.right = region.left
}
if (region.bottom < region.top){
isValid = false
region.bottom = region.top
}
return isValid
}

21
node_modules/region/test/RegionEqualityTests.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
describe('Region equal', function(){
var Region = require('../index')
it('size should return fine', function(){
var r = Region({
top : 10,
left : 10,
width : 10,
height: 10
})
r.equalsSize({
width : 10,
height: 10
})
.should
.equal(true)
})
})

18
node_modules/region/test/RegionIntersection.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
describe('Region intersection', function(){
var Region = require('../index')
it('should containPoint', function(){
var inner = Region({
left: 97, right: 147, top: 51, bottom: 251
})
var outer = Region({
left: 11, right: 447, top: 51, bottom: 937
})
outer.getIntersection(inner).getArea()
.should
.equal(inner.getArea())
})
})

25
node_modules/region/test/RegionPointTests.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
describe('Region point functions', function(){
var Region = require('../index')
it('should containPoint', function(){
var r = Region({
top: 10,
left: 10,
width: 10,
height: 10
})
r.containsPoint(15, 10)
.should
.equal(true)
r.containsPoint({x: 10, y: 10})
.should
.equal(true)
r.containsPoint(25, 10)
.should
.equal(false)
})
})

57
node_modules/region/test/RegionTests.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
describe('Region', function(){
var Region = require('../index')
it('should have correct width', function(){
var r = Region({
top: 10,
left: 20,
right: 40,
bottom: 20
})
r.getWidth()
.should
.equal(20)
})
it('should have correct height', function(){
var r = new Region({
top: 10,
left: 20,
width: 30,
height: 40
})
r.getBottom()
.should
.equal(50)
})
it('should return correct intersection', function(){
var r1 = Region({
top: 10,
left: 10,
right: 40,
bottom: 40
})
var r2 = Region({
top: 20,
left: 15,
right: 45,
bottom: 35
})
var intersection = r1.getIntersection(r2)
intersection.get()
.should
.eql({
top: 20,
left: 15,
right: 40,
bottom: 35
})
})
})