From f5782c475b9f74343373d405fe492b1b2bb24081 Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 25 Jun 2012 16:43:03 +0200 Subject: [PATCH] Ox.divideInt -> Ox.splitInt --- source/Ox.UI/js/Form/CheckboxGroup.js | 2 +- source/Ox.UI/js/Form/InputGroup.js | 2 +- source/Ox.UI/js/Form/Range.js | 2 +- source/Ox.UI/js/Video/VideoEditor.js | 2 +- source/Ox/js/Math.js | 37 +++++++++++++-------------- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/source/Ox.UI/js/Form/CheckboxGroup.js b/source/Ox.UI/js/Form/CheckboxGroup.js index 01abeb2c..df281df5 100644 --- a/source/Ox.UI/js/Form/CheckboxGroup.js +++ b/source/Ox.UI/js/Form/CheckboxGroup.js @@ -49,7 +49,7 @@ Ox.CheckboxGroup = function(options, self) { self.$checkboxes = []; if (self.options.type == 'group') { - self.checkboxWidth = Ox.divideInt( + self.checkboxWidth = Ox.splitInt( self.options.width + (self.options.checkboxes.length - 1) * 6, self.options.checkboxes.length ).map(function(v, i) { diff --git a/source/Ox.UI/js/Form/InputGroup.js b/source/Ox.UI/js/Form/InputGroup.js index c17b5ea5..69fac436 100644 --- a/source/Ox.UI/js/Form/InputGroup.js +++ b/source/Ox.UI/js/Form/InputGroup.js @@ -128,7 +128,7 @@ Ox.InputGroup = function(options, self) { function setWidths() { var length = self.options.inputs.length, - inputWidths = Ox.divideInt( + inputWidths = Ox.splitInt( self.options.width - Ox.sum(self.options.separators.map(function(v) { return v.width; })), length diff --git a/source/Ox.UI/js/Form/Range.js b/source/Ox.UI/js/Form/Range.js index 6d69ed5d..1c8d567b 100644 --- a/source/Ox.UI/js/Form/Range.js +++ b/source/Ox.UI/js/Form/Range.js @@ -218,7 +218,7 @@ Ox.Range = function(options, self) { self.thumbSize = Math.max(self.trackSize / self.values, self.options.thumbSize); self.trackImageWidths = self.trackImages == 1 ? [self.trackSize - 16] - : Ox.divideInt(self.trackSize - 2, self.trackImages); + : Ox.splitInt(self.trackSize - 2, self.trackImages); self.trackColorStart = self.options.trackGradient ? self.thumbSize / 2 / self.options.size : 0; self.trackColorStep = self.options.trackGradient diff --git a/source/Ox.UI/js/Video/VideoEditor.js b/source/Ox.UI/js/Video/VideoEditor.js index e280396f..7e207676 100644 --- a/source/Ox.UI/js/Video/VideoEditor.js +++ b/source/Ox.UI/js/Video/VideoEditor.js @@ -1019,7 +1019,7 @@ Ox.VideoEditor = function(options, self) { } if (self.options.videoSize == 'small') { width = 0; - widths = Ox.divideInt(contentWidth - 4 * self.margin, 3); + widths = Ox.splitInt(contentWidth - 4 * self.margin, 3); [1, 0, 2].forEach(function(v, i) { size.player[v] = { left: (i + 0.5) * self.margin + width, diff --git a/source/Ox/js/Math.js b/source/Ox/js/Math.js index 157606d1..fe25bab2 100644 --- a/source/Ox/js/Math.js +++ b/source/Ox/js/Math.js @@ -50,25 +50,6 @@ Ox.deg = function(rad) { return rad * 180 / Math.PI; }; -/*@ -Ox.divideInt Divides a number by another and returns an array of integers - `Ox.divideInt(num, by)` returns a sorted array of integers that has a sum of - `num`, a length of `by`, a minimum of `Math.floor(num / by)` and a maximum - of `Math.ceil(num / by)`. - > Ox.divideInt(100, 3) - [33, 33, 34] - > Ox.divideInt(100, 6) - [16, 16, 17, 17, 17, 17] -@*/ -// fixme: is splitInt a better name? -Ox.divideInt = function(number, by) { - var div = Math.floor(number / by), - mod = number % by; - return Ox.range(by).map(function(i) { - return div + (i > by - 1 - mod); - }); -}; - /*@ Ox.hypot Returns the square root of the sum of the squares of its arguments (x, y[, z]) -> Square root of the sum of the squares of its arguments @@ -202,6 +183,24 @@ Ox.sinh = function(x) { return (Math.exp(x) - Math.exp(-x)) / 2; }; +/*@ +Ox.splitInt Splits an integer into an array of integers + `Ox.splitInt(num, by)` returns a sorted array of integers that has a sum of + `num`, a length of `by`, a minimum of `Math.floor(num / by)` and a maximum + of `Math.ceil(num / by)`. + > Ox.splitInt(100, 3) + [33, 33, 34] + > Ox.splitInt(100, 6) + [16, 16, 17, 17, 17, 17] +@*/ +Ox.splitInt = function(number, by) { + var div = Math.floor(number / by), + mod = number % by; + return Ox.range(by).map(function(i) { + return div + (i > by - 1 - mod); + }); +}; + /*@ Ox.tanh Hyperbolic tangent Missing from `Math`.