@ -12,7 +12,7 @@ var uuid = require('./module/uuid');
* @ param { * } object
* @ param { * } object
* @ return { Boolean } isNumber
* @ return { Boolean } isNumber
* /
* /
exports . isNumber = function ( object ) {
exports . isNumber = function ( object ) {
return ( object instanceof Number || typeof object == 'number' ) ;
return ( object instanceof Number || typeof object == 'number' ) ;
} ;
} ;
@ -21,7 +21,7 @@ exports.isNumber = function(object) {
* Remove everything in the DOM object
* Remove everything in the DOM object
* @ param DOMobject
* @ param DOMobject
* /
* /
exports . recursiveDOMDelete = function ( DOMobject ) {
exports . recursiveDOMDelete = function ( DOMobject ) {
if ( DOMobject ) {
if ( DOMobject ) {
while ( DOMobject . hasChildNodes ( ) === true ) {
while ( DOMobject . hasChildNodes ( ) === true ) {
exports . recursiveDOMDelete ( DOMobject . firstChild ) ;
exports . recursiveDOMDelete ( DOMobject . firstChild ) ;
@ -39,13 +39,13 @@ exports.recursiveDOMDelete = function(DOMobject) {
* @ param value
* @ param value
* @ returns { number }
* @ returns { number }
* /
* /
exports . giveRange = function ( min , max , total , value ) {
exports . giveRange = function ( min , max , total , value ) {
if ( max == min ) {
if ( max == min ) {
return 0.5 ;
return 0.5 ;
}
}
else {
else {
var scale = 1 / ( max - min ) ;
var scale = 1 / ( max - min ) ;
return Math . max ( 0 , ( value - min ) * scale ) ;
return Math . max ( 0 , ( value - min ) * scale ) ;
}
}
}
}
@ -54,7 +54,7 @@ exports.giveRange = function(min,max,total,value) {
* @ param { * } object
* @ param { * } object
* @ return { Boolean } isString
* @ return { Boolean } isString
* /
* /
exports . isString = function ( object ) {
exports . isString = function ( object ) {
return ( object instanceof String || typeof object == 'string' ) ;
return ( object instanceof String || typeof object == 'string' ) ;
} ;
} ;
@ -63,7 +63,7 @@ exports.isString = function(object) {
* @ param { Date | String } object
* @ param { Date | String } object
* @ return { Boolean } isDate
* @ return { Boolean } isDate
* /
* /
exports . isDate = function ( object ) {
exports . isDate = function ( object ) {
if ( object instanceof Date ) {
if ( object instanceof Date ) {
return true ;
return true ;
}
}
@ -86,7 +86,7 @@ exports.isDate = function(object) {
* source : http : //stackoverflow.com/a/105074/1262753
* source : http : //stackoverflow.com/a/105074/1262753
* @ return { String } uuid
* @ return { String } uuid
* /
* /
exports . randomUUID = function ( ) {
exports . randomUUID = function ( ) {
return uuid . v4 ( ) ;
return uuid . v4 ( ) ;
} ;
} ;
@ -125,7 +125,7 @@ exports.fillIfDefined = function (a, b, allowDeletion = false) {
}
}
else {
else {
if ( typeof a [ prop ] === 'object' ) {
if ( typeof a [ prop ] === 'object' ) {
exports . fillIfDefined ( a [ prop ] , b [ prop ] , allowDeletion ) ;
exports . fillIfDefined ( a [ prop ] , b [ prop ] , allowDeletion ) ;
}
}
}
}
}
}
@ -273,7 +273,10 @@ exports.selectiveNotDeepExtend = function (props, a, b, allowDeletion = false) {
}
}
}
}
} else if ( Array . isArray ( b [ prop ] ) ) {
} else if ( Array . isArray ( b [ prop ] ) ) {
throw new TypeError ( 'Arrays are not supported by deepExtend' ) ;
a [ prop ] = [ ] ;
for ( let i = 0 ; i < b [ prop ] . length ; i ++ ) {
a [ prop ] . push ( b [ prop ] [ i ] ) ;
}
} else {
} else {
a [ prop ] = b [ prop ] ;
a [ prop ] = b [ prop ] ;
}
}
@ -292,7 +295,7 @@ exports.selectiveNotDeepExtend = function (props, a, b, allowDeletion = false) {
* @ param [ Boolean ] global -- > optional parameter . If true , the values of fields that are null will not deleted
* @ param [ Boolean ] global -- > optional parameter . If true , the values of fields that are null will not deleted
* @ returns { Object }
* @ returns { Object }
* /
* /
exports . deepExtend = function ( a , b , protoExtend , allowDeletion ) {
exports . deepExtend = function ( a , b , protoExtend , allowDeletion ) {
for ( var prop in b ) {
for ( var prop in b ) {
if ( b . hasOwnProperty ( prop ) || protoExtend === true ) {
if ( b . hasOwnProperty ( prop ) || protoExtend === true ) {
if ( b [ prop ] && b [ prop ] . constructor === Object ) {
if ( b [ prop ] && b [ prop ] . constructor === Object ) {
@ -349,7 +352,7 @@ exports.equalArray = function (a, b) {
* @ return { * } object
* @ return { * } object
* @ throws Error
* @ throws Error
* /
* /
exports . convert = function ( object , type ) {
exports . convert = function ( object , type ) {
var match ;
var match ;
if ( object === undefined ) {
if ( object === undefined ) {
@ -402,8 +405,8 @@ exports.convert = function(object, type) {
}
}
else {
else {
throw new Error (
throw new Error (
'Cannot convert object of type ' + exports . getType ( object ) +
' to type Date' ) ;
'Cannot convert object of type ' + exports . getType ( object ) +
' to type Date' ) ;
}
}
case 'Moment' :
case 'Moment' :
@ -428,8 +431,8 @@ exports.convert = function(object, type) {
}
}
else {
else {
throw new Error (
throw new Error (
'Cannot convert object of type ' + exports . getType ( object ) +
' to type Date' ) ;
'Cannot convert object of type ' + exports . getType ( object ) +
' to type Date' ) ;
}
}
case 'ISODate' :
case 'ISODate' :
@ -454,8 +457,8 @@ exports.convert = function(object, type) {
}
}
else {
else {
throw new Error (
throw new Error (
'Cannot convert object of type ' + exports . getType ( object ) +
' to type ISODate' ) ;
'Cannot convert object of type ' + exports . getType ( object ) +
' to type ISODate' ) ;
}
}
case 'ASPDate' :
case 'ASPDate' :
@ -479,8 +482,8 @@ exports.convert = function(object, type) {
}
}
else {
else {
throw new Error (
throw new Error (
'Cannot convert object of type ' + exports . getType ( object ) +
' to type ASPDate' ) ;
'Cannot convert object of type ' + exports . getType ( object ) +
' to type ASPDate' ) ;
}
}
default :
default :
@ -498,7 +501,7 @@ var ASPDateRegex = /^\/?Date\((\-?\d+)/i;
* @ param { * } object
* @ param { * } object
* @ return { String } type
* @ return { String } type
* /
* /
exports . getType = function ( object ) {
exports . getType = function ( object ) {
var type = typeof object ;
var type = typeof object ;
if ( type == 'object' ) {
if ( type == 'object' ) {
@ -547,7 +550,7 @@ exports.getType = function(object) {
* @ param newValue
* @ param newValue
* @ returns { Array }
* @ returns { Array }
* /
* /
exports . copyAndExtendArray = function ( arr , newValue ) {
exports . copyAndExtendArray = function ( arr , newValue ) {
let newArr = [ ] ;
let newArr = [ ] ;
for ( let i = 0 ; i < arr . length ; i ++ ) {
for ( let i = 0 ; i < arr . length ; i ++ ) {
newArr . push ( arr [ i ] ) ;
newArr . push ( arr [ i ] ) ;
@ -563,7 +566,7 @@ exports.copyAndExtendArray = function(arr,newValue) {
* @ param newValue
* @ param newValue
* @ returns { Array }
* @ returns { Array }
* /
* /
exports . copyArray = function ( arr ) {
exports . copyArray = function ( arr ) {
let newArr = [ ] ;
let newArr = [ ] ;
for ( let i = 0 ; i < arr . length ; i ++ ) {
for ( let i = 0 ; i < arr . length ; i ++ ) {
newArr . push ( arr [ i ] ) ;
newArr . push ( arr [ i ] ) ;
@ -577,7 +580,7 @@ exports.copyArray = function(arr) {
* @ return { number } left The absolute left position of this element
* @ return { number } left The absolute left position of this element
* in the browser page .
* in the browser page .
* /
* /
exports . getAbsoluteLeft = function ( elem ) {
exports . getAbsoluteLeft = function ( elem ) {
return elem . getBoundingClientRect ( ) . left ;
return elem . getBoundingClientRect ( ) . left ;
} ;
} ;
@ -587,7 +590,7 @@ exports.getAbsoluteLeft = function(elem) {
* @ return { number } top The absolute top position of this element
* @ return { number } top The absolute top position of this element
* in the browser page .
* in the browser page .
* /
* /
exports . getAbsoluteTop = function ( elem ) {
exports . getAbsoluteTop = function ( elem ) {
return elem . getBoundingClientRect ( ) . top ;
return elem . getBoundingClientRect ( ) . top ;
} ;
} ;
@ -596,7 +599,7 @@ exports.getAbsoluteTop = function(elem) {
* @ param { Element } elem
* @ param { Element } elem
* @ param { String } className
* @ param { String } className
* /
* /
exports . addClassName = function ( elem , className ) {
exports . addClassName = function ( elem , className ) {
var classes = elem . className . split ( ' ' ) ;
var classes = elem . className . split ( ' ' ) ;
if ( classes . indexOf ( className ) == - 1 ) {
if ( classes . indexOf ( className ) == - 1 ) {
classes . push ( className ) ; // add the class to the array
classes . push ( className ) ; // add the class to the array
@ -609,7 +612,7 @@ exports.addClassName = function(elem, className) {
* @ param { Element } elem
* @ param { Element } elem
* @ param { String } className
* @ param { String } className
* /
* /
exports . removeClassName = function ( elem , className ) {
exports . removeClassName = function ( elem , className ) {
var classes = elem . className . split ( ' ' ) ;
var classes = elem . className . split ( ' ' ) ;
var index = classes . indexOf ( className ) ;
var index = classes . indexOf ( className ) ;
if ( index != - 1 ) {
if ( index != - 1 ) {
@ -627,9 +630,9 @@ exports.removeClassName = function(elem, className) {
* the object or array with three parameters :
* the object or array with three parameters :
* callback ( value , index , object )
* callback ( value , index , object )
* /
* /
exports . forEach = function ( object , callback ) {
exports . forEach = function ( object , callback ) {
var i ,
var i ,
len ;
len ;
if ( Array . isArray ( object ) ) {
if ( Array . isArray ( object ) ) {
// array
// array
for ( i = 0 , len = object . length ; i < len ; i ++ ) {
for ( i = 0 , len = object . length ; i < len ; i ++ ) {
@ -652,7 +655,7 @@ exports.forEach = function(object, callback) {
* @ param { Object } object
* @ param { Object } object
* @ param { Array } array
* @ param { Array } array
* /
* /
exports . toArray = function ( object ) {
exports . toArray = function ( object ) {
var array = [ ] ;
var array = [ ] ;
for ( var prop in object ) {
for ( var prop in object ) {
@ -669,7 +672,7 @@ exports.toArray = function(object) {
* @ param { * } value
* @ param { * } value
* @ return { Boolean } changed
* @ return { Boolean } changed
* /
* /
exports . updateProperty = function ( object , key , value ) {
exports . updateProperty = function ( object , key , value ) {
if ( object [ key ] !== value ) {
if ( object [ key ] !== value ) {
object [ key ] = value ;
object [ key ] = value ;
return true ;
return true ;
@ -687,7 +690,7 @@ exports.updateProperty = function(object, key, value) {
* @ param { function } listener The callback function to be executed
* @ param { function } listener The callback function to be executed
* @ param { boolean } [ useCapture ]
* @ param { boolean } [ useCapture ]
* /
* /
exports . addEventListener = function ( element , action , listener , useCapture ) {
exports . addEventListener = function ( element , action , listener , useCapture ) {
if ( element . addEventListener ) {
if ( element . addEventListener ) {
if ( useCapture === undefined )
if ( useCapture === undefined )
useCapture = false ;
useCapture = false ;
@ -709,7 +712,7 @@ exports.addEventListener = function(element, action, listener, useCapture) {
* @ param { function } listener The listener function
* @ param { function } listener The listener function
* @ param { boolean } [ useCapture ]
* @ param { boolean } [ useCapture ]
* /
* /
exports . removeEventListener = function ( element , action , listener , useCapture ) {
exports . removeEventListener = function ( element , action , listener , useCapture ) {
if ( element . removeEventListener ) {
if ( element . removeEventListener ) {
// non-IE browsers
// non-IE browsers
if ( useCapture === undefined )
if ( useCapture === undefined )
@ -746,7 +749,7 @@ exports.preventDefault = function (event) {
* @ param { Event } event
* @ param { Event } event
* @ return { Element } target element
* @ return { Element } target element
* /
* /
exports . getTarget = function ( event ) {
exports . getTarget = function ( event ) {
// code from http://www.quirksmode.org/js/events_properties.html
// code from http://www.quirksmode.org/js/events_properties.html
if ( ! event ) {
if ( ! event ) {
event = window . event ;
event = window . event ;
@ -885,17 +888,17 @@ exports.option.asElement = function (value, defaultValue) {
* @ param { String } hex
* @ param { String } hex
* @ returns { { r : * , g : * , b : * } } | 255 range
* @ returns { { r : * , g : * , b : * } } | 255 range
* /
* /
exports . hexToRGB = function ( hex ) {
exports . hexToRGB = function ( hex ) {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i ;
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i ;
hex = hex . replace ( shorthandRegex , function ( m , r , g , b ) {
return r + r + g + g + b + b ;
hex = hex . replace ( shorthandRegex , function ( m , r , g , b ) {
return r + r + g + g + b + b ;
} ) ;
} ) ;
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i . exec ( hex ) ;
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i . exec ( hex ) ;
return result ? {
return result ? {
r : parseInt ( result [ 1 ] , 16 ) ,
g : parseInt ( result [ 2 ] , 16 ) ,
b : parseInt ( result [ 3 ] , 16 )
r : parseInt ( result [ 1 ] , 16 ) ,
g : parseInt ( result [ 2 ] , 16 ) ,
b : parseInt ( result [ 3 ] , 16 )
} : null ;
} : null ;
} ;
} ;
@ -905,12 +908,12 @@ exports.hexToRGB = function(hex) {
* @ param opacity
* @ param opacity
* @ returns { * }
* @ returns { * }
* /
* /
exports . overrideOpacity = function ( color , opacity ) {
exports . overrideOpacity = function ( color , opacity ) {
if ( color . indexOf ( "rgba" ) != - 1 ) {
if ( color . indexOf ( "rgba" ) != - 1 ) {
return color ;
return color ;
}
}
else if ( color . indexOf ( "rgb" ) != - 1 ) {
else if ( color . indexOf ( "rgb" ) != - 1 ) {
var rgb = color . substr ( color . indexOf ( "(" ) + 1 ) . replace ( ")" , "" ) . split ( "," ) ;
var rgb = color . substr ( color . indexOf ( "(" ) + 1 ) . replace ( ")" , "" ) . split ( "," ) ;
return "rgba(" + rgb [ 0 ] + "," + rgb [ 1 ] + "," + rgb [ 2 ] + "," + opacity + ")"
return "rgba(" + rgb [ 0 ] + "," + rgb [ 1 ] + "," + rgb [ 2 ] + "," + opacity + ")"
}
}
else {
else {
@ -932,7 +935,7 @@ exports.overrideOpacity = function(color,opacity) {
* @ returns { string }
* @ returns { string }
* @ constructor
* @ constructor
* /
* /
exports . RGBToHex = function ( red , green , blue ) {
exports . RGBToHex = function ( red , green , blue ) {
return "#" + ( ( 1 << 24 ) + ( red << 16 ) + ( green << 8 ) + blue ) . toString ( 16 ) . slice ( 1 ) ;
return "#" + ( ( 1 << 24 ) + ( red << 16 ) + ( green << 8 ) + blue ) . toString ( 16 ) . slice ( 1 ) ;
} ;
} ;
@ -942,43 +945,43 @@ exports.RGBToHex = function(red,green,blue) {
* @ param { Object | String } color
* @ param { Object | String } color
* @ return { Object } colorObject
* @ return { Object } colorObject
* /
* /
exports . parseColor = function ( color ) {
exports . parseColor = function ( color ) {
var c ;
var c ;
if ( exports . isString ( color ) === true ) {
if ( exports . isString ( color ) === true ) {
if ( exports . isValidRGB ( color ) === true ) {
if ( exports . isValidRGB ( color ) === true ) {
var rgb = color . substr ( 4 ) . substr ( 0 , color . length - 5 ) . split ( ',' ) . map ( function ( value ) { return parseInt ( value ) } ) ;
color = exports . RGBToHex ( rgb [ 0 ] , rgb [ 1 ] , rgb [ 2 ] ) ;
var rgb = color . substr ( 4 ) . substr ( 0 , color . length - 5 ) . split ( ',' ) . map ( function ( value ) { return parseInt ( value ) } ) ;
color = exports . RGBToHex ( rgb [ 0 ] , rgb [ 1 ] , rgb [ 2 ] ) ;
}
}
if ( exports . isValidHex ( color ) === true ) {
if ( exports . isValidHex ( color ) === true ) {
var hsv = exports . hexToHSV ( color ) ;
var hsv = exports . hexToHSV ( color ) ;
var lighterColorHSV = { h : hsv . h , s : hsv . s * 0.8 , v : Math . min ( 1 , hsv . v * 1.02 ) } ;
var darkerColorHSV = { h : hsv . h , s : Math . min ( 1 , hsv . s * 1.25 ) , v : hsv . v * 0.8 } ;
var darkerColorHex = exports . HSVToHex ( darkerColorHSV . h , darkerColorHSV . s , darkerColorHSV . v ) ;
var lighterColorHex = exports . HSVToHex ( lighterColorHSV . h , lighterColorHSV . s , lighterColorHSV . v ) ;
var lighterColorHSV = { h : hsv . h , s : hsv . s * 0.8 , v : Math . min ( 1 , hsv . v * 1.02 ) } ;
var darkerColorHSV = { h : hsv . h , s : Math . min ( 1 , hsv . s * 1.25 ) , v : hsv . v * 0.8 } ;
var darkerColorHex = exports . HSVToHex ( darkerColorHSV . h , darkerColorHSV . s , darkerColorHSV . v ) ;
var lighterColorHex = exports . HSVToHex ( lighterColorHSV . h , lighterColorHSV . s , lighterColorHSV . v ) ;
c = {
c = {
background : color ,
background : color ,
border : darkerColorHex ,
border : darkerColorHex ,
highlight : {
highlight : {
background : lighterColorHex ,
border : darkerColorHex
background : lighterColorHex ,
border : darkerColorHex
} ,
} ,
hover : {
hover : {
background : lighterColorHex ,
border : darkerColorHex
background : lighterColorHex ,
border : darkerColorHex
}
}
} ;
} ;
}
}
else {
else {
c = {
c = {
background : color ,
border : color ,
background : color ,
border : color ,
highlight : {
highlight : {
background : color ,
border : color
background : color ,
border : color
} ,
} ,
hover : {
hover : {
background : color ,
border : color
background : color ,
border : color
}
}
} ;
} ;
}
}
@ -1027,23 +1030,23 @@ exports.parseColor = function(color) {
* @ returns { * }
* @ returns { * }
* @ constructor
* @ constructor
* /
* /
exports . RGBToHSV = function ( red , green , blue ) {
red = red / 255 ; green = green / 255 ; blue = blue / 255 ;
var minRGB = Math . min ( red , Math . min ( green , blue ) ) ;
var maxRGB = Math . max ( red , Math . max ( green , blue ) ) ;
exports . RGBToHSV = function ( red , green , blue ) {
red = red / 255 ; green = green / 255 ; blue = blue / 255 ;
var minRGB = Math . min ( red , Math . min ( green , blue ) ) ;
var maxRGB = Math . max ( red , Math . max ( green , blue ) ) ;
// Black-gray-white
// Black-gray-white
if ( minRGB == maxRGB ) {
if ( minRGB == maxRGB ) {
return { h : 0 , s : 0 , v : minRGB } ;
return { h : 0 , s : 0 , v : minRGB } ;
}
}
// Colors other than black-gray-white:
// Colors other than black-gray-white:
var d = ( red == minRGB ) ? green - blue : ( ( blue == minRGB ) ? red - green : blue - red ) ;
var h = ( red == minRGB ) ? 3 : ( ( blue == minRGB ) ? 1 : 5 ) ;
var hue = 60 * ( h - d / ( maxRGB - minRGB ) ) / 360 ;
var saturation = ( maxRGB - minRGB ) / maxRGB ;
var d = ( red == minRGB ) ? green - blue : ( ( blue == minRGB ) ? red - green : blue - red ) ;
var h = ( red == minRGB ) ? 3 : ( ( blue == minRGB ) ? 1 : 5 ) ;
var hue = 60 * ( h - d / ( maxRGB - minRGB ) ) / 360 ;
var saturation = ( maxRGB - minRGB ) / maxRGB ;
var value = maxRGB ;
var value = maxRGB ;
return { h : hue , s : saturation , v : value } ;
return { h : hue , s : saturation , v : value } ;
} ;
} ;
var cssUtil = {
var cssUtil = {
@ -1066,10 +1069,10 @@ var cssUtil = {
// build a css text string from an object with key/values
// build a css text string from an object with key/values
join : function ( styles ) {
join : function ( styles ) {
return Object . keys ( styles )
return Object . keys ( styles )
. map ( function ( key ) {
return key + ': ' + styles [ key ] ;
} )
. join ( '; ' ) ;
. map ( function ( key ) {
return key + ': ' + styles [ key ] ;
} )
. join ( '; ' ) ;
}
}
} ;
} ;
@ -1112,7 +1115,7 @@ exports.removeCssText = function (element, cssText) {
* @ returns { { r : number , g : number , b : number } }
* @ returns { { r : number , g : number , b : number } }
* @ constructor
* @ constructor
* /
* /
exports . HSVToRGB = function ( h , s , v ) {
exports . HSVToRGB = function ( h , s , v ) {
var r , g , b ;
var r , g , b ;
var i = Math . floor ( h * 6 ) ;
var i = Math . floor ( h * 6 ) ;
@ -1130,31 +1133,31 @@ exports.HSVToRGB = function(h, s, v) {
case 5 : r = v , g = p , b = q ; break ;
case 5 : r = v , g = p , b = q ; break ;
}
}
return { r : Math . floor ( r * 255 ) , g : Math . floor ( g * 255 ) , b : Math . floor ( b * 255 ) } ;
return { r : Math . floor ( r * 255 ) , g : Math . floor ( g * 255 ) , b : Math . floor ( b * 255 ) } ;
} ;
} ;
exports . HSVToHex = function ( h , s , v ) {
exports . HSVToHex = function ( h , s , v ) {
var rgb = exports . HSVToRGB ( h , s , v ) ;
var rgb = exports . HSVToRGB ( h , s , v ) ;
return exports . RGBToHex ( rgb . r , rgb . g , rgb . b ) ;
return exports . RGBToHex ( rgb . r , rgb . g , rgb . b ) ;
} ;
} ;
exports . hexToHSV = function ( hex ) {
exports . hexToHSV = function ( hex ) {
var rgb = exports . hexToRGB ( hex ) ;
var rgb = exports . hexToRGB ( hex ) ;
return exports . RGBToHSV ( rgb . r , rgb . g , rgb . b ) ;
return exports . RGBToHSV ( rgb . r , rgb . g , rgb . b ) ;
} ;
} ;
exports . isValidHex = function ( hex ) {
exports . isValidHex = function ( hex ) {
var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i . test ( hex ) ;
var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i . test ( hex ) ;
return isOk ;
return isOk ;
} ;
} ;
exports . isValidRGB = function ( rgb ) {
rgb = rgb . replace ( " " , "" ) ;
exports . isValidRGB = function ( rgb ) {
rgb = rgb . replace ( " " , "" ) ;
var isOk = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i . test ( rgb ) ;
var isOk = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i . test ( rgb ) ;
return isOk ;
return isOk ;
}
}
exports . isValidRGBA = function ( rgba ) {
rgba = rgba . replace ( " " , "" ) ;
exports . isValidRGBA = function ( rgba ) {
rgba = rgba . replace ( " " , "" ) ;
var isOk = /rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i . test ( rgba ) ;
var isOk = /rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i . test ( rgba ) ;
return isOk ;
return isOk ;
}
}
@ -1166,7 +1169,7 @@ exports.isValidRGBA = function(rgba) {
* @ param referenceObject
* @ param referenceObject
* @ returns { * }
* @ returns { * }
* /
* /
exports . selectiveBridgeObject = function ( fields , referenceObject ) {
exports . selectiveBridgeObject = function ( fields , referenceObject ) {
if ( typeof referenceObject == "object" ) {
if ( typeof referenceObject == "object" ) {
var objectTo = Object . create ( referenceObject ) ;
var objectTo = Object . create ( referenceObject ) ;
for ( var i = 0 ; i < fields . length ; i ++ ) {
for ( var i = 0 ; i < fields . length ; i ++ ) {
@ -1190,7 +1193,7 @@ exports.selectiveBridgeObject = function(fields, referenceObject) {
* @ param referenceObject
* @ param referenceObject
* @ returns { * }
* @ returns { * }
* /
* /
exports . bridgeObject = function ( referenceObject ) {
exports . bridgeObject = function ( referenceObject ) {
if ( typeof referenceObject == "object" ) {
if ( typeof referenceObject == "object" ) {
var objectTo = Object . create ( referenceObject ) ;
var objectTo = Object . create ( referenceObject ) ;
for ( var i in referenceObject ) {
for ( var i in referenceObject ) {
@ -1253,7 +1256,7 @@ exports.mergeOptions = function (mergeTarget, options, option, allowDeletion = f
* @ returns { number }
* @ returns { number }
* @ private
* @ private
* /
* /
exports . binarySearchCustom = function ( orderedItems , searchFunction , field , field2 ) {
exports . binarySearchCustom = function ( orderedItems , searchFunction , field , field2 ) {
var maxIterations = 10000 ;
var maxIterations = 10000 ;
var iteration = 0 ;
var iteration = 0 ;
var low = 0 ;
var low = 0 ;
@ -1294,7 +1297,7 @@ exports.binarySearchCustom = function(orderedItems, searchFunction, field, field
* @ returns { number }
* @ returns { number }
* @ private
* @ private
* /
* /
exports . binarySearchValue = function ( orderedItems , target , field , sidePreference ) {
exports . binarySearchValue = function ( orderedItems , target , field , sidePreference ) {
var maxIterations = 10000 ;
var maxIterations = 10000 ;
var iteration = 0 ;
var iteration = 0 ;
var low = 0 ;
var low = 0 ;
@ -1303,19 +1306,19 @@ exports.binarySearchValue = function(orderedItems, target, field, sidePreference
while ( low <= high && iteration < maxIterations ) {
while ( low <= high && iteration < maxIterations ) {
// get a new guess
// get a new guess
middle = Math . floor ( 0.5 * ( high + low ) ) ;
prevValue = orderedItems [ Math . max ( 0 , middle - 1 ) ] [ field ] ;
value = orderedItems [ middle ] [ field ] ;
nextValue = orderedItems [ Math . min ( orderedItems . length - 1 , middle + 1 ) ] [ field ] ;
middle = Math . floor ( 0.5 * ( high + low ) ) ;
prevValue = orderedItems [ Math . max ( 0 , middle - 1 ) ] [ field ] ;
value = orderedItems [ middle ] [ field ] ;
nextValue = orderedItems [ Math . min ( orderedItems . length - 1 , middle + 1 ) ] [ field ] ;
if ( value == target ) { // we found the target
if ( value == target ) { // we found the target
return middle ;
return middle ;
}
}
else if ( prevValue < target && value > target ) { // target is in between of the previous and the current
else if ( prevValue < target && value > target ) { // target is in between of the previous and the current
return sidePreference == 'before' ? Math . max ( 0 , middle - 1 ) : middle ;
return sidePreference == 'before' ? Math . max ( 0 , middle - 1 ) : middle ;
}
}
else if ( value < target && nextValue > target ) { // target is in between of the current and the next
else if ( value < target && nextValue > target ) { // target is in between of the current and the next
return sidePreference == 'before' ? middle : Math . min ( orderedItems . length - 1 , middle + 1 ) ;
return sidePreference == 'before' ? middle : Math . min ( orderedItems . length - 1 , middle + 1 ) ;
}
}
else { // didnt find the target, we need to change our boundaries.
else { // didnt find the target, we need to change our boundaries.
if ( value < target ) { // it is too small --> increase low
if ( value < target ) { // it is too small --> increase low