mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 06:35:42 +00:00
class Range
This commit is contained in:
parent
dda8552088
commit
9fabd1adb8
@ -20,6 +20,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ian Gilman <ian@iangilman.com>
|
||||
* Michael Yoshitaka Erlewine <mitcho@mitcho.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -249,6 +250,46 @@ window.Rect.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
// ##########
|
||||
// Class: Range
|
||||
// A physical interval, with a min and max.
|
||||
//
|
||||
// Constructor: Range
|
||||
// Creates a Range with the given min and max
|
||||
window.Range = function(min, max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
};
|
||||
|
||||
// ----------
|
||||
window.isRange = function(r) {
|
||||
return (r
|
||||
&& Utils.isNumber(r.min)
|
||||
&& Utils.isNumber(r.max));
|
||||
};
|
||||
|
||||
window.Range.prototype = {
|
||||
// ----------
|
||||
// Function: contains
|
||||
// Whether the <Range> contains the given value or not
|
||||
//
|
||||
// Paramaters
|
||||
// - a number
|
||||
contains: function(value) {
|
||||
return( value >= this.min && value <= this.max );
|
||||
},
|
||||
// ----------
|
||||
// Function: containsWithin
|
||||
// Whether the <Range>'s interior contains the given value or not
|
||||
//
|
||||
// Paramaters
|
||||
// - a number
|
||||
containsWithin: function(value) {
|
||||
return( value > this.min && value < this.max );
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
// ##########
|
||||
// Class: Subscribable
|
||||
// A mix-in for allowing objects to collect subscribers for custom events.
|
||||
|
Loading…
Reference in New Issue
Block a user