Utils Class
Item Index
Methods
Properties
Methods
_applyInterval
-
id -
callback -
interval -
scope
use Firebrick.utils:setInterval()
Parameters:
-
idString(optional)
-
callbackFunction -
intervalInterger -
scopeObject
Returns:
id
_containerNS
()
String | Null
private
used by getPathFromName
Returns:
argsToArray
-
args
convert arguments array to nomral array
Parameters:
-
argsArguments Array
Returns:
clearInterval
-
id
clear the interval running by id
Parameters:
-
idString
clearSplash
()
private
removes splash tag $("#fb-splash")
compareArrays
-
array1 -
array2
multidimensional array comparison inspired by: http://stackoverflow.com/a/14853974/425226
Parameters:
-
array1Object -
array2Object
Returns:
true is they are identical
copyover
-
obj1 -
obj2
unlike overwrite it does not overwrite any properties that are already in obj1
Parameters:
-
obj1Object -
obj2Object
Returns:
obj2 mixed in missing property into obj1
dataFor
()
shortcut for knockout.dataFor
Returns:
knockout.dataFor
delay
-
callback -
timeout -
args -
scope
Javascript setTimout function
Parameters:
-
callbackFunction -
timeoutIntegermiliseconds
-
argsAnypass to delay function
-
scopeObject(optional) scope of the callback function. Defaults to: window
Example:
delay(function(){}, 1000, scope);
firstToUpper
-
str
Parameters:
-
strString
Returns:
first character in string uppercase
getDeepProperty
-
property -
obj
returns a deep property from an object fails silently and returns null
Parameters:
-
propertyString -
objObject
Returns:
property value
Example:
//get property "where.street" obj = { where: { street: "Some Street" } }
getPathFromName
-
name -
ext
Converts a name like "MyApp.controller.MyController" to a path MyApp/controller/MyController.js
Parameters:
-
nameString -
extString[default=''] extension
Returns:
initSplash
-
html
html is appended to the $("html") tag before the document is ready used by Firebrick:ready
Parameters:
-
htmlString
Example:
Firebrick.ready({
splash:"<div></div>"
});
isIntervalRunning
-
id
Check whether interval already exists
Parameters:
-
idString
Returns:
interval function
loadCSS
-
url
load css file and append to HEAD
Parameters:
-
urlString
merge
-
propName -
object -
a
recursively iterate over prototypes and merge all the properties of an object together from its inherited parents for a specified property (name)
Parameters:
-
propNameStringname of property to merge
-
objectObjectobject/class to iterate through
-
aObject(optional) used when calling itself recursively
Returns:
object : same object with property (name) merged
Example:
merge("a", {a:{a:"s"},__proto__:{a:{a:1, b:2, c:3}}})
//returns {a:{a:"s", b:2, c:3},__proto__:{a:{a:1, b:2, c:3}}}
mergeArrays
-
any
Parameters:
-
anyArray | Argument Arraysnumber - ignores null
Returns:
overwrite
-
obj1 -
obj2
overwrite properties in {obj1} with properties from {obj2} (mixin)
Parameters:
-
obj1Object -
obj2Object
Returns:
obj1 mixed in with obj2
require
-
name -
callback
Get a script/file from path
Parameters:
-
nameString, Array of StringsMyApp.controller.MyController
-
callbackFunction(optional) called when last require has completed or failed
Returns:
the files that were eventually loaded
Example:
require("MyApp.controller.MyController", function(){}, true, "html", "js");
setInterval
-
id -
callback -
timeout -
scope
set an interval and prevent any duplicates
Parameters:
-
idString(optional)
-
callbackFunction- callback gets this.id, this.stop()
-
timeoutIntegermiliseconds
-
scopeObjectscope to apply to the callback
stripArguments
-
args
Parameters:
-
argsObject
Returns:
Example:
var a = function(){
//arguments are [["a"]]
return stripArguments(arguments) //return ["a"]
}
var b = function(){
return a(arguments); //note not called with apply
}
b("a")
used to strip the arguments "array" inside an wrapper "array" - http://jsfiddle.net/smasala/ppdtLmag/
uniqId
()
String
returns a unique id: http://stackoverflow.com/a/19223188
Returns:
unique id
Properties
_globalC
Unknown
private
intervalRegistry
Object map
private
keep track of all the interval functions running
requiredFiles
Object map
private
keep track of all require requests
splashCleared
Object map
private
used by init&Clear Splash
